#Item Modifiers

1 messages · Page 1 of 1 (latest)

stiff fern
#

I'm a little lost on these, the end goal is for me to convert a score into an item durability in a players inventory, is that doable?
I already have the item and cooldown system with scores and stuff, just no way to visualise it

cerulean vectorBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 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

stiff fern
#

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

cerulean vectorBOT
# cerulean vector <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

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)

bleak estuary
#

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

stiff fern
bleak estuary
#

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

shrewd berry
#

there is a way

#

Have you tried using misode? because doing what you describe cost me a total of 10 seconds on misode

upper isleBOT
#
Tool: Misode
About

Misode's Datapack Generators are useful when creating files such as loot tables, predicates, advancement, worldgen files, and more!

shrewd berry
#

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.

stiff fern
#

i've never used item modifiers before and even with the website i have no idea what im doing

shrewd berry
#

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

stiff fern
#

i would love some pointers if you could 🙏

shrewd berry
#

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!).

tall viper
#

How about using a macro?

#

So function set_damage with storage namespace:name

#

In set_damage:

#

$Item replace entity @s (item)[Damage:$(damage)]

coral wind
#

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.0 and 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)
kindred tendon
#

That doesn't make item modifiers obsolete and is usually worse

#

But as you said there's some cases where it's necessary

coral wind
#

ofc item modifiers are way simpler but like i mentioned, some things you just cant do with item modifiers

kindred tendon
#

Does not contradict what I said

coral wind
#

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)

coral wind
coral wind