#Item Modifiers
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
The item in question is "warped_fungus_on_a_stick" with the cooldown lasting 20s (score decreases by 1 every 4 ticks -> i've already set this up and it works)
the version is 1.20.1 also
<@&1166082198152159386> <@&1202694677766348840>
Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)
Does the item vary or is it always warped fungus on a stick?
I can think of a very clunky way to do it where you /execute if score (entity) (score) matches (number) run give (entity) (item){Damage:(number equivalent)} 1
And then run a clear command after
Yeap 👍 (always fungus on stick)
This is the only way I can think of, you'd have to make an individual line for each score/durability
I don't think there's a way to change durability of an item without just giving a new item but I may be wrong
there is a way
Have you tried using misode? because doing what you describe cost me a total of 10 seconds on misode
Misode's Datapack Generators are useful when creating files such as loot tables, predicates, advancement, worldgen files, and more!
you want to use the set_damage modifier, but you might have issues if you want to set the durability to a fixed amount
as that would be max_durability - amount_wanted = damage_to_set
I still don't get why they decided to call missing durability, "damage". yes the item is damaged by X amount of durability points but it is confusing when you also have damage attributes for weapons.
Why do they have to make this so confusing ;-;
i've never used item modifiers before and even with the website i have no idea what im doing
well I am afraid chewing out code scripts is frowned upon here, but if you get stuck for longer we can have a call or I can give some further pointers in dms
i would love some pointers if you could 🙏
For others reading some things to take into account:
set_damage modifies the damage by a percentage (-1.0 to 1.0) of the max_durability.
it by default removes durability, using a negative scale can add durability, this does require "add":true.
For single durability points this means you have to add multiple modifiers with different scales that have conditions that check the max_durability of the item (which restricts usage to a single slot!).
How about using a macro?
So function set_damage with storage namespace:name
In set_damage:
$Item replace entity @s (item)[Damage:$(damage)]
I did recently kind of fine a way to make item modifiers practically obsolete
and for this use case it might actually be good
so what I usually do when item modifiers cant fulfill my wishes. I
- Summon an item at the player's position with as much hard-coded data as necessary in the summon command
- Use a macro to change the item's data to whatever I need, in your case
Item.components."minecraft:damage" set value $(damage) - Either do nothing and let the player pick up the item (which will place it in the next empty slot) and remove the item from the player's weapon.mainhand
- Or, (in most use-cases preferred) use
item replace entity @s weapon.mainhand from entity @n[type=item] container.0and kill the item. (note that its preferred to give the item a temporary tag so you can make sure you make the player get the right item and kill the right item, most times not necessary though)
That doesn't make item modifiers obsolete and is usually worse
But as you said there's some cases where it's necessary
ofc item modifiers are way simpler but like i mentioned, some things you just cant do with item modifiers
Does not contradict what I said
and i feel like this would be a case where this is better than item modifiers (if its true that you need to input a percentage)
i was agreeing to your statement
anyway this is just a way to modify the player's SelectedItem data (which tbh is stupid that we need such a workaround)