Package forestry.core.utils

Examples of forestry.core.utils.ItemInventory


    case BackpackGUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;
      return new GuiBackpack(new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped)));

    case BackpackT2GUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;
      return new GuiBackpackT2(new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped)));

    case LepidopteristBackpackGUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;
View Full Code Here


    case BackpackGUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;

      return new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped));

    case BackpackT2GUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;

      return new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped));

    case LepidopteristBackpackGUI:
      equipped = getBackpackItem(player);
      if (equipped == null)
        return null;
View Full Code Here

  }

  public ItemStack tryStowing(EntityPlayer player, ItemStack backpackStack, ItemStack stack) {

    ItemBackpack backpack = ((ItemBackpack) backpackStack.getItem());
    ItemInventory inventory = new ItemInventory(ItemBackpack.class, backpack.getBackpackSize(), backpackStack);
    if (backpackStack.getItemDamage() == 1)
      return stack;

    Event event = new BackpackStowEvent(player, backpack.getDefinition(), inventory, stack);
    MinecraftForge.EVENT_BUS.post(event);
    if (stack.stackSize <= 0)
      return null;
    if (event.isCanceled())
      return stack;

    ItemStack remainder = InvTools.moveItemStack(stack, inventory);
    stack.stackSize = remainder == null ? 0 : remainder.stackSize;

    inventory.save();
    return null;
  }
View Full Code Here

      // Must have inventory slots
      if (inventory.getSizeInventory() <= 0)
        return true;

      // Create our own backpack inventory
      ItemInventory backpackInventory = new ItemInventory(ItemBackpack.class, getBackpackSize(), stack);

      BackpackMode mode = getMode(stack);
      if (mode == BackpackMode.RECEIVE)
        tryChestReceive(player, backpackInventory, inventory);
      else
        tryChestTransfer(backpackInventory, inventory);

      backpackInventory.save();

      return true;
    }

    return false;
View Full Code Here

  }

  @SuppressWarnings({"rawtypes", "unchecked"})
  @Override
  public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
    ItemInventory inventory = new ItemInventory(ItemBackpack.class, getBackpackSize(), itemstack);

    // HashMap<ItemStack, Integer> contents = new HashMap<ItemStack,
    // Integer>();
    int occupied = 0;

    for (int i = 0; i < inventory.getSizeInventory(); i++) {
      if (inventory.getStackInSlot(i) == null)
        continue;
      if (inventory.getStackInSlot(i).stackSize <= 0)
        continue;

      // Count the slot as occupied
      occupied++;
    }
View Full Code Here

        continue;
      }

      // Load their inventory
      ItemBackpack packItem = ((ItemBackpack) backpack.getItem());
      ItemInventory backpackinventory = new ItemInventory(ItemBackpack.class, packItem.getBackpackSize(), backpack);
      Event event = new BackpackResupplyEvent(player, packItem.getDefinition(), backpackinventory);
      MinecraftForge.EVENT_BUS.post(event);
      if (event.isCanceled())
        continue;

      boolean inventoryChanged = false;
      // Cycle through their contents
      for (int i = 0; i < backpackinventory.getSizeInventory(); i++) {

        ItemStack packstack = backpackinventory.getStackInSlot(i);
        if (packstack == null)
          continue;
        if (packstack.stackSize <= 0)
          continue;

        // Try to add it to the player's inventory and note any change
        boolean change = topOffPlayerInventory(player, packstack);
        if (!inventoryChanged)
          inventoryChanged = change;

        // Clear consumed stacks
        if (packstack.stackSize <= 0)
          backpackinventory.setInventorySlotContents(i, null);
      }
      // Save the backpack inventory if it changed
      if (inventoryChanged)
        backpackinventory.onGuiSaved(player);

    }
  }
View Full Code Here

TOP

Related Classes of forestry.core.utils.ItemInventory

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.