From 3e736b852563b52885a9bd376ca895cc3acf3e9c Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 22 Sep 2021 10:48:03 -0700
Subject: [PATCH] Include slot when constructing the bukkit Attribute Modifiers
 (#6537)

---
 .../Attributes-API-for-item-defaults.patch      | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/patches/server/Attributes-API-for-item-defaults.patch b/patches/server/Attributes-API-for-item-defaults.patch
index cdb47e52a3..7f7c7f4107 100644
--- a/patches/server/Attributes-API-for-item-defaults.patch
+++ b/patches/server/Attributes-API-for-item-defaults.patch
@@ -4,6 +4,21 @@ 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/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
++++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
+@@ -0,0 +0,0 @@ public class CraftAttributeInstance implements AttributeInstance {
+     public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms) {
+         return new AttributeModifier(nms.getId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]);
+     }
++
++    // Paper start - construct using slot
++    public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms, org.bukkit.inventory.EquipmentSlot slot) {
++        return new AttributeModifier(nms.getId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()], slot);
++    }
++    // Paper end
+ }
 diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -20,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        }
 +        com.google.common.collect.ImmutableMultimap.Builder<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> attributeMapBuilder = com.google.common.collect.ImmutableMultimap.builder();
 +        item.getDefaultAttributeModifiers(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> {
-+            attributeMapBuilder.put(org.bukkit.Registry.ATTRIBUTE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase))), org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier));
++            attributeMapBuilder.put(org.bukkit.Registry.ATTRIBUTE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase))), org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier, equipmentSlot));
 +        });
 +        return attributeMapBuilder.build();
 +    }