#Smelting Result By ID

15 messages · Page 1 of 1 (latest)

gentle girder
#

Hello, is there a way to get the result of a smelting recipe from the ingredient id? So for example from 'minecraft:coal_ore' i would get 'minecraft:coal' without iterating over all recipes?

near jackalBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fading slate
#

What would this be useful for?
As this may be an XY problem

shell hatchBOT
#

The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.

This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.

Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.

gentle girder
fading slate
#

There is event.forEachRecipe which may help you

gentle girder
#

yeah but it iterates over all recipes, and it will get laggy pretty quick

fading slate
#

You can specify the recipe filter, and do stuff depending on recipe's inputs, outputs, id, etc.

fading slate
gentle girder
#

well i thought that maybe with input item and the recipe type out of the way, there would be a way to avoid iterating over all recipes

#

but thanks for letting me know, appreciate it :)

shell hatchBOT
#

This is an example of how to use .forEachRecipe() for changing or adding new recipes using existing ones.

ServerEvents.recipes(e => {
  // 2x slabs -> 1x plank through shaped crafting
  e.forEachRecipe({ type: 'minecraft:crafting_shaped', output: '#minecraft:slabs' }, r => {
    let ingredients = r.originalRecipeIngredients // returns a List<Ingredient>
    let output = r.originalRecipeResult           // returns an ItemStack
    e.shaped(ingredients[0], ['S', 'S'], { S: output })
  })

  // 1x stair -> 1x plank through stonecutting
  e.forEachRecipe({ type: 'minecraft:stonecutting', output: '#minecraft:stairs' }, r => {
    let ingredients = r.originalRecipeIngredients
    let output = r.originalRecipeResult
    e.stonecutting(ingredients[0], output)
  })

  // change the output from logs to planks from 4x to 2x (this will replace old recipe)
  e.forEachRecipe({ type: 'minecraft:crafting_shapeless', input: '#minecraft:logs', output: '#minecraft:planks' }, r => {
    let ingredients = r.originalRecipeIngredients
    let output = r.originalRecipeResult
    e.shapeless(Item.of(output.id, 2), ingredients[0]).id(r.getId())
  })
})
fading slate
#

e stands for event, r stands for recipe

gentle girder
#

yeah i get the grip, thank you

shell hatchBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.