I've been trying to get together a per player spawn setting mechanism and currently stuck on storing a position and player UUID together in a way where it's easily queryable and thus teleportable.
This is what i've tried so far:
/data modify entity 6f88f8eb-cfa3-44bf-a621-52b3e7d753e7 Pos set from storage game:player Spawn{target:'[{"selector":"@p"}]'}.location
That selector block is what isn't working. I need a way to get a selector working in that nbt search part.
if that's impossible something that drives the same functionality.
Also using a temp data storage would be acceptable if it's passable into that target based query 🙂
Storage game:player has the following contents:
{
Spawn:[
{
location: [-39.89557466099629d, 66.0d, 42.25176377238329d],
target: [I; -1155610777, -758824872, -1437747869, 728530035]
}
]
}
Best Answer
The way I solved this is, I copied the list of spawns to a new location. Then I iterated through them by copying the item in location 0 of the list to a temporary spot named
Current
, then removing it from the list so that the next iteration can get a new item.Now, I just compare the Current.Indexer and the player UUID by writing over current with
/data modify
. However, because we need the current values later, we must storeCurrent.Indexer
in a temporary storage.If they're different,
/data modify
returns 1. If they're the same,/data modify
returns 0. Then, reverse the result with a scoreboard for later ease of use.If the comparison returns true, we can exit the loop and use the
Current.Indexer
to teleport a tagged armor stand to the location. aka we data modify the armor stand Pos to Current.Item. and then tp player -> tagged armor stand