Compare commits

..

5 Commits

15 changed files with 223 additions and 151 deletions

View File

@ -394,17 +394,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
end
end)
local register_on_generated_old = minetest.register_on_generated
minetest.register_on_generated = function(...)
minetest.log("warning", "minetest.register_on_generated() is being called by the mod '"
.. minetest.get_current_modname() .. "'. MineClone5's map generation system avoids using "
.. "this callback to work around engine map generation issues. If possible please read "
.. "mods/CORE/mcl_mapgen/API.md and update " .. minetest.get_current_modname()
.. " to use the method described from there. MineClone5 makes no promises that "
.. "mapgen mods will be fully compatible with it, please test your server and use at "
.. "your own risk.")
return register_on_generated_old(...)
end
minetest.register_on_generated = mcl_mapgen.register_chunk_generator
function mcl_mapgen.get_far_node(p)
local p = p
@ -450,21 +440,6 @@ function mcl_mapgen.get_chunk_number(pos) -- unsigned int
c.x + k_positive
end
-- Components of this game should register functions here to update their internal
-- state when external mods modify mapgen settings that they care about.
local settings_changed_callbacks = {}
function mcl_mapgen.register_on_settings_changed(callback)
table.insert(settings_changed_callbacks, callback)
end
-- this is to be called by external mods after modifying these settings
-- to notify Mineclone that it needs to update local copies and whatever's based on them.
function mcl_mapgen.on_settings_changed()
for _, callback in pairs(settings_changed_callbacks) do
callback()
end
end
mcl_mapgen.minecraft_height_limit = 256
mcl_mapgen.bedrock_is_rough = normal

View File

@ -2,18 +2,11 @@ mcl_worlds = {}
local get_connected_players = minetest.get_connected_players
local min1, min2, min3
local max1, max2, max3
local get_local_settings = function()
min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min
max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max+128
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
-- For a given position, returns a 2-tuple:
-- 1st return value: true if pos is in void
-- 2nd return value: true if it is in the deadly part of the void
local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min
local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max+128
function mcl_worlds.is_in_void(pos)
local y = pos.y
local void = not ((y < max1 and y > min1) or (y < max2 and y > min2) or (y < max3 and y > min3))

View File

@ -229,23 +229,19 @@ mobs_mc.override.spawn = {
}
-- This table contains important spawn height references for the mob spawn height.
local get_local_settings = function()
mobs_mc.override.spawn_height = {
water = tonumber(minetest.settings:get("water_level")) or 0, -- Water level in the Overworld
-- Overworld boundaries (inclusive)
overworld_min = mcl_mapgen.overworld.min,
overworld_max = mcl_mapgen.overworld.max,
-- Nether boundaries (inclusive)
nether_min = mcl_mapgen.nether.min,
nether_max = mcl_mapgen.nether.max,
-- End boundaries (inclusive)
end_min = mcl_mapgen.end_.min,
end_max = mcl_mapgen.end_.max,
}
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
mobs_mc.override.spawn_height = {
water = tonumber(minetest.settings:get("water_level")) or 0, -- Water level in the Overworld
-- Overworld boundaries (inclusive)
overworld_min = mcl_mapgen.overworld.min,
overworld_max = mcl_mapgen.overworld.max,
-- Nether boundaries (inclusive)
nether_min = mcl_mapgen.nether.min,
nether_max = mcl_mapgen.nether.max,
-- End boundaries (inclusive)
end_min = mcl_mapgen.end_.min,
end_max = mcl_mapgen.end_.max,
}

View File

@ -12,17 +12,9 @@ local floor = math.floor
local minetest_get_gametime = minetest.get_gametime
local get_voxel_manip = minetest.get_voxel_manip
local min1, min2, min3
local max1, max2, max3
local CS
local get_local_settings = function()
min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min
max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max+128
CS = mcl_mapgen.CS_NODES
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min
local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max + 128
local CS = mcl_mapgen.CS_NODES
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)

View File

@ -34,7 +34,7 @@ minetest.register_on_mods_loaded(function()
for name,def in pairs(minetest.registered_items) do
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then
local function is_redstone(def)
return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effector_off
return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off
end
local function is_tool(def)
return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil)

View File

@ -510,8 +510,8 @@ minetest.register_craft({
}
})
minetest.register_alias("mcl_furnaces:blast_furnace", "mcl_blast_furnace:blast_furnace")
minetest.register_alias("mcl_furnaces:blast_furnace_active", "mcl_blast_furnace:blast_furnace_active")
minetest.register_alias("mcl_blast_furnace:blast_furnace", "mcl_furnaces:blast_furnace")
minetest.register_alias("mcl_blast_furnace:blast_furnace_active", "mcl_furnaces:blast_furnace_active")
-- Add entry alias for the Help
if minetest.get_modpath("doc") then

View File

@ -91,7 +91,7 @@ minetest.register_craftitem("mcl_farming:potato_item", {
_doc_items_longdesc = S("Potatoes are food items which can be eaten, cooked in the furnace and planted. Pigs like potatoes."),
_doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant it. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."),
inventory_image = "farming_potato.png",
groups = { food = 2, eatable = 1, compostability=65, smoker_cookable=1 },
groups = { food = 2, eatable = 1, compostability=65 },
_mcl_saturation = 0.6,
stack_max = 64,
on_secondary_use = minetest.item_eat(1),

View File

@ -27,34 +27,8 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo
local DISTANCE_MAX = 128
local PORTAL = "mcl_portals:portal"
local OBSIDIAN = "mcl_core:obsidian"
local O_Y_MIN, O_Y_MAX
local N_Y_MIN, N_Y_MAX
local overworld_lava_max
local nether_lava_max
local overworld_min
local limits
local get_local_settings = function()
O_Y_MIN, O_Y_MAX = max(mcl_mapgen.overworld.min, -31), min(mcl_mapgen.overworld.max, 2048)
N_Y_MIN, N_Y_MAX = mcl_mapgen.nether.bedrock_bottom_min, mcl_mapgen.nether.bedrock_top_min - H_MIN
overworld_min = mcl_mapgen.overworld.min
overworld_lava_max = mcl_mapgen.overworld.lava_max
nether_lava_max = mcl_mapgen.nether.lava_max
limits = {
nether = {
pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN},
pmax = {x=LIM_MAX, y = N_Y_MAX, z = LIM_MAX},
},
overworld = {
pmin = {x=LIM_MIN, y = O_Y_MIN, z = LIM_MIN},
pmax = {x=LIM_MAX, y = O_Y_MAX, z = LIM_MAX},
},
}
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
local O_Y_MIN, O_Y_MAX = max(mcl_mapgen.overworld.min, -31), min(mcl_mapgen.overworld.max, 2048)
local N_Y_MIN, N_Y_MAX = mcl_mapgen.nether.bedrock_bottom_min, mcl_mapgen.nether.bedrock_top_min - H_MIN
-- Alpha and particles
local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none"
@ -105,6 +79,17 @@ local get_us_time = minetest.get_us_time
local dimension_to_teleport = { nether = "overworld", overworld = "nether" }
local limits = {
nether = {
pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN},
pmax = {x=LIM_MAX, y = N_Y_MAX, z = LIM_MAX},
},
overworld = {
pmin = {x=LIM_MIN, y = O_Y_MIN, z = LIM_MIN},
pmax = {x=LIM_MAX, y = O_Y_MAX, z = LIM_MAX},
},
}
-- This function registers exits from Nether portals.
-- Incoming verification performed: two nodes must be portal nodes, and an obsidian below them.
-- If the verification passes - position adds to the table and saves to mod storage on exit.
@ -179,7 +164,7 @@ local function find_exit(p, dx, dy, dz)
end
end
-- This function searches Nether portal nodes within distance specified and checks the node
-- This functon searches Nether portal nodes whitin distance specified and checks the node
local function find_exit_with_check(p, dx, dy, dz)
while true do
local pos = find_exit(p, dx, dy, dz)
@ -196,7 +181,7 @@ local function find_exit_with_check(p, dx, dy, dz)
end
end
-- Ping-Pong the coordinate for Fast Traveling, https://git.minetest.land/Wuzzy/MineClone2/issues/795#issuecomment-11058
-- Ping-Pong the coordinate for Fast Travelling, https://git.minetest.land/Wuzzy/MineClone2/issues/795#issuecomment-11058
local function ping_pong(x, m, l1, l2)
if x < 0 then
return l1 + abs(((x*m+l1) % (l1*4)) - (l1*2)), floor(x*m/l1/2) + ((ceil(x*m/l1)+1)%2) * ((x*m)%l1)/l1
@ -436,9 +421,9 @@ end
local function get_lava_level(pos, pos1, pos2)
if pos.y > -1000 then
return max(min(overworld_lava_max, pos2.y-1), pos1.y+1)
return max(min(mcl_mapgen.overworld.lava_max, pos2.y-1), pos1.y+1)
end
return max(min(nether_lava_max, pos2.y-1), pos1.y+1)
return max(min(mcl_mapgen.nether.lava_max, pos2.y-1), pos1.y+1)
end
local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
@ -761,7 +746,7 @@ minetest.register_abm({
return
end
if lower_node_name == OBSIDIAN and pos.y >= overworld_min and random(1, 750) == 19 then
if lower_node_name == OBSIDIAN and pos.y >= mcl_mapgen.overworld.min and random(1, 750) == 19 then
local pigman_obj = minetest.add_entity(pos, "mobs_mc:pigman")
if pigman_obj then
teleport_cooloff(pigman_obj)

View File

@ -509,8 +509,8 @@ minetest.register_craft({
}
})
minetest.register_alias("mcl_furnaces:smoker", "mcl_smoker:smoker")
minetest.register_alias("mcl_furnaces:smoker_active", "mcl_smoker:smoker_active")
minetest.register_alias("mcl_smoker:smoker", "mcl_furnaces:smoker")
minetest.register_alias("mcl_smoker:smoker_active", "mcl_furnaces:smoker_active")
-- Add entry alias for the Help
if minetest.get_modpath("doc") then

View File

@ -32,16 +32,9 @@ local math_ceil = math.ceil
--custom mcl_vars
local get_node = mcl_mapgen.get_far_node
local min_y
local max_y
local get_local_settings = function()
min_y = math_max(mcl_mapgen.overworld.min, mcl_mapgen.overworld.bedrock_max) + 1
max_y = mcl_mapgen.overworld.max - 1
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
local min_y = math_max(mcl_mapgen.overworld.min, mcl_mapgen.overworld.bedrock_max) + 1
local max_y = mcl_mapgen.overworld.max - 1
-- Calculate the number of dungeon spawn attempts
-- In Minecraft, there 8 dungeon spawn attempts Minecraft chunk (16*256*16 = 65536 blocks).
-- Minetest chunks don't have this size, so scale the number accordingly.

View File

@ -1214,34 +1214,25 @@ if flat then
air_layers[#air_layers + 1] = {mcl_mapgen.nether.flat_floor, mcl_mapgen.nether.flat_ceiling} -- Flat Nether
end
local barrier_min
local barrier_max
local void_layers
local bedrock_layers
-- Realm barrier between the Overworld void and the End
local barrier_min = mcl_mapgen.realm_barrier_overworld_end_min
local barrier_max = mcl_mapgen.realm_barrier_overworld_end_max
local get_local_settings = function()
-- Realm barrier between the Overworld void and the End
barrier_min = mcl_mapgen.realm_barrier_overworld_end_min
barrier_max = mcl_mapgen.realm_barrier_overworld_end_max
local void_layers = {
{mcl_mapgen.EDGE_MIN , mcl_mapgen.nether.min - 1 }, -- below Nether
{mcl_mapgen.nether.max + 129, mcl_mapgen.end_.min - 1 }, -- below End (above Nether)
{mcl_mapgen.end_.max + 1 , barrier_min - 1 }, -- below Realm Barrier, above End
{barrier_max + 1 , mcl_mapgen.overworld.min - 1}, -- below Overworld, above Realm Barrier
}
void_layers = {
{mcl_mapgen.EDGE_MIN , mcl_mapgen.nether.min - 1 }, -- below Nether
{mcl_mapgen.nether.max + 129, mcl_mapgen.end_.min - 1 }, -- below End (above Nether)
{mcl_mapgen.end_.max + 1 , barrier_min - 1 }, -- below Realm Barrier, above End
{barrier_max + 1 , mcl_mapgen.overworld.min - 1}, -- below Overworld, above Realm Barrier
local bedrock_layers = {}
if not singlenode then
bedrock_layers = {
{mcl_mapgen.overworld.bedrock_min , mcl_mapgen.overworld.bedrock_max },
{mcl_mapgen.nether.bedrock_bottom_min, mcl_mapgen.nether.bedrock_bottom_max},
{mcl_mapgen.nether.bedrock_top_min , mcl_mapgen.nether.bedrock_top_max },
}
bedrock_layers = {}
if not singlenode then
bedrock_layers = {
{mcl_mapgen.overworld.bedrock_min , mcl_mapgen.overworld.bedrock_max },
{mcl_mapgen.nether.bedrock_bottom_min, mcl_mapgen.nether.bedrock_bottom_max},
{mcl_mapgen.nether.bedrock_top_min , mcl_mapgen.nether.bedrock_top_max },
}
end
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
mcl_mapgen.register_mapgen_block_lvm(function(vm_context)
local vm, data, area, minp, maxp, chunkseed, blockseed = vm_context.vm, vm_context.data, vm_context.area, vm_context.minp, vm_context.maxp, vm_context.chunkseed, vm_context.blockseed

View File

@ -0,0 +1,154 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
local chance_per_chunk = 600
local noise_multiplier = 1.4
local random_offset = 555
local scanning_ratio = 0.00003
local struct_threshold = chance_per_chunk
local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_level
local schematic_file = modpath .. "/schematics/mcl_structures_pillager_outpost.mts"
local outpost_schematic_lua = minetest.serialize_schematic(schematic_file, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic"
local outpost_schematic = loadstring(outpost_schematic_lua)()
local function on_placed(p1, rotation, pr, size)
local p2 = {x = p1.x + size.x, y = p1.y + size.y, z = p1.z + size.z}
-- Find chests.
local chests = minetest.find_nodes_in_area(p1, p2, "mcl_chests:chest_small")
-- Add desert temple loot into chests
for c=1, #chests do
local lootitems = mcl_loot.get_multi_loot({
{
stacks_min = 2,
stacks_max = 3,
items = {
{ itemstring = "mcl_farming:wheat_item", weight = 7, amount_min = 3, amount_max=5 },
{ itemstring = "mcl_farming:carrot_item", weight = 5, amount_min = 3, amount_max=5 },
{ itemstring = "mcl_farming:potato_item", weight = 5, amount_min = 2, amount_max=5 },
}
},
{
stacks_min = 1,
stacks_max = 2,
items = {
{ itemstring = "mcl_experience:bottle", weight = 6, amount_min = 0, amount_max=1 },
{ itemstring = "mcl_bows:arrow", weight = 4, amount_min = 2, amount_max=7 },
{ itemstring = "mcl_mobitems:string", weight = 4, amount_min = 1, amount_max=6 },
{ itemstring = "mcl_core:iron_ingot", weight = 3, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_books:book", weight = 1, func = function(stack, pr)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr)
end },
}
},
{
stacks_min = 1,
stacks_max = 3,
items = {
{ itemstring = "mcl_core:darktree", amount_min = 2, amount_max=3 },
}
},
{
stacks_min = 1,
stacks_max = 1,
items = {
{ itemstring = "mcl_bows:crossbow" },
}
}
}, pr)
mcl_structures.init_node_construct(chests[c])
local meta = minetest.get_meta(chests[c])
local inv = meta:get_inventory()
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
end
end
local function place(pos, rotation, pr)
local pos_below = {x = pos.x, y = pos.y - 1, z = pos.z}
local pos_outpost = {x = pos.x, y = pos.y, z = pos.z}
local node_below = minetest.get_node(pos_below)
local nn = node_below.name,
mcl_structures.place_schematic({pos = pos_outpost, schematic = outpost_schematic, pr = pr, on_placed = on_placed})
local p1 = pos
local p2 = vector.offset(pos,14,20,14)
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 p = sp[pr:next(1,#sp)]
if p then
minetest.add_entity(p,"mobs_mc:pillager")
end
end
local p = sp[pr:next(1,#sp)]
if p then
minetest.add_entity(p,"mobs_mc:evoker")
end
end
end
local function get_place_rank(pos)
local x, y, z = pos.x, pos.y - 1, pos.z
local p1 = {x = x - 8, y = y, z = z - 8}
local p2 = {x = x + 8, y = y, z = z + 8}
local best_pos_list_surface = minetest.find_nodes_in_area(p1, p2, node_list, false)
local other_pos_list_surface = minetest.find_nodes_in_area(p1, p2, "group:opaque", false)
p1 = {x = x - 4, y = y - 7, z = z - 4}
p2 = {x = x + 4, y = y + 7, z = z + 4}
local best_pos_list_underground = minetest.find_nodes_in_area(p1, p2, node_list, false)
local other_pos_list_underground = minetest.find_nodes_in_area(p1, p2, "group:opaque", false)
return 10 * (#best_pos_list_surface) + 2 * (#other_pos_list_surface) + 5 * (#best_pos_list_underground) + #other_pos_list_underground
end
mcl_structures.register_structure({
name = "pillager_outpost",
decoration = {
deco_type = "simple",
place_on = node_list,
flags = "all_floors",
fill_ratio = scanning_ratio,
y_min = 3,
y_max = mcl_mapgen.overworld.max,
height = 1,
biomes = not mcl_mapgen.v6 and {
"Desert",
"Plains",
"Savanna",
"Desert_ocean",
"Taiga",
},
},
on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list)
local pr = PseudoRandom(seed + random_offset)
local random_number = pr:next(1, chance_per_chunk)
local noise = mcl_structures_get_perlin_noise_level(minp) * noise_multiplier
if (random_number + noise) < struct_threshold then return end
local pos = pos_list[1]
if #pos_list > 1 then
local count = get_place_rank(pos)
for i = 2, #pos_list do
local pos_i = pos_list[i]
local count_i = get_place_rank(pos_i)
if count_i > count then
count = count_i
pos = pos_i
end
end
end
place(pos, nil, pr)
end,
place_function = place
})

View File

@ -15,4 +15,5 @@ if not mcl_mapgen.singlenode then
dofile(modpath .. "/ruined_portal.lua")
dofile(modpath .. "/stronghold.lua")
dofile(modpath .. "/witch_hut.lua")
dofile(modpath .. "/pillager_outpost.lua")
end

View File

@ -94,21 +94,13 @@ if setting then
end
-- Max. and min. heights between rail corridors are generated
local height_min, height_max
local get_local_settings = function()
if mcl_mapgen.lava then
height_min = mcl_mapgen.overworld.lava_max + 2
else
height_min = mcl_mapgen.overworld.bedrock_max + 2
end
height_max = mcl_worlds.layer_to_y(60)
-- Allow mods to separately override this
height_min = mcl_mapgen.overworld.railcorridors_height_min or height_min
height_max = mcl_mapgen.overworld.railcorridors_height_max or height_max
local height_min
if mcl_mapgen.lava then
height_min = mcl_mapgen.overworld.lava_max + 2
else
height_min = mcl_mapgen.overworld.bedrock_max + 2
end
get_local_settings()
mcl_mapgen.register_on_settings_changed(get_local_settings)
local height_max = mcl_worlds.layer_to_y(60)
-- Chaos Mode: If enabled, rail corridors don't stop generating when hitting obstacles
local chaos_mode = minetest.settings:get_bool("tsm_railcorridors_chaos") or false