Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
73983e4c16
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: 3dc4cdcd Update to Minecraft 1.14.3-pre4 88b25a8c SPIGOT-5098: Add a method to allow colored sign changes 6d913552 Update to Minecraft 1.14.3-pre4 CraftBukkit Changes:f1f33559
Update to Minecraft 1.14.38a3d3f49
SPIGOT-5098: Add a method to allow colored sign changes533290e2
SPIGOT-5100: Console warning from pig zombie targeting6dde4b9f
SPIGOT-5094: Allow opening merchant for wandering traders and hide the xp bar for custom merchants9af90077
SPIGOT-5097: Bukkit.clearRecipes() no longer working38fa220f
Fix setting game rules via the APIfe3930ce
Update to Minecraft 1.14.3-pre4da071ec5
Remove outdated build delay. Spigot Changes: 4d2f30f1 Update to Minecraft 1.14.3 f16400e3 Update to Minecraft 1.14.3-pre4
146 Zeilen
5.9 KiB
Diff
146 Zeilen
5.9 KiB
Diff
From 9288b14bdaf7935ff4fbfbdea3642072a8d737fa 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 5626ae4e3a..360abc05e4 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
@@ -175,7 +175,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 3d03fb1b87..7e347c7c99 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;
|
|
@@ -1731,12 +1731,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 a(NBTTagCompound nbttagcompound);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
index f603950b2e..eaacc9bff8 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
@@ -238,6 +238,7 @@ public class EntityTypes<T extends Entity> {
|
|
}
|
|
}
|
|
|
|
+ public boolean isPersistable() { return a(); } // Paper - OBFHELPER
|
|
public boolean a() {
|
|
return this.bb;
|
|
}
|
|
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 0000000000..743142d030
|
|
--- /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 5b0153352f..8f9820f492 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 final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
|
// CraftBukkit end
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
- private final TileEntityTypes<?> b;
|
|
+ private final TileEntityTypes<?> b; public TileEntityTypes getTileEntityType() { return b; } // Paper - OBFHELPER
|
|
@Nullable
|
|
protected World world;
|
|
protected BlockPosition position;
|
|
@@ -33,6 +33,26 @@ public abstract class TileEntity {
|
|
this.b = 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;
|
|
--
|
|
2.22.0
|
|
|