Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-23 23:00:08 +01:00
230b8d4258
bfbd24c5
Fix decompile error (Hugo Manrique)1f5d23d9
Re-add Vanished players don't have rights patch (Hugo Manrique) * pull/1256/head: Fix decompile error Re-add Vanished players don't have rights patch
156 Zeilen
6.2 KiB
Diff
156 Zeilen
6.2 KiB
Diff
From 98687afc6aeac6f87995e5b56eef3a7d35398cd8 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 e8f7b7292d..7ff8e70b24 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());
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 29c7043c86..1a7d78a5c3 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -45,7 +45,7 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
|
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;
|
|
@@ -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 {
|
|
return true;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public final MinecraftKey entityKey;
|
|
+ public final String entityKeyString;
|
|
+
|
|
+ @Override
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
+ return entityKey;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getMinecraftKeyString() {
|
|
+ return entityKeyString;
|
|
+ }
|
|
@Nullable
|
|
public final String getSaveID() {
|
|
- EntityTypes entitytypes = this.P();
|
|
- MinecraftKey minecraftkey = EntityTypes.getName(entitytypes);
|
|
-
|
|
- return entitytypes.a() && minecraftkey != null ? minecraftkey.toString() : null;
|
|
+ EntityTypes type = this.getEntityType();
|
|
+ return type != null && type.isPersistable() ? entityKeyString : 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 9a513b4e3a..fa268f3543 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.aV;
|
|
}
|
|
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..61c2b993c9
|
|
--- /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
|
|
index 8a0453245d..257dd1da9c 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
@@ -7,11 +7,11 @@ 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();
|
|
- 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;
|
|
}
|
|
|
|
+ public final MinecraftKey tileEntityKey;
|
|
+ public final String tileEntityKeyString;
|
|
+
|
|
+ @Override
|
|
+ public MinecraftKey getMinecraftKey() {
|
|
+ return tileEntityKey;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getMinecraftKeyString() {
|
|
+ return tileEntityKeyString;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Nullable
|
|
public World getWorld() {
|
|
return this.world;
|
|
--
|
|
2.18.0
|
|
|