Add Breaking Changes: gamemode changes fly and noclip; chunksize set to 8

This commit is contained in:
kay27 2022-02-20 06:21:40 +04:00
parent e155db8f9e
commit ae63e32048
6 changed files with 55 additions and 2 deletions

View File

@ -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

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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)

View File

@ -1,3 +1,5 @@
mcl_commands = {}
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/gamemode.lua")