net.minecraft.world.entity.ai.attributes

This commit is contained in:
Jake Potrebic
2024-12-14 16:44:37 -08:00
parent 6bb7e658de
commit 11b1877545
5 changed files with 66 additions and 59 deletions

View File

@@ -0,0 +1,27 @@
--- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
@@ -153,20 +_,20 @@
double baseValue = this.getBaseValue();
for (AttributeModifier attributeModifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) {
- baseValue += attributeModifier.amount();
+ baseValue += attributeModifier.amount(); // Paper - destroy speed API - diff on change
}
double d = baseValue;
for (AttributeModifier attributeModifier1 : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_MULTIPLIED_BASE)) {
- d += baseValue * attributeModifier1.amount();
+ d += baseValue * attributeModifier1.amount(); // Paper - destroy speed API - diff on change
}
for (AttributeModifier attributeModifier1 : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)) {
- d *= 1.0 + attributeModifier1.amount();
+ d *= 1.0 + attributeModifier1.amount(); // Paper - destroy speed API - diff on change
}
- return this.attribute.value().sanitizeValue(d);
+ return this.attribute.value().sanitizeValue(d); // Paper - destroy speed API - diff on change
}
private Collection<AttributeModifier> getModifiersOrEmpty(AttributeModifier.Operation operation) {

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 +_,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

@@ -0,0 +1,38 @@
--- a/net/minecraft/world/entity/ai/attributes/Attributes.java
+++ b/net/minecraft/world/entity/ai/attributes/Attributes.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.entity.ai.attributes;
import net.minecraft.core.Holder;
@@ -10,7 +_,7 @@
public static final Holder<Attribute> ARMOR_TOUGHNESS = register(
"armor_toughness", new RangedAttribute("attribute.name.armor_toughness", 0.0, 0.0, 20.0).setSyncable(true)
);
- public static final Holder<Attribute> ATTACK_DAMAGE = register("attack_damage", new RangedAttribute("attribute.name.attack_damage", 2.0, 0.0, 2048.0));
+ public static final Holder<Attribute> ATTACK_DAMAGE = register("attack_damage", new RangedAttribute("attribute.name.attack_damage", 2.0, 0.0, org.spigotmc.SpigotConfig.attackDamage)); // Spigot
public static final Holder<Attribute> ATTACK_KNOCKBACK = register("attack_knockback", new RangedAttribute("attribute.name.attack_knockback", 0.0, 0.0, 5.0));
public static final Holder<Attribute> ATTACK_SPEED = register(
"attack_speed", new RangedAttribute("attribute.name.attack_speed", 4.0, 0.0, 1024.0).setSyncable(true)
@@ -49,10 +_,10 @@
);
public static final Holder<Attribute> LUCK = register("luck", new RangedAttribute("attribute.name.luck", 0.0, -1024.0, 1024.0).setSyncable(true));
public static final Holder<Attribute> MAX_ABSORPTION = register(
- "max_absorption", new RangedAttribute("attribute.name.max_absorption", 0.0, 0.0, 2048.0).setSyncable(true)
+ "max_absorption", new RangedAttribute("attribute.name.max_absorption", 0.0, 0.0, org.spigotmc.SpigotConfig.maxAbsorption).setSyncable(true) // Spigot
);
public static final Holder<Attribute> MAX_HEALTH = register(
- "max_health", new RangedAttribute("attribute.name.max_health", 20.0, 1.0, 1024.0).setSyncable(true)
+ "max_health", new RangedAttribute("attribute.name.max_health", 20.0, 1.0, org.spigotmc.SpigotConfig.maxHealth).setSyncable(true) // Spigot
);
public static final Holder<Attribute> MINING_EFFICIENCY = register(
"mining_efficiency", new RangedAttribute("attribute.name.mining_efficiency", 0.0, 0.0, 1024.0).setSyncable(true)
@@ -61,7 +_,7 @@
"movement_efficiency", new RangedAttribute("attribute.name.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true)
);
public static final Holder<Attribute> MOVEMENT_SPEED = register(
- "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0).setSyncable(true)
+ "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, org.spigotmc.SpigotConfig.movementSpeed).setSyncable(true) // Spigot
);
public static final Holder<Attribute> OXYGEN_BONUS = register(
"oxygen_bonus", new RangedAttribute("attribute.name.oxygen_bonus", 0.0, 0.0, 1024.0).setSyncable(true)