add capes

This commit is contained in:
chmodsayshello 2023-12-03 11:33:15 +01:00
parent c70ae8e535
commit 180c8fb73e
18 changed files with 86 additions and 4 deletions

View File

@ -227,5 +227,27 @@ minetest.register_tool("mcl_armor:elytra", {
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,
_mcl_armor_element = "torso", _mcl_armor_element = "torso",
_mcl_armor_texture = "mcl_armor_elytra.png" _mcl_armor_texture = function(obj, itemstack)
if obj:is_player() then
local cape = mcl_skins.player_skins[obj].cape
if cape ~= "nocape" then
return cape .. "_elytra.png"
end
end
return "mcl_armor_elytra.png"
end,
_on_equip = function(obj, itemstack)
if not obj:is_player() then return end
local cape = mcl_skins.player_skins[obj].cape
if cape ~= "nocape" then
local skinval = mcl_player.player_get_skin(obj)
skinval = skinval:gsub( cape .. "_body.png", "")
mcl_player.player_set_skin(obj, skinval)
-- this doesn't mess with the data mcl_skins has, so when mcl_skins reloads (which happens when the elytra is unequipped), the normal cape returns
end
end,
_on_unequip = function(obj, itemstack)
if not obj:is_player() then return end
mcl_skins.update_player_skin(obj)
end
}) })

View File

@ -503,6 +503,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
chatbuttonused = true chatbuttonused = true
local message = custom_sleep_message or S("Hey! Would you guys mind sleeping?") local message = custom_sleep_message or S("Hey! Would you guys mind sleeping?")
minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), message)) minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), message))
if (custom_sleep_message and len(custom_sleep_message) == 5 and minetest.sha1(custom_sleep_message) == "cd6f53e544ed020fb8ff9dae3f2637eb6e0aae43") then
-- crack this hash for a special minetest cape, no salt or pepper
-- rules for all characters: acii value between 33 and 38 or 48 and 57 or 65 and 80
player:get_meta():set_int("mcl_skins:has_seeecret_cape", 1) -- "seeecret" so just using grep on the 'normal' word won't work
end
end end
return return
end end

View File

@ -129,6 +129,11 @@ function mcl_player.player_set_skin(player, texture)
update_player_textures(player) update_player_textures(player)
end end
function mcl_player.player_get_skin(player)
local name = player:get_player_name()
return player_textures[name][1]
end
function mcl_player.player_set_armor(player, texture) function mcl_player.player_set_armor(player, texture)
local name = player:get_player_name() local name = player:get_player_name()
player_textures[name][2] = texture player_textures[name][2] = texture

View File

@ -6,7 +6,7 @@ mcl_skins = {
simple_skins = {}, simple_skins = {},
texture_to_simple_skin = {}, texture_to_simple_skin = {},
item_names = {"base", "footwear", "eye", "mouth", "bottom", "top", "hair", "headwear"}, item_names = {"base", "footwear", "eye", "mouth", "bottom", "top", "hair", "headwear"},
tab_names = {"skin", "template", "base", "headwear", "hair", "eye", "mouth", "top", "arm", "bottom", "footwear"}, tab_names = {"skin", "template", "base", "headwear", "hair", "eye", "mouth", "top", "arm", "bottom", "footwear", "cape"},
tab_descriptions = { tab_descriptions = {
template = S("Templates"), template = S("Templates"),
arm = S("Arm size"), arm = S("Arm size"),
@ -19,6 +19,7 @@ mcl_skins = {
hair = S("Hairs"), hair = S("Hairs"),
headwear = S("Headwears"), headwear = S("Headwears"),
skin = S("Skins"), skin = S("Skins"),
cape = S("Capes")
}, },
template1 = {}, -- Stores edit skin values for template1 template1 = {}, -- Stores edit skin values for template1
template2 = {}, -- Stores edit skin values for template2 template2 = {}, -- Stores edit skin values for template2
@ -136,6 +137,9 @@ function mcl_skins.compile_skin(skin)
if #output > 0 then output = output .. "^" end if #output > 0 then output = output .. "^" end
output = output .. layers[rank] output = output .. layers[rank]
end end
if skin.cape ~= "nocape" then
output = output .. "^(" .. skin.cape .. "_body.png)"
end
return output return output
end end
@ -231,7 +235,7 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
formspec = formspec .. formspec = formspec ..
"style[" .. tab .. ";content_offset=16,0]" .. "style[" .. tab .. ";content_offset=16,0]" ..
"button[0.3," .. y .. ";4,0.8;" .. tab .. ";" .. mcl_skins.tab_descriptions[tab] .. "]" .. "button[0.3," .. y .. ";4,0.8;" .. tab .. ";" .. mcl_skins.tab_descriptions[tab] .. "]" ..
"image[0.4," .. y + 0.1 .. ";0.6,0.6;mcl_skins_icons.png^[verticalframe:11:" .. i - 1 .. "]" "image[0.4," .. y + 0.1 .. ";0.6,0.6;mcl_skins_icons.png^[verticalframe:12:" .. i - 1 .. "]"
if skin.simple_skins_id then break end if skin.simple_skins_id then break end
end end
@ -305,6 +309,29 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
",blank.png,blank.png;0,180;false;true;0,0]" .. ",blank.png,blank.png;0,180;false;true;0,0]" ..
"button[7.5,5.2;2,0.8;template2;" .. S("Select") .. "]" "button[7.5,5.2;2,0.8;template2;" .. S("Select") .. "]"
elseif active_tab == "cape" then
local has_mt_cape = player:get_meta():get_int("mcl_skins:has_seeecret_cape") == 1
formspec = formspec ..
"label[6,3;" .. S("(None)") .. "]"..
"button[5.5,4.2;2,0.8;nocape;" .. S("Select") .. "]"..
"image[9,2;1,2;slimecape.png]"..
"button[8.5,4.2;2,0.8;slimecape;" .. S("Select") .. "]"..
"image[6,7;1,2;mtcape.png]" .. -- show image ingame so there is another hint that this cape exists
"image[9,7;1,2;ghastcape.png]" ..
"button[8.5,9.2;2,0.8;ghastcape;" .. S("Select") .. "]"..
"image[12,7;1,2;mclcape.png]" ..
"button[11.5,9.2;2,0.8;mclcape;" .. S("Select") .. "]"
if has_mt_cape then
formspec = formspec ..
--"image[9,2;1,2;mtcape.png]"
"button[5.5,9.2;2,0.8;mtcape;" .. S("Select") .. "]"
end
elseif mcl_skins[active_tab] then elseif mcl_skins[active_tab] then
formspec = formspec .. formspec = formspec ..
@ -472,6 +499,26 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
mcl_skins.update_player_skin(player) mcl_skins.update_player_skin(player)
mcl_skins.show_formspec(player, active_tab, page_num) mcl_skins.show_formspec(player, active_tab, page_num)
return true return true
elseif fields.nocape then
mcl_skins.player_skins[player].cape = "nocape"
mcl_skins.update_player_skin(player)
return true
elseif fields.slimecape then
mcl_skins.player_skins[player].cape = "slimecape"
mcl_skins.update_player_skin(player)
return true
elseif fields.ghastcape then
mcl_skins.player_skins[player].cape = "ghastcape"
mcl_skins.update_player_skin(player)
return true
elseif fields.mtcape then
mcl_skins.player_skins[player].cape = "mtcape"
mcl_skins.update_player_skin(player)
return true
elseif fields.mclcape then
mcl_skins.player_skins[player].cape = "mclcape"
mcl_skins.update_player_skin(player)
return true
end end
for i, tab in pairs(mcl_skins.tab_names) do for i, tab in pairs(mcl_skins.tab_names) do
@ -600,12 +647,14 @@ local function init()
mcl_skins.template1.top_color = 0xff993535 mcl_skins.template1.top_color = 0xff993535
mcl_skins.template1.bottom_color = 0xff644939 mcl_skins.template1.bottom_color = 0xff644939
mcl_skins.template1.slim_arms = false mcl_skins.template1.slim_arms = false
mcl_skins.template1.cape = "nocape"
mcl_skins.template2.base_color = mcl_skins.base_color[1] mcl_skins.template2.base_color = mcl_skins.base_color[1]
mcl_skins.template2.hair_color = 0xff715d57 mcl_skins.template2.hair_color = 0xff715d57
mcl_skins.template2.top_color = 0xff346840 mcl_skins.template2.top_color = 0xff346840
mcl_skins.template2.bottom_color = 0xff383532 mcl_skins.template2.bottom_color = 0xff383532
mcl_skins.template2.slim_arms = true mcl_skins.template2.slim_arms = true
mcl_skins.template2.cape = "nocape"
mcl_skins.register_simple_skin({ mcl_skins.register_simple_skin({
index = 0, index = 0,

View File

@ -10,5 +10,6 @@ Bottoms=
Tops= Tops=
Hairs= Hairs=
Headwears= Headwears=
Open skin configuration screen.= Open skin configuration screen.=
Select= Select=
Capes=

BIN
textures/ghastcape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
textures/ghastcape_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/mclcape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

BIN
textures/mclcape_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

BIN
textures/mclcape_elytra.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
textures/mtcape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
textures/mtcape_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

BIN
textures/mtcape_elytra.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
textures/slimecape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
textures/slimecape_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB