2019-04-22 21:36:14 +00:00
|
|
|
From f11bd89aabd642b356d2af32e10640a8569fef7d Mon Sep 17 00:00:00 2001
|
2018-09-11 04:07:19 +00: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-04-22 21:36:14 +00:00
|
|
|
index 2b15aa6c9e..3ca32123bb 100644
|
2018-09-11 04:07:19 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
2018-11-12 18:23:18 +00:00
|
|
|
@@ -12,11 +12,13 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 04:07:19 +00:00
|
|
|
private final Block f;
|
2018-12-08 10:09:55 +00:00
|
|
|
private final EntityInsentient entity;
|
2018-09-11 04:07:19 +00:00
|
|
|
private int h;
|
|
|
|
+ private World world; // Paper
|
|
|
|
|
|
|
|
public PathfinderGoalRemoveBlock(Block block, EntityCreature entitycreature, double d0, int i) {
|
|
|
|
super(entitycreature, d0, 24, i);
|
|
|
|
this.f = block;
|
2018-12-08 10:09:55 +00:00
|
|
|
this.entity = entitycreature;
|
2018-09-11 04:07:19 +00:00
|
|
|
+ this.world = entitycreature.world; // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
2018-11-12 18:23:18 +00:00
|
|
|
@@ -99,7 +101,9 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 04:07:19 +00:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private BlockPosition a(BlockPosition blockposition, IBlockAccess iblockaccess) {
|
|
|
|
- if (iblockaccess.getType(blockposition).getBlock() == this.f) {
|
|
|
|
+ Block block = world.getBlockIfLoaded(blockposition); // Paper
|
|
|
|
+ if (block == null) return null; // Paper
|
|
|
|
+ if (block == this.f) { // Paper
|
|
|
|
return blockposition;
|
|
|
|
} else {
|
2018-11-12 18:23:18 +00:00
|
|
|
BlockPosition[] ablockposition = new BlockPosition[] { blockposition.down(), blockposition.west(), blockposition.east(), blockposition.north(), blockposition.south(), blockposition.down().down()};
|
|
|
|
@@ -109,7 +113,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
BlockPosition blockposition1 = ablockposition1[j];
|
2018-09-11 04:07:19 +00:00
|
|
|
|
|
|
|
- if (iblockaccess.getType(blockposition1).getBlock() == this.f) {
|
|
|
|
+ if (world.getBlockIfLoaded(blockposition1) == this.f) { // Paper
|
|
|
|
return blockposition1;
|
|
|
|
}
|
|
|
|
}
|
2018-11-12 18:23:18 +00:00
|
|
|
@@ -119,7 +123,8 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
2018-09-11 04:07:19 +00: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 18:23:18 +00:00
|
|
|
|
2018-09-11 04:07:19 +00:00
|
|
|
return block == this.f && iworldreader.getType(blockposition.up()).isAir() && iworldreader.getType(blockposition.up(2)).isAir();
|
|
|
|
}
|
2018-09-13 01:25:02 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/RandomPositionGenerator.java b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
2019-04-22 21:36:14 +00:00
|
|
|
index e58fdee8bb..f2c4048c2b 100644
|
2018-09-13 01:25:02 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -87,6 +87,7 @@ public class RandomPositionGenerator {
|
2018-09-13 01:58:38 +00:00
|
|
|
}
|
|
|
|
|
2019-01-01 03:15:55 +00:00
|
|
|
blockposition1 = new BlockPosition((double) k1 + entitycreature.locX, (double) l1 + entitycreature.locY, (double) i2 + entitycreature.locZ);
|
|
|
|
+ if (!entitycreature.world.isLoaded(blockposition1)) continue; // Paper
|
|
|
|
if ((!flag1 || entitycreature.f(blockposition1)) && navigationabstract.a(blockposition1)) {
|
2018-09-13 01:58:38 +00:00
|
|
|
if (!flag) {
|
2019-01-01 03:15:55 +00:00
|
|
|
blockposition1 = a(blockposition1, entitycreature);
|
|
|
|
@@ -155,6 +156,7 @@ public class RandomPositionGenerator {
|
2018-09-13 01:25:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean b(BlockPosition blockposition, EntityCreature entitycreature) {
|
2018-12-08 10:09:55 +00:00
|
|
|
- return entitycreature.world.getFluid(blockposition).a(TagsFluid.WATER);
|
2018-09-13 01:25:02 +00:00
|
|
|
+ Fluid fluid = entitycreature.world.getFluidIfLoaded(blockposition); // Paper
|
|
|
|
+ return fluid != null && fluid.a(TagsFluid.WATER); // Paper
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2019-04-22 21:36:14 +00:00
|
|
|
index 630ebfb37c..0d45e21573 100644
|
2018-09-13 01:25:02 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-02-03 15:34:04 +00:00
|
|
|
@@ -764,7 +764,17 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-12-08 10:09:55 +00:00
|
|
|
return chunk.getType(blockposition);
|
2018-09-13 01:25:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // Paper start
|
|
|
|
+ public Fluid getFluidIfLoaded(BlockPosition blockposition) {
|
|
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
|
|
+ return getFluid(blockposition);
|
|
|
|
+ } else {
|
|
|
|
+ Chunk chunk = this.getChunkIfLoaded(blockposition);
|
2018-12-08 10:09:55 +00:00
|
|
|
|
2018-09-13 01:25:02 +00:00
|
|
|
+ return chunk != null ? chunk.getFluid(blockposition) : null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2018-12-08 10:09:55 +00:00
|
|
|
public Fluid getFluid(BlockPosition blockposition) {
|
2018-09-13 01:25:02 +00:00
|
|
|
if (blockposition.isInvalidYLocation()) { // Paper
|
2019-01-01 03:15:55 +00:00
|
|
|
return FluidTypes.EMPTY.i();
|
2018-09-11 04:07:19 +00:00
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2018-09-11 04:07:19 +00:00
|
|
|
|