26 public function __construct(
27 private int $actionType,
31 if(!self::isValidActionType($actionType)){
32 throw new \InvalidArgumentException(
"Invalid action type for " . self::class);
36 public function getActionType() :
int{
return $this->actionType; }
38 public function getBlockPosition() :
BlockPosition{
return $this->blockPosition; }
40 public function getFace() :
int{
return $this->face; }
42 public static function read(ByteBufferReader $in,
int $actionType) :
self{
43 $blockPosition = CommonTypes::getSignedBlockPosition($in);
44 $face = VarInt::readSignedInt($in);
45 return new self($actionType, $blockPosition, $face);
48 public function write(ByteBufferWriter $out) :
void{
49 CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
50 VarInt::writeSignedInt($out, $this->face);
53 public static function isValidActionType(
int $actionType) :
bool{
54 return match($actionType){
55 PlayerAction::ABORT_BREAK,
56 PlayerAction::START_BREAK,
57 PlayerAction::CRACK_BREAK,
58 PlayerAction::PREDICT_DESTROY_BLOCK,
59 PlayerAction::CONTINUE_DESTROY_BLOCK =>
true,