mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Added Fluid Tank comparator support, fixed Gas Tank comparator support
This commit is contained in:
1 parent
3b214376ba
commit
41ea222aab
3 files changed
+46
No files matched your search
@@ -802,6 +802,25 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tileEntity instanceof TileEntityFluidTank)
|
||||
{
|
||||
return ((TileEntityFluidTank)tileEntity).getRedstoneLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity)
|
||||
{
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -52,6 +52,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
public GasMode dumping;
|
||||
|
||||
public int currentGasAmount;
|
||||
|
||||
public int currentRedstoneLevel;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
@@ -127,6 +129,14 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
}
|
||||
|
||||
currentGasAmount = newGasAmount;
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
|
||||
if(newRedstoneLevel != currentRedstoneLevel)
|
||||
{
|
||||
markDirty();
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user