Paper/patches/api/0316-Get-entity-default-attributes.patch
Nassim Jahnke 4cdbb0c86c
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
044d4ee9 SPIGOT-7283, SPIGOT-7318: Add AsyncStructureGenerateEvent and BlockState cloning
57b73d57 PR-913: Deprecate Projectile#doesBounce() and #setBounce()
43373c44 PR-904: Update FeatureFlag for 1.20.2
a7bbbf0c PR-911: Expand DataPack API with 1.20.2 pack version methods
0341e3a0 SPIGOT-7489: Add TeleportDuration to Display Entity
bcd8d2aa PR-912: Update Minecraft Wiki URLs

CraftBukkit Changes:
99aafc222 Increase outdated build delay
dab849f08 SPIGOT-7283, SPIGOT-7318: Add AsyncStructureGenerateEvent and BlockState cloning
041b29ae3 Upgrade specialsource-maven-plugin
851a32cff PR-1263: Remove unused implementation of AbstractProjectile#doesBounce() and #setBounce()
251af0da3 PR-1261: Expand DataPack API with 1.20.2 pack version methods
46e4ba627 Upgrade specialsource-maven-plugin
df3738a24 SPIGOT-7489: Add TeleportDuration to Display Entity
8d0fea457 PR-1262: Update Minecraft Wiki URLs
e62905aab SPIGOT-7490: Fix entity equipment updates

Spigot Changes:
a0f3d486 Rebuild patches
2023-09-29 13:05:28 +10:00

64 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 20 Aug 2021 13:03:55 -0700
Subject: [PATCH] Get entity default attributes
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index d30cdfece8d324fb95c96c156974317450518274..827da519862c32907b41be77f61d51a244b2a749 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -187,5 +187,22 @@ public interface UnsafeValues {
* @return the server's protocol version
*/
int getProtocolVersion();
+
+ /**
+ * Checks if the entity represented by the namespaced key has default attributes.
+ *
+ * @param entityKey the entity's key
+ * @return true if it has default attributes
+ */
+ boolean hasDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
+
+ /**
+ * Gets the default attributes for the entity represented by the namespaced key.
+ *
+ * @param entityKey the entity's key
+ * @return an unmodifiable instance of Attributable for reading default attributes.
+ * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
+ */
+ @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
// Paper end
}
diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java
index 6c40a989eff1163c19106c1e6b4c8fc01ace7280..6cf14afd2c1b8018c67c6cac302ae28bb12ab5a5 100644
--- a/src/main/java/org/bukkit/entity/EntityType.java
+++ b/src/main/java/org/bukkit/entity/EntityType.java
@@ -449,6 +449,25 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
Preconditions.checkArgument(this != UNKNOWN, "UNKNOWN entities do not have translation keys");
return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
}
+
+ /**
+ * Checks if the entity has default attributes.
+ *
+ * @return true if it has default attributes
+ */
+ public boolean hasDefaultAttributes() {
+ return org.bukkit.Bukkit.getUnsafe().hasDefaultEntityAttributes(this.key);
+ }
+
+ /**
+ * Gets the default attributes for the entity.
+ *
+ * @return an unmodifiable instance of Attributable for reading default attributes.
+ * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultAttributes()} first)
+ */
+ public @NotNull org.bukkit.attribute.Attributable getDefaultAttributes() {
+ return org.bukkit.Bukkit.getUnsafe().getDefaultEntityAttributes(this.key);
+ }
// Paper end
/**