@Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { if (hasValidMaster() && canDrain(from, resource.getFluid())) { SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity( getMasterPosition().x, getMasterPosition().y, getMasterPosition().z); if (resource.getFluid() == smeltery.getFluid().getFluid()) { return smeltery.drain(resource.amount, doDrain); } } return null; }
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if (hasValidMaster() && resource != null && canFill(from, resource.getFluid())) { SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity( getMasterPosition().x, getMasterPosition().y, getMasterPosition().z); return smeltery.fill(resource, doFill); } else { return 0; } }
@Override public boolean canDrain(ForgeDirection from, Fluid fluid) { // Check that the drain is coming from the from the front of the block // and that the fluid to be drained is in the smeltery. if (!hasValidMaster()) return false; boolean containsFluid = fluid == null; if (fluid != null) { SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity( getMasterPosition().x, getMasterPosition().y, getMasterPosition().z); for (FluidStack fstack : smeltery.moltenMetal) { if (fstack.getFluidID() == fluid.getID()) { containsFluid = true; break; } } } // return from == getForgeDirection().getOpposite() && containsFluid; return containsFluid; }