diff options
Diffstat (limited to 'patches/server/0558-Fix-item-default-attributes-API.patch')
-rw-r--r-- | patches/server/0558-Fix-item-default-attributes-API.patch | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/patches/server/0558-Fix-item-default-attributes-API.patch b/patches/server/0558-Fix-item-default-attributes-API.patch new file mode 100644 index 0000000000..a3726019c7 --- /dev/null +++ b/patches/server/0558-Fix-item-default-attributes-API.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <[email protected]> +Date: Sat, 8 May 2021 15:01:54 -0700 +Subject: [PATCH] Fix item default attributes API + +(previously added this API but upstream also added it) + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index 6b3fbdf0a53f95c43eee7b745d85e8fcf84413b0..bbe66459f29edf0c3de289a8b8a93e926323f82a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -396,9 +396,14 @@ public final class CraftMagicNumbers implements UnsafeValues { + + @Override + public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Material material, EquipmentSlot slot) { +- ImmutableMultimap.Builder<Attribute, AttributeModifier> defaultAttributes = ImmutableMultimap.builder(); +- +- ItemAttributeModifiers nmsDefaultAttributes = CraftMagicNumbers.getItem(material).getDefaultAttributeModifiers(); ++ // Paper start - fix item default attribute API ++ final Item item = CraftMagicNumbers.getItem(material); ++ if (item == null) { ++ throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes"); ++ } ++ final ImmutableMultimap.Builder<Attribute, AttributeModifier> defaultAttributes = ImmutableMultimap.builder(); ++ ItemAttributeModifiers nmsDefaultAttributes = item.components().getOrDefault(net.minecraft.core.component.DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); ++ // Paper end - fix item default attribute API + nmsDefaultAttributes.forEach(CraftEquipmentSlot.getNMS(slot), (key, value) -> { + Attribute attribute = CraftAttribute.minecraftToBukkit(key.value()); + defaultAttributes.put(attribute, CraftAttributeInstance.convert(value, slot)); |