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

Solved ByteArray

Comments in 'Plugin Development' started by Svile, Apr 16, 2016.

  1. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Hi! Can anyone help me with NBT ?

    suppose $bytearray is an instance of the https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/nbt/tag/ByteArrayTag.php class.

    PHP:
    $bytearray->getValue();
    returns a string.
    but the problem is: i don't understand what this string is.

    Can someone help me pls? i really want to know what this string is and how to read it.

    i'm thinking to read it using the Binary class... if right can someone make me an example or link me where is this tag used in the pocketmine code?

    please don't answer:- "the string is an array of bytes" :p
    Last edited: Apr 16, 2016
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I don't know it exactly but
    $this->value = $nbt->get($nbt->getInt());
    Looks like it's an int?!
    And if you want to read it, you should know what it's for
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    it's a schematic file
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    i found an example here: https://github.com/sk89q/WorldEdit/...orldedit/schematic/MCEditSchematicFormat.java

    And i'm reading the string with:

    PHP:
    // \pocketmine\utils\Binary::readByte()
    // $n is the byte index
    public static function readByte($c$n 0)
    {
            
    $b ord($c{$n});

            if (
    PHP_INT_SIZE === 8)
                return 
    $b << 56 >> 56;
            else
                return 
    $b << 24 >> 24;
    }
    Last edited: Apr 16, 2016
    Vaivez66 likes this.
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    each character of the string is a byte , each byte is a block id :D
  6. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile

Share This Page

Advertisement