1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to change name of the world?

Discussion in 'Help' started by Groin, Mar 27, 2018.

  1. Groin

    Groin Baby Zombie

    Messages:
    159
    The title says all. I need to know how to change the name of the world.
    p/s: I mean not rename the folder world
     
  2. korado531m7

    korado531m7 Slime

    Messages:
    77
    GitHub:
    korado531m7
    usually i create a new world(of course world name is not same)
    and open created world, copy lavel.dat, then paste it in you want to change world name.
    after pasted, rename folder, and reset default spawn coordinates.
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    you can use a nbt editor and edit the level name attribute in level.dat. I do strongly advisee you to not blindly copy level.dat from fresh levels, because there might be important data in the level.dat.
    NBT editors can be found here: Windows / Linux Mac Github NBTedit
     
  4. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    What if we want to do it using code?
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    well, the level would have to be unloaded and then you can do this:
    PHP:
    $levelPath "/path/to/your/level";
    $newName "/path/to/your/level";

    $nbt = new pocketmine\nbt\BigEndianNBTStream();
    $levelData $nbt->readCompressed(file_get_contents($levelPath "level.dat"));
    $levelData $levelData->getCompoundTag("Data");
    $oldName $levelData->getString("LevelName");
    $levelData->setString("LevelName"$newName);
    $nbt = new BigEndianNBTStream();
    file_put_contents($levelPath "level.dat"$nbt->writeCompressed(new CompoundTag("", [$levelData])));
    echo(
    "Renamed $oldName to $newName");
     
    HimbeersaftLP likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.