mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
61 lines
2.8 KiB
Diff
61 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: ysl3000 <yannicklamprecht@live.de>
|
|
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/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
index 2ea862bd560ffe76202d68b785f00877ccdedefd..a26106bf1b1cc715fd3c189e46d715fedb70ee15 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
@@ -152,4 +152,12 @@ public class AttributeMap {
|
|
}
|
|
|
|
}
|
|
+
|
|
+ // Paper - start
|
|
+ public void registerAttribute(Attribute attributeBase) {
|
|
+ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute);
|
|
+ attributes.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 233e372ba5d785352c9ac12dac37395bac63315c..0e61caa5c9f21788fbeaa90ed75d23e10b816aac 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
|
@@ -39,6 +39,14 @@ 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 net.minecraft.world.entity.ai.attributes.Attribute toMinecraft(Attribute attribute) {
|
|
return BuiltInRegistries.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 4d41a73281c851c1ff9506074f7590c06105efbb..13b4873923d64ab4b18795ce7f2dbc9a7abf067e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -710,6 +710,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
return this.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 Mob) {
|