From 5a75d2ebe70f1aae06c2a9dc86556f2ac5a21a43 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 9 Jun 2022 23:27:06 +0200 Subject: [PATCH] Minor patch changes --- ...ient-rendering-skulls-from-same-user.patch | 118 ------------------ patches/server/Fix-this-stupid-bullshit.patch | 2 +- ...Remove-unnecessary-itemmeta-handling.patch | 28 +++++ .../Sanitize-Sent-BlockEntity-NBT.patch | 2 +- ...-possibility-for-getServer-singleton.patch | 4 +- 5 files changed, 33 insertions(+), 121 deletions(-) delete mode 100644 patches/server/Fix-client-rendering-skulls-from-same-user.patch create mode 100644 patches/server/Remove-unnecessary-itemmeta-handling.patch diff --git a/patches/server/Fix-client-rendering-skulls-from-same-user.patch b/patches/server/Fix-client-rendering-skulls-from-same-user.patch deleted file mode 100644 index d03ce26e2c..0000000000 --- a/patches/server/Fix-client-rendering-skulls-from-same-user.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -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/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java -+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { - if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) { - // Spigot start - filter - stack = stack.copy(); -- CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); -+ // CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer needed due to NBT being supported - // Spigot end - nbttagcompound = stack.getTag(); -+ // Paper start -+ if (nbttagcompound != null && nbttagcompound.contains("SkullOwner", 10)) { -+ CompoundTag owner = nbttagcompound.getCompound("SkullOwner"); -+ if (owner.hasUUID("Id")) { -+ nbttagcompound.putUUID("SkullOwnerOrig", owner.getUUID("Id")); -+ net.minecraft.world.level.block.entity.SkullBlockEntity.sanitizeUUID(owner); -+ } -+ } -+ // Paper end - } - - this.writeNbt(nbttagcompound); -@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { - itemstack.setTag(this.readNbt()); - // 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.contains("SkullOwnerOrig")) { -+ CompoundTag owner = itemstack.tag.getCompound("SkullOwner"); -+ if (itemstack.tag.contains("SkullOwnerOrig")) { -+ owner.tags.put("Id", itemstack.tag.tags.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/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -0,0 +0,0 @@ public class ClientboundLevelChunkPacketData { - static ClientboundLevelChunkPacketData.BlockEntityInfo create(BlockEntity blockEntity) { - CompoundTag compoundTag = blockEntity.getUpdateTag(); - BlockPos blockPos = blockEntity.getBlockPos(); -+ if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { net.minecraft.world.level.block.entity.SkullBlockEntity.sanitizeTileEntityUUID(compoundTag); } // Paper - int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); - return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag); - } -diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java -@@ -0,0 +0,0 @@ import javax.annotation.Nullable; - import net.minecraft.Util; - import net.minecraft.core.BlockPos; - import net.minecraft.nbt.CompoundTag; -+import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.NbtUtils; - import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; - import net.minecraft.server.Services; -@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { - - @Override - public ClientboundBlockEntityDataPacket getUpdatePacket() { -- return ClientboundBlockEntityDataPacket.create(this); -+ return ClientboundBlockEntityDataPacket.create(this, e -> sanitizeTileEntityUUID(e.getUpdateTag())); // Paper - } - -+ // Paper start -+ public static CompoundTag sanitizeTileEntityUUID(CompoundTag cmp) { -+ CompoundTag owner = cmp.getCompound("Owner"); -+ if (!owner.isEmpty()) { -+ sanitizeUUID(owner); -+ } -+ return cmp; -+ } -+ -+ public static void sanitizeUUID(CompoundTag owner) { -+ CompoundTag properties = owner.getCompound("Properties"); -+ ListTag list = null; -+ if (!properties.isEmpty()) { -+ list = properties.getList("textures", 10); -+ } -+ -+ if (list != null && !list.isEmpty()) { -+ String textures = ((CompoundTag)list.get(0)).getString("Value"); -+ if (textures != null && textures.length() > 3) { -+ UUID uuid = UUID.nameUUIDFromBytes(textures.getBytes()); -+ owner.putUUID("Id", uuid); -+ return; -+ } -+ } -+ owner.putUUID("Id", UUID.randomUUID()); -+ } -+ // Paper end -+ - @Override - public CompoundTag getUpdateTag() { - return this.saveWithoutMetadata(); diff --git a/patches/server/Fix-this-stupid-bullshit.patch b/patches/server/Fix-this-stupid-bullshit.patch index d0711f324a..ecf47848c0 100644 --- a/patches/server/Fix-this-stupid-bullshit.patch +++ b/patches/server/Fix-this-stupid-bullshit.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!Bootstrap.isBootstrapped) { // CraftBukkit start - String name = Bootstrap.class.getSimpleName(); -+ /*String name = Bootstrap.class.getSimpleName(); // Paper - actually, I don't think this class should ever have been called DispenserRegistry, that's a stupid name, bootstrap is waaay better ++ /*String name = Bootstrap.class.getSimpleName(); // Paper switch (name) { case "DispenserRegistry": break; diff --git a/patches/server/Remove-unnecessary-itemmeta-handling.patch b/patches/server/Remove-unnecessary-itemmeta-handling.patch new file mode 100644 index 0000000000..7f118f680d --- /dev/null +++ b/patches/server/Remove-unnecessary-itemmeta-handling.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Tue, 22 Nov 2016 00:40:42 -0500 +Subject: [PATCH] Remove unnecessary itemmeta handling + + +diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java ++++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { + if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) { + // Spigot start - filter + stack = stack.copy(); +- CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); ++ // CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer with raw NBT being handled in metadata + // Spigot end + nbttagcompound = stack.getTag(); + } +@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { + + itemstack.setTag(this.readNbt()); + // CraftBukkit start +- if (itemstack.getTag() != null) { ++ if (false && itemstack.getTag() != null) { // Paper - This is no longer needed with raw NBT being handled in metadata + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end diff --git a/patches/server/Sanitize-Sent-BlockEntity-NBT.patch b/patches/server/Sanitize-Sent-BlockEntity-NBT.patch index a6f2dd2d73..904d5194ac 100644 --- a/patches/server/Sanitize-Sent-BlockEntity-NBT.patch +++ b/patches/server/Sanitize-Sent-BlockEntity-NBT.patch @@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -0,0 +0,0 @@ public class ClientboundLevelChunkPacketData { + CompoundTag compoundTag = blockEntity.getUpdateTag(); BlockPos blockPos = blockEntity.getBlockPos(); - if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { net.minecraft.world.level.block.entity.SkullBlockEntity.sanitizeTileEntityUUID(compoundTag); } // Paper int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); + blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag); diff --git a/patches/server/remove-null-possibility-for-getServer-singleton.patch b/patches/server/remove-null-possibility-for-getServer-singleton.patch index c681830b29..50119dd9be 100644 --- a/patches/server/remove-null-possibility-for-getServer-singleton.patch +++ b/patches/server/remove-null-possibility-for-getServer-singleton.patch @@ -26,8 +26,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.profiler = this.metricsRecorder.getProfiler(); this.onMetricsRecordingStopped = (methodprofilerresults) -> { @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop