if (!inventory.hasIngredient()) {
return;
}
ItemStack ingredient = inventory.getIngredient();
ItemStack result = ((TimedCraftable) ingredient.getMaterial()).getResult();
FurnaceSmeltEvent event = VanillaPlugin.getInstance().getEngine().getEventManager().callEvent(new FurnaceSmeltEvent(this, new MaterialCause(ingredient.getMaterial(), this.getBlock()), ingredient, result));
if (!event.isCancelled()) {
if (inventory.getOutput() == null) {
inventory.setOutput(event.getResult());
} else {
result = event.getResult();
if (inventory.getOutput().getMaterial().getId() != result.getMaterial().getId()) {
throw new UnsupportedOperationException("Smelt result must be the same material as the output slot.");
}
inventory.addAmount(FurnaceInventory.OUTPUT_SLOT, result.getAmount());
}