Package net.minecraftforge.fluids

Examples of net.minecraftforge.fluids.FluidStack.copy()


    }

    //now check for empty fluid containers to fill
    FluidStack available = vat.outputTank.getFluid();
    if(available != null) {
      ItemStack res = FluidContainerRegistry.fillFluidContainer(available.copy(), item);
      FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);

      if(filled == null) { //this shouldn't be necessary but it appears to be a bug as the above method doesnt work
        FluidContainerData[] datas = FluidContainerRegistry.getRegisteredFluidContainerData();
        for (FluidContainerData data : datas) {
View Full Code Here


    for (NetworkFluidHandler h : getNetworkHandlers()) {
      if(h.node.canSendFluid() && h.handler.canDrain(h.dirOp, in.getFluid())) {
        FluidStack res = h.handler.drain(h.dirOp, in, false);
        if(res != null) {
          if(result == null) {
            result = res.copy();
            if(doDrain) {
              h.handler.drain(h.dirOp, in, true);
            }

          } else if(result.isFluidEqual(res)) {
View Full Code Here

    for (NetworkFluidHandler h : getNetworkHandlers()) {
      if(h.node.canSendFluid()) {
        FluidStack res = h.handler.drain(h.dirOp, maxDrain, false);
        if(res != null) {
          if(result == null) {
            result = res.copy();
            if(doDrain) {
              h.handler.drain(h.dirOp, maxDrain, true);
            }
            maxDrain -= res.amount;
          } else if(result.isFluidEqual(res)) {
View Full Code Here

    }

    //now check for empty fluid containers to fill
    FluidStack available = tank.tank.getFluid();
    if(available != null) {
      ItemStack res = FluidContainerRegistry.fillFluidContainer(available.copy(), item);
      FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);

      if(filled == null) { //this shouldn't be necessary but it appears to be a bug as the above method doesnt work
        FluidContainerData[] datas = FluidContainerRegistry.getRegisteredFluidContainerData();
        for (FluidContainerData data : datas) {
View Full Code Here

  public void writeToNBT(NBTTagCompound nbtRoot) {
    super.writeToNBT(nbtRoot);
    FluidStack ft = getFluidType();
    if(ConduitUtil.isFluidValid(ft)) {
      updateTank();
      ft = ft.copy();
      ft.amount = tank.getFluidAmount();
      nbtRoot.setTag("tank", ft.writeToNBT(new NBTTagCompound()));
    }
    nbtRoot.setBoolean("fluidLocked", fluidTypeLocked);
  }
View Full Code Here

  @Override
  public boolean setFluidType(FluidStack newType) {
    if(super.setFluidType(newType)) {

      FluidStack ft = getFluidType();
      tank.setLiquid(ft == null ? null : ft.copy());
      return true;
    }
    return false;
  }
View Full Code Here

        FluidStack drained = extTank.drain(dir.getOpposite(), maxExtract, true);
        if(drained == null || drained.amount <= 0) {
          return false;
        }
        setFluidType(drained);
        tank.setLiquid(drained.copy());
        return true;
      }

      FluidStack couldDrain = liquidType.copy();
      couldDrain.amount = maxExtract;
View Full Code Here

    int closestDistance = Integer.MAX_VALUE;
    LocatedFluidHandler closestTank = null;
    for (LocatedFluidHandler lh : externals) {
      int distance = lh.bc.distanceSquared(conLoc);
      if(distance < closestDistance) {
        int couldFill = lh.tank.fill(lh.dir, toDrain.copy(), false);
        if(couldFill > 0) {
          closestTank = lh;
          closestDistance = distance;
        }
      }
View Full Code Here

        }
      }
    }

    if(closestTank != null) {
      int filled = closestTank.tank.fill(closestTank.dir, toDrain.copy(), true);
      con.getTank().addAmount(-filled);
    }

  }
View Full Code Here

    // Then to external connections
    for (ForgeDirection dir : con.getExternalConnections()) {
      if(con.canOutputToDir(dir)) {
        IFluidHandler extCon = con.getExternalHandler(dir);
        if(extCon != null) {
          int amount = extCon.fill(dir.getOpposite(), available.copy(), false);
          if(amount > 0) {
            totalRequested += amount;
            numRequests++;
          }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.