Package net.minecraftforge.fluids

Examples of net.minecraftforge.fluids.IFluidHandler


    int totalRequested = 0;
    int numRequests = 0;
    // 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++;
          }
        }
      }
    }

    if(numRequests > 0) {
      int amountPerRequest = Math.min(totalAmount, totalRequested) / numRequests;
      amountPerRequest = Math.min(maxFlowVolume, amountPerRequest);

      FluidStack requestSource = available.copy();
      requestSource.amount = amountPerRequest;
      for (ForgeDirection dir : con.getExternalConnections()) {
        if(con.canOutputToDir(dir)) {
          IFluidHandler extCon = con.getExternalHandler(dir);
          if(extCon != null) {
            int amount = extCon.fill(dir.getOpposite(), requestSource.copy(), true);
            if(amount > 0) {
              outputedToExternal(amount);
              tank.addAmount(-amount);
            }
          }
View Full Code Here


  protected final Map<ForgeDirection, Integer> externalRedstoneSignals = new HashMap<ForgeDirection, Integer>();
  protected boolean redstoneStateDirty = true;

  public IFluidHandler getExternalHandler(ForgeDirection direction) {
    IFluidHandler con = FluidUtil.getExternalFluidHandler(getBundle().getWorld(), getLocation().getLocation(direction));
    return (con != null && !(con instanceof IConduitBundle)) ? con : null;
  }
View Full Code Here

    return FluidUtil.getFluidHandler(getBundle().getWorld(), bc);
  }

  @Override
  public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreDisabled) {
    IFluidHandler h = getExternalHandler(direction);
    if(h == null) {
      return false;
    }
    //TODO: This check was added to work around a bug in dynamic tanks, but
    //it causes issues with not conecting to empty tanks such as dim. trans +
View Full Code Here

      return true;
    }
    if(!externalConnections.contains(dir)) {
      return false;
    }
    IFluidHandler ext = getExternalHandler(dir);
    if(ext instanceof TileReservoir) { // dont push to an auto ejecting
      // resevoir or we loop
      TileReservoir tr = (TileReservoir) ext;
      return !tr.isMultiblock() || !tr.isAutoEject();
    }
View Full Code Here

    // Handle buckets
    if(te instanceof IFluidHandler)
    {
      if(FluidContainerRegistry.isEmptyContainer(entityPlayer.inventory.getCurrentItem())) {
        IFluidHandler fluidHandler = (IFluidHandler)te;
        FluidTankInfo[] infoz = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN);
        for(FluidTankInfo info : infoz) {
          if(StaticUtils.Fluids.fillContainerFromTank(world, fluidHandler, entityPlayer, info.fluid)) {
            return true;
          }
        }
View Full Code Here

      for(ForgeDirection side : getConnections(ConnectionType.PULL))
      {
        if(connectedAcceptors[side.ordinal()] != null)
        {
          IFluidHandler container = connectedAcceptors[side.ordinal()];

          if(container != null)
          {
            FluidStack received = container.drain(side.getOpposite(), getPullAmount(), false);

            if(received != null && received.amount != 0)
            {
              container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true);
            }
          }
        }
      }
    }
View Full Code Here

      for(Object obj : availableAcceptors)
      {
        if(obj instanceof IFluidHandler)
        {
          IFluidHandler acceptor = (IFluidHandler)obj;
          int currentSending = sending;

          if(remaining > 0)
          {
            currentSending++;
            remaining--;
          }

          if(acceptorDirections.get(acceptor) != null && fluidToSend != null)
          {
            fluidSent += acceptor.fill(acceptorDirections.get(acceptor).getOpposite(), new FluidStack(fluidToSend.fluidID, currentSending), doTransfer);
          }
        }
      }
    }
View Full Code Here

  {
    Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP);
   
    if(up.getTileEntity(worldObj) instanceof TileEntityPortableTank)
    {
      IFluidHandler handler = (IFluidHandler)up.getTileEntity(worldObj);
     
      if(handler.canFill(ForgeDirection.DOWN, fluid.getFluid()))
      {
        return handler.fill(ForgeDirection.DOWN, fluid, doFill);
      }
    }
   
    return 0;
  }
View Full Code Here

    if (fluidStack != null && fluidStack.amount > capacity)
      fluidStack.amount = capacity;
  }

  public static IFluidHandler getTankFromTile(TileEntity tile) {
    IFluidHandler tank = null;
    if (tile instanceof IFluidHandler)
      tank = (IFluidHandler) tile;
    return tank;
  }
View Full Code Here

  }

  @Override
  public boolean logisitcsIsPipeConnected(TileEntity tile, ForgeDirection dir) {
    if (tile instanceof IFluidHandler) {
      IFluidHandler liq = (IFluidHandler) tile;

      if (liq.getTankInfo(dir.getOpposite()) != null && liq.getTankInfo(dir.getOpposite()).length > 0)
        return true;
    }

    return tile instanceof LogisticsTileGenericPipe;
  }
View Full Code Here

TOP

Related Classes of net.minecraftforge.fluids.IFluidHandler

Copyright © 2018 www.massapicom. 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.