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
|
|
|
|
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-04-18 03:34:19 +02:00
|
|
|
import mekanism.client.gui.GuiProgress.ProgressBar;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.Mekanism;
|
|
|
|
import mekanism.common.block.BlockMachine.MachineType;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.recipe.RecipeHandler.Recipe;
|
2013-11-23 20:36:50 +01:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
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-04-18 03:34:19 +02:00
|
|
|
super("PurificationChamber.ogg", "PurificationChamber", Mekanism.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);
|
2013-12-24 22:58:14 +01:00
|
|
|
if(itemstack.itemID == Mekanism.GasTank.blockID && ((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-03-08 02:00:25 +01:00
|
|
|
public int receiveGas(ForgeDirection side, GasStack stack)
|
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-03-08 02:00:25 +01:00
|
|
|
return gasTank.receive(stack, true);
|
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");
|
|
|
|
}
|
2014-04-18 03:34:19 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ProgressBar getProgressType()
|
|
|
|
{
|
|
|
|
return ProgressBar.RED;
|
|
|
|
}
|
2013-01-23 21:42:45 +01:00
|
|
|
}
|