mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
31 lines
1.8 KiB
Diff
31 lines
1.8 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||
|
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 43cd04e8d7299d961108e9a51a012a2021b20ee7..e714b42cf97b1a9ec5a8e68678541ea734bc78fe 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||
|
@@ -526,6 +526,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.Registry.ATTRIBUTE.getKey(attributeBase).toString()), CraftAttributeInstance.convert(attributeModifier, equipmentSlot));
|
||
|
+ });
|
||
|
+ return attributeMapBuilder.build();
|
||
|
+ }
|
||
|
+
|
||
|
@Override
|
||
|
public int getProtocolVersion() {
|
||
|
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|