top = $r->readBool(); } protected function encodeState(BlockDataWriter $w) : void{ $w->writeBool($this->top); } public function isTop() : bool{ return $this->top; } /** @return $this */ public function setTop(bool $top) : self{ $this->top = $top; return $this; } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $id = $blockReplace->getSide(Facing::DOWN)->getTypeId(); if(($id === BlockTypeIds::GRASS || $id === BlockTypeIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){ $top = clone $this; $top->top = true; $tx->addBlock($blockReplace->position, $this)->addBlock($blockReplace->position->getSide(Facing::UP), $top); return true; } return false; } /** * Returns whether this double-plant has a corresponding other half. */ public function isValidHalfPlant() : bool{ $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); return ( $other instanceof DoublePlant && $other->isSameType($this) && $other->top !== $this->top ); } public function onNearbyBlockChange() : void{ if(!$this->isValidHalfPlant() || (!$this->top && $this->getSide(Facing::DOWN)->isTransparent())){ $this->position->getWorld()->useBreakOn($this->position); } } public function getDrops(Item $item) : array{ return $this->top ? parent::getDrops($item) : []; } public function getAffectedBlocks() : array{ if($this->isValidHalfPlant()){ return [$this, $this->getSide($this->top ? Facing::DOWN : Facing::UP)]; } return parent::getAffectedBlocks(); } public function getFlameEncouragement() : int{ return 60; } public function getFlammability() : int{ return 100; } }