team-abnormals / blueprint

Library that implements the framework of all Abnormals mods
https://www.curseforge.com/minecraft/mc-mods/blueprint
Other
114 stars 33 forks source link

Added a method for registering a dispense behavior that does not override the old one #55

Closed flowerfugue closed 3 years ago

flowerfugue commented 3 years ago

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.