update player model remove vertial 1 node offset on newer engines only
* Player model: Remove vertical 1 node offset for new engines, but Required due to the settable player collision box engine feature change for MT/MTG v0.5.0 that breaks compatibility with old client so due that this commit will added backguard compatibility * Autodetec minetest versoin engine and provide right model character, update player code to provide compatibility with player_api
This commit is contained in:
parent
c3edca70aa
commit
3b5cbef652
@ -23,3 +23,27 @@ LIGHT_MAX = default.LIGHT_MAX
|
||||
|
||||
-- Formspecs
|
||||
default.gui_suvival_form = default.gui_survival_form
|
||||
default.gui_bg = ""
|
||||
default.gui_bg_img = ""
|
||||
default.gui_slots = ""
|
||||
|
||||
-- Players
|
||||
if minetest.get_modpath("player_api") then
|
||||
default.registered_player_models = player_api.registered_models
|
||||
default.player_register_model = player_api.register_model
|
||||
default.player_attached = player_api.player_attached
|
||||
default.player_get_animation = player_api.get_animation
|
||||
default.player_set_model = player_api.set_model
|
||||
default.player_set_textures = player_api.set_textures
|
||||
default.player_set_animation = player_api.set_animation
|
||||
else
|
||||
player_api = {}
|
||||
player_api.registered_models = default.registered_player_models
|
||||
player_api.register_model = default.player_register_model
|
||||
player_api.player_attached = default.player_attached
|
||||
player_api.get_animation = default.player_get_animation
|
||||
player_api.set_model = default.player_set_model
|
||||
player_api.set_textures = default.player_set_textures
|
||||
player_api.set_animation = default.player_set_animation
|
||||
end
|
||||
|
||||
|
2
mods/default/mod.conf
Normal file
2
mods/default/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = default
|
||||
description = Minetest Game mod: default
|
BIN
mods/default/models/character50.b3d
Normal file
BIN
mods/default/models/character50.b3d
Normal file
Binary file not shown.
BIN
mods/default/models/character50.blend
Normal file
BIN
mods/default/models/character50.blend
Normal file
Binary file not shown.
@ -4,6 +4,17 @@
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
local animation_blend = 0
|
||||
local modelchar
|
||||
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha") or nil
|
||||
|
||||
if is_50 then
|
||||
modelchar = "character50.b3d"
|
||||
eyeheithg = 1.47
|
||||
else
|
||||
modelchar = "character40.b3d"
|
||||
eyeheithg = 1.625
|
||||
end
|
||||
|
||||
default.registered_player_models = { }
|
||||
|
||||
@ -14,22 +25,6 @@ function default.player_register_model(name, def)
|
||||
models[name] = def
|
||||
end
|
||||
|
||||
-- Default player appearance
|
||||
default.player_register_model("character.b3d", {
|
||||
animation_speed = 30,
|
||||
textures = {"character.png", },
|
||||
animations = {
|
||||
-- Standard animations.
|
||||
stand = { x= 0, y= 79, },
|
||||
lay = { x=162, y=166, },
|
||||
walk = { x=168, y=187, },
|
||||
mine = { x=189, y=198, },
|
||||
walk_mine = { x=200, y=219, },
|
||||
sit = { x= 81, y=160, },
|
||||
},
|
||||
eye_height = 1.625,
|
||||
})
|
||||
|
||||
-- Player stats and animations
|
||||
local player_model = {}
|
||||
local player_textures = {}
|
||||
@ -58,15 +53,20 @@ function default.player_set_model(player, model_name)
|
||||
mesh = model_name,
|
||||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = model.visual_size or {x=1, y=1},
|
||||
eye_height = model.eye_height or 1.47,
|
||||
visual_size = model.visual_size or {x = 1, y = 1},
|
||||
collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
||||
stepheight = model.stepheight or 0.6,
|
||||
eye_height = model.eye_height or eyeheithg,
|
||||
})
|
||||
default.player_set_animation(player, "stand")
|
||||
else
|
||||
player:set_properties({
|
||||
textures = { "player.png", "player_back.png", },
|
||||
textures = {"player.png", "player_back.png"},
|
||||
visual = "upright_sprite",
|
||||
eye_height = 1.625,
|
||||
visual_size = {x = 1, y = 2},
|
||||
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3},
|
||||
stepheight = 0.6,
|
||||
eye_height = eyeheithg,
|
||||
})
|
||||
end
|
||||
player_model[name] = model_name
|
||||
@ -74,8 +74,10 @@ end
|
||||
|
||||
function default.player_set_textures(player, textures)
|
||||
local name = player:get_player_name()
|
||||
player_textures[name] = textures
|
||||
player:set_properties({textures = textures,})
|
||||
local model = models[player_model[name]]
|
||||
local model_textures = model and model.textures or nil
|
||||
player_textures[name] = textures or model_textures
|
||||
player:set_properties({textures = textures or model_textures,})
|
||||
end
|
||||
|
||||
function default.player_set_animation(player, anim_name, speed)
|
||||
@ -92,14 +94,36 @@ function default.player_set_animation(player, anim_name, speed)
|
||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||
end
|
||||
|
||||
|
||||
-- Default player appearance
|
||||
default.player_register_model( modelchar, {
|
||||
animation_speed = 30,
|
||||
textures = {"character.png", },
|
||||
animations = {
|
||||
-- Standard animations.
|
||||
stand = {x = 0, y = 79},
|
||||
lay = {x = 162, y = 166},
|
||||
walk = {x = 168, y = 187},
|
||||
mine = {x = 189, y = 198},
|
||||
walk_mine = {x = 200, y = 219},
|
||||
sit = {x = 81, y = 160},
|
||||
},
|
||||
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
||||
stepheight = 0.6,
|
||||
eye_height = eyeheithg,
|
||||
})
|
||||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_attached[player:get_player_name()] = false
|
||||
default.player_set_model(player, "character.b3d")
|
||||
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
|
||||
|
||||
player:hud_set_hotbar_image("gui_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
|
||||
default.player_set_model(player, modelchar)
|
||||
player:set_local_animation(
|
||||
{x = 0, y = 79},
|
||||
{x = 168, y = 187},
|
||||
{x = 189, y = 198},
|
||||
{x = 200, y = 219},
|
||||
30
|
||||
)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
@ -113,6 +137,15 @@ end)
|
||||
local player_set_animation = default.player_set_animation
|
||||
local player_attached = default.player_attached
|
||||
|
||||
-- Prevent knockback for attached players
|
||||
local old_calculate_knockback = minetest.calculate_knockback
|
||||
function minetest.calculate_knockback(player, ...)
|
||||
if player_attached[player:get_player_name()] then
|
||||
return 0
|
||||
end
|
||||
return old_calculate_knockback(player, ...)
|
||||
end
|
||||
|
||||
-- Check each player and apply animations
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 142 B |
Binary file not shown.
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 140 B |
Loading…
x
Reference in New Issue
Block a user