Fix a bug when trying to place snow on an unknown node.

This commit is contained in:
Splizard 2014-06-09 13:30:08 +12:00
parent 2c83d5ed76
commit b2663d0ae3
1 changed files with 9 additions and 4 deletions

View File

@ -81,9 +81,11 @@ end
--This function places snow checking at the same time for snow level and increasing as needed.
--This also takes into account sourrounding snow and makes snow even.
function snow.place(pos)
local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
local node = minetest.get_node(pos)
local drawtype = minetest.registered_nodes[node.name].drawtype
local node = minetest.get_node_or_nil(pos)
local drawtype = ""
if node and minetest.registered_nodes[node.name] then
drawtype = minetest.registered_nodes[node.name].drawtype
end
local bnode = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if node.name == "default:snow" and minetest.get_node_level(pos) < 63 then
@ -124,7 +126,10 @@ snow.is_uneven = function(pos)
for z=-1,1 do
local node = get_node({x=pos.x+x,y=pos.y,z=pos.z+z})
local bnode = get_node({x=pos.x+x,y=pos.y-1,z=pos.z+z})
local drawtype = minetest.registered_nodes[node.name].drawtype
local drawtype
if node and minetest.registered_nodes[node.name] then
drawtype = minetest.registered_nodes[node.name].drawtype
end
if drawtype == "plantlike" then
if bnode.name == "default:dirt_with_grass" then