Some more packets maybe?

This commit is contained in:
Casey 2023-08-26 16:45:22 +03:00
parent 69a00c1a2b
commit 522814f574
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
14 changed files with 106 additions and 8 deletions

View File

@ -56,11 +56,15 @@ async def inspect_server(queue: Queue, addr: tuple[str, int]):
continue continue
case Packet51MapChunk.packet_id: case Packet51MapChunk.packet_id:
continue continue
case Packet28EntityVelocity.packet_id:
continue
case Packet31RelEntityMove.packet_id: case Packet31RelEntityMove.packet_id:
continue continue
case Packet32EntityLook.packet_id: case Packet32EntityLook.packet_id:
continue continue
case Packet33RelEntityMoveLook.packet_id: case Packet33RelEntityMoveLook.packet_id:
continue continue
case Packet73WeatherStatus.packet_id:
continue
case _: case _:
print(f"S {delta*1000:+8.1f}ms {pkt}") print(f"S {delta*1000:+8.1f}ms {pkt}")

View File

@ -65,3 +65,12 @@ from .packet22collect import Packet22Collect
from .packet9respawn import Packet9Respawn from .packet9respawn import Packet9Respawn
from .packet60explosion import Packet60Explosion from .packet60explosion import Packet60Explosion
from .packet60explosion import Packet60Explosion from .packet60explosion import Packet60Explosion
from .packet54playnoteblock import Packet54PlayNoteBlock
from .packet100openwindow import Packet100OpenWindow
from .packet130updatesign import Packet130UpdateSign
from .packet131mapdata import Packet131MapData
from .packet133openguidebook import Packet133OpenGuidebook
from .packet134itemdata import Packet134ItemData
from .packet137updateflag import Packet137UpdateFlag
from .packet139setpaintingmotive import Packet139SetPaintingMotive
from .packet141updateflag import Packet141UpdateFlag

View File

@ -1,5 +1,6 @@
from typing import Any, ClassVar, Optional, Type, Union from typing import Any, ClassVar, Optional, Type, Union
import gzip
from bta_proxy.entitydata import EntityData from bta_proxy.entitydata import EntityData
from bta_proxy.itemstack import ItemStack from bta_proxy.itemstack import ItemStack
from ..datainputstream import AsyncDataInputStream from ..datainputstream import AsyncDataInputStream
@ -144,6 +145,13 @@ class Packet:
return None return None
case "entitydata": case "entitydata":
return await EntityData.read_from(stream) return await EntityData.read_from(stream)
case "nbt":
size = await stream.read_short()
if size < 0:
raise ValueError("Received tag length is less than zero! Weird tag!")
if size == 0:
return None
return gzip.decompress(await stream.read_bytes(size))
case _: case _:
raise ValueError(f"unknown type {datatype}") raise ValueError(f"unknown type {datatype}")

View File

@ -0,0 +1,10 @@
from .base import Packet
class Packet100OpenWindow(Packet, packet_id=100):
__slots__ = ('window_id', 'inv_type', 'title', 'slots')
FIELDS = [
('window_id', 'ubyte'),
('inv_type', 'ubyte'),
('title', 'str'),
('slots', 'ubyte'),
]

View File

@ -0,0 +1,12 @@
from .base import Packet
class Packet130UpdateSign(Packet, packet_id=130):
__slots__ = ('x', 'y', 'z', 'lines', 'picture', 'color')
FIELDS = [
('x', 'int'),
('y', 'short'),
('z', 'int'),
('lines', ('list', 4, 'str')),
('picture', 'int'),
('color', 'int'),
]

View File

@ -0,0 +1,10 @@
from .base import Packet
class Packet131MapData(Packet, packet_id=131):
__slots__ = ('item', 'meta', 'size', 'data')
FIELDS = [
('item', 'short'),
('meta', 'short'),
('size', 'ubyte'),
('data', ('bytes', 'size')),
]

View File

@ -0,0 +1,7 @@
from .base import Packet
class Packet133OpenGuidebook(Packet, packet_id=133):
__slots__ = ('open',)
FIELDS = [
('open', 'bool'),
]

View File

@ -0,0 +1,8 @@
from .base import Packet
class Packet134ItemData(Packet, packet_id=134):
__slots__ = ('slot', 'data')
FIELDS = [
('slot', 'int'),
('data', 'nbt'),
]

View File

@ -0,0 +1,6 @@
from .base import Packet
class Packet137UpdateFlag(Packet, packet_id=137):
__slots__ = ()
FIELDS = [
]

View File

@ -0,0 +1,7 @@
from .base import Packet
class Packet139SetPaintingMotive(Packet, packet_id=139):
__slots__ = ('motive',)
FIELDS = [
('motive', 'int'),
]

View File

@ -2,11 +2,7 @@ from .base import Packet
import gzip import gzip
class Packet140TileEntityData(Packet, packet_id=140): class Packet140TileEntityData(Packet, packet_id=140):
__slots__ = ('size', 'data') __slots__ = ('tag',)
FIELDS = [ FIELDS = [
('size', 'short'), ('tag', 'nbt')
('data', ('bytes', 'size')),
] ]
def post_creation(self):
self.data = gzip.decompress(self.data)

View File

@ -0,0 +1,11 @@
from .base import Packet
class Packet141UpdateFlag(Packet, packet_id=141):
__slots__ = ('x', 'y', 'z', 'colors', 'items')
FIELDS = [
('x', 'int'),
('y', 'short'),
('z', 'int'),
('colors', ('bytes', 384)),
('items', ('list', 3, 'nbt')),
]

View File

@ -6,8 +6,7 @@ class Packet21PickupSpawn(Packet, packet_id=21):
('item_id', 'short'), ('item_id', 'short'),
('count', 'byte'), ('count', 'byte'),
('damage', 'short'), ('damage', 'short'),
('tag_size', 'short'), ('tag', 'nbt'),
('tag', ('bytes', 'tag_size')),
('x', 'int'), ('x', 'int'),
('y', 'int'), ('y', 'int'),
('z', 'int'), ('z', 'int'),

View File

@ -0,0 +1,11 @@
from .base import Packet
class Packet54PlayNoteBlock(Packet, packet_id=54):
__slots__ = ('x', 'y', 'z', 'instrument', 'pitch')
FIELDS = [
('x', 'int'),
('y', 'short'),
('z', 'int'),
('instrument', 'ubyte'),
('pitch', 'ubyte'),
]