Merge pull request 'Don't spawn structure mobs in peaceful mode' (#2629) from fix_peaceful_structmobs into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2629 Reviewed-by: PrairieWind <prairie.astronomer1@gmail.com>mobs-redo
commit
e5f966067c
|
@ -434,7 +434,7 @@ local function spawn_check(pos,spawn_def)
|
||||||
is_ground = minetest.get_item_group(gotten_node,"solid") ~= 0
|
is_ground = minetest.get_item_group(gotten_node,"solid") ~= 0
|
||||||
end
|
end
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
|
local has_room = #minetest.find_nodes_in_area(pos,vector.offset(pos,0,1,0),{"air"}) or 0 >= 2
|
||||||
local is_water = get_item_group(gotten_node, "water") ~= 0
|
local is_water = get_item_group(gotten_node, "water") ~= 0
|
||||||
local is_lava = get_item_group(gotten_node, "lava") ~= 0
|
local is_lava = get_item_group(gotten_node, "lava") ~= 0
|
||||||
local is_leaf = get_item_group(gotten_node, "leaves") ~= 0
|
local is_leaf = get_item_group(gotten_node, "leaves") ~= 0
|
||||||
|
@ -452,6 +452,7 @@ local function spawn_check(pos,spawn_def)
|
||||||
and biome_check(spawn_def.biomes, gotten_biome)
|
and biome_check(spawn_def.biomes, gotten_biome)
|
||||||
and (is_ground or spawn_def.type_of_spawning ~= "ground")
|
and (is_ground or spawn_def.type_of_spawning ~= "ground")
|
||||||
and (spawn_def.type_of_spawning ~= "ground" or not is_leaf)
|
and (spawn_def.type_of_spawning ~= "ground" or not is_leaf)
|
||||||
|
and (spawn_def.type_of_spawning ~= "ground" or has_room)
|
||||||
and (spawn_def.check_position and spawn_def.check_position(pos) or true)
|
and (spawn_def.check_position and spawn_def.check_position(pos) or true)
|
||||||
and (not is_farm_animal(spawn_def.name) or is_grass)
|
and (not is_farm_animal(spawn_def.name) or is_grass)
|
||||||
and (spawn_def.type_of_spawning ~= "water" or is_water)
|
and (spawn_def.type_of_spawning ~= "water" or is_water)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local modpath = minetest.get_modpath(modname)
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false)
|
||||||
|
|
||||||
mcl_structures.register_structure("pillager_outpost",{
|
mcl_structures.register_structure("pillager_outpost",{
|
||||||
place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass","group:sand"},
|
place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass","group:sand"},
|
||||||
|
@ -65,6 +66,7 @@ mcl_structures.register_structure("pillager_outpost",{
|
||||||
def.on_construct(n)
|
def.on_construct(n)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not peaceful then
|
||||||
if sp and #sp > 0 then
|
if sp and #sp > 0 then
|
||||||
for i=1,5 do
|
for i=1,5 do
|
||||||
local pos = sp[pr:next(1,#sp)]
|
local pos = sp[pr:next(1,#sp)]
|
||||||
|
@ -78,4 +80,5 @@ mcl_structures.register_structure("pillager_outpost",{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,14 +2,19 @@ local modname = minetest.get_current_modname()
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local modpath = minetest.get_modpath(modname)
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
|
||||||
|
local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false)
|
||||||
|
|
||||||
local function spawn_witch(p1,p2)
|
local function spawn_witch(p1,p2)
|
||||||
local c = minetest.find_node_near(p1,15,{"mcl_cauldrons:cauldron"})
|
local c = minetest.find_node_near(p1,15,{"mcl_cauldrons:cauldron"})
|
||||||
if c then
|
if c then
|
||||||
local nn = minetest.find_nodes_in_area_under_air(vector.new(p1.x,c.y-1,p1.z),vector.new(p2.x,c.y-1,p2.z),{"mcl_core:sprucewood"})
|
local nn = minetest.find_nodes_in_area_under_air(vector.new(p1.x,c.y-1,p1.z),vector.new(p2.x,c.y-1,p2.z),{"mcl_core:sprucewood"})
|
||||||
local witch = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:witch"):get_luaentity()
|
local witch
|
||||||
local cat = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat"):get_luaentity()
|
if not peaceful then
|
||||||
|
witch = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:witch"):get_luaentity()
|
||||||
witch._home = c
|
witch._home = c
|
||||||
witch.can_despawn = false
|
witch.can_despawn = false
|
||||||
|
end
|
||||||
|
local cat = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat"):get_luaentity()
|
||||||
cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}})
|
cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}})
|
||||||
cat.owner = "!witch!" --so it's not claimable by player
|
cat.owner = "!witch!" --so it's not claimable by player
|
||||||
cat._home = c
|
cat._home = c
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local modpath = minetest.get_modpath(modname)
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false)
|
||||||
|
|
||||||
mcl_structures.register_structure("woodland_cabin",{
|
mcl_structures.register_structure("woodland_cabin",{
|
||||||
place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass"},
|
place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass"},
|
||||||
|
@ -22,6 +23,7 @@ mcl_structures.register_structure("woodland_cabin",{
|
||||||
local p1=vector.offset(p,-def.sidelen,-1,-def.sidelen)
|
local p1=vector.offset(p,-def.sidelen,-1,-def.sidelen)
|
||||||
local p2=vector.offset(p,def.sidelen,def.sidelen,def.sidelen)
|
local p2=vector.offset(p,def.sidelen,def.sidelen,def.sidelen)
|
||||||
local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon)
|
local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon)
|
||||||
|
if not peaceful then
|
||||||
if sp and #sp > 0 then
|
if sp and #sp > 0 then
|
||||||
for i=1,5 do
|
for i=1,5 do
|
||||||
local pos = sp[pr:next(1,#sp)]
|
local pos = sp[pr:next(1,#sp)]
|
||||||
|
@ -34,6 +36,7 @@ mcl_structures.register_structure("woodland_cabin",{
|
||||||
minetest.add_entity(pos,"mobs_mc:evoker")
|
minetest.add_entity(pos,"mobs_mc:evoker")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local parrot = minetest.find_node_near(p,25,{"mcl_heads:wither_skeleton"})
|
local parrot = minetest.find_node_near(p,25,{"mcl_heads:wither_skeleton"})
|
||||||
if parrot then
|
if parrot then
|
||||||
minetest.add_entity(parrot,"mobs_mc:parrot")
|
minetest.add_entity(parrot,"mobs_mc:parrot")
|
||||||
|
|
Loading…
Reference in New Issue