2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-08-05 02:42:27 +02: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
|
2021-02-16 18:08:29 +01:00
|
|
|
index bdb6f9bf3477f85859e3f0dd761e2e895f1a8e2b..22568201a292edc8e25396e55cad1572d419b775 100644
|
2018-08-05 02:42:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -60,7 +60,7 @@ public final class ItemStack {
|
|
|
|
private int g;
|
2018-08-05 02:42:27 +02:00
|
|
|
@Deprecated
|
|
|
|
private Item item;
|
|
|
|
- private NBTTagCompound tag;
|
|
|
|
+ NBTTagCompound tag; // Paper -> package private
|
2020-06-25 16:09:55 +02:00
|
|
|
private boolean j;
|
|
|
|
private Entity k;
|
|
|
|
private ShapeDetectorBlock l;
|
2018-08-05 02:42:27 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
2021-02-27 12:02:06 +01:00
|
|
|
index 391f96e585d80f7921fd96f207b0b60d88961ae7..3a257d3b0a6adb4d0a43833b996d70765559eff8 100644
|
2018-08-05 02:42:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
2021-02-27 12:02:06 +01:00
|
|
|
@@ -298,9 +298,18 @@ public class PacketDataSerializer extends ByteBuf {
|
2020-06-25 16:09:55 +02:00
|
|
|
if (item.usesDurability() || item.n()) {
|
2020-04-22 17:11:50 +02:00
|
|
|
// Spigot start - filter
|
|
|
|
itemstack = itemstack.cloneItemStack();
|
|
|
|
- CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
|
|
+ //CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer needed due to NBT being supported
|
2018-08-05 02:42:27 +02:00
|
|
|
// Spigot end
|
|
|
|
nbttagcompound = itemstack.getTag();
|
|
|
|
+ // Paper start
|
|
|
|
+ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("SkullOwner", 10)) {
|
|
|
|
+ NBTTagCompound owner = nbttagcompound.getCompound("SkullOwner");
|
2020-07-01 09:13:57 +02:00
|
|
|
+ if (owner.hasUUID("Id")) {
|
|
|
|
+ nbttagcompound.setUUID("SkullOwnerOrig", owner.getUUID("Id"));
|
2018-08-05 02:42:27 +02:00
|
|
|
+ TileEntitySkull.sanitizeUUID(owner);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
this.a(nbttagcompound);
|
2021-02-27 12:02:06 +01:00
|
|
|
@@ -320,7 +329,16 @@ public class PacketDataSerializer extends ByteBuf {
|
2019-05-05 04:23:25 +02:00
|
|
|
itemstack.setTag(this.l());
|
2018-08-05 02:42:27 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (itemstack.getTag() != null) {
|
2020-04-22 17:11:50 +02:00
|
|
|
- CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
2018-08-05 02:42:27 +02:00
|
|
|
+ // 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");
|
2020-06-29 02:33:14 +02:00
|
|
|
+ if (itemstack.tag.hasKey("SkullOwnerOrig")) {
|
|
|
|
+ owner.map.put("Id", itemstack.tag.map.get("SkullOwnerOrig"));
|
2020-06-29 00:04:04 +02:00
|
|
|
+ itemstack.tag.remove("SkullOwnerOrig");
|
2018-08-05 02:42:27 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2020-04-22 17:11:50 +02:00
|
|
|
+ // CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer needed due to NBT being supported
|
2018-08-05 02:42:27 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2020-04-22 17:11:50 +02:00
|
|
|
return itemstack;
|
2018-08-05 02:42:27 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 36a7e41cc5036345929ebf4d2fa160a8c16c2c0a..0ef4fbb19fc816f578ad741c4406790f4185093d 100644
|
2018-08-05 02:42:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -58,6 +58,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2018-08-05 02:42:27 +02:00
|
|
|
if (this.f() || (i & 1 << j) != 0) {
|
2019-05-05 04:23:25 +02:00
|
|
|
NBTTagCompound nbttagcompound = tileentity.b();
|
2018-08-05 02:42:27 +02:00
|
|
|
+ if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-12-12 01:03:31 +01:00
|
|
|
this.g.add(nbttagcompound);
|
2018-08-05 02:42:27 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
2020-06-29 00:04:04 +02:00
|
|
|
index 4fae1b3274a96b871b39de083e9b28ab6129533f..579a81e521fdfabfa0318d06c6760a8ab7a88c1e 100644
|
2018-08-05 02:42:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -145,9 +145,37 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
2019-05-05 04:23:25 +02: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 02:42:27 +02: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) {
|
2020-06-29 00:04:04 +02:00
|
|
|
+ UUID uuid = UUID.nameUUIDFromBytes(textures.getBytes());
|
|
|
|
+ owner.setUUID("Id", uuid);
|
2018-08-05 02:42:27 +02:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
2020-06-29 00:04:04 +02:00
|
|
|
+ owner.setUUID("Id", UUID.randomUUID());
|
2018-08-05 02:42:27 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2019-05-05 04:23:25 +02:00
|
|
|
@Override
|
|
|
|
public NBTTagCompound b() {
|
|
|
|
return this.save(new NBTTagCompound());
|