From 3fa4cf6d524cd189f4e66661414d6df3c89e304d Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 25 Jan 2024 11:56:54 +0100 Subject: [PATCH] Cauldron leather armor washing --- mods/ITEMS/mcl_armor/api.lua | 11 ++++++----- mods/ITEMS/mcl_armor/leather.lua | 13 ++++++++----- mods/ITEMS/mcl_cauldrons/init.lua | 8 ++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/mcl_armor/api.lua b/mods/ITEMS/mcl_armor/api.lua index 1e88643f1..750bd66c8 100755 --- a/mods/ITEMS/mcl_armor/api.lua +++ b/mods/ITEMS/mcl_armor/api.lua @@ -103,10 +103,10 @@ local function get_armor_texture(textures, name, modname, itemname, itemstring) end if overlay == "" then return core_armor_texture end -- key not present; armor not trimmed - + return core_armor_texture .. overlay end - + return func end @@ -129,6 +129,7 @@ function mcl_armor.register_set(def) local groups = table.copy(groups) groups["armor_" .. name] = 1 groups["combat_armor_" .. name] = 1 + groups["armor_" .. def.name] = 1 groups.armor = 1 groups.combat_armor = 1 groups.mcl_armor_points = def.points[name] @@ -326,12 +327,12 @@ end tt.register_snippet(function(itemstring, toolcaps, stack) if not stack then return nil end local meta = stack:get_meta() - if not mcl_armor.is_trimmed(stack) then return nil end + 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("%((.-)%_") + local trim_name = full_overlay:match("%((.-)%_") return "Upgrade:\n " .. trim_name:gsub("^%l", string.upper) .. " Armor Trim" end) @@ -339,4 +340,4 @@ 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 \ No newline at end of file +end diff --git a/mods/ITEMS/mcl_armor/leather.lua b/mods/ITEMS/mcl_armor/leather.lua index 9466de77d..8c0b45689 100644 --- a/mods/ITEMS/mcl_armor/leather.lua +++ b/mods/ITEMS/mcl_armor/leather.lua @@ -53,10 +53,10 @@ local function get_texture_function(texture) end if mcl_enchanting.is_enchanted(itemstack:get_name()) then - minetest.chat_send_all(out..mcl_enchanting.overlay) +-- minetest.chat_send_all(out..mcl_enchanting.overlay) -- TODO remove return out..mcl_enchanting.overlay else - minetest.chat_send_all(out) +-- minetest.chat_send_all(out) -- TODO remove return out end end @@ -64,6 +64,9 @@ local function get_texture_function(texture) end function mcl_armor.colorize_leather_armor(itemstack, colorstring) + if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then + return + end local color = color_string_to_table(colorstring) local meta = itemstack:get_meta() local old_color = meta:get_string("mcl_armor:color") @@ -83,7 +86,7 @@ function mcl_armor.colorize_leather_armor(itemstack, colorstring) end function mcl_armor.wash_leather_armor(itemstack) - if not itemstack or not itemstack:get_definition().groups.armor_leather == 1 then + if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then return end local meta = itemstack:get_meta() @@ -119,7 +122,7 @@ mcl_armor.register_set({ }) tt.register_priority_snippet(function(_, _, itemstack) - if not itemstack or not itemstack:get_definition().groups.armor_leather == 1 then + if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then return end local color = itemstack:get_meta():get_string("mcl_armor:color") @@ -137,7 +140,7 @@ minetest.register_chatcommand("color_leather", { local player = minetest.get_player_by_name(name) if player then local item = player:get_wielded_item() - if not item or not item:get_definition().groups.armor_leather == 1 then + if not item or minetest.get_item_group(item:get_name(), "armor_leather") == 0 then return false, "Not leather armor." end if param == "wash" then diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 0ba678583..89f173399 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -94,6 +94,14 @@ local function register_filled_cauldron(water_level, description, liquid) drop = "mcl_cauldrons:cauldron", _mcl_hardness = 2, _mcl_blast_resistance = 2, + on_rightclick = function(pos, node, player, itemstack) + local outcome = mcl_armor.wash_leather_armor(itemstack) + if outcome then + minetest.sound_play("mcl_potions_bottle_pour", + {pos=pos, gain=0.5, max_hear_range=16},true) + end + return outcome + end, }) -- Add entry aliases for the Help