tweak for mineclone and 5.x
* backported from upstream, but still compatible with MT 0.4.X and 5.0pre
This commit is contained in:
parent
a8f447a346
commit
11ff8c34be
19
api.lua
19
api.lua
@ -1,4 +1,4 @@
|
|||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath("mobs")
|
||||||
-- Check for translation method
|
-- Check for translation method
|
||||||
local S
|
local S
|
||||||
|
|
||||||
@ -25,18 +25,25 @@ end
|
|||||||
-- CMI support check
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
|
-- MineClone2 check
|
||||||
|
local use_mc2 = minetest.get_modpath("mcl_core")
|
||||||
|
|
||||||
|
-- Visual Harm 1ndicator check
|
||||||
|
local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
||||||
|
|
||||||
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230805",
|
version = "20230809",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_ice = "default:ice",
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"] or "default:snow" or "mcl_core:snow",
|
or (use_mc2 and "mcl_core:snow") or "default:snow",
|
||||||
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "default:dirt" or "mcl_core:dirt"
|
node_dirt = minetest.registered_aliases["mapgen_dirt"]
|
||||||
|
or (use_mc2 and "mcl_core:dirt") or "default:dirt"
|
||||||
}
|
}
|
||||||
mobs.fallback_node = mobs.node_dirt
|
mobs.fallback_node = mobs.node_dirt
|
||||||
|
|
||||||
|
|
||||||
-- localize common functions
|
-- localize common functions
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local square = math.sqrt
|
local square = math.sqrt
|
||||||
|
5
init.lua
5
init.lua
@ -21,6 +21,9 @@ dofile(path .. "/crafts.lua")
|
|||||||
dofile(path .. "/spawner.lua")
|
dofile(path .. "/spawner.lua")
|
||||||
|
|
||||||
-- Lucky Blocks
|
-- Lucky Blocks
|
||||||
dofile(path .. "/lucky_block.lua")
|
if minetest.get_modpath("lucky_block") then
|
||||||
|
dofile(path .. "/lucky_block.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
print("[MOD] Mobs Redo loaded")
|
print("[MOD] Mobs Redo loaded")
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
if minetest.get_modpath("lucky_block") then
|
lucky_block:add_blocks({
|
||||||
|
|
||||||
lucky_block:add_blocks({
|
|
||||||
{"dro", {"mobs:meat_raw"}, 5},
|
{"dro", {"mobs:meat_raw"}, 5},
|
||||||
{"dro", {"mobs:meat"}, 5},
|
{"dro", {"mobs:meat"}, 5},
|
||||||
{"dro", {"mobs:nametag"}, 1},
|
{"dro", {"mobs:nametag"}, 1},
|
||||||
@ -14,5 +12,4 @@ if minetest.get_modpath("lucky_block") then
|
|||||||
{"dro", {"mobs:fence_wood"}, 10},
|
{"dro", {"mobs:fence_wood"}, 10},
|
||||||
{"dro", {"mobs:fence_top"}, 12},
|
{"dro", {"mobs:fence_top"}, 12},
|
||||||
{"lig"}
|
{"lig"}
|
||||||
})
|
})
|
||||||
end
|
|
||||||
|
39
mount.lua
39
mount.lua
@ -1,8 +1,10 @@
|
|||||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||||
|
|
||||||
--[[ one of these is needed (for now) to ride mobs, otherwise no riding for you
|
local is_pa = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||||
if not minetest.get_modpath("default")
|
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check
|
||||||
or not minetest.get_modpath("player_api") then
|
|
||||||
|
-- one of these is needed to ride mobs, otherwise no riding for you
|
||||||
|
if not minetest.get_modpath("default") and not is_pa and not is_mc2 then
|
||||||
|
|
||||||
function mobs.attach() end
|
function mobs.attach() end
|
||||||
function mobs.detach() end
|
function mobs.detach() end
|
||||||
@ -11,10 +13,6 @@ or not minetest.get_modpath("player_api") then
|
|||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
|
|
||||||
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 ?
|
-- are we a real player ?
|
||||||
local function is_player(player)
|
local function is_player(player)
|
||||||
@ -25,7 +23,7 @@ local function is_player(player)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Localise some functions
|
||||||
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
|
||||||
|
|
||||||
@ -117,16 +115,18 @@ local function force_detach(player)
|
|||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
if is_pa then
|
if is_mc2 then
|
||||||
player_api.player_attached[name] = false
|
|
||||||
player_api.set_animation(player, "stand", 30)
|
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_attached[player:get_player_name()] = false
|
mcl_player.player_attached[player:get_player_name()] = false
|
||||||
mcl_player.player_set_animation(player, "stand", 30)
|
mcl_player.player_set_animation(player, "stand", 30)
|
||||||
|
else
|
||||||
|
if is_pa then
|
||||||
|
player_api.player_attached[name] = false
|
||||||
|
player_api.set_animation(player, "stand", 30)
|
||||||
else
|
else
|
||||||
default.player_attached[name] = false
|
default.player_attached[name] = false
|
||||||
default.player_set_animation(player, "stand", 30)
|
default.player_set_animation(player, "stand", 30)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
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}})
|
player:set_properties({visual_size = {x = 1, y = 1}})
|
||||||
@ -209,13 +209,15 @@ function mobs.attach(entity, player)
|
|||||||
|
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
|
|
||||||
if is_pa then
|
if is_mc2 then
|
||||||
player_api.player_attached[player:get_player_name()] = true
|
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_attached[player:get_player_name()] = true
|
mcl_player.player_attached[player:get_player_name()] = true
|
||||||
|
else
|
||||||
|
if is_pa then
|
||||||
|
player_api.player_attached[player:get_player_name()] = true
|
||||||
else
|
else
|
||||||
default.player_attached[player:get_player_name()] = true
|
default.player_attached[player:get_player_name()] = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
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})
|
||||||
@ -231,10 +233,11 @@ function mobs.attach(entity, player)
|
|||||||
|
|
||||||
if is_player(player) then
|
if is_player(player) then
|
||||||
|
|
||||||
|
if is_mc2 then
|
||||||
|
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
||||||
|
else
|
||||||
if is_pa then
|
if is_pa then
|
||||||
player_api.set_animation(player, "sit", 30)
|
player_api.set_animation(player, "sit", 30)
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
|
||||||
else
|
else
|
||||||
default.player_set_animation(player, "sit", 30)
|
default.player_set_animation(player, "sit", 30)
|
||||||
end
|
end
|
||||||
@ -342,7 +345,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
if velo.y > 0 then velo.y = 0 end
|
if velo.y > 0 then velo.y = 0 end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ctrl.jump then -- jump
|
if ctrl.jump then -- jump (only when standing on solid surface)
|
||||||
|
|
||||||
if velo.y == 0 then
|
if velo.y == 0 then
|
||||||
velo.y = velo.y + entity.jump_height
|
velo.y = velo.y + entity.jump_height
|
||||||
|
Loading…
x
Reference in New Issue
Block a user