diff --git a/patches/server/1004-Write-SavedData-IO-async.patch b/patches/server/1004-Write-SavedData-IO-async.patch index 57d9858adf..a1052c55c9 100644 --- a/patches/server/1004-Write-SavedData-IO-async.patch +++ b/patches/server/1004-Write-SavedData-IO-async.patch @@ -61,7 +61,7 @@ index ed8e875fff01c6b464fbaefbb0a3f417f9d67a72..aba5f694b25507c9ab2e214bc1f25e0a public List getEntities(EntityTypeTest filter, Predicate predicate) { diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -index 0382b6597a130d746f8954a93a756a9d1ac81d50..cb39c629af1827078f35904a373d35a63fea17ff 100644 +index 7984f17cd9c4cef8100909b6c33b3144c8096fcf..868c9bbb12c8cfe76abb62774cf08102b727063b 100644 --- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java @@ -116,7 +116,13 @@ public class WorldUpgrader { diff --git a/patches/unapplied/server/1042-Fix-and-optimise-world-force-upgrading.patch b/patches/server/1035-Fix-and-optimise-world-force-upgrading.patch similarity index 97% rename from patches/unapplied/server/1042-Fix-and-optimise-world-force-upgrading.patch rename to patches/server/1035-Fix-and-optimise-world-force-upgrading.patch index de599d49f8..507303569f 100644 --- a/patches/unapplied/server/1042-Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/1035-Fix-and-optimise-world-force-upgrading.patch @@ -270,10 +270,10 @@ index 244a19ecd0234fa1d7a6ecfea20751595688605d..8893aa1fe4b033fdc25ebe6f3a3606af Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, dynamicRegistryManager, eraseCache, recreateRegionFiles); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0f3601f2f1a7ac53425129df6498ed0df302dec8..3cb64c6c870454ee3090d6c88bede8b58d9d3361 100644 +index 5f3b35f0dbd9e78ad18ef5cf7be1a807beffeaf1..a43f597d1148e00a6533f74c25ce272cd4e26dc4 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -595,11 +595,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); @@ -35,19 +37,22 @@ index 8fcb241e8d161c9fb024a2a0488f8c29784a74f1..7127c6f163cc00eb439eb37665df3e1a } } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 8025e351fb3e24aa67b31eca74be1bc368592851..e44a45ced6f7cd7db44388bb2e85c722b6b5ca8a 100644 +index 9ff43ff4076c658b8561c5a7abd067423830f964..bbc67e97de3ab1cd20c595e794aea27cf00a7cb0 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3210,7 +3210,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3299,7 +3299,10 @@ public abstract class LivingEntity extends Entity implements Attackable { + equipmentChanges.forEach((enumitemslot, itemstack) -> { + ItemStack itemstack1 = itemstack.copy(); - // Paper start - prevent oversized data - ItemStack toSend = sanitizeItemStack(itemstack1, true); -- list.add(Pair.of(enumitemslot, toSend)); +- 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 ++ // Paper end - prevent oversized data switch (enumitemslot.getType()) { case HAND: -@@ -3224,6 +3224,77 @@ public abstract class LivingEntity extends Entity implements Attackable { + 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)); } @@ -122,6 +127,34 @@ index 8025e351fb3e24aa67b31eca74be1bc368592851..e44a45ced6f7cd7db44388bb2e85c722 + } + // 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()) { ++ // 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()); + }