From 7ac51f9c15afc541cdba4c109845692686dfcc67 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Wed, 22 Sep 2021 10:48:03 -0700 Subject: [PATCH] Include slot when constructing the bukkit Attribute Modifiers (#6537) --- ...687-Attributes-API-for-item-defaults.patch | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/patches/server/0687-Attributes-API-for-item-defaults.patch b/patches/server/0687-Attributes-API-for-item-defaults.patch index e29615da4..a0f9c4d77 100644 --- a/patches/server/0687-Attributes-API-for-item-defaults.patch +++ b/patches/server/0687-Attributes-API-for-item-defaults.patch @@ -4,8 +4,23 @@ 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 7e3826b271b2db3b48e6e21ac2e66911bf8993aa..393a19335c52b6e63d37aacdfbeff93e1795c421 100644 +--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java ++++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java +@@ -72,4 +72,10 @@ 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 85a0639e8e65f4d085f605f09ca04a706a631d56..72cfffd80ad76abe7cb16bc9133730338c07b6f6 100644 +index 85a0639e8e65f4d085f605f09ca04a706a631d56..408863b137b7bda3f3e654ac3665ddeefb6d9e7b 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -492,6 +492,19 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -20,7 +35,7 @@ index 85a0639e8e65f4d085f605f09ca04a706a631d56..72cfffd80ad76abe7cb16bc913373033 + } + com.google.common.collect.ImmutableMultimap.Builder 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(); + }