fossil & igloo -> new api
This commit is contained in:
parent
3ca6d4de3b
commit
a09226c370
|
@ -1264,8 +1264,8 @@ end
|
|||
local function generate_structures(minp, maxp, blockseed, biomemap)
|
||||
local chunk_has_igloo = false
|
||||
local struct_min, struct_max = -3, 111 --64
|
||||
|
||||
if maxp.y >= struct_min and minp.y <= struct_max then
|
||||
--except end exit portall all v6
|
||||
if mg_name == "v6" and maxp.y >= struct_min and minp.y <= struct_max then
|
||||
-- Generate structures
|
||||
local pr = PcgRandom(blockseed)
|
||||
perlin_structures = perlin_structures or minetest.get_perlin(329, 3, 0.6, 100)
|
||||
|
@ -1334,7 +1334,7 @@ local function generate_structures(minp, maxp, blockseed, biomemap)
|
|||
-- Witch hut (v6)
|
||||
if ground_y <= 0 and nn == "mcl_core:dirt" then
|
||||
local prob = minecraft_chunk_probability(48, minp, maxp)
|
||||
if mg_name == "v6" and pr:next(1, prob) == 1 then
|
||||
if pr:next(1, prob) == 1 then
|
||||
|
||||
local swampland = minetest.get_biome_id("Swampland")
|
||||
local swampland_shore = minetest.get_biome_id("Swampland_shore")
|
||||
|
@ -1425,7 +1425,7 @@ local function generate_structures(minp, maxp, blockseed, biomemap)
|
|||
|
||||
-- Ice spikes in v6
|
||||
-- In other mapgens, ice spikes are generated as decorations.
|
||||
if mg_name == "v6" and nn == "mcl_core:snowblock" then
|
||||
if nn == "mcl_core:snowblock" then
|
||||
local spike = pr:next(1,58000)
|
||||
if spike < 3 then
|
||||
-- Check surface
|
||||
|
@ -1710,14 +1710,9 @@ local function generate_underground_mushrooms(minp, maxp, seed)
|
|||
end
|
||||
end
|
||||
|
||||
local nether_wart_chance
|
||||
if mg_name == "v6" then
|
||||
nether_wart_chance = 85
|
||||
else
|
||||
nether_wart_chance = 170
|
||||
end
|
||||
-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart
|
||||
-- (only v6)
|
||||
local nether_wart_chance = 85
|
||||
local function generate_nether_decorations(minp, maxp, seed)
|
||||
local pr_nether = PseudoRandom(seed+667)
|
||||
|
||||
|
|
|
@ -43,20 +43,25 @@ function mcl_structures.place_structure(pos, def, pr)
|
|||
end
|
||||
local pp = vector.offset(pos,0,y_offset,0)
|
||||
if def.solid_ground and def.sidelen then
|
||||
local bn = minetest.get_biome_name(minetest.get_biome_data(pos).biome)
|
||||
local node_top = minetest.registered_biomes[bn].node_top
|
||||
local node_fill = minetest.registered_biomes[bn].node_filler
|
||||
local node_stone = minetest.registered_biomes[bn].node_stone
|
||||
local node_stone = "mcl_core:stone"
|
||||
local node_filler = "mcl_core:dirt"
|
||||
local node_top = "mcl_core:dirt_with_grass"
|
||||
|
||||
if minetest.get_mapgen_setting("mg_name") ~= "v6" then
|
||||
local b = minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)]
|
||||
if b.node_top then node_top = b.node_top end
|
||||
if b.node_filler then node_filler = b.node_filler end
|
||||
if b.node_stone then node_stone = b.node_stone end
|
||||
end
|
||||
|
||||
local ground_p1 = vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2)
|
||||
local ground_p2 = vector.offset(pos,def.sidelen/2,-1,def.sidelen/2)
|
||||
if not node_stone then node_stone = "mcl_core:stone" end
|
||||
if not node_fill then node_fill = "mcl_core:dirt" end
|
||||
if not node_top then node_top = "mcl_core:dirt_with_grass" end
|
||||
|
||||
local solid = minetest.find_nodes_in_area(ground_p1,ground_p2,{"group:solid"})
|
||||
if #solid < ( def.sidelen * def.sidelen ) then
|
||||
if def.make_foundation then
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(ground_p1,ground_p2,{"air","group:liquid"}),{name=node_top})
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-1,0),vector.offset(ground_p2,0,-4,0),{"air","group:liquid"}),{name=node_fill})
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-1,0),vector.offset(ground_p2,0,-4,0),{"air","group:liquid"}),{name=node_filler})
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-5,0),vector.offset(ground_p2,0,-30,0),{"air","group:liquid"}),{name=node_stone})
|
||||
else
|
||||
if logging then
|
||||
|
|
152
mods/MAPGEN/mcl_structures/igloo.lua
Normal file
152
mods/MAPGEN/mcl_structures/igloo.lua
Normal file
|
@ -0,0 +1,152 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(modname)
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
function mcl_structures.generate_igloo_top(pos, pr)
|
||||
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
|
||||
-- Furnace does ot work atm because apparently meta is not set. :-(
|
||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local path = modpath.."/schematics/mcl_structures_igloo_top.mts"
|
||||
local rotation = tostring(pr:next(0,3)*90)
|
||||
return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation
|
||||
end
|
||||
|
||||
function mcl_structures.generate_igloo_basement(pos, orientation, pr)
|
||||
-- TODO: Add brewing stand
|
||||
-- TODO: Add monster eggs
|
||||
-- TODO: Spawn villager and zombie villager
|
||||
local path = modpath.."/schematics/mcl_structures_igloo_basement.mts"
|
||||
mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr)
|
||||
end
|
||||
|
||||
function mcl_structures.generate_igloo(pos, def, pr)
|
||||
-- Place igloo
|
||||
local success, rotation = mcl_structures.generate_igloo_top(pos, pr)
|
||||
-- Place igloo basement with 50% chance
|
||||
local r = pr:next(1,2)
|
||||
if r == 1 then
|
||||
-- Select basement depth
|
||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
||||
--local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
|
||||
local buffer
|
||||
if dim == "nether" then
|
||||
buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10)
|
||||
elseif dim == "end" then
|
||||
buffer = pos.y - (mcl_vars.mg_end_min + 1)
|
||||
elseif dim == "overworld" then
|
||||
buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
|
||||
else
|
||||
return success
|
||||
end
|
||||
if buffer <= 19 then
|
||||
return success
|
||||
end
|
||||
local depth = pr:next(19, buffer)
|
||||
local bpos = {x=pos.x, y=pos.y-depth, z=pos.z}
|
||||
-- trapdoor position
|
||||
local tpos
|
||||
local dir, tdir
|
||||
if rotation == "0" then
|
||||
dir = {x=-1, y=0, z=0}
|
||||
tdir = {x=1, y=0, z=0}
|
||||
tpos = {x=pos.x+7, y=pos.y-1, z=pos.z+3}
|
||||
elseif rotation == "90" then
|
||||
dir = {x=0, y=0, z=-1}
|
||||
tdir = {x=0, y=0, z=-1}
|
||||
tpos = {x=pos.x+3, y=pos.y-1, z=pos.z+1}
|
||||
elseif rotation == "180" then
|
||||
dir = {x=1, y=0, z=0}
|
||||
tdir = {x=-1, y=0, z=0}
|
||||
tpos = {x=pos.x+1, y=pos.y-1, z=pos.z+3}
|
||||
elseif rotation == "270" then
|
||||
dir = {x=0, y=0, z=1}
|
||||
tdir = {x=0, y=0, z=1}
|
||||
tpos = {x=pos.x+3, y=pos.y-1, z=pos.z+7}
|
||||
else
|
||||
return success
|
||||
end
|
||||
local function set_brick(pos)
|
||||
local c = pr:next(1, 3) -- cracked chance
|
||||
local m = pr:next(1, 10) -- chance for monster egg
|
||||
local brick
|
||||
if m == 1 then
|
||||
if c == 1 then
|
||||
brick = "mcl_monster_eggs:monster_egg_stonebrickcracked"
|
||||
else
|
||||
brick = "mcl_monster_eggs:monster_egg_stonebrick"
|
||||
end
|
||||
else
|
||||
if c == 1 then
|
||||
brick = "mcl_core:stonebrickcracked"
|
||||
else
|
||||
brick = "mcl_core:stonebrick"
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name=brick})
|
||||
end
|
||||
local ladder_param2 = minetest.dir_to_wallmounted(tdir)
|
||||
local real_depth = 0
|
||||
-- Check how deep we can actuall dig
|
||||
for y=1, depth-5 do
|
||||
real_depth = real_depth + 1
|
||||
local node = minetest.get_node({x=tpos.x,y=tpos.y-y,z=tpos.z})
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not (def and def.walkable and def.liquidtype == "none" and def.is_ground_content) then
|
||||
bpos.y = tpos.y-y+1
|
||||
break
|
||||
end
|
||||
end
|
||||
if real_depth <= 6 then
|
||||
return success
|
||||
end
|
||||
-- Generate ladder to basement
|
||||
for y=1, real_depth-1 do
|
||||
set_brick({x=tpos.x-1,y=tpos.y-y,z=tpos.z })
|
||||
set_brick({x=tpos.x+1,y=tpos.y-y,z=tpos.z })
|
||||
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z-1})
|
||||
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z+1})
|
||||
minetest.set_node({x=tpos.x,y=tpos.y-y,z=tpos.z}, {name="mcl_core:ladder", param2=ladder_param2})
|
||||
end
|
||||
-- Place basement
|
||||
mcl_structures.generate_igloo_basement(bpos, rotation, pr)
|
||||
-- Place hidden trapdoor
|
||||
minetest.after(5, function(tpos, dir)
|
||||
minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)}) -- TODO: more reliable param2
|
||||
end, tpos, dir)
|
||||
end
|
||||
return success
|
||||
end
|
||||
|
||||
mcl_structures.register_structure("igloo",{
|
||||
place_on = {"mcl_core:snowblock","mcl_core:snow","group:grass_block_snow"},
|
||||
fill_ratio = 0.01,
|
||||
sidelen = 16,
|
||||
chunk_probability = 4400,
|
||||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = 0,
|
||||
y_offset = 0,
|
||||
biomes = { "ColdTaiga", "IcePlainsSpikes", "IcePlains" },
|
||||
place_func = mcl_structures.generate_igloo,
|
||||
loot = {
|
||||
["mcl_chests:chest"] = {{
|
||||
stacks_min = 1,
|
||||
stacks_max = 1,
|
||||
items = {
|
||||
{ itemstring = "mcl_core:apple_gold", weight = 1 },
|
||||
}
|
||||
},
|
||||
{
|
||||
stacks_min = 2,
|
||||
stacks_max = 8,
|
||||
items = {
|
||||
{ itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 },
|
||||
{ itemstring = "mcl_core:apple", weight = 15, amount_min = 1, amount_max = 3 },
|
||||
{ itemstring = "mcl_farming:wheat_item", weight = 10, amount_min = 2, amount_max = 3 },
|
||||
{ itemstring = "mcl_core:gold_nugget", weight = 10, amount_min = 1, amount_max = 3 },
|
||||
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 10 },
|
||||
{ itemstring = "mcl_tools:axe_stone", weight = 2 },
|
||||
{ itemstring = "mcl_core:emerald", weight = 1 },
|
||||
}
|
||||
}},
|
||||
}
|
||||
})
|
|
@ -75,11 +75,7 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr)
|
|||
if not rotation then
|
||||
rotation = "random"
|
||||
end
|
||||
if struct_style == "igloo" then
|
||||
return mcl_structures.generate_igloo(pos, rotation, pr)
|
||||
elseif struct_style == "fossil" then
|
||||
return mcl_structures.generate_fossil(pos, rotation, pr)
|
||||
elseif struct_style == "end_exit_portal" then
|
||||
if struct_style == "end_exit_portal" then
|
||||
return mcl_structures.generate_end_exit_portal(pos, rotation)
|
||||
elseif struct_style == "end_exit_portal_open" then
|
||||
return mcl_structures.generate_end_exit_portal_open(pos, rotation)
|
||||
|
@ -90,197 +86,6 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr)
|
|||
end
|
||||
end
|
||||
|
||||
function mcl_structures.generate_igloo(pos, rotation, pr)
|
||||
-- Place igloo
|
||||
local success, rotation = mcl_structures.generate_igloo_top(pos, pr)
|
||||
-- Place igloo basement with 50% chance
|
||||
local r = pr:next(1,2)
|
||||
if r == 1 then
|
||||
-- Select basement depth
|
||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
||||
--local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
|
||||
local buffer
|
||||
if dim == "nether" then
|
||||
buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10)
|
||||
elseif dim == "end" then
|
||||
buffer = pos.y - (mcl_vars.mg_end_min + 1)
|
||||
elseif dim == "overworld" then
|
||||
buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
|
||||
else
|
||||
return success
|
||||
end
|
||||
if buffer <= 19 then
|
||||
return success
|
||||
end
|
||||
local depth = pr:next(19, buffer)
|
||||
local bpos = {x=pos.x, y=pos.y-depth, z=pos.z}
|
||||
-- trapdoor position
|
||||
local tpos
|
||||
local dir, tdir
|
||||
if rotation == "0" then
|
||||
dir = {x=-1, y=0, z=0}
|
||||
tdir = {x=1, y=0, z=0}
|
||||
tpos = {x=pos.x+7, y=pos.y-1, z=pos.z+3}
|
||||
elseif rotation == "90" then
|
||||
dir = {x=0, y=0, z=-1}
|
||||
tdir = {x=0, y=0, z=-1}
|
||||
tpos = {x=pos.x+3, y=pos.y-1, z=pos.z+1}
|
||||
elseif rotation == "180" then
|
||||
dir = {x=1, y=0, z=0}
|
||||
tdir = {x=-1, y=0, z=0}
|
||||
tpos = {x=pos.x+1, y=pos.y-1, z=pos.z+3}
|
||||
elseif rotation == "270" then
|
||||
dir = {x=0, y=0, z=1}
|
||||
tdir = {x=0, y=0, z=1}
|
||||
tpos = {x=pos.x+3, y=pos.y-1, z=pos.z+7}
|
||||
else
|
||||
return success
|
||||
end
|
||||
local function set_brick(pos)
|
||||
local c = pr:next(1, 3) -- cracked chance
|
||||
local m = pr:next(1, 10) -- chance for monster egg
|
||||
local brick
|
||||
if m == 1 then
|
||||
if c == 1 then
|
||||
brick = "mcl_monster_eggs:monster_egg_stonebrickcracked"
|
||||
else
|
||||
brick = "mcl_monster_eggs:monster_egg_stonebrick"
|
||||
end
|
||||
else
|
||||
if c == 1 then
|
||||
brick = "mcl_core:stonebrickcracked"
|
||||
else
|
||||
brick = "mcl_core:stonebrick"
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name=brick})
|
||||
end
|
||||
local ladder_param2 = minetest.dir_to_wallmounted(tdir)
|
||||
local real_depth = 0
|
||||
-- Check how deep we can actuall dig
|
||||
for y=1, depth-5 do
|
||||
real_depth = real_depth + 1
|
||||
local node = minetest.get_node({x=tpos.x,y=tpos.y-y,z=tpos.z})
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not (def and def.walkable and def.liquidtype == "none" and def.is_ground_content) then
|
||||
bpos.y = tpos.y-y+1
|
||||
break
|
||||
end
|
||||
end
|
||||
if real_depth <= 6 then
|
||||
return success
|
||||
end
|
||||
-- Generate ladder to basement
|
||||
for y=1, real_depth-1 do
|
||||
set_brick({x=tpos.x-1,y=tpos.y-y,z=tpos.z })
|
||||
set_brick({x=tpos.x+1,y=tpos.y-y,z=tpos.z })
|
||||
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z-1})
|
||||
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z+1})
|
||||
minetest.set_node({x=tpos.x,y=tpos.y-y,z=tpos.z}, {name="mcl_core:ladder", param2=ladder_param2})
|
||||
end
|
||||
-- Place basement
|
||||
mcl_structures.generate_igloo_basement(bpos, rotation, pr)
|
||||
-- Place hidden trapdoor
|
||||
minetest.after(5, function(tpos, dir)
|
||||
minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)}) -- TODO: more reliable param2
|
||||
end, tpos, dir)
|
||||
end
|
||||
return success
|
||||
end
|
||||
|
||||
function mcl_structures.generate_igloo_top(pos, pr)
|
||||
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
|
||||
-- Furnace does ot work atm because apparently meta is not set. :-(
|
||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local path = modpath.."/schematics/mcl_structures_igloo_top.mts"
|
||||
local rotation = tostring(pr:next(0,3)*90)
|
||||
return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation
|
||||
end
|
||||
|
||||
local function igloo_placement_callback(p1, p2, size, orientation, pr)
|
||||
local chest_offset
|
||||
if orientation == "0" then
|
||||
chest_offset = {x=5, y=1, z=5}
|
||||
elseif orientation == "90" then
|
||||
chest_offset = {x=5, y=1, z=3}
|
||||
elseif orientation == "180" then
|
||||
chest_offset = {x=3, y=1, z=1}
|
||||
elseif orientation == "270" then
|
||||
chest_offset = {x=1, y=1, z=5}
|
||||
else
|
||||
return
|
||||
end
|
||||
--local size = {x=9,y=5,z=7}
|
||||
local lootitems = mcl_loot.get_multi_loot({
|
||||
{
|
||||
stacks_min = 1,
|
||||
stacks_max = 1,
|
||||
items = {
|
||||
{ itemstring = "mcl_core:apple_gold", weight = 1 },
|
||||
}
|
||||
},
|
||||
{
|
||||
stacks_min = 2,
|
||||
stacks_max = 8,
|
||||
items = {
|
||||
{ itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 },
|
||||
{ itemstring = "mcl_core:apple", weight = 15, amount_min = 1, amount_max = 3 },
|
||||
{ itemstring = "mcl_farming:wheat_item", weight = 10, amount_min = 2, amount_max = 3 },
|
||||
{ itemstring = "mcl_core:gold_nugget", weight = 10, amount_min = 1, amount_max = 3 },
|
||||
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 10 },
|
||||
{ itemstring = "mcl_tools:axe_stone", weight = 2 },
|
||||
{ itemstring = "mcl_core:emerald", weight = 1 },
|
||||
}
|
||||
}}, pr)
|
||||
|
||||
local chest_pos = vector.add(p1, chest_offset)
|
||||
init_node_construct(chest_pos)
|
||||
local meta = minetest.get_meta(chest_pos)
|
||||
local inv = meta:get_inventory()
|
||||
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
|
||||
end
|
||||
|
||||
function mcl_structures.generate_igloo_basement(pos, orientation, pr)
|
||||
-- TODO: Add brewing stand
|
||||
-- TODO: Add monster eggs
|
||||
-- TODO: Spawn villager and zombie villager
|
||||
local path = modpath.."/schematics/mcl_structures_igloo_basement.mts"
|
||||
mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr)
|
||||
end
|
||||
|
||||
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 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
|
||||
cat.can_despawn = false
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_structures.generate_fossil(pos, rotation, pr)
|
||||
-- Generates one out of 8 possible fossil pieces
|
||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local fossils = {
|
||||
"mcl_structures_fossil_skull_1.mts", -- 4×5×5
|
||||
"mcl_structures_fossil_skull_2.mts", -- 5×5×5
|
||||
"mcl_structures_fossil_skull_3.mts", -- 5×5×7
|
||||
"mcl_structures_fossil_skull_4.mts", -- 7×5×5
|
||||
"mcl_structures_fossil_spine_1.mts", -- 3×3×13
|
||||
"mcl_structures_fossil_spine_2.mts", -- 5×4×13
|
||||
"mcl_structures_fossil_spine_3.mts", -- 7×4×13
|
||||
"mcl_structures_fossil_spine_4.mts", -- 8×5×13
|
||||
}
|
||||
local r = pr:next(1, #fossils)
|
||||
local path = modpath.."/schematics/"..fossils[r]
|
||||
return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true)
|
||||
end
|
||||
|
||||
function mcl_structures.generate_end_exit_portal(pos, rot)
|
||||
local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts"
|
||||
|
@ -429,37 +234,10 @@ dofile(modpath.."/api.lua")
|
|||
dofile(modpath.."/desert_temple.lua")
|
||||
dofile(modpath.."/jungle_temple.lua")
|
||||
dofile(modpath.."/ocean_ruins.lua")
|
||||
dofile(modpath.."/witch_hut.lua")
|
||||
dofile(modpath.."/igloo.lua")
|
||||
|
||||
local function hut_placement_callback(pos,def,pr)
|
||||
local hl = def.sidelen / 2
|
||||
local p1 = vector.offset(pos,-hl,-hl,-hl)
|
||||
local p2 = vector.offset(pos,hl,hl,hl)
|
||||
if not p1 or not p2 then return end
|
||||
local legs = minetest.find_nodes_in_area(p1, p2, "mcl_core:tree")
|
||||
local tree = {}
|
||||
for i = 1, #legs do
|
||||
while minetest.get_item_group(mcl_vars.get_node({x=legs[i].x, y=legs[i].y-1, z=legs[i].z}, true, 333333).name, "water") ~= 0 do
|
||||
legs[i].y = legs[i].y - 1
|
||||
table.insert(tree,legs[i])
|
||||
end
|
||||
end
|
||||
minetest.bulk_set_node(tree, {name = "mcl_core:tree", param2 = 2})
|
||||
spawn_witch(p1,p2)
|
||||
end
|
||||
|
||||
mcl_structures.register_structure("witch_hut",{
|
||||
place_on = {"group:sand","group:grass_block","mcl_core:water_source","group:dirt"},
|
||||
fill_ratio = 0.01,
|
||||
flags = "place_center_x, place_center_z, liquid_surface, force_placement",
|
||||
sidelen = 5,
|
||||
chunk_probability = 128,
|
||||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = -4,
|
||||
y_offset = 0,
|
||||
biomes = { "Swampland", "Swampland_ocean", "Swampland_shore" },
|
||||
filenames = { modpath.."/schematics/mcl_structures_witch_hut.mts" },
|
||||
after_place = hut_placement_callback,
|
||||
})
|
||||
mcl_structures.register_structure("desert_well",{
|
||||
place_on = {"group:sand"},
|
||||
fill_ratio = 0.01,
|
||||
|
@ -475,6 +253,28 @@ mcl_structures.register_structure("desert_well",{
|
|||
filenames = { modpath.."/schematics/mcl_structures_desert_well.mts" },
|
||||
})
|
||||
|
||||
mcl_structures.register_structure("fossil",{
|
||||
place_on = {"group:material_stone"},
|
||||
fill_ratio = 0.01,
|
||||
flags = "place_center_x, place_center_z",
|
||||
solid_ground = true,
|
||||
sidelen = 13,
|
||||
chunk_probability = 256,
|
||||
y_max = 1,
|
||||
y_min = mcl_vars.mg_overworld_min,
|
||||
biomes = { "Desert" },
|
||||
filenames = {
|
||||
modpath.."/schematics/mcl_structures_fossil_skull_1.mts", -- 4×5×5
|
||||
modpath.."/schematics/mcl_structures_fossil_skull_2.mts", -- 5×5×5
|
||||
modpath.."/schematics/mcl_structures_fossil_skull_3.mts", -- 5×5×7
|
||||
modpath.."/schematics/mcl_structures_fossil_skull_4.mts", -- 7×5×5
|
||||
modpath.."/schematics/mcl_structures_fossil_spine_1.mts", -- 3×3×13
|
||||
modpath.."/schematics/mcl_structures_fossil_spine_2.mts", -- 5×4×13
|
||||
modpath.."/schematics/mcl_structures_fossil_spine_3.mts", -- 7×4×13
|
||||
modpath.."/schematics/mcl_structures_fossil_spine_4.mts", -- 8×5×13
|
||||
},
|
||||
})
|
||||
|
||||
mcl_structures.register_structure("boulder",{
|
||||
filenames = {
|
||||
modpath.."/schematics/mcl_structures_boulder_small.mts",
|
||||
|
@ -498,7 +298,7 @@ mcl_structures.register_structure("ice_spike_large",{
|
|||
|
||||
-- Debug command
|
||||
minetest.register_chatcommand("spawnstruct", {
|
||||
params = "igloo | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon",
|
||||
params = "end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon",
|
||||
description = S("Generate a pre-defined structure near your position."),
|
||||
privs = {debug = true},
|
||||
func = function(name, param)
|
||||
|
@ -512,11 +312,7 @@ minetest.register_chatcommand("spawnstruct", {
|
|||
local pr = PseudoRandom(pos.x+pos.y+pos.z)
|
||||
local errord = false
|
||||
local message = S("Structure placed.")
|
||||
if param == "igloo" then
|
||||
mcl_structures.generate_igloo(pos, rot, pr)
|
||||
elseif param == "fossil" then
|
||||
mcl_structures.generate_fossil(pos, rot, pr)
|
||||
elseif param == "end_exit_portal" then
|
||||
if param == "end_exit_portal" then
|
||||
mcl_structures.generate_end_exit_portal(pos, rot, pr)
|
||||
elseif param == "end_exit_portal_open" then
|
||||
mcl_structures.generate_end_exit_portal_open(pos, rot, pr)
|
||||
|
|
49
mods/MAPGEN/mcl_structures/witch_hut.lua
Normal file
49
mods/MAPGEN/mcl_structures/witch_hut.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(modname)
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
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 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
|
||||
cat.can_despawn = false
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function hut_placement_callback(pos,def,pr)
|
||||
local hl = def.sidelen / 2
|
||||
local p1 = vector.offset(pos,-hl,-hl,-hl)
|
||||
local p2 = vector.offset(pos,hl,hl,hl)
|
||||
local legs = minetest.find_nodes_in_area(p1, p2, "mcl_core:tree")
|
||||
local tree = {}
|
||||
for i = 1, #legs do
|
||||
while minetest.get_item_group(mcl_vars.get_node({x=legs[i].x, y=legs[i].y-1, z=legs[i].z}, true, 333333).name, "water") ~= 0 do
|
||||
legs[i].y = legs[i].y - 1
|
||||
table.insert(tree,legs[i])
|
||||
end
|
||||
end
|
||||
minetest.bulk_set_node(tree, {name = "mcl_core:tree", param2 = 2})
|
||||
spawn_witch(p1,p2)
|
||||
end
|
||||
|
||||
mcl_structures.register_structure("witch_hut",{
|
||||
place_on = {"group:sand","group:grass_block","mcl_core:water_source","group:dirt"},
|
||||
fill_ratio = 0.01,
|
||||
flags = "place_center_x, place_center_z, liquid_surface, force_placement",
|
||||
sidelen = 5,
|
||||
chunk_probability = 128,
|
||||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = -4,
|
||||
y_offset = 0,
|
||||
biomes = { "Swampland", "Swampland_ocean", "Swampland_shore" },
|
||||
filenames = { modpath.."/schematics/mcl_structures_witch_hut.mts" },
|
||||
after_place = hut_placement_callback,
|
||||
})
|
Loading…
Reference in New Issue
Block a user