コード例 #1
0
  public void smeltItem() {
    if (canSmelt()) {
      ItemStack itemStack = BrickOvenRecipeHandler.instance().findMatchingRecipe(this);

      if (ovenStacks[OUTPUT] == null) {
        ovenStacks[OUTPUT] = itemStack.copy();
      } else if (ovenStacks[OUTPUT].getItem() == itemStack.getItem()) {
        ovenStacks[OUTPUT].stackSize += itemStack.stackSize;
      }

      for (int i = INPUTSTART; i < ovenStacks.length; ++i) {
        ItemStack stack = ovenStacks[i];

        if (stack != null) {
          ItemStack containerItem = null;

          if (ovenStacks[i].getItem().hasContainerItem(ovenStacks[i])) {
            containerItem = ovenStacks[i].getItem().getContainerItem(ovenStacks[i]);
          }

          --ovenStacks[i].stackSize;

          if (ovenStacks[i].stackSize <= 0) {
            ovenStacks[i] = null;
          }

          if (containerItem != null) {
            ovenStacks[i] = containerItem;
          }
        }
      }
    }
  }
コード例 #2
0
  private boolean canSmelt() {
    boolean empty = true;
    for (int i = INPUTSTART; i < ovenStacks.length; ++i) {
      if (ovenStacks[i] != null) {
        empty = false;
        break;
      }
    }

    if (empty) {
      return false;
    } else {
      ItemStack stack = BrickOvenRecipeHandler.instance().findMatchingRecipe(this);
      if (stack == null) {
        return false;
      }

      if (ovenStacks[OUTPUT] == null) {
        return true;
      }
      if (!ovenStacks[OUTPUT].isItemEqual(stack)) {
        return false;
      }

      int result = ovenStacks[OUTPUT].stackSize + stack.stackSize;
      return result <= getInventoryStackLimit() && result <= ovenStacks[OUTPUT].getMaxStackSize();
    }
  }