2020-03-30 22:43:46 +02:00
|
|
|
if minetest.settings:get_bool("creative_mode") then
|
2020-03-30 22:41:58 +02:00
|
|
|
function minetest.handle_node_drops(pos, drops, digger)
|
|
|
|
if not digger or not digger:is_player() then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local inv = digger:get_inventory()
|
|
|
|
if inv then
|
|
|
|
for _,item in ipairs(drops) do
|
|
|
|
item = ItemStack(item):get_name()
|
|
|
|
if not inv:contains_item("main", item) then
|
|
|
|
inv:add_item("main", item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
function minetest.handle_node_drops(pos, drops, digger)
|
|
|
|
local function drop(item)
|
|
|
|
local count = ItemStack(item):get_count()
|
|
|
|
local name = ItemStack(item):get_name()
|
|
|
|
for i=1,count do
|
|
|
|
local obj = minetest.add_item(pos, name)
|
|
|
|
if obj ~= nil then
|
|
|
|
obj:get_luaentity().collect = true
|
|
|
|
local k = 1
|
|
|
|
if name == "default:cobble" then
|
|
|
|
k = math.random(3,6)
|
|
|
|
end
|
|
|
|
local x = math.random(1, 5)/k
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
x = -x
|
|
|
|
end
|
|
|
|
local z = math.random(1, 5)/k
|
|
|
|
if math.random(1,2) == 1 then
|
|
|
|
z = -z
|
|
|
|
end
|
2020-03-30 22:43:46 +02:00
|
|
|
obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z})
|
2020-03-30 22:41:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function drop_all()
|
|
|
|
for _, item in ipairs(drops) do
|
|
|
|
drop(item)
|
|
|
|
end
|
|
|
|
end
|
2020-03-30 22:43:46 +02:00
|
|
|
if ALWAYS_DROP_NODES_AS_ITEMS and minetest.get_item_group(minetest.get_node(pos).name, "drop_on_dig") == 1 then
|
2020-03-30 22:41:58 +02:00
|
|
|
drop_all()
|
|
|
|
elseif digger and digger:get_inventory() then
|
|
|
|
for _, dropped_item in ipairs(drops) do
|
|
|
|
if digger:get_inventory():room_for_item("main", dropped_item) then
|
|
|
|
digger:get_inventory():add_item("main", dropped_item)
|
|
|
|
else
|
|
|
|
drop(dropped_item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
drop_all()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|