mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
Relookup Entity Save ID if was null during precache
Should fix #1280 Citizens hijacks entity map, and im guessing under the right conditions the result might actually be null during entity creation Pre the cache patch, the id is looked up on save, so it was fine. Now, if its null and the save ID is requested, we will try to look it up again and cache it if found.
This commit is contained in:
@@ -6,7 +6,7 @@ Subject: [PATCH] Add MinecraftKey Information to Objects
|
||||
Stores the reference to the objects respective MinecraftKey
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index ed39b122e..3a8902bf1 100644
|
||||
index ed39b122ec..06c72b95f3 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
||||
@@ -23,16 +23,21 @@ index ed39b122e..3a8902bf1 100644
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public final MinecraftKey entityKey = EntityTypes.getKey(this);
|
||||
+ public final String entityKeyString = entityKey != null ? entityKey.toString() : null;
|
||||
+ private String entityKeyString = null;
|
||||
+ private MinecraftKey entityKey = getMinecraftKey();
|
||||
+
|
||||
+ @Override
|
||||
+ public MinecraftKey getMinecraftKey() {
|
||||
+ if (entityKey == null) {
|
||||
+ entityKey = EntityTypes.getKey(this);
|
||||
+ entityKeyString = entityKey != null ? entityKey.toString() : null;
|
||||
+ }
|
||||
+ return entityKey;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getMinecraftKeyString() {
|
||||
+ getMinecraftKey(); // Try to load if it doesn't exists. see: https://github.com/PaperMC/Paper/issues/1280
|
||||
+ return entityKeyString;
|
||||
+ }
|
||||
@Nullable
|
||||
@@ -40,14 +45,14 @@ index ed39b122e..3a8902bf1 100644
|
||||
- MinecraftKey minecraftkey = EntityTypes.a(this);
|
||||
-
|
||||
- return minecraftkey == null ? null : minecraftkey.toString();
|
||||
+ return entityKeyString;
|
||||
+ return getMinecraftKeyString();
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
protected abstract void a(NBTTagCompound nbttagcompound);
|
||||
diff --git a/src/main/java/net/minecraft/server/KeyedObject.java b/src/main/java/net/minecraft/server/KeyedObject.java
|
||||
new file mode 100644
|
||||
index 000000000..61c2b993c
|
||||
index 0000000000..61c2b993c9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/KeyedObject.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@@ -60,7 +65,7 @@ index 000000000..61c2b993c
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
index 5a5a588e7..672ba3134 100644
|
||||
index 5a5a588e7c..0176ca530c 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
@@ -79,16 +84,21 @@ index 5a5a588e7..672ba3134 100644
|
||||
- @Nullable
|
||||
- public static MinecraftKey a(Class<? extends TileEntity> oclass) {
|
||||
+ // Paper start
|
||||
+ public final MinecraftKey tileEntityKey = getKey(this.getClass());
|
||||
+ public final String tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null;
|
||||
+ private String tileEntityKeyString = null;
|
||||
+ private MinecraftKey tileEntityKey = getMinecraftKey();
|
||||
+
|
||||
+ @Override
|
||||
+ public MinecraftKey getMinecraftKey() {
|
||||
+ if (tileEntityKey == null) {
|
||||
+ tileEntityKey = getKey(this.getClass());
|
||||
+ tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null;
|
||||
+ }
|
||||
+ return tileEntityKey;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getMinecraftKeyString() {
|
||||
+ getMinecraftKey(); // Try to load if it doesn't exists.
|
||||
+ return tileEntityKeyString;
|
||||
+ }
|
||||
+ @Nullable public static MinecraftKey getKey(Class<? extends TileEntity> oclass) { return a(oclass); } // Paper - OBFHELPER
|
||||
|
Reference in New Issue
Block a user