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

Solved Skull tile?

Comments in 'Plugin Development' started by JonsMC, Sep 24, 2016.

  1. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    I recently making an UHC plugin and there's problem with it
    PHP:
         $nbt = new CompoundTag(" ", [
                new 
    ListTag("Items", []),
                new 
    StringTag("id"Tile::SKULL),
                new 
    IntTag("x"$x),
                new 
    IntTag("y"$y),
                new 
    IntTag("z"$z)
            ]);
         
    $level->setBlock($blockBlock::get(113));
            
    $head Tile::createTile("Skull",$player->getLevel()->getChunk($block->getX() >> 4$block->getZ() >> 4), $nbt);
            
    $level->addTile($head);
    $player is the player object, $x, $y, $z is the player's coordinate

    Console logs:
    Code:
    24.09 06:45:18 [Server] Server thread/CRITICAL Error: "Call to a member function getName() on null" (EXCEPTION) in "/src/pocketmine/nbt/tag/CompoundTag" at line 37
    24.09 06:45:18 [Server] Server thread/CRITICAL "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'FenceSkull v1.0.0': Call to a member function getName() on null on fenceskull\Main
    24.09 06:45:18 [Server] INFO Notice: Undefined property: pocketmine\nbt\tag\CompoundTag::$Rot in phar:///home/multicraft/jar/pocketmine/genisys/0.15/Genisys.0.15.9.phar/src/pocketmine/tile/Skull.php on line 57
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    This is most likely because one of the value in the array, the second argument passed to CompoundTag constructor, is null
    This is because your compound tag is missing a "Rot" property, correct nbt should be
    PHP:
    $nbt = new CompoundTag("", [
             new 
    StringTag("id"Tile::SKULL),
             new 
    IntTag("x"$block->x),
             new 
    IntTag("y"$block->y),
             new 
    IntTag("z"$block->z),
             new 
    ByteTag("SkullType"0),
             new 
    ByteTag("Rot"0)
           ]);
  3. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Now, none errors in console and the skull isn't spawning either :p
  4. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    You need to create the tile and add it to the world.
    PHP:
    $tile Tile::createTile("Skull"$player->getLevel()->getChunk($player->getX() >> 4$player->getZ() >> 4), $nbt);
    $player->getLevel()->addTile($tile);
  5. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Considering about reading my code please, i already did that on the 2 last line
  6. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    I did read that but after you code was corrected I assumed that you copied and pasted what @wolfdale said.
  7. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Nope :p
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Its not showing even if you setblock?
  9. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    setBlock($position, Block::get(144, 3));
  10. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    No lucks
  11. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Fixed :D
    ImagicalGamer likes this.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How? And FYI, Tile::createTile already calls Level::addTile.
    ImagicalGamer likes this.

Share This Page

Advertisement