diff --git a/src/main/java/mekanism/common/Upgrade.java b/src/main/java/mekanism/common/Upgrade.java index 10abd55a6..87eab949a 100644 --- a/src/main/java/mekanism/common/Upgrade.java +++ b/src/main/java/mekanism/common/Upgrade.java @@ -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 getMultScaledInfo(IUpgradeTile tile) + { + List ret = new ArrayList(); + + 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 getExpScaledInfo(IUpgradeTile tile) + { + List ret = new ArrayList(); + + 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 getInfo(Upgrade upgrade); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityFlame.java b/src/main/java/mekanism/common/entity/EntityFlame.java index a4c66ef34..238986345 100644 --- a/src/main/java/mekanism/common/entity/EntityFlame.java +++ b/src/main/java/mekanism/common/entity/EntityFlame.java @@ -223,6 +223,13 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData private boolean smeltBlock(Coord4D block) { + ItemStack stack = block.getStack(worldObj); + + if(stack == null) + { + return false; + } + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj)); if(result != null) diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index 8a6dd21ad..db402e87a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -136,12 +136,12 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock setActive(true); setEnergy(getEnergy() - energyUsage); + if((operatingTicks+1) < ticksRequired) { operatingTicks++; } - else - { + else { operate(recipe); operatingTicks = 0; } @@ -170,10 +170,12 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock public CrystallizerRecipe getRecipe() { GasInput input = getInput(); + if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getChemicalCrystallizerRecipe(getInput()); } + return cachedRecipe; } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index b52394abf..7c723ab88 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import java.util.List; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; @@ -17,6 +18,7 @@ import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; import mekanism.common.Mekanism; import mekanism.common.Upgrade; +import mekanism.common.Upgrade.IUpgradeInfoHandler; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedData; import mekanism.common.base.IUpgradeTile; @@ -36,7 +38,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile +public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler { public GasTank leftTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS); @@ -149,20 +151,19 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl public int getUpgradedUsage(ChemicalInfuserRecipe recipe) { - int possibleProcess = 0; + int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); if(leftTank.getGasType() == recipe.recipeInput.leftGas.getGas()) { - possibleProcess = leftTank.getStored()/recipe.recipeInput.leftGas.amount; + possibleProcess = Math.min(leftTank.getStored()/recipe.recipeInput.leftGas.amount, possibleProcess); possibleProcess = Math.min(rightTank.getStored()/recipe.recipeInput.rightGas.amount, possibleProcess); } else { - possibleProcess = leftTank.getStored()/recipe.recipeInput.rightGas.amount; + possibleProcess = Math.min(leftTank.getStored()/recipe.recipeInput.rightGas.amount, possibleProcess); possibleProcess = Math.min(rightTank.getStored()/recipe.recipeInput.leftGas.amount, possibleProcess); } possibleProcess = Math.min(centerTank.getNeeded()/recipe.recipeOutput.output.amount, possibleProcess); - possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); return possibleProcess; @@ -533,4 +534,10 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); } } + + @Override + public List getInfo(Upgrade upgrade) + { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index 176dd1726..aaf4d7fbb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import java.util.List; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; @@ -17,6 +18,7 @@ import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; import mekanism.common.Mekanism; import mekanism.common.Upgrade; +import mekanism.common.Upgrade.IUpgradeInfoHandler; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedData; import mekanism.common.base.IUpgradeTile; @@ -46,7 +48,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler, IUpgradeTile, ISustainedData +public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler, IUpgradeTile, ISustainedData, IUpgradeInfoHandler { public FluidTank fluidTank = new FluidTank(MAX_FLUID); public GasTank inputTank = new GasTank(MAX_GAS); @@ -257,8 +259,8 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple public int getUpgradedUsage() { - int possibleProcess = Math.min(inputTank.getStored(), outputTank.getNeeded()); - possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); + int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); return Math.min(fluidTank.getFluidAmount()/WATER_USAGE, possibleProcess); @@ -648,4 +650,10 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); } } + + @Override + public List getInfo(Upgrade upgrade) + { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index f3f6979df..218042006 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import java.util.List; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; @@ -16,6 +17,7 @@ import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; import mekanism.common.Mekanism; import mekanism.common.Upgrade; +import mekanism.common.Upgrade.IUpgradeInfoHandler; import mekanism.common.base.IActiveState; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedData; @@ -41,7 +43,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl, IUpgradeTile +public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl, IUpgradeTile, IUpgradeInfoHandler { public GasTank gasTank = new GasTank(MAX_FLUID); @@ -168,10 +170,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { + int usage = getUpgradedUsage(); + setActive(true); - fluidTank.fill(new FluidStack(gasTank.getGas().getGas().getFluid(), getUpgradedUsage()), true); - gasTank.draw(getUpgradedUsage(), true); - setEnergy(getEnergy() - BASE_ENERGY_USAGE); + fluidTank.fill(new FluidStack(gasTank.getGas().getGas().getFluid(), usage), true); + gasTank.draw(usage, true); + setEnergy(getEnergy() - BASE_ENERGY_USAGE*usage); } else { if(prevEnergy >= getEnergy()) @@ -273,10 +277,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { + int usage = getUpgradedUsage(); + setActive(true); - gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), getUpgradedUsage()), true); - fluidTank.drain(getUpgradedUsage(), true); - setEnergy(getEnergy() - BASE_ENERGY_USAGE); + gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), usage), true); + fluidTank.drain(usage, true); + setEnergy(getEnergy() - BASE_ENERGY_USAGE*usage); } else { if(prevEnergy >= getEnergy()) @@ -292,17 +298,16 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp public int getUpgradedUsage() { - int possibleProcess = 0; + int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); if(mode == 0) //Gas to fluid { - possibleProcess = Math.min(gasTank.getStored(), fluidTank.getCapacity()-fluidTank.getFluidAmount()); + possibleProcess = Math.min(Math.min(gasTank.getStored(), fluidTank.getCapacity()-fluidTank.getFluidAmount()), possibleProcess); } else { //Fluid to gas - possibleProcess = Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()); + possibleProcess = Math.min(Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess); } - possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); return possibleProcess; @@ -640,4 +645,10 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); } } + + @Override + public List getInfo(Upgrade upgrade) + { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); + } }