Package appeng.api.me.util

Examples of appeng.api.me.util.IMEInventoryHandler


    if (drainable != null && drainable.amount > 0)
    {
      List<Fluid> fluidFilter = getFilterFluids(inventory.slots);
      IAEItemStack toImport = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), drainable.amount, drainable.fluidID));

      IMEInventoryHandler cellArray = getGrid().getCellArray();
      if (cellArray != null)
      {
        IAEItemStack notImported = cellArray.calculateItemAddition(toImport.copy());

        if (fluidFilter != null && !fluidFilter.isEmpty() && fluidFilter.size() > 0)
        {
          if (fluidFilter.contains(drainable.getFluid()))
          {
            if (notImported == null && grid.useMEEnergy(modeCost, "Import Fluid"))
            {
              FluidStack drained = fluidHandler.drain(facing.getOpposite(), (int) toImport.getStackSize(), true);
              if (drained != null)
                cellArray.addItems(toImport.copy());
            }
          }
        } else
        {
          if (notImported == null && grid.useMEEnergy(modeCost, "Import Fluid"))
          {
            FluidStack drained = fluidHandler.drain(facing.getOpposite(), (int) toImport.getStackSize(), true);
            if (drained != null)
              cellArray.addItems(toImport.copy());
          }
        }
      }
    }
  }
View Full Code Here


      IAEItemStack added;
      int amount = resource.amount;
      int fluidID = resource.fluidID;
      IAEItemStack temp = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), amount, fluidID));
      temp.setStackSize(amount);
      IMEInventoryHandler cellArray = getGrid().getCellArray();
      if (cellArray != null)
      {
        if (doFill)
        {
          added = cellArray.addItems(temp);
        } else
        {
          added = cellArray.calculateItemAddition(temp);
        }
        if (added == null)
        {
          if (doFill)
            getGrid().useMEEnergy(amount / 50, "Import Fluid");
View Full Code Here

  @Override
  public boolean canFill(ForgeDirection from, Fluid fluid)
  {
    if (grid != null)
    {
      IMEInventoryHandler cellArray = grid.getCellArray();
      return cellArray != null && fluid != null && cellArray.canAccept(Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 1, fluid.getID())));
    }
    return false;
  }
View Full Code Here

    if (getGrid() != null && from.ordinal() == this.blockMetadata)
    {
      List<FluidTankInfo> tankInfo = new ArrayList<FluidTankInfo>();
      FluidTankInfo[] tankArray = new FluidTankInfo[1];

      IMEInventoryHandler cellArray = grid.getCellArray();
      if (cellArray != null)
      {
        for (IAEItemStack item : cellArray.getAvailableItems())
        {
          if (item.getItem() == FLUIDDISPLAY.getItemInstance())
            tankInfo.add(new FluidTankInfo(new FluidStack(FluidRegistry.getFluid(item.getItemDamage()), (int) item.getStackSize()), (int) getGrid().getCellArray().freeBytes()));
        }

        if (tankInfo.isEmpty())
          tankInfo.add(new FluidTankInfo(null, (int) cellArray.freeBytes()));

        tankArray = tankInfo.toArray(tankArray);
        return tankArray;
      }
    }
View Full Code Here

      {
        if ((world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z)) && unpowered)
        {
          if (((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getGrid() != null)
          {
            IMEInventoryHandler cellArray = ((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getGrid().getCellArray();
            if (cellArray != null && cellArray.extractItems(Util.createItemStack(request)) != null)
            {
              dispense(world, x, y, z, ((TileEntityMEDropper) world.getBlockTileEntity(x, y, z)).getItem().copy());
              unpowered = false;
            }
          }
View Full Code Here

  @ForgeSubscribe
  public void onNetworkPatternChange(GridPatternUpdateEvent e)
  {
    if (grid != null)
    {
      IMEInventoryHandler inventoryHandler = grid.getCraftableArray();
      if (inventoryHandler != null)
      {
        craftableFluidsInNetwork = new ArrayList<Fluid>();
        for (IAEItemStack stack : inventoryHandler.getAvailableItems())
        {
          if (stack.getItem() == FLUIDDISPLAY.getItemInstance())
          {
            craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage()));
          }
View Full Code Here

  {
    IAEItemStack toFill = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 0, toImport.fluidID));
    toFill.setStackSize(toImport.amount);
    if (grid != null)
    {
      IMEInventoryHandler cellArray = grid.getCellArray();
      if (cellArray != null)
      {
        IAEItemStack sim = cellArray.calculateItemAddition(toFill.copy());

        if (sim != null)
        {
          return false;
        }

        cellArray.addItems(toFill.copy());
        return true;
      }
    }
    return false;
  }
View Full Code Here

    IAEItemStack toDrain = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 0, toExport.fluidID));
    toDrain.setStackSize(toExport.amount);

    if (grid != null)
    {
      IMEInventoryHandler cellArray = grid.getCellArray();
      if (cellArray != null)
      {
        for (SpecialFluidStack fluidstack : fluidsInNetwork)
        {
          if (fluidstack.getID() == toExport.fluidID && fluidstack.amount >= toExport.amount)
          {
            IAEItemStack takenStack = cellArray.extractItems(Util.createItemStack(new ItemStack(toDrain.getItem(), (int) (toDrain.getStackSize()), toDrain.getItemDamage())));

            if (takenStack == null)
            {
              return false;
            } else if (takenStack.getStackSize() != (int) toDrain.getStackSize())
            {
              cellArray.addItems(takenStack);
              return false;
            } else
            {
              return true;
            }
View Full Code Here

    if (!worldObj.isRemote)
    {
      grid = gi;
      if (gi != null)
      {
        IMEInventoryHandler cellArray = gi.getCellArray();
        if (cellArray != null)
          updateFluids(cellArray.getAvailableItems());
      } else
      {
        setPowerStatus(false);
      }
      PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
View Full Code Here

  {
    networkReady = isReady;

    if (getGrid() != null)
    {
      IMEInventoryHandler cellArray = getGrid().getCellArray();
      if (cellArray != null)
        updateFluids(cellArray.getAvailableItems());
    }

    PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
  }
View Full Code Here

TOP

Related Classes of appeng.api.me.util.IMEInventoryHandler

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.