Added Fluid Tank comparator support, fixed Gas Tank comparator support

This commit is contained in:
aidancbrady committed 2016-06-30 12:45:15 -04:00
1 parent 3b214376ba
commit 41ea222aab
3 files changed
+46

No files matched your search

@@ -27,6 +27,7 @@ import net.minecraft.entity.player.EntityPlayer;
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;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
@@ -60,6 +61,8 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
public boolean needsPacket;
public int currentRedstoneLevel;
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
public TileEntityFluidTank()
@@ -139,6 +142,14 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
activeEmit();
}
int newRedstoneLevel = getRedstoneLevel();
if(newRedstoneLevel != currentRedstoneLevel)
{
markDirty();
currentRedstoneLevel = newRedstoneLevel;
}
if(needsPacket)
{
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50));
@@ -353,6 +364,12 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
}
}
public int getRedstoneLevel()
{
double fractionFull = (float)fluidTank.getFluidAmount()/(float)fluidTank.getCapacity();
return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
}
public int getCurrentNeeded()
{
int needed = fluidTank.getCapacity()-fluidTank.getFluidAmount();