aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0966-Fix-ItemFlags.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0966-Fix-ItemFlags.patch')
-rw-r--r--patches/server/0966-Fix-ItemFlags.patch57
1 files changed, 28 insertions, 29 deletions
diff --git a/patches/server/0966-Fix-ItemFlags.patch b/patches/server/0966-Fix-ItemFlags.patch
index 249bd1854a..7be17295bf 100644
--- a/patches/server/0966-Fix-ItemFlags.patch
+++ b/patches/server/0966-Fix-ItemFlags.patch
@@ -11,10 +11,10 @@ which was split from HIDE_ADDITIONAL_TOOLTIP.
public net.minecraft.world.item.AdventureModePredicate predicates
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java
-index fca0cfba14dd2cc6f24b56eaf269594b2d87fd04..8734f0b777432cd8639094b75a3da1b9595823ed 100644
+index 73fe41322e0349ad1d46a760f621b6c91112e90e..19af55ec2bf62b70bd3be44f499b32f5efe71ab1 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java
-@@ -39,7 +39,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
+@@ -38,7 +38,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
getOrEmpty(tag, CraftMetaEnchantedBook.STORED_ENCHANTMENTS).ifPresent((itemEnchantments) -> {
this.enchantments = buildEnchantments(itemEnchantments);
if (!itemEnchantments.showInTooltip) {
@@ -23,7 +23,7 @@ index fca0cfba14dd2cc6f24b56eaf269594b2d87fd04..8734f0b777432cd8639094b75a3da1b9
}
});
}
-@@ -54,7 +54,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
+@@ -53,7 +53,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
void applyToItem(CraftMetaItem.Applicator itemTag) {
super.applyToItem(itemTag);
@@ -33,10 +33,10 @@ index fca0cfba14dd2cc6f24b56eaf269594b2d87fd04..8734f0b777432cd8639094b75a3da1b9
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec736797864bfdf 100644
+index b5103f318b685145d10337c833f0026d4785f05f..1b7d4bea50730f97804f1b9a4ac8896a365bae26 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-@@ -250,6 +250,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -252,6 +252,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
static final ItemMetaKeyType<Unit> HIDE_ADDITIONAL_TOOLTIP = new ItemMetaKeyType(DataComponents.HIDE_ADDITIONAL_TOOLTIP);
@Specific(Specific.To.NBT)
static final ItemMetaKeyType<CustomData> CUSTOM_DATA = new ItemMetaKeyType<>(DataComponents.CUSTOM_DATA);
@@ -49,7 +49,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
// We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304
private Component displayName;
-@@ -330,6 +336,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -334,6 +340,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.customTag = meta.customTag;
this.version = meta.version;
@@ -60,7 +60,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
}
CraftMetaItem(DataComponentPatch tag) {
-@@ -428,6 +438,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -432,6 +442,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.customTag = null;
}
});
@@ -81,25 +81,24 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
-@@ -622,7 +646,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
- ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(unhandled));
+@@ -631,7 +655,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
try {
CompoundTag unhandledTag = NbtIo.readCompressed(buf, NbtAccounter.unlimitedHeap());
-- this.unhandledTags.copy(DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), unhandledTag).result().get());
+ DataComponentPatch unhandledPatch = DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), unhandledTag).result().get();
+- this.unhandledTags.copy(unhandledPatch);
+ // Paper start
-+ final net.minecraft.core.component.DataComponentPatch patch = net.minecraft.core.component.DataComponentPatch.CODEC.parse(net.minecraft.server.MinecraftServer.getDefaultRegistryAccess().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE), unhandledTag).result().get();
-+ CraftMetaItem.getOrEmpty(patch, CraftMetaItem.CAN_PLACE_ON).ifPresent(data -> {
++ CraftMetaItem.getOrEmpty(unhandledPatch, CraftMetaItem.CAN_PLACE_ON).ifPresent(data -> {
+ this.canPlaceOnPredicates = List.copyOf(data.predicates);
+ });
-+ CraftMetaItem.getOrEmpty(patch, CraftMetaItem.CAN_BREAK).ifPresent(data -> {
++ CraftMetaItem.getOrEmpty(unhandledPatch, CraftMetaItem.CAN_BREAK).ifPresent(data -> {
+ this.canBreakPredicates = List.copyOf(data.predicates);
+ });
-+ this.unhandledTags.copy(patch.forget(type -> type == CraftMetaItem.CAN_PLACE_ON.TYPE || type == CraftMetaItem.CAN_BREAK.TYPE));
++ this.unhandledTags.copy(unhandledPatch.forget(type -> type == CraftMetaItem.CAN_PLACE_ON.TYPE || type == CraftMetaItem.CAN_BREAK.TYPE));
+ // Paper end
- } catch (IOException ex) {
- Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
- }
-@@ -840,6 +873,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+
+ for (Entry<DataComponentType<?>, Optional<?>> entry : unhandledPatch.entrySet()) {
+ // Move removed unhandled tags to dedicated removedTags
+@@ -874,6 +906,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
itemTag.put(CraftMetaItem.MAX_DAMAGE, this.maxDamage);
}
@@ -115,16 +114,16 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
for (Map.Entry<DataComponentType<?>, Optional<?>> e : this.unhandledTags.build().entrySet()) {
e.getValue().ifPresentOrElse((value) -> {
itemTag.builder.set((DataComponentType) e.getKey(), value);
-@@ -914,7 +956,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -962,7 +1003,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Overridden
boolean isEmpty() {
-- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
-+ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
+- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
++ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
}
// Paper start
-@@ -1583,6 +1625,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -1632,6 +1673,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasJukeboxPlayable() ? that.hasJukeboxPlayable() && this.jukebox.equals(that.jukebox) : !that.hasJukeboxPlayable())
&& (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage())
&& (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage())
@@ -133,7 +132,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
&& (this.version == that.version);
}
-@@ -1627,6 +1671,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -1677,6 +1720,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (this.hasDamage() ? this.damage : 0);
hash = 61 * hash + (this.hasMaxDamage() ? 1231 : 1237);
hash = 61 * hash + (this.hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0);
@@ -142,7 +141,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
hash = 61 * hash + this.version;
return hash;
}
-@@ -1670,6 +1716,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -1721,6 +1766,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
clone.damage = this.damage;
clone.maxDamage = this.maxDamage;
clone.version = this.version;
@@ -157,7 +156,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
return clone;
} catch (CloneNotSupportedException e) {
throw new Error(e);
-@@ -1787,6 +1841,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -1838,6 +1891,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
}
@@ -174,7 +173,7 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
if (!this.unhandledTags.isEmpty()) {
Tag unhandled = DataComponentPatch.CODEC.encodeStart(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), this.unhandledTags.build()).getOrThrow(IllegalStateException::new);
try {
-@@ -1797,6 +1861,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+@@ -1848,6 +1911,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
@@ -187,9 +186,9 @@ index 8a5785565d71f3f74a9ce0179a26dbff5530023d..dbcf9a27112ac525722fd9b80ec73679
+ }
+ // Paper end
- if (!this.persistentDataContainer.isEmpty()) { // Store custom tags, wrapped in their compound
- builder.put(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT, this.persistentDataContainer.serialize());
-@@ -1936,6 +2008,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
+ if (!this.removedTags.isEmpty()) {
+ RegistryAccess registryAccess = CraftRegistry.getMinecraftRegistry();
+@@ -2001,6 +2072,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
CraftMetaItem.MAX_DAMAGE.TYPE,
CraftMetaItem.CUSTOM_DATA.TYPE,
CraftMetaItem.ATTRIBUTES.TYPE,