Merge pull request 'armor trim followup' (#3974) from trim_achievement into master

Reviewed-on: MineClone2/MineClone2#3974
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
the-real-herowl 2023-11-06 19:37:56 +00:00
commit 14f73a8c55
17 changed files with 110 additions and 19 deletions

21
mods/HUD/mcl_achievements/init.lua Normal file → Executable file
View File

@ -431,6 +431,27 @@ awards.register_achievement("mcl:wax_off", {
group = "Husbandry",
})
-- Triggered in mcl_smithing_table
awards.register_achievement("mcl:trim", {
title = S("Crafting a New Look"),
description = S("Craft a trimmed armor at a Smithing Table"),
icon = "dune_armor_trim_smithing_template.png",
type = "Advancement",
group = "Adventure",
})
awards.register_achievement("mcl:lots_of_trimming", {
title = S("Smithing with Style"),
description = S("Apply these smithing templates at least once: Spire, Snout, Rib, Ward, Silence, Vex, Tide, Wayfinder"),
icon = "silence_armor_trim_smithing_template.png",
type = "Advancement",
group = "Adventure",
on_unlock = function(name, awdef)
-- delete json that is no longer needed
minetest.get_player_by_name(name):get_meta():set_string("mcl_smithing_table:achievement_trims", "")
end,
})
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
if non_pc_achievements then

View File

@ -51,3 +51,7 @@ Bring Home the Beacon=Den Nachbarn heimleuchten
Use a beacon.=Benutzen Sie ein Leuchtfeuer.
Beaconator=Leuchtturmwärter
Use a fully powered beacon.=Benutzen Sie ein vollständiges Leuchtfeuer.
Crafting a New Look=Ein neues Aussehen
Craft a trimmed armor at a Smithing Table=Versieh ein Rüstungsteil an einem Schmiedetisch mit einem Rüstungsbesatz
Smithing with Style=Schmieden mit Stil
Apply these smithing templates at least once: Spire, Snout, Rib, Ward, Silence, Vex, Tide, Wayfinder=Wende jede dieser Schmiedevorlagen mindestens einmal an: Turmspitze, Schnauze, Rippe, Warthof, Stille, Plagegeist, Gezeiten und Wegfinder

4
mods/HUD/mcl_achievements/locale/template.txt Normal file → Executable file
View File

@ -111,3 +111,7 @@ Voluntary Exile=
Kill a raid captain. Maybe consider staying away from the local villages for the time being...=
Tactical Fishing=
Catch a fish... without a fishing rod!=
Crafting a New Look=
Craft a trimmed armor at a Smithing Table=
Smithing with Style=
Apply these smithing templates at least once: Spire, Snout, Rib, Ward, Silence, Vex, Tide, Wayfinder=

10
mods/ITEMS/mcl_armor/api.lua Normal file → Executable file
View File

@ -326,11 +326,17 @@ end
tt.register_snippet(function(itemstring, toolcaps, stack)
if not stack then return nil end
local meta = stack:get_meta()
if meta:get_string("mcl_armor:trim_overlay") == "" then return nil end -- remember, get_string returns "" if the key doesn't exist
if not mcl_armor.is_trimmed(stack) then return nil end
-- we need to get the part of the overlay image between the overlay begin ( and the trim name end _
-- we COULD easily store this info in meta, but that would bloat the meta storage, as the same few values would be stored over and over again on every trimmed item
-- this is fine here as this code gets only executed when you put armor and a trim in a smithing table
local full_overlay = meta:get_string("mcl_armor:trim_overlay")
local trim_name = full_overlay:match("%((.-)%_")
return "Upgrade:\n " .. trim_name:gsub("^%l", string.upper) .. " Armor Trim"
end)
end)
function mcl_armor.is_trimmed(itemstack)
-- this meta value will be there for every trimmed armor piece
-- remember, get_string returns "" if the key doesn't exist
return itemstack:get_meta():get_string("mcl_armor:trim_overlay") ~= ""
end

View File

@ -60,7 +60,7 @@ mcl_armor = {
trims = {
core_textures = {},
blacklisted = {["mcl_armor:elytra"]=true, ["mcl_armor:elytra_enchanted"]=true},
overlays = {"sentry","dune","coast","wild","tide","ward","vex","rib","snout","eye","spire"},
overlays = {"sentry","dune","coast","wild","tide","ward","vex","rib","snout","eye","spire","silence","wayfinder"},
colors = {["amethyst"]="#8246a5",["gold"]="#ce9627",["emerald"]="#1b9958",["copper"]="#c36447",["diamond"]="#5faed8",["iron"]="#938e88",["lapis"]="#1c306b",["netherite"]="#302a26",["quartz"]="#c9bcb9",["redstone"]="#af2c23"},
},
}

View File

@ -43,4 +43,22 @@ minetest.register_craft({
{"mcl_core:diamond","mcl_core:goldblock","mcl_core:diamond"},
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
}
})
minetest.register_craft({
output = mod_registername .. "silence",
recipe = {
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
{"mcl_core:diamond", mod_registername.."ward","mcl_core:diamond"},
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
}
})
minetest.register_craft({
output = mod_registername .. "wayfinder",
recipe = {
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
{"mcl_core:diamond", "mcl_maps:empty_map","mcl_core:diamond"},
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
}
})

70
mods/ITEMS/mcl_smithing_table/init.lua Normal file → Executable file
View File

@ -88,7 +88,18 @@ local smithing_materials = {
["mcl_copper:copper_ingot"] = "copper",
["mcl_core:emerald"] = "emerald",
["mcl_nether:quartz"] = "quartz"
}
}
local achievement_trims = {
["mcl_armor:spire"] = true,
["mcl_armor:snout"] = true,
["mcl_armor:rib"] = true,
["mcl_armor:ward"] = true,
["mcl_armor:silence"] = true,
["mcl_armor:vex"] = true,
["mcl_armor:tide"] = true,
["mcl_armor:wayfinder"] = true
}
function mcl_smithing_table.upgrade_trimmed(itemstack, color_mineral, template)
--get information required
@ -156,16 +167,19 @@ minetest.register_node("mcl_smithing_table:table", {
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local stackname = stack:get_name()
local def = stack:get_definition()
if
listname == "upgrade_item"
and string.find(stack:get_name(),"mcl_armor:") -- allow any armor piece to go in (in case the player wants to trim them)
and not mcl_armor.trims.blacklisted[stack:get_name()]
and def._mcl_armor_element -- allow any armor piece to go in (in case the player wants to trim them)
and not mcl_armor.trims.blacklisted[stackname]
or def._mcl_upgradable -- for diamond tools
or listname == "mineral"
and mcl_smithing_table.is_smithing_mineral(stack:get_name())
and mcl_smithing_table.is_smithing_mineral(stackname)
or listname == "template"
and string.find(stack:get_name(),"mcl_armor")
and string.find(stackname, "mcl_armor")
then
return stack:get_count()
end
@ -181,27 +195,51 @@ minetest.register_node("mcl_smithing_table:table", {
on_metadata_inventory_take = function(pos, listname, index, stack, player)
local inv = minetest.get_meta(pos):get_inventory()
local function take_item(listname)
local itemstack = inv:get_stack(listname, 1)
itemstack:take_item()
inv:set_stack(listname, 1, itemstack)
end
if listname == "upgraded_item" then
-- ToDo: make epic sound
minetest.sound_play("mcl_smithing_table_upgrade", { pos = pos, max_hear_distance = 16 })
if stack:get_name() == "mcl_farming:hoe_netherite" then
awards.unlock(player:get_player_name(), "mcl:seriousDedication")
elseif mcl_armor.is_trimmed(stack) then
local template_name = inv:get_stack("template", 1):get_name()
local playername = player:get_player_name()
awards.unlock(playername, "mcl:trim")
if not awards.players[playername].unlocked["mcl:lots_of_trimming"] and achievement_trims[template_name] then
local meta = player:get_meta()
local used_achievement_trims = minetest.deserialize(meta:get_string("mcl_smithing_table:achievement_trims")) or {}
if not used_achievement_trims[template_name] then
used_achievement_trims[template_name] = true
end
local used_all = true
for name, _ in pairs(achievement_trims) do
if not used_achievement_trims[name] then
used_all = false
break
end
end
if used_all then
awards.unlock(playername, "mcl:lots_of_trimming")
else
meta:set_string("mcl_smithing_table:achievement_trims", minetest.serialize(used_achievement_trims))
end
end
end
take_item("upgrade_item")
take_item("mineral")
take_item("template")
-- ToDo: make epic sound
minetest.sound_play("mcl_smithing_table_upgrade", { pos = pos, max_hear_distance = 16 })
end
if listname == "upgraded_item" then
if stack:get_name() == "mcl_farming:hoe_netherite" then
awards.unlock(player:get_player_name(), "mcl:seriousDedication")
end
end
reset_upgraded_item(pos)
end,

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
textures/silence_boots.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

BIN
textures/silence_helmet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB