Paper/patches/api/0291-Attributes-API-for-item-defaults.patch
Jake Potrebic b5ce6e3dc5
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9104)
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:
eb4b416d PR-822: Add experimental armor trim API
33498e1d PR-831: Add a standard of annotations for Minecraft experimental things and API

CraftBukkit Changes:
19de3550d SPIGOT-7315: Bed placement duplicates crops if cancelled
1eb88374e PR-1147: Add experimental armor trim API
c4c0bb0e9 Show clean error for invalidly configured server.properties options
3ae90697f Fix UUID not being updated when changing world of MapView
e43000601 PR-1164, MC-227255, MC-253819: Fix rotation of beehives and bells

Spigot Changes:
d2fdfe39 Rebuild patches
2023-04-09 01:00:50 +01: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 22649f3ba10a0b6e33c584ee84b76cbbda992919..041fe4384c611b9d88121bda0cb9e5e034ff7e7b 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4584,6 +4584,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 29a91ec8e97ce66383a1dd1fc3dcbcdcca7cfc41..0d47278d68cdf015cb980721c234a3abee39646a 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -165,6 +165,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.
*