Decoding block pallete

Discussion in 'Development' started by GamakCZ, Feb 6, 2020.

  1. GamakCZ

    GamakCZ Zombie

    Hello, I'm working on better world generator for PocketMine. For better generator I need structures as village, igloos, etc. I've used NBT files from BDS to use default textures. NBT has 2 main list tags, palette and blocks. Pallete has format
    [$index => (CompoundTag) [Name => "minecraft:blockname"], $index => ...]
    . I've tried to use ids from vanilla resources (block_id_map.json). However they were incomplete. How can I build same map with all the blocknames? Missing for example minecraft:dark_oak_log, minecraft:birch_planks or minecraft:dark_oak_planks

       private function load() {
    $data = (new BigEndianNBTStream())->readCompressed(file_get_contents($this->path));
    /** @var array $compound */
    $compounds $data->getValue();

             * @var int[] $palette
             * stateId => pmmpId
    $palette = [];

    /** @var CompoundTag $state */
    foreach ($compounds["palette"] as $state) {
    // $this->getBlockMap() returns pocketmine/resources/vanilla/block_id_map.json as array
    $palette[] = $this->getBlockMap()[$state->getString("Name")] ?? 0;

    /** @var CompoundTag $blockData */
    foreach ($compounds["blocks"] as $blockData) {
    $pos $blockData->getListTag("pos");
    $state $blockData->getInt("state");
    $this->data[] = [$pos->offsetGet(0), $pos->offsetGet(1), $pos->offsetGet(2), $palette[$state]];

    $compounds["size"])) {
    /** @var ListTag $list */
    $list $compounds["size"];
    $this->axisVector = new Vector3($list->offsetGet(0), $list->offsetGet(1), $list->offsetGet(2));



    After first test I've got this result.

Share This Page

  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.