2019-12-16 02:58:10 +00:00
|
|
|
From c069ef9aa9b923df19d13d60c7a65f4b91691ac5 Mon Sep 17 00:00:00 2001
|
2018-08-05 00:42:27 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 22 Nov 2016 00:40:42 -0500
|
|
|
|
Subject: [PATCH] Fix client rendering skulls from same user
|
|
|
|
|
|
|
|
See: https://github.com/PaperMC/Paper/issues/1304
|
|
|
|
|
|
|
|
Changes the UUID sent to client to be based on either
|
|
|
|
the texture payload, or random.
|
|
|
|
|
|
|
|
This allows the client to render multiple skull textures from the same user,
|
|
|
|
for when different skins were used when skull was made.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
2019-12-16 02:58:10 +00:00
|
|
|
index 5fc7124dd5..33d9cac4de 100644
|
2018-08-05 00:42:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
2019-05-05 02:23:25 +00:00
|
|
|
@@ -54,7 +54,7 @@ public final class ItemStack {
|
2019-03-28 04:58:05 +00:00
|
|
|
// Paper end
|
2018-08-05 00:42:27 +00:00
|
|
|
@Deprecated
|
|
|
|
private Item item;
|
|
|
|
- private NBTTagCompound tag;
|
|
|
|
+ NBTTagCompound tag; // Paper -> package private
|
|
|
|
private boolean h;
|
|
|
|
private EntityItemFrame i;
|
|
|
|
private ShapeDetectorBlock j;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
2019-12-16 02:58:10 +00:00
|
|
|
index d9574a9ace..93ae6dcd78 100644
|
2018-08-05 00:42:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
2018-10-22 23:16:21 +00:00
|
|
|
@@ -253,6 +253,15 @@ public class PacketDataSerializer extends ByteBuf {
|
2018-08-05 00:42:27 +00:00
|
|
|
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
|
|
// Spigot end
|
|
|
|
nbttagcompound = itemstack.getTag();
|
|
|
|
+ // Paper start
|
|
|
|
+ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("SkullOwner", 10)) {
|
|
|
|
+ NBTTagCompound owner = nbttagcompound.getCompound("SkullOwner");
|
|
|
|
+ if (owner.hasKey("Id")) {
|
|
|
|
+ nbttagcompound.setString("SkullOwnerOrig", owner.getString("Id"));
|
|
|
|
+ TileEntitySkull.sanitizeUUID(owner);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
this.a(nbttagcompound);
|
2018-08-26 02:37:58 +00:00
|
|
|
@@ -272,6 +281,16 @@ public class PacketDataSerializer extends ByteBuf {
|
2019-05-05 02:23:25 +00:00
|
|
|
itemstack.setTag(this.l());
|
2018-08-05 00:42:27 +00:00
|
|
|
// CraftBukkit start
|
|
|
|
if (itemstack.getTag() != null) {
|
|
|
|
+ // Paper start - Fix skulls of same owner - restore orig ID since we changed it on send to client
|
|
|
|
+ if (itemstack.tag.hasKey("SkullOwnerOrig")) {
|
|
|
|
+ NBTTagCompound owner = itemstack.tag.getCompound("SkullOwner");
|
|
|
|
+ String ownerOrig = itemstack.tag.getString("SkullOwnerOrig");
|
|
|
|
+ if (!owner.isEmpty() && !ownerOrig.isEmpty()) {
|
|
|
|
+ owner.setString("Id", ownerOrig);
|
|
|
|
+ }
|
|
|
|
+ itemstack.tag.remove("SkullOwnerOrig");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2019-12-16 02:58:10 +00:00
|
|
|
index 3a1d0deb0d..1fcbbd698a 100644
|
2018-08-05 00:42:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2019-12-12 00:03:31 +00:00
|
|
|
@@ -58,6 +58,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
2019-01-01 03:15:55 +00:00
|
|
|
|
2018-08-05 00:42:27 +00:00
|
|
|
if (this.f() || (i & 1 << j) != 0) {
|
2019-05-05 02:23:25 +00:00
|
|
|
NBTTagCompound nbttagcompound = tileentity.b();
|
2018-08-05 00:42:27 +00:00
|
|
|
+ if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
|
2019-01-01 03:15:55 +00:00
|
|
|
|
2019-12-12 00:03:31 +00:00
|
|
|
this.g.add(nbttagcompound);
|
2018-08-05 00:42:27 +00:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
2019-12-16 02:58:10 +00:00
|
|
|
index 177cceb77f..0882d82cef 100644
|
2018-08-05 00:42:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
2018-08-26 18:11:49 +00:00
|
|
|
@@ -142,9 +142,37 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
2019-05-05 02:23:25 +00:00
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public PacketPlayOutTileEntityData getUpdatePacket() {
|
|
|
|
- return new PacketPlayOutTileEntityData(this.position, 4, this.b());
|
|
|
|
+ return new PacketPlayOutTileEntityData(this.position, 4, sanitizeTileEntityUUID(this.b())); // Paper
|
2018-08-05 00:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ static NBTTagCompound sanitizeTileEntityUUID(NBTTagCompound cmp) {
|
|
|
|
+ NBTTagCompound owner = cmp.getCompound("Owner");
|
|
|
|
+ if (!owner.isEmpty()) {
|
|
|
|
+ sanitizeUUID(owner);
|
|
|
|
+ }
|
|
|
|
+ return cmp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static void sanitizeUUID(NBTTagCompound owner) {
|
|
|
|
+ NBTTagCompound properties = owner.getCompound("Properties");
|
|
|
|
+ NBTTagList list = null;
|
|
|
|
+ if (!properties.isEmpty()) {
|
|
|
|
+ list = properties.getList("textures", 10);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
|
+ String textures = ((NBTTagCompound)list.get(0)).getString("Value");
|
|
|
|
+ if (textures != null && textures.length() > 3) {
|
|
|
|
+ String uuid = UUID.nameUUIDFromBytes(textures.getBytes()).toString();
|
|
|
|
+ owner.setString("Id", uuid);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ owner.setString("Id", UUID.randomUUID().toString());
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2019-05-05 02:23:25 +00:00
|
|
|
@Override
|
|
|
|
public NBTTagCompound b() {
|
|
|
|
return this.save(new NBTTagCompound());
|
2018-08-05 00:42:27 +00:00
|
|
|
--
|
2019-12-16 02:58:10 +00:00
|
|
|
2.24.1
|
2018-08-05 00:42:27 +00:00
|
|
|
|