26 public const NETWORK_ID = ProtocolInfo::PLAYER_UPDATE_ENTITY_OVERRIDES_PACKET;
28 private int $actorRuntimeId;
29 private int $propertyIndex;
30 private OverrideUpdateType $updateType;
31 private ?
int $intOverrideValue;
32 private ?
float $floatOverrideValue;
37 private static function create(
int $actorRuntimeId,
int $propertyIndex, OverrideUpdateType $updateType, ?
int $intOverrideValue, ?
float $floatOverrideValue) :
self{
39 $result->actorRuntimeId = $actorRuntimeId;
40 $result->propertyIndex = $propertyIndex;
41 $result->updateType = $updateType;
42 $result->intOverrideValue = $intOverrideValue;
43 $result->floatOverrideValue = $floatOverrideValue;
47 public static function createIntOverride(
int $actorRuntimeId,
int $propertyIndex,
int $value) :
self{
48 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::SET_INT_OVERRIDE, $value,
null);
51 public static function createFloatOverride(
int $actorRuntimeId,
int $propertyIndex,
float $value) :
self{
52 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::SET_FLOAT_OVERRIDE,
null, $value);
55 public static function createClearOverrides(
int $actorRuntimeId,
int $propertyIndex) :
self{
56 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::CLEAR_OVERRIDES,
null,
null);
59 public static function createRemoveOverride(
int $actorRuntimeId,
int $propertyIndex) :
self{
60 return self::create($actorRuntimeId, $propertyIndex, OverrideUpdateType::REMOVE_OVERRIDE,
null,
null);
63 public function getActorRuntimeId() :
int{
return $this->actorRuntimeId; }
65 public function getPropertyIndex() :
int{
return $this->propertyIndex; }
67 public function getUpdateType() : OverrideUpdateType{
return $this->updateType; }
69 public function getIntOverrideValue() : ?
int{
return $this->intOverrideValue; }
71 public function getFloatOverrideValue() : ?
float{
return $this->floatOverrideValue; }
74 $this->actorRuntimeId =
CommonTypes::getActorRuntimeId($in);
75 $this->propertyIndex = VarInt::readUnsignedInt($in);
76 $this->updateType = OverrideUpdateType::fromPacket(Byte::readUnsigned($in));
77 if($this->updateType === OverrideUpdateType::SET_INT_OVERRIDE){
78 $this->intOverrideValue = LE::readSignedInt($in);
79 }elseif($this->updateType === OverrideUpdateType::SET_FLOAT_OVERRIDE){
80 $this->floatOverrideValue = LE::readFloat($in);
85 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
86 VarInt::writeUnsignedInt($out, $this->propertyIndex);
87 Byte::writeUnsigned($out, $this->updateType->value);
88 if($this->updateType === OverrideUpdateType::SET_INT_OVERRIDE){
89 if($this->intOverrideValue ===
null){
90 throw new \LogicException(
"PlayerUpdateEntityOverridesPacket with type SET_INT_OVERRIDE requires intOverrideValue to be provided");
92 LE::writeSignedInt($out, $this->intOverrideValue);
93 }elseif($this->updateType === OverrideUpdateType::SET_FLOAT_OVERRIDE){
94 if($this->floatOverrideValue ===
null){
95 throw new \LogicException(
"PlayerUpdateEntityOverridesPacket with type SET_FLOAT_OVERRIDE requires floatOverrideValue to be provided");
97 LE::writeFloat($out, $this->floatOverrideValue);
102 return $handler->handlePlayerUpdateEntityOverrides($this);