diff --git a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java index a1b2208eaff4..9e2cb7fadd4e 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java +++ b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java @@ -9,6 +9,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.Translatable; +import org.bukkit.entity.EntityType; import org.bukkit.util.OldEnum; import org.jetbrains.annotations.NotNull; @@ -169,6 +170,13 @@ private static Attribute getAttribute(@NotNull String key) { @NotNull Sentiment getSentiment(); + /** + * {@return the default value of this attribute} + *
+ * Default attribute values may differ between entity types, use {@link EntityType#getDefaultAttributes()} to get default attribute values for a specific entity type. + */ + double getDefaultValue(); + /** * @param name of the attribute. * @return the attribute with the given name. diff --git a/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java b/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java index 788ac9c22fd6..c1264ae6a0e8 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java +++ b/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java @@ -111,6 +111,12 @@ public interface AttributeInstance { * Gets the default value of the Attribute attached to this instance. * * @return server default value + * + * @deprecated This method is placed misleadingly as it does not return the default value in the current entity's context, but in the server's context. + * Use {@link Attribute#getDefaultValue()} as a replacement and see the note there about default values for specific entity types. + * @see Attribute#getDefaultValue() + * @see org.bukkit.entity.EntityType#getDefaultAttributes() */ + @Deprecated(since = "1.21.11") double getDefaultValue(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java index bdb4d0b55a41..69d892cc5558 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java @@ -61,6 +61,11 @@ public Sentiment getSentiment() { return Sentiment.valueOf(this.getHandle().sentiment.name()); } + @Override + public double getDefaultValue() { + return this.getHandle().getDefaultValue(); + } + @Override public String getTranslationKey() { return this.getHandle().getDescriptionId();