Provide actual ItemStack in on(_robot)_built_entity
Posted: Wed Jul 05, 2017 6:18 pm
Currently, there is no easy way to get the actual ItemStack that is being used for building an entity in a reliable way.
My use case here is copying the inventory of an item-with-inventory into the entity its being placed (a container) without loosing any state (item-with-inventory, blueprints, item-with-tags, labels, etc.)
My actual solution is to create the entity myself in on_put_item and use the player's cursor_stack to transfer the inventory to the created entity, but it has a major drawback:
I can't differentiate between the user placing a ghost and the user placing a real entity, which means a real entity will always be built even if the player intended to place a ghost.
For robots (on_robot_built_entity), the issue is worse since there is no way to access the real ItemStack at all (you only get the item name and its tags).
My suggestion is to add a new event parameter to on_robot_built_entity and on_built_entity. This parameter could either be a LuaItemStack or a LuaInventory (much like the buffer parameter to on_player_mined_entity) and it would contain the single item that was used to build the entity
My use case here is copying the inventory of an item-with-inventory into the entity its being placed (a container) without loosing any state (item-with-inventory, blueprints, item-with-tags, labels, etc.)
My actual solution is to create the entity myself in on_put_item and use the player's cursor_stack to transfer the inventory to the created entity, but it has a major drawback:
I can't differentiate between the user placing a ghost and the user placing a real entity, which means a real entity will always be built even if the player intended to place a ghost.
For robots (on_robot_built_entity), the issue is worse since there is no way to access the real ItemStack at all (you only get the item name and its tags).
My suggestion is to add a new event parameter to on_robot_built_entity and on_built_entity. This parameter could either be a LuaItemStack or a LuaInventory (much like the buffer parameter to on_player_mined_entity) and it would contain the single item that was used to build the entity