more thread safe carpet globs
This commit is contained in:
1 parent
5d00709b1f
commit
f18cc1c836
19 files changed
+48
-52
No files matched your search
@@ -117,9 +117,7 @@ public class CarpetServer implements ClientModInitializer,DedicatedServerModInit
|
||||
scriptServer.tick();
|
||||
|
||||
//in case something happens
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.currentTelepotingEntityBox = null;
|
||||
CarpetSettings.fixedPosition = null;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
|
||||
extensions.forEach(e -> e.onTick(server));
|
||||
}
|
||||
|
||||
@@ -45,10 +45,8 @@ public class CarpetSettings
|
||||
{
|
||||
public static final String carpetVersion = "1.4.37+v210519";
|
||||
public static final Logger LOG = LogManager.getLogger("carpet");
|
||||
public static boolean skipGenerationChecks = false;
|
||||
public static boolean impendingFillSkipUpdates = false;
|
||||
public static Box currentTelepotingEntityBox = null;
|
||||
public static Vec3d fixedPosition = null;
|
||||
public static ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
|
||||
public static ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
|
||||
public static int runPermissionLevel = 2;
|
||||
public static boolean doChainStone = false;
|
||||
public static boolean chainStoneStickToAll = false;
|
||||
|
||||
@@ -224,7 +224,7 @@ public class DrawCommand
|
||||
continue;
|
||||
}
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
for (int xmod = -1; xmod < 2; xmod += 2)
|
||||
{
|
||||
for (int ymod = -1; ymod < 2; ymod += 2)
|
||||
@@ -238,7 +238,7 @@ public class DrawCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class DrawCommand
|
||||
|
||||
ServerWorld world = source.getWorld();
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
|
||||
for (int r = 0; r < radius; ++r)
|
||||
{
|
||||
@@ -290,7 +290,7 @@ public class DrawCommand
|
||||
}
|
||||
}
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
|
||||
if (CarpetSettings.fillUpdates)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ public class DrawCommand
|
||||
|
||||
ServerWorld world = source.getWorld();
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
|
||||
boolean isSquare = base.equalsIgnoreCase("square");
|
||||
|
||||
@@ -387,7 +387,7 @@ public class DrawCommand
|
||||
affected+= fillFlat(world, pos, i, r, isSquare, orientation, block, replacement, list, mbpos);
|
||||
}
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
|
||||
if (CarpetSettings.fillUpdates) {
|
||||
|
||||
@@ -429,7 +429,7 @@ public class DrawCommand
|
||||
|
||||
ServerWorld world = source.getWorld();
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
|
||||
boolean isSquare = base.equalsIgnoreCase("square");
|
||||
|
||||
@@ -438,7 +438,7 @@ public class DrawCommand
|
||||
affected+= fillFlat(world, pos, i, radius, isSquare, orientation, block, replacement, list, mbpos);
|
||||
}
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
|
||||
if (CarpetSettings.fillUpdates) {
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@ public class ScriptCommand
|
||||
return 1;
|
||||
}
|
||||
int successCount = 0;
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
try
|
||||
{
|
||||
for (int x = area.minX; x <= area.maxX; x++)
|
||||
@@ -535,7 +535,7 @@ public class ScriptCommand
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
Messenger.m(source, "w Expression successful in " + successCount + " out of " + int_1 + " blocks");
|
||||
return successCount;
|
||||
@@ -618,7 +618,7 @@ public class ScriptCommand
|
||||
}
|
||||
int affected = 0;
|
||||
|
||||
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
for (int x = 0; x <= maxx; x++)
|
||||
{
|
||||
for (int y = 0; y <= maxy; y++)
|
||||
@@ -643,7 +643,7 @@ public class ScriptCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
|
||||
if (CarpetSettings.fillUpdates && block != null)
|
||||
{
|
||||
|
||||
@@ -53,9 +53,9 @@ public class BlockRotator
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
boolean retval = flip_block(state, world, player, hand, hit);
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ public class FeatureGenerator
|
||||
ConfiguredFeature<?, ?> feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN).get(id);
|
||||
if (feature != null)
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = true;
|
||||
CarpetSettings.skipGenerationChecks.set(true);
|
||||
try
|
||||
{
|
||||
return feature.generate(world, world.getChunkManager().getChunkGenerator(), world.random, pos);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
CarpetSettings.skipGenerationChecks.set(false);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -99,14 +99,14 @@ public class FeatureGenerator
|
||||
private static Thing simplePlop(ConfiguredFeature feature)
|
||||
{
|
||||
return (w, p) -> {
|
||||
CarpetSettings.skipGenerationChecks=true;
|
||||
CarpetSettings.skipGenerationChecks.set(true);
|
||||
try
|
||||
{
|
||||
return feature.generate(w, w.getChunkManager().getChunkGenerator(), w.random, p);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
CarpetSettings.skipGenerationChecks.set(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BlockStateArgument_fillUpdatesMixin
|
||||
))
|
||||
private BlockState postProcessStateProxy(BlockState state, WorldAccess serverWorld, BlockPos blockPos)
|
||||
{
|
||||
if (CarpetSettings.impendingFillSkipUpdates)
|
||||
if (CarpetSettings.impendingFillSkipUpdates.get())
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ public abstract class ChunkMixin
|
||||
at =@At("HEAD"), cancellable = true)
|
||||
private void squashWarnings(BlockPos blockPos_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.skipGenerationChecks) ci.cancel();
|
||||
if (CarpetSettings.skipGenerationChecks.get()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(ChunkRegion.class)
|
||||
public class ChunkRegion_scarpetPlopMixin
|
||||
{
|
||||
@Inject(method = "markBlockForPostProcessing", at = @At("HEAD"))
|
||||
@Inject(method = "markBlockForPostProcessing", at = @At("HEAD"), cancellable = true)
|
||||
private void markOrNot(BlockPos blockPos, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.skipGenerationChecks) ci.cancel();
|
||||
if (CarpetSettings.skipGenerationChecks.get()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,13 @@ public abstract class CommandManagerMixin
|
||||
private void onExecuteBegin(ServerCommandSource serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
if (!CarpetSettings.fillUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
}
|
||||
|
||||
@Inject(method = "execute", at = @At("RETURN"))
|
||||
private void onExecuteEnd(ServerCommandSource serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void beforeBlockInteracted(PlayerInteractBlockC2SPacket playerInteractBlockC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractBlock", at = @At(
|
||||
@@ -32,7 +32,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void afterBlockInteracted(PlayerInteractBlockC2SPacket playerInteractBlockC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractItem", at = @At(
|
||||
@@ -43,7 +43,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void beforeItemInteracted(PlayerInteractItemC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractItem", at = @At(
|
||||
@@ -54,7 +54,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void afterItemInteracted(PlayerInteractItemC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
@@ -64,7 +64,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void beforeBlockBroken(PlayerActionC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
@@ -75,7 +75,7 @@ public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
private void afterBlockBroken(PlayerActionC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,14 +22,14 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin
|
||||
private void onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, StructurePlacementData placementData, Random random)
|
||||
{
|
||||
if(!CarpetSettings.fillUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
try
|
||||
{
|
||||
structure.place(serverWorldAccess, pos, placementData, random);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
{
|
||||
if (world.isClient())
|
||||
return false;
|
||||
CarpetSettings.skipGenerationChecks = true;
|
||||
CarpetSettings.skipGenerationChecks.set(true);
|
||||
try
|
||||
{
|
||||
Random rand = new Random(world.getRandom().nextInt());
|
||||
@@ -79,7 +79,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
CarpetSettings.skipGenerationChecks.set(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ public class StructurePiece_scarpetPlopMixin
|
||||
))
|
||||
private void markOrNot(Chunk chunk, BlockPos pos)
|
||||
{
|
||||
if (!CarpetSettings.skipGenerationChecks) chunk.markBlockForPostProcessing(pos);
|
||||
if (!CarpetSettings.skipGenerationChecks.get()) chunk.markBlockForPostProcessing(pos);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class Structure_fillUpdatesMixin
|
||||
))
|
||||
private void skipUpdateNeighbours(ServerWorldAccess serverWorldAccess, BlockPos pos, Block block)
|
||||
{
|
||||
if (!CarpetSettings.impendingFillSkipUpdates)
|
||||
if (!CarpetSettings.impendingFillSkipUpdates.get())
|
||||
serverWorldAccess.updateNeighbors(pos, block);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ public class Structure_fillUpdatesMixin
|
||||
))
|
||||
private boolean skipPostprocess(StructurePlacementData structurePlacementData)
|
||||
{
|
||||
return structurePlacementData.shouldUpdateNeighbors() || CarpetSettings.impendingFillSkipUpdates;
|
||||
return structurePlacementData.shouldUpdateNeighbors() || CarpetSettings.impendingFillSkipUpdates.get();
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class WorldChunk_fillUpdatesMixin
|
||||
))
|
||||
private void onAdded(BlockState blockState, World world_1, BlockPos blockPos_1, BlockState blockState_1, boolean boolean_1)
|
||||
{
|
||||
if (!CarpetSettings.impendingFillSkipUpdates)
|
||||
if (!CarpetSettings.impendingFillSkipUpdates.get())
|
||||
blockState.onBlockAdded(world_1, blockPos_1, blockState_1, boolean_1);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class WorldChunk_fillUpdatesMixin
|
||||
))
|
||||
private void onRemovedBlock(BlockState blockState, World world, BlockPos pos, BlockState state, boolean moved)
|
||||
{
|
||||
if (CarpetSettings.impendingFillSkipUpdates) // doing due dilligence from AbstractBlock onStateReplaced
|
||||
if (CarpetSettings.impendingFillSkipUpdates.get()) // doing due dilligence from AbstractBlock onStateReplaced
|
||||
{
|
||||
if (blockState.getBlock().hasBlockEntity() && !blockState.isOf(state.getBlock()))
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public abstract class World_fillUpdatesMixin
|
||||
@ModifyConstant(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", //setBlockState main
|
||||
constant = @Constant(intValue = 16))
|
||||
private int addFillUpdatesInt(int original) {
|
||||
if (CarpetSettings.impendingFillSkipUpdates)
|
||||
if (CarpetSettings.impendingFillSkipUpdates.get())
|
||||
return -1;
|
||||
return original;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public abstract class World_fillUpdatesMixin
|
||||
))
|
||||
private void updateNeighborsMaybe(World world, BlockPos blockPos, Block block)
|
||||
{
|
||||
if (!CarpetSettings.impendingFillSkipUpdates) world.updateNeighbors(blockPos, block);
|
||||
if (!CarpetSettings.impendingFillSkipUpdates.get()) world.updateNeighbors(blockPos, block);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class World_scarpetPlopMixin
|
||||
))
|
||||
private int fixSampleHeightmap(WorldChunk chunk, Heightmap.Type type, int x, int z)
|
||||
{
|
||||
if (CarpetSettings.skipGenerationChecks)
|
||||
if (CarpetSettings.skipGenerationChecks.get())
|
||||
{
|
||||
Heightmap.Type newType = type;
|
||||
if (type == Heightmap.Type.OCEAN_FLOOR_WG) newType = Heightmap.Type.OCEAN_FLOOR;
|
||||
|
||||
@@ -688,19 +688,19 @@ public class WorldAccess {
|
||||
// lazy cause its parked execution
|
||||
expression.addLazyFunction("without_updates", 1, (c, t, lv) ->
|
||||
{
|
||||
boolean previous = CarpetSettings.impendingFillSkipUpdates;
|
||||
boolean previous = CarpetSettings.impendingFillSkipUpdates.get();
|
||||
if (previous) return lv.get(0);
|
||||
Value [] result = new Value[]{Value.NULL};
|
||||
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
result[0] = lv.get(0).evalValue(c, t);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = previous;
|
||||
CarpetSettings.impendingFillSkipUpdates.set(previous);
|
||||
}
|
||||
});
|
||||
return (cc, tt) -> result[0];
|
||||
|
||||
Reference in new issue
Block a user