From 2203d0df530c559dc21e2f064b341694c264c22c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 1 Apr 2019 10:59:36 +0200 Subject: [PATCH] Revert "Make item entities a bit more efficient" This reverts commit ba97dfd02ff849f8df53126834a8907b51794711 because it broke item entities. --- mods/ENTITIES/mcl_item_entity/init.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7491285c3a..f44917ccf3 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -88,15 +88,6 @@ minetest.register_globalstep(function(dtime) -- Magnet else - --move this to the front so players can see animation before collection - if not collected then - if object:get_luaentity()._magnet_timer > 1 then - object:get_luaentity()._magnet_timer = -item_drop_settings.magnet_time - object:get_luaentity()._magnet_active = false - elseif object:get_luaentity()._magnet_timer < 0 then - object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime - end - end object:get_luaentity()._magnet_active = true object:get_luaentity()._collector_timer = 0 @@ -104,7 +95,11 @@ minetest.register_globalstep(function(dtime) -- Move object to player disable_physics(object, object:get_luaentity()) - object:move_to(checkpos) + local opos = object:get_pos() + local vec = vector.subtract(checkpos, opos) + vec = vector.add(opos, vector.divide(vec, 2)) + object:move_to(vec) + --fix eternally falling items minetest.after(0, function(object) @@ -148,6 +143,15 @@ minetest.register_globalstep(function(dtime) end end + if not collected then + if object:get_luaentity()._magnet_timer > 1 then + object:get_luaentity()._magnet_timer = -item_drop_settings.magnet_time + object:get_luaentity()._magnet_active = false + elseif object:get_luaentity()._magnet_timer < 0 then + object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime + end + end + end end