forked from VoxeLibre/VoxeLibre
Message when trying to spawn forbidden hostile mob
This commit is contained in:
parent
f2b7392a30
commit
7a870d0ead
|
@ -50,8 +50,8 @@ end
|
||||||
|
|
||||||
-- Load settings
|
-- Load settings
|
||||||
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
||||||
local mobs_spawn = minetest.settings:get_bool("mobs_spawn") ~= false
|
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
||||||
local peaceful_only = minetest.settings:get_bool("only_peaceful_mobs")
|
|
||||||
local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
|
local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
|
||||||
local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false
|
local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
||||||
|
@ -65,7 +65,7 @@ local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or
|
||||||
local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 2.5)
|
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
|
-- Peaceful mode message so players will know there are no monsters
|
||||||
if peaceful_only then
|
if minetest.settings:get_bool("only_peaceful_mobs", false) then
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
S("Peaceful mode active! No monsters will spawn."))
|
S("Peaceful mode active! No monsters will spawn."))
|
||||||
|
@ -2756,7 +2756,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
|
|
||||||
-- remove monsters in peaceful mode
|
-- remove monsters in peaceful mode
|
||||||
if self.type == "monster"
|
if self.type == "monster"
|
||||||
and peaceful_only then
|
and minetest.settings:get_bool("only_peaceful_mobs", false) then
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
|
@ -3754,6 +3754,12 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if minetest.settings:get_bool("only_peaceful_mobs", false)
|
||||||
|
and minetest.registered_entities[mob].type == "monster" then
|
||||||
|
minetest.chat_send_player(name, S("Only peaceful mobs allowed!"))
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, mob)
|
local mob = minetest.add_entity(pos, mob)
|
||||||
|
|
|
@ -6,3 +6,4 @@ You need the “maphack” privilege to change the mob spawner.=Sie brauchen das
|
||||||
Name Tag=Namensschild
|
Name Tag=Namensschild
|
||||||
A name tag is an item to name a mob.=Ein Namensschild ist ein Gegenstand, um einen Mob zu benennen.
|
A name tag is an item to name a mob.=Ein Namensschild ist ein Gegenstand, um einen Mob zu benennen.
|
||||||
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=Bevor Sie ein Namensschild benutzen können, müssen Sie ihn an einem Amboss benennen. Dann können können Sie das Namensschild benutztn, um einen Mob zu benennen. Das wird das Namensschild verbrauchen.
|
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=Bevor Sie ein Namensschild benutzen können, müssen Sie ihn an einem Amboss benennen. Dann können können Sie das Namensschild benutztn, um einen Mob zu benennen. Das wird das Namensschild verbrauchen.
|
||||||
|
Only peaceful mobs allowed!=Nur friedliche Mobs erlaubt!
|
||||||
|
|
|
@ -6,3 +6,4 @@ You need the “maphack” privilege to change the mob spawner.=
|
||||||
Name Tag=
|
Name Tag=
|
||||||
A name tag is an item to name a mob.=
|
A name tag is an item to name a mob.=
|
||||||
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=
|
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=
|
||||||
|
Only peaceful mobs allowed!=
|
||||||
|
|
|
@ -126,6 +126,21 @@ local function register_chatcommand_alias(alias, cmd)
|
||||||
minetest.register_chatcommand(alias, def)
|
minetest.register_chatcommand(alias, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Replace spawnentity cmd to disallow spawning of hostile mobs if disabled
|
||||||
|
local orig_func = minetest.registered_chatcommands["spawnentity"].func
|
||||||
|
local cmd = table.copy(minetest.registered_chatcommands["spawnentity"])
|
||||||
|
cmd.func = function(name, param)
|
||||||
|
local ent = minetest.registered_entities[param]
|
||||||
|
if minetest.settings:get_bool("only_peaceful_mobs", false) and ent and ent._cmi_is_mob and ent.type == "monster" then
|
||||||
|
return false, S("Only peaceful mobs allowed!")
|
||||||
|
else
|
||||||
|
local bool, msg = orig_func(name, param)
|
||||||
|
return bool, msg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.unregister_chatcommand("spawnentity")
|
||||||
|
minetest.register_chatcommand("spawnentity", cmd)
|
||||||
|
|
||||||
if minecraftaliases then
|
if minecraftaliases then
|
||||||
register_chatcommand_alias("?", "help")
|
register_chatcommand_alias("?", "help")
|
||||||
register_chatcommand_alias("who", "list")
|
register_chatcommand_alias("who", "list")
|
||||||
|
@ -145,3 +160,4 @@ if minecraftaliases then
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,4 @@ List bans=Bannliste anzeigen
|
||||||
Ban list: @1=Bannliste: @1
|
Ban list: @1=Bannliste: @1
|
||||||
Show who is logged on=Anzeigen, wer eingeloggt ist
|
Show who is logged on=Anzeigen, wer eingeloggt ist
|
||||||
Displays the world seed=Den Seed der Welt anzeigen
|
Displays the world seed=Den Seed der Welt anzeigen
|
||||||
|
Only peaceful mobs allowed!=Nur friedliche Mobs erlaubt!
|
||||||
|
|
|
@ -20,3 +20,4 @@ List bans=
|
||||||
Ban list: @1=
|
Ban list: @1=
|
||||||
Show who is logged on=
|
Show who is logged on=
|
||||||
Displays the world seed=
|
Displays the world seed=
|
||||||
|
Only peaceful mobs allowed!=
|
||||||
|
|
Loading…
Reference in New Issue