Package net.minecraft.inventory

Examples of net.minecraft.inventory.IInventory


  }

  public static Map<Integer, IInventory> getAdjacentInventoryMap(World world, int i, int j, int k, Class<? extends IInventory> type) {
    Map<Integer, IInventory> map = new TreeMap<Integer, IInventory>();
    for (int side = 0; side < 6; side++) {
      IInventory inv = getInventoryFromSide(world, i, j, k, ForgeDirection.getOrientation(side), type, null);
      if (inv != null)
        map.put(side, inv);
    }
    return map;
  }
View Full Code Here


      return;
    }

    Recipe recipe = memorized.getRecipe(recipeIndex);
    recipe.sanitizeMatrix();
    IInventory matrix = recipe.getMatrix();
    if (matrix == null)
      return;

    for (int slot = 0; slot < matrix.getSizeInventory(); slot++) {
      craftingInventory.setInventorySlotContents(slot, matrix.getStackInSlot(slot));
    }
  }
View Full Code Here

      return;

    // Release inventory
    if (tile instanceof ITileStructure) {

      IInventory inventory = ((ITileStructure) tile).getInventory();
      if (inventory != null)
        for (int i = 0; i < inventory.getSizeInventory(); i++) {
          if (inventory.getStackInSlot(i) == null)
            continue;

          StackUtils.dropItemStackAsEntity(inventory.getStackInSlot(i), world, x, y, z);
          inventory.setInventorySlotContents(i, null);
        }

    } else {

      IInventory inventory;
      if (tile instanceof IInventory)
        inventory = (IInventory) tile;
      else
        inventory = tile.getInternalInventory();

      if (inventory != null) {
        for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {

          ItemStack itemstack = inventory.getStackInSlot(slot);

          if (itemstack == null)
            continue;

          float f = world.rand.nextFloat() * 0.8F + 0.1F;
          float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
          float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

          while (itemstack.stackSize > 0) {

            int stackPartial = world.rand.nextInt(21) + 10;
            if (stackPartial > itemstack.stackSize)
              stackPartial = itemstack.stackSize;
            ItemStack drop = itemstack.splitStack(stackPartial);
            EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, drop);
            float accel = 0.05F;
            entityitem.motionX = (float) world.rand.nextGaussian() * accel;
            entityitem.motionY = (float) world.rand.nextGaussian() * accel + 0.2F;
            entityitem.motionZ = (float) world.rand.nextGaussian() * accel;
            world.spawnEntityInWorld(entityitem);

          }

          inventory.setInventorySlotContents(slot, null);
        }
      }
    }

  }
View Full Code Here

      return;

    if (tile instanceof IInventory) {
      ((IInventory) tile).setInventorySlotContents(packet.slotIndex, packet.itemstack);
    } else if (tile instanceof TileForestry) {
      IInventory inventory = ((TileForestry) tile).getInternalInventory();

      if (inventory != null) inventory.setInventorySlotContents(packet.slotIndex, packet.itemstack);
    }
  }
View Full Code Here

  private void dumpToInventory(IInventory[] inventories) {

    ITileStructure central = getCentralTE();
    if (central == null)
      return;
    IInventory inv = central.getInventory();

    for (int i = TileFarmPlain.SLOT_PRODUCTION_1; i < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; i++) {
      if (inv.getStackInSlot(i) == null)
        continue;

      ItemStack stack = inv.getStackInSlot(i);

      if (stack.stackSize <= 0)
        continue;

      for (int j = 0; j < inventories.length; j++) {

        // Don't dump in arboretums!
        if (inventories[j].getSizeInventory() < 4)
          continue;

        // Get complete inventory (for double chests)
        IInventory inventory = Utils.getChest(inventories[j]);
        if (inventory instanceof ISidedInventory) {
          ISidedInventory sidedInventory = (ISidedInventory)inventory;
          int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal());
          for (int sl = 0; sl < slots.length; ++sl) {
            StackUtils.stowInInventory(stack, sidedInventory, true, sl, 1);
View Full Code Here

    return null;
  }

  @Override
  public int getSizeInventory() {
    IInventory inv = getStructureInventory();
    if (inv != null)
      return inv.getSizeInventory();
    else
      return 0;
  }
View Full Code Here

      return 0;
  }

  @Override
  public ItemStack getStackInSlot(int slotIndex) {
    IInventory inv = getStructureInventory();
    if (inv != null)
      return inv.getStackInSlot(slotIndex);
    else
      return null;
  }
View Full Code Here

      return null;
  }

  @Override
  public ItemStack decrStackSize(int slotIndex, int amount) {
    IInventory inv = getStructureInventory();
    if (inv != null)
      return inv.decrStackSize(slotIndex, amount);
    else
      return null;
  }
View Full Code Here

      return null;
  }

  @Override
  public ItemStack getStackInSlotOnClosing(int slotIndex) {
    IInventory inv = getStructureInventory();
    if (inv != null)
      return inv.getStackInSlotOnClosing(slotIndex);
    else
      return null;
  }
View Full Code Here

      return null;
  }

  @Override
  public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
    IInventory inv = getStructureInventory();
    if (inv != null)
      inv.setInventorySlotContents(slotIndex, itemstack);
  }
View Full Code Here

TOP

Related Classes of net.minecraft.inventory.IInventory

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.