[2.0.45] UndoRedoStack is not updated until after on_player_mined_entity
Posted: Fri Apr 25, 2025 12:49 am
When a player mines an entity, on_player_mined_entity event is triggered but the undo/redo stack is not updated yet with the newly mined entity. This causes a problem if the entity being mined has custom tags.
I would like to collect those tags within the on_player_mined_entity event and use LuaUndoRedoStack::set_undo_tag(...) to set those tags onto the entity within the undo stack. Then when the player triggers an undo, I can read those tags back in order to setup the custom entity correctly. The problem is that the undo stack isn't updated until after the original entity is destroyed, including its tags.
There would need to be similar consideration for on_player_mined_tile.
Alternatively (this would be a modding interface request) would it be possible to have a pointer to the undo/redo stack item included in the event data for all events that update the undo/redo stack?
I would like to collect those tags within the on_player_mined_entity event and use LuaUndoRedoStack::set_undo_tag(...) to set those tags onto the entity within the undo stack. Then when the player triggers an undo, I can read those tags back in order to setup the custom entity correctly. The problem is that the undo stack isn't updated until after the original entity is destroyed, including its tags.
There would need to be similar consideration for on_player_mined_tile.
Alternatively (this would be a modding interface request) would it be possible to have a pointer to the undo/redo stack item included in the event data for all events that update the undo/redo stack?