Merge pull request 'Remove 2D preview + fix enchanting overlay (Fix #1869, #2161)' (#2162) from remove_3d_preview into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2162
Reviewed-by: kabou <kabou@noreply.git.minetest.land>
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-05-04 23:20:50 +00:00
commit e10c06ba98
40 changed files with 29 additions and 105 deletions

View file

@ -339,14 +339,6 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
if name == "inv" then
inv_bg = "crafting_inventory_creative_survival.png"
-- Show armor and player image
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
player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]"
end
-- Background images for armor slots (hide if occupied)
local armor_slot_imgs = ""
local inv = player:get_inventory()
@ -385,7 +377,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
mcl_formspec.get_itemslot_bg(1.5,2.025,1,1)..
armor_slot_imgs..
-- player preview
player_preview..
mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")..
-- crafting guide button
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
"tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]"..

View file

@ -60,14 +60,6 @@ local function set_inventory(player, armor_change_only)
inv:set_width("craft", 2)
inv:set_size("craft", 4)
-- Show armor and player image
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
player_preview = "image[1.1,0.2;2,4;"..mcl_player.player_get_preview(player).."]"
end
local armor_slots = {"helmet", "chestplate", "leggings", "boots"}
local armor_slot_imgs = ""
for a=1,4 do
@ -82,7 +74,7 @@ local function set_inventory(player, armor_change_only)
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png]"..
player_preview..
mcl_player.get_player_formspec_model(player, 1.0, 0.0, 2.25, 4.5, "")..
--armor
"list[current_player;armor;0,0;1,1;1]"..
"list[current_player;armor;0,1;1,1;2]"..

View file

@ -87,16 +87,6 @@ mcl_armor.register_set({
end,
},
--WARNING: 2d preview is deprecated and will be removed soon
--specify textures that will be shown in player inventory then you disabled the 3d player inventory preview
--its similar to how works the textures field
previews = {
head = "dummy_texture.png", --default: "<modname>_helmet_<material>_preview.png"
torso = "dummy_texture.png", --default: "<modname>_chestplate_<material>_preview.png"
legs = "dummy_texture.png", --default: "<modname>_leggings_<material>_preview.png"
feet = "dummy_texture.png", --default: "<modname>_boots_<material>_preview.png"
},
--inventory textures aren't definable using a table similar to textures or previews
--you are forced to use the default texture names which are:
--head: "<modname>_inv_helmet_<material>.png

View file

@ -94,7 +94,6 @@ function mcl_armor.register_set(def)
local on_unequip_callbacks = def.on_unequip_callbacks or {}
local on_break_callbacks = def.on_break_callbacks or {}
local textures = def.textures or {}
local previews = def.previews or {}
local durabilities = def.durabilities or {}
local element_groups = def.element_groups or {}
@ -134,7 +133,6 @@ function mcl_armor.register_set(def)
_on_break = on_break_callbacks[name] or def.on_break,
_mcl_armor_element = name,
_mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png",
_mcl_armor_preview = previews[name] or modname .. "_" .. itemname .. "_preview.png",
})
if def.craft_material then
@ -221,17 +219,6 @@ function mcl_armor.update(obj)
end
end
local preview = def._mcl_armor_preview
if obj:is_player() and preview then
if type(preview) == "function" then
preview = preview(obj, itemstack)
end
if preview then
info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" )
end
end
info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
local mob_range_mob = def._mcl_armor_mob_range_mob
@ -254,8 +241,6 @@ function mcl_armor.update(obj)
info.texture = info.texture or "blank.png"
if obj:is_player() then
info.preview = info.preview or "blank.png"
mcl_armor.update_player(obj, info)
else
local luaentity = obj:get_luaentity()

View file

@ -63,7 +63,7 @@ mcl_player.player_register_model("mcl_armor_character_female.b3d", {
})
function mcl_armor.update_player(player, info)
mcl_player.player_set_armor(player, info.texture, info.preview)
mcl_player.player_set_armor(player, info.texture)
local meta = player:get_meta()
meta:set_int("mcl_armor:armor_points", info.points)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

View file

@ -277,11 +277,10 @@ function mcl_enchanting.initialize()
new_def.groups.not_in_craft_guide = 1
new_def.groups.enchanted = 1
if new_def._mcl_armor_texture and not type(new_def._mcl_armor_texture) == "function" then
new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay
end
if new_def._mcl_armor_preview and not type(new_def._mcl_armor_preview) == "function" then
new_def._mcl_armor_preview = new_def._mcl_armor_preview .. mcl_enchanting.overlay
if new_def._mcl_armor_texture then
if type(new_def._mcl_armor_texture) == "string" then
new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay
end
end
new_def._mcl_enchanting_enchanted_tool = new_name

View file

@ -123,7 +123,6 @@ pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman"
pumpkin_face_base_def._mcl_armor_element = "head"
pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png"
pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png"
pumpkin_face_base_def.on_construct = function(pos)
-- Attempt to spawn iron golem or snow golem

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

View file

@ -113,7 +113,6 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor)
_mcl_armor_mob_range_factor = rangefactor,
_mcl_armor_element = "head",
_mcl_armor_texture = "mcl_heads_" .. name .. ".png",
_mcl_armor_preview = "mcl_heads_" .. name .. "_preview.png",
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

View file

@ -95,37 +95,18 @@ local function set_texture(player, index, texture)
player:set_properties({textures = textures})
end
local function set_preview(player, field, preview)
player:get_meta():set_string("mcl_player:" .. field .. "_preview", preview)
end
function mcl_player.player_set_skin(player, texture, preview)
function mcl_player.player_set_skin(player, texture)
set_texture(player, 1, texture)
set_preview(player, "skin", preview)
end
function mcl_player.player_set_armor(player, texture, preview)
function mcl_player.player_set_armor(player, texture)
set_texture(player, 2, texture)
set_preview(player, "armor", preview)
end
function mcl_player.player_set_wielditem(player, texture)
set_texture(player, 3, texture)
end
function mcl_player.player_get_preview(player)
local preview = player:get_meta():get_string("mcl_player:skin_preview")
if preview == "" then
preview = "player.png"
end
local armor_preview = player:get_meta():set_string("mcl_player:armor_preview")
if armor_preview ~= "" then
preview = preview .. "^" .. armor_preview
end
return preview
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]

4
mods/PLAYER/mcl_skins/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
!textures/mcl_skins_character_1.png
textures/mcl_skins_character_*
!meta/mcl_skins_character_1.txt
meta/mcl_skins_character_*

View file

@ -3,7 +3,7 @@
local modname = minetest.get_current_modname()
mcl_skins = {
skins = {}, list = {}, previews = {}, meta = {}, has_preview = {},
skins = {}, list = {}, meta = {},
modpath = minetest.get_modpath(modname),
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
}
@ -18,10 +18,8 @@ while true do
if id == 0 then
skin = "character"
mcl_skins.has_preview[id] = true
else
skin = "mcl_skins_character_" .. id
local preview = "mcl_skins_player_" .. id
-- Does skin file exist?
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
@ -31,20 +29,12 @@ while true do
break
end
f:close()
-- Does skin preview file exist?
local file_preview = io.open(mcl_skins.modpath .. "/textures/" .. preview .. ".png")
if file_preview == nil then
minetest.log("warning", "[mcl_skins] Player skin #"..id.." does not have preview image (player_"..id..".png)")
mcl_skins.has_preview[id] = false
else
mcl_skins.has_preview[id] = true
file_preview:close()
end
end
mcl_skins.list[id] = skin
local metafile
-- does metadata exist for that skin file ?
if id == 0 then
metafile = "mcl_skins_character.txt"
@ -89,12 +79,11 @@ function mcl_skins.set_player_skin(player, skin_id)
return false
end
local playername = player:get_player_name()
local skin, preview
local skin
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
return false
elseif skin_id == 0 then
skin = "character"
preview = "player"
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
else
skin = "mcl_skins_character_" .. tostring(skin_id)
@ -104,16 +93,9 @@ function mcl_skins.set_player_skin(player, skin_id)
else
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
end
if mcl_skins.has_preview[skin_id] then
preview = "mcl_skins_player_" .. tostring(skin_id)
else
-- Fallback preview image if preview image is missing
preview = "mcl_skins_player_dummy"
end
end
--local skin_file = skin .. ".png"
mcl_skins.skins[playername] = skin
mcl_skins.previews[playername] = preview
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
mcl_skins.update_player_skin(player)
if has_mcl_inventory then
@ -131,7 +113,7 @@ function mcl_skins.update_player_skin(player)
return
end
local playername = player:get_player_name()
mcl_player.player_set_skin(player, mcl_skins.skins[playername] .. ".png", mcl_skins.previews[playername] .. ".png")
mcl_player.player_set_skin(player, mcl_skins.skins[playername] .. ".png")
end
-- load player skin on join
@ -259,7 +241,11 @@ function mcl_skins.show_formspec(playername)
formspec = formspec .. ";" .. selected .. ";false]"
formspec = formspec .. "image[0,0;1.35,2.7;" .. mcl_skins.previews[playername] .. ".png]"
local player = minetest.get_player_by_name(playername)
if player then
--maybe the function could accept both player object and player name?
formspec = formspec .. mcl_player.get_player_formspec_model(player, 0, 0, 1.35, 2.7, "mcl_skins:skin_select")
end
if meta then
if meta.name and meta.name ~= "" then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

View file

@ -97,9 +97,6 @@ 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
# The maximum number of boss bars to simultaniously display on the screen
max_bossbars (Maximum Boss bars) int 5