mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Handle bat and slime light checks
This commit is contained in:
parent
7577d37b38
commit
d2d7887e0f
4 changed files with 31 additions and 2 deletions
|
@ -287,6 +287,7 @@ function mcl_mobs.register_mob(name, def)
|
|||
spawn_in_group_min = def.spawn_in_group_min,
|
||||
noyaw = def.noyaw or false,
|
||||
particlespawners = def.particlespawners,
|
||||
spawn_check = def.spawn_check,
|
||||
-- End of MCL2 extensions
|
||||
on_spawn = def.on_spawn,
|
||||
on_blast = def.on_blast or function(self,damage)
|
||||
|
|
|
@ -742,11 +742,15 @@ local function spawn_check(pos, spawn_def)
|
|||
end
|
||||
elseif dimension == "overworld" then
|
||||
if mob_type == "monster" then
|
||||
if art_light <= overworld_threshold and sky_light <= overworld_sky_threshold then
|
||||
if mob_def.spawn_check then
|
||||
return mob_def.spawn_check(pos, gotten_light, art_light, sky_light)
|
||||
elseif art_light <= overworld_threshold and sky_light <= overworld_sky_threshold then
|
||||
return true
|
||||
end
|
||||
else
|
||||
if gotten_light > overworld_passive_threshold then
|
||||
if mob_def.spawn_check then
|
||||
return mob_def.spawn_check(pos, gotten_light, art_light, sky_light)
|
||||
elseif gotten_light > overworld_passive_threshold then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
local S = minetest.get_translator("mobs_mc")
|
||||
|
||||
local function spawn_check(pos, environmental_light, artificial_light, sky_light)
|
||||
local date = os.date("*t")
|
||||
local maxlight
|
||||
if (date.month == 10 and date.day >= 20) or (date.month == 11 and date.day <= 3) then
|
||||
maxlight = 6
|
||||
else
|
||||
maxlight = 3
|
||||
end
|
||||
|
||||
return artificial_light <= maxlight
|
||||
end
|
||||
|
||||
mcl_mobs.register_mob("mobs_mc:bat", {
|
||||
description = S("Bat"),
|
||||
type = "animal",
|
||||
|
@ -50,6 +62,7 @@ mcl_mobs.register_mob("mobs_mc:bat", {
|
|||
jump = false,
|
||||
fly = true,
|
||||
makes_footstep_sound = false,
|
||||
spawn_check = spawn_check,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -161,6 +161,16 @@ local spawn_children_on_die = function(child_mob, spawn_distance, eject_speed)
|
|||
end
|
||||
end
|
||||
|
||||
local function slime_spawn_check(pos, environmental_light, artificial_light, sky_light)
|
||||
local maxlight = swamp_light_max
|
||||
|
||||
if is_slime_chunk(pos) then
|
||||
maxlight = minetest.LIGHT_MAX + 1
|
||||
end
|
||||
|
||||
return artificial_light <= maxlight
|
||||
end
|
||||
|
||||
-- Slime
|
||||
local slime_big = {
|
||||
description = S("Slime"),
|
||||
|
@ -213,6 +223,7 @@ local slime_big = {
|
|||
spawn_small_alternative = "mobs_mc:slime_small",
|
||||
on_die = spawn_children_on_die("mobs_mc:slime_small", 1.0, 1.5),
|
||||
use_texture_alpha = true,
|
||||
spawn_check = slime_spawn_check,
|
||||
}
|
||||
mcl_mobs.register_mob("mobs_mc:slime_big", slime_big)
|
||||
|
||||
|
|
Loading…
Reference in a new issue