Scarpet: Let `e~'health'` return a sensible value for item entities
James103 opened this issue ยท 1 comments
Currently (Carpet mod 1.4.79 in Minecraft 1.19), when querying e~'health'
on an item entity, the result is always null
, despite the item entities having a Health
value stored in its NBT (which, unlike living entities, is always an integer).
Workaround: Use e~'nbt':'Health'
, but this may incur a significant performance hit due to NBT access.
Sample script with workaround: /script run entity_load_handler('item', _(e, new) -> entity_event(e, 'on_removed', _(e) -> (print(player(), e~'nbt':'Health'))));
Sample script, querying health directly: /script run entity_load_handler('item', _(e, new) -> entity_event(e, 'on_removed', _(e) -> (print(player(), e~'health'))));
Use case: I would like to create a Scarpet app that keeps track of how many and what items were burned near a special entity, so as to give the player who placed that special entity credit for the items they burn. To do this, I need to listen to when an item entity is about to be removed, and if so, check whether their Health value is zero or negative, as I don't want items despawning due to age or hopper mechanics to count.