Merge branch 'master' into 1.16

# Conflicts:
#	src/main/java/carpet/mixins/ChunkTicketManager_scarpetMixin.java
#	src/main/java/carpet/mixins/MinecraftServer_coreMixin.java
This commit is contained in:
gnembon committed 2020-04-13 01:08:06 -03:00
commit 7ebc96106b
26 files changed
+354 -83

No files matched your search

+10 -1
View File
@@ -276,7 +276,8 @@ global_foo = floor(rand(10));
check_foo_not_zero();
...
check_foo_not_zero() -> if(global_foo == 0, global_foo = 1)
</pre># Variables and Constants
</pre>
# Variables and Constants
`scarpet` provides a number of constants that can be used literally in scripts
@@ -2055,6 +2056,10 @@ Returns generation status as per the ticket system. Can return any value from se
can only be stable in a few states: `full`, `features`, `liquid_carvers`, and `structure_starts`. Returns `null`
if the chunk is not in memory unless called with optional `true`.
### `inhabited_time(pos)`
Returns inhabited time for a chunk.
### `structures(pos), structures(pos, structure_name)`
Returns structure information for a given block position. Note that structure information is the same for all the
@@ -2872,6 +2877,10 @@ __on_player_interacts_with_block(player, hand, block, face, hitvec) //right cli
__on_player_places_block(player, item_tuple, hand, block) // player have just placed the block.
__on_player_interacts_with_entity(player, entity, hand)
__on_player_attacks_entity(player, entity)
__on_player_takes_damage(player, amount, source, source_entity)
__on_player_deals_damage(player, amount, entity)
__on_player_dies(player)
__on_player_respawns(player)
__on_player_rides(player, forward, strafe, jumping, sneaking)
__on_player_jumps(player)
__on_player_deploys_elytra(player)
+4
View File
@@ -519,6 +519,10 @@ Returns generation status as per the ticket system. Can return any value from se
can only be stable in a few states: `full`, `features`, `liquid_carvers`, and `structure_starts`. Returns `null`
if the chunk is not in memory unless called with optional `true`.
### `inhabited_time(pos)`
Returns inhabited time for a chunk.
### `structures(pos), structures(pos, structure_name)`
Returns structure information for a given block position. Note that structure information is the same for all the
+4
View File
@@ -33,6 +33,10 @@ __on_player_interacts_with_block(player, hand, block, face, hitvec) //right cli
__on_player_places_block(player, item_tuple, hand, block) // player have just placed the block.
__on_player_interacts_with_entity(player, entity, hand)
__on_player_attacks_entity(player, entity)
__on_player_takes_damage(player, amount, source, source_entity)
__on_player_deals_damage(player, amount, entity)
__on_player_dies(player)
__on_player_respawns(player)
__on_player_rides(player, forward, strafe, jumping, sneaking)
__on_player_jumps(player)
__on_player_deploys_elytra(player)
+1 -1
View File
@@ -276,4 +276,4 @@ global_foo = floor(rand(10));
check_foo_not_zero();
...
check_foo_not_zero() -> if(global_foo == 0, global_foo = 1)
</pre>
</pre>
@@ -30,6 +30,7 @@ hardness
harvest
in_dimension
in_slime_chunk
inhabited_time
inventory_find
inventory_get
inventory_remove
+5 -1
View File
@@ -25,4 +25,8 @@ __on_player_wakes_up
__on_statistic
__on_tick
__on_tick_ender
__on_tick_nether
__on_tick_nether
__on_player_takes_damage
__on_player_deals_damage
__on_player_dies
__on_player_respawns
@@ -54,7 +54,7 @@
hardness blast_resistance top loaded suffocates power ticks_randomly update block_tick random_tick in_slime_chunk
set without_updates
blocks_movement block_sound material map_colour property block_properties block_data poi set_poi
place_item set_biome biome loaded_status generation_status chunk_tickets
place_item set_biome biome loaded_status generation_status inhabited_time chunk_tickets
structures structure_references set_structure reset_chunk
scoreboard scoreboard_add scoreboard_remove scoreboard_display
@@ -104,6 +104,10 @@
__on_tick
__on_tick_ender
__on_tick_nether
__on_player_takes_damage
__on_player_deals_damage
__on_player_dies
__on_player_respawns
</Keywords>
<Keywords name="Keywords8">$</Keywords>
<Keywords name="Delimiters">00&apos; 01\ 02&apos; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
+27 -53
View File
@@ -5,13 +5,11 @@ import carpet.settings.Rule;
import carpet.settings.SettingsManager;
import carpet.settings.Validator;
import carpet.utils.Messenger;
import carpet.utils.SpawnChunks;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.world.ChunkTicketType;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.ChunkPos;
@@ -236,13 +234,6 @@ public class CarpetSettings
@Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
public static boolean movableBlockEntities = false;
/*@Rule(
desc = "Orange stained glass behaves like slime, but doesn't stick to it",
extra = "Only available for 1.14. in 1.15 use honey instead",
category = {EXPERIMENTAL, FEATURE}
)
public static boolean honeySlime = false;*/
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
public static boolean desertShrubs = false;
@@ -359,9 +350,6 @@ public class CarpetSettings
)
public static boolean missingTools = false;
//@Rule(desc = "Alternative, persistent caching strategy for nether portals", category = {SURVIVAL, CREATIVE})
//public static boolean portalCaching = false; // ineffective in 1.15
@Rule(desc = "fill/clone/setblock and structure blocks cause block updates", category = CREATIVE)
public static boolean fillUpdates = true;
@@ -512,13 +500,9 @@ public class CarpetSettings
)
public static int viewDistance = 0;
private static class DisableSpawnChunksValidator extends Validator<Boolean> {
@Override public Boolean validate(ServerCommandSource source, ParsedRule<Boolean> currentRule, Boolean newValue, String string) {
if (currentRule.get().booleanValue() == newValue.booleanValue())
{
//must been some startup thing
return newValue;
}
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
public static void changeSpawnSize(int size)
{
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
if (overworld != null) {
ChunkPos centerChunk = new ChunkPos(new BlockPos(
@@ -526,40 +510,37 @@ public class CarpetSettings
overworld.getLevelProperties().getSpawnY(),
overworld.getLevelProperties().getSpawnZ()
));
ServerChunkManager chunkManager = (ServerChunkManager) overworld.getChunkManager();
chunkManager.removeTicket(ChunkTicketType.START, centerChunk, 11, Unit.INSTANCE);
if (!newValue)
{
chunkManager.addTicket(ChunkTicketType.START, centerChunk, 11, Unit.INSTANCE);
}
SpawnChunks.changeSpawnChunks(overworld.getChunkManager(), centerChunk, size);
}
}
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r spawn chunk size has to be between 0 and 32");
return null;
}
if (currentRule.get().intValue() == newValue.intValue())
{
//must been some startup thing
return newValue;
}
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
if (currentOverworld != null)
{
changeSpawnSize(newValue);
}
return newValue;
}
}
@Rule(
desc = "Allows spawn chunks to unload",
desc = "Changes size of spawn chunks",
extra = {"Defines new radius", "setting it to 0 - disables spawn chunks"},
category = CREATIVE,
validate = DisableSpawnChunksValidator.class
)
public static boolean disableSpawnChunks = false;
/*private static class KelpLimit extends Validator<Integer>
{
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>=0 && newValue <=25)?newValue:null;
}
@Override
public String description() { return "You must choose a value from 0 to 25. 25 and all natural kelp can grow 25 blocks, choose 0 to make all generated kelp not to grow";}
}
@Rule(
desc = "limits growth limit of newly naturally generated kelp to this amount of blocks",
options = {"0", "2", "25"},
category = FEATURE,
strict = false,
validate = KelpLimit.class
options = {"0", "11"},
validate = ChangeSpawnChunksValidator.class
)
public static int kelpGenerationGrowthLimit = 25;*/
public static int spawnChunksSize = 11;
@Rule(desc = "Coral structures will grow with bonemeal from coral plants", category = FEATURE)
public static boolean renewableCoral = false;
@@ -576,13 +557,6 @@ public class CarpetSettings
@Rule(desc = "Spawning requires much less CPU and Memory", category = OPTIMIZATION)
public static boolean lagFreeSpawning = false;
//@Rule(
// desc = "Prevents horses and other mobs to wander into the distance after dismounting",
// extra = "Fixes issues with various Joergens wandering off and disappearing client-side",
// category = BUGFIX
//)
//public static boolean horseWanderingFix = false;
@Rule(
desc = "Allows structure mobs to spawn in flat worlds",
@@ -296,6 +296,14 @@ public class PlayerCommand
Messenger.m(context.getSource(), "r Cannot shadow fake players");
return 0;
}
ServerPlayerEntity sendingPlayer = null;
try
{
sendingPlayer = context.getSource().getPlayer();
}
catch (CommandSyntaxException ignored) { }
if (sendingPlayer!=player && cantManipulate(context)) return 0;
EntityPlayerMPFake.createShadow(player.server, player);
return 1;
}
@@ -0,0 +1,12 @@
package carpet.fakes;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.world.ChunkTicket;
import net.minecraft.util.SortedArraySet;
import net.minecraft.util.math.ChunkPos;
public interface ChunkTicketManagerInterface
{
void changeSpawnChunks(ChunkPos pos, int distance);
Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> getTicketsByPosition();
}
@@ -0,0 +1,8 @@
package carpet.fakes;
import net.minecraft.server.world.ChunkTicketManager;
public interface ServerChunkManagerInterface
{
ChunkTicketManager getTicketManager();
}
@@ -1,15 +1,23 @@
package carpet.mixins;
import carpet.fakes.ChunkTicketManagerInterface;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.world.ChunkTicket;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.util.collection.SortedArraySet;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(ChunkTicketManager.class)
public interface ChunkTicketManager_scarpetMixin
public abstract class ChunkTicketManager_scarpetMixin implements ChunkTicketManagerInterface
{
@Accessor
Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> getTicketsByPosition();
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> ticketsByPosition;
@Override
public Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> getTicketsByPosition()
{
return ticketsByPosition;
}
}
@@ -0,0 +1,60 @@
package carpet.mixins;
import carpet.fakes.ChunkTicketManagerInterface;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.world.ChunkTicket;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ChunkTicketType;
import net.minecraft.util.SortedArraySet;
import net.minecraft.util.Unit;
import net.minecraft.util.math.ChunkPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Iterator;
@Mixin(ChunkTicketManager.class)
public abstract class ChunkTicketManager_spawnChunksMixin implements ChunkTicketManagerInterface
{
@Shadow protected abstract SortedArraySet<ChunkTicket<?>> getTicketSet(long position);
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> ticketsByPosition;
@Shadow public abstract <T> void removeTicket(ChunkTicketType<T> type, ChunkPos pos, int radius, T argument);
@Shadow protected abstract void removeTicket(long pos, ChunkTicket<?> ticket);
@Shadow public abstract <T> void addTicket(ChunkTicketType<T> type, ChunkPos pos, int radius, T argument);
@Override
public void changeSpawnChunks(ChunkPos chunkPos, int distance)
{
long pos = chunkPos.toLong();
SortedArraySet<ChunkTicket<?>> set = ticketsByPosition.get(pos);
ChunkTicket existingTicket = null;
if (set != null)
{
Iterator<ChunkTicket<?>> iter = set.iterator();
while(iter.hasNext())
{
ChunkTicket ticket = iter.next();
if (ticket.getType() == ChunkTicketType.START)
{
existingTicket = ticket;
iter.remove();
}
}
set.add(existingTicket);
}
// the reason we are removing the ticket this way is that there are sideeffects of removal
if (existingTicket != null)
{
removeTicket(pos, existingTicket);
}
// set optionally new spawn ticket
if (distance > 0)
addTicket(ChunkTicketType.START, chunkPos, distance, Unit.INSTANCE);
}
}
@@ -5,6 +5,7 @@ import carpet.script.EntityEventsGroup;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageTracker;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -12,8 +13,11 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE;
import static carpet.script.CarpetEventServer.Event.PLAYER_TAKES_DAMAGE;
@Mixin(DamageTracker.class)
public class DamageTracker_scarpetEventMixin
public abstract class DamageTracker_scarpetEventMixin
{
@Shadow @Final private LivingEntity entity;
@@ -21,5 +25,13 @@ public class DamageTracker_scarpetEventMixin
private void onDamageTaken(DamageSource damageSource_1, float float_1, float float_2, CallbackInfo ci)
{
((EntityInterface)entity).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DAMAGE, entity, float_2, damageSource_1);
if (entity instanceof ServerPlayerEntity && PLAYER_TAKES_DAMAGE.isNeeded())
{
PLAYER_TAKES_DAMAGE.onDamage(entity, float_2, damageSource_1);
}
if (damageSource_1.getAttacker() instanceof ServerPlayerEntity && PLAYER_DEALS_DAMAGE.isNeeded())
{
PLAYER_DEALS_DAMAGE.onDamage(entity, float_2, damageSource_1);
}
}
}
@@ -1,7 +1,10 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import com.google.gson.JsonElement;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListener;
import net.minecraft.world.level.LevelGeneratorOptions;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -40,4 +43,11 @@ public abstract class MinecraftServer_coreMixin
{
CarpetServer.onServerClosed((MinecraftServer) (Object) this);
}
@Inject(method = "prepareStartRegion", at = @At("RETURN"))
private void afterSpawnCreated(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo ci)
{
if (CarpetSettings.spawnChunksSize != 11)
CarpetSettings.ChangeSpawnChunksValidator.changeSpawnSize(CarpetSettings.spawnChunksSize);
}
}
@@ -0,0 +1,21 @@
package carpet.mixins;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static carpet.script.CarpetEventServer.Event.PLAYER_RESPAWNS;
@Mixin(PlayerManager.class)
public class PlayerManager_scarpetEventsMixin
{
@Inject(method = "respawnPlayer", at = @At("HEAD"))
private void onRespawn(ServerPlayerEntity player, DimensionType dimension, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> cir)
{
PLAYER_RESPAWNS.onPlayerEvent(player);
}
}
@@ -1,8 +1,10 @@
package carpet.mixins;
import carpet.fakes.ServerChunkManagerInterface;
import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.entity.EntityCategory;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
@@ -24,12 +26,20 @@ import java.util.HashMap;
import java.util.HashSet;
@Mixin(ServerChunkManager.class)
public abstract class ServerChunkManagerMixin
public abstract class ServerChunkManagerMixin implements ServerChunkManagerInterface
{
@Shadow @Final private ServerWorld world;
@Shadow @Final private static int CHUNKS_ELIGIBLE_FOR_SPAWNING;
@Shadow @Final private ChunkTicketManager ticketManager;
@Override // shared between scarpet and spawnChunks setting
public ChunkTicketManager getTicketManager()
{
return ticketManager;
}
@Inject(
method = "tickChunks",
locals = LocalCapture.CAPTURE_FAILHARD,
@@ -1,13 +0,0 @@
package carpet.mixins;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ServerChunkManager.class)
public interface ServerChunkManager_scarpetMixin
{
@Accessor
ChunkTicketManager getTicketManager();
}
@@ -17,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static carpet.script.CarpetEventServer.Event.PLAYER_DIES;
import static carpet.script.CarpetEventServer.Event.PLAYER_FINISHED_USING_ITEM;
import static carpet.script.CarpetEventServer.Event.STATISTICS;
@@ -61,6 +62,10 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
private void onDeathEvent(DamageSource source, CallbackInfo ci)
{
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, this, source.name);
if (PLAYER_DIES.isNeeded())
{
PLAYER_DIES.onPlayerEvent((ServerPlayerEntity) (Object)this);
}
}
@Redirect(method = "method_14218", at = @At(
@@ -0,0 +1,17 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(ServerWorld.class)
public class ServerWorld_spawnChunksMixin
{
@ModifyConstant(method = "setSpawnPos", constant = @Constant(intValue = 11), expect = 2)
private int pushLimit(int original)
{
return CarpetSettings.spawnChunksSize;
}
}
@@ -12,6 +12,7 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.utils.Messenger;
import net.minecraft.block.BlockState;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -479,6 +480,53 @@ public class CarpetEventServer
handler.call( () -> Collections.singletonList(((c, t) -> new EntityValue(player))), player::getCommandSource);
}
},
PLAYER_TAKES_DAMAGE("player_takes_damage", 4, false)
{
@Override
public void onDamage(Entity target, float amount, DamageSource source)
{
handler.call( () ->
{
return Arrays.asList(
((c, t) -> new EntityValue(target)),
((c, t) -> new NumericValue(amount)),
((c, t) ->new StringValue(source.getName())),
((c, t) -> source.getAttacker()==null?Value.NULL:new EntityValue(source.getAttacker()))
);
}, target::getCommandSource);
}
},
PLAYER_DEALS_DAMAGE("player_deals_damage", 3, false)
{
@Override
public void onDamage(Entity target, float amount, DamageSource source)
{
handler.call( () ->
{
return Arrays.asList(
((c, t) -> new EntityValue(source.getAttacker())),
((c, t) -> new NumericValue(amount)),
((c, t) -> new EntityValue(target))
);
}, () -> source.getAttacker().getCommandSource());
}
},
PLAYER_DIES("player_dies", 1, false)
{
@Override
public void onPlayerEvent(ServerPlayerEntity player)
{
handler.call( () -> Collections.singletonList(((c, t) -> new EntityValue(player))), player::getCommandSource);
}
},
PLAYER_RESPAWNS("player_respawns", 1, false)
{
@Override
public void onPlayerEvent(ServerPlayerEntity player)
{
handler.call( () -> Collections.singletonList(((c, t) -> new EntityValue(player))), player::getCommandSource);
}
},
STATISTICS("statistic", 4, false)
{
private <T> Identifier getStatId(Stat<T> stat)
@@ -551,6 +599,8 @@ public class CarpetEventServer
public void onBlockBroken(ServerPlayerEntity player, BlockPos pos, BlockState previousBS) { }
public void onBlockPlaced(ServerPlayerEntity player, BlockPos pos, Hand enumhand, ItemStack itemstack) { }
public void onEntityAction(ServerPlayerEntity player, Entity entity, Hand enumhand) { }
public void onDamage(Entity target, float amount, DamageSource source) { }
public void onWorldEvent(ServerWorld world, BlockPos pos) { }
public void onWorldEventFlag(ServerWorld world, BlockPos pos, int flag) { }
}
@@ -1,14 +1,14 @@
package carpet.script;
import carpet.CarpetServer;
import carpet.fakes.ChunkTicketManagerInterface;
import carpet.fakes.MinecraftServerInterface;
import carpet.fakes.BiomeArrayInterface;
import carpet.fakes.ServerChunkManagerInterface;
import carpet.fakes.StatTypeInterface;
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
import carpet.helpers.FeatureGenerator;
import carpet.mixins.ChunkTicketManager_scarpetMixin;
import carpet.mixins.PointOfInterest_scarpetMixin;
import carpet.mixins.ServerChunkManager_scarpetMixin;
import carpet.script.Fluff.TriFunction;
import carpet.script.bundled.Module;
import carpet.CarpetSettings;
@@ -707,7 +707,7 @@ public class CarpetExpression
{
ServerWorld world = ((CarpetContext) c).s.getWorld();
Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> levelTickets = (
(ChunkTicketManager_scarpetMixin) ((ServerChunkManager_scarpetMixin) world.getChunkManager())
(ChunkTicketManagerInterface) ((ServerChunkManagerInterface) world.getChunkManager())
.getTicketManager()
).getTicketsByPosition();
List<Value> res = new ArrayList<>();
+12 -3
View File
@@ -657,9 +657,18 @@ public class Expression
throw new InternalExpressionException("Failed to resolve left hand side of the += operation");
}
Value key = ((LContainerValue) v1).getAddress();
Value res = cvi.get(key).add(v2);
cvi.put(key, res);
return (cc, tt) -> res;
Value value = cvi.get(key);
if (value instanceof ListValue || value instanceof MapValue)
{
((AbstractListValue) value).append(v2);
return (cc, tt) -> value;
}
else
{
Value res = value.add(v2);
cvi.put(key, res);
return (cc, tt) -> res;
}
}
v1.assertAssignable();
String varname = v1.getVariable();
@@ -0,0 +1,16 @@
package carpet.utils;
import carpet.fakes.ChunkTicketManagerInterface;
import carpet.fakes.ServerChunkManagerInterface;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.util.math.ChunkPos;
public class SpawnChunks
{
public static void changeSpawnChunks(ServerChunkManager chunkManager, ChunkPos pos, int size)
{
ChunkTicketManager ticketManager = ((ServerChunkManagerInterface)chunkManager).getTicketManager();
((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(pos, size);
}
}
@@ -185,3 +185,38 @@ __on_player_places_block(player, item_tuple, hand, block) ->
print(' > count: '+count);
print(' > nbt: '+nbt);
);
__on_player_takes_damage(player, amount, source, entity) ->
(
print('');
print('__on_player_takes_damage(player, amount, source, source_entity)');
print('player takes damage:');
print(' - player: '+player);
print(' - amount: '+str('%.2f',amount));
print(' - source: '+source);
print(' - source_entity: '+entity);
);
__on_player_deals_damage(player, amount, entity) ->
(
print('');
print('__on_player_deals_damage(player, amount, target)');
print('player deals damage:');
print(' - player: '+player);
print(' - amount: '+str('%.2f',amount));
print(' - target: '+entity);
);
__on_player_dies(player) ->
(
print('');
print('__on_player_dies(player)');
print('Player '+player+' dies.')
);
__on_player_respawns(player) ->
(
print('');
print('__on_player_respawns(player)');
print('Player '+player+' respawns.')
);
+4 -1
View File
@@ -29,6 +29,9 @@
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
"ChunkHolder_scarpetChunkCreationMixin",
"ChunkTicketManager_spawnChunksMixin",
"ServerWorld_spawnChunksMixin",
"MobEntityMixin",
"ServerWorld_unloadedEntityMixin",
"EntityTrackerEntry_leashFixMixin",
@@ -141,9 +144,9 @@
"ServerPlayerEntity_scarpetEventMixin",
"FallingBlockEntity_scarpetEventsMixin",
"BlockItem_scarpetEventMixin",
"PlayerManager_scarpetEventsMixin",
"ChunkTicketManager_scarpetMixin",
"ServerChunkManager_scarpetMixin",
"StatType_scarpetMixin",
"PointOfInterest_scarpetMixin",
"ServerWorld_scarpetEventMixin",