Only use stored chunk ref if it matches current chunk registration
Closes #1197 While this really undoes a lot of the desired performance gains avoiding chunk lookups, we sadly have to accept this because we are seeing lots of bugs with entities.
This commit is contained in:
parent
18c1127fcd
commit
6745297b05
10 changed files with 38 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
|||
From 75b50cf5c33d0049e9670329132d0d2521f7f91a Mon Sep 17 00:00:00 2001
|
||||
From 3fbe4af7bcafee200f8492e070b8ea2d98a00181 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 4 Jul 2018 02:10:36 -0400
|
||||
Subject: [PATCH] Store reference to current Chunk for Entity and Block
|
||||
|
@ -81,17 +81,22 @@ index 4bbebb25a..68008fe6a 100644
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 3a8902bf1..ed090cc50 100644
|
||||
index 3a8902bf1..f7750a05c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1703,6 +1703,14 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1703,6 +1703,19 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
// Paper start
|
||||
+ private java.lang.ref.WeakReference<Chunk> currentChunk = null;
|
||||
+ public Chunk getCurrentChunk() {
|
||||
+ final Chunk chunk = currentChunk != null ? currentChunk.get() : world.getChunkIfLoaded(getChunkX(), getChunkZ());
|
||||
+ return chunk != null && chunk.isLoaded() ? chunk : null;
|
||||
+ final Chunk chunk = currentChunk != null ? currentChunk.get() : null;
|
||||
+ final int cx = getChunkX();
|
||||
+ final int cz = getChunkZ();
|
||||
+ if (chunk != null && chunk.isLoaded() && chunk.locX == cx && chunk.locZ == cz) {
|
||||
+ return chunk;
|
||||
+ }
|
||||
+ return world.getChunkIfLoaded(cx, cz);
|
||||
+ }
|
||||
+ public void setCurrentChunk(Chunk chunk) {
|
||||
+ this.currentChunk = chunk != null ? new java.lang.ref.WeakReference<>(chunk) : null;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 8c61ede82f1c1292632024336a7dc758559ab8d9 Mon Sep 17 00:00:00 2001
|
||||
From 63c7daaef2f42d527197a8df4878ed44813ad87f Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Tue, 1 Mar 2016 14:14:15 -0600
|
||||
Subject: [PATCH] Drop falling block and tnt entities at the specified height
|
||||
|
@ -24,10 +24,10 @@ index 0094d1a87..4da846719 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 137da4255..655340c0b 100644
|
||||
index 9d7fe97ce..c7513622e 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1770,6 +1770,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1775,6 +1775,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return this.a(new ItemStack(item, i, 0), f);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
From a9191e155ef7c4f82b15db6b6530fb7037159b91 Mon Sep 17 00:00:00 2001
|
||||
From 6254651ac3eeee042d9b4f6b1aabca609f242122 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Tue, 1 Mar 2016 23:45:08 -0600
|
||||
Subject: [PATCH] Entity Origin API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 655340c0b..a96513e27 100644
|
||||
index c7513622e..72efe282b 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -149,6 +149,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
@ -42,7 +42,7 @@ index 655340c0b..a96513e27 100644
|
|||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1732,6 +1745,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1737,6 +1750,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
||||
protected abstract void b(NBTTagCompound nbttagcompound);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 00f58d4e46fd30f9bf89b67139eefd50087366b8 Mon Sep 17 00:00:00 2001
|
||||
From 427ed2e030aab48f93a55b805946fa07fba593ae Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 8 Mar 2016 23:25:45 -0500
|
||||
Subject: [PATCH] Disable Scoreboards for non players by default
|
||||
|
@ -37,10 +37,10 @@ index ec9a87239..b08274d93 100644
|
|||
|
||||
if (scoreboard.addPlayerToTeam(s2, s)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 21118c031..921b442cd 100644
|
||||
index a4c5b780c..c620667e0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2099,6 +2099,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2104,6 +2104,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
||||
@Nullable
|
||||
public ScoreboardTeamBase aY() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From f51d39ceefb609670b7c3799893a8fe877955807 Mon Sep 17 00:00:00 2001
|
||||
From 9a662f1a253d481005f4318fd6db8deda65a553b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 22 Mar 2016 00:55:23 -0400
|
||||
Subject: [PATCH] Don't teleport dead entities
|
||||
|
@ -7,10 +7,10 @@ Had some issue with this in past, and this is the vanilla logic.
|
|||
Potentially an old CB change that's no longer needed.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index e8775e66c..7e992aeaa 100644
|
||||
index 843cb3a61..89ea217b9 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2375,7 +2375,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2380,7 +2380,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
public Entity teleportTo(Location exit, boolean portal) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From ebf30115a7e355668afb258d7e4e96fb9e955442 Mon Sep 17 00:00:00 2001
|
||||
From e90027b47608f6153ad3d0321ec2799077d3b0b7 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 6 Apr 2016 01:04:23 -0500
|
||||
Subject: [PATCH] Option to use vanilla per-world scoreboard coloring on names
|
||||
|
@ -19,10 +19,10 @@ index abc1aabdd..6ea608ba9 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 7e992aeaa..08d872318 100644
|
||||
index 89ea217b9..437ae2fa3 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2098,6 +2098,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2103,6 +2103,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return this.getFlag(5);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
From e33a8ba3bed690fc4acd04253812a8a1285b8e93 Mon Sep 17 00:00:00 2001
|
||||
From 4b24d8aeee60f407bd9917d39f49188526338a26 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 22 Apr 2016 18:20:05 -0500
|
||||
Subject: [PATCH] Vehicle Event Cancellation Changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 08d872318..e6a5bc53c 100644
|
||||
index 437ae2fa3..17ec10c26 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -70,7 +70,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
@ -17,7 +17,7 @@ index 08d872318..e6a5bc53c 100644
|
|||
public boolean attachedToPlayer;
|
||||
public World world;
|
||||
public double lastX;
|
||||
@@ -1980,6 +1980,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1985,6 +1985,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
|
@ -25,7 +25,7 @@ index 08d872318..e6a5bc53c 100644
|
|||
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
Entity orig = craft == null ? null : craft.getHandle();
|
||||
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
|
||||
@@ -1995,7 +1996,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2000,7 +2001,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From a179a7106eeb9eb6bd522fb5cc69a752f4d6bbc4 Mon Sep 17 00:00:00 2001
|
||||
From 1975e598adb294c806ff4b0699ba67178cbce3ad Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sun, 22 May 2016 20:20:55 -0500
|
||||
Subject: [PATCH] Optional TNT doesn't move in water
|
||||
|
@ -32,7 +32,7 @@ index 067cb233e..06acdaaf0 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 0412e183a..9ce691061 100644
|
||||
index e860e9c6a..a52cd0728 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1114,6 +1114,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
@ -47,7 +47,7 @@ index 0412e183a..9ce691061 100644
|
|||
if (this.bJ() instanceof EntityBoat) {
|
||||
this.inWater = false;
|
||||
} else if (this.world.a(this.getBoundingBox().grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D), Material.WATER, this)) {
|
||||
@@ -2563,6 +2568,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2568,6 +2573,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
public boolean bo() {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 80e2a4d03877b2324f2047a4aa526ad9f23a863b Mon Sep 17 00:00:00 2001
|
||||
From 3fa934b4f3d9456a4d9aa78bd013f5d0232dd929 Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Cleveland <alfeh@me.com>
|
||||
Date: Sun, 8 Jan 2017 04:31:36 +0000
|
||||
Subject: [PATCH] Don't allow entities to ride themselves - #572
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 0ed9a8413..646a2d673 100644
|
||||
index 64e566d3a..f75d57c30 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1957,6 +1957,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1962,6 +1962,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
protected void o(Entity entity) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 3bb876e1ca8ad360cad539ed4c278b146a44f71c Mon Sep 17 00:00:00 2001
|
||||
From 24da81e684f7d7c01c3b5e6053899d60668157c1 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 10 Jun 2018 20:04:42 -0400
|
||||
Subject: [PATCH] Properly remove entities on dimension teleport
|
||||
|
@ -22,10 +22,10 @@ requirement, but plugins (such as my own) use this method to
|
|||
trigger a "reload" of the entity on the client.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index fccaebfbd..5d1ea0d55 100644
|
||||
index 9f2db9025..a96cdcbc6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2425,7 +2425,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2430,7 +2430,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
// CraftBukkit end */
|
||||
|
||||
|
|
Loading…
Reference in a new issue