code tidy, updated readme (thx eschan145)

This commit is contained in:
tenplus1 2023-03-25 08:47:31 +00:00
parent 076b9480b7
commit 3bd2ee8129
2 changed files with 455 additions and 229 deletions

214
api.lua
View File

@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20230313", version = "20230325",
intllib = S, intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {} invis = minetest.global_exists("invisibility") and invisibility or {}
} }
@ -61,8 +61,7 @@ local settings = minetest.settings
-- creative check -- creative check
local creative_cache = minetest.settings:get_bool("creative_mode") local creative_cache = minetest.settings:get_bool("creative_mode")
function mobs.is_creative(name) function mobs.is_creative(name)
return creative_cache or minetest.check_player_privs(name, return creative_cache or minetest.check_player_privs(name, {creative = true})
{creative = true})
end end
-- Load settings -- Load settings
@ -92,7 +91,8 @@ local pathfinding_enable = settings:get_bool("mob_pathfinding_enable") or true
-- Use pathfinder mod if available -- Use pathfinder mod if available
local pathfinder_enable = settings:get_bool("mob_pathfinder_enable") or true local pathfinder_enable = settings:get_bool("mob_pathfinder_enable") or true
-- how long before stuck mobs start searching -- how long before stuck mobs start searching
local pathfinding_stuck_timeout = tonumber(settings:get("mob_pathfinding_stuck_timeout")) or 3.0 local pathfinding_stuck_timeout = tonumber(
settings:get("mob_pathfinding_stuck_timeout")) or 3.0
-- how long will mob follow path before giving up -- how long will mob follow path before giving up
local pathfinding_stuck_path_timeout = tonumber(settings:get("mob_pathfinding_stuck_path_timeout")) or 5.0 local pathfinding_stuck_path_timeout = tonumber(settings:get("mob_pathfinding_stuck_path_timeout")) or 5.0
-- which algorithm to use, Dijkstra(default) or A*_noprefetch or A* -- which algorithm to use, Dijkstra(default) or A*_noprefetch or A*
@ -106,7 +106,8 @@ elseif pathfinding_algorithm == "AStar" then
end end
-- max search distance from search positions (default 16) -- max search distance from search positions (default 16)
local pathfinding_searchdistance = tonumber(settings:get("mob_pathfinding_searchdistance") or 16) local pathfinding_searchdistance = tonumber(
settings:get("mob_pathfinding_searchdistance") or 16)
-- max jump height (default 4) -- max jump height (default 4)
local pathfinding_max_jump = tonumber(settings:get("mob_pathfinding_max_jump") or 4) local pathfinding_max_jump = tonumber(settings:get("mob_pathfinding_max_jump") or 4)
-- max drop height (default 6) -- max drop height (default 6)
@ -340,8 +341,7 @@ function mob_class:set_velocity(v)
-- only slow mob trying to move while inside a viscous fluid that -- only slow mob trying to move while inside a viscous fluid that
-- they aren't meant to be in (fish in water, spiders in cobweb etc) -- they aren't meant to be in (fish in water, spiders in cobweb etc)
if v > 0 and visc and visc > 0 if v > 0 and visc and visc > 0 and not check_for(self.standing_in, self.fly_in) then
and not check_for(self.standing_in, self.fly_in) then
v = v / (visc + 1) v = v / (visc + 1)
end end
@ -499,9 +499,7 @@ local line_of_sight = function(self, pos1, pos2, stepsize)
-- NaN checks -- NaN checks
if d == 0 if d == 0
or npos1.x ~= npos1.x or npos1.x ~= npos1.x or npos1.y ~= npos1.y or npos1.z ~= npos1.z then
or npos1.y ~= npos1.y
or npos1.z ~= npos1.z then
return false return false
end end
@ -709,8 +707,8 @@ local effect = function(pos, amount, texture, min_size, max_size,
}) })
end end
function mobs:effect(pos, amount, texture, min_size, max_size, function mobs:effect(
radius, gravity, glow, fall) pos, amount, texture, min_size, max_size, radius, gravity, glow, fall)
effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, fall) effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, fall)
end end
@ -1807,8 +1805,8 @@ function mob_class:smart_mobs(s, p, dist, dtime)
if pathfinder_mod and pathfinder_enable then if pathfinder_mod and pathfinder_enable then
self.path.way = pathfinder.find_path(s, p1, self, dtime) self.path.way = pathfinder.find_path(s, p1, self, dtime)
else else
self.path.way = minetest.find_path(s, p1, pathfinding_searchdistance, jumpheight, self.path.way = minetest.find_path(s, p1, pathfinding_searchdistance,
dropheight, pathfinding_algorithm) jumpheight, dropheight, pathfinding_algorithm)
end end
--[[ --[[
-- show path using particles -- show path using particles
@ -2075,8 +2073,7 @@ function mob_class:do_runaway_from()
dist = get_distance(p, s) dist = get_distance(p, s)
-- choose closest player/mob to runaway from -- choose closest player/mob to runaway from
if dist < min_dist if dist < min_dist and self:line_of_sight(sp, p, 2) == true then
and self:line_of_sight(sp, p, 2) == true then
min_dist = dist min_dist = dist
min_player = player min_player = player
end end
@ -2126,16 +2123,13 @@ function mob_class:follow_flop()
-- npc stop following player if not owner -- npc stop following player if not owner
if self.following if self.following
and self.owner and self.owner and self.owner ~= self.following:get_player_name() then
and self.owner ~= self.following:get_player_name() then
self.following = nil self.following = nil
end end
else else
-- stop following player if not holding specific item or mob is horny -- stop following player if not holding specific item or mob is horny
if self.following if self.following and self.following:is_player()
and self.following:is_player() and (self:follow_holding(self.following) == false or self.horny) then
and (self:follow_holding(self.following) == false
or self.horny) then
self.following = nil self.following = nil
end end
@ -2148,11 +2142,8 @@ function mob_class:follow_flop()
local p local p
if self.following:is_player() then if self.following:is_player() then
p = self.following:get_pos() p = self.following:get_pos()
elseif self.following.object then elseif self.following.object then
p = self.following.object:get_pos() p = self.following.object:get_pos()
end end
@ -2219,17 +2210,14 @@ end
function mob_class:dogswitch(dtime) function mob_class:dogswitch(dtime)
-- switch mode not activated -- switch mode not activated
if not self.dogshoot_switch if not self.dogshoot_switch or not dtime then
or not dtime then
return 0 return 0
end end
self.dogshoot_count = self.dogshoot_count + dtime self.dogshoot_count = self.dogshoot_count + dtime
if (self.dogshoot_switch == 1 if (self.dogshoot_switch == 1 and self.dogshoot_count > self.dogshoot_count_max)
and self.dogshoot_count > self.dogshoot_count_max) or (self.dogshoot_switch == 2 and self.dogshoot_count > self.dogshoot_count2_max) then
or (self.dogshoot_switch == 2
and self.dogshoot_count > self.dogshoot_count2_max) then
self.dogshoot_count = 0 self.dogshoot_count = 0
@ -2349,8 +2337,7 @@ function mob_class:do_states(dtime)
self:set_yaw(yaw, 8) self:set_yaw(yaw, 8)
-- for flying/swimming mobs randomly move up and down also -- for flying/swimming mobs randomly move up and down also
if self.fly_in if self.fly_in and not self.following then
and not self.following then
self:attempt_flight_correction(true) self:attempt_flight_correction(true)
end end
end end
@ -2361,8 +2348,7 @@ function mob_class:do_states(dtime)
or random(100) <= self.stand_chance then or random(100) <= self.stand_chance then
-- don't stand if mob flies and keep_flying set -- don't stand if mob flies and keep_flying set
if (self.fly and not self.keep_flying) if (self.fly and not self.keep_flying) or not self.fly then
or not self.fly then
self:set_velocity(0) self:set_velocity(0)
self.state = "stand" self.state = "stand"
@ -2550,35 +2536,21 @@ function mob_class:do_states(dtime)
if me_y < p_y then if me_y < p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x, y = 1 * self.walk_velocity, z = v.z})
y = 1 * self.walk_velocity,
z = v.z
})
elseif me_y > p_y then elseif me_y > p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x, y = -1 * self.walk_velocity, z = v.z})
y = -1 * self.walk_velocity,
z = v.z
})
end end
else else
if me_y < p_y then if me_y < p_y then
self.object:set_velocity({ self.object:set_velocity({x = v.x, y = 0.01, z = v.z})
x = v.x,
y = 0.01,
z = v.z
})
elseif me_y > p_y then elseif me_y > p_y then
self.object:set_velocity({ self.object:set_velocity({x = v.x, y = -0.01, z = v.z})
x = v.x,
y = -0.01,
z = v.z
})
end end
end end
end end
@ -2589,8 +2561,7 @@ function mob_class:do_states(dtime)
and self.attack_type ~= "dogshoot" then and self.attack_type ~= "dogshoot" then
-- no paths longer than 50 -- no paths longer than 50
if #self.path.way > 50 if #self.path.way > 50 or dist < self.reach then
or dist < self.reach then
self.path.following = false self.path.following = false
return return
end end
@ -2616,10 +2587,8 @@ function mob_class:do_states(dtime)
-- move towards enemy if beyond mob reach -- move towards enemy if beyond mob reach
if dist > (self.reach + (self.reach_ext or 0)) then if dist > (self.reach + (self.reach_ext or 0)) then
-- path finding by rnd -- path finding by rnd (only when enabled in setting and mob)
if self.pathfinding -- only if mob has pathfinding enabled if self.pathfinding and pathfinding_enable then
and pathfinding_enable then
self:smart_mobs(s, p, dist, dtime) self:smart_mobs(s, p, dist, dtime)
end end
@ -2709,8 +2678,7 @@ function mob_class:do_states(dtime)
self:set_velocity(0) self:set_velocity(0)
if self.shoot_interval if self.shoot_interval and self.timer > self.shoot_interval
and self.timer > self.shoot_interval
and random(100) <= 60 then and random(100) <= 60 then
self.timer = 0 self.timer = 0
@ -2816,17 +2784,14 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
return true return true
end end
-- custom punch function -- custom punch function (if false returned, do not continue and return true)
if self.do_punch if self.do_punch and self:do_punch(hitter, tflp, tool_capabilities, dir) == false then
and self:do_punch(hitter, tflp, tool_capabilities, dir) == false then
return true return true
end end
-- error checking when mod profiling is enabled -- error checking when mod profiling is enabled
if not tool_capabilities then if not tool_capabilities then
minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled") minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled")
return true return true
end end
@ -2853,11 +2818,8 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
local ent = hitter and hitter:get_luaentity() local ent = hitter and hitter:get_luaentity()
if ent and ent._is_arrow then if ent and ent._is_arrow then
return true -- arrow entity return true -- arrow entity
elseif not ent then elseif not ent then
return true -- non entity return true -- non entity
end end
end end
@ -2932,12 +2894,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
local wear = floor((punch_interval / 75) * 9000) local wear = floor((punch_interval / 75) * 9000)
if mobs.is_creative(hitter:get_player_name()) then if mobs.is_creative(hitter:get_player_name()) then
wear = tr and 1 or 0
if tr then
wear = 1
else
wear = 0
end
end end
if tr and weapon_def.original_description then if tr and weapon_def.original_description then
@ -3046,8 +3003,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
end end
-- if skittish then run away -- if skittish then run away
if self.runaway == true if self.runaway == true and self.order ~= "stand" then
and self.order ~= "stand" then
local lp = hitter:get_pos() local lp = hitter:get_pos()
@ -3088,7 +3044,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
and obj.state ~= "attack" and obj.state ~= "attack"
and obj.owner ~= name and obj.owner ~= name
and (obj.name == self.name or obj.name == self.group_helper) then and (obj.name == self.name or obj.name == self.group_helper) then
obj:do_attack(hitter) obj:do_attack(hitter)
end end
@ -3140,8 +3095,7 @@ function mob_class:mob_staticdata()
end end
if use_cmi then if use_cmi then
self.serialized_cmi_components = cmi.serialize_components( self.serialized_cmi_components = cmi.serialize_components(self._cmi_components)
self._cmi_components)
end end
local tmp, t = {} local tmp, t = {}
@ -3199,9 +3153,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
t = type(stat) t = type(stat)
if t ~= "function" if t ~= "function" and t ~= "nil" and t ~= "userdata" then
and t ~= "nil"
and t ~= "userdata" then
self[_] = stat self[_] = stat
end end
end end
@ -3303,10 +3255,8 @@ function mob_class:mob_activate(staticdata, def, dtime)
self.standing_in = "air" self.standing_in = "air"
self.standing_on = "air" self.standing_on = "air"
-- check existing nametag -- check for existing nametag
if not self.nametag then self.nametag = self.nametag or def.nametag
self.nametag = def.nametag
end
-- set anything changed above -- set anything changed above
self.object:set_properties(self) self.object:set_properties(self)
@ -3323,10 +3273,8 @@ function mob_class:mob_activate(staticdata, def, dtime)
end end
-- run on_spawn function if found -- run on_spawn function if found
if self.on_spawn and not self.on_spawn_run then if self.on_spawn and not self.on_spawn_run and self.on_spawn(self) then
if self.on_spawn(self) then self.on_spawn_run = true -- if true, set flag to run once only
self.on_spawn_run = true -- if true, set flag to run once only
end
end end
-- run after_activate -- run after_activate
@ -3402,11 +3350,7 @@ function mob_class:on_step(dtime, moveresult)
self.node_timer = 0 self.node_timer = 0
local y_level = self.collisionbox[2] local y_level = self.child and self.collisionbox[2] * 0.5 or self.collisionbox[2]
if self.child then
y_level = self.collisionbox[2] * 0.5
end
-- what is mob standing in? -- what is mob standing in?
self.standing_in = node_ok({ self.standing_in = node_ok({
@ -3420,12 +3364,7 @@ function mob_class:on_step(dtime, moveresult)
-- if standing inside solid block then jump to escape -- if standing inside solid block then jump to escape
if minetest.registered_nodes[self.standing_in].walkable if minetest.registered_nodes[self.standing_in].walkable
and minetest.registered_nodes[self.standing_in].drawtype == "normal" then and minetest.registered_nodes[self.standing_in].drawtype == "normal" then
self.object:set_velocity({x = 0, y = self.jump_height, z = 0 })
self.object:set_velocity({
x = 0,
y = self.jump_height,
z = 0
})
end end
-- check and stop if standing at cliff and fear of heights -- check and stop if standing at cliff and fear of heights
@ -3501,13 +3440,9 @@ function mob_class:on_step(dtime, moveresult)
return return
end end
-- run custom function (defined in mob lua file) -- run custom function (defined in mob lua file) - when false skip going any further
if self.do_custom then if self.do_custom and self:do_custom(dtime) == false then
return
-- when false skip going any further
if self:do_custom(dtime) == false then
return
end
end end
-- attack timer -- attack timer
@ -3554,9 +3489,7 @@ function mob_class:on_blast(damage)
--print("-- blast damage", damage) --print("-- blast damage", damage)
self.object:punch(self.object, 1.0, { self.object:punch(self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, nil)
damage_groups = {fleshy = damage},
}, nil)
-- return no damage, no knockback, no item drops, mob api handles all -- return no damage, no knockback, no item drops, mob api handles all
return false, false, {} return false, false, {}
@ -3820,8 +3753,7 @@ function mobs:add_mob(pos, def)
return return
end end
local aoc = mobs.spawning_mobs[def.name] local aoc = mobs.spawning_mobs[def.name] and mobs.spawning_mobs[def.name].aoc or 1
and mobs.spawning_mobs[def.name].aoc or 1
if def.ignore_count ~= true and num_mob >= aoc then if def.ignore_count ~= true and num_mob >= aoc then
--print("--- too many " .. def.name .. " in area", num_mob .. "/" .. aoc) --print("--- too many " .. def.name .. " in area", num_mob .. "/" .. aoc)
@ -3848,7 +3780,7 @@ function mobs:add_mob(pos, def)
textures = ent.child_texture[1] textures = ent.child_texture[1]
end end
-- and resize to half height -- and resize to half height (multiplication is faster than division)
mob:set_properties({ mob:set_properties({
textures = textures, textures = textures,
visual_size = { visual_size = {
@ -3935,8 +3867,8 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
mobs.spawning_mobs[name].aoc = aoc mobs.spawning_mobs[name].aoc = aoc
local spawn_action = function(pos, node, active_object_count, local spawn_action = function(
active_object_count_wider) pos, node, active_object_count, active_object_count_wider)
-- use instead of abm's chance setting when using lbm -- use instead of abm's chance setting when using lbm
if map_load and random(max(1, (chance * mob_chance_multiplier))) > 1 then if map_load and random(max(1, (chance * mob_chance_multiplier))) > 1 then
@ -3968,8 +3900,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
end end
-- do not spawn if too many entities in area -- do not spawn if too many entities in area
if active_object_count_wider if active_object_count_wider and active_object_count_wider >= max_per_block then
and active_object_count_wider >= max_per_block then
--print("--- too many entities in area", active_object_count_wider) --print("--- too many entities in area", active_object_count_wider)
return return
end end
@ -4011,17 +3942,14 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
pos.y = pos.y + 1 pos.y = pos.y + 1
-- are we spawning within height limits? -- are we spawning within height limits?
if pos.y > max_height if pos.y > max_height or pos.y < min_height then
or pos.y < min_height then
--print("--- height limits not met", name, pos.y) --print("--- height limits not met", name, pos.y)
return return
end end
-- are light levels ok? -- are light levels ok?
local light = minetest.get_node_light(pos) local light = minetest.get_node_light(pos)
if not light if not light or light > max_light or light < min_light then
or light > max_light
or light < min_light then
--print("--- light limits not met", name, light) --print("--- light limits not met", name, light)
return return
end end
@ -4101,9 +4029,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
spawn_action(pos, node) spawn_action(pos, node)
end end
}) })
else else
minetest.register_abm({ minetest.register_abm({
label = name .. " spawning", label = name .. " spawning",
nodenames = nodes, nodenames = nodes,
@ -4225,8 +4151,7 @@ function mobs:register_arrow(name, def)
self.lastpos = (self.lastpos or pos) self.lastpos = (self.lastpos or pos)
minetest.add_item(self.lastpos, minetest.add_item(self.lastpos, self.object:get_luaentity().name)
self.object:get_luaentity().name)
end end
self.object:remove() ; -- print("hit node") self.object:remove() ; -- print("hit node")
@ -4237,8 +4162,7 @@ function mobs:register_arrow(name, def)
if self.hit_player or self.hit_mob or self.hit_object then if self.hit_player or self.hit_mob or self.hit_object then
for _,player in pairs( for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.0)) do
minetest.get_objects_inside_radius(pos, 1.0)) do
if self.hit_player and player:is_player() then if self.hit_player and player:is_player() then
@ -4259,7 +4183,7 @@ function mobs:register_arrow(name, def)
self:hit_mob(player) self:hit_mob(player)
self.object:remove() ; --print("hit mob") self.object:remove() ; -- print("hit mob")
return return
end end
@ -4420,8 +4344,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
pointed_thing.under, under, placer, itemstack, pointed_thing) pointed_thing.under, under, placer, itemstack, pointed_thing)
end end
if pos if pos and not minetest.is_protected(pos, placer:get_player_name()) then
and not minetest.is_protected(pos, placer:get_player_name()) then
if not minetest.registered_entities[mob] then if not minetest.registered_entities[mob] then
return return
@ -4444,8 +4367,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
if not ent then return end -- sanity check if not ent then return end -- sanity check
-- don't set owner if monster or sneak pressed -- don't set owner if monster or sneak pressed
if ent.type ~= "monster" if ent.type ~= "monster" and not placer:get_player_control().sneak then
and not placer:get_player_control().sneak then
ent.owner = placer:get_player_name() ent.owner = placer:get_player_name()
ent.tamed = true ent.tamed = true
end end
@ -4502,12 +4424,10 @@ end
-- capture critter (thanks to blert2112 for idea) -- capture critter (thanks to blert2112 for idea)
function mobs:capture_mob(self, clicker, chance_hand, chance_net, function mobs:capture_mob(
chance_lasso, force_take, replacewith) self, clicker, chance_hand, chance_net, chance_lasso, force_take, replacewith)
if not self if not self or not clicker:is_player() or not clicker:get_inventory() then
or not clicker:is_player()
or not clicker:get_inventory() then
return false return false
end end
@ -4644,8 +4564,7 @@ function mobs:protect(self, clicker)
local tool = clicker:get_wielded_item() local tool = clicker:get_wielded_item()
local tool_name = tool:get_name() local tool_name = tool:get_name()
if tool_name ~= "mobs:protector" if tool_name ~= "mobs:protector" and tool_name ~= "mobs:protector2" then
and tool_name ~= "mobs:protector2" then
return false return false
end end
@ -4691,8 +4610,7 @@ local mob_sta = {}
function mobs:feed_tame(self, clicker, feed_count, breed, tame) function mobs:feed_tame(self, clicker, feed_count, breed, tame)
-- can eat/tame with item in hand -- can eat/tame with item in hand
if self.follow if self.follow and self:follow_holding(clicker) then
and self:follow_holding(clicker) then
-- if not in creative then take item -- if not in creative then take item
if not mobs.is_creative(clicker:get_player_name()) then if not mobs.is_creative(clicker:get_player_name()) then
@ -4812,14 +4730,11 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
-- right-clicked with nametag and name entered? -- right-clicked with nametag and name entered?
if formname == "mobs_nametag" if formname == "mobs_nametag" and fields.name and fields.name ~= "" then
and fields.name
and fields.name ~= "" then
local name = player:get_player_name() local name = player:get_player_name()
if not mob_obj[name] if not mob_obj[name] or not mob_obj[name].object then
or not mob_obj[name].object then
return return
end end
@ -4919,7 +4834,6 @@ minetest.register_chatcommand("clear_mobs", {
if player then if player then
local pos = player:get_pos() local pos = player:get_pos()
local objs = minetest.get_objects_inside_radius(pos, 28) local objs = minetest.get_objects_inside_radius(pos, 28)
for _, obj in pairs(objs) do for _, obj in pairs(objs) do

470
readme.MD
View File

@ -1,88 +1,400 @@
# MOBS REDO for MINETEST # MOBS REDO for MINETEST
Built from PilzAdam's original Simple Mobs with additional mobs by KrupnoPavel, Zeg9, ExeterDad and AspireMint. Built from PilzAdam's original Simple Mobs with additional mobs by KrupnoPavel,
Zeg9, ExeterDad and AspireMint.
This mod contains the API only for adding your own mobs into the world, so please use the additional modpacks to add animals, monsters etc. This mod contains the API only for adding your own mobs into the world, so
please use the additional modpacks to add animals, monsters, and npcs.
https://forum.minetest.net/viewtopic.php?f=11&t=9917 https://forum.minetest.net/viewtopic.php?f=11&t=9917
Crafts: ## Crafts
- Nametag (paper, black dye, string) can be used right-click on a tamed mob to give them a name. - **Nametag**. Can be crafted by paper, black dye, and string. Can be used
- Nets can be used to right-click tamed mobs to pick them up and place inside inventory as a spawn egg. to right-click on a tamed mob to give them a name.
- Magic Lasso is similar to nets but with a better chance of picking up larger mobs. - **Net**. Used to right-click tamed mobs to pick them up and place inside
- Shears are used to right-click sheep and return 1-3 wool. inventory as a spawn egg.
- Protection Rune lets you protect tamed mobs from harm by other players - **Magic lasso**. Similar to nets but with a better chance of picking up
- Mob Fence and Fence Top (to stop mobs escaping/glitching through fences) larger mobs.
- **Shears**. Used to right-click sheep and return 1-3 wool.
- **Protection Rune**. Protects tamed mobs from being harmed by other players.
- **Mob Fence and Fence Top**. Stops mobs escaping or glitching throughfences.
Lucky Blocks: 12 **Lucky Blocks**: 12
Changelog: ## Changelog
- 1.56 - Added arrow_override function to mob definition to tweak arrow entity settings, tamed monsters no longer despawn when outside loaded map area, 'looting_level' can be read from tool definition or tool meta to add extra drops when mob killed. Added injured animation and mob hit effect.
- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence), add support for MarkBu's pathfinder mod, remove need for default mod ### Version 1.56
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded. * Added `arrow_override` function to mob definition to tweak arrow entity settings
- 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game, * Added injured animation and mob hit effect
(default is 0 for unlimited), removed {immortal} from mob armor, fluid viscocity slows mobs * Tamed monsters no longer despawn when outside loaded map area
- 1.51 - Added some node checks for dangerous nodes, jumping and falling tweaks, spawn area check (thx for idea wuzzy), re-enabled mob suffocation, add 'mob_nospawn_range' setting * `looting_level` can be read from tool definition or tool meta to add extra
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found, (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added drops when mob killed
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
- 1.48- Add mobs:set_velocity(self, velocity) global function ### Version 1.55
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
- 1.46- Mobs only drop rare items when killed by player (drops.min = 0 makes them rare), code tweak, pathfinding no longer sees through walkable nodes * Added `peaceful_player` privilege and setting so mobs don't attack specific
- 1.45- Added Fence Top to add on top of any fence to stop mobs escaping, new line_of_sight tweaked by Astrobe players (thanks sfence)
- 1.44- Added ToolRanks support for swords when attacking mobs * Added support for MarkBu's `pathfinder` mod, remove need for default mod
- 1.43- Better 0.4.16 compatibility, added general attack function and settings
- 1.42- Added "all" option to immune_to table, tidied floating mobs to be less intensive ### Version 1.54
- 1.41- Mob pathfinding has been updated thanks to Elkien3
- 1.40- Updated to use newer functions, requires Minetest 0.4.16+ to work. * **New support for swimming mobs**
- 1.39- Added 'on_breed', 'on_grown' and 'do_punch' custom functions per mob - `on_flop` (for mobs not in water)
- 1.38- Better entity checking, nametag setting and on_spawn function added to mob registry, tweaked light damage - `air_damage` added
- 1.37- Added support for Raymoo's CMI (common mob interface) mod: https://forum.minetest.net/viewtopic.php?f=9&t=15448 * Added editable settings (thanks Wuzzy)
- 1.36- Death check added, if mob dies in fire/lava/with lava pick then drops are cooked * Simplified animal breeding function
- 1.35- Added owner_loyal flag for owned mobs to attack player enemies, also fixed group_attack * Child mobs now take twenty minutes to grow up
- 1.34- Added function to fly mob using directional movement (thanks D00Med for flying code) * Reverted to simple mob spawning with setting to use area checks
- 1.33- Added functions to mount ride mobs (mobs.attach, mobs.detach, mobs.drive) many thanks to Blert2112
- 1.32- Added new spawn check to count specific mobs AND new minetest.conf setting to chance spawn chance and numbers, added ability to protect tamed mobs ### Version 1.53
- 1.31- Added 'attack_animals' and 'specific_attack' flags for custom monster attacks, also 'mob_difficulty' .conf setting to make mobs harder.
- 1.30- Added support for invisibility mod (mobs cant attack what they cant see), tweaked and tidied code * Added `on_map_load` settings to `mobs:spawn` so that mobs will only spawn
- 1.29- Split original Mobs Redo into a modpack to make it easier to disable mob sets (animal, monster, npc) or simply use the Api itself for your own mod when new areas of map are loaded.
- 1.28- New damage system added with ability for mob to be immune to weapons or healed by them :)
- 1.27- Added new sheep, lava flan and spawn egg textures. New Lava Pick tool smelts what you dig. New atan checking function. ### Version 1.52
- 1.26- Pathfinding feature added thanks to rnd, when monsters attack they become scary smart in finding you :) also, beehive produces honey now :)
- 1.25- Mobs no longer spawn within 12 blocks of player or despawn within same range, spawners now have player detection, Code tidy and tweak. * Added `mob_active_limit` in settings to set number of mobs in game. The
- 1.24- Added feature where certain animals run away when punched (runaway = true in mob definition) default is 0, for unlimited mobs.
- 1.23- Added mob spawner block for admin to setup spawners in-game (place and right click to enter settings) * Removed `{immortal}` from mob armor
- 1.22- Added ability to name tamed animals and npc using nametags, also npc will attack anyone who punches them apart from owner * Fluid viscocity slows mobs (for example, water)
- 1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
- 1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error ### Version 1.51
- 1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
- 1.18- Added docile_by_day flag so that monsters will not attack automatically during daylight hours unless hit first * Added node checks for dangerous nodes
- 1.17- Added 'dogshoot' attack type, shoots when out of reach, melee attack when in reach, also api tweaks and self.reach added * Add `mob_nospawn_range` setting
- 1.16- Mobs follow multiple items now, Npc's can breed * Jumping and falling tweaks
- 1.15- Added Feeding/Taming/Breeding function, right-click to pick up any sheep with X mark on them and replace with new one to fix compatibility. * Spawn area check (thanks for idea wuzzy)
- 1.14- All .self variables saved in staticdata, Fixed self.health bug * Re-enabled mob suffocation
- 1.13- Added capture function (thanks blert2112) chance of picking up mob with hand; net; magic lasso, replaced some .x models with newer .b3d one's
- 1.12- Added animal ownership so that players cannot steal your tamed animals ### Version 1.50
- 1.11- Added flying mobs (and swimming), fly=true and fly_in="air" or "deafult:water_source" for fishy
- 1,10- Footstep removed (use replace), explosion routine added for exploding mobs. * Added new `line_of_sight` function that uses raycasting if Minetest 5.0 is
- 1.09- reworked breeding routine, added mob rotation value, added footstep feature, added jumping mobs with sounds feature, added magic lasso for picking up animals found, (thanks Astrobe)
- 1.08- Mob throwing attack has been rehauled so that they can damage one another, also drops and on_die function added * Added Chinese local
- 1.07- Npc's can now be set to follow player or stand by using self.order and self.owner variables * Removed ability to spawn mobs if world anchor nearby (`technic` or
- beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop `simple_anchor` mods)
- 1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
- 1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten ### Version 1.49
- 1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :)
- 1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc. * Added `mobs:force_capture(self, player)` function
- 1.02- Sheared sheep are remembered and spawn shaven, Warthogs will attack when threatened, Api additions * API functions now use metatables thanks to bell07
- 1.01- Mobs that suffer fall damage or die in water/lava/sunlight will now drop items
- 1.0 - more work on Api so that certain mobs can float in water while some sink like a brick :) ### Version 1.48
- 0.9 - Spawn eggs added for all mobs (admin only, cannot be placed in protected areas)... Api tweaked
- 0.8 - Added sounds to monster mobs (thanks Cyberpangolin for the sfx) and also chicken sound * Added `mobs:set_velocity(self, velocity)` global function
- 0.7 - mobs.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
- 0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block ### Version 1.47
- 0.5 - Mobs now float in water, die from falling, and some code improvements
- 0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :) * Added minimum and maximum light level for damage
- 0.3 - Added LOTT's Spider mob, made Cobwebs, added KPavel's Bee with Honey and Beehives (made texture), Warthogs now have sound and can be tamed, taming of shaved sheep or milked cow with 8 wheat so it will not despawn, many bug fixes :) * Mob damage changes
- 0.2 - Cooking bucket of milk into cheese now returns empty bucket * Ignition sources checked for lava damage
- 0.1 - Initial Release
### Version 1.46
* Mobs only drop rare items when killed by player. You can make change the
drops to rare items by using `drops.min = 0`
* Pathfinding no longer sees through walkable nodes
### Version 1.45
* Added fence top to add on top of any fence to stop mobs escaping
* New `line_of_sight` tweaked by `Astrobe`
### Version 1.44
* Added `ToolRanks` support for swords when attacking mobs
### Version 1.43
* Added general attack function and settings
* Better Minetest 0.4.16 compatibility
### Version 1.42
* Added `"all"` option to `immune_to` definition table
* Tidied floating mobs to be less intensive
### Version 1.41
* Mob pathfinding has been updated thanks to `Elkien3`
### Version 1.40
* Updated to use newer functions, requires Minetest 0.4.16+ to work
### Version 1.39
* **New custom functions**:
- `on_breed` (called when mobs have just been bred)
- `on_grown` (called when baby mobs have grown up)
- `do_punch` (called when the mob has been punched or damaged by another mob)
### Version 1.38
* Better entity checking
* Nametag setting
* `on_spawn` function added to mob registry
* Tweaked light damage
### Version 1.37
* Added support for `Raymoo`'s CMI (common mob interface) mod. See
https://forum.minetest.net/viewtopic.php?f=9&t=15448 for details
### Version 1.36
* Added death check. If the mob dies in fire/lava/with lava pick, then drops
are cooked
### Version 1.35
* Added `owner_loyal` flag for owned mobs to attack player enemies
* Fixed `group_attack`
### Version 1.34
* Added function to fly mob using directional movement (thanks D00Med for
flying code)
### Version 1.33
* Added functions to mount ride mobs:
- `mobs.attach`
- `mobs.detach`
- `mobs.drive`. Many thanks to `Blert2112`
### Version 1.32
* Added new spawn check to count specific mobs AND new `minetest.conf` setting
to chance spawn chance and numbers
* Added ability to protect tamed mobs
### Version 1.31
* Added `attack_animals` and `specific_attack` flags for custom monster
attacks
* Added 'mob_difficulty' .conf setting to make mobs harder
### Version 1.30
* Added support for `invisibility` mod
* Tweaked and tidied code
### Version 1.29
* Split original Mobs Redo into a modpack to make it easier to disable mob sets
(animal, monster, npc) or simply use the API itself for your own mod
### Version 1.28
* Added new damage system with ability for mob to be immune to weapons or
healed by them :)
### Version 1.27
* Added new sheep, lava flan and spawn egg textures
* New Lava Pick tool smelts what you dig
* New `atan` checking function
### Version 1.26
* Pathfinding feature added thanks to rnd
* When monsters attack they become scary smart in finding you :)
* Beehive produces honey now :)
### Version 1.25
* Mobs no longer spawn within 12 blocks of player or despawn within same
range
* Spawners now have player detection
* Tidy and tweak code
### Version 1.24
* Added feature where certain animals run away when punched
(`runaway = true` in mob definition)
### Version 1.23
* Added mob spawner block for admin to setup spawners in-game (place and
right-click to enter settings)
### Version 1.22
* Added ability to name tamed animals and NPCs using nametags
* NPCs will attack anyone who punches them apart from owner
### Version 1.21
* Added some more error checking to reduce `serialize.h` error and added height
checks for falling off cliffs (thanks `cmdskp`)
### Version 1.20
* Error checking added to remove bad mobs
* Out of map limit mobs and stop `serialize.h` error
### Version 1.19
* Chickens now drop egg items instead of placing the egg
* Throwing eggs result in ⅛ chance of spawning chick
### Version 1.18
* Added `docile_by_day` flag so that monsters will not attack automatically
during daylight hours unless hit first
### Version 1.17
* Added `dogshoot` attack type. Mobs now shoot when out of reach
* Melee attack when in reach, also API tweaks and `self.reach` added
### Version 1.16
* Mobs follow multiple items now
* NPCs can now breed
### Version 1.15
* Added feeding, taming, and breeding function
* Right-click to pick up any sheep with X mark on them and replace with new one
to fix compatibility.
### Version 1.14
* All variables saved in staticdata
* Fixed health bug
### Version 1.13
* Added capture function (thanks `blert2112`) chance of picking up mob with a
hand, a net, or a magic lasso
* Replaced some `.x` models with newer `.b3d` ones
### Version 1.12
* Added animal ownership so that players cannot steal your tamed animals
### Version 1.11
* Added flying and swimming mobs
* `fly=true` and `fly_in="air"` or `"default:water_source"` for fishy
### Version 1.10
* Added explosion routine for exploding mob
* Footstep removed (use replace)
### Version 1.09
* Added mob rotation value
* Added footstep feature
* Added jumping mobs with sounds feature
* Aadded magic lasso for picking up animals
* Reworked breeding routine
### Version 1.08
* Added drops that appear when mob is killed
* New custom function: `on_die` function
* Mob throwing attack has been rehauled so that they can damage one another,
### Version 1.07
* NPCs can now be set to follow player or stand by using `order` and `owner`
variables
* BETA: Npc mob added. They kill monsters (maybe as guards) and attack players
when punched by them. Right-clicking them with food will heal them, and
giving them gold lump will make them drop a random item.
### Version 1.06
* Changed recovery times after breeding. Time taken to grow up can be sped up
by feeding the baby animal.
### Version 1.05
* Added `ExeterDad`'s bunniess which can be picked up and tamed with four carrots from `farming_redo` or `farming_plus`
* Added shears to get wool from sheep
* Added Jordach/BSD's kitten
### Version 1.04
* Added mating for sheep, cows and hogs
* Added feature to feed animals to make horny and hope for a baby which is half
size, they will grow up quick though :)
### Version 1.03
* Added mob drop/replace feature so that chickens can drop eggs and cow/sheep
can eat grass/wheat etc.
### Version 1.02
* Sheared sheep are remembered and spawn shaven
* Warthogs will attack when threatened
* API additions
### Version 1.01
* Mobs that suffer fall damage or die in water/lava/sunlight will now drop
items
### Version 1.0
* More work on API so that certain mobs can float in water while some sink like
a brick :)
### Version 0.9
* Spawn eggs added for all mobs (admin only, cannot be placed in protected
areas)
* Tweaked API
### Version 0.8
* Added sounds to monster mobs (thanks `Cyberpangolin` for the `sfx`)
* Added chicken sound
### Version 0.7
* `mobs.protected` switch added to `api.lua`. When set to 1 mobs no longer
spawn in protected areas
* Minor bugfixes
### Version 0.6
* API now supports multi-textured mobs, e.g oerkki, dungeon master, rats and
chickens have random skins when spawning (sheep fix TODO)
* Added new Honey block
### Version 0.5
* Mobs now float in water, die from falling
* Minor code improvements
### Version 0.4
* Added new sheep sound :)
* Dungeon Masters and Mese Monsters have much better aim due to `shoot_offset`
* They can both shoot through nodes that aren't walkable (flowers, grass, etc.)
### Version 0.3
* Added `LOTT`'s Spider mob
* Added Cobwebs
* Added KPavel's Bee with Honey and Beehives (made texture)
* Warthogs now have sound and can be tamed
* Taming of shaved sheep or milked cow with 8 wheat so it will not despawn
* Multiple bug fixes :)
### Version 0.2
* Cooking bucket of milk into cheese now returns empty bucket
### Version 0.1
* Initial Release