#Get Player Spawn Location

3 messages · Page 1 of 1 (latest)

waxen flint
#

I'm trying to create an item that teleports the player to their spawn point when right clicked but I can't figure out how to access that data.

ItemEvents.rightClicked(event => {
    const item = event.item;
    const player = event.player;
    const playerName = player.name;

    if(item.id == 'kubejs:magic_mirror'){

        const spawnPoint = player.getSomething(); //???
        const spawnDimension = player.getSomething(); //???
        event.runCommand('execute in ' + spawnDimension + ' run tp ' + playerName + ' ' + spawnPoint);
    }
});```

If I were to run vanilla command to retrieve the data I'd just do `data get entity @s SpawnX` (...Y, Z, Dimension).

I have been at this for a couple hours and can't figure out how to retrieve this data using kubejs. Any help appreciated!
ocean bridgeBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

waxen flint
#

let spawnX = player.nbt.get("SpawnX");

Leaving this for anyone else who comes across this and needs a solution. This is how you access these properties. :)