1
0
Fork 0

fix for enchanted items

hollow_logs_ref_recovery
chmodsayshello 2023-08-31 17:59:46 +02:00
parent 7c43c15fda
commit 6c107ce990
4 changed files with 16 additions and 8 deletions

View File

@ -91,7 +91,13 @@ local function get_armor_texture(textures, name, modname, itemname, itemstring)
mcl_armor.trims.core_textures[itemstring] = core_texture mcl_armor.trims.core_textures[itemstring] = core_texture
local func = function(obj, itemstack) local func = function(obj, itemstack)
local overlay = itemstack:get_meta():get_string("mcl_armor:trim_overlay") local overlay = itemstack:get_meta():get_string("mcl_armor:trim_overlay")
local core_armor_texture = mcl_armor.trims.core_textures[itemstack:get_name()] local core_armor_texture
local stack_name = mcl_grindstone.remove_enchant_name(itemstack) -- gets original itemstring if enchanted, no need to store (nearly) identical values
local core_armor_texture = mcl_armor.trims.core_textures[stack_name]
if mcl_enchanting.is_enchanted(itemstack:get_name()) then -- working with the original stack to know wether to apply enchanting overlay or not
core_armor_texture = core_armor_texture .. mcl_enchanting.overlay
end
if overlay == "" then return core_armor_texture end -- key not present; armor not trimmed if overlay == "" then return core_armor_texture end -- key not present; armor not trimmed

View File

@ -1,5 +1,5 @@
name = mcl_armor name = mcl_armor
author = stu author = stu
description = Adds craftable armor that is visible to other players. description = Adds craftable armor that is visible to other players.
depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage, mcl_grindstone
optional_depends = mcl_fire, ethereal, bakedclay optional_depends = mcl_fire, ethereal, bakedclay

View File

@ -1,5 +1,5 @@
local mod_registername = minetest.get_current_modname() .. ":" local mod_registername = minetest.get_current_modname() .. ":"
local S = minetest.get_translator(modname) local S = minetest.get_translator(minetest.get_current_modname())
for _, template_name in pairs(mcl_armor.trims.overlays) do for _, template_name in pairs(mcl_armor.trims.overlays) do
minetest.register_craftitem(mod_registername .. template_name, { minetest.register_craftitem(mod_registername .. template_name, {

View File

@ -1,5 +1,7 @@
-- Code based from mcl_anvils -- Code based from mcl_anvils
mcl_grindstone = {}
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape local F = minetest.formspec_escape
local C = minetest.colorize local C = minetest.colorize
@ -55,7 +57,7 @@ local function create_new_item(name_item, meta, wear)
end end
-- If an item has an enchanment then remove "_enchanted" from the name -- If an item has an enchanment then remove "_enchanted" from the name
local function remove_enchant_name(stack) function mcl_grindstone.remove_enchant_name(stack)
if mcl_enchanting.is_enchanted(stack:get_name()) then if mcl_enchanting.is_enchanted(stack:get_name()) then
local name = stack:get_name() local name = stack:get_name()
return name.sub(name, 1, -11) return name.sub(name, 1, -11)
@ -116,8 +118,8 @@ local function update_grindstone_slots(meta)
local def1 = input1:get_definition() local def1 = input1:get_definition()
local def2 = input2:get_definition() local def2 = input2:get_definition()
-- Remove enchant name if they have one -- Remove enchant name if they have one
local name1 = remove_enchant_name(input1) local name1 = mcl_grindstone.remove_enchant_name(input1)
local name2 = remove_enchant_name(input2) local name2 = mcl_grindstone.remove_enchant_name(input2)
-- Calculate repair -- Calculate repair
local function calculate_repair(dur1, dur2) local function calculate_repair(dur1, dur2)
@ -143,7 +145,7 @@ local function update_grindstone_slots(meta)
local def1 = input1:get_definition() local def1 = input1:get_definition()
local meta = input1:get_meta() local meta = input1:get_meta()
if def1.type == "tool" and mcl_enchanting.is_enchanted(input1:get_name()) then if def1.type == "tool" and mcl_enchanting.is_enchanted(input1:get_name()) then
local name = remove_enchant_name(input1) local name = mcl_grindstone.remove_enchant_name(input1)
local wear = input1:get_wear() local wear = input1:get_wear()
local new_item = create_new_item(name, meta, wear) local new_item = create_new_item(name, meta, wear)
new_output = transfer_curse(input1, new_item) new_output = transfer_curse(input1, new_item)
@ -157,7 +159,7 @@ local function update_grindstone_slots(meta)
local def2 = input2:get_definition() local def2 = input2:get_definition()
local meta = input2:get_meta() local meta = input2:get_meta()
if def2.type == "tool" and mcl_enchanting.is_enchanted(input2:get_name()) then if def2.type == "tool" and mcl_enchanting.is_enchanted(input2:get_name()) then
local name = remove_enchant_name(input2) local name = mcl_grindstone.remove_enchant_name(input2)
local wear = input2:get_wear() local wear = input2:get_wear()
local new_item = create_new_item(name, meta, wear) local new_item = create_new_item(name, meta, wear)
new_output = transfer_curse(input2, new_item) new_output = transfer_curse(input2, new_item)