mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 05:55:44 +01:00
bc127ea819
Upstream has released updates that appear 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: eec4aab0 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent 205213c6 SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron CraftBukkit Changes: b8c522d5 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent f04a77dc SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron d1dbcebc SPIGOT-6653: Canceling snow bucket placement removes snow from bucket 4f34a67b #891: Fix scheduler task ID overflow and duplication issues Spigot Changes: d03d7f12 BUILDTOOLS-604: Rebuild patches
125 lines
5.3 KiB
Diff
125 lines
5.3 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 bee2fa2bfbb61209381f24ed6508d3d1c73a344a..1fa190e098079522e0fe3593fa261c1b7ad4e24b 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
@@ -207,7 +207,7 @@ public class PaperCommand extends Command {
|
|
ServerChunkCache chunkProviderServer = world.getChunkSource();
|
|
|
|
world.getAllEntities().forEach(e -> {
|
|
- ResourceLocation key = new ResourceLocation(""); // TODO: update in next patch
|
|
+ ResourceLocation key = e.getMinecraftKey();
|
|
|
|
MutablePair<Integer, Map<ChunkPos, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
|
ChunkPos chunk = e.chunkPosition();
|
|
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..d02bd109399d6b32cbbb5e6f9ec7e650e8299a26
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/KeyedObject.java
|
|
@@ -0,0 +1,12 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+
|
|
+// TODO(Mariell Hoversholm): Move stupid ass class
|
|
+public interface KeyedObject {
|
|
+ ResourceLocation getMinecraftKey();
|
|
+ default String getMinecraftKeyString() {
|
|
+ ResourceLocation key = getMinecraftKey();
|
|
+ return key != null ? key.toString() : null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 0443353c7be86952b83a089b0bd591d37989a459..0b13a1464a9e6c4912e737879b00ae14da99fbf5 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -146,7 +146,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|
import org.bukkit.plugin.PluginManager;
|
|
// CraftBukkit end
|
|
|
|
-public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
+public abstract class Entity implements Nameable, EntityAccess, CommandSource, net.minecraft.server.KeyedObject { // Paper
|
|
|
|
// CraftBukkit start
|
|
private static final int CURRENT_LEVEL = 2;
|
|
@@ -1954,12 +1954,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
return true;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ private ResourceLocation entityKey;
|
|
+ private String entityKeyString;
|
|
+
|
|
+ @Override
|
|
+ public ResourceLocation getMinecraftKey() {
|
|
+ if (entityKey == null) {
|
|
+ this.entityKey = EntityType.getKey(this.getType());
|
|
+ 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 getEncodeId() {
|
|
EntityType<?> entitytypes = this.getType();
|
|
ResourceLocation minecraftkey = EntityType.getKey(entitytypes);
|
|
|
|
- return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
|
|
+ return entitytypes != null && entitytypes.canSerialize() ? getMinecraftKeyString() : null;
|
|
+ // Paper end
|
|
}
|
|
|
|
protected abstract void readAdditionalSaveData(CompoundTag nbt);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
|
index 33884161de688c47c90a7b86196234acc80f9434..92b042080f06fb95958ff5e824830a84f2d1f2a6 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
|
@@ -20,7 +20,7 @@ import org.bukkit.inventory.InventoryHolder;
|
|
|
|
import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
|
|
-public abstract class BlockEntity {
|
|
+public abstract class BlockEntity implements net.minecraft.server.KeyedObject { // Paper
|
|
|
|
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
// CraftBukkit start - data containers
|
|
@@ -41,6 +41,26 @@ public abstract class BlockEntity {
|
|
this.blockState = state;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ private String tileEntityKeyString = null;
|
|
+ private ResourceLocation tileEntityKey = null;
|
|
+
|
|
+ @Override
|
|
+ public ResourceLocation getMinecraftKey() {
|
|
+ if (tileEntityKey == null) {
|
|
+ tileEntityKey = BlockEntityType.getKey(this.type);
|
|
+ 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 Level getLevel() {
|
|
return this.level;
|