diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index add15d695b..2111952674 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -23,3 +23,33 @@ world.removeBlock(blockposition1, false); if (!world.isClientSide) { for (int i = 0; i < 20; ++i) { +@@ -118,7 +127,9 @@ + + @Nullable + private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) { +- if (world.getBlockState(pos).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks ++ if (block == null) return null; // Paper - Prevent AI rules from loading chunks ++ if (block.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return pos; + } else { + BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; +@@ -128,7 +139,8 @@ + for (int j = 0; j < i; ++j) { + BlockPos blockposition1 = ablockposition1[j]; + +- if (world.getBlockState(blockposition1).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent AI rules from loading chunks ++ if (block2 != null && block2.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return blockposition1; + } + } +@@ -139,7 +151,7 @@ + + @Override + protected boolean isValidTarget(LevelReader world, BlockPos pos) { +- ChunkAccess ichunkaccess = world.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false); ++ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper - Prevent AI rules from loading chunks + + return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir(); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 5bb4461070..18ecd6803b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -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)) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch new file mode 100644 index 0000000000..79d33fc6bf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/component/LodestoneTracker.java ++++ b/net/minecraft/world/item/component/LodestoneTracker.java +@@ -29,7 +29,7 @@ + return this; + } else { + BlockPos blockPos = this.target.get().pos(); +- return world.isInWorldBounds(blockPos) && world.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos) ++ return world.isInWorldBounds(blockPos) && (!world.hasChunkAt(blockPos) || world.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) // Paper - Prevent compass from loading chunks + ? this + : new LodestoneTracker(Optional.empty(), true); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch index 15535ac17c..2047ce0c32 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch @@ -8,7 +8,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -@@ -31,10 +32,19 @@ +@@ -31,11 +32,20 @@ default Optional getBlockEntity(BlockPos pos, BlockEntityType type) { BlockEntity tileentity = this.getBlockEntity(pos); @@ -19,28 +19,39 @@ BlockState getBlockState(BlockPos pos); + // Paper start - if loaded util + @Nullable BlockState getBlockStateIfLoaded(BlockPos blockposition); -+ + + default @Nullable Block getBlockIfLoaded(BlockPos blockposition) { + BlockState type = this.getBlockStateIfLoaded(blockposition); + return type == null ? null : type.getBlock(); + } + @Nullable FluidState getFluidIfLoaded(BlockPos blockposition); + // Paper end - ++ FluidState getFluidState(BlockPos pos); -@@ -59,8 +69,8 @@ + default int getLightEmission(BlockPos pos) { +@@ -59,9 +69,17 @@ }); } - default BlockHitResult clip(ClipContext context) { - return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> { +- BlockState iblockdata = this.getBlockState(blockposition); + // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace + default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { - BlockState iblockdata = this.getBlockState(blockposition); ++ // Paper start - Prevent raytrace from loading chunks ++ BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); ++ if (iblockdata == null) { ++ // copied the last function parameter (listed below) ++ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); ++ ++ return BlockHitResult.miss(raytrace1.getTo(), Direction.getApproximateNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); ++ } ++ // Paper end - Prevent raytrace from loading chunks FluidState fluid = this.getFluidState(blockposition); Vec3 vec3d = raytrace1.getFrom(); -@@ -73,6 +83,12 @@ + Vec3 vec3d1 = raytrace1.getTo(); +@@ -73,6 +91,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock1.getLocation()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -53,7 +64,7 @@ }, (raytrace1) -> { Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); -@@ -145,7 +161,7 @@ +@@ -145,7 +169,7 @@ double d13 = d10 * (i1 > 0 ? 1.0D - Mth.frac(d4) : Mth.frac(d4)); double d14 = d11 * (j1 > 0 ? 1.0D - Mth.frac(d5) : Mth.frac(d5));