From 5052a4515e3ee0681eb065f8db91d678e958f0ab Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 9 Jun 2022 23:27:06 +0200 Subject: [PATCH] Minor patch changes --- ...-possibility-for-getServer-singleton.patch | 8 +- .../0148-Fix-this-stupid-bullshit.patch | 4 +- ...ient-rendering-skulls-from-same-user.patch | 118 ------------------ ...Remove-unnecessary-itemmeta-handling.patch | 28 +++++ ...-Add-tick-times-API-and-mspt-command.patch | 6 +- ...-profile-lookups-to-worldgen-threads.patch | 4 +- .../0736-Execute-chunk-tasks-mid-tick.patch | 6 +- ...valid-GameProfiles-on-skull-blocks-i.patch | 6 +- .../0898-Sanitize-Sent-BlockEntity-NBT.patch | 6 +- 9 files changed, 49 insertions(+), 137 deletions(-) delete mode 100644 patches/server/0236-Fix-client-rendering-skulls-from-same-user.patch create mode 100644 patches/server/0236-Remove-unnecessary-itemmeta-handling.patch diff --git a/patches/server/0089-remove-null-possibility-for-getServer-singleton.patch b/patches/server/0089-remove-null-possibility-for-getServer-singleton.patch index f46410865e..4013b485d6 100644 --- a/patches/server/0089-remove-null-possibility-for-getServer-singleton.patch +++ b/patches/server/0089-remove-null-possibility-for-getServer-singleton.patch @@ -6,7 +6,7 @@ Subject: [PATCH] remove null possibility for getServer singleton to stop IDE complaining about potential NPE diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 032ba4071f7562cd0c0bf3f2de46130692544ef0..681121909bdf81d5a05670f0b0150f6276d00281 100644 +index 032ba4071f7562cd0c0bf3f2de46130692544ef0..d3da5327f7826d10428c9fa8b9848fdb06afd04f 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -179,6 +179,7 @@ import co.aikar.timings.MinecraftTimings; // Paper @@ -25,9 +25,11 @@ index 032ba4071f7562cd0c0bf3f2de46130692544ef0..681121909bdf81d5a05670f0b0150f62 this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.profiler = this.metricsRecorder.getProfiler(); this.onMetricsRecordingStopped = (methodprofilerresults) -> { -@@ -2272,7 +2274,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -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 70631b3fe080320dfea0d1a4deb23e87448da250..9bffc37939586bcca0ae3d1c4aa3b0b96ad2b20d 100644 ---- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java -+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -579,9 +579,18 @@ 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); -@@ -601,7 +610,16 @@ 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 cc2f53fba1e5f6b6d4d31081ddaca1ace70abf99..56cc2169077fed1fe820d08dc14b3add63289add 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -151,6 +151,7 @@ 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 0c7e29b589ab106013d979a20edc415b4b32a677..170f051d820ee1add1b61a20dbd1f18f758717dc 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 -@@ -11,6 +11,7 @@ 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; -@@ -94,9 +95,37 @@ 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/0236-Remove-unnecessary-itemmeta-handling.patch b/patches/server/0236-Remove-unnecessary-itemmeta-handling.patch new file mode 100644 index 0000000000..88a7a7fd0c --- /dev/null +++ b/patches/server/0236-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 70631b3fe080320dfea0d1a4deb23e87448da250..35377576ed182814051c11f902e02e8e921e84e3 100644 +--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java ++++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +@@ -579,7 +579,7 @@ 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(); + } +@@ -600,7 +600,7 @@ 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/0373-Add-tick-times-API-and-mspt-command.patch b/patches/server/0373-Add-tick-times-API-and-mspt-command.patch index ca06c57356..d8a81ccb65 100644 --- a/patches/server/0373-Add-tick-times-API-and-mspt-command.patch +++ b/patches/server/0373-Add-tick-times-API-and-mspt-command.patch @@ -110,7 +110,7 @@ index 0000000000000000000000000000000000000000..874f0c2a071994c2145848886caa385e + } +} diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index 2e5718d720744967c5f2ba13805aad53a1dec593..61a26e9312b1a2d0b582778a178f73dbf702039b 100644 +index 5626a772908f7956a30a82ca73929b05c19f7268..1db8a3e4b547a3c78ae2df2e4dadb871eb80aa5d 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -1,5 +1,6 @@ @@ -129,7 +129,7 @@ index 2e5718d720744967c5f2ba13805aad53a1dec593..61a26e9312b1a2d0b582778a178f73db public static void registerCommands(final MinecraftServer server) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index bf97a9be49a8a187004ceb302db59c31f12e3e1b..7de1368bcde500ba133282537270fbdfd9c9d54b 100644 +index 8de56cabd8fdc68e136d41c4d172f3574e21e57a..f69ed252f55623ee5cba6ac9d28096c2cc92ea04 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -234,6 +234,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { consumer.accept(optional); 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 170f051d820ee1add1b61a20dbd1f18f758717dc..c1703a67a615f563dab4fb442a6df7082229af57 100644 +index 0c7e29b589ab106013d979a20edc415b4b32a677..c5d5d90d10b30f30d1262367b3d75df43fbdb231 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 -@@ -149,7 +149,7 @@ public class SkullBlockEntity extends BlockEntity { +@@ -120,7 +120,7 @@ public class SkullBlockEntity extends BlockEntity { public static void updateGameprofile(@Nullable GameProfile owner, Consumer callback) { if (owner != null && !StringUtil.isNullOrEmpty(owner.getName()) && (!owner.isComplete() || !owner.getProperties().containsKey("textures")) && profileCache != null && sessionService != null) { profileCache.getAsync(owner.getName(), (profile) -> { diff --git a/patches/server/0736-Execute-chunk-tasks-mid-tick.patch b/patches/server/0736-Execute-chunk-tasks-mid-tick.patch index f65e59a5d5..7cb0972dc3 100644 --- a/patches/server/0736-Execute-chunk-tasks-mid-tick.patch +++ b/patches/server/0736-Execute-chunk-tasks-mid-tick.patch @@ -19,7 +19,7 @@ index 3b717a6a1be16f780923e7ae3269462d3d082615..8563c66834b0b9e77bca42e4f916d82a private MinecraftTimings() {} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 93631f0a59781b8310f7bf66c0ed4781b833ef79..17efe9e0a17672b815c64491dbca70b7519b6aca 100644 +index b1a0f0b1bed05fbea5d21157317d08dd92ec78f0..6f078f69f4da1bd988f02156351c481b6da04b55 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1302,6 +1302,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { this.owner = owner; this.setChanged(); @@ -40,7 +40,7 @@ index c1703a67a615f563dab4fb442a6df7082229af57..4613a343d3ca5f76992f2bd1e55bdc08 Util.ifElse(profile, (profilex) -> { Property property = Iterables.getFirst(profilex.getProperties().get("textures"), (Property)null); if (property == null) { -@@ -166,6 +181,20 @@ public class SkullBlockEntity extends BlockEntity { +@@ -137,6 +152,20 @@ public class SkullBlockEntity extends BlockEntity { callback.accept(owner); }); }); diff --git a/patches/server/0898-Sanitize-Sent-BlockEntity-NBT.patch b/patches/server/0898-Sanitize-Sent-BlockEntity-NBT.patch index 132b836f4d..94cc4828bd 100644 --- a/patches/server/0898-Sanitize-Sent-BlockEntity-NBT.patch +++ b/patches/server/0898-Sanitize-Sent-BlockEntity-NBT.patch @@ -18,12 +18,12 @@ index 12d7cb0eb485987d245454fa2d9fef67ea7e9c76..b1e326cf4f7fe447f81b588dcb0eda9a public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) { 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 e902b437ee089907b34ae30c0a6bdf1d42e1e674..88a68a3e176b1cf0b514093b5089a1cba8ad7e06 100644 +index 23d76eb74a88610472aa0288559efbaa5cd916dc..6c30f3bf85ec0e0dfbae1b5ed192b43b1dbd48be 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -183,6 +183,7 @@ public class ClientboundLevelChunkPacketData { +@@ -182,6 +182,7 @@ 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);