diff options
author | Jake Potrebic <[email protected]> | 2024-04-28 08:22:16 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-04-28 08:22:16 -0700 |
commit | c4a1cd137a9208aaf53a66235a00e38457687d42 (patch) | |
tree | 83d693d8c69f48f22f49644402546f079641b531 | |
parent | 37b389103208c9a1777090bde42ee661e94ed512 (diff) | |
download | Paper-c4a1cd137a9208aaf53a66235a00e38457687d42.tar.gz Paper-c4a1cd137a9208aaf53a66235a00e38457687d42.zip |
Fix issue with empty lists in adventure predicates
Fixes #10473
-rw-r--r-- | patches/server/1041-Fix-ItemFlags.patch | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/patches/server/1041-Fix-ItemFlags.patch b/patches/server/1041-Fix-ItemFlags.patch index 94985c5f11..d304c0b9cc 100644 --- a/patches/server/1041-Fix-ItemFlags.patch +++ b/patches/server/1041-Fix-ItemFlags.patch @@ -33,7 +33,7 @@ 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 ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..9cd528a70ef3e6053a7103a6f9df5e93bb8550a4 100644 +index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe52f345bac 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -224,6 +224,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -108,11 +108,11 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..9cd528a70ef3e6053a7103a6f9df5e93 } + // Paper start -+ if (this.canPlaceOnPredicates != null || this.hasItemFlag(ItemFlag.HIDE_PLACED_ON)) { -+ itemTag.put(CraftMetaItem.CAN_PLACE_ON, new net.minecraft.world.item.AdventureModePredicate(this.canPlaceOnPredicates != null ? this.canPlaceOnPredicates : Collections.emptyList(), !this.hasItemFlag(ItemFlag.HIDE_PLACED_ON))); ++ if (this.canPlaceOnPredicates != null && !this.canPlaceOnPredicates.isEmpty()) { ++ itemTag.put(CraftMetaItem.CAN_PLACE_ON, new net.minecraft.world.item.AdventureModePredicate(this.canPlaceOnPredicates, !this.hasItemFlag(ItemFlag.HIDE_PLACED_ON))); + } -+ if (this.canBreakPredicates != null || this.hasItemFlag(ItemFlag.HIDE_DESTROYS)) { -+ itemTag.put(CraftMetaItem.CAN_BREAK, new net.minecraft.world.item.AdventureModePredicate(this.canBreakPredicates != null ? this.canBreakPredicates : Collections.emptyList(), !this.hasItemFlag(ItemFlag.HIDE_DESTROYS))); ++ if (this.canBreakPredicates != null && !this.canBreakPredicates.isEmpty()) { ++ itemTag.put(CraftMetaItem.CAN_BREAK, new net.minecraft.world.item.AdventureModePredicate(this.canBreakPredicates, !this.hasItemFlag(ItemFlag.HIDE_DESTROYS))); + } + // Paper end + @@ -166,13 +166,13 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..9cd528a70ef3e6053a7103a6f9df5e93 } + // Paper start -+ final boolean canBreakAddToUnhandled = this.canBreakPredicates != null || this.hasItemFlag(ItemFlag.HIDE_DESTROYS); ++ final boolean canBreakAddToUnhandled = this.canBreakPredicates != null && !this.canBreakPredicates.isEmpty(); + if (canBreakAddToUnhandled) { -+ this.unhandledTags.set(DataComponents.CAN_BREAK, new net.minecraft.world.item.AdventureModePredicate(this.canBreakPredicates != null ? this.canBreakPredicates : Collections.emptyList(), !this.hasItemFlag(ItemFlag.HIDE_DESTROYS))); ++ this.unhandledTags.set(DataComponents.CAN_BREAK, new net.minecraft.world.item.AdventureModePredicate(this.canBreakPredicates, !this.hasItemFlag(ItemFlag.HIDE_DESTROYS))); + } -+ final boolean canPlaceOnAddToUnhandled = this.canPlaceOnPredicates != null || this.hasItemFlag(ItemFlag.HIDE_PLACED_ON); ++ final boolean canPlaceOnAddToUnhandled = this.canPlaceOnPredicates != null && !this.canPlaceOnPredicates.isEmpty(); + if (canPlaceOnAddToUnhandled) { -+ this.unhandledTags.set(DataComponents.CAN_PLACE_ON, new net.minecraft.world.item.AdventureModePredicate(this.canPlaceOnPredicates != null ? this.canPlaceOnPredicates : Collections.emptyList(), !this.hasItemFlag(ItemFlag.HIDE_PLACED_ON))); ++ this.unhandledTags.set(DataComponents.CAN_PLACE_ON, new net.minecraft.world.item.AdventureModePredicate(this.canPlaceOnPredicates, !this.hasItemFlag(ItemFlag.HIDE_PLACED_ON))); + } + // Paper end if (!this.unhandledTags.isEmpty()) { |