mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-10-04 02:41:52 +02:00
Fix passive spawning, disable some debug logging
This commit is contained in:
parent
960b578ad0
commit
133ea93259
@ -618,7 +618,12 @@ local function initial_spawn_check(state, node, spawn_def)
|
|||||||
local function log_fail(reason)
|
local function log_fail(reason)
|
||||||
local count = (counts[reason] or 0) + 1
|
local count = (counts[reason] or 0) + 1
|
||||||
counts[reason] = count
|
counts[reason] = count
|
||||||
--minetest.log("Spawn check for "..tostring(spawn_def and spawn_def.name).." failed - "..reason.." ("..count..")")
|
if logging then
|
||||||
|
minetest.log("Spawn check for "..tostring(spawn_def and spawn_def.name).." failed - "..reason.." ("..count..") "..dump({
|
||||||
|
state = state,
|
||||||
|
node = node,
|
||||||
|
}))
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -701,6 +706,9 @@ local function build_state_for_position(pos, parent_state)
|
|||||||
local node = get_node(pos)
|
local node = get_node(pos)
|
||||||
local node_name = node.name
|
local node_name = node.name
|
||||||
|
|
||||||
|
-- Make sure we can spawn here
|
||||||
|
if not node or node_name == "ignore" or node_name == "mcl_core:bedrock" then return end
|
||||||
|
|
||||||
-- Check if it's ground
|
-- Check if it's ground
|
||||||
local is_water = get_item_group(node_name, "water") ~= 0
|
local is_water = get_item_group(node_name, "water") ~= 0
|
||||||
local is_ground = false
|
local is_ground = false
|
||||||
@ -709,14 +717,12 @@ local function build_state_for_position(pos, parent_state)
|
|||||||
if not is_ground then
|
if not is_ground then
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
node = get_node(pos)
|
node = get_node(pos)
|
||||||
|
node_name = node.name
|
||||||
is_ground = get_item_group(node_name,"solid") ~= 0
|
is_ground = get_item_group(node_name,"solid") ~= 0
|
||||||
end
|
end
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make sure we can spawn here
|
|
||||||
if not node or node_name == "ignore" or node_name == "mcl_core:bedrock" then return end
|
|
||||||
|
|
||||||
-- Build spawn state data
|
-- Build spawn state data
|
||||||
local state = {
|
local state = {
|
||||||
spawn_hostile = true,
|
spawn_hostile = true,
|
||||||
@ -728,8 +734,8 @@ local function build_state_for_position(pos, parent_state)
|
|||||||
state.dimension = dimension
|
state.dimension = dimension
|
||||||
|
|
||||||
state.is_ground = is_ground and get_item_group(node_name, "leaves") == 0
|
state.is_ground = is_ground and get_item_group(node_name, "leaves") == 0
|
||||||
state.grass = get_item_group(node_name, "grass_block") ~= 0
|
state.is_grass = get_item_group(node_name, "grass_block") ~= 0
|
||||||
state.water = is_water
|
state.is_water = is_water
|
||||||
|
|
||||||
-- Check light level
|
-- Check light level
|
||||||
local gotten_light = get_node_light(pos)
|
local gotten_light = get_node_light(pos)
|
||||||
@ -940,13 +946,13 @@ if mobs_spawn then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mob_chance_offset = math_random(1, 1e6) / 1e6 * cumulative_chance
|
local mob_chance_offset = math_random(1, 1e6) / 1e6 * cumulative_chance
|
||||||
minetest.log("action", "mob_chance_offset = "..tostring(mob_chance_offset).."/"..tostring(cumulative_chance))
|
--minetest.log("action", "mob_chance_offset = "..tostring(mob_chance_offset).."/"..tostring(cumulative_chance))
|
||||||
|
|
||||||
for i = 1,#spawn_table do
|
for i = 1,#spawn_table do
|
||||||
local mob_def = spawn_table[i]
|
local mob_def = spawn_table[i]
|
||||||
local mob_chance = mob_def.chance
|
local mob_chance = mob_def.chance
|
||||||
if mob_chance_offset <= mob_chance then
|
if mob_chance_offset <= mob_chance then
|
||||||
minetest.log(mob_def.name.." "..mob_chance)
|
--minetest.log(mob_def.name.." "..mob_chance)
|
||||||
return mob_def
|
return mob_def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user