Package buildcraft.api.core

Examples of buildcraft.api.core.IInvSlot


  }

  private BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder builder) {
    BuildingSlotBlock result = null;

    IInvSlot firstSlotToConsume = null;

    for (IInvSlot invSlot : InventoryIterator.getIterable(builder, ForgeDirection.UNKNOWN)) {
      if (!builder.isBuildingMaterialSlot(invSlot.getIndex())) {
        continue;
      }

      ItemStack stack = invSlot.getStackInSlot();

      if (stack != null && stack.stackSize > 0) {
        firstSlotToConsume = invSlot;
        break;
      }
    }

    iterator.startIteration();

    while (iterator.hasNext()) {
      BuildingSlotBlock slot = iterator.next();

      if (slot.buildStage > buildList.getFirst().buildStage) {
        iterator.reset ();
        return null;
      }

      if (BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
        iterator.remove();
        if (slot.mode == Mode.ClearIfInvalid) {
          clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
        } else {
          builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
        }
      } else if (slot.mode == Mode.ClearIfInvalid) {
        if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
          iterator.remove();
          clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
        } else {
          if (canDestroy(builder, context, slot)) {
            consumeEnergyToDestroy(builder, slot);
            createDestroyItems(slot);

            result = slot;
            iterator.remove();
            clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));

            break;
          }
        }
      } else if (slot.mode == Mode.Build) {
        if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
          iterator.remove();
          builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
        } else {
          if (builder.consumeEnergy(BuilderAPI.BUILD_ENERGY) && firstSlotToConsume != null) {
            slot.addStackConsumed(firstSlotToConsume.decreaseStackInSlot(1));
            result = slot;
            iterator.remove();
            builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));

            break;
View Full Code Here


    int added = 0;

    for (int itemLoop = 0; itemLoop < stack.stackSize; ++itemLoop) { // add 1 item n times.

      int smallestStackSize = Integer.MAX_VALUE;
      IInvSlot minSlot = null;

      for (IInvSlot slot : InventoryIterator.getIterable(inventory, orientation)) {
        ItemStack stackInInventory = slot.getStackInSlot();

        if (stackInInventory == null) {
View Full Code Here

      if (!ai.success()) {
        terminate();
        return;
      }

      IInvSlot slot = InvUtils.getItem(robot, new ArrayStackOrListFilter(requested.stack));

      if (slot == null) {
        terminate();
        return;
      }

      if (requested.requester != null) {
        ItemStack newStack = ((IRequestProvider)
          requested.requester).provideItemsForRequest(requested.index,
              slot.getStackInSlot().copy());

        if (newStack == null || newStack.stackSize != slot.getStackInSlot().stackSize) {
          delivered = true;
          slot.setStackInSlot(newStack);
        }

        terminate();
      } else {
        startDelegateAI(new AIRobotUnload(robot));
View Full Code Here

          return;
        }

        if (furnace.getStackInSlot(FUEL_SLOT) == null) {
          IInvSlot s = InvUtils.getItem(robot, new FuelFilter());
          furnace.setInventorySlotContents(FUEL_SLOT, s.decreaseStackInSlot(1));
        }

        if (furnace.getStackInSlot(INPUT_SLOT) == null) {
          IInvSlot s = InvUtils.getItem(robot, new ArrayStackFilter(input));
          furnace.setInventorySlotContents(INPUT_SLOT, s.decreaseStackInSlot(1));
        }

        craftStarted = true;

        if (!robot.hasFreeSlot()) {
View Full Code Here

TOP

Related Classes of buildcraft.api.core.IInvSlot

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.