@@ -4,12 +4,13 @@ import io.github.pylonmc.pylon.core.item.PylonItem
44import io.github.pylonmc.pylon.core.item.base.VanillaCookingFuel
55import io.github.pylonmc.pylon.core.item.base.VanillaCookingItem
66import io.github.pylonmc.pylon.core.item.base.VanillaCraftingItem
7- import io.github.pylonmc.pylon.core.item.base.VanillaSmithingMaterial
87import io.github.pylonmc.pylon.core.item.base.VanillaSmithingMineral
98import io.github.pylonmc.pylon.core.item.base.VanillaSmithingTemplate
109import io.github.pylonmc.pylon.core.item.research.Research.Companion.canCraft
10+ import io.github.pylonmc.pylon.core.recipe.vanilla.CookingRecipeWrapper
1111import io.github.pylonmc.pylon.core.recipe.vanilla.VanillaRecipeType
1212import io.github.pylonmc.pylon.core.util.isPylonAndIsNot
13+ import io.github.pylonmc.pylon.core.util.isPylonSimilar
1314import org.bukkit.Bukkit
1415import org.bukkit.Keyed
1516import org.bukkit.block.Furnace
@@ -51,12 +52,14 @@ internal object PylonRecipeListener : Listener {
5152
5253 @EventHandler(priority = EventPriority .LOWEST )
5354 private fun onCook (e : BlockCookEvent ) {
54- if (PylonItem .fromStack(e.result ) == null ) return
55+ if (PylonItem .fromStack(e.source ) == null ) return
5556
57+ var pylonRecipe: CookingRecipeWrapper ? = null
5658 for (recipe in RecipeType .vanillaCookingRecipes()) {
57- if (recipe.recipe.inputChoice.test(e.result )) {
59+ if (recipe.key !in VanillaRecipeType .nonPylonRecipes && recipe.recipe. inputChoice.test(e.source )) {
5860 e.result = recipe.recipe.result.clone()
59- return
61+ pylonRecipe = recipe
62+ break
6063 }
6164 }
6265 }
@@ -71,14 +74,16 @@ internal object PylonRecipeListener : Listener {
7174 val furnace = (e.block.state as Furnace )
7275 val input = furnace.inventory.smelting
7376 if (input != null && input.isPylonAndIsNot<VanillaCookingItem >()) {
74- var isProcessingPylonRecipe = false
77+ var pylonRecipe : CookingRecipeWrapper ? = null
7578 for (recipe in RecipeType .vanillaCookingRecipes()) {
7679 if (recipe.key !in VanillaRecipeType .nonPylonRecipes && recipe.recipe.inputChoice.test(input)) {
77- isProcessingPylonRecipe = true
80+ pylonRecipe = recipe
7881 break
7982 }
8083 }
81- if (! isProcessingPylonRecipe) {
84+ val isFurnaceOutputValidToPutRecipeResultIn = pylonRecipe != null
85+ && (furnace.inventory.result == null || pylonRecipe.isOutput(furnace.inventory.result!! ))
86+ if (pylonRecipe == null || ! isFurnaceOutputValidToPutRecipeResultIn) {
8287 e.isCancelled = true
8388 }
8489 }
0 commit comments