Package appeng.api.me.util

Examples of appeng.api.me.util.IMEInventoryHandler


  {
    List<Fluid> fluidFilter = getFilterFluids(inventory.slots);

    if (fluidFilter != null && fluidFilter.size() > 0)
    {
      IMEInventoryHandler cellArray = getGrid().getCellArray();
      for (Fluid entry : fluidFilter)
      {
        if (entry != null && cellArray != null)
        {
          IAEItemStack entryToAEIS = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), 1, entry.getID()));

          long contained = cellArray.countOfItemType(entryToAEIS);

          if (contained > 0)
          {
            int modeAmount = mode.getAmount() * tickRate;
            exportFluid(new FluidStack(entry, contained < modeAmount ? (int) contained : modeAmount), fluidHandler, ForgeDirection.getOrientation(getBlockMetadata()).getOpposite(), mode);
View Full Code Here


  }

  public void exportFluid(FluidStack toExport, IFluidHandler tankToFill, ForgeDirection from, FluidMode mode)
  {
 
    IMEInventoryHandler cellArray = grid.getCellArray();
    if (cellArray != null)
    {
      if (toExport == null)
        return;
      int fillable = tankToFill.fill(from, toExport, false);
 
      if (fillable > 0)
      {
        IAEItemStack toExtract = Util.createItemStack(new ItemStack(FLUIDDISPLAY.getItemInstance(), fillable, toExport.fluidID));
 
        IAEItemStack extracted = cellArray.extractItems(toExtract);

        grid.useMEEnergy(mode.getCost() * tickRate, "Export Fluid");

        if (extracted != null)
        {
View Full Code Here

      ForgeDirection orientation = ForgeDirection.getOrientation(getBlockMetadata());

      int offsetID = worldObj.getBlockId(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
      int offsetMeta = worldObj.getBlockMetadata(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);

      IMEInventoryHandler cellArray = getGrid().getCellArray();
      if (cellArray != null)
      {
        try
        {
          if (Block.blocksList[offsetID] instanceof IFluidBlock)
          {
            FluidStack simulation = ((IFluidBlock) Block.blocksList[offsetID]).drain(worldObj, xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ, false);

            if (simulation != null && cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), simulation.amount, simulation.fluidID))) == null)
            {
              ((IFluidBlock) Block.blocksList[offsetID]).drain(worldObj, xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ, true);
              cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), simulation.amount, simulation.fluidID)));
            }
          } else if (offsetID == FluidRegistry.WATER.getBlockID() && offsetMeta == 0)
          {
            if (cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.WATER.getID()))) == null)
            {
              worldObj.setBlockToAir(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
              cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.WATER.getID())));
            }
          } else if (offsetID == FluidRegistry.LAVA.getBlockID() && offsetMeta == 0)
          {
            if (cellArray.calculateItemAddition(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.LAVA.getID()))) == null)
            {
              worldObj.setBlockToAir(xCoord + orientation.offsetX, yCoord + orientation.offsetY, zCoord + orientation.offsetZ);
              cellArray.addItems(Util.createItemStack(new ItemStack(ItemEnum.FLUIDDISPLAY.getItemInstance(), 1000, FluidRegistry.LAVA.getID())));
            }
          }
        } catch (Throwable wontHappen)
        {
          // Nothing
View Full Code Here

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

  {
    networkReady = isReady;

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

    PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
  }
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 (IAEItemStack fluidstack : cellArray.getAvailableItems())
        {
          if (fluidstack != null && fluidstack.getItem() instanceof ItemFluidDisplay && fluidstack.getItemDamage() == toExport.fluidID && fluidstack.getStackSize() >= 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

  @Override
  public long drainFromNetwork(FluidStack toDrain, boolean doDrain)
  {
    if (!isMachineActive() || toDrain == null || grid == null)
      return 0;
    IMEInventoryHandler cellArray = grid.getCellArray();
    if (cellArray == null)
      return 0;
    IAEItemStack drained = cellArray.extractItems(createFluidItemStack(toDrain));
    if (drained == null)
      return 0;
    if (!doDrain)
      cellArray.addItems(drained);

    getGrid().useMEEnergy(drained.getStackSize() == 0 ? 0 : drained.getStackSize() / 4, "FluidInterface");
    return drained.getStackSize();
  }
View Full Code Here

  @Override
  public long fillToNetwork(FluidStack toFill, boolean doFill)
  {
    if (!isMachineActive() || toFill == null || grid == null)
      return 0;
    IMEInventoryHandler cellArray = grid.getCellArray();
    if (cellArray == null)
      return 0;
    IAEItemStack notFilled = cellArray.calculateItemAddition(createFluidItemStack(toFill));
    IAEItemStack filled = createFluidItemStack(toFill);
    if (notFilled != null)
      filled = createFluidItemStack(new SpecialFluidStack(notFilled.getItemDamage(), toFill.amount - notFilled.getStackSize()));
    if (doFill)
      cellArray.addItems(filled);

    getGrid().useMEEnergy(filled.getStackSize() == 0 ? 0 : filled.getStackSize() / 4, "FluidInterface");
    return filled.getStackSize();
  }
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.