Started by
Fini_Earth
on
Topic category: Help with Minecraft modding (Java Edition)
I made a weapon with a crafting recipe to craft something else (stay in craftingrid wenn crafted and damage item on crafting is on)
and i want it to keep enchants if it has any, curently it removes the enchants if i craft with it.
Can someone help me by giving me a procedure that fixes this or a setting i overlooked.
ps: im using 25.3 (newest) with 1.21.8
Pretty sure there's no setting for it. In terms of procedures maybe there is a global trigger something along the lines of item crafted, then you get itemstack and can apply old enchantments. To find what the old enchantments were you can maybe save them as a (local?) variable somewhere but that seems too extra for something so small... Anyway the gist is you need to somehow record your original enchantments, then detect when anything is crafted, check if it's your item, if it is then reference your record^ and apply the enchantments.
im not fully understanding what u are saying cuz im kinda noob with procedures, could you be mor precise with the procedures to use
(PS: i also answer on questions on procedures like this, but even less detailed)
I don't even know either. You have an item that will be damaged and remains in the crafting grid when it is used to craft something else, and through this the item will lose durability. Your problem is that the item has enchantments and they disappear after it is used for crafting.
So to fix this. You need to recognise and record the enchantments on the item before it is used for crafting. And then apply the enchantments back to the item after crafting.
Save enchantments;
On item trigger: item inventory tick
or
On item trigger: item is crafted/smelted
Record the enchants to a variable either by numbers or by strings
Reapply enchantments;
On global trigger: item is crafted
If [get item in slot X of gui] =[your_item] ->(you would need to find the slot id for where your item goes in the crafting grid or just check all slots 0-10 or so)
Check which enchants are saved to variable,
If above is true, add enchantment... to [get item in slot X of gui]