mirror of
https://github.com/minetest/minetest_game.git
synced 2024-11-08 08:43:51 +01:00
Fix crash if bones punched by non-player (#3146)
This commit is contained in:
parent
d89170c129
commit
4e402ec39f
@ -16,6 +16,27 @@ local function is_owner(pos, name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function drop(pos, itemstack)
|
||||||
|
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
||||||
|
if obj then
|
||||||
|
obj:set_velocity({
|
||||||
|
x = math.random(-10, 10) / 9,
|
||||||
|
y = 5,
|
||||||
|
z = math.random(-10, 10) / 9,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drop_contents(pos)
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
|
||||||
|
for i = 1, inv:get_size("main") do
|
||||||
|
local stk = inv:get_stack("main", i)
|
||||||
|
drop(pos, stk)
|
||||||
|
end
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
local bones_formspec =
|
local bones_formspec =
|
||||||
"size[8,9]" ..
|
"size[8,9]" ..
|
||||||
"list[current_name;main;0,0.3;8,4;]" ..
|
"list[current_name;main;0,0.3;8,4;]" ..
|
||||||
@ -87,6 +108,11 @@ local bones_def = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not player:is_player() then
|
||||||
|
drop_contents(pos)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.get_meta(pos):get_string("infotext") == "" then
|
if minetest.get_meta(pos):get_string("infotext") == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -171,17 +197,6 @@ local function may_replace(pos, player)
|
|||||||
return node_definition.buildable_to
|
return node_definition.buildable_to
|
||||||
end
|
end
|
||||||
|
|
||||||
local drop = function(pos, itemstack)
|
|
||||||
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
|
||||||
if obj then
|
|
||||||
obj:set_velocity({
|
|
||||||
x = math.random(-10, 10) / 9,
|
|
||||||
y = 5,
|
|
||||||
z = math.random(-10, 10) / 9,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local player_inventory_lists = { "main", "craft" }
|
local player_inventory_lists = { "main", "craft" }
|
||||||
bones.player_inventory_lists = player_inventory_lists
|
bones.player_inventory_lists = player_inventory_lists
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user