2018-08-05 02:42:27 +02:00
|
|
|
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.
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/network/PacketDataSerializer.java b/src/main/java/net/minecraft/network/PacketDataSerializer.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/network/PacketDataSerializer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/PacketDataSerializer.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -0,0 +0,0 @@ import net.minecraft.network.chat.IChatBaseComponent;
|
|
|
|
import net.minecraft.resources.MinecraftKey;
|
|
|
|
import net.minecraft.world.item.Item;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
+import net.minecraft.world.level.block.entity.TileEntitySkull;
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
|
|
|
|
2018-08-05 02:42:27 +02:00
|
|
|
@@ -0,0 +0,0 @@ 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);
|
|
|
|
@@ -0,0 +0,0 @@ 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;
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -0,0 +0,0 @@ import net.minecraft.network.PacketDataSerializer;
|
|
|
|
import net.minecraft.network.protocol.Packet;
|
|
|
|
import net.minecraft.world.level.ChunkCoordIntPair;
|
|
|
|
import net.minecraft.world.level.block.entity.TileEntity;
|
|
|
|
+import net.minecraft.world.level.block.entity.TileEntitySkull;
|
|
|
|
import net.minecraft.world.level.chunk.BiomeStorage;
|
|
|
|
import net.minecraft.world.level.chunk.Chunk;
|
|
|
|
import net.minecraft.world.level.chunk.ChunkSection;
|
2018-08-05 02:42:27 +02:00
|
|
|
@@ -0,0 +0,0 @@ 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
|
|
|
}
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
@@ -0,0 +0,0 @@ public final class ItemStack {
|
|
|
|
private int g;
|
|
|
|
@Deprecated
|
|
|
|
private Item item;
|
|
|
|
- private NBTTagCompound tag;
|
2021-03-16 16:50:45 +01:00
|
|
|
+ public NBTTagCompound tag; // Paper private -> public
|
2021-03-16 08:19:45 +01:00
|
|
|
private boolean j;
|
|
|
|
private Entity k;
|
|
|
|
private ShapeDetectorBlock l;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -0,0 +0,0 @@ import java.util.UUID;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import net.minecraft.nbt.GameProfileSerializer;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
+import net.minecraft.nbt.NBTTagList;
|
|
|
|
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
|
|
|
|
import net.minecraft.server.players.UserCache;
|
|
|
|
import net.minecraft.util.UtilColor;
|
2018-08-05 02:42:27 +02:00
|
|
|
@@ -0,0 +0,0 @@ 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
|
2021-03-16 14:04:28 +01:00
|
|
|
+ public static NBTTagCompound sanitizeTileEntityUUID(NBTTagCompound cmp) {
|
2018-08-05 02:42:27 +02:00
|
|
|
+ NBTTagCompound owner = cmp.getCompound("Owner");
|
|
|
|
+ if (!owner.isEmpty()) {
|
|
|
|
+ sanitizeUUID(owner);
|
|
|
|
+ }
|
|
|
|
+ return cmp;
|
|
|
|
+ }
|
|
|
|
+
|
2021-03-16 16:50:45 +01:00
|
|
|
+ public static void sanitizeUUID(NBTTagCompound owner) {
|
2018-08-05 02:42:27 +02:00
|
|
|
+ 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());
|