registerConditionalDispenseBehavior allows you to register a new dispense behavior that will only be applied if the condition predicate is met, performing the original behavior if not. As this original behavior is cached when the method is called, it'll support multiple mods adding new behavior to the same item.
It turns out using a predicate fixed all those problems I had with data syncing and fail sounds and whatnot, because the new behavior should only ever activate when it will be successful.
I put the method in DataUtil because I saw a few other registry things there, but I'll happily move it to a different class if I need to.
registerConditionalDispenseBehavior
allows you to register a new dispense behavior that will only be applied if thecondition
predicate is met, performing the original behavior if not. As this original behavior is cached when the method is called, it'll support multiple mods adding new behavior to the same item.It turns out using a predicate fixed all those problems I had with data syncing and fail sounds and whatnot, because the new behavior should only ever activate when it will be successful.
I put the method in
DataUtil
because I saw a few other registry things there, but I'll happily move it to a different class if I need to.