Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to get X, Y and Z spawn from default world?

Comments in 'Plugin Development' started by mamayadesu, Mar 25, 2015.

  1. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
  2. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    The default is 128, 70, 128.

    Otherwise you can use my ManyWorlds plugin. The `/mw ls <worldname> should show this.

    From the API,

    Server::getInstance()->getDefaultLevel()->getSpawn();

    Server::getInstance : gets the $server object. If you are running from a plugin you should actually do $this->getServer()
    getDefaultLevel : gets the Level object for the default level from $server.
    getSpawn : returns a Position for the spawn location.
    xiaoq likes this.
  3. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    He means by a plugin not commands/in-game stuff.
  4. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Hehe. Didn't read that part.
    :p I'm such a noob.
  5. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    If you wish to get the spawn from multiple worlds, you can do
    PHP:
    $this->getServer()->getLevelByName("world")->getSpawnLocation();
    while replacing "world" with what world you want to get.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The default is 128,70,128? What makes you think that?
    Also, use getSpawnLocation() instead; getSpawn() is deprecated.
  7. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    The default location for "world" is hardcoded in /src/pocketmine/level/format/mcregion/McRegion.php:

    PHP:
    public static function generate($path$name$seed$generator, array $options = []){

    // Rest of the code edited for brevity...

    $levelData = new Compound("Data", [
                
    "hardcore" => new Byte("hardcore"0),
                
    "initialized" => new Byte("initialized"1),
                
    "GameType" => new Int("GameType"0),
                
    "generatorVersion" => new Int("generatorVersion"1), //2 in MCPE
                
    "SpawnX" => new Int("SpawnX"128),
                
    "SpawnY" => new Int("SpawnY"70),
                
    "SpawnZ" => new Int("SpawnZ"128),
                
    "version" => new Int("version"19133),
                
    "DayTime" => new Int("DayTime"0),
                
    "LastPlayed" => new Long("LastPlayed"microtime(true) * 1000),
                
    "RandomSeed" => new Long("RandomSeed"$seed),
                
    "SizeOnDisk" => new Long("SizeOnDisk"0),
                
    "Time" => new Long("Time"0),
                
    "generatorName" => new String("generatorName"Generator::getGeneratorName($generator)),
                
    "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
                
    "LevelName" => new String("LevelName"$name),
                
    "GameRules" => new Compound("GameRules", [])
            ]);
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That's just for generated worlds.
  9. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    $this->getServer()-getDefaultLevel()->getSpawn();
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    CrazedMiner likes this.
  11. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    $this->getServer()->getDefaultLevel()->getSpawnLocation());
    CrazedMiner likes this.

Share This Page

Advertisement