geforkt von Mirrors/Paper
70 Zeilen
3.4 KiB
Diff
70 Zeilen
3.4 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 a501f334ce0bcc606dd2bb186cf7195102cd6c09..8acd102c0778e4e546e5191b6098eacbd15bd9f9 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
|
||
|
@@ -21,7 +21,7 @@ import org.apache.logging.log4j.Logger;
|
||
|
public class AttributeMap {
|
||
|
|
||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||
|
- private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||
|
+ private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap(); private final Map<Attribute, AttributeInstance> attributeMap = attributes; // Paper - OBFHELPER
|
||
|
private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
|
||
|
private final AttributeSupplier supplier;
|
||
|
|
||
|
@@ -135,4 +135,12 @@ public class AttributeMap {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
+
|
||
|
+ // Paper - start
|
||
|
+ public void registerAttribute(Attribute attributeBase) {
|
||
|
+ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::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 320fd6780af2fa99e4e4f4193cbc9338d492dc6d..a57b16679889f5b20c74712651f94d6796b8c661 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||
|
@@ -38,6 +38,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 net.minecraft.core.Registry.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 a8d21382d5859edfd12e01a48924ce780790b4b7..eefb6bd580ea176c3a242695ab4af46e7c61b492 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||
|
@@ -663,6 +663,13 @@ 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 Mob) {
|