From 0a45486304955f21a7d65e187afe868228ee6882 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 25 Aug 2022 20:30:10 +0200 Subject: [PATCH] Make items not drop into blocks on playerdeath --- mods/PLAYER/mcl_death_drop/init.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index 5ea548ecc..9b1bad75f 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -33,21 +33,20 @@ minetest.register_on_dieplayer(function(player) end local listname = mcl_death_drop.registered_dropped_lists[l].listname 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 for i, stack in ipairs(inv:get_list(listname)) do - local x = random(0, 9)/3 - local z = random(0, 9)/3 - pos.x = pos.x + x - pos.z = pos.z + z + local p = vector.offset(dropspots[math.random(#dropspots)],math.random()-0.5,math.random()-0.5,math.random()-0.5) 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()] if def and def.on_drop then - stack = def.on_drop(stack, player, pos) + stack = def.on_drop(stack, player, p) end - minetest.add_item(pos, stack) + minetest.add_item(p, stack) end - pos.x = pos.x - x - pos.z = pos.z - z end inv:set_list(listname, {}) end