better MineClone2 compatibility for api, items and crafts
This commit is contained in:
parent
3106c4c859
commit
f31cf75b24
40
api.lua
40
api.lua
@ -23,12 +23,11 @@ end
|
||||
-- CMI support check
|
||||
local use_cmi = minetest.global_exists("cmi")
|
||||
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20230715",
|
||||
intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||
}
|
||||
mobs.mod = "redo"
|
||||
mobs.version = "20230726"
|
||||
mobs.intllib = S
|
||||
mobs.invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||
|
||||
|
||||
-- localize common functions
|
||||
local pi = math.pi
|
||||
@ -132,12 +131,6 @@ local aoc_range = tonumber(settings:get("active_block_range")) * 16
|
||||
local creatura = minetest.get_modpath("creatura") and
|
||||
settings:get_bool("mobs_attack_creatura") == true
|
||||
|
||||
-- default nodes
|
||||
local node_ice = "default:ice"
|
||||
local node_snowblock = "default:snowblock"
|
||||
local node_snow = "default:snow"
|
||||
|
||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "default:dirt"
|
||||
|
||||
mobs.mob_class = {
|
||||
stepheight = 1.1,
|
||||
@ -1252,7 +1245,7 @@ function mob_class:do_jump()
|
||||
and (self.walk_chance == 0 or minetest.registered_items[self.looking_at].walkable)
|
||||
and not blocked
|
||||
and not self.facing_fence
|
||||
and self.looking_at ~= node_snow then
|
||||
and self.looking_at ~= mobs.node_snow then
|
||||
|
||||
local v = self.object:get_velocity()
|
||||
|
||||
@ -2271,22 +2264,13 @@ function mob_class:do_states(dtime)
|
||||
if is_node_dangerous(self, self.standing_in) then
|
||||
|
||||
local s = self.object:get_pos()
|
||||
local lp
|
||||
local grps = {}
|
||||
|
||||
-- is there something I need to avoid?
|
||||
if self.water_damage > 0
|
||||
and self.lava_damage > 0 then
|
||||
if self.water_damage > 0 then table.insert(grps, "group:water") end
|
||||
if self.fire_damage > 0 then table.insert(grps, "group:fire") end
|
||||
if self.lava_damage > 0 then table.insert(grps, "group:lava") end
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:water", "group:igniter"})
|
||||
|
||||
elseif self.water_damage > 0 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:water"})
|
||||
|
||||
elseif self.lava_damage > 0 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:igniter"})
|
||||
end
|
||||
local lp = minetest.find_node_near(s, 1, grps)
|
||||
|
||||
if lp then
|
||||
|
||||
@ -2295,7 +2279,7 @@ function mob_class:do_states(dtime)
|
||||
lp = minetest.find_nodes_in_area_under_air(
|
||||
{x = s.x - 5, y = s.y , z = s.z - 5},
|
||||
{x = s.x + 5, y = s.y + 2, z = s.z + 5},
|
||||
{"group:soil", "group:stone", "group:sand", node_ice, node_snowblock})
|
||||
{"group:cracky", "group:crumbly", "group:choppy", "group:solid"})
|
||||
|
||||
-- did we find land?
|
||||
if lp and #lp > 0 then
|
||||
|
10
compatibility.lua
Normal file
10
compatibility.lua
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
local mc2 = minetest.get_modpath("mcl_core")
|
||||
|
||||
mobs.node_ice = minetest.registered_aliases["mapgen_ice"] or "mcl_core:ice"
|
||||
mobs.node_snow = minetest.registered_aliases["mapgen_snow"] or "mcl_core:snow"
|
||||
mobs.node_snowblock = minetest.registered_aliases["mapgen_snowblock"] or "mcl_core:snowblock"
|
||||
mobs.node_stone = minetest.registered_aliases["mapgen_stone"] or "mcl_core:stone"
|
||||
mobs.node_dirt = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
||||
|
||||
mobs.fallback_node = mobs.node_dirt
|
89
crafts.lua
89
crafts.lua
@ -1,5 +1,24 @@
|
||||
|
||||
local S = mobs.intllib
|
||||
local mc2 = minetest.get_modpath("mcl_core")
|
||||
|
||||
-- recipe items
|
||||
local items = {
|
||||
paper = mc2 and "mcl_core:paper" or "default:paper",
|
||||
dye_black = mc2 and "mcl_dye:black" or "dye:black",
|
||||
string = mc2 and "mcl_mobitems:string" or "farming:string",
|
||||
stick = mc2 and "mcl_core:stick" or "default:stick",
|
||||
diamond = mc2 and "mcl_core:diamond" or "default:diamond",
|
||||
steel_ingot = mc2 and "mcl_core:iron_ingot" or "default:steel_ingot",
|
||||
gold_block = mc2 and "mcl_core:goldblock" or "default:goldblock",
|
||||
diamond_block = mc2 and "mcl_core:diamondblock" or "default:diamondblock",
|
||||
stone = mc2 and "mcl_core:stone" or "default:stone",
|
||||
mese_crystal = mc2 and "mcl_core:gold_ingot" or "default:mese_crystal",
|
||||
wood = mc2 and "mcl_core:wood" or "default: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_cooked = mc2 and "mcl_mobitems:cooked_beef" or "group:food_meat",
|
||||
}
|
||||
|
||||
-- name tag
|
||||
minetest.register_craftitem("mobs:nametag", {
|
||||
@ -8,12 +27,12 @@ minetest.register_craftitem("mobs:nametag", {
|
||||
groups = {flammable = 2, nametag = 1}
|
||||
})
|
||||
|
||||
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
|
||||
minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "mobs:nametag",
|
||||
recipe = {{"default:paper", "dye:black", "farming:string"}}
|
||||
})
|
||||
end
|
||||
recipe = {
|
||||
{ items.paper, items.dye_black, items.string }
|
||||
}
|
||||
})
|
||||
|
||||
-- leather
|
||||
minetest.register_craftitem("mobs:leather", {
|
||||
@ -52,17 +71,14 @@ minetest.register_tool("mobs:lasso", {
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
if minetest.get_modpath("farming") then
|
||||
|
||||
minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "mobs:lasso",
|
||||
recipe = {
|
||||
{"farming:string", "", "farming:string"},
|
||||
{"", "default:diamond", ""},
|
||||
{"farming:string", "", "farming:string"}
|
||||
{ items.string, "", items.string},
|
||||
{ "", items.diamond, "" },
|
||||
{ items.string, "", items.string }
|
||||
}
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_alias("mobs:magic_lasso", "mobs:lasso")
|
||||
|
||||
@ -73,17 +89,14 @@ minetest.register_tool("mobs:net", {
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
if minetest.get_modpath("farming") then
|
||||
|
||||
minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "mobs:net",
|
||||
recipe = {
|
||||
{"group:stick", "", "group:stick"},
|
||||
{"group:stick", "", "group:stick"},
|
||||
{"farming:string", "group:stick", "farming:string"}
|
||||
{ items.stick, "", items.stick },
|
||||
{ items.stick, "", items.stick },
|
||||
{ items.string, items.stick, items.string }
|
||||
}
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
-- shears (right click to shear animal)
|
||||
minetest.register_tool("mobs:shears", {
|
||||
@ -95,8 +108,8 @@ minetest.register_tool("mobs:shears", {
|
||||
minetest.register_craft({
|
||||
output = "mobs:shears",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"", "group:stick", "default:steel_ingot"}
|
||||
{ "", items.steel_ingot, "" },
|
||||
{ "", items.stick, items.steel_ingot }
|
||||
}
|
||||
})
|
||||
|
||||
@ -110,9 +123,9 @@ minetest.register_craftitem("mobs:protector", {
|
||||
minetest.register_craft({
|
||||
output = "mobs:protector",
|
||||
recipe = {
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
{"default:stone", "default:goldblock", "default:stone"},
|
||||
{"default:stone", "default:stone", "default:stone"}
|
||||
{ items.stone, items.stone, items.stone },
|
||||
{ items.stone, items.gold_block, items.stone },
|
||||
{ items.stone, items.stone, items.stone }
|
||||
}
|
||||
})
|
||||
|
||||
@ -126,9 +139,9 @@ minetest.register_craftitem("mobs:protector2", {
|
||||
minetest.register_craft({
|
||||
output = "mobs:protector2",
|
||||
recipe = {
|
||||
{"mobs:protector", "default:mese_crystal", "mobs:protector"},
|
||||
{"default:mese_crystal", "default:diamondblock", "default:mese_crystal"},
|
||||
{"mobs:protector", "default:mese_crystal", "mobs:protector"}
|
||||
{ "mobs:protector", items.mese_crystal, "mobs:protector" },
|
||||
{ items.mese_crystal, items.diamond_block, items.mese_crystal },
|
||||
{ "mobs:protector", items.mese_crystal, "mobs:protector" }
|
||||
}
|
||||
})
|
||||
|
||||
@ -143,8 +156,8 @@ minetest.register_craft({
|
||||
output = "mobs:saddle",
|
||||
recipe = {
|
||||
{"mobs:leather", "mobs:leather", "mobs:leather"},
|
||||
{"mobs:leather", "default:steel_ingot", "mobs:leather"},
|
||||
{"mobs:leather", "default:steel_ingot", "mobs:leather"}
|
||||
{"mobs:leather", items.steel_ingot, "mobs:leather"},
|
||||
{"mobs:leather", items.steel_ingot, "mobs:leather"}
|
||||
}
|
||||
})
|
||||
|
||||
@ -197,7 +210,7 @@ minetest.register_craft({
|
||||
output = "mobs:fence_top 12",
|
||||
recipe = {
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"", "default:fence_wood", ""}
|
||||
{"", items.fence_wood, ""}
|
||||
}
|
||||
})
|
||||
|
||||
@ -372,9 +385,9 @@ minetest.register_node("mobs:meatblock", {
|
||||
minetest.register_craft({
|
||||
output = "mobs:meatblock",
|
||||
recipe = {
|
||||
{"group:food_meat", "group:food_meat", "group:food_meat"},
|
||||
{"group:food_meat", "group:food_meat", "group:food_meat"},
|
||||
{"group:food_meat", "group:food_meat", "group:food_meat"}
|
||||
{ items.meat_cooked, items.meat_cooked, items.meat_cooked },
|
||||
{ items.meat_cooked, items.meat_cooked, items.meat_cooked },
|
||||
{ items.meat_cooked, items.meat_cooked, items.meat_cooked }
|
||||
}
|
||||
})
|
||||
|
||||
@ -392,9 +405,9 @@ minetest.register_node("mobs:meatblock_raw", {
|
||||
minetest.register_craft({
|
||||
output = "mobs:meatblock_raw",
|
||||
recipe = {
|
||||
{"group:food_meat_raw", "group:food_meat_raw", "group:food_meat_raw"},
|
||||
{"group:food_meat_raw", "group:food_meat_raw", "group:food_meat_raw"},
|
||||
{"group:food_meat_raw", "group:food_meat_raw", "group:food_meat_raw"}
|
||||
{ items.meat_raw, items.meat_raw, items.meat_raw },
|
||||
{ items.meat_raw, items.meat_raw, items.meat_raw },
|
||||
{ items.meat_raw, items.meat_raw, items.meat_raw }
|
||||
}
|
||||
})
|
||||
|
||||
|
6
init.lua
6
init.lua
@ -7,6 +7,12 @@ minetest.register_privilege("peaceful_player", {
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
|
||||
-- global
|
||||
mobs = {}
|
||||
|
||||
-- Compatibility
|
||||
dofile(path .. "/compatibility.lua")
|
||||
|
||||
-- Mob API
|
||||
dofile(path .. "/api.lua")
|
||||
|
||||
|
14
mount.lua
14
mount.lua
@ -1,7 +1,19 @@
|
||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||
|
||||
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||
-- one of these is needed (for now) to ride mobs, otherwise no riding for you
|
||||
if not minetest.get_modpath("default")
|
||||
or not minetest.get_modpath("player_api") then
|
||||
|
||||
function mobs.attach() end
|
||||
function mobs.detach() end
|
||||
function mobs.fly() end
|
||||
function mobs.drive() end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||
local abs, cos, floor, sin, sqrt, pi =
|
||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||
|
||||
|
@ -34,6 +34,7 @@ https://forum.minetest.net/viewtopic.php?f=11&t=9917
|
||||
* Many bug fixes and tweaks to improve performance
|
||||
* Added 'mobs_attack_creatura' setting so that monsters can attack Creatura mobs
|
||||
* Nodes can be added to 'runaway_from' table
|
||||
* Better Mineclone2 compatibility with api, items and recipes
|
||||
|
||||
### Version 1.56
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user