summaryrefslogtreecommitdiffhomepage
path: root/patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch')
-rw-r--r--patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch b/patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch
new file mode 100644
index 0000000000..20960278b3
--- /dev/null
+++ b/patches/unapplied/server/0625-Attributes-API-for-item-defaults.patch
@@ -0,0 +1,30 @@
+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] Attributes API for item defaults
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+index a08b404dbf2b6f53b29c7a6e86cac1871976ae4c..ec47babe5f34198ae213679d4a4b2bc27bdc1eab 100644
+--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+@@ -553,6 +553,19 @@ public final class CraftMagicNumbers implements UnsafeValues {
+ return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial));
+ }
+
++ @Override
++ public Multimap<Attribute, AttributeModifier> getItemAttributes(Material material, EquipmentSlot equipmentSlot) {
++ Item item = CraftMagicNumbers.getItem(material);
++ if (item == null) {
++ throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes");
++ }
++ ImmutableMultimap.Builder<Attribute, AttributeModifier> attributeMapBuilder = ImmutableMultimap.builder();
++ item.getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> {
++ attributeMapBuilder.put(CraftAttributeMap.fromMinecraft(net.minecraft.core.registries.BuiltInRegistries.ATTRIBUTE.getKey(attributeBase).toString()), CraftAttributeInstance.convert(attributeModifier, equipmentSlot));
++ });
++ return attributeMapBuilder.build();
++ }
++
+ @Override
+ public int getProtocolVersion() {
+ return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();