diff options
author | the lemons <citrons@mondecitronne.com> | 2022-02-12 02:37:21 -0600 |
---|---|---|
committer | the lemons <citrons@mondecitronne.com> | 2022-02-12 02:37:21 -0600 |
commit | 2f0a46d6f23ccab7816bb4634db4bf977903a3e3 (patch) | |
tree | 66c023828e39c72f200365fd6632770658043cdb | |
parent | 06450dcc221a5c1adda4a300b7891cbdf4fbbb4e (diff) |
align the entity of the item stack with the node hitbox, but also break item stacks again
-rw-r--r-- | mods/vzxv_itemstacks/container.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mods/vzxv_itemstacks/container.lua b/mods/vzxv_itemstacks/container.lua index 8fd3bf5..a0e709a 100644 --- a/mods/vzxv_itemstacks/container.lua +++ b/mods/vzxv_itemstacks/container.lua @@ -21,11 +21,13 @@ minetest.register_entity("vzxv_itemstacks:itemstack",{ }, on_activate = function(self) local ent = self.object - container_entities[minetest.hash_node_position(ent:get_pos())] = ent + local pos = vzxv.round_pos(ent:get_pos()) + container_entities[minetest.hash_node_position(pos)] = ent end, on_deactivate = function(self) local ent = self.object - container_entities[minetest.hash_node_position(ent:get_pos())] = nil + local pos = vzxv.round_pos(ent:get_pos()) + container_entities[minetest.hash_node_position(pos)] = nil end, }) @@ -33,6 +35,11 @@ local function get_container_entity(pos) return container_entities[minetest.hash_node_position(pos)] end +local function add_container_entity(pos) + pos = {x = pos.x, y = pos.y - 0.20, z = pos.z} + minetest.add_entity(pos, "vzxv_itemstacks:itemstack") +end + local function remove_container_entity(pos) local h = minetest.hash_node_position(pos) if container_entities[h] then @@ -58,7 +65,7 @@ function vzxv.set_container_stack(pos, stack) local entity = get_container_entity(pos) if stack and not entity then - minetest.add_entity(pos, "vzxv_itemstacks:itemstack") + add_container_entity(pos) entity = get_container_entity(pos) elseif not stack and entity then remove_container_entity(pos) @@ -81,7 +88,7 @@ minetest.register_lbm { local entity = get_container_entity(pos) if stack and not stack:is_empty() then if not entity then - minetest.add_entity(pos, "vzxv_itemstacks:itemstack") + add_container_entity(pos) entity = get_container_entity(pos) end update_container_entity(entity, stack) |