2018-10-05 05:18:46 +02:00
|
|
|
From b7b5152e42f0919e1199cdbe053e6ac69233aad2 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
|
|
|
|
|
|
|
|
|
2018-09-13 03:25:02 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2018-10-05 05:18:46 +02:00
|
|
|
index c68cef1677..f81985a847 100644
|
2018-09-13 03:25:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
@@ -482,6 +482,7 @@ public class Chunk implements IChunkAccess {
|
2018-09-13 03:25:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public Fluid getFluid(BlockPosition blockposition) { return b(blockposition); } // Paper - OBFHELPER
|
|
|
|
public Fluid b(BlockPosition blockposition) {
|
|
|
|
return this.b(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
}
|
2018-09-11 06:07:19 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
|
|
|
index b1661693cf..2cbb6c8f91 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
|
|
|
@@ -7,11 +7,13 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
|
|
|
private final Block f;
|
|
|
|
private final EntityInsentient g;
|
|
|
|
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;
|
|
|
|
this.g = entitycreature;
|
|
|
|
+ this.world = entitycreature.world; // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
@@ -89,13 +91,15 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
BlockPosition[] ablockposition = new BlockPosition[]{blockposition.down(), blockposition.west(), blockposition.east(), blockposition.north(), blockposition.south(), blockposition.down().down()};
|
|
|
|
|
|
|
|
for(BlockPosition blockposition1 : ablockposition) {
|
|
|
|
- if (iblockaccess.getType(blockposition1).getBlock() == this.f) {
|
|
|
|
+ if (world.getBlockIfLoaded(blockposition1) == this.f) { // Paper
|
|
|
|
return blockposition1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -105,7 +109,8 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
return block == this.f && iworldreader.getType(blockposition.up()).isAir() && iworldreader.getType(blockposition.up(2)).isAir();
|
|
|
|
}
|
|
|
|
}
|
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
|
2018-09-13 03:58:38 +02:00
|
|
|
index 800e0046a8..bfa6c2eef8 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
|
2018-09-13 03:58:38 +02:00
|
|
|
@@ -78,6 +78,7 @@ public class RandomPositionGenerator {
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockPosition blockposition2 = new BlockPosition((double)j1 + entitycreature.locX, (double)k1 + entitycreature.locY, (double)l1 + entitycreature.locZ);
|
|
|
|
+ if (!entitycreature.world.isLoaded(blockposition2)) continue; // Paper
|
|
|
|
if ((!flag1 || entitycreature.f(blockposition2)) && navigationabstract.a(blockposition2)) {
|
|
|
|
if (!flag) {
|
|
|
|
blockposition2 = a(blockposition2, entitycreature);
|
|
|
|
@@ -141,6 +142,7 @@ public class RandomPositionGenerator {
|
2018-09-13 03:25:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean b(BlockPosition blockposition, EntityCreature entitycreature) {
|
|
|
|
- return entitycreature.world.b(blockposition).a(TagsFluid.WATER);
|
|
|
|
+ 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
|
2018-09-18 03:50:02 +02:00
|
|
|
index 0c42d042b1..e52e4bb458 100644
|
2018-09-13 03:25:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-09-18 03:50:02 +02:00
|
|
|
@@ -762,6 +762,18 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-09-13 03:25:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ public Fluid getFluidIfLoaded(BlockPosition blockposition) {
|
|
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
|
|
+ return getFluid(blockposition);
|
|
|
|
+ } else {
|
|
|
|
+ Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
|
|
+
|
|
|
|
+ return chunk != null ? chunk.getFluid(blockposition) : null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+ public Fluid getFluid(BlockPosition blockposition) { return b(blockposition); } // Paper - OBFHELPER
|
|
|
|
public Fluid b(BlockPosition blockposition) {
|
|
|
|
if (blockposition.isInvalidYLocation()) { // Paper
|
|
|
|
return FluidTypes.a.i();
|
2018-09-11 06:07:19 +02:00
|
|
|
--
|
2018-09-18 03:50:02 +02:00
|
|
|
2.19.0
|
2018-09-11 06:07:19 +02:00
|
|
|
|