2021-06-11 14:02:28 +02:00
|
|
|
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
|
2022-12-07 21:16:54 +01:00
|
|
|
index 03561cb69c58e4ed8115a9e67df28d5df1f79bc4..dd1102d5291ef6f18e82400a6d8a0a376cc071e9 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -150,4 +150,12 @@ public class AttributeMap {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper - start
|
|
|
|
+ public void registerAttribute(Attribute attributeBase) {
|
|
|
|
+ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute);
|
2021-06-15 04:59:31 +02:00
|
|
|
+ attributes.put(attributeBase, attributeModifiable);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper - end
|
|
|
|
+
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
2022-12-07 21:16:54 +01:00
|
|
|
index 233e372ba5d785352c9ac12dac37395bac63315c..0e61caa5c9f21788fbeaa90ed75d23e10b816aac 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -39,6 +39,14 @@ public class CraftAttributeMap implements Attributable {
|
2021-06-11 14:02:28 +02:00
|
|
|
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) {
|
2022-12-07 21:16:54 +01:00
|
|
|
return BuiltInRegistries.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey()));
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
2023-06-13 01:51:45 +02:00
|
|
|
index c74a6df6a9c3c7745daae4c0558948ea4a31d7a6..63a1522071ec6e9a550598b04c1a901ff76a5c78 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -702,6 +702,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
2021-06-15 04:59:31 +02:00
|
|
|
return this.getHandle().craftAttributes.getAttribute(attribute);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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) {
|