@Override public FluidStack drain(int maxDrain, boolean doDrain) { if (fluid == null) { return null; } int drained = maxDrain; if (fluid.amount < drained) { drained = fluid.amount; } FluidStack stack = new FluidStack(fluid, drained); if (doDrain) { fluid.amount -= drained; if (fluid.amount <= 0) { fluid = null; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorld(), this.getPos(), this, drained)); } } return stack; }
@Override public FluidStack drain(final int maxDrain, final boolean doDrain) { if (fluid == null) { return null; } final int drained = Math.min(maxDrain, fluid.amount); final FluidStack f = new FluidStack(fluid, drained); if (doDrain) { fluid.amount -= drained; if (fluid.amount <= 0) { fluid = null; } if (tile != null) { FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, drained)); } } return f; }
@Override public FluidStack drain(int maxDrain, boolean doDrain) { if (!isFluidTanker()) { return null; } if (fluid == null) { return null; } int drained = maxDrain; if (fluid.amount < drained) { drained = fluid.amount; } FluidStack stack = new FluidStack(fluid, drained); if (doDrain) { fluid.amount -= drained; if (fluid.amount <= 0) { fluid = null; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, world, this.getPosition(), this, drained)); } } return stack; }
@Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { FluidDrainingEvent fluidDrainingEvent = new FluidEvent.FluidDrainingEvent(resource, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.tank); FluidEvent.fireEvent(fluidDrainingEvent); if (resource == null || !resource.isFluidEqual(this.tank.getFluid())) { return null; } return this.drain(from, resource.amount, doDrain); }
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { FluidFillingEvent fluidFillingEvent = new FluidEvent.FluidFillingEvent(resource, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.tank); FluidEvent.fireEvent(fluidFillingEvent); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); return this.tank.fill(resource, doFill); }
@Override public int fill(FluidStack resource, boolean doFill) { if (!isFluidTanker()) { return 0; } if (resource == null) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(maxOilStorage, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(maxOilStorage - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(maxOilStorage, resource.amount)); if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, world, this.getPosition(), this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = maxOilStorage - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = maxOilStorage; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, world, this.getPosition(), this, filled)); } return filled; }
@Override public int fill(FluidStack resource, boolean doFill) { if (resource == null) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(maxOilStorage, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(maxOilStorage - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(maxOilStorage, resource.amount)); if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = maxOilStorage - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = maxOilStorage; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, filled)); } return filled; }
@Override public int fill(FluidStack resource, boolean doFill) { if (resource == null) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(maxLiquidStorage, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(maxLiquidStorage - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(maxLiquidStorage, resource.amount)); if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = maxLiquidStorage - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = maxLiquidStorage; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, filled)); } return filled; }
@Override public int fill(FluidStack resource, boolean doFill) { if (resource == null) { return 0; } if (!(resource.isFluidEqual(new FluidStack(getfluidForHeight(getStackOrder()), 1)))) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(maxOilStorage, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(maxOilStorage - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(maxOilStorage, resource.amount)); if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = maxOilStorage - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = maxOilStorage; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, filled)); } return filled; }
@Override public int fill(FluidStack resource, boolean doFill) { if (resource == null) { return 0; } if (!(resource.isFluidEqual(new FluidStack(ModBlocks.fluidBitumen, 1)))) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(maxOilStorage, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(maxOilStorage - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(maxOilStorage, resource.amount)); if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = maxOilStorage - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = maxOilStorage; } if (this != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, this.getWorld(), this.getPos(), this, filled)); } return filled; }
@Override public int fill(final FluidStack resource, final boolean doFill) { if (resource == null) { return 0; } if (!doFill) { if (fluid == null) { return Math.min(capacity, resource.amount); } if (!fluid.isFluidEqual(resource)) { return 0; } return Math.min(capacity - fluid.amount, resource.amount); } if (fluid == null) { fluid = new FluidStack(resource, Math.min(capacity, resource.amount)); if (tile != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, fluid.amount)); } return fluid.amount; } if (!fluid.isFluidEqual(resource)) { return 0; } int filled = capacity - fluid.amount; if (resource.amount < filled) { fluid.amount += resource.amount; filled = resource.amount; } else { fluid.amount = capacity; } if (tile != null) { FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile .getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, filled)); } return filled; }