2018-07-27 05:57:31 +02:00
|
|
|
From de17c631c117b92a3cb3256819347d169ed0225b Mon Sep 17 00:00:00 2001
|
2018-07-04 09:55:24 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 4 Jul 2018 01:40:13 -0400
|
|
|
|
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
|
2018-07-27 05:57:31 +02:00
|
|
|
index ed39b122ec..06c72b95f3 100644
|
2018-07-04 09:55:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
@@ -41,7 +41,7 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
-public abstract class Entity implements ICommandListener {
|
|
|
|
+public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
private static final int CURRENT_LEVEL = 2;
|
2018-07-27 05:57:31 +02:00
|
|
|
@@ -1702,11 +1702,28 @@ public abstract class Entity implements ICommandListener {
|
2018-07-04 09:55:24 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2018-07-27 05:57:31 +02:00
|
|
|
+ private String entityKeyString = null;
|
|
|
|
+ private MinecraftKey entityKey = getMinecraftKey();
|
2018-07-04 09:55:24 +02:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MinecraftKey getMinecraftKey() {
|
2018-07-27 05:57:31 +02:00
|
|
|
+ if (entityKey == null) {
|
|
|
|
+ entityKey = EntityTypes.getKey(this);
|
|
|
|
+ entityKeyString = entityKey != null ? entityKey.toString() : null;
|
|
|
|
+ }
|
2018-07-04 09:55:24 +02:00
|
|
|
+ return entityKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getMinecraftKeyString() {
|
2018-07-27 05:57:31 +02:00
|
|
|
+ getMinecraftKey(); // Try to load if it doesn't exists. see: https://github.com/PaperMC/Paper/issues/1280
|
2018-07-04 09:55:24 +02:00
|
|
|
+ return entityKeyString;
|
|
|
|
+ }
|
|
|
|
@Nullable
|
|
|
|
public final String getSaveID() {
|
|
|
|
- MinecraftKey minecraftkey = EntityTypes.a(this);
|
|
|
|
-
|
|
|
|
- return minecraftkey == null ? null : minecraftkey.toString();
|
2018-07-27 05:57:31 +02:00
|
|
|
+ return getMinecraftKeyString();
|
2018-07-04 09:55:24 +02:00
|
|
|
+ // 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
|
2018-07-27 05:57:31 +02:00
|
|
|
index 0000000000..61c2b993c9
|
2018-07-04 09:55:24 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/net/minecraft/server/KeyedObject.java
|
|
|
|
@@ -0,0 +1,8 @@
|
|
|
|
+package net.minecraft.server;
|
|
|
|
+
|
|
|
|
+public interface KeyedObject {
|
|
|
|
+ MinecraftKey getMinecraftKey();
|
|
|
|
+ default String getMinecraftKeyString() {
|
|
|
|
+ return getMinecraftKey().toString();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
2018-07-27 05:57:31 +02:00
|
|
|
index 5a5a588e7c..0176ca530c 100644
|
2018-07-04 09:55:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
@@ -7,7 +7,7 @@ import org.apache.logging.log4j.Logger;
|
|
|
|
import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
|
|
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
|
|
|
|
|
|
|
-public abstract class TileEntity {
|
|
|
|
+public abstract class TileEntity implements KeyedObject {
|
|
|
|
|
|
|
|
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
|
|
private static final Logger a = LogManager.getLogger();
|
2018-07-27 05:57:31 +02:00
|
|
|
@@ -27,8 +27,26 @@ public abstract class TileEntity {
|
2018-07-04 09:55:24 +02:00
|
|
|
TileEntity.f.a(new MinecraftKey(s), oclass);
|
|
|
|
}
|
|
|
|
|
|
|
|
- @Nullable
|
|
|
|
- public static MinecraftKey a(Class<? extends TileEntity> oclass) {
|
|
|
|
+ // Paper start
|
2018-07-27 05:57:31 +02:00
|
|
|
+ private String tileEntityKeyString = null;
|
|
|
|
+ private MinecraftKey tileEntityKey = getMinecraftKey();
|
2018-07-04 09:55:24 +02:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MinecraftKey getMinecraftKey() {
|
2018-07-27 05:57:31 +02:00
|
|
|
+ if (tileEntityKey == null) {
|
|
|
|
+ tileEntityKey = getKey(this.getClass());
|
|
|
|
+ tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null;
|
|
|
|
+ }
|
2018-07-04 09:55:24 +02:00
|
|
|
+ return tileEntityKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getMinecraftKeyString() {
|
2018-07-27 05:57:31 +02:00
|
|
|
+ getMinecraftKey(); // Try to load if it doesn't exists.
|
2018-07-04 09:55:24 +02:00
|
|
|
+ return tileEntityKeyString;
|
|
|
|
+ }
|
|
|
|
+ @Nullable public static MinecraftKey getKey(Class<? extends TileEntity> oclass) { return a(oclass); } // Paper - OBFHELPER
|
|
|
|
+ @Nullable public static MinecraftKey a(Class<? extends TileEntity> oclass) {
|
|
|
|
return (MinecraftKey) TileEntity.f.b(oclass);
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
|
|
|
2.18.0
|
|
|
|
|