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

Need help with creating a tile and setting it.

Comments in 'Plugin Development' started by Irish, May 9, 2016.

  1. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    As the title suggests, everytime I place down a skull block it's either invisible, has the wrong meta, or sometimes even both. I tried setting the damage, with no success.
    PHP:
    $head = new Block(Block::SKULL_BLOCK);
                
    $head->setDamage(3);
                
    $level->setBlock(new Vector3($x$y+1$z),$head);
    EDIT: Scroll to the bottom of the page for the updated thread.
    Last edited: May 11, 2016
  2. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I looked around the forums and did Tile::createTile, but it still doesn't work.
    Code:
    PHP:
    $player $event->getPlayer();
            
    $cause $player->getLastDamageCause();
            
    $x $player->x;
            
    $y $player->y;
            
    $z $player->z;
            
    $nbt = new CompoundTag("", [
                new 
    ListTag("Items", []),
                new 
    StringTag("id"Tile::SKULL),
                new 
    IntTag("x"$x),
                new 
    IntTag("y"$y),
                new 
    IntTag("z"$z)
            ]);
            
    $block $player->getLevel()->getBlock(new Vector3($x$y+1$z));
            
    $level $player->getLevel();
            
    $head Tile::createTile("Skull",$player->getLevel()->getChunk($block->getX() >> 4$block->getZ >> 4), $nbt);
            
    $fence = new Block(Block::NETHER_BRICK_FENCE);
            
    $level->addTile($head);
          
    Error:
    Code:
    [20:28:59] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\tile\Tile::createTile() must implement interface pocketmine\level\format\FullChunk, null given, called in C:\Users\IrishPacks\Downloads\Genisys\plugins\Rates\src\Rates\main.php on line 133" (EXCEPTION) in "/src/pocketmine/tile/Tile" at line 83
    
    I understand it's something in getChunk, but I'm not sure.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    var_dump()
  4. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I misspelled $block >> getZ() I think. I didn't put the ()
  5. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Well a new error has occurred, and I have no clue how to fix it. It has something to do with getName() returning null in CompoundTag.

    Error:
    Code:
    [15:56:35] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'Rates+ v1.0.0': Call to a member function getName() on null on Rates\Main
    [15:56:35] [Server thread/CRITICAL]: Error: "Call to a member function getName() on null" (EXCEPTION) in "/src/pocketmine/nbt/tag/CompoundTag" at line 37
    
    PHP:
    PHP:
    $player $event->getPlayer();
            
    $cause $player->getLastDamageCause();
            
    $x $player->x;
            
    $y $player->y;
            
    $z $player->z;
            
    $nbt = new CompoundTag(" ", [
                new 
    ListTag("Items", []),
                new 
    StringTag("id"Tile::SKULL),
                new 
    IntTag("x"$x),
                new 
    IntTag("y"$y),
                new 
    IntTag("z"$z)
            ]);
            
    $block $player->getLevel()->getBlock(new Vector3($x$y+1$z));
            
    $level $player->getLevel();
            
    $head Tile::createTile("Skull",$player->getLevel()->getChunk($block->getX() >> 4$block->getZ() >> 4), $nbt);
            
    $level->addTile($head);
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Id is should be StringTag?
  7. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Should it be an IntTag, I used code from the actual Genisys php files.
  8. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Bump, because I still am not sure.
  9. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Define $player as:
    PHP:
    $player $event->getEntity();
    Then do:
    PHP:
    if($player instanceofPlayer{
    //code here
    )
    Last edited: May 15, 2016
  10. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    That would work?
  11. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    already did do that :/
  12. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    That works for me, you can't use getPlayer() on some events such as this one. Must use getEntity().
  13. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    public function onDeath(Death $event){
    $player = $event->getEntity();
    if($player instanceof Player){
    }

    Top of code ^

Share This Page

Advertisement