コード例 #1
0
 @Override
 public void onInventoryChanged() {
   for (int i = 0; i < 6; i++) {
     for (int j = 0; j < 3; j++) {
       SocketModule m = getSide(ForgeDirection.getOrientation(i));
       m.onInventoryChange(configs[i], j, this, ForgeDirection.getOrientation(i), false);
     }
   }
 }
コード例 #2
0
  public int addItemInternal(ItemStack stack, boolean doAdd, int inv) {
    int amntAdded;
    int temp;

    if (inv > -1 && inv < 3) {
      ItemStack currStack = inventory.getStackInSlot(inv);

      if (currStack == null) {
        if (doAdd) {
          inventory.setInventorySlotContents(inv, stack.copy());
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), true);
          }
        }

        return stack.stackSize;
      } else if (currStack.isItemEqual(stack)) {
        temp =
            Math.min(
                currStack.stackSize + stack.stackSize, currStack.getItem().getItemStackLimit());
        if (temp == (currStack.stackSize + stack.stackSize)) {
          amntAdded = stack.stackSize;
        } else {
          amntAdded = currStack.getItem().getItemStackLimit() - currStack.stackSize;
        }

        if (doAdd && amntAdded > 0) {
          currStack.stackSize += amntAdded;
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), true);
          }
        }

        return amntAdded;
      }
    }

    return 0;
  }
コード例 #3
0
  public ItemStack extractItemInternal(boolean doRemove, int inv, int maxItemCount) {
    ItemStack newStack;

    if (inv > -1 && inv < 3) {
      ItemStack currStack = inventory.getStackInSlot(inv);

      if (currStack != null) {
        newStack = currStack.copy();
        newStack.stackSize = Math.min(currStack.stackSize, maxItemCount);
        if (doRemove) {
          currStack.stackSize -= newStack.stackSize;
          if (currStack.stackSize <= 0) inventory.setInventorySlotContents(inv, null);
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), false);
          }
        }

        return newStack;
      }
    }

    return null;
  }