Improved Thread safety (may help with #394)

This commit is contained in:
Frank 2022-01-28 17:13:34 +01:00
parent 2ef8fd08af
commit 755a0ad7ab
14 changed files with 46 additions and 19 deletions

View file

@ -40,6 +40,7 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.biomes.BCLBiome;
import ru.betterend.interfaces.ISlime;
import ru.betterend.registry.EndBiomes;
import ru.betterend.util.GlobalState;
import java.util.EnumSet;
import java.util.Random;
@ -49,7 +50,6 @@ public class EndSlimeEntity extends Slime {
EndSlimeEntity.class,
EntityDataSerializers.BYTE
);
private static final MutableBlockPos POS = new MutableBlockPos();
public EndSlimeEntity(EntityType<EndSlimeEntity> entityType, Level world) {
super(entityType, world);
@ -227,6 +227,8 @@ public class EndSlimeEntity extends Slime {
}
private static boolean isWaterNear(LevelAccessor world, BlockPos pos) {
final MutableBlockPos POS = GlobalState.stateForThread().POS;
for (int x = pos.getX() - 32; x <= pos.getX() + 32; x++) {
POS.setX(x);
for (int z = pos.getZ() - 32; z <= pos.getZ() + 32; z++) {