2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-11 06:07:19 +02:00
|
|
|
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/server/PathfinderGoalRemoveBlock.java b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
2021-03-09 00:12:31 +01:00
|
|
|
index 127428c400f6de1cb65458346aac6a176b6c1896..6ea402c603b9b54705e79a2fdc61fe5a254479a3 100644
|
2018-09-11 06:07:19 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -13,11 +13,13 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2019-05-05 10:33:44 +02:00
|
|
|
private final Block g;
|
2018-12-08 11:09:55 +01:00
|
|
|
private final EntityInsentient entity;
|
2019-05-05 10:33:44 +02:00
|
|
|
private int i;
|
2018-09-11 06:07:19 +02:00
|
|
|
+ private World world; // Paper
|
|
|
|
|
|
|
|
public PathfinderGoalRemoveBlock(Block block, EntityCreature entitycreature, double d0, int i) {
|
|
|
|
super(entitycreature, d0, 24, i);
|
2019-05-05 10:33:44 +02:00
|
|
|
this.g = block;
|
2018-12-08 11:09:55 +01:00
|
|
|
this.entity = entitycreature;
|
2018-09-11 06:07:19 +02:00
|
|
|
+ this.world = entitycreature.world; // Paper
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -115,7 +117,9 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 06:07:19 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private BlockPosition a(BlockPosition blockposition, IBlockAccess iblockaccess) {
|
2020-06-25 16:09:55 +02:00
|
|
|
- if (iblockaccess.getType(blockposition).a(this.g)) {
|
2018-09-11 06:07:19 +02:00
|
|
|
+ Block block = world.getBlockIfLoaded(blockposition); // Paper
|
|
|
|
+ if (block == null) return null; // Paper
|
2020-06-25 16:09:55 +02:00
|
|
|
+ if (block.a(this.g)) { // Paper
|
2018-09-11 06:07:19 +02:00
|
|
|
return blockposition;
|
|
|
|
} else {
|
2019-05-28 01:01:45 +02:00
|
|
|
BlockPosition[] ablockposition = new BlockPosition[]{blockposition.down(), blockposition.west(), blockposition.east(), blockposition.north(), blockposition.south(), blockposition.down().down()};
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -125,7 +129,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-11-12 19:23:18 +01:00
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
BlockPosition blockposition1 = ablockposition1[j];
|
2018-09-11 06:07:19 +02:00
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
- if (iblockaccess.getType(blockposition1).a(this.g)) {
|
|
|
|
+ if (iblockaccess.getBlockIfLoaded(blockposition1).a(this.g)) { // Paper
|
2018-09-11 06:07:19 +02:00
|
|
|
return blockposition1;
|
|
|
|
}
|
|
|
|
}
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -136,7 +140,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 06:07:19 +02:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-09-11 06:07:19 +02:00
|
|
|
protected boolean a(IWorldReader iworldreader, BlockPosition blockposition) {
|
2019-07-20 06:01:24 +02:00
|
|
|
- IChunkAccess ichunkaccess = iworldreader.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, ChunkStatus.FULL, false);
|
|
|
|
+ IChunkAccess ichunkaccess = iworldreader.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
2018-11-12 19:23:18 +01:00
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a(this.g) && ichunkaccess.getType(blockposition.up()).isAir() && ichunkaccess.getType(blockposition.up(2)).isAir();
|
2018-09-11 06:07:19 +02:00
|
|
|
}
|
2018-09-13 03:25:02 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/RandomPositionGenerator.java b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 8dc028a4b1f5cf7bac0e3f1319bca5b5eb0e2482..aaa89a39bf697bd0f3354005b428d858f065f66b 100644
|
2018-09-13 03:25:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -116,6 +116,7 @@ public class RandomPositionGenerator {
|
2018-09-13 03:58:38 +02:00
|
|
|
}
|
|
|
|
|
2019-12-12 17:20:43 +01:00
|
|
|
blockposition2 = new BlockPosition((double) k1 + entitycreature.locX(), (double) l1 + entitycreature.locY(), (double) i2 + entitycreature.locZ());
|
2019-06-28 12:33:17 +02:00
|
|
|
+ if (!entitycreature.world.isLoaded(blockposition2)) continue; // Paper
|
2019-12-12 17:20:43 +01:00
|
|
|
if (blockposition2.getY() >= 0 && blockposition2.getY() <= entitycreature.world.getBuildHeight() && (!flag3 || entitycreature.a(blockposition2)) && (!flag2 || navigationabstract.a(blockposition2))) {
|
|
|
|
if (flag1) {
|
|
|
|
blockposition2 = a(blockposition2, random.nextInt(l + 1) + i1, entitycreature.world.getBuildHeight(), (blockposition3) -> {
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -123,7 +124,8 @@ public class RandomPositionGenerator {
|
2019-12-12 17:20:43 +01:00
|
|
|
});
|
|
|
|
}
|
2018-09-13 03:25:02 +02:00
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
- if (flag || !entitycreature.world.getFluid(blockposition2).a((Tag) TagsFluid.WATER)) {
|
2019-12-12 17:20:43 +01:00
|
|
|
+ Fluid fluid = entitycreature.world.getFluidIfLoaded(blockposition2); // Paper
|
2020-06-25 16:09:55 +02:00
|
|
|
+ if (flag || (fluid != null && !fluid.a((Tag) TagsFluid.WATER))) { // Paper
|
|
|
|
PathType pathtype = PathfinderNormal.a((IBlockAccess) entitycreature.world, blockposition2.i());
|
2019-12-12 17:20:43 +01:00
|
|
|
|
|
|
|
if (entitycreature.a(pathtype) == 0.0F) {
|