Beispiel #1
0
 def decode(cls, buf: Buffer) -> PlayClientSettings:
     return cls(
         buf.unpack_string(),
         buf.unpack("b"),
         buf.unpack_varint(),
         buf.unpack("?"),
         buf.unpack("B"),
         buf.unpack_varint(),
     )
Beispiel #2
0
def test_varint():
    buf = Buffer()

    buf.write(Buffer.pack_varint(0))
    buf.write(Buffer.pack_varint(1))
    buf.write(Buffer.pack_varint(3749146))

    assert buf.unpack_varint() == 0
    assert buf.unpack_varint() == 1
    assert buf.unpack_varint() == 3749146
Beispiel #3
0
 def decode(cls, buf: Buffer) -> PlayBlockPlacement:
     return cls(
         buf.unpack_varint(),
         *buf.unpack_pos(),
         buf.unpack_varint(),
         buf.unpack("f"),
         buf.unpack("f"),
         buf.unpack("f"),
         buf.unpack("?"),
     )
Beispiel #4
0
 def decode(cls, buf: Buffer) -> PlayClickWindow:
     return cls(
         buf.unpack("B"),
         buf.unpack("h"),
         buf.unpack("b"),
         buf.unpack("h"),
         buf.unpack_varint(),
         buf.unpack_slot(),
     )
Beispiel #5
0
def test_varint(var_int, error_msg):
    buf = Buffer()
    if error_msg:
        with pytest.raises(ValueError) as err:

            buf.write(Buffer.pack_varint(var_int))
            assert error_msg in str(err)
    else:
        buf.write(Buffer.pack_varint(var_int))
        assert buf.unpack_varint() == var_int
 def decode(cls, buf: Buffer) -> PlayUpdateStructureBlock:
     return cls(
         *buf.unpack_pos(),
         buf.unpack_varint(),
         buf.unpack_varint(),
         buf.unpack_string(),
         buf.unpack("b"),
         buf.unpack("b"),
         buf.unpack("b"),
         buf.unpack("b"),
         buf.unpack("b"),
         buf.unpack("b"),
         buf.unpack_varint(),
         buf.unpack_varint(),
         buf.unpack_string(),
         buf.unpack("f"),
         buf.unpack_varint(),
         buf.unpack("b"),
     )
Beispiel #7
0
 def decode(cls, buf: Buffer) -> PlayInteractEntity:
     return cls(
         buf.unpack_varint(),
         buf.unpack_varint(),
         buf.unpack_optional(buf.unpack_varint),
         buf.unpack_optional(buf.unpack_varint),
         buf.unpack_optional(buf.unpack_varint),
         buf.unpack_optional(buf.unpack_varint),
         buf.unpack("?"),
     )
Beispiel #8
0
 def decode(cls, buf: Buffer) -> LoginStart:
     return cls(buf.read(buf.unpack_varint()).decode("UTF-8"))
Beispiel #9
0
 def decode(cls, buf: Buffer) -> LoginEncryptionResponse:
     return cls(buf.read(buf.unpack_varint()),
                buf.read(buf.unpack_varint()))
Beispiel #10
0
 def decode(cls, buf: Buffer) -> PlayQueryEntityNBT:
     return cls(buf.unpack_varint(), buf.unpack_varint())
Beispiel #11
0
 def decode(cls, buf: Buffer) -> PlayEntityAction:
     return cls(buf.unpack_varint(), buf.unpack_varint(), buf.unpack_varint())
Beispiel #12
0
 def decode(cls, buf: Buffer) -> PlayUpdateCommandBlock:
     return cls(
         *buf.unpack_position(), buf.unpack_string(), buf.unpack_varint(), buf.unpack("b")
     )
Beispiel #13
0
 def decode(cls, buf: Buffer) -> PlayTabCompleteServerBound:
     return cls(buf.unpack_varint(), buf.unpack_string())
Beispiel #14
0
 def decode(cls, buf: Buffer) -> PlayQueryBlockNBT:
     return cls(buf.unpack_varint(), *buf.unpack_pos())
Beispiel #15
0
 def decode(cls, buf: Buffer) -> PlayResourcePackStatus:
     return cls(buf.unpack_varint())
Beispiel #16
0
 def decode(cls, buf: Buffer) -> PlayTeleportConfirm:
     return cls(buf.unpack_varint())
Beispiel #17
0
 def decode(cls, buf: Buffer) -> PlayPickItem:
     return cls(buf.unpack_varint())
Beispiel #18
0
 def decode(cls, buf: Buffer) -> PlayEditBook:
     return cls(buf.unpack_slot(), buf.unpack("?"), buf.unpack_varint())
Beispiel #19
0
 def decode(cls, buf: Buffer) -> PlaySetRecipeBookState:
     return cls(buf.unpack_varint(), buf.unpack("?"), buf.unpack("?"))
Beispiel #20
0
 def decode(cls, buf: Buffer) -> PlaySelectTrade:
     return cls(buf.unpack_varint())
Beispiel #21
0
 def decode(cls, buf: Buffer) -> PlaySetBeaconEffect:
     return cls(buf.unpack_varint(), buf.unpack_varint())
Beispiel #22
0
 def decode(cls, buf: Buffer) -> HandshakeHandshake:
     return cls(buf.unpack_varint(), buf.unpack_string(), buf.unpack("H"),
                buf.unpack_varint())
Beispiel #23
0
 def decode(cls, buf: Buffer) -> PlayUpdateCommandBlockMinecart:
     return cls(buf.unpack_varint(), buf.unpack_string(), buf.unpack("?"))
Beispiel #24
0
 def decode(cls, buf: Buffer) -> PlayGenerateStructure:
     return cls(*buf.unpack_pos(), buf.unpack_varint(), buf.unpack("?"))
Beispiel #25
0
 def decode(cls, buf: Buffer) -> PlayPlayerDigging:
     return cls(buf.unpack_varint(), *buf.unpack_position(), buf.unpack("b"))
Beispiel #26
0
 def decode(cls, buf: Buffer) -> PlayClientStatus:
     return cls(buf.unpack_varint())
Beispiel #27
0
 def decode(cls, buf: Buffer) -> PlayAdvancementTab:
     return cls(buf.unpack_varint(),
                (buf.unpack_varint() if buf.unpack("?") else None))
Beispiel #28
0
 def decode(cls, buf: Buffer) -> PlayAnimationServerBound:
     return cls(buf.unpack_varint())
Beispiel #29
0
 def decode(cls, buf: Buffer) -> PlayAdvancementTab:
     return cls(buf.unpack_varint(), buf.unpack_optional(buf.unpack_varint))