Examples of ISidedInventory


Examples of net.minecraft.inventory.ISidedInventory

  public static ItemStack extractItemStackFromInventory(IInventory inventory, int side) {

    ItemStack retStack = null;

    if (inventory instanceof ISidedInventory) {
      ISidedInventory sidedInv = (ISidedInventory) inventory;
      int slots[] = sidedInv.getAccessibleSlotsFromSide(side);
      for (int i = 0; i < slots.length && retStack == null; i++) {
        if (sidedInv.getStackInSlot(i) != null && sidedInv.canExtractItem(i, sidedInv.getStackInSlot(i), side)) {
          retStack = sidedInv.getStackInSlot(i).copy();
          sidedInv.setInventorySlotContents(i, null);
        }
      }
    } else {
      for (int i = 0; i < inventory.getSizeInventory() && retStack == null; i++) {
        if (inventory.getStackInSlot(i) != null) {
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

      return null;
    }
    int stackSize = stack.stackSize;

    if (inventory instanceof ISidedInventory) {
      ISidedInventory sidedInv = (ISidedInventory) inventory;
      int slots[] = sidedInv.getAccessibleSlotsFromSide(side);

      if (slots == null) {
        return stack;
      }
      for (int i = 0; i < slots.length && stack != null; i++) {
        if (sidedInv.canInsertItem(slots[i], stack, side) && ItemHelper.itemsEqualWithMetadata(stack, inventory.getStackInSlot(slots[i]), true)) {
          stack = addToOccupiedInventorySlot(sidedInv, slots[i], stack);
        }
      }
      for (int i = 0; i < slots.length && stack != null; i++) {
        if (sidedInv.canInsertItem(slots[i], stack, side) && inventory.getStackInSlot(slots[i]) == null) {
          stack = addToEmptyInventorySlot(sidedInv, slots[i], stack);
        }
      }
    } else {
      int invSize = inventory.getSizeInventory();
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

    if (stack == null) {
      return null;
    }
    if (inventory instanceof ISidedInventory) {
      ISidedInventory sidedInv = (ISidedInventory) inventory;
      int slots[] = sidedInv.getAccessibleSlotsFromSide(side);

      if (slots == null) {
        return stack;
      }
      for (int i = 0; i < slots.length && stack != null; i++) {
        if (sidedInv.canInsertItem(slots[i], stack, side) && ItemHelper.itemsEqualWithMetadata(stack, inventory.getStackInSlot(slots[i]), true)) {
          stack = simulateAddToOccupiedInventorySlot(sidedInv, slots[i], stack);
        }
      }
      for (int i = 0; i < slots.length && stack != null; i++) {
        if (sidedInv.canInsertItem(slots[i], stack, side) && inventory.getStackInSlot(slots[i]) == null) {
          stack = simulateAddToEmptyInventorySlot(sidedInv, slots[i], stack);
        }
      }
    } else {
      int invSize = inventory.getSizeInventory();
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

      return false;
    }
    if(!(te instanceof IInventory)) {
      return false;
    }
    ISidedInventory target;
    if(te instanceof ISidedInventory) {
      target = (ISidedInventory) te;
    } else {
      target = new InventoryWrapper((IInventory) te);
    }

    int[] targetSlots = target.getAccessibleSlotsFromSide(dir.getOpposite().ordinal());
    if(targetSlots == null) {
      return false;
    }

    for (int inputSlot = slotDefinition.minInputSlot; inputSlot <= slotDefinition.maxInputSlot; inputSlot++) {
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

          }
        }
      }
      else if (tileEntity instanceof ISidedInventory)
      {
        ISidedInventory inventory = (ISidedInventory) tileEntity;
        int[] slots = inventory.getAccessibleSlotsFromSide(direction.ordinal());
        for (int i = 0; i < slots.length; i++)
        {
          if (inventory.canInsertItem(slots[i], itemStack, direction.ordinal()))
          {
            itemStack = this.addStackToInventory(slots[i], inventory, itemStack);
          }
          if (itemStack == null)
          {
            return null;
          }
        }

      }
      else if (tileEntity instanceof IInventory)
      {
        IInventory inventory = (IInventory) tileEntity;

        for (int i = 0; i < inventory.getSizeInventory(); i++)
        {
          itemStack = this.addStackToInventory(i, inventory, itemStack);
          if (itemStack == null)
          {
            return null;
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

      {
        ret[i] = inv.getStackInSlot(i) != null ? inv.getStackInSlot(i).copy() : null;
      }
    }
    else {
      ISidedInventory sidedInventory = (ISidedInventory)inv;
      int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());

      if(slots == null || slots.length == 0)
      {
        return null;
      }

      for(int get = 0; get <= slots.length - 1; get++)
      {
        int slotID = slots[get];

        ret[slotID] = sidedInventory.getStackInSlot(slotID) != null ? sidedInventory.getStackInSlot(slotID).copy() : null;
      }
    }

    return ret;
  }
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

          }
        }
      }
    }
    else {
      ISidedInventory sidedInventory = (ISidedInventory)inv;
      int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());

      if(slots != null && slots.length != 0)
      {
        if(stack.pathType != Path.HOME && sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
        {
          slots = sidedInventory.getAccessibleSlotsFromSide(1);
        }

        for(int get = 0; get <= slots.length - 1; get++)
        {
          int slotID = slots[get];

          if(stack.pathType != Path.HOME)
          {
            if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal()))
            {
              continue;
            }
          }
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

          }
        }
      }
    }
    else {
      ISidedInventory sidedInventory = (ISidedInventory)inventory;
      int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());

      if(slots != null && slots.length != 0)
      {
        /*if(sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
        {
          slots = sidedInventory.getAccessibleSlotsFromSide(1);
        }*/

        for(int get = 0; get <= slots.length - 1; get++)
        {
          int slotID = slots[get];

          if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal()))
          {
            continue;
          }

          ItemStack inSlot = testInv[slotID];
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

            continue;
          }
         
          if(chest.getValue() instanceof ISidedInventory)
          {
            ISidedInventory sided = (ISidedInventory)chest.getValue();
            if(!sided.canExtractItem(stack.getKey(), stack.getValue(), chest.getKey().ordinal()))
            {
              continue;
            }
          }
         
View Full Code Here

Examples of net.minecraft.inventory.ISidedInventory

          }
        }
      }
    }
    else {
      ISidedInventory sidedInventory = (ISidedInventory)inventory;
      int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]);

      if(slots != null && slots.length != 0)
      {
        for(int get = slots.length - 1; get >= 0; get--)
        {
          int slotID = slots[get];

          if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(slotID), type))
          {
            ItemStack stack = sidedInventory.getStackInSlot(slotID);
            int current = ret.getStack() != null ? ret.getStack().stackSize : 0;

            if(current+stack.stackSize <= max)
            {
              ItemStack copy = stack.copy();

              if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.OPPOSITES[side]))
              {
                ret.appendStack(slotID, copy);
              }
            }
            else {
              ItemStack copy = stack.copy();

              if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.OPPOSITES[side]))
              {
                copy.stackSize = max-current;
                ret.appendStack(slotID, copy);
              }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.