Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/Spigot-Server-Patches/0305-Prevent-Mob-AI-Rules-from-Loading-Chunks.patch

78 Zeilen
4.1 KiB
Diff

2019-07-20 06:01:24 +02:00
From a52dd455c6715e7f965b20e0a7fc6eb099534676 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
2019-07-20 06:01:24 +02:00
index bf8ca9b32a..7ccb3d5c06 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 {
2019-05-05 10:33:44 +02:00
private final Block g;
private final EntityInsentient entity;
2019-05-05 10:33:44 +02:00
private int i;
+ 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;
this.entity = entitycreature;
+ this.world = entitycreature.world; // Paper
}
2019-05-05 10:33:44 +02:00
@Override
@@ -114,7 +116,9 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
@Nullable
private BlockPosition a(BlockPosition blockposition, IBlockAccess iblockaccess) {
2019-05-05 10:33:44 +02:00
- if (iblockaccess.getType(blockposition).getBlock() == this.g) {
+ 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
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 {
for (int j = 0; j < i; ++j) {
BlockPosition blockposition1 = ablockposition1[j];
2019-05-05 10:33:44 +02:00
- if (iblockaccess.getType(blockposition1).getBlock() == this.g) {
+ if (world.getBlockIfLoaded(blockposition1) == this.g) { // Paper
return blockposition1;
}
}
2019-07-20 06:01:24 +02:00
@@ -135,7 +139,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
2019-05-05 10:33:44 +02:00
@Override
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
2019-07-20 06:01:24 +02:00
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).getBlock() == 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
2019-07-20 06:01:24 +02:00
index 6e4da70b7e..643dc0241d 100644
--- a/src/main/java/net/minecraft/server/RandomPositionGenerator.java
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
@@ -99,6 +99,7 @@ public class RandomPositionGenerator {
}
blockposition2 = new BlockPosition((double) l + entitycreature.locX, (double) i1 + entitycreature.locY, (double) j1 + entitycreature.locZ);
+ if (!entitycreature.world.isLoaded(blockposition2)) continue; // Paper
if ((!flag1 || entitycreature.a(blockposition2)) && navigationabstract.a(blockposition2)) {
if (!flag) {
blockposition2 = a(blockposition2, entitycreature);
@@ -165,6 +166,7 @@ public class RandomPositionGenerator {
}
private static boolean b(BlockPosition blockposition, EntityCreature entitycreature) {
- return entitycreature.world.getFluid(blockposition).a(TagsFluid.WATER);
+ Fluid fluid = entitycreature.world.getFluidIfLoaded(blockposition); // Paper
+ return fluid != null && fluid.a(TagsFluid.WATER); // Paper
}
}
--
2.22.0