add trim advancements

This commit is contained in:
chmodsayshello 2023-10-21 22:25:30 +02:00
parent 712a6d6c66
commit ec7e99019e
17 changed files with 103 additions and 15 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"},
}
})

59
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
@ -181,27 +192,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: 575 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: 276 B