mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 18:05:10 +00:00
Renaming
This commit is contained in:
1 parent
5818060656
commit
3d90ddab46
6 files changed
+19
-19
No files matched your search
@@ -13,7 +13,7 @@ public class AttributeController {
|
||||
private static final Map<String, AttributeDefinition> definitions = new HashMap<>();
|
||||
private static int nextId = 0;
|
||||
|
||||
public static AttributeDefinition registerAttribute(String key, String displayName, Operation op) {
|
||||
public static AttributeDefinition registerAttribute(String key, String displayName, AttributeValueType op) {
|
||||
if (definitions.containsKey(key)) {
|
||||
return definitions.get(key);
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ public class AttributeDefinition {
|
||||
private final int id;
|
||||
private final String key; // e.g., "cnpc:main_attack_flat"
|
||||
private final String displayName; // Human‑readable name
|
||||
private final Operation operation;
|
||||
private final AttributeValueType attributeValueType;
|
||||
|
||||
public AttributeDefinition(int id, String key, String displayName, Operation operation) {
|
||||
public AttributeDefinition(int id, String key, String displayName, AttributeValueType attributeValueType) {
|
||||
this.id = id;
|
||||
this.key = key;
|
||||
this.displayName = displayName;
|
||||
this.operation = operation;
|
||||
this.attributeValueType = attributeValueType;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@@ -30,7 +30,7 @@ public class AttributeDefinition {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
public AttributeValueType getOperation() {
|
||||
return attributeValueType;
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ public class AttributeModifier {
|
||||
private final UUID id;
|
||||
private final String name;
|
||||
private final double amount;
|
||||
private final Operation operation;
|
||||
private final AttributeValueType attributeValueType;
|
||||
|
||||
public AttributeModifier(UUID id, String name, double amount, Operation operation) {
|
||||
public AttributeModifier(UUID id, String name, double amount, AttributeValueType attributeValueType) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.operation = operation;
|
||||
this.attributeValueType = attributeValueType;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
@@ -32,7 +32,7 @@ public class AttributeModifier {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
public AttributeValueType getOperation() {
|
||||
return attributeValueType;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.attribute;
|
||||
|
||||
public enum Operation {
|
||||
public enum AttributeValueType {
|
||||
FLAT, // e.g., +10 Health or +3 Damage
|
||||
PERCENT // e.g., +0.25 means +25% bonus
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class ModAttributes {
|
||||
public static final AttributeDefinition CRITICAL_DAMAGE_FLAT;
|
||||
|
||||
static {
|
||||
MAIN_ATTACK_FLAT = AttributeController.registerAttribute("cnpc:main_attack_flat", "Main Attack Damage (Flat)", Operation.FLAT);
|
||||
MAIN_ATTACK_PERCENT = AttributeController.registerAttribute("cnpc:main_attack_percent", "Main Attack Damage (%)", Operation.PERCENT);
|
||||
HEALTH = AttributeController.registerAttribute("cnpc:health", "Health", Operation.FLAT);
|
||||
CRITICAL_CHANCE_PERCENT = AttributeController.registerAttribute("cnpc:critical_chance_percent", "Critical Chance (%)", Operation.PERCENT);
|
||||
CRITICAL_DAMAGE_FLAT = AttributeController.registerAttribute("cnpc:critical_damage_flat", "Critical Damage Bonus (Flat)", Operation.FLAT);
|
||||
MAIN_ATTACK_FLAT = AttributeController.registerAttribute("cnpc:main_attack_flat", "Main Attack Damage (Flat)", AttributeValueType.FLAT);
|
||||
MAIN_ATTACK_PERCENT = AttributeController.registerAttribute("cnpc:main_attack_percent", "Main Attack Damage (%)", AttributeValueType.PERCENT);
|
||||
HEALTH = AttributeController.registerAttribute("cnpc:health", "Health", AttributeValueType.FLAT);
|
||||
CRITICAL_CHANCE_PERCENT = AttributeController.registerAttribute("cnpc:critical_chance_percent", "Critical Chance (%)", AttributeValueType.PERCENT);
|
||||
CRITICAL_DAMAGE_FLAT = AttributeController.registerAttribute("cnpc:critical_damage_flat", "Critical Damage Bonus (Flat)", AttributeValueType.FLAT);
|
||||
}
|
||||
}
|
||||
@@ -49,14 +49,14 @@ public class ModifiableAttributeInstance implements IAttributeInstance {
|
||||
double finalValue = baseValue;
|
||||
// Apply flat modifiers first:
|
||||
for (AttributeModifier mod : modifiers) {
|
||||
if (mod.getOperation() == Operation.FLAT) {
|
||||
if (mod.getOperation() == AttributeValueType.FLAT) {
|
||||
finalValue += mod.getAmount();
|
||||
}
|
||||
}
|
||||
// Then apply percentage modifiers additively:
|
||||
double percentSum = 0;
|
||||
for (AttributeModifier mod : modifiers) {
|
||||
if (mod.getOperation() == Operation.PERCENT) {
|
||||
if (mod.getOperation() == AttributeValueType.PERCENT) {
|
||||
percentSum += mod.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user