mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-07-08 01:40:00 +00:00
55 lines
2.3 KiB
Diff
55 lines
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
Date: Sat, 10 Dec 2022 23:38:53 -0600
|
|
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 a6253272205337b3b855679b3057c2519a807a4c..86c809041ce31d5d2bc789be848ec0f1ef12b564 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;
|
|
@@ -256,6 +257,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) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
|
this.count = nbttagcompound.getByte("Count");
|
|
if (nbttagcompound.contains("tag", 10)) {
|
|
@@ -530,7 +537,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;
|
|
@@ -866,6 +877,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()) {
|