/** * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't * full, etc. */ private boolean canSmelt() { if (this.slots[0] == null) { return false; } else { ItemStack itemstack = Melter_Recipes.smelting().getSmeltingResult(this.slots[0]); if (itemstack == null) return false; if (this.slots[2] == null) return true; if (!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } }
/** * Turn one item from the furnace source stack into the appropriate smelted item in the furnace * result stack */ public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = Melter_Recipes.smelting().getSmeltingResult(this.slots[0]); if (this.slots[2] == null) { this.slots[2] = itemstack.copy(); } else if (this.slots[2].isItemEqual(itemstack)) { this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize--; if (this.slots[0].stackSize <= 0) { this.slots[0] = null; } } }