Paper/patches/api/0289-Attributes-API-for-item-defaults.patch
Nassim Jahnke 9df2066642
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
dfe1fb48 PR-906: Add missing MinecraftExperimental annotation to Bundles
825ab30d PR-905: Add missing MapCursor.Type and update documentation
e03d10e6 PR-903: Make BARRIER Waterlogged
1961ead6 PR-898: Use Java Consumer instead of Bukkit Consumer

CraftBukkit Changes:
f71a799f0 Make BARRIER Waterlogged
172f76a45 Upgrade specialsource-maven-plugin
f0702775c SPIGOT-7486: Alternate approach to null profile names
069495671 SPIGOT-7485: Allow air entity items since required for Vanilla logic
5dfd33dc2 SPIGOT-7484: Cancelling PlayerEditBookEvent does not update client's book contents
02d490788 PR-1250: Standardize and centralize Bukkit / Minecraft registry conversion
9024a09b9 PR-1251: Use Java Consumer instead of Bukkit Consumer
6d4b25bf1 Increase diff stability
2023-09-23 12:21:59 +10:00

56 lines
2.6 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:02:00 -0700
Subject: [PATCH] Attributes API for item defaults
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index de709541754ce47aed82025e45311b6162b8c629..8fea0f3f6dfa0634405ed2e4c2941beb616a0efc 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4474,6 +4474,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public io.papermc.paper.inventory.ItemRarity getItemRarity() {
return Bukkit.getUnsafe().getItemRarity(this);
}
+
+ /**
+ * Returns an immutable multimap of attributes for the slot.
+ * {@link #isItem()} must be true for this material.
+ *
+ * @param equipmentSlot the slot to get the attributes for
+ * @throws IllegalArgumentException if {@link #isItem()} is false
+ * @return an immutable multimap of attributes
+ * @deprecated use {@link #getDefaultAttributeModifiers(EquipmentSlot)}
+ */
+ @NotNull
+ @Deprecated
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
+ return Bukkit.getUnsafe().getItemAttributes(this, equipmentSlot);
+ }
// Paper end
/**
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 00e61ab3103c86c9aabcdfa2fd4c565adcc091da..a9e7c64e1f98ff73c1804466d7c79eaf343dde7c 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -170,6 +170,18 @@ public interface UnsafeValues {
*/
public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial);
+ /**
+ * Returns an immutable multimap of attributes for the material and slot.
+ * {@link Material#isItem()} must be true for this material.
+ *
+ * @param material the material
+ * @param equipmentSlot the slot to get the attributes for
+ * @throws IllegalArgumentException if {@link Material#isItem()} is false
+ * @return an immutable multimap of attributes
+ */
+ @org.jetbrains.annotations.NotNull
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(@org.jetbrains.annotations.NotNull Material material, @org.jetbrains.annotations.NotNull EquipmentSlot equipmentSlot);
+
/**
* Returns the server's protocol version.
*