From 962425faa574cf268b15753d45799c8ba41c7b8a Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 6 Sep 2022 12:45:38 +0200 Subject: [PATCH 1/3] Don't spawn structure mobs in peaceful mode --- mods/ENTITIES/mcl_mobs/spawning.lua | 3 +- .../mcl_structures/pillager_outpost.lua | 39 ++++++++++--------- mods/MAPGEN/mcl_structures/witch_hut.lua | 11 ++++-- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index bdfe1398fe..4a7b678856 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -434,7 +434,7 @@ local function spawn_check(pos,spawn_def) is_ground = minetest.get_item_group(gotten_node,"solid") ~= 0 end 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_lava = get_item_group(gotten_node, "lava") ~= 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 (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 has_room) 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 (spawn_def.type_of_spawning ~= "water" or is_water) diff --git a/mods/MAPGEN/mcl_structures/pillager_outpost.lua b/mods/MAPGEN/mcl_structures/pillager_outpost.lua index 9b916bdca4..a70c9c2d2d 100644 --- a/mods/MAPGEN/mcl_structures/pillager_outpost.lua +++ b/mods/MAPGEN/mcl_structures/pillager_outpost.lua @@ -1,6 +1,7 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) +local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false) mcl_structures.register_structure("pillager_outpost",{ place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass","group:sand"}, @@ -55,26 +56,28 @@ mcl_structures.register_structure("pillager_outpost",{ }} }, after_place = function(p,def,pr) - local p1 = vector.offset(p,-7,0,-7) - local p2 = vector.offset(p,7,14,7) - local spawnon = {"mcl_core:stripped_oak"} - local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon) - for _,n in pairs(minetest.find_nodes_in_area(p1,p2,{"group:wall"})) do - local def = minetest.registered_nodes[minetest.get_node(n).name:gsub("_%d+$","")] - if def and def.on_construct then - def.on_construct(n) - end - end - if sp and #sp > 0 then - for i=1,5 do - local pos = sp[pr:next(1,#sp)] - if pos then - minetest.add_entity(pos,"mobs_mc:pillager") + if not peaceful then + local p1 = vector.offset(p,-7,0,-7) + local p2 = vector.offset(p,7,14,7) + local spawnon = {"mcl_core:stripped_oak"} + local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon) + for _,n in pairs(minetest.find_nodes_in_area(p1,p2,{"group:wall"})) do + local def = minetest.registered_nodes[minetest.get_node(n).name:gsub("_%d+$","")] + if def and def.on_construct then + def.on_construct(n) end end - local pos = sp[pr:next(1,#sp)] - if pos then - minetest.add_entity(pos,"mobs_mc:evoker") + if sp and #sp > 0 then + for i=1,5 do + local pos = sp[pr:next(1,#sp)] + if pos then + minetest.add_entity(pos,"mobs_mc:pillager") + end + end + local pos = sp[pr:next(1,#sp)] + if pos then + minetest.add_entity(pos,"mobs_mc:evoker") + end end end end diff --git a/mods/MAPGEN/mcl_structures/witch_hut.lua b/mods/MAPGEN/mcl_structures/witch_hut.lua index 039c463323..5ac23b1440 100644 --- a/mods/MAPGEN/mcl_structures/witch_hut.lua +++ b/mods/MAPGEN/mcl_structures/witch_hut.lua @@ -2,14 +2,19 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) +local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false) + local function spawn_witch(p1,p2) local c = minetest.find_node_near(p1,15,{"mcl_cauldrons:cauldron"}) 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 witch = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:witch"):get_luaentity() + local witch + 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.can_despawn = false + end local cat = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat"):get_luaentity() - witch._home = c - witch.can_despawn = false cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}}) cat.owner = "!witch!" --so it's not claimable by player cat._home = c From 89f3bb5aa64b797f533d5950a3c1738ceea0e00c Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 7 Sep 2022 11:52:54 +0200 Subject: [PATCH 2/3] only prevent mob spawning, not wall fixing --- .../mcl_structures/pillager_outpost.lua | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/pillager_outpost.lua b/mods/MAPGEN/mcl_structures/pillager_outpost.lua index a70c9c2d2d..fe1db5ce37 100644 --- a/mods/MAPGEN/mcl_structures/pillager_outpost.lua +++ b/mods/MAPGEN/mcl_structures/pillager_outpost.lua @@ -56,17 +56,17 @@ mcl_structures.register_structure("pillager_outpost",{ }} }, after_place = function(p,def,pr) - if not peaceful then - local p1 = vector.offset(p,-7,0,-7) - local p2 = vector.offset(p,7,14,7) - local spawnon = {"mcl_core:stripped_oak"} - local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon) - for _,n in pairs(minetest.find_nodes_in_area(p1,p2,{"group:wall"})) do - local def = minetest.registered_nodes[minetest.get_node(n).name:gsub("_%d+$","")] - if def and def.on_construct then - def.on_construct(n) - end + local p1 = vector.offset(p,-7,0,-7) + local p2 = vector.offset(p,7,14,7) + local spawnon = {"mcl_core:stripped_oak"} + local sp = minetest.find_nodes_in_area_under_air(p1,p2,spawnon) + for _,n in pairs(minetest.find_nodes_in_area(p1,p2,{"group:wall"})) do + local def = minetest.registered_nodes[minetest.get_node(n).name:gsub("_%d+$","")] + if def and def.on_construct then + def.on_construct(n) end + end + if not peaceful then if sp and #sp > 0 then for i=1,5 do local pos = sp[pr:next(1,#sp)] From 9449cdfd88023a492f589dfabec1a4c5b9fd97eb Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 7 Sep 2022 11:53:22 +0200 Subject: [PATCH 3/3] Don't spawn illagers in cabins in peaceful --- mods/MAPGEN/mcl_structures/woodland_mansion.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/woodland_mansion.lua b/mods/MAPGEN/mcl_structures/woodland_mansion.lua index 6a4cfebe03..8b492c186a 100644 --- a/mods/MAPGEN/mcl_structures/woodland_mansion.lua +++ b/mods/MAPGEN/mcl_structures/woodland_mansion.lua @@ -1,6 +1,7 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) +local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false) mcl_structures.register_structure("woodland_cabin",{ place_on = {"group:grass_block","group:dirt","mcl_core:dirt_with_grass"}, @@ -22,17 +23,19 @@ mcl_structures.register_structure("woodland_cabin",{ local p1=vector.offset(p,-def.sidelen,-1,-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) - if sp and #sp > 0 then - for i=1,5 do + if not peaceful then + if sp and #sp > 0 then + for i=1,5 do + local pos = sp[pr:next(1,#sp)] + if pos then + minetest.add_entity(pos,"mobs_mc:vindicator") + end + end local pos = sp[pr:next(1,#sp)] if pos then - minetest.add_entity(pos,"mobs_mc:vindicator") + minetest.add_entity(pos,"mobs_mc:evoker") end end - local pos = sp[pr:next(1,#sp)] - if pos then - minetest.add_entity(pos,"mobs_mc:evoker") - end end local parrot = minetest.find_node_near(p,25,{"mcl_heads:wither_skeleton"}) if parrot then