@@ -542,11 +542,11 @@ public static function putRotationByte(ByteBufferWriter $out, float $rotation) :
542542 }
543543
544544 /** @throws DataDecodeException */
545- private static function readGameRule (ByteBufferReader $ in , int $ type , bool $ isPlayerModifiable , bool $ isStartGame ) : GameRule {
545+ private static function readGameRule (ByteBufferReader $ in , int $ protocolId , int $ type , bool $ isPlayerModifiable , bool $ isStartGame ) : GameRule {
546546 return match ($ type ){
547- BoolGameRule::ID => BoolGameRule::decode ($ in , $ isPlayerModifiable ),
548- IntGameRule::ID => IntGameRule::decode ($ in , $ isPlayerModifiable , $ isStartGame ),
549- FloatGameRule::ID => FloatGameRule::decode ($ in , $ isPlayerModifiable ),
547+ BoolGameRule::ID => BoolGameRule::decode ($ in , $ protocolId , $ isPlayerModifiable ),
548+ IntGameRule::ID => IntGameRule::decode ($ in , $ protocolId , $ isPlayerModifiable , $ isStartGame ),
549+ FloatGameRule::ID => FloatGameRule::decode ($ in , $ protocolId , $ isPlayerModifiable ),
550550 default => throw new PacketDecodeException ("Unknown gamerule type $ type " ),
551551 };
552552 }
@@ -560,14 +560,14 @@ private static function readGameRule(ByteBufferReader $in, int $type, bool $isPl
560560 * @throws PacketDecodeException
561561 * @throws DataDecodeException
562562 */
563- public static function getGameRules (ByteBufferReader $ in , bool $ isStartGame ) : array {
563+ public static function getGameRules (ByteBufferReader $ in , int $ protocolId , bool $ isStartGame ) : array {
564564 $ count = VarInt::readUnsignedInt ($ in );
565565 $ rules = [];
566566 for ($ i = 0 ; $ i < $ count ; ++$ i ){
567567 $ name = self ::getString ($ in );
568568 $ isPlayerModifiable = self ::getBool ($ in );
569569 $ type = VarInt::readUnsignedInt ($ in );
570- $ rules [$ name ] = self ::readGameRule ($ in , $ type , $ isPlayerModifiable , $ isStartGame );
570+ $ rules [$ name ] = self ::readGameRule ($ in , $ protocolId , $ type , $ isPlayerModifiable , $ isStartGame );
571571 }
572572
573573 return $ rules ;
@@ -579,13 +579,13 @@ public static function getGameRules(ByteBufferReader $in, bool $isStartGame) : a
579579 * @param GameRule[] $rules
580580 * @phpstan-param array<string, GameRule> $rules
581581 */
582- public static function putGameRules (ByteBufferWriter $ out , array $ rules , bool $ isStartGame ) : void {
582+ public static function putGameRules (ByteBufferWriter $ out , int $ protocolId , array $ rules , bool $ isStartGame ) : void {
583583 VarInt::writeUnsignedInt ($ out , count ($ rules ));
584584 foreach ($ rules as $ name => $ rule ){
585585 self ::putString ($ out , $ name );
586586 self ::putBool ($ out , $ rule ->isPlayerModifiable ());
587587 VarInt::writeUnsignedInt ($ out , $ rule ->getTypeId ());
588- $ rule ->encode ($ out , $ isStartGame );
588+ $ rule ->encode ($ out , $ protocolId , $ isStartGame );
589589 }
590590 }
591591
0 commit comments