コード例 #1
0
  public void smeltItem() {
    if (!canSmelt()) {
      return;
    }

    ItemStack itemstack;

    if (inventory[0].getItem().hasContainerItem()) {
      itemstack = MachineRecipes.getOutput(inventory[0], false, recipes).copy();
      inventory[0] = new ItemStack(inventory[0].getItem().getContainerItem());
    } else {
      itemstack = MachineRecipes.getOutput(inventory[0], true, recipes).copy();
    }

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

    if (inventory[2] == null) {
      inventory[2] = itemstack;
    } else {
      inventory[2].stackSize += itemstack.stackSize;
    }
  }
コード例 #2
0
  public boolean canSmelt() {
    if (inventory[0] == null) {
      return false;
    }

    ItemStack itemstack = MachineRecipes.getOutput(inventory[0], false, recipes);

    if (itemstack == null) {
      return false;
    }

    if (inventory[2] == null) {
      return true;
    }

    if (!inventory[2].isItemEqual(itemstack)) {
      return false;
    } else {
      return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize();
    }
  }