2019-06-14 04:27:40 +02:00
|
|
|
From 66cbb8fdb84a9bfa90faa2381beddd06044eb30f 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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 706be9a736..b1457526ec 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
|
2018-11-12 19:23:18 +01:00
|
|
|
@@ -12,11 +12,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
|
|
|
|
@@ -114,7 +116,9 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 06:07:19 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private BlockPosition a(BlockPosition blockposition, IBlockAccess iblockaccess) {
|
2019-05-05 10:33:44 +02:00
|
|
|
- if (iblockaccess.getType(blockposition).getBlock() == this.g) {
|
2018-09-11 06:07:19 +02:00
|
|
|
+ Block block = world.getBlockIfLoaded(blockposition); // Paper
|
|
|
|
+ if (block == null) return null; // Paper
|
2019-05-05 10:33:44 +02:00
|
|
|
+ if (block == 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()};
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -124,7 +128,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
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
- if (iblockaccess.getType(blockposition1).getBlock() == this.g) {
|
|
|
|
+ if (world.getBlockIfLoaded(blockposition1) == this.g) { // Paper
|
2018-09-11 06:07:19 +02:00
|
|
|
return blockposition1;
|
|
|
|
}
|
|
|
|
}
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -135,7 +139,8 @@ 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) {
|
|
|
|
- Block block = iworldreader.getType(blockposition).getBlock();
|
|
|
|
+ Block block = world.getBlockIfLoaded(blockposition); // Paper
|
|
|
|
+ if (block == null) return false; // Paper
|
2018-11-12 19:23:18 +01:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
return block == this.g && iworldreader.getType(blockposition.up()).isAir() && iworldreader.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
|
2019-06-06 17:36:57 +02:00
|
|
|
index b286934aa8..c7e25e2be8 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
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -93,6 +93,7 @@ public class RandomPositionGenerator {
|
2018-09-13 03:58:38 +02:00
|
|
|
}
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
blockposition1 = new BlockPosition((double) k1 + entitycreature.locX, (double) l1 + entitycreature.locY, (double) i2 + entitycreature.locZ);
|
|
|
|
+ if (!entitycreature.world.isLoaded(blockposition1)) continue; // Paper
|
2019-05-05 10:33:44 +02:00
|
|
|
if ((!flag1 || entitycreature.a(blockposition1)) && navigationabstract.a(blockposition1)) {
|
2018-09-13 03:58:38 +02:00
|
|
|
if (!flag) {
|
2019-01-01 04:15:55 +01:00
|
|
|
blockposition1 = a(blockposition1, entitycreature);
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -161,6 +162,7 @@ public class RandomPositionGenerator {
|
2018-09-13 03:25:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean b(BlockPosition blockposition, EntityCreature entitycreature) {
|
2018-12-08 11:09:55 +01:00
|
|
|
- return entitycreature.world.getFluid(blockposition).a(TagsFluid.WATER);
|
2018-09-13 03:25:02 +02:00
|
|
|
+ Fluid fluid = entitycreature.world.getFluidIfLoaded(blockposition); // Paper
|
|
|
|
+ return fluid != null && fluid.a(TagsFluid.WATER); // Paper
|
|
|
|
}
|
|
|
|
}
|
2018-09-11 06:07:19 +02:00
|
|
|
--
|
2019-05-05 13:32:20 +02:00
|
|
|
2.21.0
|
2018-09-11 06:07:19 +02:00
|
|
|
|