diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index f762b9d6..1cebed0c 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -330,22 +330,27 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz inv_bg = "crafting_inventory_creative_survival.png" -- Show armor and player image - local img, img_player - if mod_player then - img_player = mcl_player.player_get_preview(player) + local player_preview + if minetest.settings:get_bool("3d_player_preview", true) then + player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "") else - img_player = "player.png" - end - img = img_player - local player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]" - if show_armor and armor.textures[playername] and armor.textures[playername].preview then - img = armor.textures[playername].preview - local s1 = img:find("character_preview") - if s1 ~= nil then - s1 = img:sub(s1+21) - img = img_player..s1 + local img, img_player + if mod_player then + img_player = mcl_player.player_get_preview(player) + else + img_player = "player.png" end + img = img_player player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]" + if show_armor and armor.textures[playername] and armor.textures[playername].preview then + img = armor.textures[playername].preview + local s1 = img:find("character_preview") + if s1 ~= nil then + s1 = img:sub(s1+21) + img = img_player..s1 + end + player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]" + end end -- Background images for armor slots (hide if occupied) diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index c6f97185..05442405 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -64,22 +64,27 @@ local function set_inventory(player, armor_change_only) local player_name = player:get_player_name() -- Show armor and player image - local img, img_player - if mod_player then - img_player = mcl_player.player_get_preview(player) + local player_preview + if minetest.settings:get_bool("3d_player_preview", true) then + player_preview = mcl_player.get_player_formspec_model(player, 1.0, 0.0, 2.25, 4.5, "") else - img_player = "player.png" - end - img = img_player - local player_preview = "image[0.6,0.2;2,4;"..img.."]" - if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then - img = armor.textures[player_name].preview - local s1 = img:find("character_preview") - if s1 ~= nil then - s1 = img:sub(s1+21) - img = img_player..s1 + local img, img_player + if mod_player then + img_player = mcl_player.player_get_preview(player) + else + img_player = "player.png" + end + img = img_player + player_preview = "image[0.6,0.2;2,4;"..img.."]" + if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then + img = armor.textures[player_name].preview + local s1 = img:find("character_preview") + if s1 ~= nil then + s1 = img:sub(s1+21) + img = img_player..s1 + end + player_preview = "image[1.1,0.2;2,4;"..img.."]" end - player_preview = "image[1.1,0.2;2,4;"..img.."]" end local armor_slots = {"helmet", "chestplate", "leggings", "boots"} diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index f58c58fe..e6610caa 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -93,6 +93,13 @@ function mcl_player.player_get_preview(player) end end +function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname) + local name = player:get_player_name() + local model = player_model[name] + local anim = models[model].animations[player_anim[name]] + return "model[" .. x .. "," .. y .. ";" .. w .. "," .. h .. ";" .. fsname .. ";" .. model .. ";" .. table.concat(player_textures[name], ",") .. ";0," .. 180 .. ";false;false;" .. anim.x .. "," .. anim.y .. "]" +end + function mcl_player.player_set_animation(player, anim_name, speed) local name = player:get_player_name() if player_anim[name] == anim_name then diff --git a/settingtypes.txt b/settingtypes.txt index 394749fd..7acccf91 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -94,6 +94,9 @@ fire_animation_frames (Fire Animation Frames) int 8 # Whether to animate chests when open / close animated_chests (Animated chests) bool true +# Whether to preview the player in inventory in 3D (requires Minetest 5.4) +3d_player_preview (3D Player preview) bool true + [Experimental] # Whether ice is translucent. If disabled, ice is fully opaque. #