diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch new file mode 100644 index 0000000000..08b12ec883 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java ++++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java +@@ -162,4 +162,12 @@ + } + } + } ++ ++ // Paper - start - living entity allow attribute registration ++ public void registerAttribute(Holder attributeBase) { ++ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute); ++ attributes.put(attributeBase, attributeModifiable); ++ } ++ // Paper - end - living entity allow attribute registration ++ + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java index 5678d2007d..0a7ed5a4f1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -35,4 +35,11 @@ public class CraftAttributeMap implements Attributable { return (nms == null) ? null : new CraftAttributeInstance(nms, attribute); } + // Paper start - living entity allow attribute registration + @Override + public void registerAttribute(Attribute attribute) { + Preconditions.checkArgument(attribute != null, "attribute"); + handle.registerAttribute(CraftAttribute.bukkitToMinecraftHolder(attribute)); + } + // Paper end - living entity allow attribute registration } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 1ca252f365..a4be1eea35 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -775,6 +775,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return this.getHandle().craftAttributes.getAttribute(attribute); } + // Paper start - living entity allow attribute registration + @Override + public void registerAttribute(Attribute attribute) { + getHandle().craftAttributes.registerAttribute(attribute); + } + // Paper end - living entity allow attribute registration + @Override public void setAI(boolean ai) { if (this.getHandle() instanceof Mob) {