MineClone5/mods/MAPGEN/mcl_structures/init.lua

627 lines
21 KiB
Lua
Raw Normal View History

2021-05-25 12:52:25 +02:00
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local modpath = minetest.get_modpath(modname)
local name_prefix = "mcl_structures:"
2021-05-25 12:52:25 +02:00
mcl_structures = {}
local rotations = {
"0",
"90",
"180",
"270"
}
2022-01-12 00:27:28 +01:00
local registered_structures = {}
2022-01-14 01:25:39 +01:00
local use_process_mapgen_block_lvm = false
local use_process_mapgen_chunk = false
local on_finished_block_callbacks = {}
local on_finished_chunk_callbacks = {}
2022-01-14 01:25:39 +01:00
local noise_params = {
offset = 0,
scale = 1,
spread = {
x = mcl_mapgen.CS_NODES,
y = mcl_mapgen.CS_NODES,
z = mcl_mapgen.CS_NODES,
},
seed = 329,
octaves = 1,
persistence = 0.6,
}
local perlin_noise
local get_perlin_noise_level = function(minp)
perlin_noise = perlin_noise or minetest.get_perlin(noise_params)
return perlin_noise:get_3d(minp)
end
mcl_structures.get_perlin_noise_level = get_perlin_noise_level
local spawnstruct_hint = S("Use /help spawnstruct to see a list of avaiable types.")
local function dir_to_rotation(dir)
local ax, az = math.abs(dir.x), math.abs(dir.z)
if ax > az then
if dir.x < 0 then
return "270"
end
return "90"
end
if dir.z < 0 then
return "180"
end
return "0"
end
local function spawnstruct_function(name, param)
local player = minetest.get_player_by_name(name)
if not player then return end
if param == "" then
minetest.chat_send_player(name, S("Error: No structure type given. Please use “/spawnstruct <type>”."))
minetest.chat_send_player(name, spawnstruct_hint)
return
end
local struct = registered_structures[param]
if not struct then
struct = registered_structures[name_prefix .. param]
end
if not struct then
minetest.chat_send_player(name, S("Error: Unknown structure type. Please use “/spawnstruct <type>”."))
minetest.chat_send_player(name, spawnstruct_hint)
return
end
local place = struct.place_function
if not place then return end
local pos = player:get_pos()
if not pos then return end
local pr = PseudoRandom(math.floor(pos.x * 333 + pos.y * 19 - pos.z + 4))
pos = vector.round(pos)
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
local rot = dir_to_rotation(dir)
place(pos, rot, pr, player)
minetest.chat_send_player(name, S("Structure placed."))
end
local function update_spawnstruct_chatcommand()
local spawnstruct_params = ""
for _, registered_structure in pairs(registered_structures) do
if spawnstruct_params ~= "" then
spawnstruct_params = spawnstruct_params .. " | "
end
spawnstruct_params = spawnstruct_params .. registered_structure.short_name
end
local def = {
params = spawnstruct_params,
description = S("Generate a pre-defined structure near your position."),
privs = {debug = true},
func = spawnstruct_function,
}
local registered_chatcommands = minetest.registered_chatcommands
if registered_chatcommands["spawnstruct"] then
minetest.override_chatcommand("spawnstruct", def)
else
minetest.register_chatcommand("spawnstruct", def)
end
end
2022-01-14 01:25:39 +01:00
function process_mapgen_block_lvm(vm_context)
local nodes = minetest.find_nodes_in_area(vm_context.minp, vm_context.maxp, {"group:struct"}, true)
for node_name, pos_list in pairs(nodes) do
local lvm_callback = on_finished_block_callbacks[node_name]
2022-01-14 01:25:39 +01:00
if lvm_callback then
lvm_callback(vm_context, pos_list)
end
end
end
function process_mapgen_chunk(minp, maxp, seed, vm_context)
local nodes = minetest.find_nodes_in_area(minp, maxp, {"group:struct"}, true)
for node_name, pos_list in pairs(nodes) do
local chunk_callback = on_finished_chunk_callbacks[node_name]
2022-01-14 01:25:39 +01:00
if chunk_callback then
chunk_callback(minp, maxp, seed, vm_context, pos_list)
end
end
2022-01-15 05:04:43 +01:00
for node_name, pos_list in pairs(nodes) do
for _, pos in pairs(pos_list) do
local node = minetest.get_node(pos)
if string.sub(node.name, 1, 15) == 'mcl_structures:' then
minetest.swap_node(pos, {name = 'air'})
end
end
end
2022-01-14 01:25:39 +01:00
end
2022-01-12 00:27:28 +01:00
2022-01-14 01:25:39 +01:00
--------------------------------------------------------------------------------------
-- mcl_structures.register_structure(struct_def)
-- struct_def:
2022-01-16 03:42:18 +01:00
-- name - name, like 'desert_temple'
-- decoration - decoration definition, to use as structure seed (thanks cora for the idea)
-- on_finished_block - callback, if needed, to use with decorations: funcion(vm_context, pos_list)
-- on_finished_chunk - next callback if needed: funcion(minp, maxp, seed, vm_context, pos_list)
-- place_function - callback to place schematic by /spawnstruct debug command: function(pos, rotation, pr, placer)
2022-01-16 03:42:18 +01:00
-- on_placed - useful when you want to process the area after placement: function(pos, rotation, pr, size)
2022-01-12 00:27:28 +01:00
function mcl_structures.register_structure(def)
local short_name = def.name
local name = "mcl_structures:" .. short_name
local decoration = def.decoration
local on_finished_block = def.on_finished_block
local on_finished_chunk = def.on_finished_chunk
local place_function = def.place_function
2022-01-12 00:27:28 +01:00
if not name then
2022-01-14 01:25:39 +01:00
minetest.log('warning', 'Structure name is not passed for registration - ignoring')
2022-01-12 00:27:28 +01:00
return
end
if registered_structures[name] then
minetest.log('warning', 'Structure '..name..' is already registered - owerwriting')
end
2022-01-14 01:25:39 +01:00
local decoration_id
if decoration then
minetest.register_node(':' .. name, {
2022-01-17 03:48:59 +01:00
drawtype = "airlike",
2022-01-16 03:42:18 +01:00
sunlight_propagates = true,
pointable = false,
walkable = false,
diggable = false,
buildable_to = true,
groups = {
2022-01-14 01:25:39 +01:00
struct = 1,
not_in_creative_inventory = 1,
},
})
decoration_id = minetest.register_decoration({
deco_type = decoration.deco_type,
place_on = decoration.place_on,
sidelen = decoration.sidelen,
fill_ratio = decoration.fill_ratio,
noise_params = decoration.noise_params,
biomes = decoration.biomes,
y_min = decoration.y_min,
y_max = decoration.y_max,
spawn_by = decoration.spawn_by,
num_spawn_by = decoration.num_spawn_by,
flags = decoration.flags,
decoration = name,
height = decoration.height,
height_max = decoration.height_max,
param2 = decoration.param2,
param2_max = decoration.param2_max,
place_offset_y = decoration.place_offset_y,
schematic = decoration.schematic,
replacements = decoration.replacements,
flags = decoration.flags,
rotation = decoration.rotation,
})
end
2022-01-12 00:27:28 +01:00
registered_structures[name] = {
place_function = place_function,
on_finished_block = on_finished_block,
on_finished_chunk = on_finished_chunk,
decoration_id = decoration_id,
short_name = short_name,
2022-01-12 00:27:28 +01:00
}
update_spawnstruct_chatcommand()
if on_finished_block then
on_finished_block_callbacks[name] = on_finished_block
2022-01-14 01:25:39 +01:00
if not use_process_mapgen_block_lvm then
use_process_mapgen_block_lvm = true
mcl_mapgen.register_mapgen_block_lvm(process_mapgen_block_lvm, mcl_mapgen.order.BUILDINGS)
end
end
if on_finished_chunk then
on_finished_chunk_callbacks[name] = on_finished_chunk
2022-01-14 01:25:39 +01:00
if not use_process_mapgen_chunk then
use_process_mapgen_chunk = true
mcl_mapgen.register_mapgen(process_mapgen_chunk, mcl_mapgen.order.BUILDINGS)
end
end
2022-01-12 00:27:28 +01:00
end
2022-01-14 01:25:39 +01:00
-- It doesN'T remove registered node and decoration!
2022-01-12 00:27:28 +01:00
function mcl_structures.unregister_structure(name)
if not registered_structures[name] then
minetest.log('warning','Structure '..name..' is not registered - skipping')
return
end
registered_structures[name] = nil
end
local function ecb_place(blockpos, action, calls_remaining, param)
if calls_remaining >= 1 then return end
2022-01-12 00:27:28 +01:00
local pos = param.pos
local rotation = param.rotation
minetest.place_schematic(pos, param.schematic, rotation, param.replacements, param.force_placement, param.flags)
2022-01-16 03:42:18 +01:00
local on_placed = param.on_placed
if not on_placed then
2022-01-12 00:27:28 +01:00
return
end
2022-01-16 03:42:18 +01:00
on_placed(pos, rotation, param.pr, param.size)
end
2021-05-25 12:52:25 +02:00
2022-01-12 00:27:28 +01:00
function mcl_structures.place_schematic(def)
2022-01-16 03:42:18 +01:00
local pos = def.pos
local schematic = def.schematic
local rotation = def.rotation
local pr = def.pr
local on_placed = def.on_placed -- on_placed(pos, rotation, pr, size)
local emerge = def.emerge
2022-01-12 00:27:28 +01:00
if not pos then
minetest.log('warning', '[mcl_structures] No pos. specified to place schematic')
return
end
if not schematic then
minetest.log('warning', '[mcl_structures] No schematic specified to place at ' .. minetest.pos_to_string(pos))
return
end
if not rotation or rotation == 'random' then
if pr then
rotation = rotations[pr:next(1,#rotations)]
else
rotation = rotations[math.random(1,#rotations)]
end
end
2022-01-15 05:04:43 +01:00
2022-01-16 03:42:18 +01:00
if not emerge and not on_placed then
2022-01-12 00:27:28 +01:00
minetest.place_schematic(pos, schematic, rotation, def.replacements, def.force_placement, def.flags)
return
end
2022-01-15 05:04:43 +01:00
local serialized_schematic = minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic"
local loaded_schematic = loadstring(serialized_schematic)()
2022-01-12 00:27:28 +01:00
if not loaded_schematic then
minetest.log('warning', '[mcl_structures] Schematic ' .. schematic .. ' load serialized string problem at ' .. minetest.pos_to_string(pos))
return
end
local size = loaded_schematic.size
if not size then
minetest.log('warning', '[mcl_structures] Schematic ' .. schematic .. ' has no size at ' .. minetest.pos_to_string(pos))
return
end
local size_x, size_y, size_z = size.x, size.y, size.z
if rotation == "90" or rotation == "270" then
size_x, size_z = size_z, size_x
end
local x, y, z = pos.x, pos.y, pos.z
local p1 = {x = x, y = y, z = z}
local p2 = {x = x + size_x - 1, y = y + size_y - 1, z = size_z - 1}
local ecb_param = {
pos = vector.new(pos),
schematic = loaded_schematic,
rotation = rotation,
replacements = replacements,
force_placement = force_placement,
flags = flags,
size = vector.new(size),
pr = pr,
2022-01-16 03:42:18 +01:00
on_placed = on_placed,
2022-01-12 00:27:28 +01:00
}
2022-01-15 05:04:43 +01:00
if not emerge then
ecb_place(p1, nil, 0, ecb_param)
return
end
2022-01-16 03:42:18 +01:00
minetest.log("verbose", "[mcl_structures] Emerge area " .. minetest.pos_to_string(p1) .. " - " .. minetest.pos_to_string(p2)
.. " of size " ..minetest.pos_to_string(size) .. " to place " .. schematic .. ", rotation " .. tostring(rotation))
2022-01-12 00:27:28 +01:00
minetest.emerge_area(p1, p2, ecb_place, ecb_param)
end
2021-05-25 12:52:25 +02:00
function mcl_structures.get_struct(file)
local localfile = modpath.."/schematics/"..file
local file, errorload = io.open(localfile, "rb")
if errorload then
minetest.log("error", "[mcl_structures] Could not open this struct: "..localfile)
return nil
end
local allnode = file:read("*a")
file:close()
return allnode
end
-- Call on_construct on pos.
-- Useful to init chests from formspec.
2022-01-16 03:42:18 +01:00
function mcl_structures.init_node_construct(pos)
local node = minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
if def and def.on_construct then
def.on_construct(pos)
return true
end
return false
end
2015-07-04 04:56:02 +02:00
-- The call of Struct
2022-01-04 01:13:28 +01:00
function mcl_structures.call_struct(pos, struct_style, rotation, pr, callback)
minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos))
2017-09-10 20:16:13 +02:00
if not rotation then
rotation = "random"
end
2022-01-16 03:42:18 +01:00
if struct_style == "desert_well" then
return mcl_structures.generate_desert_well(pos, rotation)
2017-05-20 07:46:57 +02:00
elseif struct_style == "igloo" then
return mcl_structures.generate_igloo(pos, rotation, pr)
elseif struct_style == "witch_hut" then
return mcl_structures.generate_witch_hut(pos, rotation)
elseif struct_style == "ice_spike_small" then
return mcl_structures.generate_ice_spike_small(pos, rotation)
2017-08-11 01:48:36 +02:00
elseif struct_style == "ice_spike_large" then
return mcl_structures.generate_ice_spike_large(pos, rotation)
elseif struct_style == "boulder" then
return mcl_structures.generate_boulder(pos, rotation, pr)
elseif struct_style == "fossil" then
return mcl_structures.generate_fossil(pos, rotation, pr)
elseif struct_style == "end_exit_portal" then
2022-01-04 01:13:28 +01:00
return mcl_structures.generate_end_exit_portal(pos, rotation, pr, callback)
elseif struct_style == "end_exit_portal_open" then
return mcl_structures.generate_end_exit_portal_open(pos, rotation)
elseif struct_style == "end_gateway_portal" then
return mcl_structures.generate_end_gateway_portal(pos, rotation)
elseif struct_style == "end_portal_shrine" then
return mcl_structures.generate_end_portal_shrine(pos, rotation, pr)
2022-01-04 01:13:28 +01:00
elseif struct_style == "end_portal" then
return mcl_structures.generate_end_portal(pos, rotation, pr)
end
end
function mcl_structures.generate_end_portal(pos, rotation, pr)
-- todo: proper facedir
local x0, y0, z0 = pos.x - 2, pos.y, pos.z - 2
for x = 0, 4 do
for z = 0, 4 do
if x % 4 == 0 or z % 4 == 0 then
if x % 4 ~= 0 or z % 4 ~= 0 then
minetest.swap_node({x = x0 + x, y = y0, z = z0 + z}, {name = "mcl_portals:end_portal_frame_eye"})
end
else
minetest.swap_node({x = x0 + x, y = y0, z = z0 + z}, {name = "mcl_portals:portal_end"})
end
end
2017-05-20 06:47:42 +02:00
end
2015-07-04 04:56:02 +02:00
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_desert_well(pos, rot)
local newpos = {x=pos.x,y=pos.y-2,z=pos.z}
2021-05-25 12:52:25 +02:00
local path = modpath.."/schematics/mcl_structures_desert_well.mts"
2022-01-12 00:27:28 +01:00
return mcl_structures.place_schematic({
pos = newpos,
schematic = path,
rotation = rot or "0",
force_placement = true
})
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_igloo(pos, rotation, pr)
2019-10-02 22:29:25 +02:00
-- Place igloo
local success, rotation = mcl_structures.generate_igloo_top(pos, pr)
2019-10-02 22:31:19 +02:00
-- Place igloo basement with 50% chance
local r = pr:next(1,2)
if r == 1 then
2019-10-02 22:29:25 +02:00
-- Select basement depth
local dim = mcl_worlds.pos_to_dimension(pos)
--local buffer = pos.y - (mcl_mapgen.overworld.lava_max + 10)
2021-04-17 07:46:24 +02:00
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_mapgen.overworld.lava_max + 10)
else
return success
end
2019-02-06 02:02:18 +01:00
if buffer <= 19 then
return success
2019-02-06 02:02:18 +01:00
end
local depth = pr:next(19, buffer)
2019-02-06 02:02:18 +01:00
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
2021-05-25 12:52:25 +02:00
local function set_brick(pos)
local c = pr:next(1, 3) -- cracked chance
local m = pr:next(1, 10) -- chance for monster egg
2019-02-06 02:02:18 +01:00
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
2019-10-02 22:29:25 +02:00
-- Check how deep we can actuall dig
2019-02-06 02:02:18 +01:00
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]
2019-10-02 22:31:19 +02:00
if (not def) or (not def.walkable) or (def.liquidtype ~= "none") or (not def.is_ground_content) then
2019-10-02 22:29:25 +02:00
bpos.y = tpos.y-y+1
break
end
2019-10-02 22:29:25 +02:00
end
if real_depth <= 6 then
return success
end
-- Generate ladder to basement
2019-10-02 22:31:19 +02:00
for y=1, real_depth-1 do
2019-02-06 02:02:18 +01:00
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
2019-10-02 22:29:25 +02:00
-- 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)
2019-02-06 02:02:18 +01:00
end
return success
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_igloo_top(pos, pr)
2017-05-20 07:46:57 +02:00
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
2022-01-12 00:27:28 +01:00
-- Furnace does not work atm because apparently meta is not set. :-(
2017-05-20 07:59:10 +02:00
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
2021-05-25 12:52:25 +02:00
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
2017-05-20 07:46:57 +02:00
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
2021-04-17 07:46:24 +02:00
--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)
2022-01-16 03:42:18 +01:00
mcl_structures.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
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_igloo_basement(pos, orientation, pr)
2017-05-24 05:43:01 +02:00
-- TODO: Add brewing stand
2019-02-06 02:23:51 +01:00
-- TODO: Add monster eggs
2019-02-06 02:02:18 +01:00
-- TODO: Spawn villager and zombie villager
2021-05-25 12:52:25 +02:00
local path = modpath.."/schematics/mcl_structures_igloo_basement.mts"
mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr)
2017-05-24 05:43:01 +02:00
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_boulder(pos, rotation, pr)
2017-08-12 02:24:34 +02:00
-- Choose between 2 boulder sizes (2×2×2 or 3×3×3)
local r = pr:next(1, 10)
local path
2017-08-12 02:24:34 +02:00
if r <= 3 then
2021-05-25 12:52:25 +02:00
path = modpath.."/schematics/mcl_structures_boulder_small.mts"
2017-08-12 02:24:34 +02:00
else
2021-05-25 12:52:25 +02:00
path = modpath.."/schematics/mcl_structures_boulder.mts"
2017-08-12 02:24:34 +02:00
end
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
2021-03-07 00:49:34 +01:00
return minetest.place_schematic(newpos, path, rotation) -- don't serialize schematics for registered biome decorations, for MT 5.4.0, https://github.com/minetest/minetest/issues/10995
end
local function hut_placement_callback(p1, p2, size, orientation, pr)
if not p1 or not p2 then return end
local legs = minetest.find_nodes_in_area(p1, p2, "mcl_core:tree")
for i = 1, #legs do
while minetest.get_item_group(mcl_mapgen.get_far_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
minetest.swap_node(legs[i], {name = "mcl_core:tree", param2 = 2})
end
end
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_witch_hut(pos, rotation, pr)
local path = modpath.."/schematics/mcl_structures_witch_hut.mts"
mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr)
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_ice_spike_small(pos, rotation)
local path = modpath.."/schematics/mcl_structures_ice_spike_small.mts"
2021-03-07 00:49:34 +01:00
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_ice_spike_large(pos, rotation)
local path = modpath.."/schematics/mcl_structures_ice_spike_large.mts"
2021-03-07 00:49:34 +01:00
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
2017-08-11 01:48:36 +02:00
end
2021-05-25 12:52:25 +02:00
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 = {
2017-09-08 01:39:14 +02:00
"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]
2021-03-07 00:49:34 +01:00
return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true)
end
2022-01-04 01:13:28 +01:00
function mcl_structures.generate_end_exit_portal(pos, rot, pr, callback)
local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts"
2022-01-04 01:13:28 +01:00
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true, nil, callback)
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_end_exit_portal_open(pos, rot)
local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts"
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
end
2021-05-25 12:52:25 +02:00
function mcl_structures.generate_end_gateway_portal(pos, rot)
local path = modpath.."/schematics/mcl_structures_end_gateway_portal.mts"
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
end
dofile(modpath .. "/structures.lua")