1
0
Fork 0

Make items not drop into blocks on playerdeath

mobs-redo
cora 2022-08-25 20:30:10 +02:00
parent 0385dd7cab
commit 0a45486304
1 changed files with 7 additions and 8 deletions

View File

@ -33,21 +33,20 @@ minetest.register_on_dieplayer(function(player)
end end
local listname = mcl_death_drop.registered_dropped_lists[l].listname local listname = mcl_death_drop.registered_dropped_lists[l].listname
local drop = mcl_death_drop.registered_dropped_lists[l].drop local drop = mcl_death_drop.registered_dropped_lists[l].drop
local dropspots = minetest.find_nodes_in_area(vector.offset(pos,-3,0,-3),vector.offset(pos,3,0,3),{"air"})
if #dropspots == 0 then
table.insert(dropspots,pos)
end
if inv then if inv then
for i, stack in ipairs(inv:get_list(listname)) do for i, stack in ipairs(inv:get_list(listname)) do
local x = random(0, 9)/3 local p = vector.offset(dropspots[math.random(#dropspots)],math.random()-0.5,math.random()-0.5,math.random()-0.5)
local z = random(0, 9)/3
pos.x = pos.x + x
pos.z = pos.z + z
if not void_deadly and drop and not mcl_enchanting.has_enchantment(stack, "curse_of_vanishing") then if not void_deadly and drop and not mcl_enchanting.has_enchantment(stack, "curse_of_vanishing") then
local def = minetest.registered_items[stack:get_name()] local def = minetest.registered_items[stack:get_name()]
if def and def.on_drop then if def and def.on_drop then
stack = def.on_drop(stack, player, pos) stack = def.on_drop(stack, player, p)
end end
minetest.add_item(pos, stack) minetest.add_item(p, stack)
end end
pos.x = pos.x - x
pos.z = pos.z - z
end end
inv:set_list(listname, {}) inv:set_list(listname, {})
end end