Examples of IFluidHandler


Examples of net.minecraftforge.fluids.IFluidHandler

 
  private boolean isFluidSidedTexture(ForgeDirection connection) {
    WorldUtil util = new WorldUtil(getWorld(), getX(), getY(), getZ());
    TileEntity tile = util.getAdjacentTileEntitie(connection);
    if (tile instanceof IFluidHandler) {
      IFluidHandler liq = (IFluidHandler) tile;

      if (liq.getTankInfo(connection.getOpposite()) != null && liq.getTankInfo(connection.getOpposite()).length > 0)
        return true;
    }
    return false;
  }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

      if(this.isConnectableTank(tile, arrivingItem.output, false)) {
        List<Pair<TileEntity,ForgeDirection>> adjTanks = getAdjacentTanks(false);
        //Try to put liquid into all adjacent tanks.
        for (int i = 0; i < adjTanks.size(); i++) {
          Pair<TileEntity,ForgeDirection> pair = adjTanks.get(i);
          IFluidHandler tank = (IFluidHandler) pair.getValue1();
          ForgeDirection dir = pair.getValue2();
          filled = tank.fill(dir.getOpposite(), liquid.copy(), true);
          liquid.amount -= filled;
          if (liquid.amount != 0) continue;
          return true;
        }
        //Try inserting the liquid into the pipe side tank
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

  private void updateInv(boolean force) {
    itemList.clear();
    for(Pair<TileEntity, ForgeDirection> pair:getAdjacentTanks(false)) {
      if(!(pair.getValue1() instanceof IFluidHandler)) continue;
      IFluidHandler tankContainer = (IFluidHandler) pair.getValue1();
      FluidTankInfo[] tanks = tankContainer.getTankInfo(pair.getValue2().getOpposite());
      if(tanks == null) continue;
      for(FluidTankInfo tank: tanks) {
        if(tank == null) continue;
        FluidStack liquid = tank.fluid;
        if(liquid != null && liquid.fluidID != 0) {
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    super.throttledUpdateEntity();
    if(dummyInventory.getStackInSlot(0) == null) return;
    WorldUtil worldUtil = new WorldUtil(getWorld(), getX(), getY(), getZ());
    for (AdjacentTile tile :  worldUtil.getAdjacentTileEntities(true)){
      if (!(tile.tile instanceof IFluidHandler) || SimpleServiceLocator.pipeInformaitonManager.isPipe(tile.tile)) continue;
      IFluidHandler container = (IFluidHandler) tile.tile;
      if (container.getTankInfo(ForgeDirection.UNKNOWN) == null || container.getTankInfo(ForgeDirection.UNKNOWN).length == 0) continue;
     
      //How much do I want?
      Map<FluidIdentifier, Integer> wantFluids = new HashMap<FluidIdentifier, Integer>();
      FluidIdentifier fIdent = FluidIdentifier.get(dummyInventory.getIDStackInSlot(0).getItem());
      wantFluids.put(fIdent, amount);

      //How much do I have?
      HashMap<FluidIdentifier, Integer> haveFluids = new HashMap<FluidIdentifier, Integer>();

      FluidTankInfo[] result = container.getTankInfo(ForgeDirection.UNKNOWN);
      for (FluidTankInfo slot : result){
        if (slot == null || slot.fluid == null || slot.fluid.fluidID == 0 || !wantFluids.containsKey(FluidIdentifier.get(slot.fluid))) continue;
        Integer liquidWant = haveFluids.get(FluidIdentifier.get(slot.fluid));
        if (liquidWant==null){
          haveFluids.put(FluidIdentifier.get(slot.fluid), slot.fluid.amount);
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

      @Override
      public boolean canPipeConnect(TileEntity tile, ForgeDirection dir) {
        if(super.canPipeConnect(tile, dir)) return true;
        if(SimpleServiceLocator.pipeInformaitonManager.isPipe(tile)) return false;
        if (tile instanceof IFluidHandler) {
          IFluidHandler liq = (IFluidHandler) tile;
          if (liq.getTankInfo(dir.getOpposite()) != null && liq.getTankInfo(dir.getOpposite()).length > 0)
            return true;
        }
        return false;
      }
    }, item);
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

  public void endReached(LPTravelingItemServer data, TileEntity tile) {
    this.transport.markChunkModified(tile);
    notifyOfItemArival(data.getInfo());
    if (!(tile instanceof IFluidHandler)) return;
    if (SimpleServiceLocator.pipeInformaitonManager.isPipe(tile)) return;
    IFluidHandler container = (IFluidHandler) tile;
    if (data.getItemIdentifierStack() == null) return;
    FluidStack liquidId = FluidContainerRegistry.getFluidForFilledItem(data.getItemIdentifierStack().makeNormalStack());
    if (liquidId == null) return;
    ForgeDirection orientation = data.output.getOpposite();
    if(getUpgradeManager().hasSneakyUpgrade()) {
      orientation = getUpgradeManager().getSneakyOrientation();
    }
    while (data.getItemIdentifierStack().getStackSize() > 0 && container.fill(orientation, liquidId, false) == liquidId.amount && this.useEnergy(5)) {
      container.fill(orientation, liquidId.copy(), true);
      data.getItemIdentifierStack().lowerStackSize(1);
      Item item = data.getItemIdentifierStack().getItem().item;
      if (item.hasContainerItem(data.getItemIdentifierStack().makeNormalStack())) {
        Item containerItem = item.getContainerItem();
        transport.sendItem(new ItemStack(containerItem, 1));
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    if (MainProxy.isClient(getWorld())) return;
    super.throttledUpdateEntity();
    WorldUtil worldUtil = new WorldUtil(getWorld(), getX(), getY(), getZ());
    for (AdjacentTile tile :  worldUtil.getAdjacentTileEntities(true)){
      if (!(tile.tile instanceof IFluidHandler) || SimpleServiceLocator.pipeInformaitonManager.isPipe(tile.tile)) continue;
      IFluidHandler container = (IFluidHandler) tile.tile;
      if (container.getTankInfo(ForgeDirection.UNKNOWN) == null || container.getTankInfo(ForgeDirection.UNKNOWN).length == 0) continue;
     
      //How much do I want?
      Map<ItemIdentifier, Integer> wantContainers = dummyInventory.getItemsAndCount();
      HashMap<FluidIdentifier, Integer> wantFluids = new HashMap<FluidIdentifier, Integer>();
      for (Entry<ItemIdentifier, Integer> item : wantContainers.entrySet()){
        ItemStack wantItem = item.getKey().unsafeMakeNormalStack(1);
        FluidStack liquidstack = FluidContainerRegistry.getFluidForFilledItem(wantItem);
        if (liquidstack == null) continue;
        wantFluids.put(FluidIdentifier.get(liquidstack), item.getValue() * liquidstack.amount);
      }

      //How much do I have?
      HashMap<FluidIdentifier, Integer> haveFluids = new HashMap<FluidIdentifier, Integer>();
     
      FluidTankInfo[] result = container.getTankInfo(ForgeDirection.UNKNOWN);
      for (FluidTankInfo slot : result){
        if (slot == null || slot.fluid == null || slot.fluid.fluidID == 0 || !wantFluids.containsKey(FluidIdentifier.get(slot.fluid))) continue;
        Integer liquidWant = haveFluids.get(FluidIdentifier.get(slot.fluid));
        if (liquidWant==null){
          haveFluids.put(FluidIdentifier.get(slot.fluid), slot.fluid.amount);
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    try
    {
      for (PartP2PLiquids l : getOutputs())
      {
        IFluidHandler handler = l.getTarget();
        if ( handler != null )
        {
          if ( handler.canFill( l.side.getOpposite(), input ) )
            outs.add( l );
        }
      }
    }
    catch (GridAccessException e)
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    Iterator<PartP2PLiquids> i = list.iterator();
    while (i.hasNext())
    {
      PartP2PLiquids l = i.next();
      IFluidHandler tank = l.getTarget();
      if ( tank != null )
        l.tmpUsed = tank.fill( l.side.getOpposite(), resource.copy(), false );
      else
        l.tmpUsed = 0;

      if ( l.tmpUsed <= 0 )
        i.remove();
      else
        requestTotal += l.tmpUsed;
    }

    if ( requestTotal <= 0 )
    {
      if ( stack.pop() != this )
        throw new RuntimeException( "Invalid Recursion detected." );

      return 0;
    }

    if ( !doFill )
    {
      if ( stack.pop() != this )
        throw new RuntimeException( "Invalid Recursion detected." );

      return Math.min( resource.amount, requestTotal );
    }

    int available = resource.amount;
    int used = 0;

    i = list.iterator();
    while (i.hasNext())
    {
      PartP2PLiquids l = i.next();

      FluidStack insert = resource.copy();
      insert.amount = (int) Math.ceil( insert.amount * ((double) l.tmpUsed / (double) requestTotal) );
      if ( insert.amount > available )
        insert.amount = available;

      IFluidHandler tank = l.getTarget();
      if ( tank != null )
        l.tmpUsed = tank.fill( l.side.getOpposite(), insert.copy(), true );
      else
        l.tmpUsed = 0;

      available -= insert.amount;
      used += insert.amount;
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    public void outputLiquid(AdjacentTileCache cache, ITileFilter filter, ForgeDirection[] sides, int tankIndex, int amount) {
        for (ForgeDirection side : sides) {
            TileEntity tile = cache.getTileOnSide(side);
            if (!filter.matches(tile)) continue;
            IFluidHandler tank = getTankFromTile(tile);
            if (tank == null) continue;
            outputLiquid((IFluidHandler) tile, side, tankIndex, amount);
        }
    }
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.