From 693ace14c2c29211ba9169109498e9574ea5d0bd Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 7 Dec 2023 10:47:30 -0500 Subject: [PATCH] Add tool texture overlay when enchanted --- README.md | 2 -- api.lua | 17 +++++++++++++++++ textures/x_enchanting_glint.png | Bin 0 -> 365 bytes 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 textures/x_enchanting_glint.png diff --git a/README.md b/README.md index 62e938a..761c567 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ Adds Enchanting Mechanics and API. * mesh node model * mesh entity model and animations -NOTE: item inventory/wield image will not be adjusted until this feature is supported by MT engine, see: https://github.com/minetest/minetest/issues/5686 - ## How To ### Enchanting Setup diff --git a/api.lua b/api.lua index 7bae93f..01ce459 100644 --- a/api.lua +++ b/api.lua @@ -552,6 +552,23 @@ function XEnchanting.set_enchanted_tool(self, pos, itemstack, level, player_name stack_meta:set_int('is_enchanted', 1) stack_meta:set_string('x_enchanting', minetest.serialize(final_enchantments_meta)) + + if tool_def and tool_def.inventory_image and tool_def.inventory_image ~= '' then + stack_meta:set_string('inventory_image', tool_def.inventory_image .. '^((' .. tool_def.inventory_image .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.inventory_overlay and tool_def.inventory_overlay ~= '' then + stack_meta:set_string('inventory_overlay', tool_def.inventory_overlay .. '^((' .. tool_def.inventory_overlay .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.wield_image and tool_def.wield_image ~= '' then + stack_meta:set_string('wield_image', tool_def.wield_image .. '^((' .. tool_def.wield_image .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.wield_overlay and tool_def.wield_overlay ~= '' then + stack_meta:set_string('wield_overlay', tool_def.wield_overlay .. '^((' .. tool_def.wield_overlay .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + inv:set_stack('item', 1, itemstack) local trade_stack = inv:get_stack('trade', 1) diff --git a/textures/x_enchanting_glint.png b/textures/x_enchanting_glint.png new file mode 100644 index 0000000000000000000000000000000000000000..205f5b62e309d116d97c0bfd0652783cd1fb3637 GIT binary patch literal 365 zcmV-z0h0cSP)8 z`^b+pG|)Ix@42X;H$R%0)nZ6P$GcmI#ZcC-JCDw9jra%E1yR4s7|4Ex zc9JY87ar|I7vczRQE9s1xTCu(%zQM_8%}5*%DZB$Pn>~3ck~+_%?0#Mqkb0>)X4)y z`?`6Ea$$#~>EqAe_tj2x7E7G5%>_rR*I3taT_~ZfXIO5ro?(NgRfR5~nF$czhzIGZ zlN(LNt|%foTi?lXvrD@)ry5kHN!RdkR_s=o+`BaJ>`wA*s6oj< zq1i31Ubilgo6yhtup$YXLTjcry0tbI>wk;+q9hKJBhRaIOY{2=D~@ud3Cj=r00000 LNkvXXu0mjf$k3<1 literal 0 HcmV?d00001