living entity allow attribute registration

This commit is contained in:
ysl3000 2020-10-24 16:37:44 +02:00
parent 0312fd2b42
commit 6b65e03d85
3 changed files with 29 additions and 0 deletions

View File

@ -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<Attribute> attributeBase) {
+ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute);
+ attributes.put(attributeBase, attributeModifiable);
+ }
+ // Paper - end - living entity allow attribute registration
+
}

View File

@ -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
}

View File

@ -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) {