diff --git a/src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java b/src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java index 8900ff4c6bb..ea3ec7391fb 100644 --- a/src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java +++ b/src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java @@ -323,4 +323,22 @@ public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase } } } + + //Comparator + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int comparatorSide) + { + return getTankLogic(world, x, y, z).comparatorStrength(); + } + + public static LavaTankLogic getTankLogic(IBlockAccess blockAccess, int par1, int par2, int par3) + { + return (LavaTankLogic)blockAccess.getTileEntity(par1, par2, par3); + } } \ No newline at end of file diff --git a/src/main/java/tconstruct/smeltery/blocks/SmelteryBlock.java b/src/main/java/tconstruct/smeltery/blocks/SmelteryBlock.java index f0f1d9b47a9..53d8d069030 100644 --- a/src/main/java/tconstruct/smeltery/blocks/SmelteryBlock.java +++ b/src/main/java/tconstruct/smeltery/blocks/SmelteryBlock.java @@ -13,6 +13,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -320,4 +321,31 @@ public void breakBlock (World world, int x, int y, int z, Block blockID, int met } super.breakBlock(world, x, y, z, blockID, meta); } + + //Comparator + + public boolean hasComparatorInputOverride () + { + return true; + } + + public int getComparatorInputOverride (World world, int x, int y, int z, int comparatorSide) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) + { + if (PHConstruct.newSmeltery) + return 0; + else + return Container.calcRedstoneFromInventory(((SmelteryLogic) world.getTileEntity(x, y, z))); + } + if (meta == 1) + { + if (PHConstruct.newSmeltery) + return 0; + else + return ((SmelteryDrainLogic) world.getTileEntity(x, y, z)).comparatorStrength(); + } + return 0; + } } \ No newline at end of file diff --git a/src/main/java/tconstruct/smeltery/logic/LavaTankLogic.java b/src/main/java/tconstruct/smeltery/logic/LavaTankLogic.java index 2d885dc16d7..990b97d540e 100644 --- a/src/main/java/tconstruct/smeltery/logic/LavaTankLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/LavaTankLogic.java @@ -183,4 +183,9 @@ public void updateEntity () worldObj.func_147479_m(xCoord, yCoord, zCoord); } } + + public int comparatorStrength() + { + return 15 * tank.getFluidAmount() / tank.getCapacity(); + } } \ No newline at end of file diff --git a/src/main/java/tconstruct/smeltery/logic/SmelteryDrainLogic.java b/src/main/java/tconstruct/smeltery/logic/SmelteryDrainLogic.java index 91b71af2657..0e75836d3ed 100644 --- a/src/main/java/tconstruct/smeltery/logic/SmelteryDrainLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/SmelteryDrainLogic.java @@ -2,6 +2,7 @@ import mantle.blocks.abstracts.MultiServantLogic; import mantle.blocks.iface.IFacingLogic; +import mantle.world.CoordTuple; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -185,4 +186,11 @@ public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) readFromNBT(packet.func_148857_g()); worldObj.func_147479_m(xCoord, yCoord, zCoord); } + + public int comparatorStrength() + { + CoordTuple master = this.getMasterPosition(); + SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity(master.x, master.y, master.z); + return 15 * smeltery.currentLiquid / smeltery.maxLiquid; + } } \ No newline at end of file