From 372d9c2d4abed34dc7aa1977647998cd08c01efd Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 29 Jul 2018 12:04:09 -0400 Subject: [PATCH] If Entity is added to chunk, look up the chunk if current isnt set Hopefully will (f)ix #1280... I'm suspicious that Citizens isn't calling things in the same order and causes the current chunk to not be set, which then bugs removals. Though this doesn't make any sense to me, so this likely won't fix it... But if the isAddedToChunk is true, we really should be returning a chunk anyways if its loaded. --- ...entation-of-tile-entity-removal-list.patch | 13 ------------- ...to-current-Chunk-for-Entity-and-Bloc.patch | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch index 5f48152f48..068a58d14e 100644 --- a/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch +++ b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch @@ -4,19 +4,6 @@ Date: Thu, 3 Mar 2016 02:39:54 -0600 Subject: [PATCH] Change implementation of (tile)entity removal list -diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index aadc426fd..584501787 100644 ---- a/src/main/java/net/minecraft/server/Entity.java -+++ b/src/main/java/net/minecraft/server/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper - private static final DataWatcherObject aC = DataWatcher.a(Entity.class, DataWatcherRegistry.h); - private static final DataWatcherObject aD = DataWatcher.a(Entity.class, DataWatcherRegistry.h); - private static final DataWatcherObject aE = DataWatcher.a(Entity.class, DataWatcherRegistry.h); -- public boolean aa; -+ public boolean aa; public boolean isAddedToChunk() { return aa; } // Paper - OBFHELPER - public int ab; public int getChunkX() { return ab; } // Paper - OBFHELPER - public int ac; public int getChunkY() { return ac; } // Paper - OBFHELPER - public int ad; public int getChunkZ() { return ad; } // Paper - OBFHELPER diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index e85ed2e33..89197281e 100644 --- a/src/main/java/net/minecraft/server/World.java diff --git a/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch index d9e3cac4ed..effaa2319e 100644 --- a/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch +++ b/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch @@ -8,7 +8,7 @@ This enables us a fast reference to the entities current chunk instead of having to look it up by hashmap lookups. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 4bbebb25af..ea167a17bb 100644 +index 4bbebb25a..ea167a17b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk { @@ -81,9 +81,18 @@ index 4bbebb25af..ea167a17bb 100644 // Keep this synced up with World.a(Class) if (entity instanceof EntityInsentient) { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 06c72b95f3..c107bd767f 100644 +index 06c72b95f..0e3a94ab8 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java +@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper + private static final DataWatcherObject aC = DataWatcher.a(Entity.class, DataWatcherRegistry.h); + private static final DataWatcherObject aD = DataWatcher.a(Entity.class, DataWatcherRegistry.h); + private static final DataWatcherObject aE = DataWatcher.a(Entity.class, DataWatcherRegistry.h); +- public boolean aa; ++ public boolean aa; public boolean isAddedToChunk() { return aa; } // Paper - OBFHELPER + public int ab; public int getChunkX() { return ab; } // Paper - OBFHELPER + public int ac; public int getChunkY() { return ac; } // Paper - OBFHELPER + public int ad; public int getChunkZ() { return ad; } // Paper - OBFHELPER @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } @@ -98,7 +107,7 @@ index 06c72b95f3..c107bd767f 100644 + */ + public Chunk getCurrentChunk() { + final Chunk chunk = currentChunk != null ? currentChunk.get() : null; -+ return chunk != null && chunk.isLoaded() ? chunk : null; ++ return chunk != null && chunk.isLoaded() ? chunk : (isAddedToChunk() ? world.getChunkIfLoaded(getChunkX(), getChunkZ()) : null); + } + /** + * Returns the chunk at the location, using the entities local cache if avail @@ -124,7 +133,7 @@ index 06c72b95f3..c107bd767f 100644 private MinecraftKey entityKey = getMinecraftKey(); diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 0176ca530c..29069b753e 100644 +index 0176ca530..29069b753 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -0,0 +0,0 @@ public abstract class TileEntity implements KeyedObject { @@ -143,7 +152,7 @@ index 0176ca530c..29069b753e 100644 private MinecraftKey tileEntityKey = getMinecraftKey(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index c5a194ffea..833e3111de 100644 +index c5a194ffe..833e3111d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ import java.util.UUID;