#stacking attribute buffs in multiplayer

1 messages · Page 1 of 1 (latest)

grim zinc
#

so im trying to make it so when you have a specific item it gives you an attribute value relative to the amount you have of that item. i already have that done but the issue is having it work in multiplayer since it checks for the amount of this item you have every tick and stores it in one data storage, so it jumbles up with other players item count of the same item.

my question is is there any way to detect when a player is given this item in any way (/give or on pickup) so i can only then run the command that stores the item count?

grim zinc
#

aughhh i hate to do this but ive no clue what to do

verbal ruinBOT
#

-# (helpers summoned) <@&1166082198152159386> <@&1202694677766348840>

past path
#

I don't get the problem. Can you share the code?

real mantle
#

It shouldn't be getting jumbled up as long as you're storing and evaluating that data individually for each player every tick, so yeah we'll need to see your work to offer a solution

grim zinc
#

heres an example i made

#

execute store result storage hello:storage count double 0.5 run clear @a minecraft:stick 0
execute as @a run function hello:stickmacro with storage hello:storage

#

attribute @s attack_damage modifier remove scale
$attribute @s attack_damage modifier add scale $(count) add_value

#

both run every tick

#

i cant store the data individually since its decimals

#

heres a more specific one

execute as @a[nbt={Inventory:[{components:{"minecraft:custom_data":{basedamage:true}}}]}] store result storage hello:storage basedamagebonus double 0.2 run clear @s prismarine_shard[custom_data={basedamage:true}] 0 execute as @a[nbt={Inventory:[{components:{"minecraft:custom_data":{basedamage:true}}}]}] run function hello:items/base_damage/base_damagemacro with storage hello:storage

attribute @s attack_damage modifier remove basedamage $attribute @s attack_damage modifier add basedamage $(basedamagebonus) add_value

hallow flax
#

you would want to run the first bit as a subfunction as well instead of targeting @a multiple times. if you do that then the storage is both set and used by each individual player before it's set by the next player

grim zinc
#

sorry what do you mean by subfunction?

hallow flax
#

just an extra function to handle the logic in, instead of doing it directly in the tick function

#

so your ticking function just runs something like execute as @a run function hello:count and that function is just your original logic but only targeting @s

grim zinc
#

would it give them the attribute individually even though they use the same storage that way

hallow flax
#

yes, because the commands are run by each player in turn when handled this way. so for two players, execute as @a run function ... runs the function all the way through for player one (setting the storage and running the macro with the storage and setting the attribute) before starting to run the function for player two

grim zinc
#

ohhh and all that in the same tick?? thats awesome tysm!!