dont force mc2 or faroming, proper checks of player on mount logic

* proper checks on mount logic
* do not force mc2 or farming on local items
  for craft recipes to work
* seems minimized nodes at do_states, add older ones
This commit is contained in:
mckaygerhard 2023-07-28 23:05:30 -04:00
parent 90292f9af2
commit f12519cd5f
3 changed files with 69 additions and 56 deletions

11
api.lua
View File

@ -30,8 +30,9 @@ mobs = {
version = "20230726", version = "20230726",
intllib = S, intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}, invis = minetest.global_exists("invisibility") and invisibility or {},
node_snow = minetest.registered_aliases["mapgen_snow"] or "mcl_core:snow", node_ice = "default:ice"
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" node_snow = minetest.registered_aliases["mapgen_snow"] or "default:snow" or "mcl_core:snow",
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "default:dirt" or "mcl_core:dirt"
} }
mobs.fallback_node = mobs.node_dirt mobs.fallback_node = mobs.node_dirt
@ -2340,9 +2341,9 @@ function mob_class:do_states(dtime)
local s = self.object:get_pos() local s = self.object:get_pos()
local grps = {} local grps = {}
if self.water_damage > 0 then table.insert(grps, "group:water") end if self.water_damage > 0 then table.insert(grps, "group:water", "group:igniter") end
if self.fire_damage > 0 then table.insert(grps, "group:fire") 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 if self.lava_damage > 0 then table.insert(grps, "group:lava", "group:igniter") end
local lp = minetest.find_node_near(s, 1, grps) local lp = minetest.find_node_near(s, 1, grps)
@ -2353,7 +2354,7 @@ function mob_class:do_states(dtime)
lp = minetest.find_nodes_in_area_under_air( 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 , z = s.z - 5},
{x = s.x + 5, y = s.y + 2, z = s.z + 5}, {x = s.x + 5, y = s.y + 2, z = s.z + 5},
{"group:cracky", "group:crumbly", "group:choppy", "group:solid"}) {"group:cracky", "group:crumbly", "group:choppy", "group:solid", "group:stone", "group:sand", node_ice, node_snowblock})
-- did we find land? -- did we find land?
if lp and #lp > 0 then if lp and #lp > 0 then

View File

@ -4,20 +4,20 @@ local mc2 = minetest.get_modpath("mcl_core")
-- recipe items -- recipe items
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",
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",
steel_ingot = mc2 and "mcl_core:iron_ingot" or "default:steel_ingot", steel_ingot = (mc2 and "mcl_core:iron_ingot") or "default:steel_ingot",
gold_block = mc2 and "mcl_core:goldblock" or "default:goldblock", gold_block = (mc2 and "mcl_core:goldblock") or "default:goldblock",
diamond_block = mc2 and "mcl_core:diamondblock" or "default:diamondblock", diamond_block = (mc2 and "mcl_core:diamondblock") or "default:diamondblock",
stone = mc2 and "mcl_core:stone" or "default:stone", stone = (mc2 and "mcl_core:stone") or "default:stone",
mese_crystal = mc2 and "mcl_core:gold_ingot" or "default:mese_crystal", mese_crystal = (mc2 and "mcl_core:gold_ingot") or "default:mese_crystal",
wood = mc2 and "mcl_core:wood" or "default:wood", wood = (mc2 and "mcl_core:wood") or "default:wood",
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",
} }
-- name tag -- name tag
@ -27,12 +27,14 @@ minetest.register_craftitem("mobs:nametag", {
groups = {flammable = 2, nametag = 1} groups = {flammable = 2, nametag = 1}
}) })
minetest.register_craft({ if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
output = "mobs:nametag", minetest.register_craft({
recipe = { output = "mobs:nametag",
{ items.paper, items.dye_black, items.string } recipe = {
} { items.paper, items.dye_black, items.string }
}) }
})
end
-- leather -- leather
minetest.register_craftitem("mobs:leather", { minetest.register_craftitem("mobs:leather", {
@ -71,14 +73,17 @@ minetest.register_tool("mobs:lasso", {
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ if minetest.get_modpath("farming") then
output = "mobs:lasso",
recipe = { minetest.register_craft({
{ items.string, "", items.string}, output = "mobs:lasso",
{ "", items.diamond, "" }, recipe = {
{ items.string, "", items.string } { items.string, "", items.string},
} { "", items.diamond, "" },
}) { items.string, "", items.string }
}
})
end
minetest.register_alias("mobs:magic_lasso", "mobs:lasso") minetest.register_alias("mobs:magic_lasso", "mobs:lasso")
@ -89,14 +94,17 @@ minetest.register_tool("mobs:net", {
groups = {flammable = 2} groups = {flammable = 2}
}) })
minetest.register_craft({ if minetest.get_modpath("farming") then
output = "mobs:net",
recipe = { minetest.register_craft({
{ items.stick, "", items.stick }, output = "mobs:net",
{ items.stick, "", items.stick }, recipe = {
{ items.string, items.stick, items.string } { items.stick, "", items.stick },
} { items.stick, "", items.stick },
}) { items.string, items.stick, items.string }
}
})
end
-- shears (right click to shear animal) -- shears (right click to shear animal)
minetest.register_tool("mobs:shears", { minetest.register_tool("mobs:shears", {

View File

@ -13,9 +13,18 @@ or not minetest.get_modpath("player_api") then
end end
]] ]]
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility local is_pa = minetest.get_modpath("player_api") -- 5.x compatibility
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 compatibility local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 compatibility
-- are we a real player ?
local function is_player(player)
if player and type(player) == "userdata" and minetest.is_player(player) then
return true
end
end
local abs, cos, floor, sin, sqrt, pi = local abs, cos, floor, sin, sqrt, pi =
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
@ -89,7 +98,9 @@ end
local function force_detach(player) local function force_detach(player)
local attached_to = player and player:get_attach() if not is_player(player) then return end
local attached_to = player:get_attach()
if not attached_to then if not attached_to then
return return
@ -105,7 +116,7 @@ local function force_detach(player)
local name = player:get_player_name() local name = player:get_player_name()
if is_50 then if is_pa then
player_api.player_attached[name] = false player_api.player_attached[name] = false
player_api.set_animation(player, "stand", 30) player_api.set_animation(player, "stand", 30)
elseif is_mc2 then elseif is_mc2 then
@ -175,17 +186,10 @@ local function find_free_pos(pos)
end end
-- are we a real player ?
local function is_player(player)
if player and type(player) == "userdata" and minetest.is_player(player) then
return true
end
end
function mobs.attach(entity, player) function mobs.attach(entity, player)
if not is_player(player) then return end
entity.player_rotation = entity.player_rotation or {x = 0, y = 0, z = 0} entity.player_rotation = entity.player_rotation or {x = 0, y = 0, z = 0}
entity.driver_attach_at = entity.driver_attach_at or {x = 0, y = 0, z = 0} entity.driver_attach_at = entity.driver_attach_at or {x = 0, y = 0, z = 0}
entity.driver_eye_offset = entity.driver_eye_offset or {x = 0, y = 0, z = 0} entity.driver_eye_offset = entity.driver_eye_offset or {x = 0, y = 0, z = 0}
@ -204,7 +208,7 @@ function mobs.attach(entity, player)
force_detach(player) force_detach(player)
if is_50 then if is_pa then
player_api.player_attached[player:get_player_name()] = true player_api.player_attached[player:get_player_name()] = true
elseif is_mc2 then elseif is_mc2 then
mcl_player.player_attached[player:get_player_name()] = true mcl_player.player_attached[player:get_player_name()] = true
@ -226,7 +230,7 @@ function mobs.attach(entity, player)
if is_player(player) then if is_player(player) then
if is_50 then if is_pa then
player_api.set_animation(player, "sit", 30) player_api.set_animation(player, "sit", 30)
elseif is_mc2 then elseif is_mc2 then
mcl_player.player_set_animation(player, "sit_mount" , 30) mcl_player.player_set_animation(player, "sit_mount" , 30)
@ -246,7 +250,7 @@ function mobs.detach(player)
minetest.after(0.1, function() minetest.after(0.1, function()
if player and player:is_player() then if is_player(player) then
local pos = find_free_pos(player:get_pos()) local pos = find_free_pos(player:get_pos())