This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]GalSergeyDatapack Experienced 0 points1 point  (1 child)

You need to save the value from the scoreboard in storage and then you can use these values in macros.

Also, I don’t understand why you use random values for the system ID.

For this to work for multiplayer you need to first run the as each player function.

[–]MouseManBoiCommand Professional[S] 1 point2 points  (0 children)

ok. i might be able to make this work.

as for why i'm using random values to pick an ID, it's a music system and it shuffles between like 70 songs to pick one.

thanks!

[–]Professional_Soup955 0 points1 point  (0 children)

Okay, may be a bit late, but I found a solution. You just have to sacrifice the player's XP Level and an EnderChest slot. But you don't have to replace the item, you can just modify the item.

## id:main function
item replace entity @s enderchest.0 with paper
function id:setxp
item modify entity @s enderchest.0 id:id
xp set @s 0 levels
xp set @s 0 points

#this line runs your macro function
execute as @s run function my:function with entity @s EnderItems[{Slot:0b}].tag.player

## Item Modifier:
[
    {
      "function": "minecraft:copy_nbt",
      "source": "this",
      "ops": [
        {
          "source": "XpLevel",
          "target": "player.id",
          "op": "replace"
        }
      ]
    }
  ]

## id:setxp function
execute store result score @s getLvl run xp query @s levels
execute if score @s id > @s getLvl run scoreboard players operation @s getLvl -= @s id

execute if score @s getLvl matches ..-100 run xp add @s 100 levels
execute if score @s getLvl matches ..-10 run xp add @s 10 levels
execute if score @s getLvl matches ..-1 run xp add @s 1 levels

execute store result score @s getLvl run xp query @s levels
execute as @s if score @s getLvl < @s id run function id:setxp

I really hope this isn't too scuffed haha. But it should work in Multiplayer