forked from MineClone5/MineClone5
fix crash and world loading issue
This commit fixes the crash when placing a lodestone or even a normal compass in an item frame, and lodestones now work after reloading the world
This commit is contained in:
parent
98f2bd1a20
commit
a493a6cd5c
|
@ -17,7 +17,7 @@ local random_frame = math.random(0, compass_frames-1)
|
|||
|
||||
function mcl_compass.get_compass_image(pos, dir, x, y, z)
|
||||
-- Compasses do not work in certain zones
|
||||
if mcl_worlds.compass_works(pos) then
|
||||
if mcl_worlds.compass_works(pos) and x ~= nil and y ~= nil and z ~= nil then
|
||||
local _, dim = mcl_worlds.y_to_layer(y)
|
||||
local _, playerdim = mcl_worlds.y_to_layer(pos.y)
|
||||
|
||||
|
@ -39,7 +39,7 @@ function mcl_compass.get_compass_image(pos, dir, x, y, z)
|
|||
return random_frame
|
||||
end
|
||||
else
|
||||
if x ~= 0 and y ~= 0 and z~= 0 then
|
||||
if x ~= 0 and y ~= 0 and z~= 0 and x ~= nil and y ~= nil and x~= nil then
|
||||
local _, dim = mcl_worlds.y_to_layer(y)
|
||||
local _, playerdim = mcl_worlds.y_to_layer(pos.y)
|
||||
if dim == playerdim then --already explained that very same if statement above
|
||||
|
@ -98,15 +98,20 @@ minetest.register_globalstep(function(dtime)
|
|||
compass_image = mcl_compass.get_compass_image(pos, player:get_look_horizontal(), 0, 0, 0) --no lodestone meta
|
||||
else
|
||||
checkblock = {x = x, y = y, z = z}
|
||||
local function get_far_node(pos) --function that tries to read node normally, and does it even if its unloaded https://dev.minetest.net/minetest.get_node
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "ignore" then
|
||||
minetest.get_voxel_manip():read_from_map(pos, pos)
|
||||
node = minetest.get_node(pos)
|
||||
end
|
||||
return node
|
||||
end
|
||||
|
||||
if minetest.get_node(checkblock).name == "mcl_compass:lodestone" then --check if lodestone still exists
|
||||
if get_far_node(checkblock).name == "mcl_compass:lodestone" then --check if lodestone still exists
|
||||
compass_image = mcl_compass.get_compass_image(pos, player:get_look_horizontal(), x, y, z)
|
||||
compass_image = compass_image .. "_lodestone"
|
||||
else -- lodestone got destroyed
|
||||
stack:get_meta():set_string("x", "")
|
||||
stack:get_meta():set_string("y", "")
|
||||
stack:get_meta():set_string("z", "")
|
||||
compass_image = mcl_compass.get_compass_image(pos, player:get_look_horizontal(), 0, 0, 0)
|
||||
compass_image = random_frame .. "_lodestone"
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue