mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-24 16:20:19 +01:00
add 0.4.x compatibility when riding mod
This commit is contained in:
parent
9f74408792
commit
65e369e5fc
@ -8,3 +8,4 @@ lucky_block?
|
|||||||
cmi?
|
cmi?
|
||||||
toolranks?
|
toolranks?
|
||||||
pathfinder?
|
pathfinder?
|
||||||
|
player_api?
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = mobs
|
name = mobs
|
||||||
depends =
|
depends =
|
||||||
optional_depends = default, tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder
|
optional_depends = default, tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder, player_api
|
||||||
description = Adds a mob api for mods to add animals or monsters etc.
|
description = Adds a mob api for mods to add animals or monsters etc.
|
||||||
|
34
mount.lua
34
mount.lua
@ -1,5 +1,7 @@
|
|||||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||||
|
|
||||||
|
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -73,6 +75,8 @@ end
|
|||||||
|
|
||||||
local function force_detach(player)
|
local function force_detach(player)
|
||||||
|
|
||||||
|
if not player then return end
|
||||||
|
|
||||||
local attached_to = player:get_attach()
|
local attached_to = player:get_attach()
|
||||||
|
|
||||||
if not attached_to then
|
if not attached_to then
|
||||||
@ -87,11 +91,19 @@ local function force_detach(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
player:set_detach()
|
player:set_detach()
|
||||||
player_api.player_attached[player:get_player_name()] = false
|
|
||||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
|
||||||
player_api.set_animation(player, "stand", 30)
|
|
||||||
player:set_properties({visual_size = {x = 1, y = 1}})
|
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
if is_50 then
|
||||||
|
player_api.player_attached[name] = false
|
||||||
|
player_api.set_animation(player, "stand", 30)
|
||||||
|
else
|
||||||
|
default.player_attached[name] = false
|
||||||
|
default.player_set_animation(player, "stand", 30)
|
||||||
|
end
|
||||||
|
|
||||||
|
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
|
player:set_properties({visual_size = {x = 1, y = 1}})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -99,6 +111,7 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
force_detach(player)
|
force_detach(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
|
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
@ -108,6 +121,7 @@ minetest.register_on_shutdown(function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
return true
|
return true
|
||||||
@ -168,8 +182,13 @@ function mobs.attach(entity, player)
|
|||||||
|
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
|
|
||||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
if is_50 then
|
||||||
player_api.player_attached[player:get_player_name()] = true
|
player_api.player_attached[player:get_player_name()] = true
|
||||||
|
else
|
||||||
|
default.player_attached[player:get_player_name()] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||||
player:set_eye_offset(eye_offset, {x = 0, y = 0, z = 0})
|
player:set_eye_offset(eye_offset, {x = 0, y = 0, z = 0})
|
||||||
|
|
||||||
player:set_properties({
|
player:set_properties({
|
||||||
@ -182,7 +201,12 @@ function mobs.attach(entity, player)
|
|||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
|
|
||||||
if player and player:is_player() then
|
if player and player:is_player() then
|
||||||
|
|
||||||
|
if is_50 then
|
||||||
player_api.set_animation(player, "sit", 30)
|
player_api.set_animation(player, "sit", 30)
|
||||||
|
else
|
||||||
|
default.player_set_animation(player, "sit", 30)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user