Chemical Infuser, Chemical Washer and Electrolytic Separator are now upgradeable
This commit is contained in:
parent
f320aa4337
commit
b419519cc0
10 changed files with 166 additions and 50 deletions
|
@ -19,7 +19,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
|||
import mekanism.common.tile.TileEntityChemicalInfuser;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -37,11 +36,19 @@ public class GuiChemicalInfuser extends GuiMekanism
|
|||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
|
||||
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
|
||||
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE);
|
||||
double usage = 0;
|
||||
|
||||
if(tileEntity.getRecipe() != null)
|
||||
{
|
||||
usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*tileEntity.BASE_ENERGY_USAGE;
|
||||
}
|
||||
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(usage);
|
||||
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
|
||||
|
|
|
@ -45,7 +45,7 @@ public class GuiChemicalWasher extends GuiMekanism
|
|||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage);
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.BASE_ENERGY_USAGE*tileEntity.getUpgradedUsage());
|
||||
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")));
|
||||
|
|
|
@ -21,7 +21,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
|||
import mekanism.common.tile.TileEntityElectrolyticSeparator;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -40,11 +39,19 @@ public class GuiElectrolyticSeparator extends GuiMekanism
|
|||
|
||||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png")));
|
||||
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(general.FROM_H2*2);
|
||||
double usage = 0;
|
||||
|
||||
if(tileEntity.getRecipe() != null)
|
||||
{
|
||||
usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*tileEntity.getRecipe().extraEnergy;
|
||||
}
|
||||
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(usage);
|
||||
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png")));
|
||||
|
|
|
@ -154,7 +154,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
{
|
||||
super(Material.iron);
|
||||
setHardness(3.5F);
|
||||
setResistance(8F);
|
||||
setResistance(16F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
blockType = type;
|
||||
}
|
||||
|
|
|
@ -580,9 +580,9 @@ public final class RecipeHandler
|
|||
{
|
||||
Map.Entry entry = (Map.Entry)obj;
|
||||
|
||||
if(entry.getKey() instanceof FluidStack)
|
||||
if(entry.getKey() instanceof FluidInput)
|
||||
{
|
||||
if(((FluidStack)entry.getKey()).getFluid() == input)
|
||||
if(((FluidInput)entry.getKey()).ingredient.getFluid() == input)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ public class SeparatorRecipe extends MachineRecipe<FluidInput, ChemicalPairOutpu
|
|||
|
||||
public boolean canOperate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank)
|
||||
{
|
||||
return getInput().useFluid(fluidTank, false, 1) && getOutput().applyOutputs(leftTank, rightTank, false);
|
||||
return getInput().useFluid(fluidTank, false, 1) && getOutput().applyOutputs(leftTank, rightTank, false, 1);
|
||||
}
|
||||
|
||||
public void operate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank)
|
||||
public void operate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank, int scale)
|
||||
{
|
||||
if(getInput().useFluid(fluidTank, true, 1))
|
||||
if(getInput().useFluid(fluidTank, true, scale))
|
||||
{
|
||||
getOutput().applyOutputs(leftTank, rightTank, true);
|
||||
getOutput().applyOutputs(leftTank, rightTank, true, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,25 +55,29 @@ public class ChemicalPairOutput extends MachineOutput<ChemicalPairOutput>
|
|||
return new ChemicalPairOutput(rightGas, leftGas);
|
||||
}
|
||||
|
||||
public boolean applyOutputs(GasTank leftTank, GasTank rightTank, boolean doEmit)
|
||||
public boolean applyOutputs(GasTank leftTank, GasTank rightTank, boolean doEmit, int scale)
|
||||
{
|
||||
if(leftTank.canReceive(leftGas.getGas()) && rightTank.canReceive(rightGas.getGas()))
|
||||
{
|
||||
if(leftTank.getNeeded() >= leftGas.amount && rightTank.getNeeded() >= rightGas.amount)
|
||||
if(leftTank.getNeeded() >= leftGas.amount*scale && rightTank.getNeeded() >= rightGas.amount*scale)
|
||||
{
|
||||
leftTank.receive(leftGas, doEmit);
|
||||
rightTank.receive(rightGas, doEmit);
|
||||
leftTank.receive(leftGas.copy().withAmount(leftGas.amount*scale), doEmit);
|
||||
rightTank.receive(rightGas.copy().withAmount(rightGas.amount*scale), doEmit);
|
||||
|
||||
return true;
|
||||
}
|
||||
} else if(leftTank.canReceive(rightGas.getGas()) && rightTank.canReceive(leftGas.getGas()))
|
||||
}
|
||||
else if(leftTank.canReceive(rightGas.getGas()) && rightTank.canReceive(leftGas.getGas()))
|
||||
{
|
||||
if(leftTank.getNeeded() >= rightGas.amount && rightTank.getNeeded() >= leftGas.amount)
|
||||
if(leftTank.getNeeded() >= rightGas.amount*scale && rightTank.getNeeded() >= leftGas.amount*scale)
|
||||
{
|
||||
leftTank.receive(rightGas, doEmit);
|
||||
rightTank.receive(leftGas, doEmit);
|
||||
leftTank.receive(rightGas.copy().withAmount(rightGas.amount*scale), doEmit);
|
||||
rightTank.receive(leftGas.copy().withAmount(leftGas.amount*scale), doEmit);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
|
@ -14,17 +16,19 @@ import mekanism.api.gas.IGasHandler;
|
|||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ChemicalPairInput;
|
||||
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -32,9 +36,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData
|
||||
public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile
|
||||
{
|
||||
public GasTank leftTank = new GasTank(MAX_GAS);
|
||||
public GasTank rightTank = new GasTank(MAX_GAS);
|
||||
|
@ -52,9 +54,11 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double ENERGY_USAGE = usage.chemicalInfuserUsage;
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalInfuserUsage;
|
||||
|
||||
public ChemicalInfuserRecipe cachedRecipe;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
@ -62,7 +66,7 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
public TileEntityChemicalInfuser()
|
||||
{
|
||||
super("machine.cheminfuser", "ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy);
|
||||
inventory = new ItemStack[4];
|
||||
inventory = new ItemStack[5];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,10 +114,10 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true);
|
||||
}
|
||||
|
||||
if(canOperate(recipe) && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this))
|
||||
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this))
|
||||
{
|
||||
setActive(true);
|
||||
setEnergy(getEnergy() - ENERGY_USAGE);
|
||||
setEnergy(getEnergy() - BASE_ENERGY_USAGE);
|
||||
|
||||
operate(recipe);
|
||||
}
|
||||
|
@ -142,6 +146,27 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
public int getUpgradedUsage(ChemicalInfuserRecipe recipe)
|
||||
{
|
||||
int possibleProcess = 0;
|
||||
|
||||
if(leftTank.getGasType() == recipe.recipeInput.leftGas.getGas())
|
||||
{
|
||||
possibleProcess = leftTank.getStored()/recipe.recipeInput.leftGas.amount;
|
||||
possibleProcess = Math.min(rightTank.getStored()/recipe.recipeInput.rightGas.amount, possibleProcess);
|
||||
}
|
||||
else {
|
||||
possibleProcess = leftTank.getStored()/recipe.recipeInput.rightGas.amount;
|
||||
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;
|
||||
}
|
||||
|
||||
public ChemicalPairInput getInput()
|
||||
{
|
||||
|
@ -151,10 +176,12 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
public ChemicalInfuserRecipe getRecipe()
|
||||
{
|
||||
ChemicalPairInput input = getInput();
|
||||
|
||||
if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput()))
|
||||
{
|
||||
cachedRecipe = RecipeHandler.getChemicalInfuserRecipe(getInput());
|
||||
}
|
||||
|
||||
return cachedRecipe;
|
||||
}
|
||||
|
||||
|
@ -488,4 +515,22 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
|||
rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank")));
|
||||
centerTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("centerTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
|||
public double prevEnergy;
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalWasherUsage;
|
||||
|
||||
public double energyUsage = usage.chemicalWasherUsage;
|
||||
|
||||
public WasherRecipe cachedRecipe;
|
||||
|
||||
|
@ -120,13 +118,13 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
|||
outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true);
|
||||
}
|
||||
|
||||
if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this))
|
||||
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this))
|
||||
{
|
||||
setActive(true);
|
||||
|
||||
operate(recipe);
|
||||
int operations = operate(recipe);
|
||||
|
||||
setEnergy(getEnergy() - energyUsage);
|
||||
setEnergy(getEnergy() - BASE_ENERGY_USAGE*operations);
|
||||
}
|
||||
else {
|
||||
if(prevEnergy >= getEnergy())
|
||||
|
@ -176,9 +174,13 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
|||
return recipe != null && recipe.canOperate(inputTank, fluidTank, outputTank);
|
||||
}
|
||||
|
||||
public void operate(WasherRecipe recipe)
|
||||
public int operate(WasherRecipe recipe)
|
||||
{
|
||||
recipe.operate(inputTank, fluidTank, outputTank, getUpgradedUsage());
|
||||
int operations = getUpgradedUsage();
|
||||
|
||||
recipe.operate(inputTank, fluidTank, outputTank, operations);
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
private void manageBuckets()
|
||||
|
@ -257,6 +259,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
|||
{
|
||||
int possibleProcess = Math.min(inputTank.getStored(), outputTank.getNeeded());
|
||||
possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess);
|
||||
possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess);
|
||||
|
||||
return Math.min(fluidTank.getFluidAmount()/WATER_USAGE, possibleProcess);
|
||||
}
|
||||
|
@ -643,7 +646,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
|||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
|
@ -13,7 +15,9 @@ import mekanism.api.gas.IGasHandler;
|
|||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
|
@ -21,11 +25,11 @@ import mekanism.common.recipe.RecipeHandler.Recipe;
|
|||
import mekanism.common.recipe.inputs.FluidInput;
|
||||
import mekanism.common.recipe.machines.SeparatorRecipe;
|
||||
import mekanism.common.recipe.outputs.ChemicalPairOutput;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -40,16 +44,13 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
|||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler
|
||||
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler, IUpgradeTile
|
||||
{
|
||||
/** This separator's water slot. */
|
||||
public FluidTank fluidTank = new FluidTank(24000);
|
||||
|
@ -75,11 +76,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
public boolean isActive = false;
|
||||
|
||||
public SeparatorRecipe cachedRecipe;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
|
||||
public TileEntityElectrolyticSeparator()
|
||||
{
|
||||
super("ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy);
|
||||
inventory = new ItemStack[4];
|
||||
inventory = new ItemStack[5];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,12 +143,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
if(canOperate(recipe) && getEnergy() >= recipe.extraEnergy)
|
||||
{
|
||||
setActive(true);
|
||||
operate(recipe);
|
||||
setEnergy(getEnergy() - recipe.extraEnergy);
|
||||
|
||||
int operations = operate(recipe);
|
||||
|
||||
setEnergy(getEnergy() - recipe.extraEnergy*operations);
|
||||
}
|
||||
else {
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
int dumpAmount = 8*(int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED));
|
||||
|
||||
if(leftTank.getGas() != null)
|
||||
{
|
||||
|
@ -164,7 +171,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
}
|
||||
}
|
||||
else {
|
||||
leftTank.draw(8, true);
|
||||
leftTank.draw(dumpAmount, true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
|
@ -190,7 +197,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
}
|
||||
}
|
||||
else {
|
||||
rightTank.draw(8, true);
|
||||
rightTank.draw(dumpAmount, true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
|
@ -201,14 +208,36 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public int getUpgradedUsage(SeparatorRecipe recipe)
|
||||
{
|
||||
int possibleProcess = 0;
|
||||
|
||||
if(leftTank.getGasType() == recipe.recipeOutput.leftGas.getGas())
|
||||
{
|
||||
possibleProcess = leftTank.getNeeded()/recipe.recipeOutput.leftGas.amount;
|
||||
possibleProcess = Math.min(rightTank.getNeeded()/recipe.recipeOutput.rightGas.amount, possibleProcess);
|
||||
}
|
||||
else {
|
||||
possibleProcess = leftTank.getNeeded()/recipe.recipeOutput.rightGas.amount;
|
||||
possibleProcess = Math.min(rightTank.getNeeded()/recipe.recipeOutput.leftGas.amount, possibleProcess);
|
||||
}
|
||||
|
||||
possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess);
|
||||
possibleProcess = Math.min((int)(getEnergy()/recipe.extraEnergy), possibleProcess);
|
||||
|
||||
return Math.min(fluidTank.getFluidAmount()/recipe.recipeInput.ingredient.amount, possibleProcess);
|
||||
}
|
||||
|
||||
public SeparatorRecipe getRecipe()
|
||||
{
|
||||
FluidInput input = getInput();
|
||||
|
||||
if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput()))
|
||||
{
|
||||
cachedRecipe = RecipeHandler.getElectrolyticSeparatorRecipe(getInput());
|
||||
}
|
||||
|
||||
return cachedRecipe;
|
||||
}
|
||||
|
||||
|
@ -222,9 +251,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
return recipe != null && recipe.canOperate(fluidTank, leftTank, rightTank);
|
||||
}
|
||||
|
||||
public void operate(SeparatorRecipe recipe)
|
||||
public int operate(SeparatorRecipe recipe)
|
||||
{
|
||||
recipe.operate(fluidTank, leftTank, rightTank);
|
||||
int operations = getUpgradedUsage(recipe);
|
||||
|
||||
recipe.operate(fluidTank, leftTank, rightTank, operations);
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
public boolean canFill(ChemicalPairOutput gases)
|
||||
|
@ -581,7 +614,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid);
|
||||
return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -593,7 +626,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid()))
|
||||
if(Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid()))
|
||||
{
|
||||
return fluidTank.fill(resource, doFill);
|
||||
}
|
||||
|
@ -659,4 +692,22 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
{
|
||||
isActive = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue