2018-07-23 06:46:13 +08:00
|
|
|
From 6e81d6e82a4e7ba0d6c513918f3a3f597851df36 Mon Sep 17 00:00:00 2001
|
2018-07-04 15:55:24 +08: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
|
|
|
|
|
2018-07-15 09:53:17 +08:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
|
|
index a0ebc1eaa..e4c771a39 100644
|
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
|
|
@@ -171,7 +171,7 @@ public class PaperCommand extends Command {
|
|
|
|
|
|
|
|
List<Entity> entities = world.entityList;
|
|
|
|
entities.forEach(e -> {
|
|
|
|
- MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch
|
|
|
|
+ MinecraftKey key = e.getMinecraftKey();
|
|
|
|
|
|
|
|
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
|
|
|
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
|
|
|
|
@@ -234,5 +234,5 @@ public class PaperCommand extends Command {
|
|
|
|
|
|
|
|
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Paper config reload complete.");
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+
|
|
|
|
}
|
2018-07-04 15:55:24 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2018-07-23 06:46:13 +08:00
|
|
|
index 3fa32228b..e65558f7a 100644
|
2018-07-04 15:55:24 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2018-07-15 09:53:17 +08:00
|
|
|
@@ -45,7 +45,7 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
2018-07-04 15:55:24 +08:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2018-07-15 09:53:17 +08:00
|
|
|
-public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
|
|
+public abstract class Entity implements INamableTileEntity, ICommandListener, KeyedObject { // Paper
|
2018-07-04 15:55:24 +08:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
private static final int CURRENT_LEVEL = 2;
|
2018-07-15 09:53:17 +08:00
|
|
|
@@ -73,7 +73,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
|
|
private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
|
|
|
|
private static double c = 1.0D;
|
|
|
|
private static int entityCount;
|
|
|
|
- private final EntityTypes<?> g;
|
|
|
|
+ private final EntityTypes<?> g; public EntityTypes<?> getEntityType() { return g; } // Paper - OBFHELPER
|
|
|
|
private int id;
|
|
|
|
public boolean j;
|
|
|
|
public final List<Entity> passengers;
|
|
|
|
@@ -197,6 +197,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
|
|
} else {
|
|
|
|
this.defaultActivationState = false;
|
|
|
|
}
|
|
|
|
+ // Paper start
|
|
|
|
+ this.entityKey = EntityTypes.getName(entitytypes);
|
|
|
|
+ this.entityKeyString = this.entityKey != null ? this.entityKey.toString() : null;
|
|
|
|
+ // Paper end
|
|
|
|
// Spigot end
|
|
|
|
|
|
|
|
this.datawatcher = new DataWatcher(this);
|
|
|
|
@@ -1781,12 +1785,24 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
2018-07-04 15:55:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2018-07-15 09:53:17 +08:00
|
|
|
+ public final MinecraftKey entityKey;
|
|
|
|
+ public final String entityKeyString;
|
2018-07-04 15:55:24 +08:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
|
|
+ return entityKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getMinecraftKeyString() {
|
|
|
|
+ return entityKeyString;
|
|
|
|
+ }
|
|
|
|
@Nullable
|
|
|
|
public final String getSaveID() {
|
2018-07-15 09:53:17 +08:00
|
|
|
- EntityTypes entitytypes = this.P();
|
|
|
|
- MinecraftKey minecraftkey = EntityTypes.getName(entitytypes);
|
2018-07-04 15:55:24 +08:00
|
|
|
-
|
2018-07-15 09:53:17 +08:00
|
|
|
- return entitytypes.a() && minecraftkey != null ? minecraftkey.toString() : null;
|
|
|
|
+ EntityTypes type = this.getEntityType();
|
|
|
|
+ return type != null && type.isPersistable() ? entityKeyString : null;
|
2018-07-04 15:55:24 +08:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract void a(NBTTagCompound nbttagcompound);
|
2018-07-15 09:53:17 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
2018-07-23 06:46:13 +08:00
|
|
|
index 9a513b4e3..fa268f354 100644
|
2018-07-15 09:53:17 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
2018-07-23 06:46:13 +08:00
|
|
|
@@ -238,6 +238,7 @@ public class EntityTypes<T extends Entity> {
|
2018-07-15 09:53:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public boolean isPersistable() { return a(); } // Paper - OBFHELPER
|
|
|
|
public boolean a() {
|
|
|
|
return this.aV;
|
|
|
|
}
|
2018-07-04 15:55:24 +08:00
|
|
|
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
|
|
|
|
--- /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-23 06:46:13 +08:00
|
|
|
index 8a0453245..257dd1da9 100644
|
2018-07-04 15:55:24 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
2018-07-15 09:53:17 +08:00
|
|
|
@@ -7,11 +7,11 @@ import org.apache.logging.log4j.Logger;
|
2018-07-04 15:55:24 +08:00
|
|
|
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-15 09:53:17 +08:00
|
|
|
- private final TileEntityTypes<?> e;
|
|
|
|
+ private final TileEntityTypes<?> e; public TileEntityTypes getTileEntityType() { return e; } // Paper - OBFHELPER
|
|
|
|
protected World world;
|
|
|
|
protected BlockPosition position;
|
|
|
|
protected boolean d;
|
|
|
|
@@ -21,8 +21,25 @@ public abstract class TileEntity {
|
|
|
|
public TileEntity(TileEntityTypes<?> tileentitytypes) {
|
|
|
|
this.position = BlockPosition.ZERO;
|
|
|
|
this.e = tileentitytypes;
|
|
|
|
+ // Paper start
|
|
|
|
+ this.tileEntityKey = TileEntityTypes.a(tileentitytypes);
|
|
|
|
+ this.tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null;
|
2018-07-04 15:55:24 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 09:53:17 +08:00
|
|
|
+ public final MinecraftKey tileEntityKey;
|
|
|
|
+ public final String tileEntityKeyString;
|
2018-07-04 15:55:24 +08:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
|
|
+ return tileEntityKey;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getMinecraftKeyString() {
|
|
|
|
+ return tileEntityKeyString;
|
|
|
|
+ }
|
2018-07-15 09:53:17 +08:00
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Nullable
|
|
|
|
public World getWorld() {
|
|
|
|
return this.world;
|
2018-07-04 15:55:24 +08:00
|
|
|
--
|
|
|
|
2.18.0
|
|
|
|
|