aboutsummaryrefslogtreecommitdiffhomepage
path: root/removed-patches-1-20-5
diff options
context:
space:
mode:
authorOwen1212055 <[email protected]>2024-04-25 08:36:48 -0400
committerOwen1212055 <[email protected]>2024-04-25 08:36:48 -0400
commit345b5c1c4c3f99756029f039b8e063ed6f8c3181 (patch)
treec229a0fd351d859a98e60ccce197b358a8a9fb62 /removed-patches-1-20-5
parent6da0d8cc91be3b8e1c84c0436f49654cdde6de2f (diff)
downloadPaper-345b5c1c4c3f99756029f039b8e063ed6f8c3181.tar.gz
Paper-345b5c1c4c3f99756029f039b8e063ed6f8c3181.zip
Patches!!!!!!! (we are done)
Diffstat (limited to 'removed-patches-1-20-5')
-rw-r--r--removed-patches-1-20-5/0675-Prevent-sending-oversized-item-data-in-equipment-and.patch88
-rw-r--r--removed-patches-1-20-5/0693-Fix-bees-aging-inside-hives.patch51
-rw-r--r--removed-patches-1-20-5/1027-Hide-unnecessary-itemmeta-from-clients.patch160
3 files changed, 299 insertions, 0 deletions
diff --git a/removed-patches-1-20-5/0675-Prevent-sending-oversized-item-data-in-equipment-and.patch b/removed-patches-1-20-5/0675-Prevent-sending-oversized-item-data-in-equipment-and.patch
new file mode 100644
index 0000000000..5e19c6e46b
--- /dev/null
+++ b/removed-patches-1-20-5/0675-Prevent-sending-oversized-item-data-in-equipment-and.patch
@@ -0,0 +1,88 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nassim Jahnke <[email protected]>
+Date: Wed, 1 Dec 2021 12:36:25 +0100
+Subject: [PATCH] Prevent sending oversized item data in equipment and metadata
+
+TODO: Check if still needed with compacted items over the network and limits
+
+
+diff --git a/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java b/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java
+index 3ee4c01e4505241e575b8b2e96338ba27b793a2b..d70f77e4d5ca59c9f802ecb354fa8d53d1e10134 100644
+--- a/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java
++++ b/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java
+@@ -44,7 +44,7 @@ public class EntityDataSerializers {
+ public static final EntityDataSerializer<ItemStack> ITEM_STACK = new EntityDataSerializer<ItemStack>() {
+ @Override
+ public void write(FriendlyByteBuf buf, ItemStack value) {
+- buf.writeItem(value);
++ buf.writeItem(net.minecraft.world.entity.LivingEntity.sanitizeItemStack(value, true)); // Paper - prevent oversized data
+ }
+
+ @Override
+diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
+index 91563f903834c1a0636dc087f8c6376815165b6c..a51564e8dce3c125ed5f05cc23548a05c1e79a95 100644
+--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
+@@ -335,7 +335,10 @@ public class ServerEntity {
+ ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot);
+
+ if (!itemstack.isEmpty()) {
+- list.add(Pair.of(enumitemslot, itemstack.copy()));
++ // Paper start - prevent oversized data
++ final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false);
++ list.add(Pair.of(enumitemslot, sanitized));
++ // Paper end - prevent oversized data
+ }
+ }
+
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index ed6fd20ff608e764d6b0f517f6c9c85c533f1646..8025e351fb3e24aa67b31eca74be1bc368592851 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -3208,7 +3208,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ equipmentChanges.forEach((enumitemslot, itemstack) -> {
+ ItemStack itemstack1 = itemstack.copy();
+
+- list.add(Pair.of(enumitemslot, itemstack1));
++ // Paper start - prevent oversized data
++ ItemStack toSend = sanitizeItemStack(itemstack1, true);
++ list.add(Pair.of(enumitemslot, toSend));
++ // Paper end - prevent oversized data
+ switch (enumitemslot.getType()) {
+ case HAND:
+ this.setLastHandItem(enumitemslot, itemstack1);
+@@ -3221,6 +3224,34 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ ((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
+ }
+
++ // Paper start - prevent oversized data
++ public static ItemStack sanitizeItemStack(final ItemStack itemStack, final boolean copyItemStack) {
++ if (itemStack.isEmpty() || !itemStack.hasTag()) {
++ return itemStack;
++ }
++
++ final ItemStack copy = copyItemStack ? itemStack.copy() : itemStack;
++ final CompoundTag tag = copy.getTag();
++ if (copy.is(Items.BUNDLE) && tag.get("Items") instanceof ListTag oldItems && !oldItems.isEmpty()) {
++ // Bundles change their texture based on their fullness.
++ org.bukkit.inventory.meta.BundleMeta bundleMeta = (org.bukkit.inventory.meta.BundleMeta) copy.asBukkitMirror().getItemMeta();
++ int sizeUsed = 0;
++ for (org.bukkit.inventory.ItemStack item : bundleMeta.getItems()) {
++ int scale = 64 / item.getMaxStackSize();
++ sizeUsed += scale * item.getAmount();
++ }
++ // Now we add a single fake item that uses the same amount of slots as all other items.
++ ListTag items = new ListTag();
++ items.add(new ItemStack(Items.PAPER, sizeUsed).save(new CompoundTag()));
++ tag.put("Items", items);
++ }
++ if (tag.get("BlockEntityTag") instanceof CompoundTag blockEntityTag) {
++ blockEntityTag.remove("Items");
++ }
++ return copy;
++ }
++ // Paper end - prevent oversized data
++
+ private ItemStack getLastArmorItem(EquipmentSlot slot) {
+ return (ItemStack) this.lastArmorItemStacks.get(slot.getIndex());
+ }
diff --git a/removed-patches-1-20-5/0693-Fix-bees-aging-inside-hives.patch b/removed-patches-1-20-5/0693-Fix-bees-aging-inside-hives.patch
new file mode 100644
index 0000000000..4e25bcc978
--- /dev/null
+++ b/removed-patches-1-20-5/0693-Fix-bees-aging-inside-hives.patch
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Sat, 21 Aug 2021 21:54:16 -0700
+Subject: [PATCH] Fix bees aging inside hives
+
+Fixes bees incorrectly being aged up due to upstream's
+resetting the ticks inside hive on a failed release
+
+TODO: Test if still needed
+
+diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+index a69a81ba6a2b65978b5cf00810ed12156a5f89e6..55b0e2bf98a285cdcd30e40d94192b7a1802efd8 100644
+--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
++++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+@@ -332,7 +332,7 @@ public class BeehiveBlockEntity extends BlockEntity {
+
+ for (Iterator iterator = bees.iterator(); iterator.hasNext(); ++tileentitybeehive_hivebee.ticksInHive) {
+ tileentitybeehive_hivebee = (BeehiveBlockEntity.BeeData) iterator.next();
+- if (tileentitybeehive_hivebee.ticksInHive > tileentitybeehive_hivebee.minOccupationTicks) {
++ if (tileentitybeehive_hivebee.exitTickCounter > tileentitybeehive_hivebee.minOccupationTicks) { // Paper - Fix bees aging inside hives; use exitTickCounter
+ BeehiveBlockEntity.BeeReleaseStatus tileentitybeehive_releasestatus = tileentitybeehive_hivebee.entityData.getBoolean("HasNectar") ? BeehiveBlockEntity.BeeReleaseStatus.HONEY_DELIVERED : BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED;
+
+ if (BeehiveBlockEntity.releaseOccupant(world, pos, state, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, flowerPos)) {
+@@ -340,10 +340,11 @@ public class BeehiveBlockEntity extends BlockEntity {
+ iterator.remove();
+ // CraftBukkit start
+ } else {
+- tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
++ tileentitybeehive_hivebee.exitTickCounter = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable // Paper - Fix bees aging inside hives; use exitTickCounter to keep actual bee life
+ // CraftBukkit end
+ }
+ }
++ tileentitybeehive_hivebee.exitTickCounter++; // Paper - Fix bees aging inside hives
+ }
+
+ if (flag) {
+@@ -432,12 +433,14 @@ public class BeehiveBlockEntity extends BlockEntity {
+
+ final CompoundTag entityData;
+ int ticksInHive;
++ int exitTickCounter; // Paper - Fix bees aging inside hives; separate counter for checking if bee should exit to reduce exit attempts
+ final int minOccupationTicks;
+
+ BeeData(CompoundTag entityData, int ticksInHive, int minOccupationTicks) {
+ BeehiveBlockEntity.removeIgnoredBeeTags(entityData);
+ this.entityData = entityData;
+ this.ticksInHive = ticksInHive;
++ this.exitTickCounter = ticksInHive; // Paper - Fix bees aging inside hives
+ this.minOccupationTicks = minOccupationTicks;
+ }
+ }
diff --git a/removed-patches-1-20-5/1027-Hide-unnecessary-itemmeta-from-clients.patch b/removed-patches-1-20-5/1027-Hide-unnecessary-itemmeta-from-clients.patch
new file mode 100644
index 0000000000..c3fea6f0cd
--- /dev/null
+++ b/removed-patches-1-20-5/1027-Hide-unnecessary-itemmeta-from-clients.patch
@@ -0,0 +1,160 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Noah van der Aa <[email protected]>
+Date: Tue, 3 Aug 2021 17:28:27 +0200
+Subject: [PATCH] Hide unnecessary itemmeta from clients
+
+TODO: Needs updating for data components
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
+index 22eec853588ded2d255ab69d408f8e987832abe2..dda4fbd63681ab9614ebbb55632355f30d7b19ac 100644
+--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
+@@ -348,7 +348,10 @@ public class ServerEntity {
+ ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot);
+
+ if (!itemstack.isEmpty()) {
+- list.add(Pair.of(enumitemslot, itemstack.copy()));
++ // Paper start - prevent oversized data
++ final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false);
++ list.add(Pair.of(enumitemslot, ((LivingEntity) this.entity).stripMeta(sanitized, false))); // Paper - Hide unnecessary item meta
++ // Paper end - prevent oversized data
+ }
+ }
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index 32076a765d48d59b339d600f69afa85edbcf833c..6b905d0245f16794078de34fb8509a0cd0869382 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -2802,8 +2802,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ // Refresh the current entity metadata
+ entity.refreshEntityData(ServerGamePacketListenerImpl.this.player);
+ // SPIGOT-7136 - Allays
+- if (entity instanceof Allay) {
+- ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList())));
++ if (entity instanceof Allay allay) { // Paper - Hide unnecessary item meta
++ ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, allay.stripMeta(allay.getItemBySlot(slot), true))).collect(Collectors.toList()))); // Paper - Hide unnecessary item meta
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote();
+ }
+ }
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index 9ff43ff4076c658b8561c5a7abd067423830f964..bbc67e97de3ab1cd20c595e794aea27cf00a7cb0 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -3299,7 +3299,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ equipmentChanges.forEach((enumitemslot, itemstack) -> {
+ ItemStack itemstack1 = itemstack.copy();
+
+- list.add(Pair.of(enumitemslot, itemstack1));
++ // Paper start - prevent oversized data
++ ItemStack toSend = sanitizeItemStack(itemstack1, true);
++ list.add(Pair.of(enumitemslot, stripMeta(toSend, toSend == itemstack1))); // Paper - Hide unnecessary item meta
++ // Paper end - prevent oversized data
+ switch (enumitemslot.getType()) {
+ case HAND:
+ this.setLastHandItem(enumitemslot, itemstack1);
+@@ -3315,6 +3318,105 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ ((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
+ }
+
++ // Paper start - Hide unnecessary item meta
++ public ItemStack stripMeta(final ItemStack itemStack, final boolean copyItemStack) {
++ if (itemStack.isEmpty() || (!itemStack.hasTag() && itemStack.getCount() < 2)) {
++ return itemStack;
++ }
++
++ final ItemStack copy = copyItemStack ? itemStack.copy() : itemStack;
++ if (this.level().paperConfig().anticheat.obfuscation.items.hideDurability) {
++ // Only show damage values for elytra's, since they show a different texture when broken.
++ if (!copy.is(Items.ELYTRA) || copy.getDamageValue() < copy.getMaxDamage() - 1) {
++ copy.setDamageValue(0);
++ }
++ }
++
++ final CompoundTag tag = copy.getTag();
++ if (this.level().paperConfig().anticheat.obfuscation.items.hideItemmeta) {
++ // Some resource packs show different textures when there is more than one item. Since this shouldn't provide a big advantage,
++ // we'll tell the client if there's one or (more than) two items.
++ copy.setCount(copy.getCount() > 1 ? 2 : 1);
++ // We can't just strip out display, leather helmets still use the display.color tag.
++ if (tag != null) {
++ if (tag.get("display") instanceof CompoundTag displayTag) {
++ displayTag.remove("Lore");
++ displayTag.remove("Name");
++ }
++
++ if (tag.get("Enchantments") instanceof ListTag enchantmentsTag && !enchantmentsTag.isEmpty()) {
++ // The client still renders items with the enchantment glow if the enchantments tag contains at least one (empty) child.
++ ListTag enchantments = new ListTag();
++ CompoundTag fakeEnchantment = new CompoundTag();
++ // Soul speed boots generate client side particles.
++ if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SOUL_SPEED, itemStack) > 0) {
++ fakeEnchantment.putString("id", org.bukkit.enchantments.Enchantment.SOUL_SPEED.getKey().asString());
++ fakeEnchantment.putInt("lvl", 1);
++ }
++ enchantments.add(fakeEnchantment);
++ tag.put("Enchantments", enchantments);
++ }
++ tag.remove("AttributeModifiers");
++ tag.remove("Unbreakable");
++ tag.remove("PublicBukkitValues"); // Persistent data container1
++
++ // Books
++ tag.remove("author");
++ tag.remove("filtered_title");
++ tag.remove("pages");
++ tag.remove("filtered_pages");
++ tag.remove("title");
++ tag.remove("generation");
++
++ // Filled maps
++ tag.remove("map");
++ tag.remove("map_scale_direction");
++ tag.remove("map_to_lock");
++ }
++ }
++
++ if (this.level().paperConfig().anticheat.obfuscation.items.hideItemmetaWithVisualEffects && tag != null) {
++ // Lodestone compasses
++ tag.remove("LodestonePos");
++ if (tag.contains("LodestoneDimension")) {
++ // The client shows the glint if either the position or the dimension is present, so we just wipe
++ // the position and fake the dimension
++ tag.putString("LodestoneDimension", "paper:paper");
++ }
++ }
++
++ return copy;
++ }
++ // Paper end - Hide unnecessary item meta
++
++ // Paper start - prevent oversized data
++ public static ItemStack sanitizeItemStack(final ItemStack itemStack, final boolean copyItemStack) {
++ if (itemStack.isEmpty() || !itemStack.hasTag()) {
++ return itemStack;
++ }
++
++ final ItemStack copy = copyItemStack ? itemStack.copy() : itemStack;
++ final CompoundTag tag = copy.getTag();
++ if (copy.is(Items.BUNDLE) && tag.get("Items") instanceof ListTag oldItems && !oldItems.isEmpty()) {
++ // Bundles change their texture based on their fullness.
++ org.bukkit.inventory.meta.BundleMeta bundleMeta = (org.bukkit.inventory.meta.BundleMeta) copy.asBukkitMirror().getItemMeta();
++ int sizeUsed = 0;
++ for (org.bukkit.inventory.ItemStack item : bundleMeta.getItems()) {
++ int scale = 64 / item.getMaxStackSize();
++ sizeUsed += scale * item.getAmount();
++ }
++ // Now we add a single fake item that uses the same amount of slots as all other items.
++ ListTag items = new ListTag();
++ items.add(new ItemStack(Items.PAPER, sizeUsed).save(new CompoundTag()));
++ tag.put("Items", items);
++ }
++ if (tag.get("BlockEntityTag") instanceof CompoundTag blockEntityTag) {
++ blockEntityTag.remove("Items");
++ }
++ return copy;
++ }
++ // Paper end - prevent oversized data
++
+ private ItemStack getLastArmorItem(EquipmentSlot slot) {
+ return (ItemStack) this.lastArmorItemStacks.get(slot.getIndex());
+ }