1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-22 10:00:28 +02:00

Compare commits

...

24 Commits

Author SHA1 Message Date
ae21b80f08 report error if self.texture_mods is not a string 2025-07-21 14:03:05 +01:00
84377ee259 fix on_pick_up example in api.txt 2025-06-14 08:51:26 +01:00
5077217497 in peaceful mode dont register monster abm's 2025-06-03 13:41:39 +01:00
bae9cb12e2 add missing log level (thx Niklp) 2025-05-30 07:45:47 +01:00
126e5afc24 default active_block_range to 4 if not set 2025-05-26 07:23:15 +01:00
112c512c6e add mob repellent info 2025-05-25 13:32:46 +01:00
0f5b0e382d add recipe for mob repellent 2025-05-23 12:45:56 +01:00
5ed3a34cf3 remove self.attack_players check from do_punch 2025-05-20 08:13:06 +01:00
f44441c580 remove tester 2025-05-17 07:44:15 +01:00
2cf43ffc4e fix fear_height defaults 2025-05-17 07:43:26 +01:00
0d6b794fa0 default fear_height to 2 2025-05-16 10:46:45 +01:00
42da759407 tamed npc/animal wont attack players unless provoked 2025-05-15 15:44:22 +01:00
c0c4c3ea48 tweak general_attack 2025-05-15 14:34:38 +01:00
f5817061ce little tidy 2025-05-11 11:01:32 +01:00
43ad058efa change minetest. to core. 2025-05-04 12:25:59 +01:00
b977431e21 is_node_dangerous only if damage > 0 2025-05-01 08:01:12 +01:00
68b25c9d08 use tnt or mcl_explosions for mobs:boom 2025-04-11 10:12:30 +01:00
24adcae920 add self check in tnt boom 2025-04-11 08:46:01 +01:00
16a04547ab fix texture name 2025-04-10 09:42:58 +01:00
3a7b1bbfe6 added mobs_heart_particle.png 2025-04-09 15:15:41 +01:00
01a60d9a55 add particles to replace defaults 2025-04-09 15:11:47 +01:00
99f4fc1768 move deprecated functions from api to compatibility.lua 2025-04-08 08:33:25 +01:00
027620bfa3 tidy comments, change float var 2025-04-05 12:09:03 +01:00
854834f04e deprecate self.jump and add mobs.compatibility_check function. 2025-04-04 10:12:46 +01:00
13 changed files with 621 additions and 687 deletions

1011
api.lua

File diff suppressed because it is too large Load Diff

17
api.txt
View File

@ -50,7 +50,7 @@ functions needed for the mob to work properly which contains the following:
set to 0 for jumping mobs only. set to 0 for jumping mobs only.
'randomly_turn' if set to false then mob will not turn to face player or 'randomly_turn' if set to false then mob will not turn to face player or
randomly turn while walking or standing. randomly turn while walking or standing.
'jump' when true allows your mob to jump updwards. 'jump' when true allows your mob to jump updwards[DEPRECATED].
'jump_height' holds the height your mob can jump, 0 to disable jumping. 'jump_height' holds the height your mob can jump, 0 to disable jumping.
'can_leap' when true obstacles like fences or pits wont stop a mob 'can_leap' when true obstacles like fences or pits wont stop a mob
from trying to jump out. from trying to jump out.
@ -92,7 +92,7 @@ functions needed for the mob to work properly which contains the following:
When set to 16 then only natural light will kill mob. When set to 16 then only natural light will kill mob.
'suffocation' when > 0 mobs will suffocate inside solid blocks and will be 'suffocation' when > 0 mobs will suffocate inside solid blocks and will be
hurt by the value given every second (0 to disable). hurt by the value given every second (0 to disable).
'floats' when set to 1 mob will float in water, 0 has them sink. 'floats' when True mob will float in water, otherwise they sink.
'follow' mobs follow player when holding any of the items which appear 'follow' mobs follow player when holding any of the items which appear
on this table, the same items can be fed to a mob to tame or on this table, the same items can be fed to a mob to tame or
breed e.g. {"farming:wheat", "default:apple", "group:fish"} breed e.g. {"farming:wheat", "default:apple", "group:fish"}
@ -102,7 +102,8 @@ functions needed for the mob to work properly which contains the following:
'docile_by_day' when true has mobs wandering around during daylight 'docile_by_day' when true has mobs wandering around during daylight
hours and only attacking player at night or when hours and only attacking player at night or when
provoked. provoked.
'attack_chance' 0 to 100 chance the mob will attack (default is 5). 'attack_chance' 0 to 100 chance the mob will attack (default is 5),
set to 100 so that mob needs to be provoked to attack.
'attack_patience' Time in seconds before mob gives up attacking if 'attack_patience' Time in seconds before mob gives up attacking if
player isn't seen (Defaults to 11). player isn't seen (Defaults to 11).
'attack_monsters' when true mob will attack monsters. 'attack_monsters' when true mob will attack monsters.
@ -230,8 +231,6 @@ functions needed for the mob to work properly which contains the following:
'rotate' custom model rotation, 0 = front, 90 = side, 180 = back, 'rotate' custom model rotation, 0 = front, 90 = side, 180 = back,
270 = other side. 270 = other side.
'glow' has mob glow without light source, 0 to 15 or nil to disable 'glow' has mob glow without light source, 0 to 15 or nil to disable
'double_melee_attack' when true has the api choose between 'punch' and
'punch2' animations. [DEPRECATED]
'animation' holds a table containing animation names and settings for use with 'animation' holds a table containing animation names and settings for use with
mesh models: mesh models:
@ -315,15 +314,15 @@ Pickup Items
'pick_up' table of itemstrings the mob will pick up. 'pick_up' table of itemstrings the mob will pick up.
'on_pick_up' function that will be called on item pickup - arguments are 'on_pick_up' function that will be called on item pickup - arguments are
(self, itemstring) and can return nil or a a modified itemstack e.g. (self, itemtable) and can return nil or a a modified itemstack e.g.
on_pick_up = function(self, itemstring) on_pick_up = function(self, itemtable)
local istack = ItemStack(entity.itemstring) local istack = ItemStack(itemtable.itemstring)
print("-- took", istack:get_name()) print("-- took", istack:get_name())
istack:take_item(1) istack:take_item()
return istack return istack
end, end,

41
compatibility.lua Normal file
View File

@ -0,0 +1,41 @@
-- called after mob registration to check for older settings
function mobs.compatibility_check(self)
-- simple mobs rotation setting
if self.drawtype == "side" then self.rotate = math.rad(90) end
-- replace floats var from number to bool
if self.floats == 1 then self.floats = true
elseif self.floats == 0 then self.floats = false end
end
-- deprecated functions
function mobs:yaw(entity, yaw, delay)
entity:set_yaw(yaw, delay)
end
function mobs:set_animation(entity, anim)
entity:set_animation(anim)
end
function mobs:line_of_sight(entity, pos1, pos2)
return entity:line_of_sight(pos1, pos2)
end
function mobs:yaw_to_pos(entity, target, rot)
return entity:yaw_to_pos(target, rot)
end
function mobs:register_spawn(name, nodes, max_light, min_light, chance,
active_object_count, max_height, day_toggle)
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30,
chance, active_object_count, -31000, max_height, day_toggle)
end
function mobs:explosion(pos, radius)
mobs:boom({sounds = {explode = "tnt_explode"}}, pos, radius, radius, "mobs_tnt_smoke.png")
end

View File

@ -1,8 +1,8 @@
local S = minetest.get_translator("mobs") local S = core.get_translator("mobs")
local FS = function(...) return minetest.formspec_escape(S(...)) end local FS = function(...) return core.formspec_escape(S(...)) end
local mc2 = minetest.get_modpath("mcl_core") local mc2 = core.get_modpath("mcl_core")
local mod_def = minetest.get_modpath("default") local mod_def = core.get_modpath("default")
-- determine which sounds to use, default or mcl_sounds -- determine which sounds to use, default or mcl_sounds
@ -25,21 +25,11 @@ sound_helper("node_sound_water_defaults")
sound_helper("node_sound_snow_defaults") sound_helper("node_sound_snow_defaults")
sound_helper("node_sound_glass_defaults") sound_helper("node_sound_glass_defaults")
-- mob repellent node
minetest.register_node("mobs:mob_repellent", {
description = S("Mob Repellent"),
tiles = {"mobs_repellent.png"},
is_ground_content = false,
groups = {handy = 1, cracky = 3},
sounds = mobs.node_sound_stone_defaults()
})
-- helper function to add {eatable} group to food items -- helper function to add {eatable} group to food items
function mobs.add_eatable(item, hp) function mobs.add_eatable(item, hp)
local def = minetest.registered_items[item] local def = core.registered_items[item]
if def then if def then
@ -47,7 +37,7 @@ function mobs.add_eatable(item, hp)
groups.eatable = hp ; groups.flammable = 2 groups.eatable = hp ; groups.flammable = 2
minetest.override_item(item, {groups = groups}) core.override_item(item, {groups = groups})
end end
end end
@ -56,6 +46,7 @@ end
local items = { local items = {
paper = mc2 and "mcl_core:paper" or "default:paper", paper = mc2 and "mcl_core:paper" or "default:paper",
dye_black = mc2 and "mcl_dye:black" or "dye:black", dye_black = mc2 and "mcl_dye:black" or "dye:black",
dye_red = mc2 and "mcl_dye:red" or "dye:red",
string = mc2 and "mcl_mobitems:string" or "farming:string", string = mc2 and "mcl_mobitems:string" or "farming:string",
stick = mc2 and "mcl_core:stick" or "default:stick", stick = mc2 and "mcl_core:stick" or "default:stick",
diamond = mc2 and "mcl_core:diamond" or "default:diamond", diamond = mc2 and "mcl_core:diamond" or "default:diamond",
@ -68,17 +59,18 @@ local items = {
fence_wood = mc2 and "group:fence_wood" or "default:fence_wood", fence_wood = mc2 and "group:fence_wood" or "default:fence_wood",
meat_raw = mc2 and "mcl_mobitems:beef" or "group:food_meat_raw", meat_raw = mc2 and "mcl_mobitems:beef" or "group:food_meat_raw",
meat_cooked = mc2 and "mcl_mobitems:cooked_beef" or "group:food_meat", meat_cooked = mc2 and "mcl_mobitems:cooked_beef" or "group:food_meat",
obsidian = mc2 and "mcl_core:obsidian" or "default:obsidian"
} }
-- name tag -- name tag
minetest.register_craftitem("mobs:nametag", { core.register_craftitem("mobs:nametag", {
description = S("Name Tag") .. " " .. S("\nRight-click Mobs Redo mob to apply"), description = S("Name Tag") .. " " .. S("\nRight-click Mobs Redo mob to apply"),
inventory_image = "mobs_nametag.png", inventory_image = "mobs_nametag.png",
groups = {flammable = 2, nametag = 1} groups = {flammable = 2, nametag = 1}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:nametag", output = "mobs:nametag",
recipe = { recipe = {
{ items.paper, items.dye_black, items.string } { items.paper, items.dye_black, items.string }
@ -87,7 +79,7 @@ minetest.register_craft({
-- leather -- leather
minetest.register_craftitem("mobs:leather", { core.register_craftitem("mobs:leather", {
description = S("Leather"), description = S("Leather"),
inventory_image = "mobs_leather.png", inventory_image = "mobs_leather.png",
groups = {flammable = 2, leather = 1} groups = {flammable = 2, leather = 1}
@ -95,10 +87,10 @@ minetest.register_craftitem("mobs:leather", {
-- raw meat -- raw meat
minetest.register_craftitem("mobs:meat_raw", { core.register_craftitem("mobs:meat_raw", {
description = S("Raw Meat"), description = S("Raw Meat"),
inventory_image = "mobs_meat_raw.png", inventory_image = "mobs_meat_raw.png",
on_use = minetest.item_eat(3), on_use = core.item_eat(3),
groups = {food_meat_raw = 1} groups = {food_meat_raw = 1}
}) })
@ -106,16 +98,16 @@ mobs.add_eatable("mobs:meat_raw", 3)
-- cooked meat -- cooked meat
minetest.register_craftitem("mobs:meat", { core.register_craftitem("mobs:meat", {
description = S("Meat"), description = S("Meat"),
inventory_image = "mobs_meat.png", inventory_image = "mobs_meat.png",
on_use = minetest.item_eat(8), on_use = core.item_eat(8),
groups = {food_meat = 1} groups = {food_meat = 1}
}) })
mobs.add_eatable("mobs:meat", 8) mobs.add_eatable("mobs:meat", 8)
minetest.register_craft({ core.register_craft({
type = "cooking", type = "cooking",
output = "mobs:meat", output = "mobs:meat",
recipe = "mobs:meat_raw", recipe = "mobs:meat_raw",
@ -124,13 +116,13 @@ minetest.register_craft({
-- lasso -- lasso
minetest.register_tool("mobs:lasso", { core.register_tool("mobs:lasso", {
description = S("Lasso (right-click animal to put in inventory)"), description = S("Lasso (right-click animal to put in inventory)"),
inventory_image = "mobs_magic_lasso.png", inventory_image = "mobs_magic_lasso.png",
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:lasso", output = "mobs:lasso",
recipe = { recipe = {
{ items.string, "", items.string}, { items.string, "", items.string},
@ -139,17 +131,17 @@ minetest.register_craft({
} }
}) })
minetest.register_alias("mobs:magic_lasso", "mobs:lasso") core.register_alias("mobs:magic_lasso", "mobs:lasso")
-- net -- net
minetest.register_tool("mobs:net", { core.register_tool("mobs:net", {
description = S("Net (right-click animal to put in inventory)"), description = S("Net (right-click animal to put in inventory)"),
inventory_image = "mobs_net.png", inventory_image = "mobs_net.png",
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:net", output = "mobs:net",
recipe = { recipe = {
{ items.stick, "", items.stick }, { items.stick, "", items.stick },
@ -160,13 +152,13 @@ minetest.register_craft({
-- shears (right click to shear animal) -- shears (right click to shear animal)
minetest.register_tool("mobs:shears", { core.register_tool("mobs:shears", {
description = S("Steel Shears (right-click to shear)"), description = S("Steel Shears (right-click to shear)"),
inventory_image = "mobs_shears.png", inventory_image = "mobs_shears.png",
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:shears", output = "mobs:shears",
recipe = { recipe = {
{ "", items.steel_ingot, "" }, { "", items.steel_ingot, "" },
@ -176,13 +168,13 @@ minetest.register_craft({
-- protection rune -- protection rune
minetest.register_craftitem("mobs:protector", { core.register_craftitem("mobs:protector", {
description = S("Mob Protection Rune"), description = S("Mob Protection Rune"),
inventory_image = "mobs_protector.png", inventory_image = "mobs_protector.png",
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:protector", output = "mobs:protector",
recipe = { recipe = {
{ items.stone, items.stone, items.stone }, { items.stone, items.stone, items.stone },
@ -193,13 +185,13 @@ minetest.register_craft({
-- protection rune (level 2) -- protection rune (level 2)
minetest.register_craftitem("mobs:protector2", { core.register_craftitem("mobs:protector2", {
description = S("Mob Protection Rune (Level 2)"), description = S("Mob Protection Rune (Level 2)"),
inventory_image = "mobs_protector2.png", inventory_image = "mobs_protector2.png",
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:protector2", output = "mobs:protector2",
recipe = { recipe = {
{ "mobs:protector", items.mese_crystal, "mobs:protector" }, { "mobs:protector", items.mese_crystal, "mobs:protector" },
@ -208,15 +200,34 @@ minetest.register_craft({
} }
}) })
-- mob repellent node
core.register_node("mobs:mob_repellent", {
description = S("Mob Repellent (Stops mobs spawning within 16 block radius)"),
tiles = {"mobs_repellent.png"},
is_ground_content = false,
groups = {handy = 1, cracky = 3},
sounds = mobs.node_sound_stone_defaults()
})
core.register_craft({
output = "mobs:mob_repellent",
recipe = {
{ items.obsidian, items.dye_red, items.obsidian },
{ items.obsidian, "mobs:protector", items.obsidian },
{ items.obsidian, items.obsidian, items.obsidian }
}
})
-- saddle -- saddle
minetest.register_craftitem("mobs:saddle", { core.register_craftitem("mobs:saddle", {
description = S("Saddle"), description = S("Saddle"),
inventory_image = "mobs_saddle.png", inventory_image = "mobs_saddle.png",
groups = {flammable = 2, saddle = 1} groups = {flammable = 2, saddle = 1}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:saddle", output = "mobs:saddle",
recipe = { recipe = {
{"group:leather", "group:leather", "group:leather"}, {"group:leather", "group:leather", "group:leather"},
@ -244,7 +255,7 @@ end
-- mob fence top (has enlarged collisionbox to stop mobs getting over) -- mob fence top (has enlarged collisionbox to stop mobs getting over)
minetest.register_node("mobs:fence_top", { core.register_node("mobs:fence_top", {
description = S("Mob Fence Top"), description = S("Mob Fence Top"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_wood.png"}, tiles = {"default_wood.png"},
@ -257,7 +268,7 @@ minetest.register_node("mobs:fence_top", {
selection_box = {type = "fixed", fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}} selection_box = {type = "fixed", fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}}
}) })
minetest.register_craft({ core.register_craft({
output = "mobs:fence_top 12", output = "mobs:fence_top 12",
recipe = { recipe = {
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
@ -267,13 +278,13 @@ minetest.register_craft({
-- items that can be used as fuel -- items that can be used as fuel
minetest.register_craft({type = "fuel", recipe = "mobs:nametag", burntime = 3}) core.register_craft({type = "fuel", recipe = "mobs:nametag", burntime = 3})
minetest.register_craft({type = "fuel", recipe = "mobs:lasso", burntime = 7}) core.register_craft({type = "fuel", recipe = "mobs:lasso", burntime = 7})
minetest.register_craft({type = "fuel", recipe = "mobs:net", burntime = 8}) core.register_craft({type = "fuel", recipe = "mobs:net", burntime = 8})
minetest.register_craft({type = "fuel", recipe = "mobs:leather", burntime = 4}) core.register_craft({type = "fuel", recipe = "mobs:leather", burntime = 4})
minetest.register_craft({type = "fuel", recipe = "mobs:saddle", burntime = 7}) core.register_craft({type = "fuel", recipe = "mobs:saddle", burntime = 7})
minetest.register_craft({type = "fuel", recipe = "mobs:fence_wood", burntime = 7}) core.register_craft({type = "fuel", recipe = "mobs:fence_wood", burntime = 7})
minetest.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2}) core.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2})
-- this tool spawns same mob and adds owner, protected, nametag info -- this tool spawns same mob and adds owner, protected, nametag info
@ -282,7 +293,7 @@ minetest.register_craft({type = "fuel", recipe = "mobs:fence_top", burntime = 2}
local tex_obj local tex_obj
minetest.register_tool(":mobs:mob_reset_stick", { core.register_tool(":mobs:mob_reset_stick", {
description = S("Mob Reset Stick"), description = S("Mob Reset Stick"),
inventory_image = "default_stick.png^[colorize:#ff000050", inventory_image = "default_stick.png^[colorize:#ff000050",
stack_max = 1, stack_max = 1,
@ -300,7 +311,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
if obj and not sneak then if obj and not sneak then
local self = obj:get_luaentity() local self = obj:get_luaentity()
local obj2 = minetest.add_entity(obj:get_pos(), self.name) local obj2 = core.add_entity(obj:get_pos(), self.name)
if obj2 then if obj2 then
@ -336,7 +347,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
local name = user:get_player_name() local name = user:get_player_name()
minetest.show_formspec(name, "mobs_texture", "size[8,4]" core.show_formspec(name, "mobs_texture", "size[8,4]"
.. "field[0.5,1;7.5,0;name;" .. "field[0.5,1;7.5,0;name;"
.. FS("Enter texture:") .. ";" .. bt .. "]" .. FS("Enter texture:") .. ";" .. bt .. "]"
.. "button_exit[2.5,3.5;3,1;mob_texture_change;" .. "button_exit[2.5,3.5;3,1;mob_texture_change;"
@ -345,7 +356,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
end end
}) })
minetest.register_on_player_receive_fields(function(player, formname, fields) core.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_texture" and fields.name and fields.name ~= "" then if formname == "mobs_texture" and fields.name and fields.name ~= "" then
@ -375,22 +386,22 @@ end)
-- Meat Block -- Meat Block
minetest.register_node("mobs:meatblock", { core.register_node("mobs:meatblock", {
description = S("Meat Block"), description = S("Meat Block"),
tiles = {"mobs_meat_top.png", "mobs_meat_bottom.png", "mobs_meat_side.png"}, tiles = {"mobs_meat_top.png", "mobs_meat_bottom.png", "mobs_meat_side.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1}, groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1},
is_ground_content = false, is_ground_content = false,
sounds = mobs.node_sound_dirt_defaults(), sounds = mobs.node_sound_dirt_defaults(),
on_place = minetest.rotate_node, on_place = core.rotate_node,
on_use = minetest.item_eat(20), on_use = core.item_eat(20),
_mcl_hardness = 0.8, _mcl_hardness = 0.8,
_mcl_blast_resistance = 1 _mcl_blast_resistance = 1
}) })
mobs.add_eatable("mobs:meatblock", 20) mobs.add_eatable("mobs:meatblock", 20)
minetest.register_craft({ core.register_craft({
output = "mobs:meatblock", output = "mobs:meatblock",
recipe = { recipe = {
{ items.meat_cooked, items.meat_cooked, items.meat_cooked }, { items.meat_cooked, items.meat_cooked, items.meat_cooked },
@ -401,22 +412,22 @@ minetest.register_craft({
-- Meat Block (raw) -- Meat Block (raw)
minetest.register_node("mobs:meatblock_raw", { core.register_node("mobs:meatblock_raw", {
description = S("Raw Meat Block"), description = S("Raw Meat Block"),
tiles = {"mobs_meat_raw_top.png", "mobs_meat_raw_bottom.png", "mobs_meat_raw_side.png"}, tiles = {"mobs_meat_raw_top.png", "mobs_meat_raw_bottom.png", "mobs_meat_raw_side.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1}, groups = {choppy = 1, oddly_breakable_by_hand = 1, axey = 1, handy = 1},
is_ground_content = false, is_ground_content = false,
sounds = mobs.node_sound_dirt_defaults(), sounds = mobs.node_sound_dirt_defaults(),
on_place = minetest.rotate_node, on_place = core.rotate_node,
on_use = minetest.item_eat(20), on_use = core.item_eat(20),
_mcl_hardness = 0.8, _mcl_hardness = 0.8,
_mcl_blast_resistance = 1 _mcl_blast_resistance = 1
}) })
mobs.add_eatable("mobs:meatblock_raw", 20) mobs.add_eatable("mobs:meatblock_raw", 20)
minetest.register_craft({ core.register_craft({
output = "mobs:meatblock_raw", output = "mobs:meatblock_raw",
recipe = { recipe = {
{ items.meat_raw, items.meat_raw, items.meat_raw }, { items.meat_raw, items.meat_raw, items.meat_raw },
@ -425,7 +436,7 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({ core.register_craft({
type = "cooking", type = "cooking",
output = "mobs:meatblock", output = "mobs:meatblock",
recipe = "mobs:meatblock_raw", recipe = "mobs:meatblock_raw",
@ -434,9 +445,9 @@ minetest.register_craft({
-- hearing vines (if mesecons active it acts like blinkyplant) -- hearing vines (if mesecons active it acts like blinkyplant)
local mod_mese = minetest.get_modpath("mesecons") local mod_mese = core.get_modpath("mesecons")
minetest.register_node("mobs:hearing_vines", { core.register_node("mobs:hearing_vines", {
description = S("Hearing Vines"), description = S("Hearing Vines"),
drawtype = "firelike", drawtype = "firelike",
waving = 1, waving = 1,
@ -454,12 +465,12 @@ minetest.register_node("mobs:hearing_vines", {
}, },
on_sound = function(pos, def) on_sound = function(pos, def)
if def.loudness > 0.5 then if def.loudness > 0.5 then
minetest.set_node(pos, {name = "mobs:hearing_vines_active"}) core.set_node(pos, {name = "mobs:hearing_vines_active"})
end end
end end
}) })
minetest.register_node("mobs:hearing_vines_active", { core.register_node("mobs:hearing_vines_active", {
description = S("Active Hearing Vines"), description = S("Active Hearing Vines"),
drawtype = "firelike", drawtype = "firelike",
waving = 1, waving = 1,
@ -479,11 +490,11 @@ minetest.register_node("mobs:hearing_vines_active", {
type = "fixed", fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -0.25, 6 / 16}, type = "fixed", fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -0.25, 6 / 16},
}, },
on_construct = function(pos) on_construct = function(pos)
minetest.get_node_timer(pos):start(1) core.get_node_timer(pos):start(1)
if mod_mese then mesecon.receptor_on(pos) end if mod_mese then mesecon.receptor_on(pos) end
end, end,
on_timer = function(pos) on_timer = function(pos)
minetest.set_node(pos, {name = "mobs:hearing_vines"}) core.set_node(pos, {name = "mobs:hearing_vines"})
if mod_mese then mesecon.receptor_off(pos) end if mod_mese then mesecon.receptor_off(pos) end
end end
}) })

View File

@ -1,16 +1,16 @@
local S = minetest.get_translator("mobs") local S = core.get_translator("mobs")
-- peaceful player privilege -- peaceful player privilege
minetest.register_privilege("peaceful_player", { core.register_privilege("peaceful_player", {
description = "Prevents Mobs Redo mobs from attacking player", description = "Prevents Mobs Redo mobs from attacking player",
give_to_singleplayer = false give_to_singleplayer = false
}) })
-- fallback node -- fallback node
minetest.register_node("mobs:fallback_node", { core.register_node("mobs:fallback_node", {
description = S("Fallback Node"), description = S("Fallback Node"),
tiles = {"mobs_fallback.png"}, tiles = {"mobs_fallback.png"},
is_ground_content = false, is_ground_content = false,
@ -19,7 +19,7 @@ minetest.register_node("mobs:fallback_node", {
}) })
local path = minetest.get_modpath("mobs") local path = core.get_modpath("mobs")
dofile(path .. "/api.lua") -- mob API dofile(path .. "/api.lua") -- mob API
@ -31,7 +31,7 @@ dofile(path .. "/spawner.lua") -- mob spawner
-- Lucky Blocks -- Lucky Blocks
if minetest.get_modpath("lucky_block") then if core.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua") dofile(path .. "/lucky_block.lua")
end end

View File

@ -20,6 +20,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Textures borrowed from minetest_game (CC BY-SA 3.0):
mobs_tnt_smoke.png
mobs_bubble_particle.png
mobs_heart_particle.png
Textures under CC0 license by TenPlus1 Textures under CC0 license by TenPlus1

View File

@ -1,5 +1,5 @@
local S = minetest.get_translator("mobs") local S = core.get_translator("mobs")
-- add lucky blocks -- add lucky blocks
@ -21,7 +21,7 @@ lucky_block:add_blocks({
-- pint sized rune, use on tamed mob to shrink to half-size -- pint sized rune, use on tamed mob to shrink to half-size
minetest.register_craftitem(":mobs:pint_sized_rune", { core.register_craftitem(":mobs:pint_sized_rune", {
description = S("Pint Sized Rune"), description = S("Pint Sized Rune"),
inventory_image = "mobs_pint_sized_rune.png", inventory_image = "mobs_pint_sized_rune.png",
groups = {flammable = 2}, groups = {flammable = 2},
@ -39,17 +39,17 @@ minetest.register_craftitem(":mobs:pint_sized_rune", {
local self = pointed_thing.ref:get_luaentity() local self = pointed_thing.ref:get_luaentity()
if not self._cmi_is_mob then if not self._cmi_is_mob then
minetest.chat_send_player(name, S("Not a Mobs Redo mob!")) core.chat_send_player(name, S("Not a Mobs Redo mob!"))
return return
end end
if not self.tamed then if not self.tamed then
minetest.chat_send_player(name, S("Not tamed!")) core.chat_send_player(name, S("Not tamed!"))
return return
end end
if self.pint_size_potion then if self.pint_size_potion then
minetest.chat_send_player(name, S("Potion already applied!")) core.chat_send_player(name, S("Potion already applied!"))
return return
end end
@ -92,7 +92,7 @@ minetest.register_craftitem(":mobs:pint_sized_rune", {
end end
}) })
minetest.register_craft({ core.register_craft({
output = "lucky_block:pint_sized_rune", output = "lucky_block:pint_sized_rune",
recipe = {{"lucky_block:pint_sized_potion", "mobs:protector"}} recipe = {{"lucky_block:pint_sized_potion", "mobs:protector"}}
}) })

View File

@ -1,11 +1,11 @@
-- lib_mount by Blert2112 (edited by TenPlus1) -- lib_mount by Blert2112 (edited by TenPlus1)
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check local is_mc2 = core.get_modpath("mcl_mobs") -- MineClone2 check
-- one of these is needed to ride mobs, otherwise no riding for you -- one of these is needed to ride mobs, otherwise no riding for you
if not minetest.get_modpath("player_api") and not is_mc2 then if not core.get_modpath("player_api") and not is_mc2 then
function mobs.attach() end function mobs.attach() end
function mobs.detach() end function mobs.detach() end
@ -28,7 +28,7 @@ local function node_is(entity)
if entity.standing_on == "air" then return "air" end if entity.standing_on == "air" then return "air" end
local def = minetest.registered_nodes[entity.standing_on] local def = core.registered_nodes[entity.standing_on]
if def.groups.lava then return "lava" end if def.groups.lava then return "lava" end
if def.groups.liquid then return "liquid" end if def.groups.liquid then return "liquid" end
@ -90,15 +90,15 @@ end
-- detach player on leaving -- detach player on leaving
minetest.register_on_leaveplayer(function(player) core.register_on_leaveplayer(function(player)
force_detach(player) force_detach(player)
end) end)
-- detatch all players on shutdown -- detatch all players on shutdown
minetest.register_on_shutdown(function() core.register_on_shutdown(function()
local players = minetest.get_connected_players() local players = core.get_connected_players()
for i = 1, #players do for i = 1, #players do
force_detach(players[i]) force_detach(players[i])
@ -107,7 +107,7 @@ end)
-- detatch player when dead -- detatch player when dead
minetest.register_on_dieplayer(function(player) core.register_on_dieplayer(function(player)
force_detach(player) force_detach(player)
return true return true
end) end)
@ -125,11 +125,11 @@ local function find_free_pos(pos)
for _, c in pairs(check) do for _, c in pairs(check) do
local npos = {x = pos.x + c.x, y = pos.y + c.y, z = pos.z + c.z} local npos = {x = pos.x + c.x, y = pos.y + c.y, z = pos.z + c.z}
local node = minetest.get_node_or_nil(npos) local node = core.get_node_or_nil(npos)
if node and node.name then if node and node.name then
local def = minetest.registered_nodes[node.name] local def = core.registered_nodes[node.name]
if def and not def.walkable and def.liquidtype == "none" then if def and not def.walkable and def.liquidtype == "none" then
return npos return npos
@ -144,7 +144,7 @@ end
local function is_player(player) local function is_player(player)
if player and type(player) == "userdata" and minetest.is_player(player) then if player and type(player) == "userdata" and core.is_player(player) then
return true return true
end end
end end
@ -184,7 +184,7 @@ function mobs.attach(entity, player)
visual_size = {x = entity.driver_scale.x, y = entity.driver_scale.y} visual_size = {x = entity.driver_scale.x, y = entity.driver_scale.y}
}) })
minetest.after(0.2, function() core.after(0.2, function()
if is_player(player) then if is_player(player) then
@ -205,7 +205,7 @@ function mobs.detach(player)
force_detach(player) force_detach(player)
minetest.after(0.1, function() core.after(0.1, function()
if player and player:is_player() then if player and player:is_player() then
@ -299,7 +299,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if velo.y == 0 if velo.y == 0
and entity.standing_on ~= "air" and entity.standing_on ~= "ignore" and entity.standing_on ~= "air" and entity.standing_on ~= "ignore"
and minetest.get_item_group(entity.standing_on, "liquid") == 0 then and core.get_item_group(entity.standing_on, "liquid") == 0 then
velo.y = velo.y + entity.jump_height velo.y = velo.y + entity.jump_height
acce_y = acce_y + (acce_y * 3) + 1 acce_y = acce_y + (acce_y * 3) + 1
end end
@ -391,7 +391,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
new_acce.y = 0 new_acce.y = 0
p.y = p.y + 1 p.y = p.y + 1
if minetest.get_item_group(entity.standing_in, "liquid") ~= 0 then if core.get_item_group(entity.standing_in, "liquid") ~= 0 then
if velo.y >= 5 then if velo.y >= 5 then
velo.y = 5 velo.y = 5
@ -458,7 +458,7 @@ function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
if ctrl.LMB and ctrl.sneak and shoots then if ctrl.LMB and ctrl.sneak and shoots then
local pos = entity.object:get_pos() local pos = entity.object:get_pos()
local obj = minetest.add_entity({ local obj = core.add_entity({
x = pos.x + 0 + dir.x * 2.5, x = pos.x + 0 + dir.x * 2.5,
y = pos.y + 1.5 + dir.y, y = pos.y + 1.5 + dir.y,
z = pos.z + 0 + dir.z * 2.5}, arrow) z = pos.z + 0 + dir.z * 2.5}, arrow)

View File

@ -1,12 +1,12 @@
local S = minetest.get_translator("mobs") local S = core.get_translator("mobs")
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99) local max_per_block = tonumber(core.settings:get("max_objects_per_block") or 99)
-- helper functions -- helper functions
local function is_player(player) local function is_player(player)
if player and type(player) == "userdata" and minetest.is_player(player) then if player and type(player) == "userdata" and core.is_player(player) then
return true return true
end end
end end
@ -26,7 +26,7 @@ end
local spawner_default = "mobs_animal:pumba 10 15 0 0 0" local spawner_default = "mobs_animal:pumba 10 15 0 0 0"
minetest.register_node("mobs:spawner", { core.register_node("mobs:spawner", {
tiles = {"mob_spawner.png"}, tiles = {"mob_spawner.png"},
drawtype = "glasslike", drawtype = "glasslike",
paramtype = "light", paramtype = "light",
@ -40,7 +40,7 @@ minetest.register_node("mobs:spawner", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = core.get_meta(pos)
-- setup formspec -- setup formspec
local head = S("(mob name) (min light) (max light) (amount)" local head = S("(mob name) (min light) (max light) (amount)"
@ -48,7 +48,7 @@ minetest.register_node("mobs:spawner", {
-- text entry formspec -- text entry formspec
meta:set_string("formspec", "size[10,3.5]" meta:set_string("formspec", "size[10,3.5]"
.. "label[0.15,0.5;" .. minetest.formspec_escape(head) .. "]" .. "label[0.15,0.5;" .. core.formspec_escape(head) .. "]"
.. "field[1,2.5;8.5,0.8;text;" .. S("Command:") .. "field[1,2.5;8.5,0.8;text;" .. S("Command:")
.. ";${command}]") .. ";${command}]")
@ -58,19 +58,19 @@ minetest.register_node("mobs:spawner", {
on_right_click = function(pos, placer) on_right_click = function(pos, placer)
if minetest.is_protected(pos, placer:get_player_name()) then return end if core.is_protected(pos, placer:get_player_name()) then return end
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if not fields.text or fields.text == "" then return end if not fields.text or fields.text == "" then return end
local meta = minetest.get_meta(pos) local meta = core.get_meta(pos)
local comm = fields.text:split(" ") local comm = fields.text:split(" ")
local name = sender:get_player_name() local name = sender:get_player_name()
if minetest.is_protected(pos, name) then if core.is_protected(pos, name) then
minetest.record_protection_violation(pos, name) core.record_protection_violation(pos, name)
return return
end end
@ -88,8 +88,8 @@ minetest.register_node("mobs:spawner", {
meta:set_string("command", fields.text) meta:set_string("command", fields.text)
meta:set_string("infotext", S("Spawner Active (@1)", mob)) meta:set_string("infotext", S("Spawner Active (@1)", mob))
else else
minetest.chat_send_player(name, S("Mob Spawner settings failed!")) core.chat_send_player(name, S("Mob Spawner settings failed!"))
minetest.chat_send_player(name, core.chat_send_player(name,
S("Syntax: “name min_light[0-14] max_light[0-14] " S("Syntax: “name min_light[0-14] max_light[0-14] "
.. "max_mobs_in_area[0 to disable] player_distance[1-20] " .. "max_mobs_in_area[0 to disable] player_distance[1-20] "
.. "y_offset[-10 to 10]”")) .. "y_offset[-10 to 10]”"))
@ -99,7 +99,7 @@ minetest.register_node("mobs:spawner", {
-- spawner abm -- spawner abm
minetest.register_abm({ core.register_abm({
label = "Mob spawner node", label = "Mob spawner node",
nodenames = {"mobs:spawner"}, nodenames = {"mobs:spawner"},
interval = 10, interval = 10,
@ -112,7 +112,7 @@ minetest.register_abm({
if active_object_count_wider >= max_per_block then return end if active_object_count_wider >= max_per_block then return end
-- get meta and command -- get meta and command
local meta = minetest.get_meta(pos) local meta = core.get_meta(pos)
local comm = meta:get_string("command"):split(" ") local comm = meta:get_string("command"):split(" ")
-- get settings from command -- get settings from command
@ -133,7 +133,7 @@ minetest.register_abm({
end end
-- check objects inside 9x9 area around spawner -- check objects inside 9x9 area around spawner
local objs = minetest.get_objects_inside_radius(pos, 9) local objs = core.get_objects_inside_radius(pos, 9)
local count = 0 local count = 0
local ent local ent
@ -152,7 +152,7 @@ minetest.register_abm({
if pla > 0 then if pla > 0 then
local in_range, player local in_range, player
local players = minetest.get_connected_players() local players = core.get_connected_players()
for i = 1, #players do for i = 1, #players do
@ -171,12 +171,12 @@ minetest.register_abm({
end end
-- set medium mob usually spawns in (defaults to air) -- set medium mob usually spawns in (defaults to air)
local reg = minetest.registered_entities[mob].fly_in local reg = core.registered_entities[mob].fly_in
if not reg or type(reg) == "string" then reg = {(reg or "air")} end if not reg or type(reg) == "string" then reg = {(reg or "air")} end
-- find air blocks within 5 nodes of spawner -- find air blocks within 5 nodes of spawner
local air = minetest.find_nodes_in_area( local air = core.find_nodes_in_area(
{x = pos.x - 5, y = pos.y + yof, z = pos.z - 5}, {x = pos.x - 5, y = pos.y + yof, z = pos.z - 5},
{x = pos.x + 5, y = pos.y + yof, z = pos.z + 5}, reg) {x = pos.x + 5, y = pos.y + yof, z = pos.z + 5}, reg)
@ -184,13 +184,13 @@ minetest.register_abm({
if air and #air > 0 then if air and #air > 0 then
local pos2 = air[math.random(#air)] local pos2 = air[math.random(#air)]
local lig = minetest.get_node_light(pos2) or 0 local lig = core.get_node_light(pos2) or 0
pos2.y = pos2.y + 0.5 pos2.y = pos2.y + 0.5
-- only if light levels are within range -- only if light levels are within range
if lig >= mlig and lig <= xlig and minetest.registered_entities[mob] then if lig >= mlig and lig <= xlig and core.registered_entities[mob] then
minetest.add_entity(pos2, mob) core.add_entity(pos2, mob)
end end
end end
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

View File

Before

Width:  |  Height:  |  Size: 202 B

After

Width:  |  Height:  |  Size: 202 B