mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-06-28 06:30:18 +02:00
tweak for mineclone and 5.x
This commit is contained in:
33
mount.lua
33
mount.lua
@ -1,8 +1,9 @@
|
||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||
|
||||
--[[ 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
|
||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check
|
||||
|
||||
-- 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
|
||||
|
||||
function mobs.attach() end
|
||||
function mobs.detach() end
|
||||
@ -11,11 +12,8 @@ or not minetest.get_modpath("player_api") then
|
||||
|
||||
return
|
||||
end
|
||||
]]
|
||||
|
||||
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 compatibility
|
||||
|
||||
-- Localise some functions
|
||||
local abs, cos, floor, sin, sqrt, pi =
|
||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||
|
||||
@ -105,15 +103,12 @@ local function force_detach(player)
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if is_50 then
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_attached[player:get_player_name()] = false
|
||||
mcl_player.player_set_animation(player, "stand", 30)
|
||||
else
|
||||
default.player_attached[name] = false
|
||||
default.player_set_animation(player, "stand", 30)
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
end
|
||||
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
@ -206,12 +201,10 @@ function mobs.attach(entity, player)
|
||||
|
||||
force_detach(player)
|
||||
|
||||
if is_50 then
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_attached[player:get_player_name()] = true
|
||||
else
|
||||
default.player_attached[player:get_player_name()] = true
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
end
|
||||
|
||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||
@ -228,12 +221,10 @@ function mobs.attach(entity, player)
|
||||
|
||||
if is_player(player) then
|
||||
|
||||
if is_50 then
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
||||
else
|
||||
default.player_set_animation(player, "sit", 30)
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user