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.
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.
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);
Define $player as: PHP: $player = $event->getEntity(); Then do: PHP: if($player instanceofPlayer{//code here)
public function onDeath(Death $event){ $player = $event->getEntity(); if($player instanceof Player){ } Top of code ^