Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
ab347c4c96
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 42d5a714 SPIGOT-5899: Hoglins API similar to Piglins 2c1ee10e SPIGOT-5887: ClickType doesn't include off hand swaps 5ff7c7ce SPIGOT-5886: Missing BlockData CraftBukkit Changes:7560f5f5
SPIGOT-5905: Fix hex colours not being allowed in MOTDd47c47ee
SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent2fe6b4a3
SPIGOT-5899: Hoglins API similar to Piglinse09dbeca
SPIGOT-5887: ClickType doesn't include off hand swaps23aac2a5
SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously92cbf656
SPIGOT-5884: Tab completions lost on reloadData / minecraft:reloadfb4e54ad
SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is calledaa8f3d5a
SPIGOT-5901: Structures are generated in all worlds based on the setting for the main worlda0c35937
SPIGOT-5895: PlayerChangedWorldEvent#getFrom is incorrect89c0a5c3
SPIGOT-5886: Missing BlockData Spigot Changes: 0287a20d SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
143 Zeilen
6.1 KiB
Diff
143 Zeilen
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
index 41c79650b169b87fbc70cf502438a5453a04f23d..b839769ceae8932bb121a0b96fde1e7d129a1f63 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
@@ -178,7 +178,7 @@ public class PaperCommand extends Command {
|
|
|
|
Collection<Entity> entities = world.entitiesById.values();
|
|
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());
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 9da321fc0e02e4a2e47f515011df33714affd368..ee93b977b5f78855fd58a2055ca4e17255f3388b 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -49,7 +49,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|
import org.bukkit.plugin.PluginManager;
|
|
// CraftBukkit end
|
|
|
|
-public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
+public abstract class Entity implements INamableTileEntity, ICommandListener, KeyedObject { // Paper
|
|
|
|
// CraftBukkit start
|
|
private static final int CURRENT_LEVEL = 2;
|
|
@@ -1670,12 +1670,31 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
return true;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ private MinecraftKey entityKey;
|
|
+ private String entityKeyString;
|
|
+
|
|
+ @Override
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
+ if (entityKey == null) {
|
|
+ this.entityKey = EntityTypes.getName(this.getEntityType());
|
|
+ this.entityKeyString = this.entityKey != null ? this.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
|
|
public final String getSaveID() {
|
|
EntityTypes<?> entitytypes = this.getEntityType();
|
|
MinecraftKey minecraftkey = EntityTypes.getName(entitytypes);
|
|
|
|
- return entitytypes.a() && minecraftkey != null ? minecraftkey.toString() : null;
|
|
+ return entitytypes != null && entitytypes.isPersistable() ? getMinecraftKeyString() : null;
|
|
+ // Paper end
|
|
}
|
|
|
|
protected abstract void loadData(NBTTagCompound nbttagcompound);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
index 9a772e40ad8f9858e6278b99d9d1ff5dc54513cb..b9fe08301409bc1f0d61a7566c26e720ff720d80 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
@@ -248,6 +248,7 @@ public class EntityTypes<T extends Entity> {
|
|
}
|
|
}
|
|
|
|
+ public boolean isPersistable() { return a(); } // Paper - OBFHELPER
|
|
public boolean a() {
|
|
return this.bh;
|
|
}
|
|
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 0000000000000000000000000000000000000000..743142d0303fa25fe48a2abb07040d1228d04402
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/KeyedObject.java
|
|
@@ -0,0 +1,9 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+public interface KeyedObject {
|
|
+ MinecraftKey getMinecraftKey();
|
|
+ default String getMinecraftKeyString() {
|
|
+ MinecraftKey key = getMinecraftKey();
|
|
+ return key != null ? key.toString() : null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
|
index 6d06812f5fb6366ccd2673e9155be869b9bc0f6d..3cae7ef750371cee741c2f27799c1bb5864a278a 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
@@ -11,7 +11,7 @@ import org.bukkit.inventory.InventoryHolder;
|
|
// CraftBukkit end
|
|
import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
|
|
-public abstract class TileEntity {
|
|
+public abstract class TileEntity implements KeyedObject { // Paper
|
|
|
|
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
// CraftBukkit start - data containers
|
|
@@ -19,7 +19,7 @@ public abstract class TileEntity {
|
|
public CraftPersistentDataContainer persistentDataContainer;
|
|
// CraftBukkit end
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
- private final TileEntityTypes<?> tileType;
|
|
+ private final TileEntityTypes<?> tileType; public TileEntityTypes getTileEntityType() { return tileType; } // Paper - OBFHELPER
|
|
@Nullable
|
|
protected World world;
|
|
protected BlockPosition position;
|
|
@@ -33,6 +33,26 @@ public abstract class TileEntity {
|
|
this.tileType = tileentitytypes;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ private String tileEntityKeyString = null;
|
|
+ private MinecraftKey tileEntityKey = null;
|
|
+
|
|
+ @Override
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
+ if (tileEntityKey == null) {
|
|
+ tileEntityKey = TileEntityTypes.a(this.getTileEntityType());
|
|
+ tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null;
|
|
+ }
|
|
+ return tileEntityKey;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getMinecraftKeyString() {
|
|
+ getMinecraftKey(); // Try to load if it doesn't exists.
|
|
+ return tileEntityKeyString;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Nullable
|
|
public World getWorld() {
|
|
return this.world;
|