From 3195df3864f65489c2e120c0a2aea9e29e750eaa Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 28 Apr 2021 17:53:40 +0000 Subject: [PATCH 1/5] remove object crosshair --- .../textures/object_crosshair.png | Bin 150 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 mods/HUD/mcl_base_textures/textures/object_crosshair.png diff --git a/mods/HUD/mcl_base_textures/textures/object_crosshair.png b/mods/HUD/mcl_base_textures/textures/object_crosshair.png deleted file mode 100644 index e5a400e951b3fc543b6e2baf007c24f0949229cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^HXzIhBp8I+pWFvhOeH~n!3+##lh0ZJdH$X*jv*C{ z$r3>gt&NVrF-;(b vWgXi(?mWIbDLY~dZa;k2xLe@ivxS@t;avh+c8nGmKo)ws`njxgN@xNA{9!K; From 32c03dc27eb835fb60fdc2e396f6c3d5e5fc010d Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 28 Apr 2021 17:55:03 +0000 Subject: [PATCH 2/5] new object overlay --- .../textures/object_crosshair.png | Bin 0 -> 144 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 mods/HUD/mcl_base_textures/textures/object_crosshair.png diff --git a/mods/HUD/mcl_base_textures/textures/object_crosshair.png b/mods/HUD/mcl_base_textures/textures/object_crosshair.png new file mode 100644 index 0000000000000000000000000000000000000000..8e94dcc6bef47196a2f5cd93226eec0e8a8c3a24 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bO2I}#X;^)4C~IxyaaOC0(?STf%O0X z|CipJe-|WO666=m;PC858jz#y>EamTas2JYjl2v7Jcl>@_`kf^@w<{*x$i7SEfvA; k^G7OwTYihYBfxAcmUfh3mZZ_ebf7i{Pgg&ebxsLQ0Dz7xGXMYp literal 0 HcmV?d00001 From ec08032b62d6377ef5d94dbba4fdcd923f09d298 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 29 Apr 2021 11:40:09 +0200 Subject: [PATCH 3/5] Add on_break callback --- mods/ITEMS/mcl_armor/api.lua | 2 ++ mods/ITEMS/mcl_armor/damage.lua | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_armor/api.lua b/mods/ITEMS/mcl_armor/api.lua index 2e5ba1112..566ce5c49 100644 --- a/mods/ITEMS/mcl_armor/api.lua +++ b/mods/ITEMS/mcl_armor/api.lua @@ -92,6 +92,7 @@ function mcl_armor.register_set(def) local groups = def.groups or {} local on_equip_callbacks = def.on_equip_callbacks or {} local on_unequip_callbacks = def.on_unequip_callbacks or {} + local on_break_callbacks = def.on_break_callbacks or {} local textures = def.textures or {} local previews = def.previews or {} local durabilities = def.durabilities or {} @@ -125,6 +126,7 @@ function mcl_armor.register_set(def) on_secondary_use = mcl_armor.equip_on_use, _on_equip = on_equip_callbacks[name] or def.on_equip, _on_unequip = on_unequip_callbacks[name] or def.on_unequip, + _on_break = on_break_callbacks[name] or def.on_break, _mcl_armor_element = name, _mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png", _mcl_armor_preview = previews[name] or modname .. "_" .. itemname .. "_preview.png", diff --git a/mods/ITEMS/mcl_armor/damage.lua b/mods/ITEMS/mcl_armor/damage.lua index 8ad566d18..f17033495 100644 --- a/mods/ITEMS/mcl_armor/damage.lua +++ b/mods/ITEMS/mcl_armor/damage.lua @@ -1,3 +1,12 @@ +local function use_durability(obj, inv, index, stack, uses) + local def = stack:get_definition() + mcl_util.use_item_durability(stack, uses) + if stack:is_empty() and def and def._on_break then + stack = def._on_break(obj) or stack + end + inv:set_stack("armor", index, stack) +end + mcl_damage.register_modifier(function(obj, damage, reason) local flags = reason.flags @@ -28,8 +37,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) points = points + minetest.get_item_group(itemname, "mcl_armor_points") toughness = toughness + minetest.get_item_group(itemname, "mcl_armor_toughness") - mcl_util.use_item_durability(itemstack, uses) - inv:set_stack("armor", element.index, itemstack) + use_durability(obj, inv, element.index, itemstack, uses) end if not flags.bypasses_magic then @@ -84,8 +92,8 @@ mcl_damage.register_modifier(function(obj, damage, reason) mcl_util.deal_damage(reason.source, thorns_damage, {type = "thorns", direct = obj}) local thorns_item = thorns_pieces[math.random(#thorns_pieces)] - mcl_util.use_item_durability(thorns_item.itemstack, 2) - inv:set_stack("armor", thorns_item.index, thorns_item.itemstack) + + use_durability(obj, inv, thorns_item.index, thorns_item.itemstack, 2) end mcl_armor.update(obj) From 87e41cc9a939e83c4c287cd6f231a8cc086819f2 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 29 Apr 2021 11:46:27 +0200 Subject: [PATCH 4/5] Add support for armor texture and preview being functions --- mods/ITEMS/mcl_armor/api.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_armor/api.lua b/mods/ITEMS/mcl_armor/api.lua index 566ce5c49..b632eeca7 100644 --- a/mods/ITEMS/mcl_armor/api.lua +++ b/mods/ITEMS/mcl_armor/api.lua @@ -205,12 +205,26 @@ function mcl_armor.update(obj) if not itemstack:is_empty() then local def = itemstack:get_definition() - if def._mcl_armor_texture then - info.texture = "(" .. def._mcl_armor_texture .. ")" .. (info.texture and "^" .. info.texture or "") + local texture = def._mcl_armor_texture + + if texture then + if type(texture) == "function" then + texture = texture(obj, itemstack) + end + if texture then + info.texture = "(" .. texture .. ")" .. (info.texture and "^" .. info.texture or "") + end end - if obj:is_player() and def._mcl_armor_preview then - info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" ) + 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") From 6550e3e8e2200099ddc61a1ffccd44013bab8565 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 29 Apr 2021 11:51:06 +0200 Subject: [PATCH 5/5] Add per-element armor groups --- mods/ITEMS/mcl_armor/api.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mods/ITEMS/mcl_armor/api.lua b/mods/ITEMS/mcl_armor/api.lua index b632eeca7..d58b5e666 100644 --- a/mods/ITEMS/mcl_armor/api.lua +++ b/mods/ITEMS/mcl_armor/api.lua @@ -96,6 +96,7 @@ function mcl_armor.register_set(def) local textures = def.textures or {} local previews = def.previews or {} local durabilities = def.durabilities or {} + local element_groups = def.element_groups or {} for name, element in pairs(mcl_armor.elements) do local itemname = element.name .. "_" .. def.name @@ -111,6 +112,10 @@ function mcl_armor.register_set(def) groups.mcl_armor_uses = (durabilities[name] or math.floor(def.durability * element.durability)) + 1 groups.enchantability = def.enchantability + for k, v in pairs(element_groups) do + groups[k] = v + end + minetest.register_tool(itemstring, { description = S(def.description .. " " .. (descriptions[name] or element.description)), _doc_items_longdesc = mcl_armor.longdesc,