Skip to content

Commit

Permalink
Comparator output on seared tanks and Smeltery
Browse files Browse the repository at this point in the history
Unmerged 164accessory commits #932
  • Loading branch information
bonii-xx committed Aug 28, 2014
1 parent e488814 commit 5c78471
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java
Expand Up @@ -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);
}
}
28 changes: 28 additions & 0 deletions src/main/java/tconstruct/smeltery/blocks/SmelteryBlock.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
5 changes: 5 additions & 0 deletions src/main/java/tconstruct/smeltery/logic/LavaTankLogic.java
Expand Up @@ -183,4 +183,9 @@ public void updateEntity ()
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}

public int comparatorStrength()
{
return 15 * tank.getFluidAmount() / tank.getCapacity();
}
}
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 5c78471

Please sign in to comment.