diff --git a/minetest.conf b/minetest.conf index 97d1f5cd6..22270e9c2 100644 --- a/minetest.conf +++ b/minetest.conf @@ -36,6 +36,10 @@ mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_de # Probably values >10 won't work because of numerous overridings. Type: int. max_block_generate_distance = 13 +# Size of mapchunks generated by mapgen, stated in mapblocks (16 nodes). +# type: int +chunksize = 8 + # MCL2-specific stuff keepInventory = false diff --git a/mods/MAPGEN/mcl_mapgen_core/biomes.lua b/mods/MAPGEN/mcl_mapgen_core/biomes.lua index d50f4da56..16a19f160 100644 --- a/mods/MAPGEN/mcl_mapgen_core/biomes.lua +++ b/mods/MAPGEN/mcl_mapgen_core/biomes.lua @@ -1,3 +1,4 @@ +local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass") local c_dirt_with_grass_snow = minetest.get_content_id("mcl_core:dirt_with_grass_snow") local c_top_snow = minetest.get_content_id("mcl_core:snow") local c_snow_block = minetest.get_content_id("mcl_core:snowblock") diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index e628321f0..f8a5d1b53 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -60,8 +60,6 @@ local flat = mcl_mapgen.flat -- Content IDs local c_bedrock = minetest.get_content_id("mcl_core:bedrock") -local c_dirt = minetest.get_content_id("mcl_core:dirt") -local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass") local c_void = minetest.get_content_id("mcl_core:void") local c_lava = minetest.get_content_id("mcl_core:lava_source") diff --git a/mods/MAPGEN/mcl_mapgen_core/nether.lua b/mods/MAPGEN/mcl_mapgen_core/nether.lua index 1b05d32bf..ec75c80a2 100644 --- a/mods/MAPGEN/mcl_mapgen_core/nether.lua +++ b/mods/MAPGEN/mcl_mapgen_core/nether.lua @@ -5,6 +5,7 @@ local mcl_mushrooms = minetest.get_modpath("mcl_mushrooms") local c_water = minetest.get_content_id("mcl_core:water_source") local c_stone = minetest.get_content_id("mcl_core:stone") local c_sand = minetest.get_content_id("mcl_core:sand") +local c_dirt = minetest.get_content_id("mcl_core:dirt") local c_soul_sand = minetest.get_content_id("mcl_nether:soul_sand") local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") diff --git a/mods/MISC/mcl_commands/gamemode.lua b/mods/MISC/mcl_commands/gamemode.lua index bd24a7685..8d720e21d 100644 --- a/mods/MISC/mcl_commands/gamemode.lua +++ b/mods/MISC/mcl_commands/gamemode.lua @@ -32,8 +32,17 @@ minetest.is_creative_enabled = function(name) return core_is_creative_enabled(name) end +local registered_functions_on_gamemode_change = {} + local function handle_gamemode_command(player_name, new_gamemode) + local old_gamemode_id = player_to_gamemode_id[player_name] + local old_gamemode = old_gamemode_id and id_to_gamemode[old_gamemode_id] player_to_gamemode_id[player_name] = gamemode_ids[new_gamemode] + if old_gamemode ~= new_gamemode then + for _, function_ref in pairs(registered_functions_on_gamemode_change) do + function_ref(player_name, old_gamemode, new_gamemode) + end + end return true end @@ -78,3 +87,41 @@ minetest.register_chatcommand("gamemode", { end end }) + +local action_id_to_index = {} + +function mcl_commands.register_on_gamemode_change(action_id, function_ref) + if action_id_to_index[action_id] then + minetest.log("warning", "[mcl_command] [gamemode] Duplicate register_on_gamemode_change action_id") + return + end + local new_index = #registered_functions_on_gamemode_change + 1 + registered_functions_on_gamemode_change[new_index] = function_ref + action_id_to_index[action_id] = new_index +end + +function mcl_commands.unregister_on_gamemode_change(action_id) + local old_index = action_id_to_index[action_id] + if not old_index then + minetest.log("warning", "[mcl_command] [gamemode] Can't unregister not registered action_id in unregister_on_gamemode_change") + return + end + table.remove(registered_functions_on_gamemode_change, old_index) + action_to_id[action_id] = nil +end + +mcl_commands.register_on_gamemode_change("check_fly_and_noclip", function(player_name, old_gamemode, new_gamemode) + if new_gamemode == "creative" then + local privs = minetest.get_player_privs(player_name) + if not privs then return end + privs.fly = true + privs.noclip = true + minetest.set_player_privs(player_name, privs) + elseif new_gamemode == "survival" then + local privs = minetest.get_player_privs(player_name) + if not privs then return end + privs.fly = nil + privs.noclip = nil + minetest.set_player_privs(player_name, privs) + end +end) diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index b6b07fb22..1fd5ecc3c 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -1,3 +1,5 @@ +mcl_commands = {} + local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/gamemode.lua")