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:
parent
90292f9af2
commit
f12519cd5f
11
api.lua
11
api.lua
@ -30,8 +30,9 @@ mobs = {
|
||||
version = "20230726",
|
||||
intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
node_snow = minetest.registered_aliases["mapgen_snow"] or "mcl_core:snow",
|
||||
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
||||
node_ice = "default:ice"
|
||||
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
|
||||
|
||||
@ -2340,9 +2341,9 @@ function mob_class:do_states(dtime)
|
||||
local s = self.object:get_pos()
|
||||
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.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)
|
||||
|
||||
@ -2353,7 +2354,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: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?
|
||||
if lp and #lp > 0 then
|
||||
|
48
crafts.lua
48
crafts.lua
@ -4,20 +4,20 @@ 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",
|
||||
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
|
||||
@ -27,12 +27,14 @@ minetest.register_craftitem("mobs:nametag", {
|
||||
groups = {flammable = 2, nametag = 1}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
|
||||
minetest.register_craft({
|
||||
output = "mobs:nametag",
|
||||
recipe = {
|
||||
{ items.paper, items.dye_black, items.string }
|
||||
}
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
-- leather
|
||||
minetest.register_craftitem("mobs:leather", {
|
||||
@ -71,14 +73,17 @@ minetest.register_tool("mobs:lasso", {
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
if minetest.get_modpath("farming") then
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:lasso",
|
||||
recipe = {
|
||||
{ items.string, "", items.string},
|
||||
{ "", items.diamond, "" },
|
||||
{ items.string, "", items.string }
|
||||
}
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_alias("mobs:magic_lasso", "mobs:lasso")
|
||||
|
||||
@ -89,14 +94,17 @@ minetest.register_tool("mobs:net", {
|
||||
groups = {flammable = 2}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
if minetest.get_modpath("farming") then
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:net",
|
||||
recipe = {
|
||||
{ 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", {
|
||||
|
34
mount.lua
34
mount.lua
@ -13,9 +13,18 @@ or not minetest.get_modpath("player_api") then
|
||||
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
|
||||
|
||||
-- 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 =
|
||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||
|
||||
@ -89,7 +98,9 @@ end
|
||||
|
||||
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
|
||||
return
|
||||
@ -105,7 +116,7 @@ local function force_detach(player)
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if is_50 then
|
||||
if is_pa then
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
elseif is_mc2 then
|
||||
@ -175,17 +186,10 @@ local function find_free_pos(pos)
|
||||
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)
|
||||
|
||||
if not is_player(player) then return end
|
||||
|
||||
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_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)
|
||||
|
||||
if is_50 then
|
||||
if is_pa then
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
elseif is_mc2 then
|
||||
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_50 then
|
||||
if is_pa then
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
elseif is_mc2 then
|
||||
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
||||
@ -246,7 +250,7 @@ function mobs.detach(player)
|
||||
|
||||
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())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user