Paper/Spigot-Server-Patches/0264-Fix-client-rendering-skulls-from-same-user.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

124 lines
6.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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
index 1a28e6f20340920c35bcd87a0dbfdcd745c79706..64e9d50be03cbefa521bf8c2e6dba5ceadda78b6 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -60,7 +60,7 @@ public final class ItemStack {
private int g;
@Deprecated
private Item item;
- private NBTTagCompound tag;
+ NBTTagCompound tag; // Paper -> package private
private boolean j;
private Entity k;
private ShapeDetectorBlock l;
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index 2976e8cc2da6e54e08e50ca1f5de5669823ef3f7..ee24acdd5e843e5421bf83bd6c069a4ecca09115 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -284,9 +284,18 @@ public class PacketDataSerializer extends ByteBuf {
if (item.usesDurability() || item.n()) {
// 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
// Spigot end
nbttagcompound = itemstack.getTag();
+ // Paper start
+ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("SkullOwner", 10)) {
+ NBTTagCompound owner = nbttagcompound.getCompound("SkullOwner");
+ if (owner.hasUUID("Id")) {
+ nbttagcompound.setUUID("SkullOwnerOrig", owner.getUUID("Id"));
+ TileEntitySkull.sanitizeUUID(owner);
+ }
+ }
+ // Paper end
}
this.a(nbttagcompound);
@@ -306,7 +315,16 @@ public class PacketDataSerializer extends ByteBuf {
itemstack.setTag(this.l());
// CraftBukkit start
if (itemstack.getTag() != null) {
- CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+ // 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");
+ if (itemstack.tag.hasKey("SkullOwnerOrig")) {
+ owner.map.put("Id", itemstack.tag.map.get("SkullOwnerOrig"));
+ itemstack.tag.remove("SkullOwnerOrig");
+ }
+ }
+ // Paper end
+ // CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer needed due to NBT being supported
}
// CraftBukkit end
return itemstack;
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
index 36a7e41cc5036345929ebf4d2fa160a8c16c2c0a..0ef4fbb19fc816f578ad741c4406790f4185093d 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
@@ -58,6 +58,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
if (this.f() || (i & 1 << j) != 0) {
NBTTagCompound nbttagcompound = tileentity.b();
+ if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
this.g.add(nbttagcompound);
}
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
index 4fae1b3274a96b871b39de083e9b28ab6129533f..579a81e521fdfabfa0318d06c6760a8ab7a88c1e 100644
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
@@ -145,9 +145,37 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
@Nullable
@Override
public PacketPlayOutTileEntityData getUpdatePacket() {
- return new PacketPlayOutTileEntityData(this.position, 4, this.b());
+ return new PacketPlayOutTileEntityData(this.position, 4, sanitizeTileEntityUUID(this.b())); // Paper
}
+ // 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) {
+ UUID uuid = UUID.nameUUIDFromBytes(textures.getBytes());
+ owner.setUUID("Id", uuid);
+ return;
+ }
+ }
+ owner.setUUID("Id", UUID.randomUUID());
+ }
+ // Paper end
+
@Override
public NBTTagCompound b() {
return this.save(new NBTTagCompound());