use pocketmine\network\mcpe\handler\PacketHandler; use pocketmine\network\mcpe\serializer\NetworkBinaryStream; class AnvilDamagePacket extends DataPacket implements ServerboundPacket{ public const NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET; /** @var int */ private $x; /** @var int */ private $y; /** @var int */ private $z; /** @var int */ private $damageAmount; public static function create(int $x, int $y, int $z, int $damageAmount) : self{ $result = new self; [$result->x, $result->y, $result->z] = [$x, $y, $z]; $result->damageAmount = $damageAmount; return $result; } public function getDamageAmount() : int{ return $this->damageAmount; } public function getX() : int{ return $this->x; } public function getY() : int{ return $this->y; } public function getZ() : int{ return $this->z; } protected function decodePayload(NetworkBinaryStream $in) : void{ $this->damageAmount = $in->getByte(); $in->getBlockPosition($this->x, $this->y, $this->z); } protected function encodePayload(NetworkBinaryStream $out) : void{ $out->putByte($this->damageAmount); $out->putBlockPosition($this->x, $this->y, $this->z); } public function handle(PacketHandler $handler) : bool{ return $handler->handleAnvilDamage($this); } }