24 public function __construct(
25 private int $actionType,
29 if(!self::isValidActionType($actionType)){
30 throw new \InvalidArgumentException(
"Invalid action type for " . self::class);
34 public function getActionType() :
int{
return $this->actionType; }
36 public function getBlockPosition() :
BlockPosition{
return $this->blockPosition; }
38 public function getFace() :
int{
return $this->face; }
40 public static function read(ByteBufferReader $in,
int $actionType) :
self{
41 $blockPosition = CommonTypes::getSignedBlockPosition($in);
42 $face = VarInt::readSignedInt($in);
43 return new self($actionType, $blockPosition, $face);
46 public function write(ByteBufferWriter $out) :
void{
47 CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
48 VarInt::writeSignedInt($out, $this->face);
51 public static function isValidActionType(
int $actionType) :
bool{
52 return match($actionType){
53 PlayerAction::ABORT_BREAK,
54 PlayerAction::START_BREAK,
55 PlayerAction::CRACK_BREAK,
56 PlayerAction::PREDICT_DESTROY_BLOCK,
57 PlayerAction::CONTINUE_DESTROY_BLOCK =>
true,