2014-01-26 23:12:03 +01:00
|
|
|
package mekanism.common.tile;
|
|
|
|
|
2015-02-27 02:50:02 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import mekanism.api.Coord4D;
|
2014-08-01 01:58:12 +02:00
|
|
|
import mekanism.api.MekanismConfig.usage;
|
2014-09-03 20:00:03 +02:00
|
|
|
import mekanism.api.Range4D;
|
2014-01-29 00:47:06 +01:00
|
|
|
import mekanism.api.gas.Gas;
|
2014-01-28 22:49:49 +01:00
|
|
|
import mekanism.api.gas.GasRegistry;
|
|
|
|
import mekanism.api.gas.GasStack;
|
|
|
|
import mekanism.api.gas.GasTank;
|
|
|
|
import mekanism.api.gas.GasTransmission;
|
|
|
|
import mekanism.api.gas.IGasHandler;
|
|
|
|
import mekanism.api.gas.IGasItem;
|
|
|
|
import mekanism.api.gas.ITubeConnection;
|
|
|
|
import mekanism.common.Mekanism;
|
2014-09-06 22:14:49 +02:00
|
|
|
import mekanism.common.Upgrade;
|
2015-02-27 02:50:02 +01:00
|
|
|
import mekanism.common.base.IDropperHandler;
|
2014-08-10 04:20:49 +02:00
|
|
|
import mekanism.common.base.IRedstoneControl;
|
|
|
|
import mekanism.common.base.ISustainedData;
|
|
|
|
import mekanism.common.base.IUpgradeTile;
|
2014-01-26 23:12:03 +01:00
|
|
|
import mekanism.common.block.BlockMachine.MachineType;
|
2014-06-11 11:57:49 +02:00
|
|
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
2014-01-28 22:49:49 +01:00
|
|
|
import mekanism.common.recipe.RecipeHandler;
|
2014-09-05 05:20:12 +02:00
|
|
|
import mekanism.common.recipe.inputs.ItemStackInput;
|
|
|
|
import mekanism.common.recipe.machines.DissolutionRecipe;
|
2014-07-11 06:42:06 +02:00
|
|
|
import mekanism.common.tile.component.TileComponentUpgrade;
|
2014-01-28 22:49:49 +01:00
|
|
|
import mekanism.common.util.ChargeUtils;
|
|
|
|
import mekanism.common.util.InventoryUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
2015-02-19 22:12:28 +01:00
|
|
|
import mekanism.common.util.StatUtils;
|
2014-01-26 23:12:03 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-01-28 22:49:49 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-04-20 04:44:06 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-09-03 20:00:03 +02:00
|
|
|
|
2015-02-27 02:50:02 +01:00
|
|
|
public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IGasHandler, IUpgradeTile, ISustainedData, IDropperHandler
|
2014-01-26 23:12:03 +01:00
|
|
|
{
|
2014-01-28 22:49:49 +01:00
|
|
|
public GasTank injectTank = new GasTank(MAX_GAS);
|
|
|
|
public GasTank outputTank = new GasTank(MAX_GAS);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public static final int MAX_GAS = 10000;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
public static final int BASE_INJECT_USAGE = 1;
|
|
|
|
|
|
|
|
public int injectUsage = 1;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public int updateDelay;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2015-02-19 23:17:28 +01:00
|
|
|
public int gasOutput = 256;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public boolean isActive;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public boolean clientActive;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public double prevEnergy;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public int operatingTicks = 0;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
public int BASE_TICKS_REQUIRED = 100;
|
|
|
|
|
|
|
|
public int ticksRequired = 100;
|
|
|
|
|
|
|
|
public final double BASE_ENERGY_USAGE = usage.chemicalDissolutionChamberUsage;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
public double energyUsage = usage.chemicalDissolutionChamberUsage;
|
|
|
|
|
|
|
|
public DissolutionRecipe cachedRecipe;
|
2014-07-11 06:42:06 +02:00
|
|
|
|
2014-08-16 18:22:07 +02:00
|
|
|
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-26 23:12:03 +01:00
|
|
|
public TileEntityChemicalDissolutionChamber()
|
|
|
|
{
|
2014-08-28 00:16:59 +02:00
|
|
|
super("machine.dissolution", "ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy);
|
2014-07-11 06:42:06 +02:00
|
|
|
inventory = new ItemStack[5];
|
2014-01-26 23:12:03 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public void onUpdate()
|
|
|
|
{
|
2014-08-28 00:55:35 +02:00
|
|
|
if(worldObj.isRemote && updateDelay > 0)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-08-28 00:55:35 +02:00
|
|
|
updateDelay--;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-08-28 00:55:35 +02:00
|
|
|
if(updateDelay == 0 && clientActive != isActive)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-08-28 00:55:35 +02:00
|
|
|
isActive = clientActive;
|
|
|
|
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(!worldObj.isRemote)
|
|
|
|
{
|
2014-09-05 05:20:12 +02:00
|
|
|
DissolutionRecipe recipe = getRecipe();
|
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(updateDelay > 0)
|
|
|
|
{
|
|
|
|
updateDelay--;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(updateDelay == 0 && clientActive != isActive)
|
|
|
|
{
|
2014-08-08 04:48:35 +02:00
|
|
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
ChargeUtils.discharge(3, this);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
if(inventory[0] != null && injectTank.getNeeded() > 0)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-01-29 00:47:06 +01:00
|
|
|
injectTank.receive(GasTransmission.removeGas(inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true);
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(inventory[2] != null && outputTank.getGas() != null)
|
|
|
|
{
|
|
|
|
outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-02-23 20:41:42 +01:00
|
|
|
boolean changed = false;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsage && MekanismUtils.canFunction(this))
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
setActive(true);
|
2014-09-06 22:14:49 +02:00
|
|
|
setEnergy(getEnergy() - energyUsage);
|
2014-09-05 05:20:12 +02:00
|
|
|
minorOperate();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
if((operatingTicks+1) < ticksRequired)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
operatingTicks++;
|
|
|
|
}
|
|
|
|
else {
|
2014-09-05 05:20:12 +02:00
|
|
|
operate(recipe);
|
2014-01-28 22:49:49 +01:00
|
|
|
operatingTicks = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(prevEnergy >= getEnergy())
|
|
|
|
{
|
2014-02-23 20:41:42 +01:00
|
|
|
changed = true;
|
2014-01-28 22:49:49 +01:00
|
|
|
setActive(false);
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-05 05:20:12 +02:00
|
|
|
if(changed && !canOperate(recipe))
|
2014-02-23 20:41:42 +01:00
|
|
|
{
|
|
|
|
operatingTicks = 0;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
prevEnergy = getEnergy();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(outputTank.getGas() != null)
|
|
|
|
{
|
|
|
|
GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput));
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(tileEntity instanceof IGasHandler)
|
|
|
|
{
|
|
|
|
if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas()))
|
|
|
|
{
|
2014-08-10 04:33:25 +02:00
|
|
|
outputTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend, true), true);
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
|
|
|
|
{
|
2014-01-29 00:47:06 +01:00
|
|
|
if(slotID == 1)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-09-05 05:20:12 +02:00
|
|
|
return RecipeHandler.getDissolutionRecipe(new ItemStackInput(itemstack)) != null;
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
2014-01-29 00:47:06 +01:00
|
|
|
else if(slotID == 3)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
return ChargeUtils.canBeDischarged(itemstack);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
|
|
|
|
{
|
|
|
|
if(slotID == 2)
|
|
|
|
{
|
|
|
|
return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public int[] getAccessibleSlotsFromSide(int side)
|
|
|
|
{
|
2014-02-15 23:10:13 +01:00
|
|
|
if(side == MekanismUtils.getLeft(facing).ordinal() || side == 1)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-01-29 00:47:06 +01:00
|
|
|
return new int[] {1};
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
2014-02-15 23:10:13 +01:00
|
|
|
else if(side == 0)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-01-29 00:47:06 +01:00
|
|
|
return new int[] {0};
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
|
|
|
else if(side == MekanismUtils.getRight(facing).ordinal())
|
|
|
|
{
|
|
|
|
return new int[] {2};
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
return InventoryUtils.EMPTY;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-18 03:34:19 +02:00
|
|
|
public double getScaledProgress()
|
|
|
|
{
|
2015-02-18 03:27:35 +01:00
|
|
|
return ((double)operatingTicks) / ((double)ticksRequired);
|
2014-04-18 03:34:19 +02:00
|
|
|
}
|
|
|
|
|
2014-09-05 05:20:12 +02:00
|
|
|
public DissolutionRecipe getRecipe()
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
2014-09-06 22:14:49 +02:00
|
|
|
ItemStackInput input = getInput();
|
2015-02-18 03:27:35 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput()))
|
|
|
|
{
|
|
|
|
cachedRecipe = RecipeHandler.getDissolutionRecipe(getInput());
|
|
|
|
}
|
2015-02-18 03:27:35 +01:00
|
|
|
|
2014-09-06 22:14:49 +02:00
|
|
|
return cachedRecipe;
|
2014-09-05 05:20:12 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-05 05:20:12 +02:00
|
|
|
public ItemStackInput getInput()
|
|
|
|
{
|
|
|
|
return new ItemStackInput(inventory[1]);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-05 05:20:12 +02:00
|
|
|
public boolean canOperate(DissolutionRecipe recipe)
|
|
|
|
{
|
|
|
|
return recipe != null && recipe.canOperate(inventory, outputTank);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-05 05:20:12 +02:00
|
|
|
public void operate(DissolutionRecipe recipe)
|
|
|
|
{
|
|
|
|
recipe.operate(inventory, outputTank);
|
|
|
|
|
|
|
|
markDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void minorOperate()
|
|
|
|
{
|
2014-09-06 22:14:49 +02:00
|
|
|
injectTank.draw(injectUsage, true);
|
2014-01-28 22:49:49 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
2014-06-02 16:52:13 +02:00
|
|
|
public void handlePacketData(ByteBuf dataStream)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
super.handlePacketData(dataStream);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
isActive = dataStream.readBoolean();
|
|
|
|
controlType = RedstoneControl.values()[dataStream.readInt()];
|
|
|
|
operatingTicks = dataStream.readInt();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(dataStream.readBoolean())
|
|
|
|
{
|
|
|
|
injectTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
injectTank.setGas(null);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(dataStream.readBoolean())
|
|
|
|
{
|
|
|
|
outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outputTank.setGas(null);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public ArrayList getNetworkedData(ArrayList data)
|
|
|
|
{
|
|
|
|
super.getNetworkedData(data);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
data.add(isActive);
|
|
|
|
data.add(controlType.ordinal());
|
|
|
|
data.add(operatingTicks);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(injectTank.getGas() != null)
|
|
|
|
{
|
|
|
|
data.add(true);
|
|
|
|
data.add(injectTank.getGas().getGas().getID());
|
|
|
|
data.add(injectTank.getStored());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data.add(false);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
if(outputTank.getGas() != null)
|
|
|
|
{
|
|
|
|
data.add(true);
|
|
|
|
data.add(outputTank.getGas().getGas().getID());
|
|
|
|
data.add(outputTank.getStored());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data.add(false);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
return data;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public void readFromNBT(NBTTagCompound nbtTags)
|
|
|
|
{
|
|
|
|
super.readFromNBT(nbtTags);
|
2014-01-28 22:49:49 +01:00
|
|
|
|
2014-03-08 02:00:25 +01:00
|
|
|
isActive = nbtTags.getBoolean("isActive");
|
|
|
|
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
|
|
|
operatingTicks = nbtTags.getInteger("operatingTicks");
|
|
|
|
injectTank.read(nbtTags.getCompoundTag("injectTank"));
|
|
|
|
outputTank.read(nbtTags.getCompoundTag("gasTank"));
|
|
|
|
}
|
2014-01-28 22:49:49 +01:00
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public void writeToNBT(NBTTagCompound nbtTags)
|
|
|
|
{
|
|
|
|
super.writeToNBT(nbtTags);
|
|
|
|
|
|
|
|
nbtTags.setBoolean("isActive", isActive);
|
|
|
|
nbtTags.setInteger("controlType", controlType.ordinal());
|
|
|
|
nbtTags.setInteger("operatingTicks", operatingTicks);
|
2014-04-20 05:34:19 +02:00
|
|
|
nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound()));
|
|
|
|
nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound()));
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
|
|
|
public boolean canSetFacing(int i)
|
|
|
|
{
|
|
|
|
return i != 0 && i != 1;
|
|
|
|
}
|
2014-07-11 06:42:06 +02:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public void setActive(boolean active)
|
|
|
|
{
|
|
|
|
isActive = active;
|
|
|
|
|
|
|
|
if(clientActive != active && updateDelay == 0)
|
|
|
|
{
|
2014-08-08 04:48:35 +02:00
|
|
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
2014-03-08 02:00:25 +01:00
|
|
|
|
|
|
|
updateDelay = 10;
|
|
|
|
clientActive = active;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean getActive()
|
|
|
|
{
|
|
|
|
return isActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderUpdate()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean lightUpdate()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-01-28 22:49:49 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canTubeConnect(ForgeDirection side)
|
|
|
|
{
|
|
|
|
return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-28 22:49:49 +01:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public RedstoneControl getControlType()
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
return controlType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public void setControlType(RedstoneControl type)
|
2014-01-28 22:49:49 +01:00
|
|
|
{
|
|
|
|
controlType = type;
|
|
|
|
MekanismUtils.saveChunk(this);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-09-16 03:26:29 +02:00
|
|
|
@Override
|
|
|
|
public boolean canPulse()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-29 00:47:06 +01:00
|
|
|
@Override
|
2014-08-10 04:33:25 +02:00
|
|
|
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer)
|
2014-01-29 00:47:06 +01:00
|
|
|
{
|
|
|
|
if(canReceiveGas(side, stack.getGas()))
|
|
|
|
{
|
2014-08-10 04:33:25 +02:00
|
|
|
return injectTank.receive(stack, doTransfer);
|
2014-01-29 00:47:06 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-29 00:47:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-10 04:33:25 +02:00
|
|
|
public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer)
|
2014-01-29 00:47:06 +01:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
|
|
|
{
|
|
|
|
return side == MekanismUtils.getLeft(facing) && type == GasRegistry.getGas("sulfuricAcid");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canDrawGas(ForgeDirection side, Gas type)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-11 06:42:06 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileComponentUpgrade getComponent()
|
|
|
|
{
|
|
|
|
return upgradeComponent;
|
|
|
|
}
|
2014-07-27 00:44:24 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeSustainedData(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
if(injectTank.getGas() != null)
|
|
|
|
{
|
|
|
|
itemStack.stackTagCompound.setTag("injectTank", injectTank.getGas().write(new NBTTagCompound()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(outputTank.getGas() != null)
|
|
|
|
{
|
|
|
|
itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readSustainedData(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
injectTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("injectTank")));
|
|
|
|
outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")));
|
|
|
|
}
|
2014-09-06 22:14:49 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void recalculateUpgradables(Upgrade upgrade)
|
|
|
|
{
|
|
|
|
super.recalculateUpgradables(upgrade);
|
|
|
|
|
|
|
|
switch(upgrade)
|
|
|
|
{
|
|
|
|
case SPEED:
|
2015-02-19 23:17:28 +01:00
|
|
|
injectUsage = StatUtils.inversePoisson(MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_INJECT_USAGE));
|
2014-09-06 22:14:49 +02:00
|
|
|
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
|
|
|
case ENERGY:
|
|
|
|
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
2015-02-18 03:27:35 +01:00
|
|
|
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
2014-09-06 22:14:49 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-27 02:50:02 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object[] getTanks()
|
|
|
|
{
|
|
|
|
return new Object[] {injectTank, outputTank};
|
|
|
|
}
|
2014-01-26 23:12:03 +01:00
|
|
|
}
|