Prevent various interactions from causing chunk loads

Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
This commit is contained in:
Aikar
2018-09-10 23:56:36 -04:00
parent ca42ec8f4e
commit 54b44d1f1c
4 changed files with 81 additions and 10 deletions

View File

@@ -86,7 +86,17 @@
return flag1;
}
@@ -465,9 +496,11 @@
@@ -457,7 +488,8 @@
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D);
int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks
+ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks
BlockPos blockposition1 = blockposition.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
BlockState iblockdata2 = this.enderman.getCarriedBlock();
@@ -465,9 +497,11 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
@@ -98,7 +108,16 @@
}
}
@@ -506,9 +539,11 @@
@@ -499,16 +533,19 @@
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D);
int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks
+ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks
Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D);
Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D);
BlockHitResult movingobjectpositionblock = world.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman));
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(BlockTags.ENDERMAN_HOLDABLE) && flag) {
@@ -110,7 +129,7 @@
}
}
@@ -592,7 +627,7 @@
@@ -592,7 +629,7 @@
} else {
if (this.target != null && !this.enderman.isPassenger()) {
if (this.enderman.isBeingStaredBy((Player) this.target)) {