コード例 #1
0
  private void activeEmit() {
    if (fluidTank.getFluid() != null) {
      TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(worldObj);

      if (tileEntity != null
          && CapabilityUtils.hasCapability(
              tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP)) {
        IFluidHandler handler =
            CapabilityUtils.getCapability(
                tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP);
        FluidStack toDrain =
            new FluidStack(fluidTank.getFluid(), Math.min(tier.output, fluidTank.getFluidAmount()));
        fluidTank.drain(handler.fill(toDrain, true), true);
      }
    }
  }
コード例 #2
0
  public int pushUp(FluidStack fluid, boolean doFill) {
    Coord4D up = Coord4D.get(this).offset(EnumFacing.UP);

    if (up.getTileEntity(worldObj) instanceof TileEntityFluidTank) {
      IFluidHandler handler =
          CapabilityUtils.getCapability(
              up.getTileEntity(worldObj),
              CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
              EnumFacing.DOWN);

      if (PipeUtils.canFill(handler, fluid)) {
        return handler.fill(fluid, doFill);
      }
    }

    return 0;
  }