diff --git a/src/main/java/tconstruct/blocks/CastingChannelBlock.java b/src/main/java/tconstruct/blocks/CastingChannelBlock.java index 7e89fbf8..670be47a 100644 --- a/src/main/java/tconstruct/blocks/CastingChannelBlock.java +++ b/src/main/java/tconstruct/blocks/CastingChannelBlock.java @@ -30,78 +30,77 @@ public class CastingChannelBlock extends BlockContainer } @Override - public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) - { - if (!world.isRemote) - { - CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); - if (player.isSneaking()) - { - } - else - { - //int amount = 0; - //if (tile.getFluid() != null) - //amount = tile.getLiquidAmount(); - //player.addChatMessage("LiquidAmount: " + amount); - tile.setActive(true); - } - } + public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + ItemStack stack = player.getCurrentEquippedItem(); + CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); + /* + * Debugging + System.out.println("Side: "+side); + System.out.println("hitting: "+hitX+", "+hitY+", "+hitZ); + String s = "LiquidAmount "+(world.isRemote?"client side: ":"server side: "); + int amount = 0; + if (tile.getTankInfo(null)[0].fluid != null) + amount = tile.getTankInfo(null)[0].fluid.amount; + if(world.isRemote) + player.addChatMessage("-----"); + player.addChatMessage(s + amount); + */ + if(stack==null) + tile.changeOutputs(player, side, hitX, hitY, hitZ); + return true; + } - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.itemID == this.blockID) - return false; - return true; - } + @Override + public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + { + CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); + float minX = 0.3125F; + float maxX = 0.6875F; + float minZ = 0.3125F; + float maxZ = 0.6875F; + minZ = 0F; + maxZ = 1F; + minX = 0F; + maxX = 1F; + + this.setBlockBounds(minX, 0.375F, minZ, maxX, 0.625F, maxZ); + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } @Override - public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { - CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); - float minX = 0.3125F; - float maxX = 0.6875F; - float minZ = 0.3125F; - float maxZ = 0.6875F; - if (tile.hasTankConnected(ForgeDirection.NORTH)) - minZ = 0F; - if (tile.hasTankConnected(ForgeDirection.SOUTH)) - maxZ = 1F; - if (tile.hasTankConnected(ForgeDirection.WEST)) - minX = 0F; - if (tile.hasTankConnected(ForgeDirection.EAST)) - maxX = 1F; - - this.setBlockBounds(minX, 0.375F, minZ, maxX, 0.625F, maxZ); + return true; } - @Override - public boolean renderAsNormalBlock () - { - return false; - } + @Override + public int getRenderType () + { + return BlockRenderCastingChannel.renderID; + } - @Override - public boolean isOpaqueCube () - { - return false; - } + @Override + public void registerIcons (IconRegister iconRegister) + { + this.blockIcon = iconRegister.registerIcon("tinker:searedstone"); + } - @Override - public int getRenderType () - { - return BlockRenderCastingChannel.renderID; - } + @Override + public TileEntity createNewTileEntity (World var1) + { + return new CastingChannelLogic(); + } - @Override - public void registerIcons (IconRegister iconRegister) - { - this.blockIcon = iconRegister.registerIcon("tinker:searedstone"); - } - - @Override - public TileEntity createNewTileEntity (World var1) - { - return new CastingChannelLogic(); - } - -} \ No newline at end of file +} diff --git a/src/main/java/tconstruct/blocks/logic/CastingChannelLogic.java b/src/main/java/tconstruct/blocks/logic/CastingChannelLogic.java index 2ac85d10..f519c46a 100644 --- a/src/main/java/tconstruct/blocks/logic/CastingChannelLogic.java +++ b/src/main/java/tconstruct/blocks/logic/CastingChannelLogic.java @@ -1,21 +1,24 @@ package tconstruct.blocks.logic; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.NetHandler; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidEvent; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import net.minecraftforge.fluids.IFluidTank; import tconstruct.TConstruct; -import tconstruct.library.util.IActiveLogic; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -23,649 +26,558 @@ import cpw.mods.fml.relauncher.SideOnly; * @author BluSunrize */ -public class CastingChannelLogic extends TileEntity implements IFluidTank, IFluidHandler, IActiveLogic +public class CastingChannelLogic extends TileEntity implements IFluidHandler { - public final static int fillMax = TConstruct.ingotLiquidValue*5; - public final static int outputMax = TConstruct.ingotLiquidValue; - public FluidStack liquid; - public ForgeDirection lastProvider; - private int ticks = 0; - private int ticksLPReset = 0; - public int recentlyFilledDelay; - boolean pullingLiquids; + public final static int fillMax = TConstruct.ingotLiquidValue; + public final static int outputMax = TConstruct.ingotLiquidValue; + FluidTank internalTank = new FluidTank(fillMax); + HashMap subTanks = new HashMap(); + public ForgeDirection lastProvider; + public ArrayList validOutputs = new ArrayList(); + public int ticks = 0; + public int recentlyFilledDelay; - public CastingChannelLogic() - { - recentlyFilledDelay = 0; - lastProvider = ForgeDirection.UNKNOWN; - } + /* UNUSED + public CastingChannelMode mode = CastingChannelMode.SINGLEDRAIN; + */ - @Override - public void updateEntity () - { - if (this.worldObj.isRemote) - return; - ticks++; - ticksLPReset++; - if (!worldObj.isRemote) - { - if (this.pullingLiquids) - pullLiquids(); - } - //this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - if (ticks == 20) - { - if (recentlyFilledDelay != 0) - recentlyFilledDelay--; - if (recentlyFilledDelay == 0) - moveLiquidToTanks(); - ticks = 0; - } - if (ticksLPReset == 60) - { - this.lastProvider = ForgeDirection.UNKNOWN; - ticksLPReset = 0; - } - } + public CastingChannelLogic() + { + lastProvider = ForgeDirection.UNKNOWN; + validOutputs.add(ForgeDirection.DOWN); + validOutputs.add(ForgeDirection.NORTH); + validOutputs.add(ForgeDirection.SOUTH); + validOutputs.add(ForgeDirection.EAST); + validOutputs.add(ForgeDirection.WEST); - void pullLiquids () - { - if (pullLiquid(xCoord + 1, yCoord, zCoord, ForgeDirection.EAST) || pullLiquid(xCoord - 1, yCoord, zCoord, ForgeDirection.WEST) || pullLiquid(xCoord, yCoord, zCoord + 1, ForgeDirection.NORTH) - || pullLiquid(xCoord, yCoord, zCoord - 1, ForgeDirection.SOUTH)) - { + subTanks.put(ForgeDirection.NORTH, new FluidTank(TConstruct.ingotLiquidValue/4)); + subTanks.put(ForgeDirection.SOUTH, new FluidTank(TConstruct.ingotLiquidValue/4)); + subTanks.put(ForgeDirection.WEST, new FluidTank(TConstruct.ingotLiquidValue/4)); + subTanks.put(ForgeDirection.EAST, new FluidTank(TConstruct.ingotLiquidValue/4)); + } - } - else - { - pullingLiquids = false; - } - } + @Override + public void updateEntity () + { + ticks++; - boolean pullLiquid (int x, int y, int z, ForgeDirection direction) - { - TileEntity tank = worldObj.getBlockTileEntity(x, y, z); - if (tank instanceof IFluidHandler && !(tank instanceof CastingChannelLogic)) - { - FluidStack templiquid = ((IFluidHandler) tank).drain(direction, 3, false); - if (templiquid != null) - { - if (this.liquid == null) - { - if (templiquid.amount > fillMax) - templiquid.amount = fillMax; - this.liquid = ((IFluidHandler) tank).drain(direction, templiquid.amount, true); - return true; - } - else if (this.liquid.isFluidEqual(templiquid)) - { - if (templiquid.amount + this.liquid.amount > fillMax) - templiquid.amount = fillMax - this.liquid.amount; - liquid.amount += ((IFluidHandler) tank).drain(direction, templiquid.amount, true).amount; - return true; - } - } - } - return false; - } + boolean flagActiveFaucet = false; - private void moveLiquidToChannels () - { - if (this.liquid == null || this.liquid.amount <= 0) - { - return; - } - TileEntity tankXplus = null; - TileEntity tankXminus = null; - TileEntity tankZplus = null; - TileEntity tankZminus = null; - TileEntity tankYminus = null; - HashMap tankMap = this.getOutputs(); - if (tankMap.size() <= 0) - { - //TConstruct.logger.info("Nope, no connections to go to"); - return; - } - boolean yFilled = false; - if (tankMap.containsKey("yMinus")) - { - tankYminus = (TileEntity) tankMap.get("yMinus"); - FluidStack liquidToPush = this.drain(24, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankYminus).fill(ForgeDirection.UP, liquidToPush, true); - if (filled > 0) - { - yFilled = true; - this.drain(filled, true); - } - } - } + TileEntity possibleFaucet = worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord); + if(possibleFaucet!=null && possibleFaucet instanceof FaucetLogic) + flagActiveFaucet = ((FaucetLogic)possibleFaucet).active; - if (!yFilled) - { - int divisionSurplus = (this.liquid.amount % tankMap.size()); - int amountXp = (this.outputMax / tankMap.size()); - int amountXm = (this.outputMax / tankMap.size()); - int amountZp = (this.outputMax / tankMap.size()); - int amountZm = (this.outputMax / tankMap.size()); - if (divisionSurplus > 0) - amountXp++; - if (divisionSurplus > 1) - amountXm++; - if (divisionSurplus > 2) - amountZp++; + if(ticks == 6 && !flagActiveFaucet) + this.distributeFluids(); + if (ticks >= 12 && !flagActiveFaucet) + { + if (recentlyFilledDelay != 0) + recentlyFilledDelay--; + if (recentlyFilledDelay == 0 || lastProvider == ForgeDirection.UP) + this.outputFluids(); - if (tankMap.containsKey("xPlus")) - { - tankXplus = (TileEntity) tankMap.get("xPlus"); - FluidStack liquidToPush = this.drain(amountXp, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankXplus).fill(ForgeDirection.WEST, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("xMinus")) - { - tankXminus = (TileEntity) tankMap.get("xMinus"); - FluidStack liquidToPush = this.drain(amountXm, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankXminus).fill(ForgeDirection.EAST, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("zPlus")) - { - tankZplus = (TileEntity) tankMap.get("zPlus"); - FluidStack liquidToPush = this.drain(amountZp, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankZplus).fill(ForgeDirection.NORTH, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("zMinus")) - { - tankZminus = (TileEntity) tankMap.get("zMinus"); - FluidStack liquidToPush = this.drain(amountZm, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankZminus).fill(ForgeDirection.SOUTH, liquidToPush, true); - this.drain(filled, true); - } - } - } - } + ticks = 0; + } + } - private void moveLiquidToTanks () - { - if (this.liquid == null || this.liquid.amount <= 0) - { - return; - } - TileEntity tankXplus = null; - TileEntity tankXminus = null; - TileEntity tankZplus = null; - TileEntity tankZminus = null; - TileEntity tankYminus = null; - HashMap tankMap = this.getOutputs(); - if (tankMap.size() <= 0) - { - //TConstruct.logger.info("Nope, no connections to go to"); - return; - } - boolean yFilled = false; - if (tankMap.containsKey("yMinus")) - { - tankYminus = (TileEntity) tankMap.get("yMinus"); - FluidStack liquidToPush = this.drain(24, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankYminus).fill(ForgeDirection.UP, liquidToPush, true); - if (filled > 0) - { - yFilled = true; - this.drain(filled, true); - } - } - } + public void changeOutputs(EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + /* + * UNUSED + if(player.isSneaking()) + { - if (!yFilled) - { - int divisionSurplus = (this.liquid.amount % tankMap.size()); - int amountXp = (this.outputMax / tankMap.size()); - int amountXm = (this.outputMax / tankMap.size()); - int amountZp = (this.outputMax / tankMap.size()); - int amountZm = (this.outputMax / tankMap.size()); - if (divisionSurplus > 0) - amountXp++; - if (divisionSurplus > 1) - amountXm++; - if (divisionSurplus > 2) - amountZp++; + if(mode == null || mode == CastingChannelMode.SINGLEDRAIN) + mode = CastingChannelMode.CONTINUEDRAIN; + else + mode = CastingChannelMode.SINGLEDRAIN; - if (tankMap.containsKey("xPlus")) - { - tankXplus = (TileEntity) tankMap.get("xPlus"); - FluidStack liquidToPush = this.drain(amountXp, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankXplus).fill(ForgeDirection.WEST, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("xMinus")) - { - tankXminus = (TileEntity) tankMap.get("xMinus"); - FluidStack liquidToPush = this.drain(amountXm, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankXminus).fill(ForgeDirection.EAST, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("zPlus")) - { - tankZplus = (TileEntity) tankMap.get("zPlus"); - FluidStack liquidToPush = this.drain(amountZp, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankZplus).fill(ForgeDirection.NORTH, liquidToPush, true); - this.drain(filled, true); - } - } - if (tankMap.containsKey("zMinus")) - { - tankZminus = (TileEntity) tankMap.get("zMinus"); - FluidStack liquidToPush = this.drain(amountZm, false); - if ((liquidToPush != null) && (liquidToPush.amount > 0)) - { - int filled = ((IFluidHandler) tankZminus).fill(ForgeDirection.SOUTH, liquidToPush, true); - this.drain(filled, true); - } - } - } - } + String s = "Casting Channel Mode "+(worldObj.isRemote?"client side: ":"server side: "); + player.addChatMessage(s+mode.toString()); + return; + } + */ - @SideOnly(Side.CLIENT) - public float tankBelow () - { - TileEntity te = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord); - if (te instanceof CastingChannelLogic) - return -0.5f; - if (te instanceof LavaTankLogic) - return -1.0f; - if (te instanceof CastingBasinLogic) - return -0.75f; - if (te instanceof CastingTableLogic) - return -0.125f; - if (te instanceof IFluidHandler) - return 0f; + ForgeDirection toggle = ForgeDirection.UNKNOWN; + if(side == 0 || side == 1) + { + if(hitX>0.3125 && hitX<0.6875) + if(hitZ>0 && hitZ<0.3125) + toggle = ForgeDirection.NORTH; + if(hitX>0.3125 && hitX<0.6875) + if(hitZ>0.6875 && hitZ<1) + toggle = ForgeDirection.SOUTH; + if(hitZ>0.3125 && hitZ<0.6875) + if(hitX>0 && hitX<0.3125) + toggle = ForgeDirection.WEST; + if(hitZ>0.3125 && hitZ<0.6875) + if(hitX>0.6875 && hitX<1) + toggle = ForgeDirection.EAST; - return 0.5f; - } + if(side == 0) + if(hitX>0.3125 && hitX<0.6875) + if(hitZ>0.3125 && hitZ<0.6875) + toggle = ForgeDirection.DOWN; + } + else + { + if(side==2) + { + if(hitX>0 && hitX<0.3125) + toggle = ForgeDirection.WEST; + if(hitX>0.6875 && hitX<1) + toggle = ForgeDirection.EAST; + } + if(side==3) + { + if(hitX>0 && hitX<0.3125) + toggle = ForgeDirection.WEST; + if(hitX>0.6875 && hitX<1) + toggle = ForgeDirection.EAST; + } + if(side==4) + { + if(hitZ>0 && hitZ<0.3125) + toggle = ForgeDirection.NORTH; + if(hitZ>0.6875 && hitZ<1) + toggle = ForgeDirection.SOUTH; + } + if(side==5) + { + if(hitZ>0 && hitZ<0.3125) + toggle = ForgeDirection.NORTH; + if(hitZ>0.6875 && hitZ<1) + toggle = ForgeDirection.SOUTH; + } + } - public boolean hasChannelConnected (ForgeDirection dir) - { - switch (dir) - { - case DOWN: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord) instanceof CastingChannelLogic); - case NORTH: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1) instanceof CastingChannelLogic); - case SOUTH: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1) instanceof CastingChannelLogic); - case WEST: - return (this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord) instanceof CastingChannelLogic); - case EAST: - return (this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord) instanceof CastingChannelLogic); - default: - return false; - } - } + if(toggle != ForgeDirection.UNKNOWN && toggle != ForgeDirection.UP) + { + TileEntity tile = worldObj.getBlockTileEntity(xCoord+toggle.offsetX,yCoord+toggle.offsetY,zCoord+toggle.offsetZ); + if(tile instanceof IFluidHandler) + if(validOutputs.contains(toggle)) + { + validOutputs.remove(toggle); + if(tile instanceof CastingChannelLogic && toggle != ForgeDirection.DOWN) + ((CastingChannelLogic)tile).validOutputs.remove(toggle.getOpposite()); + } + else + { + validOutputs.add(toggle); + if(tile instanceof CastingChannelLogic && toggle != ForgeDirection.DOWN) + if(! ((CastingChannelLogic)tile).validOutputs.contains(toggle.getOpposite()) ) + ((CastingChannelLogic)tile).validOutputs.add(toggle.getOpposite()); + } - public boolean hasTankConnected (ForgeDirection dir) - { - switch (dir) - { - case DOWN: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord) instanceof IFluidHandler); - case NORTH: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1) instanceof IFluidHandler); - case SOUTH: - return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1) instanceof IFluidHandler); - case WEST: - return (this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord) instanceof IFluidHandler); - case EAST: - return (this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord) instanceof IFluidHandler); - default: - return false; - } - } + } + this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } - private HashMap getOutputs () - { - HashMap map = new HashMap(); - TileEntity tankXplus = this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord); - TileEntity tankXminus = this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord); - TileEntity tankZplus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1); - TileEntity tankZminus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1); - TileEntity tankYminus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord); + private void distributeFluids() + { + /* DEBUG + boolean printDebugLog = false; + ArrayList debugLog = new ArrayList(); + */ + //Move Fluid to Output Tanks + Set connected = this.getOutputs().keySet(); - if (this.pullingLiquids) - { - if (this.hasChannelConnected(ForgeDirection.EAST) && (this.lastProvider != ForgeDirection.EAST)) - { - map.put("xPlus", tankXplus); - } - if (this.hasChannelConnected(ForgeDirection.WEST) && (this.lastProvider != ForgeDirection.WEST)) - { - map.put("xMinus", tankXminus); - } - if (this.hasChannelConnected(ForgeDirection.SOUTH) && (this.lastProvider != ForgeDirection.SOUTH)) - { - map.put("zPlus", tankZplus); - } - if (this.hasChannelConnected(ForgeDirection.NORTH) && (this.lastProvider != ForgeDirection.NORTH)) - { - map.put("zMinus", tankZminus); - } - if (this.hasChannelConnected(ForgeDirection.DOWN) && (this.lastProvider != ForgeDirection.DOWN)) - { - map.put("yMinus", tankYminus); - } - } - else - { - if (this.hasTankConnected(ForgeDirection.EAST) && (this.lastProvider != ForgeDirection.EAST)) - { - map.put("xPlus", tankXplus); - } - if (this.hasTankConnected(ForgeDirection.WEST) && (this.lastProvider != ForgeDirection.WEST)) - { - map.put("xMinus", tankXminus); - } - if (this.hasTankConnected(ForgeDirection.SOUTH) && (this.lastProvider != ForgeDirection.SOUTH)) - { - map.put("zPlus", tankZplus); - } - if (this.hasTankConnected(ForgeDirection.NORTH) && (this.lastProvider != ForgeDirection.NORTH)) - { - map.put("zMinus", tankZminus); - } - if (this.hasTankConnected(ForgeDirection.DOWN) && (this.lastProvider != ForgeDirection.DOWN)) - { - map.put("yMinus", tankYminus); - } - } + if(connected.contains(ForgeDirection.DOWN)) + connected.remove(ForgeDirection.DOWN); + if(connected.contains(lastProvider)) + connected.remove(lastProvider); - return map; - } + int output = Math.min(internalTank.getFluidAmount(), 12); + int connectedAmount = connected.size(); + if(connectedAmount < 1)connectedAmount = 1; + int scaledAmount = output/connectedAmount; - public int fill (FluidStack stack, boolean doFill) - { - if (stack == null) - { - return 0; - } - if (this.liquid == null) - { - FluidStack transfered = stack.copy(); + for(ForgeDirection dirOut: connected) + { + if(this.internalTank.getFluid() == null) + break; - if (transfered.amount > this.fillMax) - { - transfered.amount = this.fillMax; - } + /* DEBUG + debugLog.add("Moving to "+dirOut+"ern SubTank"); + */ + FluidStack tempFS = new FluidStack(internalTank.getFluid().getFluid(), scaledAmount); + int fit = subTanks.get(dirOut).fill(tempFS, false); + /* DEBUG + debugLog.add("SubTank will accept "+fit+"mb"); + */ + if(fit > 0) + fit = internalTank.drain(fit, true).amount; + /* DEBUG + debugLog.add("Internal Tank was drained by "+fit+"mb"); + */ + tempFS.amount = fit; + fit = subTanks.get(dirOut).fill(tempFS, true); + /* DEBUG + debugLog.add("SubTank was filled by "+fit+"mb"); + if(fit > 0) + printDebugLog = true; + debugLog.add("Internal Tank now contains: "+internalTank.getFluidAmount()+"mb"); + debugLog.add("SubTank now contains: "+subTanks.get(dirOut).getFluidAmount()+"mb"); + */ + this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + /* DEBUG + if(printDebugLog) + { + for(String s: debugLog) + System.out.println(s); + debugLog.clear(); + } + printDebugLog = false; + */ - if (doFill) - { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - this.liquid = transfered; - } - recentlyFilledDelay = 2; - if (this.lastProvider == ForgeDirection.UP) - recentlyFilledDelay = 3; - return transfered.amount; - } + //Get Fluid from most recent InputTank + FluidTank inputTank = subTanks.get(lastProvider); + if(inputTank != null && inputTank.getFluid() != null) //Tank can be null if input was received from top + { + /* DEBUG + debugLog.add("Importing from "+lastProvider+"ern SubTank"); + */ + FluidStack tempFS = new FluidStack(inputTank.getFluid().getFluid(), Math.min(inputTank.getFluidAmount(), 12)); + int fit = internalTank.fill(tempFS, false); + /* DEBUG + debugLog.add("Internal Tank will accept "+fit+"mb"); + */ + if(fit > 0) + fit = inputTank.drain(fit, true).amount; + /* DEBUG + debugLog.add("Import Tank was drained by "+fit+"mb"); + */ + tempFS.amount = fit; + fit = internalTank.fill(tempFS, true); + /* DEBUG + debugLog.add("Internal Tank was filled by "+fit+"mb"); + if(fit > 0) + printDebugLog = true; + debugLog.add("Internal Tank now contains: "+internalTank.getFluidAmount()+"mb"); + debugLog.add("SubTank now contains: "+inputTank.getFluidAmount()+"mb"); + */ - if (stack.isFluidEqual(this.liquid)) - { - if (stack.amount + this.liquid.amount >= this.fillMax) - { - int spaceInTank = this.fillMax - this.liquid.amount; - if ((doFill) && (spaceInTank > 0)) - { - this.liquid.amount = this.fillMax; - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - return spaceInTank; - } + this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + /* DEBUG + if(printDebugLog) + { + for(String s: debugLog) + System.out.println(s); + debugLog.clear(); + } + */ + } - if (doFill) - { - this.liquid.amount += stack.amount; - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - return stack.amount; - } + private void outputFluids() + { + /* DEBUG + boolean printDebugLog = false; + ArrayList debugLog = new ArrayList(); + */ - return 0; - } + HashMap connected = this.getOutputs(); + if(connected.containsKey(lastProvider)) + connected.remove(lastProvider); + if(connected.containsKey(ForgeDirection.DOWN) && this.internalTank.getFluid() != null) // Prioritizes FluidHandlers below + { + int output = Math.min(internalTank.getFluid().amount, 12); + FluidStack tempFS = new FluidStack(internalTank.getFluid().getFluid(), output); + int fittingBelow = ((IFluidHandler)connected.get(ForgeDirection.DOWN)).fill(ForgeDirection.UP, tempFS, false); + if(fittingBelow > 0) + fittingBelow = this.drain(ForgeDirection.DOWN, fittingBelow, true).amount; + tempFS.amount = fittingBelow; + fittingBelow = ((IFluidHandler)connected.get(ForgeDirection.DOWN)).fill(ForgeDirection.UP, tempFS, true); - @Override - public int fill (ForgeDirection from, FluidStack resource, boolean doFill) - { - this.lastProvider = from; - ticksLPReset = 0; - int filled = fill(resource, doFill); - if (from == ForgeDirection.UP) - moveLiquidToTanks(); - return filled; - } + connected.remove(ForgeDirection.DOWN); + } + if(connected.size() != 0) + { + for(ForgeDirection dir:connected.keySet()) //Iterates to connected FluidHandlers + { + if(subTanks.get(dir)!=null && subTanks.get(dir).getFluid() != null) + { + /* DEBUG + debugLog.add("Exporting from "+dir+"ern SubTank"); + */ + FluidStack tempFS = new FluidStack(subTanks.get(dir).getFluid().getFluid(), Math.min(subTanks.get(dir).getFluidAmount(),12)); + int fit = ((IFluidHandler)connected.get(dir)).fill(dir.getOpposite(), tempFS, false); + /* DEBUG + debugLog.add("New Channel will accept "+fit+"mb"); + */ + if(fit > 0) + fit = this.drain(dir, fit, true).amount; + /* DEBUG + debugLog.add("OldSubTank was drained by "+fit+"mb"); + */ + tempFS.amount = fit; + fit = ((IFluidHandler)connected.get(dir)).fill(dir.getOpposite(), tempFS, true); + /* DEBUG + debugLog.add("New Channel was filled by "+fit+"mb"); - public FluidStack drain (int maxDrain, boolean doDrain) - { - if ((this.liquid == null)) - { - return null; - } - if (this.liquid.amount <= 0) - { - return null; - } - int toDrain = maxDrain; - if (this.liquid.amount < toDrain) - { - toDrain = this.liquid.amount; - } - if (doDrain) - { - this.liquid.amount -= toDrain; - } + debugLog.add("OldSubTank now contains: "+drain(dir, 100000, false).amount+"mb"); + if(fit > 0) + printDebugLog = true; + */ + } + /* DEBUG + for(String s: debugLog) + System.out.println(s); + debugLog.clear(); + */ + } + } + } - FluidStack drained = new FluidStack(liquid.fluidID, toDrain); + @SideOnly(Side.CLIENT) + public float tankBelow () + { + TileEntity te = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord); + if (te instanceof CastingChannelLogic) + return -0.5f; + if (te instanceof LavaTankLogic) + return -1.0f; + if (te instanceof CastingBasinLogic) + return -0.75f; + if (te instanceof CastingTableLogic) + return -0.125f; + if (te instanceof IFluidHandler) + return 0f; - if (this.liquid.amount <= 0) - { - this.liquid = null; - } - if (doDrain) - { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this)); - } - return drained; - } + return 0.5f; + } - @Override - public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain) - { - return this.drain(maxDrain, doDrain); - } + public HashMap getOutputs () + { + HashMap map = new HashMap(); + for(ForgeDirection fd: this.validOutputs) + { + int tX = this.xCoord + fd.offsetX; + int tY = this.yCoord + fd.offsetY; + int tZ = this.zCoord + fd.offsetZ; + TileEntity tile = this.worldObj.getBlockTileEntity(tX,tY,tZ); - @Override - public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) - { - return this.drain(resource.amount, doDrain); - } + if(tile != null && tile instanceof IFluidHandler) + map.put(fd, tile); + } + return map; + } - @Override - public int getCapacity () - { - return this.fillMax; - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + if(doFill) + { + this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + this.lastProvider = from; + if(this.internalTank.getFluid() == null) + this.recentlyFilledDelay = 2; + } - public int getLiquidAmount () - { - return this.liquid.amount; - } + if(from == ForgeDirection.UP) + { + return this.internalTank.fill(resource, doFill); + } + else if(from == ForgeDirection.NORTH || from == ForgeDirection.SOUTH || from == ForgeDirection.WEST || from == ForgeDirection.EAST) + { + return this.subTanks.get(from).fill(resource, doFill); + } + return 0; + } - @Override - public void readFromNBT (NBTTagCompound tags) - { - super.readFromNBT(tags); - readCustomNBT(tags); - pullingLiquids = tags.getBoolean("PullingLiquids"); - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + { + return drain(from, resource.amount, doDrain); + } - public void readCustomNBT (NBTTagCompound tags) - { - if (tags.getBoolean("hasLiquid")) - { - this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid")); - } - else - this.liquid = null; - this.recentlyFilledDelay = tags.getInteger("recentlyFilledDelay"); - this.lastProvider = this.convertIntToFD(tags.getInteger("LastProvider")); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + //if(doDrain) + // this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + if(from == ForgeDirection.DOWN) + return this.internalTank.drain(maxDrain, doDrain); + else if(from == ForgeDirection.NORTH || from == ForgeDirection.SOUTH || from == ForgeDirection.WEST || from == ForgeDirection.EAST) + { + return this.subTanks.get(from).drain(maxDrain, doDrain); + } - @Override - public void writeToNBT (NBTTagCompound tags) - { - super.writeToNBT(tags); - writeCustomNBT(tags); - tags.setBoolean("PullingLiquids", pullingLiquids); - } + return null; + } - public void writeCustomNBT (NBTTagCompound tags) - { - tags.setBoolean("hasLiquid", liquid != null); - if (liquid != null) - { - NBTTagCompound nbt = new NBTTagCompound(); - liquid.writeToNBT(nbt); - tags.setCompoundTag("Fluid", nbt); - } - tags.setInteger("LastProvider", this.convertFDToInt(this.lastProvider)); - tags.setInteger("recentlyFilledDelay", this.recentlyFilledDelay); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) + { + if(from == ForgeDirection.DOWN) + return false; + if(from == ForgeDirection.UP) + return true; + return validOutputs.contains(from); + } - @Override - public Packet getDescriptionPacket () - { - NBTTagCompound tag = new NBTTagCompound(); - writeCustomNBT(tag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) + { + if(from == ForgeDirection.UP) + return false; + return validOutputs.contains(from); + } - @Override - public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) - { - readCustomNBT(packet.data); - this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + if(from == null || from == ForgeDirection.UP || from == ForgeDirection.DOWN || from == ForgeDirection.UNKNOWN) + return new FluidTankInfo[]{new FluidTankInfo(internalTank)}; + else + return new FluidTankInfo[]{new FluidTankInfo(subTanks.get(from))}; + } - public int convertFDToInt (ForgeDirection dir) - { - switch (dir) - { - case DOWN: - return 0; - case UP: - return 1; - case NORTH: - return 2; - case SOUTH: - return 3; - case WEST: - return 4; - case EAST: - return 5; - default: - return -1; - } - } + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } - public ForgeDirection convertIntToFD (int i) - { - switch (i) - { - case 0: - return ForgeDirection.DOWN; - case 1: - return ForgeDirection.UP; - case 2: - return ForgeDirection.NORTH; - case 3: - return ForgeDirection.SOUTH; - case 4: - return ForgeDirection.WEST; - case 5: - return ForgeDirection.EAST; - default: - return ForgeDirection.UNKNOWN; - } - } + public void readCustomNBT (NBTTagCompound tags) + { - @Override - public boolean getActive () - { - return pullingLiquids; - } + NBTTagCompound nbtTank = tags.getCompoundTag("internalTank"); + if(nbtTank != null) + internalTank.readFromNBT(nbtTank); - @Override - public void setActive (boolean flag) - { - //pullingLiquids = flag; - pullingLiquids = !pullingLiquids; - } + for(ForgeDirection fdSub: subTanks.keySet()) + { + NBTTagCompound nbtSubTank = tags.getCompoundTag("subTank_"+fdSub.name()); + if(nbtSubTank != null) + subTanks.get(fdSub).readFromNBT(nbtSubTank); + } - @Override - public boolean canFill (ForgeDirection from, Fluid fluid) - { - return liquid == null || (liquid.amount < fillMax); - } + int[] validFDs = tags.getIntArray("validOutputs"); + if(validFDs != null) + { + validOutputs = new ArrayList(); + for(int i: validFDs) + validOutputs.add(convertIntToFD(i)); + } + /* UNUSED + this.mode = CastingChannelMode.readFromNBT(tags); + */ + this.lastProvider = this.convertIntToFD(tags.getInteger("LastProvider")); + } - @Override - public boolean canDrain (ForgeDirection from, Fluid fluid) - { - return true; - } + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } - @Override - public FluidTankInfo[] getTankInfo (ForgeDirection from) - { - return new FluidTankInfo[] { getInfo() }; - } + public void writeCustomNBT (NBTTagCompound tags) + { + NBTTagCompound nbtTank = new NBTTagCompound(); + internalTank.writeToNBT(nbtTank); + tags.setCompoundTag("internalTank", nbtTank); + for(ForgeDirection fdSub: subTanks.keySet()) + { + NBTTagCompound nbtSubTank = new NBTTagCompound(); + subTanks.get(fdSub).writeToNBT(nbtSubTank); + tags.setCompoundTag("subTank_"+fdSub.name(), nbtSubTank); + } - @Override - public FluidStack getFluid () - { - return liquid == null ? null : liquid.copy(); - } + int[] validFDs = new int[validOutputs.size()]; + int it = 0; + for(ForgeDirection fd: validOutputs) + { + if(fd != null) + validFDs[it] = convertFDToInt(fd); + it++; + } + tags.setIntArray("validOutputs", validFDs); + /* UNUSED + CastingChannelMode.writeToNBT(tags, this.mode); + */ + tags.setInteger("LastProvider", this.convertFDToInt(this.lastProvider)); + } - @Override - public int getFluidAmount () - { - return liquid == null ? 0 : liquid.amount; - } + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeCustomNBT(tag); + return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readCustomNBT(packet.data); + this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); + } + + public int convertFDToInt (ForgeDirection dir) + { + switch (dir) + { + case DOWN: + return 0; + case UP: + return 1; + case NORTH: + return 2; + case SOUTH: + return 3; + case WEST: + return 4; + case EAST: + return 5; + default: + return -1; + } + } + + public ForgeDirection convertIntToFD (int i) + { + switch (i) + { + case 0: + return ForgeDirection.DOWN; + case 1: + return ForgeDirection.UP; + case 2: + return ForgeDirection.NORTH; + case 3: + return ForgeDirection.SOUTH; + case 4: + return ForgeDirection.WEST; + case 5: + return ForgeDirection.EAST; + default: + return ForgeDirection.UNKNOWN; + } + } + /* UNUSED + public enum CastingChannelMode + { + //Will not output while being filled by Faucet, hence only taking one ingots worth from the Smeltery + SINGLEDRAIN, + //Will keep the Faucet above it open + CONTINUEDRAIN; + + public static void writeToNBT(NBTTagCompound tag, CastingChannelMode mode) + { + if(mode == SINGLEDRAIN) + tag.setString("CastingChannelMode","single"); + else + tag.setString("CastingChannelMode","continue"); + } + public static CastingChannelMode readFromNBT(NBTTagCompound tag) + { + return (!tag.hasKey("CastingChannelMode") || tag.getString("CastingChannelMode")=="single") ? SINGLEDRAIN : CONTINUEDRAIN ; + } + } + */ - @Override - public FluidTankInfo getInfo () - { - FluidTankInfo info = new FluidTankInfo(this); - return info; - } } diff --git a/src/main/java/tconstruct/client/TControls.java b/src/main/java/tconstruct/client/TControls.java index 034f77a0..ff9f2c1b 100644 --- a/src/main/java/tconstruct/client/TControls.java +++ b/src/main/java/tconstruct/client/TControls.java @@ -97,7 +97,7 @@ public class TControls extends TKeyHandler { jumping = mc.thePlayer.isAirBorne; ItemStack shoes = mc.thePlayer.getCurrentArmor(0); - if (shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor")) + if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor")) { NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor"); midairJumps = shoeTag.getInteger("Double-Jump"); diff --git a/src/main/java/tconstruct/client/block/BlockRenderCastingChannel.java b/src/main/java/tconstruct/client/block/BlockRenderCastingChannel.java index 002bbdb5..e38be3fe 100644 --- a/src/main/java/tconstruct/client/block/BlockRenderCastingChannel.java +++ b/src/main/java/tconstruct/client/block/BlockRenderCastingChannel.java @@ -1,18 +1,19 @@ package tconstruct.client.block; +import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.item.Item; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; import org.lwjgl.opengl.GL11; import tconstruct.blocks.logic.CastingChannelLogic; - import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -22,348 +23,222 @@ import cpw.mods.fml.client.registry.RenderingRegistry; public class BlockRenderCastingChannel implements ISimpleBlockRenderingHandler { - public static int renderID = RenderingRegistry.getNextAvailableRenderId(); + public static int renderID = RenderingRegistry.getNextAvailableRenderId(); - @Override - public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) - { - //Floor - renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.6875D, 0.5D, 0.6875D); - this.renderStandardBlock(block, metadata, renderer); - //Channel Z- - renderer.setRenderBounds(0.3125D, 0.375D, 0D, 0.6875D, 0.5D, 0.3125D); - this.renderStandardBlock(block, metadata, renderer); - renderer.setRenderBounds(0.3125D, 0.5D, 0D, 0.375D, 0.625D, 0.3125D); - this.renderStandardBlock(block, metadata, renderer); - renderer.setRenderBounds(0.625D, 0.5D, 0D, 0.6875D, 0.625D, 0.3125D); - this.renderStandardBlock(block, metadata, renderer); - //Channel Z+ - renderer.setRenderBounds(0.3125D, 0.375D, 0.6875D, 0.6875D, 0.5D, 1D); - this.renderStandardBlock(block, metadata, renderer); - renderer.setRenderBounds(0.3125D, 0.5D, 0.6875D, 0.375D, 0.625D, 1D); - this.renderStandardBlock(block, metadata, renderer); - renderer.setRenderBounds(0.625D, 0.5D, 0.6875D, 0.6875D, 0.625D, 1D); - this.renderStandardBlock(block, metadata, renderer); - //Wall X- - renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.375D, 0.625D, 0.6875D); - this.renderStandardBlock(block, metadata, renderer); - //Wall X+ - renderer.setRenderBounds(0.625D, 0.375D, 0.3125D, 0.6875D, 0.625D, 0.6875D); - this.renderStandardBlock(block, metadata, renderer); - } + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + //Floor + renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.6875D, 0.5D, 0.6875D); + this.renderStandardBlock(block, metadata, renderer); + //Channel Z- + renderer.setRenderBounds(0.3125D, 0.375D, 0D, 0.6875D, 0.5D, 0.3125D); + this.renderStandardBlock(block, metadata, renderer); + renderer.setRenderBounds(0.3125D, 0.5D, 0D, 0.375D, 0.625D, 0.3125D); + this.renderStandardBlock(block, metadata, renderer); + renderer.setRenderBounds(0.625D, 0.5D, 0D, 0.6875D, 0.625D, 0.3125D); + this.renderStandardBlock(block, metadata, renderer); + //Channel Z+ + renderer.setRenderBounds(0.3125D, 0.375D, 0.6875D, 0.6875D, 0.5D, 1D); + this.renderStandardBlock(block, metadata, renderer); + renderer.setRenderBounds(0.3125D, 0.5D, 0.6875D, 0.375D, 0.625D, 1D); + this.renderStandardBlock(block, metadata, renderer); + renderer.setRenderBounds(0.625D, 0.5D, 0.6875D, 0.6875D, 0.625D, 1D); + this.renderStandardBlock(block, metadata, renderer); + //Wall X- + renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.375D, 0.625D, 0.6875D); + this.renderStandardBlock(block, metadata, renderer); + //Wall X+ + renderer.setRenderBounds(0.625D, 0.375D, 0.3125D, 0.6875D, 0.625D, 0.6875D); + this.renderStandardBlock(block, metadata, renderer); + } - @Override - public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) - { - if (modelID == renderID) - { - CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == renderID) + { + CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z); - if (!tile.hasTankConnected(ForgeDirection.DOWN))//CentrePiece, floor is removed if tank below is found - { - renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.6875D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } - else - //"Guiding Borders" when tank below is found - { - renderer.setRenderBounds(0.375D, 0.125D, 0.3125D, 0.625D, 0.5D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.375D, 0.125D, 0.625D, 0.625D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.3125D, 0.125D, 0.3125D, 0.375D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.125D, 0.3125D, 0.6875D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } - /*renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.375D, 0.625D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.3125D, 0.375D, 0.625D, 0.375D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.375D, 0.3125D, 0.6875D, 0.625D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.375D, 0.625D, 0.6875D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z);*/ - if (tile.hasTankConnected(ForgeDirection.NORTH))//Channel to Z- - { - renderer.setRenderBounds(0.3125D, 0.375D, 0D, 0.6875D, 0.5D, 0.3125D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.3125D, 0.5D, 0D, 0.375D, 0.625D, 0.3125D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.5D, 0D, 0.6875D, 0.625D, 0.3125D); - renderer.renderStandardBlock(block, x, y, z); - } - else - //Wall to Z- - { - renderer.setRenderBounds(0.375D, 0.5D, 0.3125D, 0.625D, 0.625D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - } + Set outputs = tile.getOutputs().keySet(); - if (tile.hasTankConnected(ForgeDirection.SOUTH))//Channel to Z+ - { - renderer.setRenderBounds(0.3125D, 0.375D, 0.6875D, 0.6875D, 0.5D, 1D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.3125D, 0.5D, 0.6875D, 0.375D, 0.625D, 1D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.5D, 0.6875D, 0.6875D, 0.625D, 1D); - renderer.renderStandardBlock(block, x, y, z); - } - else - //Wall to Z+ - { - renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } + if (!outputs.contains(ForgeDirection.DOWN))//CentrePiece, floor is removed if tank below is found + { + renderer.setRenderBounds(0.3125D, 0.375D, 0.3125D, 0.6875D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } + else + //"Guiding Borders" when tank below is found + { + renderer.setRenderBounds(0.375D, 0.125D, 0.3125D, 0.625D, 0.5D, 0.375D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.375D, 0.125D, 0.625D, 0.625D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.3125D, 0.125D, 0.3125D, 0.375D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625D, 0.125D, 0.3125D, 0.6875D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } + if (outputs.contains(ForgeDirection.NORTH))//Channel to Z- + { + renderer.setRenderBounds(0.3125D, 0.375D, 0D, 0.6875D, 0.5D, 0.3125D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.3125D, 0.5D, 0D, 0.375D, 0.625D, 0.3125D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625D, 0.5D, 0D, 0.6875D, 0.625D, 0.3125D); + renderer.renderStandardBlock(block, x, y, z); + } + else + //Wall to Z- + { + renderer.setRenderBounds(0.375D, 0.5D, 0.3125D, 0.625D, 0.625D, 0.375D); + renderer.renderStandardBlock(block, x, y, z); + } - if (tile.hasTankConnected(ForgeDirection.WEST))//Channel to X- - { - renderer.setRenderBounds(0D, 0.375D, 0.3125D, 0.3125D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0D, 0.5D, 0.3125D, 0.375D, 0.625D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0D, 0.5D, 0.625D, 0.375D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } - else - //Wall to X- - { - renderer.setRenderBounds(0.3125D, 0.5D, 0.3125D, 0.375D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } + if (outputs.contains(ForgeDirection.SOUTH))//Channel to Z+ + { + renderer.setRenderBounds(0.3125D, 0.375D, 0.6875D, 0.6875D, 0.5D, 1D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.3125D, 0.5D, 0.6875D, 0.375D, 0.625D, 1D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625D, 0.5D, 0.6875D, 0.6875D, 0.625D, 1D); + renderer.renderStandardBlock(block, x, y, z); + } + else + //Wall to Z+ + { + renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.625D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } - if (tile.hasTankConnected(ForgeDirection.EAST))//Channel to X+ - { - renderer.setRenderBounds(0.6875D, 0.375D, 0.3125D, 1D, 0.5D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.5D, 0.3125D, 1D, 0.625D, 0.375D); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0.625D, 0.5D, 0.625D, 1D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } - else - //Wall to X+ - { - renderer.setRenderBounds(0.625D, 0.5D, 0.3125D, 0.6875D, 0.625D, 0.6875D); - renderer.renderStandardBlock(block, x, y, z); - } + if (outputs.contains(ForgeDirection.WEST))//Channel to X- + { + renderer.setRenderBounds(0D, 0.375D, 0.3125D, 0.3125D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0D, 0.5D, 0.3125D, 0.375D, 0.625D, 0.375D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0D, 0.5D, 0.625D, 0.375D, 0.625D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } + else + //Wall to X- + { + renderer.setRenderBounds(0.3125D, 0.5D, 0.3125D, 0.375D, 0.625D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } - if (tile.liquid != null) - { - float height = tile.getLiquidAmount() / (tile.getCapacity() * 1.05F); - float j = tile.liquid.amount / tile.fillMax; - double startY = tile.tankBelow(); - //if(tile.nearbyChannel(ForgeDirection.DOWN))startY = -0.5D; - //else if(tile.hasTankConnected(ForgeDirection.DOWN))startY = 0D; - float liquidAmount = tile.liquid.amount / 288f * 0.125f; - renderer.setRenderBounds(0.375D, startY, 0.375D, 0.625D, 0.5 + liquidAmount, 0.625D); //Center - renderLiquidPart(world, x, y, z, block, renderer, tile); - //TConstruct.logger.info(tile.recentlyFilledDelay); + if (outputs.contains(ForgeDirection.EAST))//Channel to X+ + { + renderer.setRenderBounds(0.6875D, 0.375D, 0.3125D, 1D, 0.5D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625D, 0.5D, 0.3125D, 1D, 0.625D, 0.375D); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBounds(0.625D, 0.5D, 0.625D, 1D, 0.625D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } + else + //Wall to X+ + { + renderer.setRenderBounds(0.625D, 0.5D, 0.3125D, 0.6875D, 0.625D, 0.6875D); + renderer.renderStandardBlock(block, x, y, z); + } + FluidTankInfo tankMain = tile.getTankInfo(null)[0]; + if (tankMain.fluid != null) + { + float liquidAmount = (float)tankMain.fluid.amount / (float)tankMain.capacity * 0.125f; + double startY = tile.tankBelow(); + renderer.setRenderBounds(0.375D, startY, 0.375D, 0.625D, 0.5 + liquidAmount, 0.625D); //Center + renderLiquidPart(world, x, y, z, block, renderer, tankMain.fluid, false); + } + for(ForgeDirection dir: outputs) + { + double[] bounds = getRenderboundsForLiquid(dir); + if(bounds == null) + break; + FluidTankInfo tankSub = tile.getTankInfo(dir)[0]; + if(tankSub == null || tankSub.fluid == null) + break; + float liquidAmount = (float)tankSub.fluid.amount / (float)tankSub.capacity * 0.125f / 2; + renderer.setRenderBounds(bounds[0], 0.5, bounds[1], bounds[2], 0.5 + liquidAmount, bounds[3]); + renderLiquidPart(world, x, y, z, block, renderer, tankSub.fluid, true); + } + } + return true; + } - if (tile.hasTankConnected(ForgeDirection.NORTH)) - { - if (tile.lastProvider == ForgeDirection.NORTH) - { - renderer.setRenderBounds(0.375D, 0.5D, 0D, 0.625D, 0.5 + liquidAmount, 0.375D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - else - { - if (tile.recentlyFilledDelay == 0) - { - renderer.setRenderBounds(0.375D, 0.5D, 0D, 0.625D, 0.5 + liquidAmount, 0.375D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - } - if (tile.hasTankConnected(ForgeDirection.SOUTH)) - { - if (tile.lastProvider == ForgeDirection.SOUTH) - { - renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.5 + liquidAmount, 1D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - else - { - if (tile.recentlyFilledDelay == 0) - { - renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.5 + liquidAmount, 1D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - } - if (tile.hasTankConnected(ForgeDirection.WEST)) - { - if (tile.lastProvider == ForgeDirection.WEST) - { - renderer.setRenderBounds(0D, 0.5D, 0.375D, 0.375D, 0.5 + liquidAmount, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - else - { - if (tile.recentlyFilledDelay == 0) - { - renderer.setRenderBounds(0D, 0.5D, 0.375D, 0.375D, 0.5 + liquidAmount, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - } - if (tile.hasTankConnected(ForgeDirection.EAST)) - { - if (tile.lastProvider == ForgeDirection.EAST) - { - renderer.setRenderBounds(0.625D, 0.5D, 0.375D, 1D, 0.5 + liquidAmount, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - else - { - if (tile.recentlyFilledDelay == 0) - { - renderer.setRenderBounds(0.625D, 0.5D, 0.375D, 1D, 0.5 + liquidAmount, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } + private double[] getRenderboundsForLiquid(ForgeDirection dir) + { + switch(dir) + { + case NORTH: + return new double[]{0.375,0,0.625,0.375}; + case SOUTH: + return new double[]{0.375,0.625,0.625,1}; + case WEST: + return new double[]{0,0.375,0.375,0.625}; + case EAST: + return new double[]{0.625,0.375,1,0.625}; + default: + return null; + } + } - } - /*if(tile.lastProvider==ForgeDirection.UP && tile.recentlyFilledDelay != 0) - { - renderer.setRenderBounds(0.375D, 0.5D, 0.375D, 0.625D, 1D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - }*/ + private void renderLiquidPart (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer, FluidStack fluidStack, boolean useFlowingTexture) + { + int color = block.colorMultiplier(world, x, y, z); + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + Fluid fluid = fluidStack.getFluid(); + if (fluid.canBePlacedInWorld() && !useFlowingTexture) + BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, x, y, z, renderer, world); + else + if(useFlowingTexture) + BlockSkinRenderHelper.renderLiquidBlock(fluid.getFlowingIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + else + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + } - /*if(tile.hasTankConnected(ForgeDirection.NORTH)&&tile.lastProvider!=ForgeDirection.NORTH)//Channel to Z- - { - if(tile.recentlyFilledDelay == 0 || tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.5D, 0D, 0.625D, 0.625D, 0.375D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.recentlyFilledDelay != 0 && tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.375D, 0.375D, 0.625D, 1D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - if(tile.hasTankConnected(ForgeDirection.SOUTH)&&tile.lastProvider!=ForgeDirection.SOUTH)//Channel to Z+ - { - if(tile.recentlyFilledDelay == 0 || tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.625D, 1D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.recentlyFilledDelay != 0 && tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.375D, 0.375D, 0.625D, 1D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - if(tile.hasTankConnected(ForgeDirection.WEST)&&tile.lastProvider!=ForgeDirection.WEST)//Channel to X- - { - if(tile.recentlyFilledDelay == 0 || tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0D, 0.5D, 0.375D, 0.375D, 0.625D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.recentlyFilledDelay != 0 && tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.375D, 0.375D, 0.625D, 1D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - if(tile.hasTankConnected(ForgeDirection.EAST)&&tile.lastProvider!=ForgeDirection.EAST)//Channel to X+ - { - if(tile.recentlyFilledDelay == 0 || tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.625D, 0.5D, 0.375D, 1D, 0.625D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.recentlyFilledDelay != 0 && tile.lastProvider == ForgeDirection.UP) - { - renderer.setRenderBounds(0.375D, 0.375D, 0.375D, 0.625D, 1D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - } - if(tile.lastProvider==ForgeDirection.NORTH && tile.recentlyFilledDelay != 0) - { - renderer.setRenderBounds(0.375D, 0.5D, 0.625D, 0.625D, 0.625D, 1D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.lastProvider==ForgeDirection.SOUTH && tile.recentlyFilledDelay != 0) - { - renderer.setRenderBounds(0.375D, 0.5D, 0D, 0.625D, 0.625D, 0.375D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.lastProvider==ForgeDirection.WEST && tile.recentlyFilledDelay != 0) - { - renderer.setRenderBounds(0.625D, 0.5D, 0.375D, 1D, 0.625D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - } - if(tile.lastProvider==ForgeDirection.EAST && tile.recentlyFilledDelay != 0) - { - renderer.setRenderBounds(0D, 0.5D, 0.375D, 0.375D, 0.625D, 0.625D); - renderLiquidPart(world, x, y, z, block, renderer, tile); - }*/ - } + private void renderStandardBlock (Block block, int meta, RenderBlocks renderer) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } - } - return true; - } + @Override + public boolean shouldRender3DInInventory () + { + return true; + } - private void renderLiquidPart (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer, CastingChannelLogic logic) - { - FluidStack liquid = logic.liquid; - int color = block.colorMultiplier(world, x, y, z); - float red = (color >> 16 & 0xFF) / 255.0F; - float green = (color >> 8 & 0xFF) / 255.0F; - float blue = (color & 0xFF) / 255.0F; - Fluid fluid = liquid.getFluid(); - if (fluid.canBePlacedInWorld()) - BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, x, y, z, renderer, world); - else - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); - } - - private void renderStandardBlock (Block block, int meta, RenderBlocks renderer) - { - Tessellator tessellator = Tessellator.instance; - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); - tessellator.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean shouldRender3DInInventory () - { - // TODO Auto-generated method stub - return true; - } - - @Override - public int getRenderId () - { - return renderID; - } + @Override + public int getRenderId () + { + return renderID; + } } diff --git a/src/main/java/tconstruct/plugins/waila/CastingChannelDataProvider.java b/src/main/java/tconstruct/plugins/waila/CastingChannelDataProvider.java index 451ed865..7c3ad429 100644 --- a/src/main/java/tconstruct/plugins/waila/CastingChannelDataProvider.java +++ b/src/main/java/tconstruct/plugins/waila/CastingChannelDataProvider.java @@ -1,49 +1,71 @@ package tconstruct.plugins.waila; +import java.util.List; + import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; import tconstruct.blocks.logic.CastingChannelLogic; -import java.util.List; - public class CastingChannelDataProvider implements IWailaDataProvider { - @Override - public ItemStack getWailaStack (IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return null; - } + @Override + public ItemStack getWailaStack (IWailaDataAccessor accessor, IWailaConfigHandler config) + { + return null; + } - @Override - public List getWailaHead (ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return currenttip; - } + @Override + public List getWailaHead (ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) + { + return currenttip; + } - @Override - public List getWailaBody (ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - if (accessor.getTileEntity() instanceof CastingChannelLogic) - { - CastingChannelLogic te = (CastingChannelLogic) accessor.getTileEntity(); - if (te.liquid != null && te.liquid.amount > 0) - { - FluidStack fs = te.liquid; - currenttip.add(StatCollector.translateToLocal("tconstruct.waila.liquidtag") + WailaRegistrar.fluidNameHelper(fs)); - currenttip.add(StatCollector.translateToLocal("tconstruct.waila.amounttag") + fs.amount + "/" + te.getCapacity()); - } - else - { - currenttip.add("§o" + StatCollector.translateToLocal("tconstruct.waila.empty")); // "§o" == Italics - } - } + @Override + public List getWailaBody (ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) + { + if (accessor.getTileEntity() instanceof CastingChannelLogic) + { + CastingChannelLogic te = (CastingChannelLogic) accessor.getTileEntity(); + FluidTankInfo internalTank = te.getTankInfo(null)[0]; + FluidTankInfo northTank = te.getTankInfo(ForgeDirection.NORTH)[0]; + FluidTankInfo southTank = te.getTankInfo(ForgeDirection.SOUTH)[0]; + FluidTankInfo westTank = te.getTankInfo(ForgeDirection.WEST)[0]; + FluidTankInfo eastTank = te.getTankInfo(ForgeDirection.EAST)[0]; - return currenttip; - } + if(internalTank.fluid != null && internalTank.fluid.amount > 0) + { + FluidStack fs = internalTank.fluid; + currenttip.add(StatCollector.translateToLocal("tconstruct.waila.liquidtag") + WailaRegistrar.fluidNameHelper(fs)); + currenttip.add(StatCollector.translateToLocal("tconstruct.waila.amounttag") + fs.amount + "/" + internalTank.capacity); + } + else + { + currenttip.add("§o" + StatCollector.translateToLocal("tconstruct.waila.empty")); // "§o" == Italics + } + + currenttip.add(StatCollector.translateToLocal("tconstruct.waila.subtanks")); + String s1, s2, s3, s4; + s1 = s2 = s3 = s4 = "§o" + StatCollector.translateToLocal("tconstruct.waila.empty"); + + if(northTank.fluid != null) + s1 = northTank.fluid.amount + " / " + northTank.capacity; + if(southTank.fluid != null) + s2 = southTank.fluid.amount + " / " + southTank.capacity; + if(westTank.fluid != null) + s3 = westTank.fluid.amount + " / " + westTank.capacity; + if(eastTank.fluid != null) + s4 = eastTank.fluid.amount + " / " + eastTank.capacity; + currenttip.add(s1 +"; " + s2 +"; " + s3 +"; " + s4); + } + + return currenttip; + } }