#Is there a way to *literally* match input tag when doing an ingredient replacement?

35 messages · Page 1 of 1 (latest)

worthy verge
#

For example, the intent of the below code is to take recipe that has a treated wood slabs as input and replace it with treated wood planks

event.replaceInput(
  { input: '#forge:treated_wood_slab' },
  '#forge:treated_wood_slab',
  '#forge:treated_wood'
)

But this, of course, also includes recipes that just use #minecraft:slabs because treated wood slabs are IN minecraft slabs

last heronBOT
#

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

worthy verge
#

Bump, I forgot i posted this already and ran into the issue again

#

This would also be nice to literally match ingredients, example: I want to match an item, but NOT tags that item is a member of (example, if i want to match create:raw_zinc but NOT #forge:raw_materials/zinc)

#

Similarly but with slightly different nuance, I might want to match members of a tag only and not any aditional tags those ingredients are members of (example, anything in #forge:crops/rice but NOT #forge:crops)

worthy verge
#

Bumping again

worthy verge
#

Further bump

#

To clarify ahead of time, yes I know I can remove treated wood slabs from the #minecraft:slabs tag but that's not a solution

lost thunder
#

how many treated wood slabs are in forge treated slabs

#

if it is not many you could probably do it individually

#

@worthy verge

worthy verge
#

I've already done it, but that's not a solution

#

It's a workaround, and one that doesn't work half the time, especially in the additional examples

lost thunder
#

Honestly something are just broken at times especially related to mods and custom recipes

#

just to clarify so i can do some testing what mod are the treated slabs from? @worthy verge

worthy verge
#

Immersive Engineering

#

Yes it works in this case, but it's not broken behavior it's just unintuitive logcial behavior

#

Example in the OP isn't "replace any input that uses treated wood slabs," it's "replace any input that accepts treated wood slabs"

worthy verge
#

Thus i'm looking for some kind of way to literally match

wanton basin
#

forEachRecipe and write a custom match logic

#

then add the modified recipe with the same id as the original

worthy verge
#

I see, so in the body I'd do something like get the originalRecipeIngredients, check the list for a tag (which in this case will hopefully match literally since i'm actually checking the ingredients), and then if and only if true do a replaceIngredient

wanton basin
#

apart from the comment this should work

event.forEachRecipe({ input: '#forge:treated_wood_slab' }, recipe => {
  recipe.originalRecipeIngredients.forEach(ingredient => {
    if(ingredient.tag == '#forge:treated_wood_slab'){ //check if with # or without
      event.replaceInput(
        { id: recipe.getOrCreateId() },
        '#forge:treated_wood_slab',
        '#forge:treated_wood'
      )
      break
    }
  })
})
worthy verge
#

OOOOOH

#

THAT'S CLEVER

#

though I'm not sure the break is nessecary is it, especially if there are mutliple matching the tag

wanton basin
#

it would work without the break, it just stops it from doing uneccesary calculations

worthy verge
#

the break would break out of the the second foreach though, which is problematic if there are multiple ingredients that use the tag (for example it uses TWO treated wood slabs, it would only find the first one and break, if i'm reading correctly)

wanton basin
#

It's using replaceInput so applying to the entire recipe

worthy verge
#

OHH sure is

#

that still leaves an edge case of "uses both an ingredient you want to replace and one you don't that would be hit"

wanton basin
#

If it's a recipe with Mixed Inputs you would need to either do that manually or do more complicated logic

worthy verge
#

I haven't had a chance to try this yet but i see no reason it shouldn't work, anything else would be a different support question as this answers my original one pretty effectively. Closing, and thank you a bunch!