From 0000000000000000000000000000000000000000 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 diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMapBase.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMapBase.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMapBase.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMapBase.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; public class AttributeMapBase { private static final Logger LOGGER = LogManager.getLogger(); - private final Map b = Maps.newHashMap(); + private final Map b = Maps.newHashMap(); private final Map attributeMap = b; // Paper - OBFHELPER private final Set c = Sets.newHashSet(); private final AttributeProvider d; @@ -0,0 +0,0 @@ public class AttributeMapBase { } } + + // Paper - start + public void registerAttribute(AttributeBase attributeBase) { + AttributeModifiable attributeModifiable = new AttributeModifiable(attributeBase, AttributeModifiable::getAttribute); + attributeMap.put(attributeBase, attributeModifiable); + } + // Paper - end + } diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -0,0 +0,0 @@ public class CraftAttributeMap implements Attributable { return (nms == null) ? null : new CraftAttributeInstance(nms, attribute); } + // Paper start + @Override + public void registerAttribute(Attribute attribute) { + Preconditions.checkArgument(attribute != null, "attribute"); + handle.registerAttribute(CraftAttributeMap.toMinecraft(attribute)); + } + // Paper end + public static AttributeBase toMinecraft(Attribute attribute) { return IRegistry.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey())); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return getHandle().craftAttributes.getAttribute(attribute); } + // Paper start + @Override + public void registerAttribute(Attribute attribute) { + getHandle().craftAttributes.registerAttribute(attribute); + } + // Paper end + @Override public void setAI(boolean ai) { if (this.getHandle() instanceof EntityInsentient) {