Package net.minecraft.inventory

Examples of net.minecraft.inventory.IInventory


   * wildcard when item == null, counts all types of items
   */
  private boolean hasItemCount(int startSlot, int countSlots, ItemStack item, int itemCount) {
    int count = 0;

    IInventory tradeInventory = this.getOrCreateTradeInventory();
    for (int i = startSlot; i < startSlot + countSlots; i++) {
      ItemStack itemInSlot = tradeInventory.getStackInSlot(i);
      if (itemInSlot == null)
        continue;
      if (item == null || StackUtils.isIdenticalItem(itemInSlot, item))
        count += itemInSlot.stackSize;
      if (count >= itemCount)
View Full Code Here


   */
  private float percentOccupied(int startSlot, int countSlots, ItemStack item) {
    int count = 0;
    int total = 0;

    IInventory tradeInventory = this.getOrCreateTradeInventory();
    for (int i = startSlot; i < startSlot + countSlots; i++) {
      ItemStack itemInSlot = tradeInventory.getStackInSlot(i);
      if (itemInSlot == null) {
        total += 64;
      } else {
        total += itemInSlot.getMaxStackSize();
        if (item == null || StackUtils.isIdenticalItem(itemInSlot, item))
View Full Code Here

  public boolean hasPaperMin(int count) {
    return hasItemCount(TradeStation.SLOT_LETTERS_1, TradeStation.SLOT_LETTERS_COUNT, new ItemStack(Items.paper), count);
  }

  public boolean hasInputBufMin(float percentage) {
    IInventory inventory = getOrCreateTradeInventory();
    ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD);
    if (tradeGood == null)
      return true;
    return percentOccupied(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood) > percentage;
  }
View Full Code Here

  public boolean hasPostageMin(int postage) {

    int posted = 0;

    IInventory tradeInventory = this.getOrCreateTradeInventory();
    for (int i = TradeStation.SLOT_STAMPS_1; i < TradeStation.SLOT_STAMPS_1 + TradeStation.SLOT_STAMPS_COUNT; i++) {
      ItemStack stamp = tradeInventory.getStackInSlot(i);
      if (stamp == null)
        continue;
      if (!(stamp.getItem() instanceof IStamps))
        continue;
View Full Code Here

    return getOrCreateTradeInventory().isItemValidForSlot(slotIndex, itemstack);
  }

  @Override
  public boolean canInsertItem(int i, ItemStack itemstack, int j) {
    IInventory inventory = getOrCreateTradeInventory();
    if (inventory instanceof TradeStation)
      return ((TradeStation)getOrCreateTradeInventory()).canInsertItem(i, itemstack, j);
    return super.canInsertItem(i, itemstack, j);
  }
View Full Code Here

    return super.canInsertItem(i, itemstack, j);
  }

  @Override
  public boolean canExtractItem(int i, ItemStack itemstack, int j) {
    IInventory inventory = getOrCreateTradeInventory();
    if (inventory instanceof TradeStation) {
      boolean permission = (getAccess() == EnumAccess.SHARED);
      return ((TradeStation) getOrCreateTradeInventory()).canExtractItem(i, itemstack, j, permission);
    }
    return super.canExtractItem(i, itemstack, j);
View Full Code Here

    return super.canExtractItem(i, itemstack, j);
  }

  @Override
  public int[] getAccessibleSlotsFromSide(int side) {
    IInventory inventory = getOrCreateTradeInventory();
    if (inventory instanceof TradeStation) {
      boolean permission = (getAccess() == EnumAccess.SHARED);
      return ((TradeStation) getOrCreateTradeInventory()).getAccessibleSlotsFromSide(side, permission);
    }
    return super.getAccessibleSlotsFromSide(side);
View Full Code Here

  /* IMAILCONTAINER */
  @Override
  public boolean hasMail() {

    IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile());
    for (int i = 0; i < mailInventory.getSizeInventory(); i++)
      if (mailInventory.getStackInSlot(i) != null)
        return true;

    return false;
  }
View Full Code Here

  @Override
  public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {

    ItemStack product = null;
    IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile());

    for (int i = 0; i < mailInventory.getSizeInventory(); i++) {
      ItemStack slotStack = mailInventory.getStackInSlot(i);
      if (slotStack == null)
        continue;

      product = slotStack;
      if (doRemove)
        mailInventory.setInventorySlotContents(i, null);
      break;
    }

    if (product != null)
      return new ItemStack[] { product };
View Full Code Here

  }

  public static List<IInventory> getAdjacentInventories(World world, int i, int j, int k, Class<? extends IInventory> type) {
    List<IInventory> list = new ArrayList<IInventory>(5);
    for (int side = 0; side < 6; side++) {
      IInventory inv = getInventoryFromSide(world, i, j, k, ForgeDirection.getOrientation(side), type, null);
      if (inv != null)
        list.add(inv);
    }
    return list;
  }
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.