From 5a7952bf9251bdf549863a1e5731ab728ab2e3d8 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 11 Feb 2019 15:49:36 +0100 Subject: [PATCH] Set mob spawn chance to 2.5 and fix player respawn msg --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++-- mods/PLAYER/mcl_spawn/init.lua | 30 ++++++++++++++++++------------ settingtypes.txt | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 0f7057dfce..30b8a582f3 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -65,7 +65,7 @@ local remove_far = false local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 local show_health = false local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99) -local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 1) +local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 2.5) -- Peaceful mode message so players will know there are no monsters if peaceful_only then @@ -3335,7 +3335,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, nodenames = nodes, neighbors = neighbors, interval = interval, - chance = max(1, (chance * mobs_spawn_chance)), + chance = floor(max(1, chance * mobs_spawn_chance)), catch_up = false, action = spawn_abm_action, }) diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index d5391f7d2c..f97f1700cb 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -2,33 +2,37 @@ mcl_spawn = {} local mg_name = minetest.get_mapgen_setting("mg_name") --- Returns current spawn position of player. +-- Returns current custom spawn position of player. +-- Returns nil if player has no custom spawn position. -- If player is nil or not a player, the default spawn point is returned. -- The second return value is true if spawn point is player-chosen, -- false otherwise. mcl_spawn.get_spawn_pos = function(player) - local spawn, custom_spawn + local spawn, custom_spawn = nil, false if player ~= nil and player:is_player() then - spawn = minetest.string_to_pos(player:get_attribute("mcl_beds:spawn")) - custom_spawn = true + local attr = player:get_attribute("mcl_beds:spawn") + if attr ~= nil and attr ~= "" then + spawn = minetest.string_to_pos(attr) + custom_spawn = true + end end if not spawn or spawn == "" then spawn = minetest.setting_get_pos("static_spawnpoint") custom_spawn = false end - if not spawn then - spawn = { x=0, y=0, z=0 } - if mg_name == "flat" then - spawn.y = mcl_vars.mg_bedrock_overworld_max + 5 + if not spawn or spawn == "" then + local attr = player:get_attribute("mcl_spawn:first_spawn") + if attr ~= nil and attr ~= "" then + spawn = minetest.string_to_pos(attr) + custom_spawn = false end - custom_spawn = false end return spawn, custom_spawn end -- Sets the player's spawn position to pos. -- Set pos to nil to clear the spawn position. -mcl_spawn.set_spawn_pos = function(player, pos) +mcl_spawn.set_spawn_pos = function(player, pos, type) if pos == nil then player:set_attribute("mcl_beds:spawn", "") else @@ -39,7 +43,7 @@ end -- Respawn player at specified respawn position minetest.register_on_respawnplayer(function(player) local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) - if custom_spawn then + if pos and custom_spawn then -- Check if bed is still there -- and the spawning position is free of solid or damaging blocks. local node_bed = minetest.get_node(pos) @@ -65,5 +69,7 @@ minetest.register_on_respawnplayer(function(player) end) minetest.register_on_newplayer(function(player) - mcl_spawn.set_spawn_pos(player, player:get_pos()) + -- Remember where the player spawned first + player:set_attribute("mcl_spawn:first_spawn", minetest.pos_to_string(player:get_pos())) end) + diff --git a/settingtypes.txt b/settingtypes.txt index 69a51081e4..1adfec3fbe 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -62,7 +62,7 @@ mobs_spawn (Spawn mobs naturally) bool true # Controls the overall amount of mobs that spawn. The higher the number, # the less often mobs will spawn. This does not affect mob spawners. -mobs_spawn_chance (Mob spawn chance) float 1.0 0.0 +mobs_spawn_chance (Mob spawn chance) float 2.5 0.0 # If enabled, only peaceful mobs will appear naturally. This does not # affect mob spawners.