Fix remaining crash if player_api isn't available

master
Lars Mueller 2022-01-16 13:16:13 +01:00
parent 29229e6a93
commit 88d2e10ad9
3 changed files with 18 additions and 4 deletions

View File

@ -382,11 +382,10 @@ function def:on_punch(puncher)
self:_update_texture()
epidermis.set_player_data(player_name, {epidermis = self._.base_texture})
-- Swap skins & meshes with owner
local puncher_model = player_api.get_animation(puncher).model
local puncher_model = epidermis.get_model(puncher)
local puncher_skin = epidermis.get_skin(puncher)
player_api.set_model(puncher, self._.mesh)
epidermis.set_model(puncher, self._.mesh)
epidermis.set_skin(puncher, self._.base_texture)
player_api.set_textures(puncher, {self._.base_texture})
if puncher_skin:match"^[^%[%^]+%.png$" then -- simple texture without modifiers
self:_set_mesh(puncher_model)
self:_set_texture(puncher_skin, true)

View File

@ -34,4 +34,19 @@ end
function epidermis.set_skin(player, skin)
set_texture(player, skin_texture_index, skin)
end
function epidermis.get_model(player)
if player_api then
return player_api.get_animation(player).model
end
return player:get_properties().mesh
end
function epidermis.set_model(player, model)
if player_api then
player_api.set_model(player, model)
return
end
player:set_properties{mesh = model}
end

View File

@ -17,7 +17,7 @@ minetest.register_craftitem("epidermis:spawner_paintable", {
minetest.serialize{
owner = user:get_player_name(),
base_texture = base_texture,
mesh = assert(player_api.get_animation(user).model)
mesh = assert(epidermis.get_model(user))
}
)
if not object then