21 public const NETWORK_ID = ProtocolInfo::PLAYER_UPDATE_ENTITY_OVERRIDES_PACKET;
23 private int $actorRuntimeId;
24 private int $propertyIndex;
25 private OverrideUpdateType $updateType;
26 private ?
int $intOverrideValue;
27 private ?
float $floatOverrideValue;
32 private static function create(
int $actorRuntimeId,
int $propertyIndex, OverrideUpdateType $updateType, ?
int $intOverrideValue, ?
float $floatOverrideValue) :
self{
34 $result->actorRuntimeId = $actorRuntimeId;
35 $result->propertyIndex = $propertyIndex;
36 $result->updateType = $updateType;
37 $result->intOverrideValue = $intOverrideValue;
38 $result->floatOverrideValue = $floatOverrideValue;
42 public static function createIntOverride(
int $actorRuntimeId,
int $propertyIndex,
int $value) :
self{
43 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::SET_INT_OVERRIDE, $value,
null);
46 public static function createFloatOverride(
int $actorRuntimeId,
int $propertyIndex,
float $value) :
self{
47 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::SET_FLOAT_OVERRIDE,
null, $value);
50 public static function createClearOverrides(
int $actorRuntimeId,
int $propertyIndex) :
self{
51 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::CLEAR_OVERRIDES,
null,
null);
54 public static function createRemoveOverride(
int $actorRuntimeId,
int $propertyIndex) :
self{
55 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::REMOVE_OVERRIDE,
null,
null);
58 public function getActorRuntimeId() :
int{
return $this->actorRuntimeId; }
60 public function getPropertyIndex() :
int{
return $this->propertyIndex; }
62 public function getUpdateType() : OverrideUpdateType{
return $this->updateType; }
64 public function getIntOverrideValue() : ?
int{
return $this->intOverrideValue; }
66 public function getFloatOverrideValue() : ?
float{
return $this->floatOverrideValue; }
69 $this->actorRuntimeId = $in->getActorRuntimeId();
71 $this->updateType = OverrideUpdateType::fromPacket($in->
getByte());
72 if($this->updateType === OverrideUpdateType::SET_INT_OVERRIDE){
73 $this->intOverrideValue = $in->
getLInt();
74 }elseif($this->updateType === OverrideUpdateType::SET_FLOAT_OVERRIDE){
75 $this->floatOverrideValue = $in->
getLFloat();
80 $out->putActorRuntimeId($this->actorRuntimeId);
82 $out->putByte($this->updateType->value);
83 if($this->updateType === OverrideUpdateType::SET_INT_OVERRIDE){
84 if($this->intOverrideValue === null){
85 throw new \LogicException(
"PlayerUpdateEntityOverridesPacket with type SET_INT_OVERRIDE require an intOverrideValue to be provided");
87 $out->putLInt($this->intOverrideValue);
88 }elseif($this->updateType === OverrideUpdateType::SET_FLOAT_OVERRIDE){
89 if($this->floatOverrideValue ===
null){
90 throw new \LogicException(
"PlayerUpdateEntityOverridesPacket with type SET_INT_OVERRIDE require an intOverrideValue to be provided");
92 $out->putLFloat($this->floatOverrideValue);
97 return $handler->handlePlayerUpdateEntityOverridesPacket($this);