forked from Mineclonia/Mineclonia
(Hopefully) fix hand rarely dropping as item
This commit is contained in:
parent
44f4db844e
commit
861174dc32
|
@ -67,7 +67,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
|
|
||||||
-- Collection
|
-- Collection
|
||||||
if vector.distance(checkpos, object:getpos()) <= item_drop_settings.radius_collect and not object:get_luaentity()._collected then
|
if vector.distance(checkpos, object:getpos()) <= item_drop_settings.radius_collect and not object:get_luaentity()._removed then
|
||||||
|
|
||||||
if object:get_luaentity().itemstring ~= "" then
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||||
|
@ -88,7 +88,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Destroy entity
|
-- Destroy entity
|
||||||
|
|
||||||
-- This just prevents this sectino to be run again because object:remove() doesn't remove the item immediately.
|
-- This just prevents this sectino to be run again because object:remove() doesn't remove the item immediately.
|
||||||
object:get_luaentity()._collected = true
|
object:get_luaentity()._removed = true
|
||||||
object:remove()
|
object:remove()
|
||||||
collected = true
|
collected = true
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||||
if not object:get_luaentity()._collected then
|
if not object:get_luaentity()._removed then
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
max_hear_distance = 16,
|
max_hear_distance = 16,
|
||||||
|
@ -137,7 +137,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
check_pickup_achievements(object, player)
|
check_pickup_achievements(object, player)
|
||||||
object:get_luaentity()._collected = true
|
object:get_luaentity()._removed = true
|
||||||
object:remove()
|
object:remove()
|
||||||
else
|
else
|
||||||
enable_physics(object, object:get_luaentity())
|
enable_physics(object, object:get_luaentity())
|
||||||
|
@ -252,7 +252,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||||
name = item:get_name()
|
name = item:get_name()
|
||||||
end
|
end
|
||||||
for i=1,count do
|
for i=1,count do
|
||||||
local obj = minetest.add_item(pos, name)
|
local obj = core.add_item(pos, name)
|
||||||
if obj ~= nil then
|
if obj ~= nil then
|
||||||
local x = math.random(1, 5)
|
local x = math.random(1, 5)
|
||||||
if math.random(1,2) == 1 then
|
if math.random(1,2) == 1 then
|
||||||
|
@ -386,6 +386,7 @@ core.register_entity(":__builtin:item", {
|
||||||
age = self.age,
|
age = self.age,
|
||||||
_insta_collect = self._insta_collect,
|
_insta_collect = self._insta_collect,
|
||||||
_flowing = self._flowing,
|
_flowing = self._flowing,
|
||||||
|
_removed = self._removed,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -404,10 +405,16 @@ core.register_entity(":__builtin:item", {
|
||||||
-- If true, can collect item without delay
|
-- If true, can collect item without delay
|
||||||
self._insta_collect = data._insta_collect
|
self._insta_collect = data._insta_collect
|
||||||
self._flowing = data._flowing
|
self._flowing = data._flowing
|
||||||
|
self._removed = data._removed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.itemstring = staticdata
|
self.itemstring = staticdata
|
||||||
end
|
end
|
||||||
|
if self._removed then
|
||||||
|
self._removed = true
|
||||||
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
if self._insta_collect == nil then
|
if self._insta_collect == nil then
|
||||||
-- Intentionally default, since delayed collection is rare
|
-- Intentionally default, since delayed collection is rare
|
||||||
self._insta_collect = true
|
self._insta_collect = true
|
||||||
|
@ -439,8 +446,6 @@ core.register_entity(":__builtin:item", {
|
||||||
if count > max_count then
|
if count > max_count then
|
||||||
overflow = true
|
overflow = true
|
||||||
count = count - max_count
|
count = count - max_count
|
||||||
else
|
|
||||||
self.itemstring = ''
|
|
||||||
end
|
end
|
||||||
local pos = object:getpos()
|
local pos = object:getpos()
|
||||||
pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15
|
pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15
|
||||||
|
@ -456,6 +461,7 @@ core.register_entity(":__builtin:item", {
|
||||||
visual_size = {x = s, y = s},
|
visual_size = {x = s, y = s},
|
||||||
collisionbox = {-c, -c, -c, c, c, c}
|
collisionbox = {-c, -c, -c, c, c, c}
|
||||||
})
|
})
|
||||||
|
self._removed = true
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
-- merging succeeded
|
-- merging succeeded
|
||||||
return true
|
return true
|
||||||
|
@ -481,12 +487,15 @@ core.register_entity(":__builtin:item", {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
if self._removed then
|
||||||
|
return
|
||||||
|
end
|
||||||
self.age = self.age + dtime
|
self.age = self.age + dtime
|
||||||
if self._collector_timer ~= nil then
|
if self._collector_timer ~= nil then
|
||||||
self._collector_timer = self._collector_timer + dtime
|
self._collector_timer = self._collector_timer + dtime
|
||||||
end
|
end
|
||||||
if time_to_live > 0 and self.age > time_to_live then
|
if time_to_live > 0 and self.age > time_to_live then
|
||||||
self.itemstring = ''
|
self._removed = true
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -521,6 +530,7 @@ core.register_entity(":__builtin:item", {
|
||||||
if def.groups.lava then
|
if def.groups.lava then
|
||||||
minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.5})
|
minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.5})
|
||||||
end
|
end
|
||||||
|
self._removed = true
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue