Mekanism-tilera-Edition/common/mekanism/api/gas/GasStack.java
Aidan Brady dacc68e6c6 Gas API completely overhauled. Sorry @micdoodle8 :(
General cleanup, pressurized tubes are 40 times more efficient, a few enhancements, Miners balanced.
2013-11-26 20:11:26 -05:00

66 lines
1 KiB
Java

package mekanism.api.gas;
import net.minecraft.nbt.NBTTagCompound;
public class GasStack
{
private Gas type;
public int amount;
public GasStack(int id, int quantity)
{
type = GasRegistry.getGas(id);
amount = quantity;
}
public GasStack(Gas gas, int quantity)
{
type = gas;
amount = quantity;
}
private GasStack() {}
public Gas getGas()
{
return type;
}
public NBTTagCompound write(NBTTagCompound nbtTags)
{
type.write(nbtTags);
nbtTags.setInteger("amount", amount);
return nbtTags;
}
private void read(NBTTagCompound nbtTags)
{
type = Gas.readFromNBT(nbtTags);
amount = nbtTags.getInteger("amount");
}
public static GasStack readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())
{
return null;
}
GasStack stack = new GasStack();
stack.read(nbtTags);
return stack;
}
public GasStack copy()
{
return new GasStack(type, amount);
}
@Override
public String toString()
{
return "[" + type + ", " + amount + "]";
}
}