#world spawn being weird (sharedSpawnPos)

8 messages · Page 1 of 1 (latest)

spring arrow
#

so i made a server script that places a structure at world spawn on first server load that can be teleported back to by using a custom command i made. Problem is that, the player spawns on top of the structure instead of in it. Is there a way to counter this? Amazing image for reference.

shell baneBOT
#

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

spring arrow
#
ServerEvents.loaded(event => {
  const { server , server: { persistentData } } = event
  console.log(persistentData.firstload)
  if(!persistentData.firstload) {
    let overworld = server.overworld()
    let spawnPos = overworld.sharedSpawnPos.offset(0, 1, 0)
    server.gameRules.set('spawnRadius', 0)
    const { x, y, z } = spawnPos
      console.log(`place template toastech_datapack:global_recall ${Math.floor(x-3)} ${Math.floor(y-2)} ${Math.floor(z-3)}`)
    server.runCommandSilent(`place template toastech_datapack:global_recall ${Math.floor(x-3)} ${Math.floor(y-2)} ${Math.floor(z-3)}`)
      console.log(persistentData.firstload)
    persistentData.firstload = true
    }
})```
queen mulch
#

There probably is a more elegant solution to this... but... maybe just try teleporting the player a couple blocks down?

spring arrow
#

so just add this?

PlayerEvents.loggedIn(event => {
  const { player , player: { persistentData } } = event
  if(!persistentData.firstjoin) {
    persistentData.firstjoin = true
    const playerName = player.getName().getString()
    player.runCommandSilent(`tp ${playerName} ~ ~-7 ~`)
  }
})```
queen mulch
#

probably.

spring arrow
#

it seems to work!

bright fableBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.