Add comparator support to the GasTank (#1829).

This commit is contained in:
jmongeon committed 2014-09-26 20:35:43 -04:00
1 parent f240f907c5
commit 5011ea1c70
2 files changed
+36

No files matched your search

@@ -219,6 +219,19 @@ public class BlockGasTank extends BlockContainer
return itemStack;
}
@Override
public boolean hasComparatorInputOverride()
{
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int par5)
{
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z);
return tileEntity.getRedstoneLevel();
}
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{
@@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl
@@ -42,6 +43,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
public Mode dumping;
public int currentGasAmount;
/** This machine's current RedstoneControl type. */
public RedstoneControl controlType;
@@ -90,6 +93,17 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
{
gasTank.draw(output, true);
}
if(!worldObj.isRemote)
{
int newGasAmount = gasTank.getStored();
if(newGasAmount != this.currentGasAmount)
{
markDirty();
this.currentGasAmount = newGasAmount;
}
}
}
@Override
@@ -265,6 +279,15 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
return true;
}
public int getRedstoneLevel()
{
int stored = gasTank.getStored();
if(stored == 0) return 0;
return MathHelper.floor_float((float)stored / (float)MAX_GAS * 14.0f + 1.0f);
}
@Override
public RedstoneControl getControlType()
{