From 6b65e03d850383ef7d767abbcef448a4a38e0278 Mon Sep 17 00:00:00 2001 From: ysl3000 Date: Sat, 24 Oct 2020 16:37:44 +0200 Subject: [PATCH] living entity allow attribute registration --- .../entity/ai/attributes/AttributeMap.java.patch | 15 +++++++++++++++ .../craftbukkit/attribute/CraftAttributeMap.java | 7 +++++++ .../craftbukkit/entity/CraftLivingEntity.java | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch 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 000000000..08b12ec88 --- /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 5678d2007..0a7ed5a4f 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 1ca252f36..a4be1eea3 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) {