From 625be3510227392839a552791f70e5f43a3b2ed3 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sat, 11 Jun 2022 23:20:41 -0500 Subject: [PATCH] Create 0023-Reset-large-tags.patch --- patches/server/0023-Reset-large-tags.patch | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 patches/server/0023-Reset-large-tags.patch diff --git a/patches/server/0023-Reset-large-tags.patch b/patches/server/0023-Reset-large-tags.patch new file mode 100644 index 0000000..72e306a --- /dev/null +++ b/patches/server/0023-Reset-large-tags.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Telesphoreo +Date: Sat, 11 Jun 2022 23:16:06 -0500 +Subject: [PATCH] Reset large tags + + +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 6b3cfc19c4fd1382ddf534265a1114995a4f6b55..6c0ea385df617793aafe995bcf1264ce9b764297 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -20,6 +20,7 @@ import java.util.function.Predicate; + import java.util.stream.Collectors; + import java.util.stream.Stream; + import javax.annotation.Nullable; ++import me.totalfreedom.scissors.NbtUtility; + import net.minecraft.ChatFormatting; + import net.minecraft.Util; + import net.minecraft.advancements.CriteriaTriggers; +@@ -251,6 +252,12 @@ public final class ItemStack { + + // CraftBukkit - break into own method + private void load(CompoundTag nbttagcompound) { ++ // Scissors start - Reset large tags ++ if (NbtUtility.isTooLarge(nbttagcompound)) { ++ // Reset tag without destroying item ++ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound); ++ } ++ // Scissors end + this.item = (Item) Registry.ITEM.get(new ResourceLocation(nbttagcompound.getString("id"))); + this.count = nbttagcompound.getByte("Count"); + if (nbttagcompound.contains("tag", 10)) { +@@ -507,7 +514,11 @@ public final class ItemStack { + nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); + nbt.putByte("Count", (byte) this.count); + if (this.tag != null) { +- nbt.put("tag", this.tag.copy()); ++ // Scissors start - Don't save large tags ++ if (!NbtUtility.isTooLarge(this.tag)) { ++ nbt.put("tag", this.tag.copy()); ++ } ++ // Scissors end + } + + return nbt; +@@ -839,6 +850,9 @@ public final class ItemStack { + // Paper end + + public void setTag(@Nullable CompoundTag nbt) { ++ // Scissors start - Ignore large tags ++ if (NbtUtility.isTooLarge(nbt)) return; ++ // Scissors end + this.tag = nbt; + this.processEnchantOrder(this.tag); // Paper + if (this.getItem().canBeDepleted()) {