order of events
Posted: Sun May 14, 2017 2:19 pm
Hi,
is it somewhere documented in which order the events will be executes inside one mod?
I registered an on_tick and an on_player_tool_inventory_changed event and the on_tick event fired before the other one. I was a little bit surprised because I saved the LuaItemStack of the tool and wanted to access it. To prevent an invalid stack or adjust values based on the used tool, I wanted to use the on_*_changed event. When I removed my iron-axe from the slot, the on_tick event fires and my function tries to access the now invalid stack. So if I save the stack somewhere I have to verify it before each use and makes the on_*_changed useless. I also tested with on_player_main_inventory_changed and on_player_quickbar_inventory_changed, both are executed after on_tick, but the actual action (removing the item from the inventory, caused by the player) was done before on_tick. I would expect the reverse order.
TLDR: please execute on_player_*_inventory_changed before on_tick.
is it somewhere documented in which order the events will be executes inside one mod?
I registered an on_tick and an on_player_tool_inventory_changed event and the on_tick event fired before the other one. I was a little bit surprised because I saved the LuaItemStack of the tool and wanted to access it. To prevent an invalid stack or adjust values based on the used tool, I wanted to use the on_*_changed event. When I removed my iron-axe from the slot, the on_tick event fires and my function tries to access the now invalid stack. So if I save the stack somewhere I have to verify it before each use and makes the on_*_changed useless. I also tested with on_player_main_inventory_changed and on_player_quickbar_inventory_changed, both are executed after on_tick, but the actual action (removing the item from the inventory, caused by the player) was done before on_tick. I would expect the reverse order.
TLDR: please execute on_player_*_inventory_changed before on_tick.