mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 13:14:44 +02:00
Using doubles in most places again to avoid precision loss
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user