Polished off the upgrade system - now works consistently and properly for all Mekanism machines. Also, fixed a flamethrower bug

This commit is contained in:
Aidan C. Brady committed 2015-02-26 16:47:36 -05:00
1 parent c7e199b06c
commit 74ba02e0bb
6 files changed
+94 -26

No files matched your search

+38 -5
View File
@@ -9,7 +9,6 @@ import mekanism.api.EnumColor;
import mekanism.api.MekanismConfig.general;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -80,12 +79,41 @@ public enum Upgrade
if(tile instanceof IUpgradeTile)
{
if(canMultiply())
if(tile instanceof IUpgradeInfoHandler)
{
double effect = Math.pow(general.maxUpgradeMultiplier, (float)((IUpgradeTile)tile).getComponent().getUpgrades(this)/(float)getMax());
ret.add(MekanismUtils.localize("gui.upgrades.effect") + ": " + (Math.round(effect*100)/100F) + "x");
return ((IUpgradeInfoHandler)tile).getInfo(this);
}
else {
ret = getMultScaledInfo((IUpgradeTile)tile);
}
}
return ret;
}
public List<String> getMultScaledInfo(IUpgradeTile tile)
{
List<String> ret = new ArrayList<String>();
if(canMultiply())
{
double effect = Math.pow(general.maxUpgradeMultiplier, (float)tile.getComponent().getUpgrades(this)/(float)getMax());
ret.add(MekanismUtils.localize("gui.upgrades.effect") + ": " + (Math.round(effect*100)/100F) + "x");
}
return ret;
}
public List<String> getExpScaledInfo(IUpgradeTile tile)
{
List<String> ret = new ArrayList<String>();
if(canMultiply())
{
double effect = Math.pow(2, (float)tile.getComponent().getUpgrades(this));
ret.add(MekanismUtils.localize("gui.upgrades.effect") + ": " + effect + "x");
}
return ret;
@@ -132,4 +160,9 @@ public enum Upgrade
return compound;
}
public static interface IUpgradeInfoHandler
{
public List<String> getInfo(Upgrade upgrade);
}
}