In two of my mods I use the "preplayermineditem" events to simulate picking up entities contents and all by storing the inventory contents onpreplayermineditem, emptying the entity inventory contents and then letting the game pick up the empty inventory (chest). When it gets placed back down later I use onbuilt to restore the inventory contents.
As it is now, the game empties the entire chest before calling onpreplayermineditem so it's always empty by the time the script sees it was mined.
What's expected:
- Player mines entity: onpreplayermineditem is called
- Standard inventory transfer of any items still in the chest are performed
- If the inventory transfer was successful: onplayermineditem is called for the contents of the inventory
- Player mines entity:
- Standard inventory transfer of any items in the chest are performed
- If the inventory transfer was successful: onpreplayermineditem is called
- onplayermineditem is called for the contents of the inventory