mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Add check for unknown nodes.
* Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability.
This commit is contained in:
parent
b9c2c3bd0a
commit
4a1b93bbfa
@ -478,7 +478,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||||||
-- Selected node needs to have 3 nodes of free space above
|
-- Selected node needs to have 3 nodes of free space above
|
||||||
for u=1, 3 do
|
for u=1, 3 do
|
||||||
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
||||||
if minetest.registered_nodes[node.name].walkable then
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
if ndef and ndef.walkable then
|
||||||
node_ok = false
|
node_ok = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -512,7 +513,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
|||||||
node_ok = true
|
node_ok = true
|
||||||
for u=1, 3 do
|
for u=1, 3 do
|
||||||
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
||||||
if minetest.registered_nodes[node.name].walkable then
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
if ndef and ndef.walkable then
|
||||||
node_ok = false
|
node_ok = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user