Prevent crashes when dispensers/droppers operate on/with unknowns (#4764)
Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4764 Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land> Co-authored-by: Mikita Wiśniewski <rudzik8@protonmail.com> Co-committed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
This commit is contained in:
parent
20f01a8ef7
commit
a93690c6fb
@ -127,6 +127,9 @@ local dispenserdef = {
|
||||
end
|
||||
local dropnode = minetest.get_node(droppos)
|
||||
local dropnodedef = minetest.registered_nodes[dropnode.name]
|
||||
if not dropnodedef then
|
||||
dropnodedef = minetest.registered_nodes["mapgen_stone"]
|
||||
end
|
||||
local stacks = {}
|
||||
for i = 1, inv:get_size("main") do
|
||||
local stack = inv:get_stack("main", i)
|
||||
@ -140,7 +143,7 @@ local dispenserdef = {
|
||||
local dropitem = ItemStack(stack)
|
||||
dropitem:set_count(1)
|
||||
local stack_id = stacks[r].stackpos
|
||||
local stackdef = stack:get_definition()
|
||||
local stackdef = core.registered_items[stack:get_name()]
|
||||
|
||||
if not stackdef then
|
||||
return
|
||||
|
@ -125,6 +125,9 @@ local dropperdef = {
|
||||
local dropnode = minetest.get_node(droppos)
|
||||
-- Do not drop into solid nodes, unless they are containers
|
||||
local dropnodedef = minetest.registered_nodes[dropnode.name]
|
||||
if not dropnodedef then
|
||||
dropnodedef = minetest.registered_nodes["mapgen_stone"]
|
||||
end
|
||||
if dropnodedef.groups.container == 2 then
|
||||
-- If they are containers - double down as hopper
|
||||
mcl_util.hopper_push(pos, droppos)
|
||||
@ -143,6 +146,11 @@ local dropperdef = {
|
||||
local r = math.random(1, #stacks)
|
||||
local stack = stacks[r].stack
|
||||
local dropitem = ItemStack(stack)
|
||||
local stackdef = core.registered_items[stack:get_name()]
|
||||
if not stackdef then
|
||||
return
|
||||
end
|
||||
|
||||
dropitem:set_count(1)
|
||||
local stack_id = stacks[r].stackpos
|
||||
local pos_variation = 100
|
||||
|
Loading…
Reference in New Issue
Block a user