2014-01-08 02:55:50 +01:00
|
|
|
package mekanism.common.tile;
|
2013-01-23 21:42:45 +01:00
|
|
|
|
2013-02-22 04:03:54 +01:00
|
|
|
import java.util.Map;
|
2013-01-23 21:42:45 +01:00
|
|
|
|
2014-08-01 01:58:12 +02:00
|
|
|
import mekanism.api.MekanismConfig.usage;
|
2013-11-27 02:11:26 +01:00
|
|
|
import mekanism.api.gas.Gas;
|
|
|
|
import mekanism.api.gas.GasRegistry;
|
|
|
|
import mekanism.api.gas.GasStack;
|
2013-11-30 18:37:47 +01:00
|
|
|
import mekanism.api.gas.GasTransmission;
|
2013-12-12 22:54:55 +01:00
|
|
|
import mekanism.api.gas.IGasHandler;
|
2013-11-27 02:11:26 +01:00
|
|
|
import mekanism.api.gas.IGasItem;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.api.gas.ITubeConnection;
|
2014-08-01 01:58:12 +02:00
|
|
|
import mekanism.common.MekanismBlocks;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.block.BlockMachine.MachineType;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.recipe.RecipeHandler.Recipe;
|
2014-09-03 20:00:03 +02:00
|
|
|
|
2014-05-29 20:01:43 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.init.Items;
|
2013-11-23 20:36:50 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-04-20 04:44:06 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-01-23 21:42:45 +01:00
|
|
|
|
2013-12-12 22:54:55 +01:00
|
|
|
public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMachine implements IGasHandler, ITubeConnection
|
2013-01-23 21:42:45 +01:00
|
|
|
{
|
|
|
|
public TileEntityPurificationChamber()
|
|
|
|
{
|
2014-08-28 00:16:59 +02:00
|
|
|
super("purification", "PurificationChamber", usage.purificationChamberUsage, 1, 200, MachineType.PURIFICATION_CHAMBER.baseEnergy);
|
2013-01-23 21:42:45 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-01-23 21:42:45 +01:00
|
|
|
@Override
|
2013-02-22 04:03:54 +01:00
|
|
|
public Map getRecipes()
|
2013-01-23 21:42:45 +01:00
|
|
|
{
|
|
|
|
return Recipe.PURIFICATION_CHAMBER.get();
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-01-23 21:42:45 +01:00
|
|
|
@Override
|
2014-01-17 02:35:05 +01:00
|
|
|
public GasStack getItemGas(ItemStack itemstack)
|
2013-01-23 21:42:45 +01:00
|
|
|
{
|
2014-04-20 05:34:19 +02:00
|
|
|
if(itemstack.isItemEqual(new ItemStack(Items.flint))) return new GasStack(GasRegistry.getGas("oxygen"), 10);
|
2014-08-01 01:58:12 +02:00
|
|
|
if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
|
2014-01-17 02:35:05 +01:00
|
|
|
((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")) return new GasStack(GasRegistry.getGas("oxygen"), 1);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-17 02:35:05 +01:00
|
|
|
return null;
|
2013-01-30 13:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-10 04:33:25 +02:00
|
|
|
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer)
|
2013-01-30 13:53:36 +01:00
|
|
|
{
|
2013-11-27 02:11:26 +01:00
|
|
|
if(stack.getGas() == GasRegistry.getGas("oxygen"))
|
2013-01-30 13:53:36 +01:00
|
|
|
{
|
2014-08-10 04:33:25 +02:00
|
|
|
return gasTank.receive(stack, doTransfer);
|
2013-01-30 13:53:36 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
return 0;
|
2013-01-30 13:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-11-27 02:11:26 +01:00
|
|
|
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
2013-01-30 13:53:36 +01:00
|
|
|
{
|
2013-11-27 02:11:26 +01:00
|
|
|
return type == GasRegistry.getGas("oxygen");
|
2013-01-30 13:53:36 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-01-30 13:53:36 +01:00
|
|
|
@Override
|
|
|
|
public void handleSecondaryFuel()
|
|
|
|
{
|
2014-01-17 02:35:05 +01:00
|
|
|
if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem)
|
2013-01-30 13:53:36 +01:00
|
|
|
{
|
2014-01-17 02:35:05 +01:00
|
|
|
GasStack removed = GasTransmission.removeGas(inventory[1], GasRegistry.getGas("oxygen"), gasTank.getNeeded());
|
|
|
|
gasTank.receive(removed, true);
|
2013-12-24 22:58:14 +01:00
|
|
|
return;
|
2013-01-30 13:53:36 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-01-30 13:53:36 +01:00
|
|
|
super.handleSecondaryFuel();
|
|
|
|
}
|
2013-02-22 04:03:54 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canTubeConnect(ForgeDirection side)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-20 22:35:42 +01:00
|
|
|
@Override
|
|
|
|
public boolean isValidGas(Gas gas)
|
|
|
|
{
|
|
|
|
return gas == GasRegistry.getGas("oxygen");
|
|
|
|
}
|
2013-01-23 21:42:45 +01:00
|
|
|
}
|