Skip to content

Commit 6a26898

Browse files
committed
Fix some inconsistencies
1 parent b32070b commit 6a26898

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+121
-121
lines changed

src/AddPlayerPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
126126
}
127127

128128
$this->deviceId = CommonTypes::getString($in);
129-
$this->buildPlatform = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
129+
$this->buildPlatform = LE::readSignedInt($in);
130130
}
131131

132132
protected function encodePayload(ByteBufferWriter $out) : void{
@@ -152,7 +152,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
152152
}
153153

154154
CommonTypes::putString($out, $this->deviceId);
155-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->buildPlatform);
155+
LE::writeSignedInt($out, $this->buildPlatform);
156156
}
157157

158158
public function handle(PacketHandlerInterface $handler) : bool{

src/AgentActionEventPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ public function getResponseJson() : string{ return $this->responseJson; }
5151

5252
protected function decodePayload(ByteBufferReader $in) : void{
5353
$this->requestId = CommonTypes::getString($in);
54-
$this->action = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
54+
$this->action = LE::readUnsignedInt($in);
5555
$this->responseJson = CommonTypes::getString($in);
5656
}
5757

5858
protected function encodePayload(ByteBufferWriter $out) : void{
5959
CommonTypes::putString($out, $this->requestId);
60-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->action);
60+
LE::writeUnsignedInt($out, $this->action);
6161
CommonTypes::putString($out, $this->responseJson);
6262
}
6363

src/AnimateEntityPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
8383
$this->animation = CommonTypes::getString($in);
8484
$this->nextState = CommonTypes::getString($in);
8585
$this->stopExpression = CommonTypes::getString($in);
86-
$this->stopExpressionVersion = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
86+
$this->stopExpressionVersion = LE::readSignedInt($in);
8787
$this->controller = CommonTypes::getString($in);
8888
$this->blendOutTime = LE::readFloat($in);
8989
$this->actorRuntimeIds = [];
@@ -96,7 +96,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
9696
CommonTypes::putString($out, $this->animation);
9797
CommonTypes::putString($out, $this->nextState);
9898
CommonTypes::putString($out, $this->stopExpression);
99-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->stopExpressionVersion);
99+
LE::writeSignedInt($out, $this->stopExpressionVersion);
100100
CommonTypes::putString($out, $this->controller);
101101
LE::writeFloat($out, $this->blendOutTime);
102102
VarInt::writeUnsignedInt($out, count($this->actorRuntimeIds));

src/AvailableCommandsPacket.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,17 @@ protected function getEnumValueIndex(int $valueCount, ByteBufferReader $in) : in
288288
}elseif($valueCount < 65536){
289289
return LE::readUnsignedShort($in);
290290
}else{
291-
return /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
291+
return LE::readUnsignedInt($in);
292292
}
293293
}
294294

295295
protected function putEnumValueIndex(int $index, int $valueCount, ByteBufferWriter $out) : void{
296296
if($valueCount < 256){
297297
Byte::writeUnsigned($out, $index);
298298
}elseif($valueCount < 65536){
299-
/* TODO: check if this should be unsigned */ LE::writeUnsignedShort($out, $index);
299+
LE::writeUnsignedShort($out, $index);
300300
}else{
301-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $index);
301+
LE::writeUnsignedInt($out, $index);
302302
}
303303
}
304304

@@ -311,11 +311,11 @@ protected function putEnumValueIndex(int $index, int $valueCount, ByteBufferWrit
311311
*/
312312
protected function getEnumConstraint(array $enums, array $enumValues, ByteBufferReader $in) : CommandEnumConstraint{
313313
//wtf, what was wrong with an offset inside the enum? :(
314-
$valueIndex = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
314+
$valueIndex = LE::readUnsignedInt($in);
315315
if(!isset($enumValues[$valueIndex])){
316316
throw new PacketDecodeException("Enum constraint refers to unknown enum value index $valueIndex");
317317
}
318-
$enumIndex = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
318+
$enumIndex = LE::readUnsignedInt($in);
319319
if(!isset($enums[$enumIndex])){
320320
throw new PacketDecodeException("Enum constraint refers to unknown enum index $enumIndex");
321321
}
@@ -338,8 +338,8 @@ protected function getEnumConstraint(array $enums, array $enumValues, ByteBuffer
338338
* @param int[] $enumValueIndexes string value -> int index
339339
*/
340340
protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes, ByteBufferWriter $out) : void{
341-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $enumValueIndexes[$constraint->getAffectedValue()]);
342-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $enumIndexes[$constraint->getEnum()->getName()]);
341+
LE::writeUnsignedInt($out, $enumValueIndexes[$constraint->getAffectedValue()]);
342+
LE::writeUnsignedInt($out, $enumIndexes[$constraint->getEnum()->getName()]);
343343
VarInt::writeUnsignedInt($out, count($constraint->getConstraints()));
344344
foreach($constraint->getConstraints() as $v){
345345
Byte::writeUnsigned($out, $v);
@@ -359,7 +359,7 @@ protected function getCommandData(array $enums, array $postfixes, array $allChai
359359
$description = CommonTypes::getString($in);
360360
$flags = LE::readUnsignedShort($in);
361361
$permission = Byte::readUnsigned($in);
362-
$aliases = $enums[/* TODO: check if this should be unsigned */ LE::readSignedInt($in)] ?? null;
362+
$aliases = $enums[LE::readSignedInt($in)] ?? null;
363363

364364
$chainedSubCommandData = [];
365365
for($i = 0, $count = VarInt::readUnsignedInt($in); $i < $count; ++$i){
@@ -374,7 +374,7 @@ protected function getCommandData(array $enums, array $postfixes, array $allChai
374374
for($paramIndex = 0, $paramCount = VarInt::readUnsignedInt($in); $paramIndex < $paramCount; ++$paramIndex){
375375
$parameter = new CommandParameter();
376376
$parameter->paramName = CommonTypes::getString($in);
377-
$parameter->paramType = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
377+
$parameter->paramType = LE::readUnsignedInt($in);
378378
$parameter->isOptional = CommonTypes::getBool($in);
379379
$parameter->flags = Byte::readUnsigned($in);
380380

@@ -449,7 +449,7 @@ protected function putCommandData(CommandData $data, array $enumIndexes, array $
449449
$type = $parameter->paramType;
450450
}
451451

452-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $type);
452+
LE::writeUnsignedInt($out, $type);
453453
CommonTypes::putBool($out, $parameter->isOptional);
454454
Byte::writeUnsigned($out, $parameter->flags);
455455
}
@@ -585,8 +585,8 @@ protected function encodePayload(ByteBufferWriter $out) : void{
585585
foreach($chainedSubCommandData->getValues() as $value){
586586
$valueNameIndex = $chainedSubCommandValueNameIndexes[$value->getName()] ??
587587
throw new \LogicException("Chained subcommand value name index for \"" . $value->getName() . "\" not found (this should never happen)");
588-
/* TODO: check if this should be unsigned */ LE::writeUnsignedShort($out, $valueNameIndex);
589-
/* TODO: check if this should be unsigned */ LE::writeUnsignedShort($out, $value->getType());
588+
LE::writeUnsignedShort($out, $valueNameIndex);
589+
LE::writeUnsignedShort($out, $value->getType());
590590
}
591591
}
592592

src/AwardAchievementPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public static function create(int $achievementId) : self{
3535
public function getAchievementId() : int{ return $this->achievementId; }
3636

3737
protected function decodePayload(ByteBufferReader $in) : void{
38-
$this->achievementId = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
38+
$this->achievementId = LE::readSignedInt($in);
3939
}
4040

4141
protected function encodePayload(ByteBufferWriter $out) : void{
42-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->achievementId);
42+
LE::writeSignedInt($out, $this->achievementId);
4343
}
4444

4545
public function handle(PacketHandlerInterface $handler) : bool{

src/BossEventPacket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
168168
LE::writeFloat($out, $this->healthPercent);
169169
/** @noinspection PhpMissingBreakStatementInspection */
170170
case self::TYPE_PROPERTIES:
171-
/* TODO: check if this should be unsigned */ LE::writeUnsignedShort($out, $this->darkenScreen ? 1 : 0);
171+
LE::writeUnsignedShort($out, $this->darkenScreen ? 1 : 0);
172172
case self::TYPE_TEXTURE:
173173
VarInt::writeUnsignedInt($out, $this->color);
174174
VarInt::writeUnsignedInt($out, $this->overlay);

src/ChangeDimensionPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ protected function decodePayload(ByteBufferReader $in) : void{
4747
$this->dimension = VarInt::readSignedInt($in);
4848
$this->position = CommonTypes::getVector3($in);
4949
$this->respawn = CommonTypes::getBool($in);
50-
$this->loadingScreenId = CommonTypes::readOptional($in, fn() => /* TODO: check if this should be unsigned */ LE::readSignedInt($in));
50+
$this->loadingScreenId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
5151
}
5252

5353
protected function encodePayload(ByteBufferWriter $out) : void{
5454
VarInt::writeSignedInt($out, $this->dimension);
5555
CommonTypes::putVector3($out, $this->position);
5656
CommonTypes::putBool($out, $this->respawn);
57-
CommonTypes::writeOptional($out, $this->loadingScreenId, /* TODO: check if this should be unsigned */ LE::writeSignedInt(...));
57+
CommonTypes::writeOptional($out, $this->loadingScreenId, LE::writeUnsignedInt(...));
5858
}
5959

6060
public function handle(PacketHandlerInterface $handler) : bool{

src/CommandBlockUpdatePacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
5959
$this->name = CommonTypes::getString($in);
6060
$this->filteredName = CommonTypes::getString($in);
6161
$this->shouldTrackOutput = CommonTypes::getBool($in);
62-
$this->tickDelay = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
62+
$this->tickDelay = LE::readUnsignedInt($in);
6363
$this->executeOnFirstTick = CommonTypes::getBool($in);
6464
}
6565

@@ -80,7 +80,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
8080
CommonTypes::putString($out, $this->name);
8181
CommonTypes::putString($out, $this->filteredName);
8282
CommonTypes::putBool($out, $this->shouldTrackOutput);
83-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->tickDelay);
83+
LE::writeUnsignedInt($out, $this->tickDelay);
8484
CommonTypes::putBool($out, $this->executeOnFirstTick);
8585
}
8686

src/GuiDataPickItemPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public static function create(string $itemDescription, string $itemEffects, int
4040
protected function decodePayload(ByteBufferReader $in) : void{
4141
$this->itemDescription = CommonTypes::getString($in);
4242
$this->itemEffects = CommonTypes::getString($in);
43-
$this->hotbarSlot = /* TODO: check if this should be unsigned */ LE::readSignedInt($in);
43+
$this->hotbarSlot = LE::readSignedInt($in);
4444
}
4545

4646
protected function encodePayload(ByteBufferWriter $out) : void{
4747
CommonTypes::putString($out, $this->itemDescription);
4848
CommonTypes::putString($out, $this->itemEffects);
49-
/* TODO: check if this should be unsigned */ LE::writeSignedInt($out, $this->hotbarSlot);
49+
LE::writeSignedInt($out, $this->hotbarSlot);
5050
}
5151

5252
public function handle(PacketHandlerInterface $handler) : bool{

src/ItemRegistryPacket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
6565
VarInt::writeUnsignedInt($out, count($this->entries));
6666
foreach($this->entries as $entry){
6767
CommonTypes::putString($out, $entry->getStringId());
68-
/* TODO: check if this should be unsigned */ LE::writeUnsignedShort($out, $entry->getNumericId());
68+
LE::writeSignedShort($out, $entry->getNumericId());
6969
CommonTypes::putBool($out, $entry->isComponentBased());
7070
VarInt::writeSignedInt($out, $entry->getVersion());
7171
$out->writeByteArray($entry->getComponentNbt()->getEncodedNbt());

0 commit comments

Comments
 (0)