2021-06-13 06:03:02 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Mon, 10 Sep 2018 23:56:36 -0400
|
|
|
|
Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
2023-07-04 10:22:56 +02:00
|
|
|
index e3d070d46729c023d594699619a4b3f8658edbce..509317a26c79f453335df1c19dc4c9ec570046af 100644
|
2021-06-13 06:03:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -126,7 +126,9 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
2021-06-13 06:03:02 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) {
|
|
|
|
- if (world.getBlockState(pos).is(this.blockToRemove)) {
|
2021-12-06 00:32:02 +01:00
|
|
|
+ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper
|
2021-06-13 06:03:02 +02:00
|
|
|
+ if (block == null) return null; // Paper
|
|
|
|
+ if (block.is(this.blockToRemove)) { // Paper
|
|
|
|
return pos;
|
|
|
|
} else {
|
|
|
|
BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()};
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -136,7 +138,8 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
2021-06-13 06:03:02 +02:00
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
BlockPos blockposition1 = ablockposition1[j];
|
|
|
|
|
|
|
|
- if (world.getBlockState(blockposition1).is(this.blockToRemove)) {
|
2021-12-06 00:32:02 +01:00
|
|
|
+ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper
|
2021-06-13 06:03:02 +02:00
|
|
|
+ if (block2 != null && block2.is(this.blockToRemove)) { // Paper
|
|
|
|
return blockposition1;
|
|
|
|
}
|
|
|
|
}
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -147,7 +150,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
2021-06-13 06:03:02 +02:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir();
|
|
|
|
}
|