#Smith Unbreakable Items Recipe

16 messages · Page 1 of 1 (latest)

glossy temple
#

Background: I'm not sure how to go about this so I don't have code to bug fix, more of an idea which I have been trying (unsuccessfully) to do on my own for some time now.

Idea: I want to make a recipe which will smith together (using the smithing table) any item which has full durability but can lose durability (eg: armor, tools, and weapons) with this item 'create_things_and_misc:mending_rune' to make a version of the original item with the only change being it has the Unbreakable:1b tag. Essentially, I want to add an unbreakable item recipe to all the items that it makes sense for (items with durability) that don't already have the tag and are at full durability. Can someone help me with that?

terse wigeonBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

glossy temple
#

Smith Unbreakable Items Recipe

signal apex
#

Probably iterate over all items with Ingredient.of(/.*/).stacks, then test item.maxDamage and if it is an item with durability, create the recipe for that item
Downside is it will spam the smithing table category in jei but that's not really avoidable for non-crafting-table recipes

glossy temple
#

I'm somewhat new to Kubejs, would item.maxDamage be used as a function of Item.of()? By that I mean Item.of().maxDamage. And if it is not used like that, how might I use item.maxDamage in my code?

signal apex
#

Item.of() returns an ItemStack and maxDamage is an Item property?, so you'd want Item.of().item, or otherwise call .item on a stack

#

I'm not sure what the default value is for items which don't have durability, like maybe -1, 0, or undefined, so you'd want to test that by just debugging it to the console so you know what to match for

glossy temple
#

I know that there is a .filter() function that filters for items with a specific phrase in their name. Is there some variation of that for nbt data that I could use or is that aspect more manual?

#

Btw, thank you very much as you are the only person on this thread and every comment has been extremely helpful! 😀 I appreciate it.

signal apex
#

OK, I checked my scripts and apparently maxDamage is something you can just call on an ItemStack, at least on 1.19
You don't need to do anything like that, you can just do like:

for (let stack of Ingredient.of(/.*/).stacks) {
    if (!stack.maxDamage) continue // again I don't know if this is the exact check you would do
    event.smithing(
        Item.of(stack.id, {Unbreakable: true}), 
        stack, 
        'create_things_and_misc:mending_rune') 
}
glossy temple
#

Thanks, I'm going to try that a little later but you been amazing! Thank you so much!

glossy temple
#

I still haven't figured out the check for durability before making the recipe but for some reason, a different problem has started up. Basically, the items that can become Unbreakable only have the recipe in JEI but in the smithing table, it doesn't work. Do you have any clue how to fix that part of the issue (screenshots attached)?

#

The right is JEI (which shows as functional) and the left is the smithing table (which doesn't seem to work). Also, this is specifically the recipe for the diamond sword but all items appear as well, I just narrowed it down to the diamond sword because that is what I am using for testing.

signal apex
#

It says there is one nbt tag on the smithing output; what is that?

glossy temple
#

The Damage tag to say that there is 0 Damage.

#

I also wondered about that because damage was the only thing that seemed to function properly.