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

change level name in level.dat

Comments in 'Plugin Development' started by Creeperface, Sep 5, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    how to change level name in level.dat ?
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use an NBT explorer to edit level.dat
  4. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I think he means with code cause this is in the Plugin Development section :p
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then use the PocketMine NBT class :) read PocketMine source for examples how to use it. (Search new NBT)
    Creeperface likes this.
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    $nbt = new NBT(NBT::LITTLE_ENDIAN);
    $nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8));
    $levelData $nbt->getData();
    so can i use
    PHP:
     $levelData->LevelName = new String("LevelName"$name)
    ?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Kind of. But remember to emit and save it.
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

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

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    OK thx again :)
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    should i use $nbt->setData($levelData) too?
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Assuming you know PHP, read the source code I linked you.
    Creeperface likes this.
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so i have only level folder (now is not loaded)
    and i can change some NBT data:
    PHP:
    $nbt = new NBT(NBT::LITTLE_ENDIAN);
    $nbt->read(file_get_contents($this->getDataPath() . "worlds/world/level.dat"));
    $levelData $nbt->getData();
    $levelData->LevelName = new String("LevelName""Awesome level");
    $nbt->setData(new Compound("", [
    "Data" => $levelData
    ]));
    $buffer $nbt->writeCompressed();
    file_put_contents($this->getDataPath() . "worlds/world/level.dat"$buffer);
    PEMapModder likes this.

Share This Page

Advertisement