Paper/Spigot-Server-Patches/0288-Prevent-Mob-AI-Rules-from-Loading-Chunks.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

76 lines
4.5 KiB
Diff

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/server/PathfinderGoalRemoveBlock.java b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
index 537e7224b9f9dbbe107537c5d7ef9d3bb4cbb422..c03ebbc933197be3e7097ea3f7b7cd08c90db7bb 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
@@ -12,11 +12,13 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
private final Block g;
private final EntityInsentient entity;
private int i;
+ private World world; // Paper
public PathfinderGoalRemoveBlock(Block block, EntityCreature entitycreature, double d0, int i) {
super(entitycreature, d0, 24, i);
this.g = block;
this.entity = entitycreature;
+ this.world = entitycreature.world; // Paper
}
@Override
@@ -114,7 +116,9 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
@Nullable
private BlockPosition a(BlockPosition blockposition, IBlockAccess iblockaccess) {
- if (iblockaccess.getType(blockposition).a(this.g)) {
+ Block block = world.getBlockIfLoaded(blockposition); // Paper
+ if (block == null) return null; // Paper
+ if (block.a(this.g)) { // Paper
return blockposition;
} else {
BlockPosition[] ablockposition = new BlockPosition[]{blockposition.down(), blockposition.west(), blockposition.east(), blockposition.north(), blockposition.south(), blockposition.down().down()};
@@ -124,7 +128,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
for (int j = 0; j < i; ++j) {
BlockPosition blockposition1 = ablockposition1[j];
- if (iblockaccess.getType(blockposition1).a(this.g)) {
+ if (iblockaccess.getBlockIfLoaded(blockposition1).a(this.g)) { // Paper
return blockposition1;
}
}
@@ -135,7 +139,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
@Override
protected boolean a(IWorldReader iworldreader, BlockPosition blockposition) {
- IChunkAccess ichunkaccess = iworldreader.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, ChunkStatus.FULL, false);
+ IChunkAccess ichunkaccess = iworldreader.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a(this.g) && ichunkaccess.getType(blockposition.up()).isAir() && ichunkaccess.getType(blockposition.up(2)).isAir();
}
diff --git a/src/main/java/net/minecraft/server/RandomPositionGenerator.java b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
index 8dc028a4b1f5cf7bac0e3f1319bca5b5eb0e2482..aaa89a39bf697bd0f3354005b428d858f065f66b 100644
--- a/src/main/java/net/minecraft/server/RandomPositionGenerator.java
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
@@ -116,6 +116,7 @@ public class RandomPositionGenerator {
}
blockposition2 = new BlockPosition((double) k1 + entitycreature.locX(), (double) l1 + entitycreature.locY(), (double) i2 + entitycreature.locZ());
+ if (!entitycreature.world.isLoaded(blockposition2)) continue; // Paper
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) -> {
@@ -123,7 +124,8 @@ public class RandomPositionGenerator {
});
}
- if (flag || !entitycreature.world.getFluid(blockposition2).a((Tag) TagsFluid.WATER)) {
+ Fluid fluid = entitycreature.world.getFluidIfLoaded(blockposition2); // Paper
+ if (flag || (fluid != null && !fluid.a((Tag) TagsFluid.WATER))) { // Paper
PathType pathtype = PathfinderNormal.a((IBlockAccess) entitycreature.world, blockposition2.i());
if (entitycreature.a(pathtype) == 0.0F) {