mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 16:37:45 +00:00
Change from Double to Float
This commit is contained in:
1 parent
c4fdf1a7b6
commit
d482213c85
8 files changed
+129
-72
No files matched your search
@@ -24,6 +24,7 @@ import net.minecraftforge.event.world.BlockEvent;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
import noppes.npcs.attribute.AttributeController;
|
||||
import noppes.npcs.attribute.DamageCalculator;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
@@ -472,6 +473,12 @@ public class ScriptPlayerEventHandler {
|
||||
}
|
||||
|
||||
if(event.source.getEntity() instanceof EntityPlayer) {
|
||||
if(event.entityLiving instanceof EntityPlayer){
|
||||
event.ammount = DamageCalculator.calculateDamagePlayer((EntityPlayer) event.source.getEntity(), (EntityPlayer) event.entityLiving, event.ammount);
|
||||
} else if (event.entityLiving instanceof EntityNPCInterface){
|
||||
|
||||
}
|
||||
|
||||
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||
cancel = cancel || EventHooks.onPlayerAttack(handler, pevent1);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package noppes.npcs.attribute;
|
||||
public enum AttributeValueType {
|
||||
FLAT, // e.g., +10 Health or +3 Damage
|
||||
PERCENT, // e.g., +0.25 means +25% bonus
|
||||
MAGIC // Represents a container of magic–based values (summed up as a double)
|
||||
MAGIC // Represents a container of magic–based values (summed up as a float)
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package noppes.npcs.attribute;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.attribute.player.PlayerAttributeTracker;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
@@ -9,51 +12,98 @@ import java.util.Random;
|
||||
public class DamageCalculator {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static double calculateDamage(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, double baseDamage) {
|
||||
public static float calculateDamagePlayer(EntityPlayer attacker, EntityPlayer defender, float base){
|
||||
return calculateDamagePlayer(AttributeController.getTracker(attacker), AttributeController.getTracker(defender), base);
|
||||
}
|
||||
|
||||
public static float calculateDamagePlayer(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, float baseDamage) {
|
||||
|
||||
// Calculate physical damage
|
||||
double mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
double mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
double physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
|
||||
// Calculate neutral damage
|
||||
double neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
|
||||
double neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
|
||||
double neutralTotal = neutralDamage * neutralBoost;
|
||||
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
|
||||
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
|
||||
float neutralTotal = neutralDamage * neutralBoost;
|
||||
|
||||
// Calculate magic damage
|
||||
double magicTotal = 0.0;
|
||||
float magicTotal = 0.0f;
|
||||
MagicController magicController = MagicController.getInstance();
|
||||
for (Map.Entry<Integer, Double> entry : attacker.magicDamage.entrySet()) {
|
||||
for (Map.Entry<Integer, Float> entry : attacker.magicDamage.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
if (magicController.getMagic(magicId) != null) {
|
||||
double attackMagic = entry.getValue();
|
||||
double defenseMagic = defender.magicDefense.getOrDefault(magicId, 0.0);
|
||||
double effectiveMagic = attackMagic - defenseMagic;
|
||||
float attackMagic = entry.getValue();
|
||||
float defenseMagic = defender.magicDefense.getOrDefault(magicId, 0.0f);
|
||||
float effectiveMagic = attackMagic - defenseMagic;
|
||||
|
||||
double boostMagic = attacker.magicBoost.getOrDefault(magicId, 0.0);
|
||||
double resistanceMagic = defender.magicResistance.getOrDefault(magicId, 0.0);
|
||||
double effectiveBoost = boostMagic - resistanceMagic;
|
||||
float boostMagic = attacker.magicBoost.getOrDefault(magicId, 0.0f);
|
||||
float resistanceMagic = defender.magicResistance.getOrDefault(magicId, 0.0f);
|
||||
float effectiveBoost = boostMagic - resistanceMagic;
|
||||
|
||||
double magicDamageForMagic = effectiveMagic * (effectiveBoost + 1);
|
||||
float magicDamageForMagic = effectiveMagic * (effectiveBoost + 1);
|
||||
// Ensure magic damage doesn't drop below 0 for this magic
|
||||
magicTotal += Math.max(0, magicDamageForMagic);
|
||||
}
|
||||
}
|
||||
|
||||
// Sum all damage components
|
||||
double totalDamage = physicalDamage + neutralTotal + magicTotal;
|
||||
float totalDamage = physicalDamage + neutralTotal + magicTotal;
|
||||
|
||||
// Critical hit: if critical, double damage and add bonus
|
||||
double criticalChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE);
|
||||
double criticalBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE);
|
||||
if (random.nextDouble() < (criticalChance / 100)) {
|
||||
// Critical hit: if critical, float damage and add bonus
|
||||
float criticalChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE);
|
||||
float criticalBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE);
|
||||
if (random.nextFloat() < (criticalChance / 100)) {
|
||||
totalDamage = (totalDamage * 2) + criticalBonus;
|
||||
}
|
||||
|
||||
return totalDamage;
|
||||
}
|
||||
|
||||
public static float calculateDamageNPC(PlayerAttributeTracker attacker, EntityNPCInterface defender, float baseDamage) {
|
||||
|
||||
// Calculate physical damage
|
||||
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
|
||||
// Calculate neutral damage
|
||||
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
|
||||
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
|
||||
float neutralTotal = neutralDamage * neutralBoost;
|
||||
|
||||
// Calculate magic damage
|
||||
// float magicTotal = 0.0;
|
||||
// MagicController magicController = MagicController.getInstance();
|
||||
// for (Map.Entry<Integer, Float> entry : attacker.magicDamage.entrySet()) {
|
||||
// int magicId = entry.getKey();
|
||||
// if (magicController.getMagic(magicId) != null) {
|
||||
// float attackMagic = entry.getValue();
|
||||
// float defenseMagic = defender.magicDefense.getOrDefault(magicId, 0.0);
|
||||
// float effectiveMagic = attackMagic - defenseMagic;
|
||||
//
|
||||
// float boostMagic = attacker.magicBoost.getOrDefault(magicId, 0.0);
|
||||
// float resistanceMagic = defender.magicResistance.getOrDefault(magicId, 0.0);
|
||||
// float effectiveBoost = boostMagic - resistanceMagic;
|
||||
//
|
||||
// float magicDamageForMagic = effectiveMagic * (effectiveBoost + 1);
|
||||
// // Ensure magic damage doesn't drop below 0 for this magic
|
||||
// magicTotal += Math.max(0, magicDamageForMagic);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Sum all damage components
|
||||
// float totalDamage = physicalDamage + neutralTotal + magicTotal;
|
||||
//
|
||||
// // Critical hit: if critical, float damage and add bonus
|
||||
// float criticalChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE);
|
||||
// float criticalBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE);
|
||||
// if (random.nextFloat() < (criticalChance / 100)) {
|
||||
// totalDamage = (totalDamage * 2) + criticalBonus;
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,6 @@ package noppes.npcs.attribute;
|
||||
*/
|
||||
public interface IAttributeInstance {
|
||||
AttributeDefinition getAttribute();
|
||||
double getValue();
|
||||
void setValue(double value);
|
||||
float getValue();
|
||||
void setValue(float value);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ItemAttributeHelper {
|
||||
/**
|
||||
* Applies a non–magic attribute to an item.
|
||||
*/
|
||||
public static void applyAttribute(ItemStack item, String attributeKey, double value) {
|
||||
public static void applyAttribute(ItemStack item, String attributeKey, Float value) {
|
||||
if (item == null) return;
|
||||
if (item.stackTagCompound == null) {
|
||||
item.stackTagCompound = new NBTTagCompound();
|
||||
@@ -40,7 +40,7 @@ public class ItemAttributeHelper {
|
||||
} else {
|
||||
attrTag = new NBTTagCompound();
|
||||
}
|
||||
attrTag.setDouble(attributeKey, value);
|
||||
attrTag.setFloat(attributeKey, value);
|
||||
root.setTag(RPGItemAttributes, attrTag);
|
||||
}
|
||||
|
||||
@@ -63,15 +63,15 @@ public class ItemAttributeHelper {
|
||||
/**
|
||||
* Reads non–magic attributes from an item.
|
||||
*/
|
||||
public static Map<String, Double> readAttributes(ItemStack item) {
|
||||
Map<String, Double> map = new HashMap<>();
|
||||
public static Map<String, Float> readAttributes(ItemStack item) {
|
||||
Map<String, Float> map = new HashMap<>();
|
||||
if (item == null || item.stackTagCompound == null) return map;
|
||||
NBTTagCompound root = item.stackTagCompound;
|
||||
if (root.hasKey(RPGItemAttributes)) {
|
||||
NBTTagCompound attrTag = root.getCompoundTag(RPGItemAttributes);
|
||||
Set<String> keys = attrTag.func_150296_c();
|
||||
for (String key : keys) {
|
||||
map.put(key, attrTag.getDouble(key));
|
||||
map.put(key, attrTag.getFloat(key));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@@ -81,8 +81,8 @@ public class ItemAttributeHelper {
|
||||
* Reads a magic attribute map from an item.
|
||||
* The given attributeTag is the key under which the compound is stored (e.g., MAGIC_DAMAGE_FLAT).
|
||||
*/
|
||||
public static Map<Integer, Double> readMagicAttributeMap(ItemStack item, String attributeTag) {
|
||||
Map<Integer, Double> map = new HashMap<>();
|
||||
public static Map<Integer, Float> readMagicAttributeMap(ItemStack item, String attributeTag) {
|
||||
Map<Integer, Float> map = new HashMap<>();
|
||||
if (item == null || item.stackTagCompound == null) return map;
|
||||
if (item.stackTagCompound.hasKey(attributeTag)) {
|
||||
NBTTagCompound magicMap = item.stackTagCompound.getCompoundTag(attributeTag);
|
||||
@@ -90,7 +90,7 @@ public class ItemAttributeHelper {
|
||||
for (String key : keys) {
|
||||
try {
|
||||
int magicId = Integer.parseInt(key);
|
||||
map.put(magicId, magicMap.getDouble(key));
|
||||
map.put(magicId, magicMap.getFloat(key));
|
||||
} catch (NumberFormatException e) {
|
||||
// Skip invalid key.
|
||||
}
|
||||
@@ -103,14 +103,14 @@ public class ItemAttributeHelper {
|
||||
* Applies (writes) a magic attribute to an item.
|
||||
* This is essentially the same as writeMagicAttribute.
|
||||
*/
|
||||
public static void applyMagicAttribute(ItemStack item, String attributeTag, int magicId, double value) {
|
||||
public static void applyMagicAttribute(ItemStack item, String attributeTag, int magicId, Float value) {
|
||||
writeMagicAttribute(item, attributeTag, magicId, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a magic attribute value to the given attributeTag.
|
||||
*/
|
||||
public static void writeMagicAttribute(ItemStack item, String attributeTag, int magicId, double value) {
|
||||
public static void writeMagicAttribute(ItemStack item, String attributeTag, int magicId, Float value) {
|
||||
if (item == null) return;
|
||||
if (item.stackTagCompound == null)
|
||||
item.stackTagCompound = new NBTTagCompound();
|
||||
@@ -120,7 +120,7 @@ public class ItemAttributeHelper {
|
||||
} else {
|
||||
magicMap = new NBTTagCompound();
|
||||
}
|
||||
magicMap.setDouble(String.valueOf(magicId), value);
|
||||
magicMap.setFloat(String.valueOf(magicId), value);
|
||||
item.stackTagCompound.setTag(attributeTag, magicMap);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class ItemAttributeHelper {
|
||||
|| key.equals(ModAttributes.MAGIC_DEFENSE_KEY) || key.equals(ModAttributes.MAGIC_RESISTANCE_KEY)) {
|
||||
continue;
|
||||
}
|
||||
double value = attrTag.getDouble(key);
|
||||
Float value = attrTag.getFloat(key);
|
||||
AttributeDefinition def = AttributeController.getAttribute(key);
|
||||
AttributeDefinition.AttributeSection section = def != null ? def.getSection() : AttributeDefinition.AttributeSection.EXTRA;
|
||||
String displayName = getTranslatedAttributeName(key, def);
|
||||
@@ -228,7 +228,7 @@ public class ItemAttributeHelper {
|
||||
String key = magicIter.next();
|
||||
try {
|
||||
int magicId = Integer.parseInt(key);
|
||||
double value = magicTag.getDouble(key);
|
||||
Float value = magicTag.getFloat(key);
|
||||
Magic magic = MagicController.getInstance().getMagic(magicId);
|
||||
if (magic != null) {
|
||||
String magicDisplayName = magic.getDisplayName() + " " + EnumChatFormatting.GRAY + getMagicAppendix(magicKey);
|
||||
@@ -293,8 +293,8 @@ public class ItemAttributeHelper {
|
||||
* Formats the attribute line based on its section and value type.
|
||||
*/
|
||||
private static String formatAttributeLine(AttributeDefinition def, AttributeDefinition.AttributeSection section,
|
||||
double value, String displayName) {
|
||||
String formattedValue = formatDouble(value);
|
||||
Float value, String displayName) {
|
||||
String formattedValue = formatFloat(value);
|
||||
if (section == AttributeDefinition.AttributeSection.MODIFIER || section == AttributeDefinition.AttributeSection.INFO) {
|
||||
String sign = value >= 0 ? "+" : "";
|
||||
String color = value >= 0 ? EnumChatFormatting.GREEN.toString() : EnumChatFormatting.RED.toString();
|
||||
@@ -327,9 +327,9 @@ public class ItemAttributeHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to format a double by removing trailing zeros.
|
||||
* Helper to format a Float by removing trailing zeros.
|
||||
*/
|
||||
private static String formatDouble(double value) {
|
||||
return new java.math.BigDecimal(Double.toString(value)).stripTrailingZeros().toPlainString();
|
||||
private static String formatFloat(Float value) {
|
||||
return new java.math.BigDecimal(Float.toString(value)).stripTrailingZeros().toPlainString();
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import noppes.npcs.attribute.IAttributeInstance;
|
||||
|
||||
public class PlayerAttribute implements IAttributeInstance {
|
||||
private final AttributeDefinition attribute;
|
||||
private double baseValue;
|
||||
private float baseValue;
|
||||
|
||||
public PlayerAttribute(AttributeDefinition attribute, double baseValue) {
|
||||
public PlayerAttribute(AttributeDefinition attribute, float baseValue) {
|
||||
this.attribute = attribute;
|
||||
this.baseValue = baseValue;
|
||||
}
|
||||
@@ -19,12 +19,12 @@ public class PlayerAttribute implements IAttributeInstance {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue() {
|
||||
public float getValue() {
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(double value) {
|
||||
public void setValue(float value) {
|
||||
this.baseValue = value;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
public class PlayerAttributeMap {
|
||||
private final Map<AttributeDefinition, IAttributeInstance> map = new HashMap<>();
|
||||
|
||||
public IAttributeInstance registerAttribute(AttributeDefinition attribute, double baseValue) {
|
||||
public IAttributeInstance registerAttribute(AttributeDefinition attribute, float baseValue) {
|
||||
if (map.containsKey(attribute)) {
|
||||
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public class PlayerAttributeTracker {
|
||||
private PlayerAttributeMap playerAttributes = new PlayerAttributeMap();
|
||||
|
||||
public final int extraHealth = 0;
|
||||
public final Map<Integer, Double> magicDamage = new HashMap<>();
|
||||
public final Map<Integer, Double> magicBoost = new HashMap<>();
|
||||
public final Map<Integer, Double> magicDefense = new HashMap<>();
|
||||
public final Map<Integer, Double> magicResistance = new HashMap<>();
|
||||
public final Map<Integer, Float> magicDamage = new HashMap<>();
|
||||
public final Map<Integer, Float> magicBoost = new HashMap<>();
|
||||
public final Map<Integer, Float> magicDefense = new HashMap<>();
|
||||
public final Map<Integer, Float> magicResistance = new HashMap<>();
|
||||
|
||||
private PlayerEquipmentTracker equipmentTracker = new PlayerEquipmentTracker();
|
||||
|
||||
@@ -46,14 +46,14 @@ public class PlayerAttributeTracker {
|
||||
ItemStack[] equipment = new ItemStack[] { currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet };
|
||||
for (ItemStack piece : equipment) {
|
||||
if (piece != null) {
|
||||
for (Entry<String, Double> entry : ItemAttributeHelper.readAttributes(piece).entrySet()) {
|
||||
for (Entry<String, Float> entry : ItemAttributeHelper.readAttributes(piece).entrySet()) {
|
||||
String key = entry.getKey();
|
||||
double value = entry.getValue();
|
||||
float value = entry.getValue();
|
||||
AttributeDefinition def = AttributeController.getAttribute(key);
|
||||
if (def != null) {
|
||||
IAttributeInstance inst = playerAttributes.getAttributeInstance(def);
|
||||
if (inst == null) {
|
||||
inst = playerAttributes.registerAttribute(def, 0.0);
|
||||
inst = playerAttributes.registerAttribute(def, 0.0f);
|
||||
}
|
||||
inst.setValue(inst.getValue() + value);
|
||||
}
|
||||
@@ -61,31 +61,31 @@ public class PlayerAttributeTracker {
|
||||
// Process Magic
|
||||
|
||||
// OFFENSIVE MAGIC
|
||||
Map<Integer, Double> magicFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DAMAGE_KEY);
|
||||
for (Entry<Integer, Double> entry : magicFlat.entrySet()) {
|
||||
Map<Integer, Float> magicFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DAMAGE_KEY);
|
||||
for (Entry<Integer, Float> entry : magicFlat.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
double value = entry.getValue();
|
||||
magicDamage.put(magicId, magicDamage.getOrDefault(magicId, 0.0) + value);
|
||||
float value = entry.getValue();
|
||||
magicDamage.put(magicId, magicDamage.getOrDefault(magicId, 0.0f) + value);
|
||||
}
|
||||
Map<Integer, Double> magicPercent = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_BOOST_KEY);
|
||||
for (Entry<Integer, Double> entry : magicPercent.entrySet()) {
|
||||
Map<Integer, Float> magicPercent = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_BOOST_KEY);
|
||||
for (Entry<Integer, Float> entry : magicPercent.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
double value = entry.getValue();
|
||||
magicBoost.put(magicId, magicBoost.getOrDefault(magicId, 0.0) + value);
|
||||
float value = entry.getValue();
|
||||
magicBoost.put(magicId, magicBoost.getOrDefault(magicId, 0.0f) + value);
|
||||
}
|
||||
|
||||
// DEFENSIVE MAGIC
|
||||
Map<Integer, Double> magicDefFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DEFENSE_KEY);
|
||||
for (Entry<Integer, Double> entry : magicDefFlat.entrySet()) {
|
||||
Map<Integer, Float> magicDefFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DEFENSE_KEY);
|
||||
for (Entry<Integer, Float> entry : magicDefFlat.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
double value = entry.getValue();
|
||||
magicDefense.put(magicId, magicDefense.getOrDefault(magicId, 0.0) + value);
|
||||
float value = entry.getValue();
|
||||
magicDefense.put(magicId, magicDefense.getOrDefault(magicId, 0.0f) + value);
|
||||
}
|
||||
Map<Integer, Double> magicResist = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_RESISTANCE_KEY);
|
||||
for (Entry<Integer, Double> entry : magicResist.entrySet()) {
|
||||
Map<Integer, Float> magicResist = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_RESISTANCE_KEY);
|
||||
for (Entry<Integer, Float> entry : magicResist.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
double value = entry.getValue();
|
||||
magicResistance.put(magicId, magicResistance.getOrDefault(magicId, 0.0) + value);
|
||||
float value = entry.getValue();
|
||||
magicResistance.put(magicId, magicResistance.getOrDefault(magicId, 0.0f) + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,8 @@ public class PlayerAttributeTracker {
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttributeValue(AttributeDefinition def) {
|
||||
public float getAttributeValue(AttributeDefinition def) {
|
||||
IAttributeInstance inst = playerAttributes.getAttributeInstance(def);
|
||||
return inst != null ? inst.getValue() : 0.0;
|
||||
return inst != null ? inst.getValue() : 0.0f;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user