A lot of mods need to know when an item is added in the player inventory or removed (from any source like pickup or remove/add from a contained), most of them just check every ticks and it's pretty heavy in performance wise.
So why not just add an event that add a hook like minecraft do for their achievement with InventoryChangeTrigger.
What are your thoughts on that ?
it's pretty heavy in performance wise.
proof? Just waving your hands and saying "performance!" does not mean there is a performance problem.
proof? Just waving your hands and saying "performance!" does not mean there is a performance problem.
Well, i'm sure you can see why having a multiple mods checking 20 time by second if each slot of an inventory have changed and that for each items they want to check is way heavier compared to a hook that will be trigerred only one time when a slot change.
Minecraft have choose the hook for the achievement instead of the tick one.
There is inherently a performance concern with mechanics of the game that are written which reply on tick-based conditional logic for detecting and acting upon state changes. Issues of this kind are exacerbated by any number of mods which add content of this sort. In order to remedy this concern, designs which introduce pub-sub and observer based patterns reduce the tick overhead by removal of mass code. The implementation of a potential solution is where performance metrics guide finding the most practical yet optimized design.
yes, but forge isn't and can't be in the business of making large modifications of the game's core design aspects like that.
I am not suggesting making any modifications to the game's code more than the patches required to add a typical hook. One event which already exists which is similar to this proposed idea is LivingEquipmentChangeEvent.
The same argument can be applied to any inventory, not only player inventories.
This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!
This issue has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.
Most helpful comment
I am not suggesting making any modifications to the game's code more than the patches required to add a typical hook. One event which already exists which is similar to this proposed idea is
LivingEquipmentChangeEvent.