1
0
Fork 0

Compare commits

...

33 Commits

Author SHA1 Message Date
AFCMS 1504d64647
Merge branch 'master' into dyable-leather-armor 2022-05-02 09:56:11 +02:00
AFCMS 132529d8f4
theorically support enchantments 2022-05-01 01:53:51 +02:00
AFCMS a3d2761215
better colored leather textures + optipng -o7 -zm1-9 -nc -strip all -clobber 2022-05-01 01:49:23 +02:00
AFCMS 0e42e58901
Get rid of the 2d preview 2022-05-01 01:36:47 +02:00
AFCMS f6f0690253
remove 2d inventory preview 2022-05-01 01:13:30 +02:00
AFCMS a7484b1389
working coloring 2022-05-01 01:09:21 +02:00
AFCMS 56d14619cd
stuff 2022-05-01 00:58:43 +02:00
AFCMS 459f142fc5
add basic tooltip to colored armor 2022-05-01 00:52:25 +02:00
AFCMS d9fef2966f
oops 2022-05-01 00:37:27 +02:00
AFCMS 126d74b428
fix mcl_armor inventory images 2022-05-01 00:37:22 +02:00
AFCMS b4611dc20f
some fixes 2022-05-01 00:27:37 +02:00
AFCMS 95e165b50b
Merge branch 'master' into dyable-leather-armor 2022-05-01 00:16:23 +02:00
AFCMS 45ca8dfbfb Merge branch 'master' into dyable-leather-armor 2021-05-27 09:09:52 +02:00
AFCMS 39481d8b10 Merge branch 'master' into dyable-leather-armor 2021-05-19 00:19:58 +02:00
AFCMS 422d48f658 Merge branch 'master' into dyable-leather-armor 2021-05-10 09:39:20 +02:00
AFCMS c1eefab8d6 Merge branch 'master' into dyable-leather-armor 2021-05-04 10:30:10 +02:00
AFCMS e573dd25e1 Merge branch 'master' into dyable-leather-armor 2021-05-03 23:26:05 +02:00
AFCMS 98226d677c not working implementation of colored leather armors 2021-04-29 16:47:18 +02:00
AFCMS 547291c333 restart form scratch 2021-04-29 16:24:34 +02:00
AFCMS 5637b649e8 fix merge 2021-04-29 16:23:24 +02:00
AFCMS 16b4a6e5c2 Merge branch 'master' into dyable-leather-armor 2021-04-29 16:22:32 +02:00
AFCMS fb0a687bdc Merge branch 'master' into dyable-leather-armor 2021-04-16 13:45:05 +02:00
AFCMS 2aa7218126 Merge branch 'master' into dyable-leather-armor 2021-04-13 12:12:00 +02:00
AFCMS e0aa16cf06 Merge branch 'master' into dyable-leather-armor 2021-03-31 20:33:28 +02:00
AFCMS 69629d4ca3 Merge branch 'master' into dyable-leather-armor 2021-03-31 16:15:44 +02:00
AFCMS e7166430d7 Merge branch 'master' into dyable-leather-armor 2021-03-30 22:28:25 +02:00
AFCMS 31027aca2e Avoid unnecessary registration 2021-03-29 21:39:04 +02:00
AFCMS 9990db92b4 Revert "Revert "Update leather.lua""
This reverts commit c1ea059a14.
2021-03-29 21:35:15 +02:00
AFCMS c1ea059a14 Revert "Update leather.lua"
This reverts commit a01813e421.
2021-03-29 21:33:46 +02:00
AFCMS a01813e421 Update leather.lua 2021-03-29 21:33:27 +02:00
AFCMS d7ae8c62db Merge branch 'master' into dyable-leather-armor 2021-03-29 18:50:52 +02:00
AFCMS 2d585c9517 basic dyable armors 2021-03-29 18:39:23 +02:00
AFCMS 896b213f17 optimisation 2021-03-27 08:02:50 +01:00
52 changed files with 148 additions and 107 deletions

View File

@ -340,12 +340,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
inv_bg = "crafting_inventory_creative_survival.png" inv_bg = "crafting_inventory_creative_survival.png"
-- Show armor and player image -- Show armor and player image
local player_preview local player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")
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) -- Background images for armor slots (hide if occupied)
local armor_slot_imgs = "" local armor_slot_imgs = ""
@ -368,7 +363,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
end end
local stack_size = get_stack_size(player) local stack_size = get_stack_size(player)
-- Survival inventory slots -- Survival inventory slots
main_list = "list[current_player;main;0,3.75;9,3;9]".. main_list = "list[current_player;main;0,3.75;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,3.75,9,3).. mcl_formspec.get_itemslot_bg(0,3.75,9,3)..

View File

@ -61,12 +61,7 @@ local function set_inventory(player, armor_change_only)
inv:set_size("craft", 4) inv:set_size("craft", 4)
-- Show armor and player image -- Show armor and player image
local player_preview local player_preview = mcl_player.get_player_formspec_model(player, 1.0, 0.0, 2.25, 4.5, "")
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_slots = {"helmet", "chestplate", "leggings", "boots"}
local armor_slot_imgs = "" local armor_slot_imgs = ""

View File

@ -48,7 +48,7 @@ mcl_armor.register_set({
enchantability = 15, enchantability = 15,
--this define how much each piece of armor protect the player --this define how much each piece of armor protect the player
--these points will be shown in the HUD (chestplate bar above the health bar) --these points will be shown in the HUD (chestplate bar above the health bar)
points = { points = {
head = 1, head = 1,
torso = 3, torso = 3,
@ -87,23 +87,15 @@ mcl_armor.register_set({
end, end,
}, },
--WARNING: 2d preview is deprecated and will be removed soon --specify textures that will be shown in player inventory
--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 except you can't use functions
--its similar to how works the textures field inventory = {
previews = { head = "inv_dummy_texture.png", --default: "<modname>_inv_helmet_<material>.png"
head = "dummy_texture.png", --default: "<modname>_helmet_<material>_preview.png" torso = "inv_dummy_texture.png", --default: "<modname>_inv_chestplate_<material>.png"
torso = "dummy_texture.png", --default: "<modname>_chestplate_<material>_preview.png" legs = "inv_dummy_texture.png", --default: "<modname>_inv_leggings_<material>.png"
legs = "dummy_texture.png", --default: "<modname>_leggings_<material>_preview.png" feet = "inv_dummy_texture.png", --default: "<modname>_inv_boots_<material>.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
--torso: "<modname>_inv_chestplate_<material>.png
--legs: "<modname>_inv_leggings_<material>.png
--feet: "<modname>_inv_boots_<material>.png
--this callback table allow you to define functions that will be called each time an entity equip an armor piece or the mcl_armor.on_equip() function is called --this callback table allow you to define functions that will be called each time an entity equip an armor piece or the mcl_armor.on_equip() function is called
--the functions accept two arguments: obj and itemstack --the functions accept two arguments: obj and itemstack
on_equip_callbacks = { on_equip_callbacks = {
@ -134,12 +126,12 @@ mcl_armor.register_set({
craft_material = "mcl_mobitems:leather", craft_material = "mcl_mobitems:leather",
--this is used to generate cooking crafts for each piece of armor --this is used to generate cooking crafts for each piece of armor
--if set to nil no craft will be added --if set to nil no craft will be added
cook_material = "mcl_core:gold_nugget", --cooking any piece of this armor will output a gold nugged cook_material = "mcl_core:gold_nugget", --cooking any piece of this armor will output a gold nugged
--this is used for allowing each piece of the armor to be repaired by using an anvil with repair_material as aditionnal material --this is used for allowing each piece of the armor to be repaired by using an anvil with repair_material as aditionnal material
--it basicaly set the _repair_material item field of each piece of the armor --it basicaly set the _repair_material item field of each piece of the armor
--if set to nil no repair material will be added --if set to nil no repair material will be added
repair_material = "mcl_core:iron_ingot", repair_material = "mcl_core:iron_ingot",
}) })
``` ```
@ -179,7 +171,7 @@ minetest.register_tool("dummy_mod:random_armor", {
}, },
--these fields should be initialised like that in most cases --these fields should be initialised like that in most cases
--mcl_armor.equip_on_use is a function that try to equip the piece of armor you have in hand inside the right armor slot if the slot is empty --mcl_armor.equip_on_use is a function that try to equip the piece of armor you have in hand inside the right armor slot if the slot is empty
on_place = mcl_armor.equip_on_use, on_place = mcl_armor.equip_on_use,
on_secondary_use = mcl_armor.equip_on_use, on_secondary_use = mcl_armor.equip_on_use,
@ -263,7 +255,7 @@ mcl_armor.register_protection_enchantment({
max_level = 4, max_level = 4,
--which enchants this enchant will not be compatible with --which enchants this enchant will not be compatible with
--each of these values is a enchant id --each of these values is a enchant id
incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true},
--how much will the enchant consume from the enchantability group of the armor item --how much will the enchant consume from the enchantability group of the armor item
@ -284,7 +276,7 @@ mcl_armor.register_protection_enchantment({
factor = 1, factor = 1,
--restrict damage to one type --restrict damage to one type
--allow the enchant to only protect of one type of damage --allow the enchant to only protect of one type of damage
damage_type = "magic", damage_type = "magic",
--restrict damage to one category --restrict damage to one category

View File

@ -94,7 +94,7 @@ function mcl_armor.register_set(def)
local on_unequip_callbacks = def.on_unequip_callbacks or {} local on_unequip_callbacks = def.on_unequip_callbacks or {}
local on_break_callbacks = def.on_break_callbacks or {} local on_break_callbacks = def.on_break_callbacks or {}
local textures = def.textures or {} local textures = def.textures or {}
local previews = def.previews or {} local inventory = def.inventory or {}
local durabilities = def.durabilities or {} local durabilities = def.durabilities or {}
local element_groups = def.element_groups or {} local element_groups = def.element_groups or {}
@ -120,7 +120,7 @@ function mcl_armor.register_set(def)
description = S(def.description .. " " .. (descriptions[name] or element.description)), description = S(def.description .. " " .. (descriptions[name] or element.description)),
_doc_items_longdesc = mcl_armor.longdesc, _doc_items_longdesc = mcl_armor.longdesc,
_doc_items_usagehelp = mcl_armor.usage, _doc_items_usagehelp = mcl_armor.usage,
inventory_image = modname .. "_inv_" .. itemname .. ".png", inventory_image = inventory[name] or modname .. "_inv_" .. itemname .. ".png",
_repair_material = def.repair_material or def.craft_material, _repair_material = def.repair_material or def.craft_material,
groups = groups, groups = groups,
sounds = { sounds = {
@ -134,7 +134,6 @@ function mcl_armor.register_set(def)
_on_break = on_break_callbacks[name] or def.on_break, _on_break = on_break_callbacks[name] or def.on_break,
_mcl_armor_element = name, _mcl_armor_element = name,
_mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png", _mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png",
_mcl_armor_preview = previews[name] or modname .. "_" .. itemname .. "_preview.png",
}) })
if def.craft_material then if def.craft_material then
@ -221,17 +220,6 @@ function mcl_armor.update(obj)
end end
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") info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
local mob_range_mob = def._mcl_armor_mob_range_mob local mob_range_mob = def._mcl_armor_mob_range_mob
@ -254,8 +242,6 @@ function mcl_armor.update(obj)
info.texture = info.texture or "blank.png" info.texture = info.texture or "blank.png"
if obj:is_player() then if obj:is_player() then
info.preview = info.preview or "blank.png"
mcl_armor.update_player(obj, info) mcl_armor.update_player(obj, info)
else else
local luaentity = obj:get_luaentity() local luaentity = obj:get_luaentity()

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator("mcl_armor")
local modpath = minetest.get_modpath("mcl_armor")
mcl_armor = { mcl_armor = {
longdesc = S("This is a piece of equippable armor which reduces the amount of damage you receive."), longdesc = S("This is a piece of equippable armor which reduces the amount of damage you receive."),
@ -59,10 +60,9 @@ mcl_armor = {
player_view_range_factors = {}, player_view_range_factors = {},
} }
local modpath = minetest.get_modpath("mcl_armor")
dofile(modpath .. "/api.lua") dofile(modpath .. "/api.lua")
dofile(modpath .. "/player.lua") dofile(modpath .. "/player.lua")
dofile(modpath .. "/damage.lua") dofile(modpath .. "/damage.lua")
dofile(modpath .. "/register.lua") dofile(modpath .. "/register.lua")
dofile(modpath .. "/alias.lua") dofile(modpath .. "/alias.lua")
dofile(modpath .."/leather.lua")

View File

@ -0,0 +1,113 @@
local S = minetest.get_translator(minetest.get_current_modname())
local colors = {
-- { ID, decription, wool, dye }
{ "red", "Red", "mcl_dye:red", "#951d1d" },
{ "blue", "Blue", "mcl_dye:blue", "#2a2c94" },
{ "cyan", "Cyan", "mcl_dye:cyan", "#0d7d8e" },
{ "grey", "Grey", "mcl_dye:dark_grey", "#363a3f" },
{ "silver", "Light Grey", "mcl_dye:grey", "#818177" },
{ "black", "Black", "mcl_dye:black", "#020307" },
{ "yellow", "Yellow", "mcl_dye:yellow", "#f2b410" },
{ "green", "Green", "mcl_dye:dark_green", "#495d20" },
{ "magenta", "Magenta", "mcl_dye:magenta", "#ae2ea4" },
{ "orange", "Orange", "mcl_dye:orange", "#e36501" },
{ "purple", "Purple", "mcl_dye:violet", "#681ba1" },
{ "brown", "Brown", "mcl_dye:brown", "#623b1a" },
{ "pink", "Pink", "mcl_dye:pink", "#d66691" },
{ "lime", "Lime", "mcl_dye:green", "#60ad13" },
{ "light_blue", "Light Blue", "mcl_dye:lightblue", "#1f8eca" },
{ "white", "White", "mcl_dye:white", "#d1d7d8" },
}
--local function get_color_rgb(color)
-- return tonumber(str.sub(first, 2, 3)), tonumber(str.sub(first, 4, 5)), tonumber(str.sub(first, 6, 7))
--end
local function calculate_color(first, last)
--local first_r = tonumber(str.sub(first, 2, 3))
--local first_g = tonumber(str.sub(first, 4, 5))
return tonumber(first)*tonumber(last)
end
local function get_texture_function(texture)
local function get_texture(_, itemstack)
local out
local color = itemstack:get_meta():get_string("color")
if color == "" or color == nil then
out = texture
else
out = texture.."^[multiply:"..color
end
if mcl_enchanting.is_enchanted(itemstack) then
return out.."^"..mcl_enchanting.overlay
else
return out
end
end
return get_texture
end
mcl_armor.register_set({
name = "leather_colored",
description = "Colored Leather",
descriptions = {
head = "Cap",
torso = "Tunic",
legs = "Pants",
},
durability = 80,
enchantability = 15,
points = {
head = 1,
torso = 3,
legs = 2,
feet = 1,
},
textures = {
head = get_texture_function("mcl_armor_helmet_colored_leather.png"),
torso = get_texture_function("mcl_armor_chestplate_colored_leather.png"),
legs = get_texture_function("mcl_armor_leggings_colored_leather.png"),
feet = get_texture_function("mcl_armor_boots_colored_leather.png"),
},
inventory = {
head = "mcl_armor_inv_helmet_colored_leather.png",
torso = "mcl_armor_inv_chestplate_colored_leather.png",
legs = "mcl_armor_inv_leggings_colored_leather.png",
feet = "mcl_armor_inv_boots_colored_leather.png",
},
repair_material = "mcl_mobitems:leather",
groups = {armor_leather_colored = 1},
})
tt.register_priority_snippet(function(_, _, itemstack)
if not itemstack or not itemstack:get_definition().groups.armor_leather_colored == 1 then
return
end
local color = itemstack:get_meta():get_string("color")
if color and color ~= "" then
local text = "Color: "..color
return text, false
end
end)
-- This command is only temporary
minetest.register_chatcommand("color_leather", {
params = "<color>",
description = "Colorize a leather armor",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if player then
local item = player:get_wielded_item()
item:get_meta():set_string("color", param)
tt.reload_itemstack_description(item)
player:set_wielded_item(item)
return true, "Done."
else
return false, "Player isn't online"
end
end,
})

View File

@ -1,5 +1,5 @@
name = mcl_armor name = mcl_armor
author = stu author = stu
description = Adds craftable armor that is visible to other players. description = Adds craftable armor that is visible to other players.
depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage, tt
optional_depends = mcl_fire, ethereal, bakedclay optional_depends = mcl_fire, ethereal, bakedclay

View File

@ -63,7 +63,7 @@ mcl_player.player_register_model("mcl_armor_character_female.b3d", {
}) })
function mcl_armor.update_player(player, info) 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() local meta = player:get_meta()
meta:set_int("mcl_armor:armor_points", info.points) 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: 133 B

After

Width:  |  Height:  |  Size: 140 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.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 310 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: 227 B

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 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.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 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

@ -280,9 +280,6 @@ function mcl_enchanting.initialize()
if new_def._mcl_armor_texture and not type(new_def._mcl_armor_texture) == "function" then 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 new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay
end 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
end
new_def._mcl_enchanting_enchanted_tool = new_name new_def._mcl_enchanting_enchanted_tool = new_name
new_def.after_use = get_after_use_callback(itemdef) new_def.after_use = get_after_use_callback(itemdef)

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_element = "head"
pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png" 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) pumpkin_face_base_def.on_construct = function(pos)
-- Attempt to spawn iron golem or snow golem -- Attempt to spawn iron golem or snow golem

View File

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

View File

@ -95,37 +95,19 @@ local function set_texture(player, index, texture)
player:set_properties({textures = textures}) player:set_properties({textures = textures})
end 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_texture(player, 1, texture)
set_preview(player, "skin", preview)
end end
function mcl_player.player_set_armor(player, texture, preview) function mcl_player.player_set_armor(player, texture)
set_texture(player, 2, texture) set_texture(player, 2, texture)
set_preview(player, "armor", preview)
end end
function mcl_player.player_set_wielditem(player, texture) function mcl_player.player_set_wielditem(player, texture)
set_texture(player, 3, texture) set_texture(player, 3, texture)
end 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) function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
local name = player:get_player_name() local name = player:get_player_name()
local model = player_model[name] local model = player_model[name]

2
mods/PLAYER/mcl_skins/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
!mcl_skins_character_1.png
textures/mcl_skins_character_*

View File

@ -3,7 +3,7 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
mcl_skins = { mcl_skins = {
skins = {}, list = {}, previews = {}, meta = {}, has_preview = {}, skins = {}, list = {}, meta = {},
modpath = minetest.get_modpath(modname), modpath = minetest.get_modpath(modname),
skin_count = 0, -- counter of _custom_ skins (all skins except character.png) skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
} }
@ -18,10 +18,8 @@ while true do
if id == 0 then if id == 0 then
skin = "character" skin = "character"
mcl_skins.has_preview[id] = true
else else
skin = "mcl_skins_character_" .. id skin = "mcl_skins_character_" .. id
local preview = "mcl_skins_player_" .. id
-- Does skin file exist? -- Does skin file exist?
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png") f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
@ -31,16 +29,6 @@ while true do
break break
end end
f:close() 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 end
mcl_skins.list[id] = skin mcl_skins.list[id] = skin
@ -89,12 +77,11 @@ function mcl_skins.set_player_skin(player, skin_id)
return false return false
end end
local playername = player:get_player_name() 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 if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
return false return false
elseif skin_id == 0 then elseif skin_id == 0 then
skin = "character" skin = "character"
preview = "player"
mcl_player.player_set_model(player, "mcl_armor_character.b3d") mcl_player.player_set_model(player, "mcl_armor_character.b3d")
else else
skin = "mcl_skins_character_" .. tostring(skin_id) skin = "mcl_skins_character_" .. tostring(skin_id)
@ -104,16 +91,9 @@ function mcl_skins.set_player_skin(player, skin_id)
else else
mcl_player.player_set_model(player, "mcl_armor_character.b3d") mcl_player.player_set_model(player, "mcl_armor_character.b3d")
end 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 end
--local skin_file = skin .. ".png" --local skin_file = skin .. ".png"
mcl_skins.skins[playername] = skin mcl_skins.skins[playername] = skin
mcl_skins.previews[playername] = preview
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id)) player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
mcl_skins.update_player_skin(player) mcl_skins.update_player_skin(player)
if has_mcl_inventory then if has_mcl_inventory then
@ -131,7 +111,7 @@ function mcl_skins.update_player_skin(player)
return return
end end
local playername = player:get_player_name() 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 end
-- load player skin on join -- load player skin on join
@ -259,7 +239,11 @@ function mcl_skins.show_formspec(playername)
formspec = formspec .. ";" .. selected .. ";false]" 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 then
if meta.name and meta.name ~= "" 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 # Whether to animate chests when open / close
animated_chests (Animated chests) bool true 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 # The maximum number of boss bars to simultaniously display on the screen
max_bossbars (Maximum Boss bars) int 5 max_bossbars (Maximum Boss bars) int 5