#what does `ServerEvents.modifyRecipeIngredient` even do?
6 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
ServerEvents.modifyRecipeIngredient make use of the same class as ServerEvents.modifyRecipeResult, which is ModifyCraftingItemKubeEvent
This is actually the first time I even hear about modifyRecipeIngredient, its pretty much unused by the community, but going by what modifyRecipeResult does, which allows you to make a callback on recipe attempt and add or remove arbitrary code, such as copying enchantments/components from ingredient in recipe to recipe result, then modifyRecipeIngredient similarily should allow you to alter the ingredients on recipe craft; perhaps allowing something akin to the old Ender Shards from Extra Utilities (1) that had 8 uses that ticked down on crafts, disappearing on reaching 0
so extra is recipe ID?
I have no experience with the Ingredient version, but here's one of my own scripts that use .modifyRecipeResult, which again uses the same class
ServerEvents.recipes(event => {
event.shapeless(Item.of('project_unknown:cloak_of_perception', 1),
[
'project_unknown:cloak_of_perception',
'#project_unknown:cloak_filters'
]
).modifyResult('project_unknown:cloak_filter_edit') //custom ID to use later in modifyRecipeResult callback
})
ServerEvents.modifyRecipeResult('project_unknown:cloak_filter_edit', event => {
let cloak = event.grid.find('project_unknown:cloak_of_perception')
let skull = event.grid.find('#project_unknown:cloak_filters')
let oldFilter = cloak.getComponents().get($DataComponents.CUSTOM_DATA).copyTag().getString('project_unknown:mobfilter')
if(cloak_filters.containsKey(skull.id) && !oldFilter.includes(cloak_filters.get(skull.id))){
let padding = ','
if(oldFilter.length() == 0)
padding = ''
oldFilter += padding + cloak_filters.get(skull.id)
let newTag = cloak.getComponents().get($DataComponents.CUSTOM_DATA).copyTag()
newTag.putString('project_unknown:mobfilter', oldFilter)
$CustomData.set($DataComponents.CUSTOM_DATA, cloak, newTag)
event.success(cloak)
}
event.success(Item.of('air')) //returns an empty itemstack that cannot be clicked, if recipe fails
})
oh, it's just an ID for modifier then