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.
Dieser Commit ist enthalten in:
Aikar 2018-07-29 12:04:09 -04:00
Ursprung d98f6afef0
Commit e674d3a00f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
2 geänderte Dateien mit 16 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From 67c7a52969344e723be71cbd2fed330ca8ffa28d Mon Sep 17 00:00:00 2001
From ab050c94d0a74f405ae49fce43faf3ee265d9a39 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
@ -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
@@ -25,7 +25,7 @@ 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
@@ -121,7 +121,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
private static final DataWatcherObject<Boolean> aC = DataWatcher.a(Entity.class, DataWatcherRegistry.h);
private static final DataWatcherObject<Boolean> aD = DataWatcher.a(Entity.class, DataWatcherRegistry.h);
private static final DataWatcherObject<Boolean> 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
@@ -1703,6 +1703,38 @@ 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
@@ -28,6 +28,14 @@ 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
@@ -9,6 +9,7 @@ import java.util.UUID;

Datei anzeigen

@ -1,22 +1,9 @@
From bc94a21d1941e2d5d173d0be455acef7c1b02ce8 Mon Sep 17 00:00:00 2001
From abef5d63377c635fd7072ddf5e166aff23a86ead Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io>
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
@@ -122,7 +122,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
private static final DataWatcherObject<Boolean> aC = DataWatcher.a(Entity.class, DataWatcherRegistry.h);
private static final DataWatcherObject<Boolean> aD = DataWatcher.a(Entity.class, DataWatcherRegistry.h);
private static final DataWatcherObject<Boolean> 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