Creating a new world doesn't set a spawnlocation

Discussion in 'Spigot Plugin Development' started by KennyTV, Feb 13, 2018.

Thread Status:
Not open for further replies.
  1. Sou, using this code, all 3 values are simply 0 (also when entering the world ingame the first time, the spawn location is at 0, y, 0), but I actually need the proper spawn for the seed.

    Code (Text):
    final World world = getServer().createWorld(new WorldCreator("testworld"));
    final Block block = world.getSpawnLocation().getBlock();
    getLogger().warning("x: " + block.getX());
    getLogger().warning("y: " + block.getY());
    getLogger().warning("z: " + block.getZ());
    Do I have to use another method of the worldcreator to also set the normal spawnlocation the created seed would have?

    As the normal mainworld does actually have the normal spawn location the seed gives, it should be possible to have it for newly created worlds as well...
    Couldn't find any information in the docs or on other forum threads.
     
  2. This is what I could find. Also note the canSpawn method. I also feel like there's some mystery hiding in the 'can have a fixed spawn', but yeah... Not sure if the linked method calls canSpawn internally, didn't want to dig into the source at this moment.
     
    • Informative Informative x 1
  3. Uhm, seems like both methods return null for the ChunkGenerator

    Code (Text):
    final WorldCreator creator = new WorldCreator("testworld");
    final World world = getServer().createWorld(creator);

    final ChunkGenerator generator = creator.generator(); //null
    final ChunkGenerator generator2 = world.getGenerator(); //null
     
  4. I tried your code and it works fine for me (spigot 1.12.2-R0.1-SNAPSHOT). Maybe try checking that you didn't set any custom generator somewhere in your code and on the bukkit.yml file.
     
  5. Looked a bit into the docs and how for exaple MultiVerse handles the creation: None of it can actually create a world with the set spawnpoint by the seed, its always 0 y 0. I'm now starting to recreate the main world itself, because it seems to work there fine with the vanilla spawn (I think it's because it is generated by Minecraft, not Bukkit).
    New problem to that: I have to restart the server everytime, so the world gets regenerated, but I have a lack of Linux skills so I can't manage to make an autorestart :confused:
     
  6. I looked into the nms code and bukkit uses the seed like the vanilla minecraft does to generate the world spawn location. I'm sorry but I can't reproduce your issue.
     
  7. Um, try creating a world with the method getServer().createWorld(new WorldCreator("testworld")) and teleport yourself into it - the world looks as the seed promises, but you'll spawn at x and z = 0, not the actual coordinates you'd be teleported if you paste the seed into a singleplayer world
     
  8. So is it that the spawnpoint is set properly, just that it's ignored when being teleported to the world, or is it that the spawnpoint is never set aside from 0, 0?

    You can verify this by looking internally at the level.dat with an NBT program such as NBTExplorer.
     
  9. Haven't checked that, but World#getSpawnLocation returns 0 0 0 for all coordinates as well as me spawning... Looking manually wouldn't serve my purpose of constantly recreating the world
     
    #9 KennyTV, Feb 14, 2018
    Last edited: Feb 14, 2018
  10. Hmmmm. Perhaps immediately after creation, try to call World#setSpawnLocation with a generated location... you said the ChunkGenerator objects were null?
     
  11. Yes, they return null.
    I also had a task trying to get it a couple of seconds later, but it still returned null.

    Setting the spawn after creation does what it should do, I spawn at the set coordinates and World#getSpawnLocation returns the new values.
    I also tried creating worlds with the newest MultiVerse version on a newly created server without any other plugins, even those worlds (besides the vanilla created one) had the spawn point set to 0 0 0, not the spawn of the seed
     
  12. https://hub.spigotmc.org/javadocs/b...dGenerator-java.lang.String-java.lang.String-
    I don't think id needs to be anything but null, I'd test worldName to see if it needs to be world or anything specific, but I think, according to the docs.

    I'm hoping that using that ChunkGenerator will allow the spawn location to be set as the world is created, elsewise we'll have to recreate the vanilla spawn selection methodology.
     
    • Like Like x 1
  13. Waow, just figured something out... On Spigot 1.12 getting the correct seed coordinates actually works without me changing any of my code. Seems to be a habit with the 1.8 Spigot . _.
    Since the seeds for 1.12 are the same as for 1.8, I'm just going to use the 1.12 Spigot.

    Sorry for the waste of time, but thanks for the help anyways. :D
     
    • Winner Winner x 1
Thread Status:
Not open for further replies.

Share This Page