1

I'm working on a minigame in 1.13 and am trying to make a command that executes at a players position and spawns an area effect cloud there. I have managed that but I also need that area effect cloud to be spawned with a tag or something (or a score etc.) that can link it to the player that was used to spawn it. I tried one command that is supposed to give the area effect cloud the players name as a tag but it doesn't seem to work:

/execute as @a[team=Alive,scores={ReadyToPlant=3,Sneak=1..,PlantedPotato=0},nbt={SelectedItem:{id:"minecraft:stripped_birch_wood"}}] at @s run summon area_effect_cloud ~ ~ ~ {Duration:2147483647,CustomName:"{\"text\":\"SpawningPotato\"}",Tags:["{\"text\":\"@s\"}"]}

  • I'm not sure how easy this is, but you're probably going to want to give everyone a unique player ID score, and then set a score in the area effect cloud to that value. – MBraedley Mar 15 '19 at 15:55
0

You could try to make a command chain where after the area effect cloud is spawned it summons a perminate, imobile, indistructable, invisible entity such as a armor stand next to or under or above the area effect cloud that has a tag which can then activate a command block with the sequence:

execute if entity @e[type=armor_stand,tag=...] run ...

Idk if this will work or helps at all but I hope it does.

0

The best way I can think of is to assign a unique id to every player using the scoreboard system and then copy that id to the area of effect cloud.

To set this up, create the following objectives:

/scoreboard objectives add index dummy

/scoreboard objectives add global_temp dummy

initialize the global index: /scoreboard players set global index 1

and then, paste these into a command block chain (1 repeating and 3 chain command blocks):

enter image description here

execute as @a unless entity @s[scores={index=1..}] run scoreboard players set @s index 0

execute store success score global global_temp run scoreboard players operation @a[limit=1,sort=arbitrary,scores={index=0}] index = global index

execute if score global global_temp matches 1 run scoreboard players add global index 1

scoreboard players reset global global_temp

here is how the system works. When a player joins, the value of the global index is copied into the players index objective. Then, the value of "global_index" is increased by 1 so the next player who joins gets a higher number than the previous player. The first player will have an index of 1, the second an index of 2 and so on...

now you can store the index of the player to the area of effect cloud like this:

/execute as <area_of_effect_cloud> store result score @s index run scoreboard players get @p[distance=..5,limit=1,sort=nearest] index

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.