Using doubles in most places again to avoid precision loss

This commit is contained in:
nossr50
2019-06-04 21:12:10 -07:00
parent 32fa6cee96
commit fc6c6ed2c4
59 changed files with 382 additions and 351 deletions

View File

@ -25,6 +25,18 @@ public abstract class SkillManager {
return mcMMOPlayer.getSkillLevel(skill);
}
/**
* Applies XP to a player, provides SELF as an XpGainSource source
*
* @param xp amount of XP to apply
* @param xpGainReason the reason for the XP gain
* @deprecated use applyXpGain(float, XPGainReason, XPGainSource)
*/
@Deprecated
public void applyXpGain(double xp, XPGainReason xpGainReason) {
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason, XPGainSource.SELF);
}
/**
* Applies XP to a player, provides SELF as an XpGainSource source
*
@ -48,6 +60,17 @@ public abstract class SkillManager {
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason, xpGainSource);
}
/**
* Applies XP to a player
*
* @param xp amount of XP to apply
* @param xpGainReason the reason for the XP gain
* @param xpGainSource the source of the XP
*/
public void applyXpGain(double xp, XPGainReason xpGainReason, XPGainSource xpGainSource) {
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason, xpGainSource);
}
public XPGainReason getXPGainReason(LivingEntity target, Entity damager) {
return (damager instanceof Player && target instanceof Player) ? XPGainReason.PVP : XPGainReason.PVE;
}

View File

@ -20,7 +20,7 @@ public final class Fishing {
public static Fishing instance;
private final long fishingRodCastCdMilliseconds;
private final int overfishLimit;
private final float boundingBoxSize;
private final double boundingBoxSize;
private HashMap<Material, List<Enchantment>> enchantableCache = new HashMap<>();
private HashMap<Material, Integer> fishingXpRewardMap;
private Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
@ -121,7 +121,7 @@ public final class Fishing {
return overfishLimit;
}
public float getBoundingBoxSize() {
public double getBoundingBoxSize() {
return boundingBoxSize;
}
}

View File

@ -173,7 +173,7 @@ public class RepairManager extends SkillManager {
inventory.removeItem(toRemove);
// Give out XP like candy
applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability())
applyXpGain(((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability())
* repairable.getXpMultiplier())
* mcMMO.getConfigManager().getConfigExperience().getRepairXPBase())
* mcMMO.getConfigManager().getConfigExperience().getExperienceRepair().getItemMaterialXPMultiplier(repairable.getRepairItemMaterialCategory()), XPGainReason.PVE);
@ -188,7 +188,7 @@ public class RepairManager extends SkillManager {
item.setDurability(newDurability);
}
private float getPercentageRepaired(short startDurability, short newDurability, short totalDurability) {
private double getPercentageRepaired(short startDurability, short newDurability, short totalDurability) {
return ((startDurability - newDurability) / (float) totalDurability);
}