feat: harder, better, faster, stronger

changed project structure: no more useless `mc` folder
refactored dispatcher: no longer weird stateful builder pattern
improved packets: don't need proto number to be created
This commit is contained in:
əlemi 2023-11-20 17:36:03 +01:00
parent 63a272858a
commit eef8bf3d26
Signed by: alemi
GPG key ID: A4895B84D311642C
230 changed files with 1598 additions and 1857 deletions

View file

@ -1,10 +1,9 @@
"""aiocraft is an asyncio-driven headless minecraft client""" """aiocraft is an asyncio-driven headless minecraft client"""
# from .client import Client from .client import AbstractMinecraftClient
from .mc import * # TODO move mc out of mc from .server import AbstractMinecraftServer
from .client import MinecraftClient from .types import *
from .server import MinecraftServer from .auth import MicrosoftAuthenticator, MojangAuthenticator
from .mc.auth import MicrosoftAuthenticator, MojangAuthenticator
from .aiocraft import * # This is needed for PyO3 functions! No clue why or how... from .aiocraft import * # This is needed for PyO3 functions! No clue why or how...

View file

@ -6,7 +6,7 @@ from typing import Optional, Dict, Any
import aiohttp import aiohttp
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
from ..definitions import GameProfile from ..types import GameProfile
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
@ -26,7 +26,7 @@ class AuthException(Exception):
class AuthInterface: class AuthInterface:
accessToken : str accessToken : str
selectedProfile : GameProfile selectedProfile : GameProfile
session_server_override : str session_server_override : str | None = None
SESSION_SERVER = "https://sessionserver.mojang.com/session/minecraft" SESSION_SERVER = "https://sessionserver.mojang.com/session/minecraft"
TIMEOUT = aiohttp.ClientTimeout(total=3) TIMEOUT = aiohttp.ClientTimeout(total=3)

View file

@ -1,14 +1,9 @@
import re
import uuid
import logging import logging
from urllib.parse import urlencode from urllib.parse import urlencode
from typing import Dict, List, Optional, Any from typing import Any
from yarl import URL from ..types import GameProfile
import aiohttp
from ..definitions import GameProfile
from .interface import AuthInterface, AuthException from .interface import AuthInterface, AuthException
class InvalidStateError(Exception): class InvalidStateError(Exception):
@ -18,11 +13,11 @@ class MicrosoftAuthenticator(AuthInterface):
client_id : str client_id : str
client_secret : str client_secret : str
redirect_uri : str redirect_uri : str
code : Optional[str] code : str | None
accessToken : str accessToken : str
selectedProfile : GameProfile selectedProfile : GameProfile
refreshToken : Optional[str] refreshToken : str | None
MINECRAFT_CLIENT_ID = "00000000402b5328" MINECRAFT_CLIENT_ID = "00000000402b5328"
OAUTH_LOGIN = "https://login.live.com/oauth20" OAUTH_LOGIN = "https://login.live.com/oauth20"
@ -34,7 +29,7 @@ class MicrosoftAuthenticator(AuthInterface):
client_id:str, client_id:str,
client_secret:str, client_secret:str,
redirect_uri:str="http://localhost", redirect_uri:str="http://localhost",
code:Optional[str]=None code:str|None = None
): ):
self.client_id = client_id self.client_id = client_id
self.client_secret = client_secret self.client_secret = client_secret
@ -44,14 +39,14 @@ class MicrosoftAuthenticator(AuthInterface):
self.accessToken = '' self.accessToken = ''
self.selectedProfile = GameProfile(id='', name='') self.selectedProfile = GameProfile(id='', name='')
def serialize(self) -> Dict[str, Any]: def serialize(self) -> dict[str, Any]:
return { return {
'accessToken': self.accessToken, 'accessToken': self.accessToken,
'refreshToken': self.refreshToken, 'refreshToken': self.refreshToken,
'selectedProfile': self.selectedProfile.serialize(), 'selectedProfile': self.selectedProfile.serialize(),
} }
def deserialize(self, data:Dict[str, Any]): def deserialize(self, data:dict[str, Any]):
self.accessToken = data['accessToken'] self.accessToken = data['accessToken']
self.refreshToken = data['refreshToken'] self.refreshToken = data['refreshToken']
self.selectedProfile = GameProfile(**data['selectedProfile']) self.selectedProfile = GameProfile(**data['selectedProfile'])
@ -65,9 +60,9 @@ class MicrosoftAuthenticator(AuthInterface):
return ( return (
self.OAUTH_LOGIN + "_authorize.srf" + self.OAUTH_LOGIN + "_authorize.srf" +
f"?client_id={self.client_id}" + f"?client_id={self.client_id}" +
f"&response_type=code" + "&response_type=code" +
f"&redirect_uri={self.redirect_uri}" + f"&redirect_uri={self.redirect_uri}" +
f"&scope=XboxLive.signin%20offline_access" + "&scope=XboxLive.signin%20offline_access" +
f"&state={state}" f"&state={state}"
) )
@ -181,7 +176,7 @@ class MicrosoftAuthenticator(AuthInterface):
) )
return auth_response['access_token'] return auth_response['access_token']
async def fetch_mcstore(self) -> Dict[str, Any]: async def fetch_mcstore(self) -> dict[str, Any]:
"""Get the store information""" """Get the store information"""
logging.debug("Fetching MC Store") logging.debug("Fetching MC Store")
return await self._get( return await self._get(
@ -189,7 +184,7 @@ class MicrosoftAuthenticator(AuthInterface):
headers={ "Authorization": f"Bearer {self.accessToken}" }, headers={ "Authorization": f"Bearer {self.accessToken}" },
) )
async def fetch_profile(self) -> Dict[str, Any]: async def fetch_profile(self) -> dict[str, Any]:
"""Get player profile""" """Get player profile"""
logging.debug("Fetching profile") logging.debug("Fetching profile")
return await self._get( return await self._get(

View file

@ -7,17 +7,14 @@ from typing import Optional, Dict, Any
from .interface import AuthInterface, AuthException from .interface import AuthInterface, AuthException
from ..definitions import GameProfile from ..types import GameProfile
@dataclass @dataclass
class MojangAuthenticator(AuthInterface): class MojangAuthenticator(AuthInterface):
#selectedProfile : GameProfile
#accessToken : str
#session_server_override : str
username : str username : str
password : Optional[str] password : Optional[str]
clientToken : str clientToken : str
auth_server_override : str auth_server_override : str | None = None
AGENT_NAME = "Minecraft" AGENT_NAME = "Minecraft"
AGENT_VERSION = 1 AGENT_VERSION = 1

View file

@ -1,78 +1,74 @@
import asyncio
import logging import logging
import json import json
import uuid
from dataclasses import dataclass
from asyncio import Task from asyncio import Task
from enum import Enum
from time import time from time import time
from typing import Dict, List, Callable, Type, Optional, Tuple, AsyncIterator, Any, Set from typing import Any, Type
import dns.resolver import dns.resolver
from .dispatcher import Dispatcher from .dispatcher import Dispatcher
from .mc.packet import Packet from .auth import AuthInterface, AuthException
from .mc.auth import AuthInterface, AuthException, MojangAuthenticator, MicrosoftAuthenticator from .types import ConnectionState
from .mc.definitions import Dimension, Difficulty, Gamemode, ConnectionState from .packet import Packet
from .mc.proto.status.serverbound import PacketPing, PacketPingStart from .proto.status.serverbound import PacketPing, PacketPingStart
from .mc.proto.status.clientbound import PacketServerInfo, PacketPing as PacketPong from .proto.status.clientbound import PacketServerInfo, PacketPing as PacketPong
from .mc.proto.handshaking.serverbound import PacketSetProtocol from .proto.handshaking.serverbound import PacketSetProtocol
from .mc.proto.play.serverbound import PacketKeepAlive as PacketKeepAliveResponse from .proto.play.serverbound import PacketKeepAlive as PacketKeepAliveResponse
from .mc.proto.play.clientbound import PacketKeepAlive, PacketSetCompression, PacketKickDisconnect from .proto.play.clientbound import PacketKeepAlive, PacketSetCompression, PacketKickDisconnect
from .mc.proto.login.serverbound import PacketLoginStart, PacketEncryptionBegin as PacketEncryptionResponse from .proto.login.serverbound import PacketLoginStart, PacketEncryptionBegin as PacketEncryptionResponse
from .mc.proto.login.clientbound import ( from .proto.login.clientbound import (
PacketCompress, PacketDisconnect, PacketEncryptionBegin, PacketLoginPluginRequest, PacketSuccess PacketCompress, PacketDisconnect, PacketEncryptionBegin, PacketLoginPluginRequest, PacketSuccess
) )
from .util import encryption, helpers from .util import encryption, helpers
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class MinecraftClient: class AbstractMinecraftClient:
online_mode: bool online_mode: bool
authenticator: AuthInterface authenticator: AuthInterface
dispatcher : Dispatcher
logger: logging.Logger logger: logging.Logger
_dispatcher: Dispatcher | None
_authenticated: bool _authenticated: bool
_processing: bool _processing: bool
_worker: Task _worker: Task
def __init__( def __init__(
self, self,
server:str,
authenticator:AuthInterface, authenticator:AuthInterface,
online_mode:bool = True, online_mode:bool = True,
force_port:int = 0,
resolve_srv:bool = True,
): ):
self.logger = LOGGER.getChild(f"on({server})") self.logger = LOGGER.getChild(f"as({authenticator.selectedProfile.name})")
self.online_mode = online_mode self.online_mode = online_mode
self.authenticator = authenticator self.authenticator = authenticator
self._authenticated = False self._authenticated = False
self._processing = False self._processing = False
self._dispatcher = None
host = server def resolve_srv(self, server: str) -> tuple[str, int]:
port = force_port or 25565
if resolve_srv:
try: try:
answ = dns.resolver.resolve(f"_minecraft._tcp.{server}", "SRV") answ = dns.resolver.resolve(f"_minecraft._tcp.{server}", "SRV")
# TODO can we just use the 1st record? # TODO can we just use the 1st record?
host = str(answ[0].target).rstrip('.') host = str(answ[0].target).rstrip('.')
port = answ[0].port port = answ[0].port
return (host, port)
except Exception: # TODO what can I catch? dns.resolver.exception doesn't always exist, wtf except Exception: # TODO what can I catch? dns.resolver.exception doesn't always exist, wtf
self.logger.warning("Failed resolving SRV record for '%s'", server) self.logger.warning("Failed resolving SRV record for '%s'", server)
return (server, 25565)
self.dispatcher = Dispatcher().set_host(host, port)
@property @property
def connected(self) -> bool: def connected(self) -> bool:
return self.dispatcher.connected return self._dispatcher is not None and self.dispatcher.connected
async def write(self, packet:Packet, wait:bool=False): @property
# TODO get rid of this, too many ways to do one thing... def dispatcher(self) -> Dispatcher:
await self.dispatcher.write(packet, wait) # This is a weird fix to avoid asserting dispatcher is not None in all handlers:
# if i'm receiving a packet callback dispatcher is very likely not None, if I received
# a callback and it's None it's because client is stopping so an exc is ok
if self._dispatcher is None:
raise ValueError("Invalid state: connect first")
return self._dispatcher
async def authenticate(self): async def authenticate(self):
if self._authenticated: if self._authenticated:
@ -90,46 +86,78 @@ class MinecraftClient:
self.logger.info("Logged in") self.logger.info("Logged in")
self._authenticated = True self._authenticated = True
async def info(self, host:str="", port:int=0, proto:int=0, ping:bool=False) -> Dict[str, Any]: async def info(
self,
host:str,
port:int=0,
proto:int=0,
ping:bool=False,
log_ignored_packets:bool=False,
whitelist: set[Type[Packet]] = set(),
) -> dict[str, Any]:
"""Make a mini connection to asses server status and version""" """Make a mini connection to asses server status and version"""
if not port:
host, port = self.resolve_srv(host)
self._dispatcher = Dispatcher(
host=host,
port=port,
proto=proto,
log_ignored_packets=log_ignored_packets,
whitelist=whitelist
)
try: try:
await self.dispatcher.set_host(host, port).connect() await self.dispatcher.connect()
await self._handshake(ConnectionState.STATUS) await self._handshake(ConnectionState.STATUS)
return await self._status(ping) return await self._status(ping)
finally: finally:
if self.dispatcher.connected: if self.dispatcher.connected:
await self.dispatcher.disconnect() await self.dispatcher.disconnect()
self._dispatcher = None
async def join(self, host:str="", port:int=0, proto:int=0): async def join(
self,
host:str,
port:int=0,
proto:int=0,
log_ignored_packets:bool=False,
whitelist: set[Type[Packet]]=set(),
):
if not port:
host, port = self.resolve_srv(host)
self._dispatcher = Dispatcher(
host=host,
port=port,
proto=proto,
log_ignored_packets=log_ignored_packets,
whitelist=whitelist,
)
if self.online_mode: if self.online_mode:
await self.authenticate() await self.authenticate()
try: try:
await self.dispatcher.set_host(host, port).set_proto(proto).connect() await self.dispatcher.connect()
await self._handshake(ConnectionState.LOGIN) await self._handshake(ConnectionState.LOGIN)
if await self._login(): if await self._login():
await self._play() await self._play()
finally: finally:
if self.dispatcher.connected: if self.dispatcher.connected:
await self.dispatcher.disconnect() await self.dispatcher.disconnect()
self._dispatcher = None
async def _handshake(self, state:ConnectionState): async def _handshake(self, state:ConnectionState):
await self.dispatcher.write( await self.dispatcher.write(
PacketSetProtocol( PacketSetProtocol(
self.dispatcher._proto, protocolVersion=self.dispatcher.proto,
protocolVersion=self.dispatcher._proto, serverHost=self.dispatcher.host,
serverHost=self.dispatcher._host, serverPort=self.dispatcher.port,
serverPort=self.dispatcher._port,
nextState=state.value nextState=state.value
) )
) )
async def _status(self, ping:bool=False) -> Dict[str, Any]: async def _status(self, ping:bool=False) -> dict[str, Any]:
self.dispatcher.state = ConnectionState.STATUS self.dispatcher.promote(ConnectionState.STATUS)
await self.dispatcher.write( await self.dispatcher.write(PacketPingStart()) #empty packet
PacketPingStart(self.dispatcher._proto) #empty packet
)
#Response #Response
data : Dict[str, Any] = {} data : dict[str, Any] = {}
ping_id : int = 0 ping_id : int = 0
ping_time : float = 0 ping_time : float = 0
async for packet in self.dispatcher.packets(): async for packet in self.dispatcher.packets():
@ -141,10 +169,7 @@ class MinecraftClient:
ping_id = int(time()) ping_id = int(time())
ping_time = time() ping_time = time()
await self.dispatcher.write( await self.dispatcher.write(
PacketPing( PacketPing(time=ping_id)
self.dispatcher._proto,
time=ping_id,
)
) )
if isinstance(packet, PacketPong): if isinstance(packet, PacketPong):
if packet.time == ping_id: if packet.time == ping_id:
@ -153,12 +178,9 @@ class MinecraftClient:
return data return data
async def _login(self) -> bool: async def _login(self) -> bool:
self.dispatcher.state = ConnectionState.LOGIN self.dispatcher.promote(ConnectionState.LOGIN)
await self.dispatcher.write( await self.dispatcher.write(
PacketLoginStart( PacketLoginStart(username=self.authenticator.selectedProfile.name)
self.dispatcher._proto,
username=self.authenticator.selectedProfile.name
)
) )
async for packet in self.dispatcher.packets(): async for packet in self.dispatcher.packets():
if isinstance(packet, PacketEncryptionBegin): if isinstance(packet, PacketEncryptionBegin):
@ -187,7 +209,6 @@ class MinecraftClient:
else: else:
self.logger.warning("Server gave an offline-mode serverId but still requested Encryption") self.logger.warning("Server gave an offline-mode serverId but still requested Encryption")
encryption_response = PacketEncryptionResponse( encryption_response = PacketEncryptionResponse(
self.dispatcher._proto,
sharedSecret=encrypted_secret, sharedSecret=encrypted_secret,
verifyToken=token verifyToken=token
) )
@ -207,7 +228,7 @@ class MinecraftClient:
return False return False
async def _play(self): async def _play(self):
self.dispatcher.state = ConnectionState.PLAY self.dispatcher.promote(ConnectionState.PLAY)
async for packet in self.dispatcher.packets(): async for packet in self.dispatcher.packets():
self.logger.debug("[ * ] Processing %s", packet.__class__.__name__) self.logger.debug("[ * ] Processing %s", packet.__class__.__name__)
if isinstance(packet, PacketSetCompression): if isinstance(packet, PacketSetCompression):

View file

@ -1,19 +1,18 @@
import io import io
import asyncio import asyncio
import contextlib
import zlib import zlib
import logging import logging
from typing import Type, AsyncIterator
from asyncio import StreamReader, StreamWriter, Queue, Task from asyncio import StreamReader, StreamWriter, Queue, Task
from enum import Enum
from typing import List, Dict, Set, Optional, AsyncIterator, Type, Union
from types import ModuleType from types import ModuleType
from cryptography.hazmat.primitives.ciphers import CipherContext from cryptography.hazmat.primitives.ciphers import CipherContext
from .mc import proto as minecraft_protocol from . import proto as minecraft_protocol
from .mc.types import VarInt, Context from .primitives import VarInt, Context
from .mc.packet import Packet from .packet import Packet
from .mc.definitions import ConnectionState from .types import ConnectionState
from .util import encryption from .util import encryption
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
@ -29,11 +28,11 @@ class Dispatcher:
_is_server : bool # True when receiving packets from clients _is_server : bool # True when receiving packets from clients
_down : StreamReader _down : StreamReader
_reader : Optional[Task] _reader : Task | None
_decryptor : CipherContext _decryptor : CipherContext
_up : StreamWriter _up : StreamWriter
_writer : Optional[Task] _writer : Task | None
_encryptor : CipherContext _encryptor : CipherContext
_dispatching : bool _dispatching : bool
@ -41,8 +40,8 @@ class Dispatcher:
_incoming : Queue _incoming : Queue
_outgoing : Queue _outgoing : Queue
_packet_whitelist : Optional[Set[Type[Packet]]] _packet_whitelist : set[Type[Packet]] | None
_packet_id_whitelist : Optional[Set[int]] _packet_id_whitelist : set[int] | None
_log_ignored_packets : bool _log_ignored_packets : bool
@ -52,20 +51,39 @@ class Dispatcher:
_proto : int _proto : int
_encryption : bool _encryption : bool
_compression : Optional[int] _compression : int | None
state : ConnectionState # TODO make getter/setter ? state : ConnectionState # TODO make getter/setter ?
logger : logging.Logger logger : logging.Logger
def __init__(self, server:bool = False): def __init__(
self._proto = 757 self,
host:str = "localhost",
port:int = 25565,
proto:int = 757,
compression_threshold: int | None = None,
server:bool = False,
log_ignored_packets: bool = False,
whitelist: set[Type[Packet]] = set(),
):
self._proto = proto
self._host = host
self._port = port
self._compression = compression_threshold
self._is_server = server self._is_server = server
self._host = "localhost"
self._port = 25565
self._dispatching = False self._dispatching = False
self._packet_whitelist = None self._packet_whitelist = None
self._packet_id_whitelist = None self._packet_id_whitelist = None
self._log_ignored_packets = False self._log_ignored_packets = log_ignored_packets
self._packet_whitelist = set(whitelist) if whitelist is not None else None
if self._packet_whitelist:
self._packet_whitelist.add(minecraft_protocol.play.clientbound.PacketKeepAlive)
self._packet_whitelist.add(minecraft_protocol.play.clientbound.PacketKickDisconnect)
self._packet_id_whitelist = set((P().for_proto(self.proto) for P in self._packet_whitelist)) if self._packet_whitelist else None
def promote(self, next_state:ConnectionState):
# change dispatcher state
self.state = next_state
@property @property
def proto(self) -> int: def proto(self) -> int:
@ -84,7 +102,7 @@ class Dispatcher:
return self._encryption return self._encryption
@property @property
def compression(self) -> Optional[int]: def compression(self) -> int | None:
return self._compression return self._compression
@property @property
@ -112,7 +130,7 @@ class Dispatcher:
except asyncio.TimeoutError: except asyncio.TimeoutError:
pass # so we recheck self.connected pass # so we recheck self.connected
def encrypt(self, secret:Optional[bytes]=None) -> 'Dispatcher': def encrypt(self, secret: bytes | None = None):
if secret is not None: if secret is not None:
cipher = encryption.create_AES_cipher(secret) cipher = encryption.create_AES_cipher(secret)
self._encryptor = cipher.encryptor() self._encryptor = cipher.encryptor()
@ -122,52 +140,20 @@ class Dispatcher:
else: else:
self._encryption = False self._encryption = False
self.logger.info("Encryption disabled") self.logger.info("Encryption disabled")
return self
def whitelist(self, ids:Optional[List[Type[Packet]]]) -> 'Dispatcher': def update_compression_threshold(self, threshold: int | None):
self._packet_whitelist = set(ids) if ids is not None else None self._compression = threshold or 0
if self._packet_whitelist:
self._packet_whitelist.add(minecraft_protocol.play.clientbound.PacketKeepAlive)
self._packet_whitelist.add(minecraft_protocol.play.clientbound.PacketKickDisconnect)
self._packet_id_whitelist = set((P(self._proto).id for P in self._packet_whitelist)) if self._packet_whitelist else None
return self
def set_host(
self,
host:Optional[str]="",
port:Optional[int]=0,
) -> 'Dispatcher':
self._host = host or self._host
self._port = port or self._port
self.logger = LOGGER.getChild(f"on({self._host}:{self._port})")
return self
def set_proto(self, proto:Optional[int]=757) -> 'Dispatcher':
self._proto = proto or self._proto
if self._packet_whitelist:
self._packet_id_whitelist = set((P(self._proto).id for P in self._packet_whitelist))
return self
def set_compression(self, threshold:Optional[int] = None) -> 'Dispatcher':
self._compression = threshold
return self
def set_state(self, state:Optional[ConnectionState]=ConnectionState.HANDSHAKING) -> 'Dispatcher':
self.state = state or self.state
return self
def log_ignored_packets(self, log:bool) -> 'Dispatcher':
self._log_ignored_packets = log
return self
async def connect(self, async def connect(self,
reader : Optional[StreamReader] = None, reader : StreamReader | None = None,
writer : Optional[StreamWriter] = None, writer : StreamWriter | None = None,
queue_size : int = 100, queue_size : int = 100,
) -> 'Dispatcher': ):
if self.connected: if self.connected:
raise InvalidState("Dispatcher already connected") raise InvalidState("Dispatcher already connected")
self.logger = LOGGER.getChild(f"on({self._host}:{self._port})")
self._encryption = False self._encryption = False
self._compression = None self._compression = None
self._incoming = Queue(queue_size) self._incoming = Queue(queue_size)
@ -191,7 +177,7 @@ class Dispatcher:
self.logger.info("Connected") self.logger.info("Connected")
return self return self
async def disconnect(self, block:bool=True) -> 'Dispatcher': async def disconnect(self, block:bool=True):
self._dispatching = False self._dispatching = False
if block and self._writer and self._reader: if block and self._writer and self._reader:
await asyncio.gather(self._writer, self._reader) await asyncio.gather(self._writer, self._reader)
@ -314,7 +300,7 @@ class Dispatcher:
self.logger.debug("%s", buffer.getvalue()) self.logger.debug("%s", buffer.getvalue())
await self.disconnect(block=False) await self.disconnect(block=False)
async def _up_worker(self, timeout=1): async def _up_worker(self, timeout:float = 1.):
while self._dispatching: while self._dispatching:
try: try:
packet : Packet = await asyncio.wait_for(self._outgoing.get(), timeout=timeout) packet : Packet = await asyncio.wait_for(self._outgoing.get(), timeout=timeout)
@ -325,7 +311,7 @@ class Dispatcher:
return return
try: try:
buffer = packet.serialize() buffer = packet.serialize(self.proto)
length = len(buffer.getvalue()) # ewww TODO length = len(buffer.getvalue()) # ewww TODO
if self._compression is not None: if self._compression is not None:

View file

@ -1,2 +0,0 @@
from .packet import Packet
from .definitions import *

View file

@ -1,275 +0,0 @@
import io
import math
import logging
import struct
from typing import Dict, Tuple, Any, Optional, Iterable, List
import numpy as np
from aiocraft.mc.types import VarInt, Short, UnsignedByte, UnsignedLong, Type, Context
def bit_pack(data:Iterable[int], bits:int, size:int=64):
if size <= bits:
raise ValueError("Cannot pack into chunks smaller than bits per block")
out : List[int] = []
cursor = 0
buffer = 0
for el in data:
if cursor + bits > size:
delta = (cursor+bits) - size
buffer |= (el & (2**(bits-delta) - 1)) << cursor
out.append(buffer)
buffer = 0 | (( el >> (bits-delta) ) & (2**(delta) - 1))
cursor = delta
else:
buffer |= (el & (2**bits - 1)) << cursor
cursor += bits
return out
class BitStream:
data : bytes
cursor : int
size : int
def __init__(self, data:bytes, size:int):
self.data = data
self.cursor = 0
self.size = size if size > 0 else len(self.data) * 8
def __len__(self) -> int:
return self.size - self.cursor
def read(self, size:int) -> int:
if len(self) < size:
raise ValueError(f"Not enough bits ({len(self)} left, {size} requested)")
# Calculate splice indexes
start_byte = math.floor(self.cursor / 8)
end_byte = math.ceil((self.cursor + size) / 8)
# Construct int from bytes
buf = 0
delta = end_byte-start_byte
fmt = f">{delta}B" # TODO endianness doesn't seem to matter?
unpacked = struct.unpack(fmt, self.data[start_byte:end_byte])
for (i, x) in enumerate(unpacked):
# buf |= (x << (8 * (len(unpacked) - (i + 1))))
buf |= (x << (8 * i))
# Trim extra bits
# offset = self.cursor % 8 # start
offset = (8*delta) - ((self.cursor + size) % (8 * delta)) # end
if offset > 0:
buf = buf >> offset # There's an extra 1 to the left in air, maybe shift 1 bit less?
buf = buf & ((1 << size) - 1)
# Increment and return
self.cursor += size
return buf
class PalettedContainer(Type):
"""
block_data = [ UnsignedLong.read(buf) for _ in range(container_size) ]
for y in range(self.size):
for z in range(self.size):
for x in range(self.size):
i = x + ((y * 16) + z) * 16
start_long = (i * bits) // 64
start_offset = (i * bits) % 64
end_long = ((i + 1) * bits - 1) // 64
if start_long == end_long:
block = (block_data[start_long] >> start_offset) & max_val
else:
end_offset = 64 - start_offset
block = (block_data[start_long] >> start_offset |
block_data[end_long] << end_offset) & max_val
"""
pytype : type
threshold : int
size : int
def __init__(self, threshold:int, size:int):
self.threshold = threshold
self.size = size
def write(self, data, buffer:io.BytesIO, ctx:Context):
# TODO attempt to make a palette rather than sending always 13
UnsignedByte.write(13, buffer, ctx=ctx) # 13 bits per block
VarInt.write(0, buffer, ctx=ctx) # 0 palette len
for c in bit_pack(blocks, 13, 8*8): # FIXME add generator to iter blocks? idk
UnsignedLong.write(c, buffer, ctx=ctx)
def read(self, buffer:io.BytesIO, ctx:Context):
bits = UnsignedByte.read(buffer, ctx=ctx) # FIXME if bits > 4 it reads trash
#logging.debug("[%d|%d@%d] Bits per block : %d", ctx.x, ctx.z, ctx.sec, bits)
if bits < 4:
bits = 4
if bits >= self.threshold:
bits = 13 # this should not be hardcoded but we have no way to calculate all possible block states
palette_len = VarInt.read(buffer, ctx=ctx)
palette = np.zeros((palette_len,), dtype='int32')
for i in range(palette_len):
palette[i] = VarInt.read(buffer, ctx=ctx)
# logging.debug("[%d|%d@%d] Palette section : [%d] %s", ctx.x, ctx.z, ctx.sec, palette_len, str(palette))
container_size = VarInt.read(buffer, ctx=ctx)
section = np.zeros((self.size, self.size, self.size), dtype='int32')
stream = BitStream(buffer.read(container_size * 8), container_size*8*8) # a Long is 64 bits long
# logging.debug("[%d|%d@%d] Buffer : %s", ctx.x, ctx.z, ctx.sec, stream.data)
for y in range(self.size):
for z in range(self.size):
for x in range(self.size):
val = stream.read(bits)
if val >= len(palette):
logging.warning("out of bounds : %d (%d)", val, len(palette)) # FIXME happens a lot!
section[x, y, z] = val
continue
section[x, y, z] = palette[val] if bits < self.threshold else val
return section
BiomeContainer = PalettedContainer(4, 4)
BlockStateContainer = PalettedContainer(9, 16)
class HalfByteArrayType(Type):
size : int
def __init__(self, size:int):
self.size = size
def write(self, data:np.ndarray, buffer:io.BytesIO, ctx:Context):
if data.shape != (self.size, self.size, self.size):
raise ValueError(f"Array must be of shape {str((self.size, self.size, self.size))}")
alternating = False
val = 0
for y in range(self.size):
for z in range(self.size):
for x in range(self.size):
if alternating:
val |= (data[x, y, z] & 0xF)
buffer.write(struct.pack("B", val)) # FIXME this format is probably wrong
else:
val |= (data[x, y, z] & 0xF) << 4
alternating = not alternating
def read(self, buffer:io.BytesIO, ctx:Context):
section = np.empty((self.size, self.size, self.size), dtype='int32')
bit_buffer = BitStream(buffer.read((self.size**3)//2), (self.size**3)*4)
for y in range(self.size):
for z in range(self.size):
for x in range(self.size):
section[x, y, z] = bit_buffer.read(4)
return section
BlockLightSection = HalfByteArrayType(16)
SkyLightSection = HalfByteArrayType(16)
class NewChunkSectionType(Type):
pytype : type
def write(self, data, buffer:io.BytesIO, ctx:Context):
raise NotImplementedError
def read(self, buffer:io.BytesIO, ctx:Context):
block_count = Short.read(buffer, ctx=ctx)
block_states = BlockStateContainer.read(buffer, ctx=ctx)
biomes = BiomeContainer.read(buffer, ctx=ctx)
return (
block_count,
block_states,
biomes
)
class OldChunkSectionType(Type):
pytype : type
def write(self, data:Tuple[np.ndarray, np.ndarray, np.ndarray], buffer:io.BytesIO, ctx:Context):
BlockStateContainer.write(data[0], buffer, ctx=ctx)
BlockLightSection.write(data[1], buffer, ctx=ctx)
if ctx.overworld:
SkyLightSection.write(data[2], buffer, ctx=ctx)
def read(self, buffer:io.BytesIO, ctx:Context):
block_states = BlockStateContainer.read(buffer, ctx=ctx)
block_light = BlockLightSection.read(buffer, ctx=ctx)
if ctx.overworld:
sky_light = SkyLightSection.read(buffer, ctx=ctx)
else:
sky_light = np.empty((16, 16, 16), dtype='int32')
return (
block_states,
block_light,
sky_light
)
ChunkSection = OldChunkSectionType()
class Chunk(Type):
x : int
z : int
bitmask : int
ground_up_continuous : bool
blocks : np.ndarray
block_light : np.ndarray
sky_light : np.ndarray
biomes: bytes
def __init__(self, x:int, z:int, bitmask:int, ground_up_continuous:bool):
self.x = x
self.z = z
self.bitmask = bitmask
self.blocks = np.zeros((16, 256, 16), dtype='int32')
self.block_light = np.zeros((16, 256, 16), dtype='int32')
self.sky_light = np.zeros((16, 256, 16), dtype='int32')
self.ground_up_continuous = ground_up_continuous
def __getitem__(self, item:Any):
return self.blocks[item]
def merge(self, other:'Chunk'):
for i in range(16):
if not ((self.bitmask >> i) & 1):
self.blocks[:, i*16 : (i+1)*16, :] = other.blocks[:, i*16 : (i+1)*16, :]
self.block_light[:, i*16 : (i+1)*16, :] = other.block_light[:, i*16 : (i+1)*16, :]
self.sky_light[:, i*16 : (i+1)*16, :] = other.sky_light[:, i*16 : (i+1)*16, :]
def read(self, buffer:io.BytesIO, ctx:Context):
ctx.x = self.x
ctx.z = self.z
for i in range(16):
if (self.bitmask >> i) & 1:
ctx.sec = i
block_states, block_light, sky_light = ChunkSection.read(buffer, ctx=ctx)
self.blocks[:, i*16 : (i+1)*16, :] = block_states
self.block_light[:, i*16 : (i+1)*16, :] = block_light
self.sky_light[:, i*16 : (i+1)*16, :] = sky_light
if self.ground_up_continuous:
self.biomes = buffer.read(256) # 16x16
if buffer.read():
logging.warning("Leftover data in chunk buffer")
return self
def write(self, data:Any, buffer:io.BytesIO, ctx:Context):
for i in range(16):
if (self.bitmask >> i) & 1:
ChunkSection.write(
(self.blocks[:, i*16 : (i+1)*16, :], self.block_light[:, i*16 : (i+1)*16, :], self.sky_light[:, i*16 : (i+1)*16, :]),
buffer,
ctx=ctx
)
pass # TODO!!
class World:
chunks : Dict[Tuple[int, int], Chunk]
def __init__(self):
self.chunks = {}
def __getitem__(self, item:Tuple[int, int, int]):
return self.get(*item)
def get(self, x:int, y:int, z:int) -> int:
coord = (x//16, z//16)
if coord not in self.chunks:
raise KeyError(f"Chunk {coord} not loaded")
return self.chunks[coord][int(x%16), int(y), int(z%16)]
def put(self, chunk:Chunk, x:int, z:int, merge:bool=False):
if merge and (x,z) in self.chunks:
chunk.merge(self.chunks[(x,z)])
self.chunks[(x,z)] = chunk

View file

@ -3,38 +3,51 @@ import json
from asyncio import Event from asyncio import Event
from typing import Tuple, List, Dict, Any from typing import Tuple, List, Dict, Any
from .types import Type, VarInt, Context from .primitives import Type, VarInt, Context
MAX_FIELD_PRINT_SIZE = 255 MAX_FIELD_PRINT_SIZE = 255
class Packet: class Packet:
__slots__ = 'id', 'definition', '_processed', '_proto', '_state' __slots__ = 'id', 'definition', '_processed', '_proto', '_state'
id : int id : int | None
definition : List[Tuple[str, Type]] definition : List[Tuple[str, Type]] | None
_processed : Event _processed : Event
_proto : int _proto : int | None
_state : int _state : int
_ids : Dict[int, int] # definitions are compiled at install time _ids : Dict[int, int] # definitions are compiled at install time
_definitions : Dict[int, List[Tuple[str, Type]]] # definitions are compiled at install time _definitions : Dict[int, List[Tuple[str, Type]]] # definitions are compiled at install time
def __init__(self, proto:int, **kwargs): def __init__(self, **kwargs):
self._proto = proto if not self._definitions:
raise NotImplementedError("cannot instantiate Packet base class")
self.id = None
self.definition = None
self._proto = None
self._processed = Event() self._processed = Event()
for k, v in kwargs.items():
setattr(self, k, v)
def for_proto(self, proto: int) -> int:
self._proto = proto
while proto not in self._definitions: while proto not in self._definitions:
proto -= 1 proto -= 1
self.definition = self._definitions[proto] self.definition = self._definitions[proto]
self.id = self._ids[proto] self.id = self._ids[proto]
for name, t in self.definition: return self.id
if name in kwargs and kwargs[name] is not None:
setattr(self, name, kwargs[name])
@property @property
def processed(self) -> Event: def processed(self) -> Event:
"""Returns an event which will be set only after the packet has been processed (either sent or raised exc)""" """Returns an event which will be set only after the packet has been processed (either sent or raised exc)"""
return self._processed return self._processed
@property
def slots(self) -> list[str]:
if self.definition is not None:
return [k for k, t in self.definition]
return [k for k in self.__slots__]
@classmethod @classmethod
def deserialize(cls, proto:int, buffer:io.BytesIO): def deserialize(cls, proto:int, buffer:io.BytesIO):
ctx = Context(_proto=proto) ctx = Context(_proto=proto)
@ -43,10 +56,13 @@ class Packet:
fallback_proto -= 1 fallback_proto -= 1
for k, t in cls._definitions[fallback_proto]: for k, t in cls._definitions[fallback_proto]:
setattr(ctx, k, t.read(buffer, ctx=ctx)) setattr(ctx, k, t.read(buffer, ctx=ctx))
return cls(proto, **ctx.serialize()) return cls(**ctx.serialize())
# return cls(proto, **{ name : t.read(buffer) for (name, t) in cls._definitions[proto] }) # return cls(proto, **{ name : t.read(buffer) for (name, t) in cls._definitions[proto] })
def serialize(self) -> io.BytesIO: def serialize(self, proto:int) -> io.BytesIO:
self.for_proto(proto) # this sets both id and definitions but mypy doesn't know...
assert self.id is not None
assert self.definition is not None
ctx = Context(_proto=self._proto) ctx = Context(_proto=self._proto)
buf = io.BytesIO() buf = io.BytesIO()
VarInt.write(self.id, buf, ctx=ctx) VarInt.write(self.id, buf, ctx=ctx)
@ -60,9 +76,11 @@ class Packet:
def __eq__(self, other) -> bool: def __eq__(self, other) -> bool:
if not isinstance(other, self.__class__): if not isinstance(other, self.__class__):
return False return False
if self._proto != other._proto: if self._proto is not None \
and other._proto is not None \
and self._proto != other._proto:
return False return False
for name, t in self.definition: for name in self.slots:
if getattr(self, name) != getattr(other, name): if getattr(self, name) != getattr(other, name):
return False return False
return True return True
@ -73,13 +91,13 @@ class Packet:
obj["_proto"] = self._proto obj["_proto"] = self._proto
obj["_state"] = self._state obj["_state"] = self._state
obj["_id"] = f"0x{self.id:02x}" obj["_id"] = f"0x{self.id:02x}"
for key, t in self.definition: for key in self.slots:
obj[key] = getattr(self, key, None) obj[key] = getattr(self, key, None)
return json.dumps(obj, indent=2, default=str) return json.dumps(obj, indent=2, default=str)
def __repr__(self) -> str: def __repr__(self) -> str:
trunc = lambda x : x if len(x) < MAX_FIELD_PRINT_SIZE else "[blob]" trunc = lambda x : x if len(x) < MAX_FIELD_PRINT_SIZE else "[blob]"
attrs = (f"{key}={trunc(repr(getattr(self, key, None)))}" for (key, t) in self.definition) attrs = (f"{key}={trunc(repr(getattr(self, key, None)))}" for key in self.slots)
return f"{self.__class__.__name__}({self._proto}, {', '.join(attrs)})" return f"{self.__class__.__name__}({self._proto}, {', '.join(attrs)})"

View file

@ -1,15 +1,14 @@
import io import io
import struct import struct
import asyncio
import json import json
import uuid import uuid
import logging import logging
import pynbt import pynbt
from typing import List, Tuple, Dict, Any, Union, Optional, Callable, Type as Class from typing import List, Tuple, Dict, Any, Union, Optional, Callable
from .definitions import Item from .types import Item
class Context: class Context:
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -390,7 +389,7 @@ class ParticleType(Type):
# TODO this changes across versions! # TODO this changes across versions!
def read(self, data:dict, buffer:io.BytesIO, ctx:Context): def read(self, data:dict, buffer:io.BytesIO, ctx:Context):
from aiocraft.mc.proto.ext import ParticlesDefinitions from aiocraft.proto.ext import ParticlesDefinitions
proto = ctx._proto proto = ctx._proto
while proto not in ParticlesDefinitions._definitions: while proto not in ParticlesDefinitions._definitions:
proto -= 1 proto -= 1
@ -414,7 +413,7 @@ class EntityMetadataType(Type):
buffer.write(b'\xFF') buffer.write(b'\xFF')
def read(self, buffer:io.BytesIO, ctx:Context) -> Dict[int, Any]: def read(self, buffer:io.BytesIO, ctx:Context) -> Dict[int, Any]:
from aiocraft.mc.proto.ext import MetadataDefinitions from aiocraft.proto.ext import MetadataDefinitions
proto = ctx._proto proto = ctx._proto
while proto not in MetadataDefinitions._definitions: while proto not in MetadataDefinitions._definitions:
proto -= 1 proto -= 1

View file

@ -1,4 +1,4 @@
from ..types import * from ..primitives import *
class MetadataDefinitions: class MetadataDefinitions:
_definitions: dict[int, dict[int, Type]] = { _definitions: dict[int, dict[int, Type]] = {
@ -68,7 +68,7 @@ class ParticlesDefinitions:
756 : {4: StructType(( 'blockState', VarInt ), ), 15: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 16: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 25: StructType(( 'blockState', VarInt ), ), 36: StructType(( 'item', Slot ), ), 37: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )}, 756 : {4: StructType(( 'blockState', VarInt ), ), 15: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 16: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 25: StructType(( 'blockState', VarInt ), ), 36: StructType(( 'item', Slot ), ), 37: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )},
757 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )}, 757 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )},
758 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )}, 758 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )},
759 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )}, 759 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 25: StructType(( 'blockState', VarInt ), ), 30: StructType(( 'rotation', Float ), ), 39: StructType(( 'item', Slot ), ), 40: StructType(( 'positionType', String ), ( 'entityId', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'entityEyeHeight', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), ), 92: StructType(( 'delayInTicksBeforeShown', VarInt ), )},
760 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )}, 760 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 25: StructType(( 'blockState', VarInt ), ), 30: StructType(( 'rotation', Float ), ), 39: StructType(( 'item', Slot ), ), 40: StructType(( 'positionType', String ), ( 'entityId', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'entityEyeHeight', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), ), 92: StructType(( 'delayInTicksBeforeShown', VarInt ), )},
761 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 24: StructType(( 'blockState', VarInt ), ), 35: StructType(( 'item', Slot ), ), 36: StructType(( 'origin', Position ), ( 'positionType', String ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), )} 761 : {2: StructType(( 'blockState', VarInt ), ), 3: StructType(( 'blockState', VarInt ), ), 14: StructType(( 'red', Float ), ( 'green', Float ), ( 'blue', Float ), ( 'scale', Float ), ), 15: StructType(( 'fromRed', Float ), ( 'fromGreen', Float ), ( 'fromBlue', Float ), ( 'scale', Float ), ( 'toRed', Float ), ( 'toGreen', Float ), ( 'toBlue', Float ), ), 25: StructType(( 'blockState', VarInt ), ), 30: StructType(( 'rotation', Float ), ), 39: StructType(( 'item', Slot ), ), 40: StructType(( 'positionType', String ), ( 'entityId', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'entityEyeHeight', SwitchType('positionType', { 'minecraft:entity' : VarInt }, None, ) ), ( 'destination', SwitchType('positionType', { 'minecraft:block' : Position, 'minecraft:entity' : VarInt }, None, ) ), ( 'ticks', VarInt ), ), 92: StructType(( 'delayInTicksBeforeShown', VarInt ), )}
} }

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketLegacyServerListPing(Packet): class PacketLegacyServerListPing(Packet):
__slots__ = ( 'id', 'payload' ) __slots__ = ( 'id', 'payload' )
payload : int payload : int
def __init__(self, proto:int, def __init__(self,
payload:int=None, payload:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
payload=payload payload=payload
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketSetProtocol(Packet): class PacketSetProtocol(Packet):
__slots__ = ( 'id', 'nextState', 'protocolVersion', 'serverHost', 'serverPort' ) __slots__ = ( 'id', 'nextState', 'protocolVersion', 'serverHost', 'serverPort' )
@ -13,14 +13,14 @@ class PacketSetProtocol(Packet):
serverHost : str serverHost : str
serverPort : int serverPort : int
def __init__(self, proto:int, def __init__(self,
nextState:int=None, nextState:int | None = None,
protocolVersion:int=None, protocolVersion:int | None = None,
serverHost:str=None, serverHost:str | None = None,
serverPort:int=None, serverPort:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
nextState=nextState, nextState=nextState,
protocolVersion=protocolVersion, protocolVersion=protocolVersion,
serverHost=serverHost, serverHost=serverHost,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCompress(Packet): class PacketCompress(Packet):
__slots__ = ( 'id', 'threshold' ) __slots__ = ( 'id', 'threshold' )
threshold : int threshold : int
def __init__(self, proto:int, def __init__(self,
threshold:int=None, threshold:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
threshold=threshold threshold=threshold
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDisconnect(Packet): class PacketDisconnect(Packet):
__slots__ = ( 'id', 'reason' ) __slots__ = ( 'id', 'reason' )
reason : str reason : str
def __init__(self, proto:int, def __init__(self,
reason:str=None, reason:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
reason=reason reason=reason
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEncryptionBegin(Packet): class PacketEncryptionBegin(Packet):
__slots__ = ( 'id', 'publicKey', 'serverId', 'verifyToken' ) __slots__ = ( 'id', 'publicKey', 'serverId', 'verifyToken' )
@ -12,13 +12,13 @@ class PacketEncryptionBegin(Packet):
serverId : str serverId : str
verifyToken : bytes verifyToken : bytes
def __init__(self, proto:int, def __init__(self,
publicKey:bytes=None, publicKey:bytes | None = None,
serverId:str=None, serverId:str | None = None,
verifyToken:bytes=None, verifyToken:bytes | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
publicKey=publicKey, publicKey=publicKey,
serverId=serverId, serverId=serverId,
verifyToken=verifyToken verifyToken=verifyToken

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketLoginPluginRequest(Packet): class PacketLoginPluginRequest(Packet):
__slots__ = ( 'id', 'channel', 'data', 'messageId' ) __slots__ = ( 'id', 'channel', 'data', 'messageId' )
@ -12,13 +12,13 @@ class PacketLoginPluginRequest(Packet):
data : bytes data : bytes
messageId : int messageId : int
def __init__(self, proto:int, def __init__(self,
channel:str=None, channel:str | None = None,
data:bytes=None, data:bytes | None = None,
messageId:int=None, messageId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
channel=channel, channel=channel,
data=data, data=data,
messageId=messageId messageId=messageId

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketSuccess(Packet): class PacketSuccess(Packet):
__slots__ = ( 'id', 'properties', 'username', 'uuid' ) __slots__ = ( 'id', 'properties', 'username', 'uuid' )
@ -12,13 +12,13 @@ class PacketSuccess(Packet):
username : str username : str
uuid : str uuid : str
def __init__(self, proto:int, def __init__(self,
properties:list=None, properties:list | None = None,
username:str=None, username:str | None = None,
uuid:str=None, uuid:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
properties=properties, properties=properties,
username=username, username=username,
uuid=uuid uuid=uuid

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEncryptionBegin(Packet): class PacketEncryptionBegin(Packet):
__slots__ = ( 'id', 'crypto', 'hasVerifyToken', 'sharedSecret', 'verifyToken' ) __slots__ = ( 'id', 'crypto', 'hasVerifyToken', 'sharedSecret', 'verifyToken' )
@ -13,14 +13,14 @@ class PacketEncryptionBegin(Packet):
sharedSecret : bytes sharedSecret : bytes
verifyToken : bytes verifyToken : bytes
def __init__(self, proto:int, def __init__(self,
crypto:Union[None, dict]=None, crypto:Union[None, dict] | None = None,
hasVerifyToken:bool=None, hasVerifyToken:bool | None = None,
sharedSecret:bytes=None, sharedSecret:bytes | None = None,
verifyToken:bytes=None, verifyToken:bytes | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
crypto=crypto, crypto=crypto,
hasVerifyToken=hasVerifyToken, hasVerifyToken=hasVerifyToken,
sharedSecret=sharedSecret, sharedSecret=sharedSecret,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketLoginPluginResponse(Packet): class PacketLoginPluginResponse(Packet):
__slots__ = ( 'id', 'data', 'messageId' ) __slots__ = ( 'id', 'data', 'messageId' )
@ -11,12 +11,12 @@ class PacketLoginPluginResponse(Packet):
data : tuple data : tuple
messageId : int messageId : int
def __init__(self, proto:int, def __init__(self,
data:tuple=None, data:tuple | None = None,
messageId:int=None, messageId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
data=data, data=data,
messageId=messageId messageId=messageId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketLoginStart(Packet): class PacketLoginStart(Packet):
__slots__ = ( 'id', 'playerUUID', 'signature', 'username' ) __slots__ = ( 'id', 'playerUUID', 'signature', 'username' )
@ -12,13 +12,13 @@ class PacketLoginStart(Packet):
signature : tuple signature : tuple
username : str username : str
def __init__(self, proto:int, def __init__(self,
playerUUID:tuple=None, playerUUID:tuple | None = None,
signature:tuple=None, signature:tuple | None = None,
username:str=None, username:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
playerUUID=playerUUID, playerUUID=playerUUID,
signature=signature, signature=signature,
username=username username=username

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAbilities(Packet): class PacketAbilities(Packet):
__slots__ = ( 'id', 'flags', 'flyingSpeed', 'walkingSpeed' ) __slots__ = ( 'id', 'flags', 'flyingSpeed', 'walkingSpeed' )
@ -12,13 +12,13 @@ class PacketAbilities(Packet):
flyingSpeed : float flyingSpeed : float
walkingSpeed : float walkingSpeed : float
def __init__(self, proto:int, def __init__(self,
flags:int=None, flags:int | None = None,
flyingSpeed:float=None, flyingSpeed:float | None = None,
walkingSpeed:float=None, walkingSpeed:float | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
flags=flags, flags=flags,
flyingSpeed=flyingSpeed, flyingSpeed=flyingSpeed,
walkingSpeed=walkingSpeed walkingSpeed=walkingSpeed

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAcknowledgePlayerDigging(Packet): class PacketAcknowledgePlayerDigging(Packet):
__slots__ = ( 'id', 'block', 'location', 'sequenceId', 'status', 'successful' ) __slots__ = ( 'id', 'block', 'location', 'sequenceId', 'status', 'successful' )
@ -14,15 +14,15 @@ class PacketAcknowledgePlayerDigging(Packet):
status : int status : int
successful : bool successful : bool
def __init__(self, proto:int, def __init__(self,
block:int=None, block:int | None = None,
location:tuple=None, location:tuple | None = None,
sequenceId:int=None, sequenceId:int | None = None,
status:int=None, status:int | None = None,
successful:bool=None, successful:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
block=block, block=block,
location=location, location=location,
sequenceId=sequenceId, sequenceId=sequenceId,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketActionBar(Packet): class PacketActionBar(Packet):
__slots__ = ( 'id', 'text' ) __slots__ = ( 'id', 'text' )
text : str text : str
def __init__(self, proto:int, def __init__(self,
text:str=None, text:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
text=text text=text
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAdvancementProgress(Packet): class PacketAdvancementProgress(Packet):
__slots__ = ( 'id', 'id' ) __slots__ = ( 'id', 'id' )
id : tuple id : tuple
def __init__(self, proto:int, def __init__(self,
id:tuple=None, id:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
id=id id=id
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAdvancements(Packet): class PacketAdvancements(Packet):
__slots__ = ( 'id', 'advancementMapping', 'identifiers', 'progressMapping', 'reset' ) __slots__ = ( 'id', 'advancementMapping', 'identifiers', 'progressMapping', 'reset' )
@ -13,14 +13,14 @@ class PacketAdvancements(Packet):
progressMapping : list progressMapping : list
reset : bool reset : bool
def __init__(self, proto:int, def __init__(self,
advancementMapping:list=None, advancementMapping:list | None = None,
identifiers:list=None, identifiers:list | None = None,
progressMapping:list=None, progressMapping:list | None = None,
reset:bool=None, reset:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
advancementMapping=advancementMapping, advancementMapping=advancementMapping,
identifiers=identifiers, identifiers=identifiers,
progressMapping=progressMapping, progressMapping=progressMapping,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAnimation(Packet): class PacketAnimation(Packet):
__slots__ = ( 'id', 'animation', 'entityId' ) __slots__ = ( 'id', 'animation', 'entityId' )
@ -11,12 +11,12 @@ class PacketAnimation(Packet):
animation : int animation : int
entityId : int entityId : int
def __init__(self, proto:int, def __init__(self,
animation:int=None, animation:int | None = None,
entityId:int=None, entityId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
animation=animation, animation=animation,
entityId=entityId entityId=entityId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketAttachEntity(Packet): class PacketAttachEntity(Packet):
__slots__ = ( 'id', 'entityId', 'leash', 'vehicleId' ) __slots__ = ( 'id', 'entityId', 'leash', 'vehicleId' )
@ -12,13 +12,13 @@ class PacketAttachEntity(Packet):
leash : bool leash : bool
vehicleId : int vehicleId : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
leash:bool=None, leash:bool | None = None,
vehicleId:int=None, vehicleId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
leash=leash, leash=leash,
vehicleId=vehicleId vehicleId=vehicleId

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketBed(Packet): class PacketBed(Packet):
__slots__ = ( 'id', 'entityId', 'location' ) __slots__ = ( 'id', 'entityId', 'location' )
@ -11,12 +11,12 @@ class PacketBed(Packet):
entityId : int entityId : int
location : tuple location : tuple
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
location:tuple=None, location:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
location=location location=location
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketBlockAction(Packet): class PacketBlockAction(Packet):
__slots__ = ( 'id', 'blockId', 'byte1', 'byte2', 'location' ) __slots__ = ( 'id', 'blockId', 'byte1', 'byte2', 'location' )
@ -13,14 +13,14 @@ class PacketBlockAction(Packet):
byte2 : int byte2 : int
location : tuple location : tuple
def __init__(self, proto:int, def __init__(self,
blockId:int=None, blockId:int | None = None,
byte1:int=None, byte1:int | None = None,
byte2:int=None, byte2:int | None = None,
location:tuple=None, location:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
blockId=blockId, blockId=blockId,
byte1=byte1, byte1=byte1,
byte2=byte2, byte2=byte2,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketBlockBreakAnimation(Packet): class PacketBlockBreakAnimation(Packet):
__slots__ = ( 'id', 'destroyStage', 'entityId', 'location' ) __slots__ = ( 'id', 'destroyStage', 'entityId', 'location' )
@ -12,13 +12,13 @@ class PacketBlockBreakAnimation(Packet):
entityId : int entityId : int
location : tuple location : tuple
def __init__(self, proto:int, def __init__(self,
destroyStage:int=None, destroyStage:int | None = None,
entityId:int=None, entityId:int | None = None,
location:tuple=None, location:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
destroyStage=destroyStage, destroyStage=destroyStage,
entityId=entityId, entityId=entityId,
location=location location=location

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketBlockChange(Packet): class PacketBlockChange(Packet):
__slots__ = ( 'id', 'location', 'type' ) __slots__ = ( 'id', 'location', 'type' )
@ -11,12 +11,12 @@ class PacketBlockChange(Packet):
location : tuple location : tuple
type : int type : int
def __init__(self, proto:int, def __init__(self,
location:tuple=None, location:tuple | None = None,
type:int=None, type:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
location=location, location=location,
type=type type=type
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketBossBar(Packet): class PacketBossBar(Packet):
__slots__ = ( 'id', 'action', 'color', 'dividers', 'entityUUID', 'flags', 'health', 'title' ) __slots__ = ( 'id', 'action', 'color', 'dividers', 'entityUUID', 'flags', 'health', 'title' )
@ -16,17 +16,17 @@ class PacketBossBar(Packet):
health : Union[None, float] health : Union[None, float]
title : Union[None, str] title : Union[None, str]
def __init__(self, proto:int, def __init__(self,
action:int=None, action:int | None = None,
color:Union[None, int]=None, color:Union[None, int] | None = None,
dividers:Union[None, int]=None, dividers:Union[None, int] | None = None,
entityUUID:str=None, entityUUID:str | None = None,
flags:Union[None, int]=None, flags:Union[None, int] | None = None,
health:Union[None, float]=None, health:Union[None, float] | None = None,
title:Union[None, str]=None, title:Union[None, str] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
action=action, action=action,
color=color, color=color,
dividers=dividers, dividers=dividers,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCamera(Packet): class PacketCamera(Packet):
__slots__ = ( 'id', 'cameraId' ) __slots__ = ( 'id', 'cameraId' )
cameraId : int cameraId : int
def __init__(self, proto:int, def __init__(self,
cameraId:int=None, cameraId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
cameraId=cameraId cameraId=cameraId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketChat(Packet): class PacketChat(Packet):
__slots__ = ( 'id', 'message', 'position', 'sender' ) __slots__ = ( 'id', 'message', 'position', 'sender' )
@ -12,13 +12,13 @@ class PacketChat(Packet):
position : int position : int
sender : str sender : str
def __init__(self, proto:int, def __init__(self,
message:str=None, message:str | None = None,
position:int=None, position:int | None = None,
sender:str=None, sender:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
message=message, message=message,
position=position, position=position,
sender=sender sender=sender

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketChatPreview(Packet): class PacketChatPreview(Packet):
__slots__ = ( 'id', 'message', 'queryId' ) __slots__ = ( 'id', 'message', 'queryId' )
@ -11,12 +11,12 @@ class PacketChatPreview(Packet):
message : tuple message : tuple
queryId : int queryId : int
def __init__(self, proto:int, def __init__(self,
message:tuple=None, message:tuple | None = None,
queryId:int=None, queryId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
message=message, message=message,
queryId=queryId queryId=queryId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketChatSuggestions(Packet): class PacketChatSuggestions(Packet):
__slots__ = ( 'id', 'action', 'entries' ) __slots__ = ( 'id', 'action', 'entries' )
@ -11,12 +11,12 @@ class PacketChatSuggestions(Packet):
action : int action : int
entries : list entries : list
def __init__(self, proto:int, def __init__(self,
action:int=None, action:int | None = None,
entries:list=None, entries:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
action=action, action=action,
entries=entries entries=entries
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketClearTitles(Packet): class PacketClearTitles(Packet):
__slots__ = ( 'id', 'reset' ) __slots__ = ( 'id', 'reset' )
reset : bool reset : bool
def __init__(self, proto:int, def __init__(self,
reset:bool=None, reset:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
reset=reset reset=reset
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCloseWindow(Packet): class PacketCloseWindow(Packet):
__slots__ = ( 'id', 'windowId' ) __slots__ = ( 'id', 'windowId' )
windowId : int windowId : int
def __init__(self, proto:int, def __init__(self,
windowId:int=None, windowId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
windowId=windowId windowId=windowId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCollect(Packet): class PacketCollect(Packet):
__slots__ = ( 'id', 'collectedEntityId', 'collectorEntityId', 'pickupItemCount' ) __slots__ = ( 'id', 'collectedEntityId', 'collectorEntityId', 'pickupItemCount' )
@ -12,13 +12,13 @@ class PacketCollect(Packet):
collectorEntityId : int collectorEntityId : int
pickupItemCount : int pickupItemCount : int
def __init__(self, proto:int, def __init__(self,
collectedEntityId:int=None, collectedEntityId:int | None = None,
collectorEntityId:int=None, collectorEntityId:int | None = None,
pickupItemCount:int=None, pickupItemCount:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
collectedEntityId=collectedEntityId, collectedEntityId=collectedEntityId,
collectorEntityId=collectorEntityId, collectorEntityId=collectorEntityId,
pickupItemCount=pickupItemCount pickupItemCount=pickupItemCount

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCombatEvent(Packet): class PacketCombatEvent(Packet):
__slots__ = ( 'id', 'duration', 'entityId', 'event', 'message', 'playerId' ) __slots__ = ( 'id', 'duration', 'entityId', 'event', 'message', 'playerId' )
@ -14,15 +14,15 @@ class PacketCombatEvent(Packet):
message : Union[None, str] message : Union[None, str]
playerId : Union[None, int] playerId : Union[None, int]
def __init__(self, proto:int, def __init__(self,
duration:Union[None, int]=None, duration:Union[None, int] | None = None,
entityId:Union[None, int]=None, entityId:Union[None, int] | None = None,
event:int=None, event:int | None = None,
message:Union[None, str]=None, message:Union[None, str] | None = None,
playerId:Union[None, int]=None, playerId:Union[None, int] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
duration=duration, duration=duration,
entityId=entityId, entityId=entityId,
event=event, event=event,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCraftProgressBar(Packet): class PacketCraftProgressBar(Packet):
__slots__ = ( 'id', 'property', 'value', 'windowId' ) __slots__ = ( 'id', 'property', 'value', 'windowId' )
@ -12,13 +12,13 @@ class PacketCraftProgressBar(Packet):
value : int value : int
windowId : int windowId : int
def __init__(self, proto:int, def __init__(self,
property:int=None, property:int | None = None,
value:int=None, value:int | None = None,
windowId:int=None, windowId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
property=property, property=property,
value=value, value=value,
windowId=windowId windowId=windowId

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCraftRecipeResponse(Packet): class PacketCraftRecipeResponse(Packet):
__slots__ = ( 'id', 'recipe', 'windowId' ) __slots__ = ( 'id', 'recipe', 'windowId' )
@ -11,12 +11,12 @@ class PacketCraftRecipeResponse(Packet):
recipe : Union[int,str] recipe : Union[int,str]
windowId : int windowId : int
def __init__(self, proto:int, def __init__(self,
recipe:Union[int,str]=None, recipe:Union[int,str] | None = None,
windowId:int=None, windowId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
recipe=recipe, recipe=recipe,
windowId=windowId windowId=windowId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketCustomPayload(Packet): class PacketCustomPayload(Packet):
__slots__ = ( 'id', 'channel', 'data' ) __slots__ = ( 'id', 'channel', 'data' )
@ -11,12 +11,12 @@ class PacketCustomPayload(Packet):
channel : str channel : str
data : bytes data : bytes
def __init__(self, proto:int, def __init__(self,
channel:str=None, channel:str | None = None,
data:bytes=None, data:bytes | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
channel=channel, channel=channel,
data=data data=data
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDeathCombatEvent(Packet): class PacketDeathCombatEvent(Packet):
__slots__ = ( 'id', 'entityId', 'message', 'playerId' ) __slots__ = ( 'id', 'entityId', 'message', 'playerId' )
@ -12,13 +12,13 @@ class PacketDeathCombatEvent(Packet):
message : str message : str
playerId : int playerId : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
message:str=None, message:str | None = None,
playerId:int=None, playerId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
message=message, message=message,
playerId=playerId playerId=playerId

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDeclareCommands(Packet): class PacketDeclareCommands(Packet):
__slots__ = ( 'id', 'nodes', 'rootIndex' ) __slots__ = ( 'id', 'nodes', 'rootIndex' )
@ -11,12 +11,12 @@ class PacketDeclareCommands(Packet):
nodes : list nodes : list
rootIndex : int rootIndex : int
def __init__(self, proto:int, def __init__(self,
nodes:list=None, nodes:list | None = None,
rootIndex:int=None, rootIndex:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
nodes=nodes, nodes=nodes,
rootIndex=rootIndex rootIndex=rootIndex
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDeclareRecipes(Packet): class PacketDeclareRecipes(Packet):
__slots__ = ( 'id', 'recipes' ) __slots__ = ( 'id', 'recipes' )
recipes : list recipes : list
def __init__(self, proto:int, def __init__(self,
recipes:list=None, recipes:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
recipes=recipes recipes=recipes
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDestroyEntity(Packet): class PacketDestroyEntity(Packet):
__slots__ = ( 'id', 'entityId' ) __slots__ = ( 'id', 'entityId' )
entityId : int entityId : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId entityId=entityId
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketDifficulty(Packet): class PacketDifficulty(Packet):
__slots__ = ( 'id', 'difficulty', 'difficultyLocked' ) __slots__ = ( 'id', 'difficulty', 'difficultyLocked' )
@ -11,12 +11,12 @@ class PacketDifficulty(Packet):
difficulty : int difficulty : int
difficultyLocked : bool difficultyLocked : bool
def __init__(self, proto:int, def __init__(self,
difficulty:int=None, difficulty:int | None = None,
difficultyLocked:bool=None, difficultyLocked:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
difficulty=difficulty, difficulty=difficulty,
difficultyLocked=difficultyLocked difficultyLocked=difficultyLocked
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEndCombatEvent(Packet): class PacketEndCombatEvent(Packet):
__slots__ = ( 'id', 'duration', 'entityId' ) __slots__ = ( 'id', 'duration', 'entityId' )
@ -11,12 +11,12 @@ class PacketEndCombatEvent(Packet):
duration : int duration : int
entityId : int entityId : int
def __init__(self, proto:int, def __init__(self,
duration:int=None, duration:int | None = None,
entityId:int=None, entityId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
duration=duration, duration=duration,
entityId=entityId entityId=entityId
) )

View file

@ -2,18 +2,18 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEnterCombatEvent(Packet): class PacketEnterCombatEvent(Packet):
__slots__ = ( 'id' ) __slots__ = ( 'id' )
def __init__(self, proto:int, def __init__(self,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntity(Packet): class PacketEntity(Packet):
__slots__ = ( 'id', 'entityId' ) __slots__ = ( 'id', 'entityId' )
entityId : int entityId : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId entityId=entityId
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityDestroy(Packet): class PacketEntityDestroy(Packet):
__slots__ = ( 'id', 'entityIds' ) __slots__ = ( 'id', 'entityIds' )
entityIds : list entityIds : list
def __init__(self, proto:int, def __init__(self,
entityIds:list=None, entityIds:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityIds=entityIds entityIds=entityIds
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityEffect(Packet): class PacketEntityEffect(Packet):
__slots__ = ( 'id', 'amplifier', 'duration', 'effectId', 'entityId', 'factorCodec', 'hideParticles' ) __slots__ = ( 'id', 'amplifier', 'duration', 'effectId', 'entityId', 'factorCodec', 'hideParticles' )
@ -15,16 +15,16 @@ class PacketEntityEffect(Packet):
factorCodec : tuple factorCodec : tuple
hideParticles : Union[bool,int] hideParticles : Union[bool,int]
def __init__(self, proto:int, def __init__(self,
amplifier:int=None, amplifier:int | None = None,
duration:int=None, duration:int | None = None,
effectId:int=None, effectId:int | None = None,
entityId:int=None, entityId:int | None = None,
factorCodec:tuple=None, factorCodec:tuple | None = None,
hideParticles:Union[bool,int]=None, hideParticles:Union[bool,int] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
amplifier=amplifier, amplifier=amplifier,
duration=duration, duration=duration,
effectId=effectId, effectId=effectId,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityEquipment(Packet): class PacketEntityEquipment(Packet):
__slots__ = ( 'id', 'entityId', 'equipments', 'item', 'slot' ) __slots__ = ( 'id', 'entityId', 'equipments', 'item', 'slot' )
@ -13,14 +13,14 @@ class PacketEntityEquipment(Packet):
item : Item item : Item
slot : int slot : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
equipments:bytes=None, equipments:bytes | None = None,
item:Item=None, item:Item | None = None,
slot:int=None, slot:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
equipments=equipments, equipments=equipments,
item=item, item=item,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityHeadRotation(Packet): class PacketEntityHeadRotation(Packet):
__slots__ = ( 'id', 'entityId', 'headYaw' ) __slots__ = ( 'id', 'entityId', 'headYaw' )
@ -11,12 +11,12 @@ class PacketEntityHeadRotation(Packet):
entityId : int entityId : int
headYaw : int headYaw : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
headYaw:int=None, headYaw:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
headYaw=headYaw headYaw=headYaw
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityLook(Packet): class PacketEntityLook(Packet):
__slots__ = ( 'id', 'entityId', 'onGround', 'pitch', 'yaw' ) __slots__ = ( 'id', 'entityId', 'onGround', 'pitch', 'yaw' )
@ -13,14 +13,14 @@ class PacketEntityLook(Packet):
pitch : int pitch : int
yaw : int yaw : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
onGround:bool=None, onGround:bool | None = None,
pitch:int=None, pitch:int | None = None,
yaw:int=None, yaw:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
onGround=onGround, onGround=onGround,
pitch=pitch, pitch=pitch,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityMetadata(Packet): class PacketEntityMetadata(Packet):
__slots__ = ( 'id', 'entityId', 'metadata' ) __slots__ = ( 'id', 'entityId', 'metadata' )
@ -11,12 +11,12 @@ class PacketEntityMetadata(Packet):
entityId : int entityId : int
metadata : dict metadata : dict
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
metadata:dict=None, metadata:dict | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
metadata=metadata metadata=metadata
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityMoveLook(Packet): class PacketEntityMoveLook(Packet):
__slots__ = ( 'id', 'dX', 'dY', 'dZ', 'entityId', 'onGround', 'pitch', 'yaw' ) __slots__ = ( 'id', 'dX', 'dY', 'dZ', 'entityId', 'onGround', 'pitch', 'yaw' )
@ -16,17 +16,17 @@ class PacketEntityMoveLook(Packet):
pitch : int pitch : int
yaw : int yaw : int
def __init__(self, proto:int, def __init__(self,
dX:int=None, dX:int | None = None,
dY:int=None, dY:int | None = None,
dZ:int=None, dZ:int | None = None,
entityId:int=None, entityId:int | None = None,
onGround:bool=None, onGround:bool | None = None,
pitch:int=None, pitch:int | None = None,
yaw:int=None, yaw:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
dX=dX, dX=dX,
dY=dY, dY=dY,
dZ=dZ, dZ=dZ,

View file

@ -2,33 +2,36 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntitySoundEffect(Packet): class PacketEntitySoundEffect(Packet):
__slots__ = ( 'id', 'entityId', 'pitch', 'seed', 'soundCategory', 'soundId', 'volume' ) __slots__ = ( 'id', 'entityId', 'pitch', 'seed', 'soundCategory', 'soundEvent', 'soundId', 'volume' )
entityId : int entityId : int
pitch : float pitch : float
seed : int seed : int
soundCategory : int soundCategory : int
soundEvent : Union[None, dict]
soundId : int soundId : int
volume : float volume : float
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
pitch:float=None, pitch:float | None = None,
seed:int=None, seed:int | None = None,
soundCategory:int=None, soundCategory:int | None = None,
soundId:int=None, soundEvent:Union[None, dict] | None = None,
volume:float=None, soundId:int | None = None,
volume:float | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
pitch=pitch, pitch=pitch,
seed=seed, seed=seed,
soundCategory=soundCategory, soundCategory=soundCategory,
soundEvent=soundEvent,
soundId=soundId, soundId=soundId,
volume=volume volume=volume
) )
@ -75,5 +78,5 @@ class PacketEntitySoundEffect(Packet):
758 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ) ], 758 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ) ],
759 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ) ], 759 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ) ],
760 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ), ( 'seed', Long ) ], 760 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ), ( 'seed', Long ) ],
761 : [ ( 'soundId', VarInt ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ), ( 'seed', Long ) ] 761 : [ ( 'soundId', VarInt ), ( 'soundEvent', SwitchType('soundId', { 0 : StructType(( 'resource', String ), ( 'range', OptionalType(Float, ) ), ) }, None, ) ), ( 'soundCategory', VarInt ), ( 'entityId', VarInt ), ( 'volume', Float ), ( 'pitch', Float ), ( 'seed', Long ) ]
} }

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityStatus(Packet): class PacketEntityStatus(Packet):
__slots__ = ( 'id', 'entityId', 'entityStatus' ) __slots__ = ( 'id', 'entityId', 'entityStatus' )
@ -11,12 +11,12 @@ class PacketEntityStatus(Packet):
entityId : int entityId : int
entityStatus : int entityStatus : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
entityStatus:int=None, entityStatus:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
entityStatus=entityStatus entityStatus=entityStatus
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityTeleport(Packet): class PacketEntityTeleport(Packet):
__slots__ = ( 'id', 'entityId', 'onGround', 'pitch', 'x', 'y', 'yaw', 'z' ) __slots__ = ( 'id', 'entityId', 'onGround', 'pitch', 'x', 'y', 'yaw', 'z' )
@ -16,17 +16,17 @@ class PacketEntityTeleport(Packet):
yaw : int yaw : int
z : Union[float,int] z : Union[float,int]
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
onGround:bool=None, onGround:bool | None = None,
pitch:int=None, pitch:int | None = None,
x:Union[float,int]=None, x:Union[float,int] | None = None,
y:Union[float,int]=None, y:Union[float,int] | None = None,
yaw:int=None, yaw:int | None = None,
z:Union[float,int]=None, z:Union[float,int] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
onGround=onGround, onGround=onGround,
pitch=pitch, pitch=pitch,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityUpdateAttributes(Packet): class PacketEntityUpdateAttributes(Packet):
__slots__ = ( 'id', 'entityId', 'properties' ) __slots__ = ( 'id', 'entityId', 'properties' )
@ -11,12 +11,12 @@ class PacketEntityUpdateAttributes(Packet):
entityId : int entityId : int
properties : list properties : list
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
properties:list=None, properties:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
properties=properties properties=properties
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketEntityVelocity(Packet): class PacketEntityVelocity(Packet):
__slots__ = ( 'id', 'entityId', 'velocityX', 'velocityY', 'velocityZ' ) __slots__ = ( 'id', 'entityId', 'velocityX', 'velocityY', 'velocityZ' )
@ -13,14 +13,14 @@ class PacketEntityVelocity(Packet):
velocityY : int velocityY : int
velocityZ : int velocityZ : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
velocityX:int=None, velocityX:int | None = None,
velocityY:int=None, velocityY:int | None = None,
velocityZ:int=None, velocityZ:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
velocityX=velocityX, velocityX=velocityX,
velocityY=velocityY, velocityY=velocityY,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketExperience(Packet): class PacketExperience(Packet):
__slots__ = ( 'id', 'experienceBar', 'level', 'totalExperience' ) __slots__ = ( 'id', 'experienceBar', 'level', 'totalExperience' )
@ -12,13 +12,13 @@ class PacketExperience(Packet):
level : int level : int
totalExperience : int totalExperience : int
def __init__(self, proto:int, def __init__(self,
experienceBar:float=None, experienceBar:float | None = None,
level:int=None, level:int | None = None,
totalExperience:int=None, totalExperience:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
experienceBar=experienceBar, experienceBar=experienceBar,
level=level, level=level,
totalExperience=totalExperience totalExperience=totalExperience

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketExplosion(Packet): class PacketExplosion(Packet):
__slots__ = ( 'id', 'affectedBlockOffsets', 'playerMotionX', 'playerMotionY', 'playerMotionZ', 'radius', 'x', 'y', 'z' ) __slots__ = ( 'id', 'affectedBlockOffsets', 'playerMotionX', 'playerMotionY', 'playerMotionZ', 'radius', 'x', 'y', 'z' )
@ -17,18 +17,18 @@ class PacketExplosion(Packet):
y : float y : float
z : float z : float
def __init__(self, proto:int, def __init__(self,
affectedBlockOffsets:list=None, affectedBlockOffsets:list | None = None,
playerMotionX:float=None, playerMotionX:float | None = None,
playerMotionY:float=None, playerMotionY:float | None = None,
playerMotionZ:float=None, playerMotionZ:float | None = None,
radius:float=None, radius:float | None = None,
x:float=None, x:float | None = None,
y:float=None, y:float | None = None,
z:float=None, z:float | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
affectedBlockOffsets=affectedBlockOffsets, affectedBlockOffsets=affectedBlockOffsets,
playerMotionX=playerMotionX, playerMotionX=playerMotionX,
playerMotionY=playerMotionY, playerMotionY=playerMotionY,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketFacePlayer(Packet): class PacketFacePlayer(Packet):
__slots__ = ( 'id', 'entityId', 'entity_feet_eyes', 'feet_eyes', 'isEntity', 'x', 'y', 'z' ) __slots__ = ( 'id', 'entityId', 'entity_feet_eyes', 'feet_eyes', 'isEntity', 'x', 'y', 'z' )
@ -16,17 +16,17 @@ class PacketFacePlayer(Packet):
y : float y : float
z : float z : float
def __init__(self, proto:int, def __init__(self,
entityId:Union[None, int]=None, entityId:Union[None, int] | None = None,
entity_feet_eyes:Union[None, str]=None, entity_feet_eyes:Union[None, str] | None = None,
feet_eyes:int=None, feet_eyes:int | None = None,
isEntity:bool=None, isEntity:bool | None = None,
x:float=None, x:float | None = None,
y:float=None, y:float | None = None,
z:float=None, z:float | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
entity_feet_eyes=entity_feet_eyes, entity_feet_eyes=entity_feet_eyes,
feet_eyes=feet_eyes, feet_eyes=feet_eyes,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketFeatureFlags(Packet): class PacketFeatureFlags(Packet):
__slots__ = ( 'id', 'features' ) __slots__ = ( 'id', 'features' )
features : list features : list
def __init__(self, proto:int, def __init__(self,
features:list=None, features:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
features=features features=features
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketGameStateChange(Packet): class PacketGameStateChange(Packet):
__slots__ = ( 'id', 'gameMode', 'reason' ) __slots__ = ( 'id', 'gameMode', 'reason' )
@ -11,12 +11,12 @@ class PacketGameStateChange(Packet):
gameMode : float gameMode : float
reason : int reason : int
def __init__(self, proto:int, def __init__(self,
gameMode:float=None, gameMode:float | None = None,
reason:int=None, reason:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
gameMode=gameMode, gameMode=gameMode,
reason=reason reason=reason
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketHeldItemSlot(Packet): class PacketHeldItemSlot(Packet):
__slots__ = ( 'id', 'slot' ) __slots__ = ( 'id', 'slot' )
slot : int slot : int
def __init__(self, proto:int, def __init__(self,
slot:int=None, slot:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
slot=slot slot=slot
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketHideMessage(Packet): class PacketHideMessage(Packet):
__slots__ = ( 'id', 'id', 'signature' ) __slots__ = ( 'id', 'id', 'signature' )
@ -11,12 +11,12 @@ class PacketHideMessage(Packet):
id : int id : int
signature : Union[Union[None, bytes],bytes] signature : Union[Union[None, bytes],bytes]
def __init__(self, proto:int, def __init__(self,
id:int=None, id:int | None = None,
signature:Union[Union[None, bytes],bytes]=None, signature:Union[Union[None, bytes],bytes] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
id=id, id=id,
signature=signature signature=signature
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketInitializeWorldBorder(Packet): class PacketInitializeWorldBorder(Packet):
__slots__ = ( 'id', 'newDiameter', 'oldDiameter', 'portalTeleportBoundary', 'speed', 'warningBlocks', 'warningTime', 'x', 'z' ) __slots__ = ( 'id', 'newDiameter', 'oldDiameter', 'portalTeleportBoundary', 'speed', 'warningBlocks', 'warningTime', 'x', 'z' )
@ -17,18 +17,18 @@ class PacketInitializeWorldBorder(Packet):
x : float x : float
z : float z : float
def __init__(self, proto:int, def __init__(self,
newDiameter:float=None, newDiameter:float | None = None,
oldDiameter:float=None, oldDiameter:float | None = None,
portalTeleportBoundary:int=None, portalTeleportBoundary:int | None = None,
speed:int=None, speed:int | None = None,
warningBlocks:int=None, warningBlocks:int | None = None,
warningTime:int=None, warningTime:int | None = None,
x:float=None, x:float | None = None,
z:float=None, z:float | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
newDiameter=newDiameter, newDiameter=newDiameter,
oldDiameter=oldDiameter, oldDiameter=oldDiameter,
portalTeleportBoundary=portalTeleportBoundary, portalTeleportBoundary=portalTeleportBoundary,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketKeepAlive(Packet): class PacketKeepAlive(Packet):
__slots__ = ( 'id', 'keepAliveId' ) __slots__ = ( 'id', 'keepAliveId' )
keepAliveId : int keepAliveId : int
def __init__(self, proto:int, def __init__(self,
keepAliveId:int=None, keepAliveId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
keepAliveId=keepAliveId keepAliveId=keepAliveId
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketKickDisconnect(Packet): class PacketKickDisconnect(Packet):
__slots__ = ( 'id', 'reason' ) __slots__ = ( 'id', 'reason' )
reason : str reason : str
def __init__(self, proto:int, def __init__(self,
reason:str=None, reason:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
reason=reason reason=reason
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketLogin(Packet): class PacketLogin(Packet):
__slots__ = ( 'id', 'death', 'difficulty', 'dimension', 'dimensionCodec', 'enableRespawnScreen', 'entityId', 'gameMode', 'hashedSeed', 'isDebug', 'isFlat', 'isHardcore', 'levelType', 'maxPlayers', 'previousGameMode', 'reducedDebugInfo', 'simulationDistance', 'viewDistance', 'worldName', 'worldNames', 'worldType' ) __slots__ = ( 'id', 'death', 'difficulty', 'dimension', 'dimensionCodec', 'enableRespawnScreen', 'entityId', 'gameMode', 'hashedSeed', 'isDebug', 'isFlat', 'isHardcore', 'levelType', 'maxPlayers', 'previousGameMode', 'reducedDebugInfo', 'simulationDistance', 'viewDistance', 'worldName', 'worldNames', 'worldType' )
@ -29,30 +29,30 @@ class PacketLogin(Packet):
worldNames : list worldNames : list
worldType : str worldType : str
def __init__(self, proto:int, def __init__(self,
death:tuple=None, death:tuple | None = None,
difficulty:int=None, difficulty:int | None = None,
dimension:Union[dict,int,str]=None, dimension:Union[dict,int,str] | None = None,
dimensionCodec:dict=None, dimensionCodec:dict | None = None,
enableRespawnScreen:bool=None, enableRespawnScreen:bool | None = None,
entityId:int=None, entityId:int | None = None,
gameMode:int=None, gameMode:int | None = None,
hashedSeed:int=None, hashedSeed:int | None = None,
isDebug:bool=None, isDebug:bool | None = None,
isFlat:bool=None, isFlat:bool | None = None,
isHardcore:bool=None, isHardcore:bool | None = None,
levelType:str=None, levelType:str | None = None,
maxPlayers:int=None, maxPlayers:int | None = None,
previousGameMode:int=None, previousGameMode:int | None = None,
reducedDebugInfo:bool=None, reducedDebugInfo:bool | None = None,
simulationDistance:int=None, simulationDistance:int | None = None,
viewDistance:int=None, viewDistance:int | None = None,
worldName:str=None, worldName:str | None = None,
worldNames:list=None, worldNames:list | None = None,
worldType:str=None, worldType:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
death=death, death=death,
difficulty=difficulty, difficulty=difficulty,
dimension=dimension, dimension=dimension,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketMap(Packet): class PacketMap(Packet):
__slots__ = ( 'id', 'columns', 'data', 'icons', 'itemDamage', 'locked', 'rows', 'scale', 'trackingPosition', 'x', 'y' ) __slots__ = ( 'id', 'columns', 'data', 'icons', 'itemDamage', 'locked', 'rows', 'scale', 'trackingPosition', 'x', 'y' )
@ -19,20 +19,20 @@ class PacketMap(Packet):
x : Union[None, int] x : Union[None, int]
y : Union[None, int] y : Union[None, int]
def __init__(self, proto:int, def __init__(self,
columns:int=None, columns:int | None = None,
data:Union[None, bytes]=None, data:Union[None, bytes] | None = None,
icons:Union[list,tuple]=None, icons:Union[list,tuple] | None = None,
itemDamage:int=None, itemDamage:int | None = None,
locked:bool=None, locked:bool | None = None,
rows:Union[None, int]=None, rows:Union[None, int] | None = None,
scale:int=None, scale:int | None = None,
trackingPosition:bool=None, trackingPosition:bool | None = None,
x:Union[None, int]=None, x:Union[None, int] | None = None,
y:Union[None, int]=None, y:Union[None, int] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
columns=columns, columns=columns,
data=data, data=data,
icons=icons, icons=icons,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketMapChunk(Packet): class PacketMapChunk(Packet):
__slots__ = ( 'id', 'biomes', 'bitMap', 'blockEntities', 'blockLight', 'blockLightMask', 'chunkData', 'emptyBlockLightMask', 'emptySkyLightMask', 'groundUp', 'heightmaps', 'ignoreOldData', 'skyLight', 'skyLightMask', 'trustEdges', 'x', 'z' ) __slots__ = ( 'id', 'biomes', 'bitMap', 'blockEntities', 'blockLight', 'blockLightMask', 'chunkData', 'emptyBlockLightMask', 'emptySkyLightMask', 'groundUp', 'heightmaps', 'ignoreOldData', 'skyLight', 'skyLightMask', 'trustEdges', 'x', 'z' )
@ -25,26 +25,26 @@ class PacketMapChunk(Packet):
x : int x : int
z : int z : int
def __init__(self, proto:int, def __init__(self,
biomes:Union[Union[None, list],list]=None, biomes:Union[Union[None, list],list] | None = None,
bitMap:Union[int,list]=None, bitMap:Union[int,list] | None = None,
blockEntities:list=None, blockEntities:list | None = None,
blockLight:list=None, blockLight:list | None = None,
blockLightMask:list=None, blockLightMask:list | None = None,
chunkData:bytes=None, chunkData:bytes | None = None,
emptyBlockLightMask:list=None, emptyBlockLightMask:list | None = None,
emptySkyLightMask:list=None, emptySkyLightMask:list | None = None,
groundUp:bool=None, groundUp:bool | None = None,
heightmaps:dict=None, heightmaps:dict | None = None,
ignoreOldData:bool=None, ignoreOldData:bool | None = None,
skyLight:list=None, skyLight:list | None = None,
skyLightMask:list=None, skyLightMask:list | None = None,
trustEdges:bool=None, trustEdges:bool | None = None,
x:int=None, x:int | None = None,
z:int=None, z:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
biomes=biomes, biomes=biomes,
bitMap=bitMap, bitMap=bitMap,
blockEntities=blockEntities, blockEntities=blockEntities,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketMapChunkBulk(Packet): class PacketMapChunkBulk(Packet):
__slots__ = ( 'id', 'data', 'meta', 'skyLightSent' ) __slots__ = ( 'id', 'data', 'meta', 'skyLightSent' )
@ -12,13 +12,13 @@ class PacketMapChunkBulk(Packet):
meta : list meta : list
skyLightSent : bool skyLightSent : bool
def __init__(self, proto:int, def __init__(self,
data:bytes=None, data:bytes | None = None,
meta:list=None, meta:list | None = None,
skyLightSent:bool=None, skyLightSent:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
data=data, data=data,
meta=meta, meta=meta,
skyLightSent=skyLightSent skyLightSent=skyLightSent

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketMessageHeader(Packet): class PacketMessageHeader(Packet):
__slots__ = ( 'id', 'messageHash', 'previousSignature', 'senderUuid', 'signature' ) __slots__ = ( 'id', 'messageHash', 'previousSignature', 'senderUuid', 'signature' )
@ -13,14 +13,14 @@ class PacketMessageHeader(Packet):
senderUuid : str senderUuid : str
signature : bytes signature : bytes
def __init__(self, proto:int, def __init__(self,
messageHash:bytes=None, messageHash:bytes | None = None,
previousSignature:tuple=None, previousSignature:tuple | None = None,
senderUuid:str=None, senderUuid:str | None = None,
signature:bytes=None, signature:bytes | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
messageHash=messageHash, messageHash=messageHash,
previousSignature=previousSignature, previousSignature=previousSignature,
senderUuid=senderUuid, senderUuid=senderUuid,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketMultiBlockChange(Packet): class PacketMultiBlockChange(Packet):
__slots__ = ( 'id', 'chunkCoordinates', 'chunkX', 'chunkZ', 'notTrustEdges', 'records', 'suppressLightUpdates' ) __slots__ = ( 'id', 'chunkCoordinates', 'chunkX', 'chunkZ', 'notTrustEdges', 'records', 'suppressLightUpdates' )
@ -15,16 +15,16 @@ class PacketMultiBlockChange(Packet):
records : list records : list
suppressLightUpdates : bool suppressLightUpdates : bool
def __init__(self, proto:int, def __init__(self,
chunkCoordinates:int=None, chunkCoordinates:int | None = None,
chunkX:int=None, chunkX:int | None = None,
chunkZ:int=None, chunkZ:int | None = None,
notTrustEdges:bool=None, notTrustEdges:bool | None = None,
records:list=None, records:list | None = None,
suppressLightUpdates:bool=None, suppressLightUpdates:bool | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
chunkCoordinates=chunkCoordinates, chunkCoordinates=chunkCoordinates,
chunkX=chunkX, chunkX=chunkX,
chunkZ=chunkZ, chunkZ=chunkZ,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketNamedEntitySpawn(Packet): class PacketNamedEntitySpawn(Packet):
__slots__ = ( 'id', 'currentItem', 'entityId', 'metadata', 'pitch', 'playerUUID', 'x', 'y', 'yaw', 'z' ) __slots__ = ( 'id', 'currentItem', 'entityId', 'metadata', 'pitch', 'playerUUID', 'x', 'y', 'yaw', 'z' )
@ -18,19 +18,19 @@ class PacketNamedEntitySpawn(Packet):
yaw : int yaw : int
z : Union[float,int] z : Union[float,int]
def __init__(self, proto:int, def __init__(self,
currentItem:int=None, currentItem:int | None = None,
entityId:int=None, entityId:int | None = None,
metadata:dict=None, metadata:dict | None = None,
pitch:int=None, pitch:int | None = None,
playerUUID:str=None, playerUUID:str | None = None,
x:Union[float,int]=None, x:Union[float,int] | None = None,
y:Union[float,int]=None, y:Union[float,int] | None = None,
yaw:int=None, yaw:int | None = None,
z:Union[float,int]=None, z:Union[float,int] | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
currentItem=currentItem, currentItem=currentItem,
entityId=entityId, entityId=entityId,
metadata=metadata, metadata=metadata,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketNamedSoundEffect(Packet): class PacketNamedSoundEffect(Packet):
__slots__ = ( 'id', 'pitch', 'seed', 'soundCategory', 'soundName', 'volume', 'x', 'y', 'z' ) __slots__ = ( 'id', 'pitch', 'seed', 'soundCategory', 'soundName', 'volume', 'x', 'y', 'z' )
@ -17,18 +17,18 @@ class PacketNamedSoundEffect(Packet):
y : int y : int
z : int z : int
def __init__(self, proto:int, def __init__(self,
pitch:Union[float,int]=None, pitch:Union[float,int] | None = None,
seed:int=None, seed:int | None = None,
soundCategory:int=None, soundCategory:int | None = None,
soundName:str=None, soundName:str | None = None,
volume:float=None, volume:float | None = None,
x:int=None, x:int | None = None,
y:int=None, y:int | None = None,
z:int=None, z:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
pitch=pitch, pitch=pitch,
seed=seed, seed=seed,
soundCategory=soundCategory, soundCategory=soundCategory,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketNbtQueryResponse(Packet): class PacketNbtQueryResponse(Packet):
__slots__ = ( 'id', 'nbt', 'transactionId' ) __slots__ = ( 'id', 'nbt', 'transactionId' )
@ -11,12 +11,12 @@ class PacketNbtQueryResponse(Packet):
nbt : Optional[dict] nbt : Optional[dict]
transactionId : int transactionId : int
def __init__(self, proto:int, def __init__(self,
nbt:Optional[dict]=None, nbt:Optional[dict] | None = None,
transactionId:int=None, transactionId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
nbt=nbt, nbt=nbt,
transactionId=transactionId transactionId=transactionId
) )

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketOpenBook(Packet): class PacketOpenBook(Packet):
__slots__ = ( 'id', 'hand' ) __slots__ = ( 'id', 'hand' )
hand : int hand : int
def __init__(self, proto:int, def __init__(self,
hand:int=None, hand:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
hand=hand hand=hand
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketOpenHorseWindow(Packet): class PacketOpenHorseWindow(Packet):
__slots__ = ( 'id', 'entityId', 'nbSlots', 'windowId' ) __slots__ = ( 'id', 'entityId', 'nbSlots', 'windowId' )
@ -12,13 +12,13 @@ class PacketOpenHorseWindow(Packet):
nbSlots : int nbSlots : int
windowId : int windowId : int
def __init__(self, proto:int, def __init__(self,
entityId:int=None, entityId:int | None = None,
nbSlots:int=None, nbSlots:int | None = None,
windowId:int=None, windowId:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
nbSlots=nbSlots, nbSlots=nbSlots,
windowId=windowId windowId=windowId

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketOpenSignEntity(Packet): class PacketOpenSignEntity(Packet):
__slots__ = ( 'id', 'location' ) __slots__ = ( 'id', 'location' )
location : tuple location : tuple
def __init__(self, proto:int, def __init__(self,
location:tuple=None, location:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
location=location location=location
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketOpenWindow(Packet): class PacketOpenWindow(Packet):
__slots__ = ( 'id', 'entityId', 'inventoryType', 'slotCount', 'windowId', 'windowTitle' ) __slots__ = ( 'id', 'entityId', 'inventoryType', 'slotCount', 'windowId', 'windowTitle' )
@ -14,15 +14,15 @@ class PacketOpenWindow(Packet):
windowId : int windowId : int
windowTitle : str windowTitle : str
def __init__(self, proto:int, def __init__(self,
entityId:Union[None, int]=None, entityId:Union[None, int] | None = None,
inventoryType:Union[int,str]=None, inventoryType:Union[int,str] | None = None,
slotCount:int=None, slotCount:int | None = None,
windowId:int=None, windowId:int | None = None,
windowTitle:str=None, windowTitle:str | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
entityId=entityId, entityId=entityId,
inventoryType=inventoryType, inventoryType=inventoryType,
slotCount=slotCount, slotCount=slotCount,

View file

@ -2,19 +2,19 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketPing(Packet): class PacketPing(Packet):
__slots__ = ( 'id', 'id' ) __slots__ = ( 'id', 'id' )
id : int id : int
def __init__(self, proto:int, def __init__(self,
id:int=None, id:int | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
id=id id=id
) )

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketPlayerChat(Packet): class PacketPlayerChat(Packet):
__slots__ = ( 'id', 'filterType', 'filterTypeMask', 'formattedMessage', 'index', 'networkName', 'networkTargetName', 'plainMessage', 'previousMessages', 'previousSignature', 'salt', 'senderName', 'senderTeam', 'senderUuid', 'signature', 'signedChatContent', 'timestamp', 'type', 'unsignedChatContent', 'unsignedContent' ) __slots__ = ( 'id', 'filterType', 'filterTypeMask', 'formattedMessage', 'index', 'networkName', 'networkTargetName', 'plainMessage', 'previousMessages', 'previousSignature', 'salt', 'senderName', 'senderTeam', 'senderUuid', 'signature', 'signedChatContent', 'timestamp', 'type', 'unsignedChatContent', 'unsignedContent' )
@ -28,29 +28,29 @@ class PacketPlayerChat(Packet):
unsignedChatContent : tuple unsignedChatContent : tuple
unsignedContent : tuple unsignedContent : tuple
def __init__(self, proto:int, def __init__(self,
filterType:int=None, filterType:int | None = None,
filterTypeMask:Union[None, list]=None, filterTypeMask:Union[None, list] | None = None,
formattedMessage:tuple=None, formattedMessage:tuple | None = None,
index:int=None, index:int | None = None,
networkName:str=None, networkName:str | None = None,
networkTargetName:tuple=None, networkTargetName:tuple | None = None,
plainMessage:str=None, plainMessage:str | None = None,
previousMessages:bytes=None, previousMessages:bytes | None = None,
previousSignature:tuple=None, previousSignature:tuple | None = None,
salt:int=None, salt:int | None = None,
senderName:str=None, senderName:str | None = None,
senderTeam:tuple=None, senderTeam:tuple | None = None,
senderUuid:str=None, senderUuid:str | None = None,
signature:Union[bytes,tuple]=None, signature:Union[bytes,tuple] | None = None,
signedChatContent:str=None, signedChatContent:str | None = None,
timestamp:int=None, timestamp:int | None = None,
type:int=None, type:int | None = None,
unsignedChatContent:tuple=None, unsignedChatContent:tuple | None = None,
unsignedContent:tuple=None, unsignedContent:tuple | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
filterType=filterType, filterType=filterType,
filterTypeMask=filterTypeMask, filterTypeMask=filterTypeMask,
formattedMessage=formattedMessage, formattedMessage=formattedMessage,

View file

@ -2,8 +2,8 @@
from typing import Tuple, List, Dict, Union, Optional from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet from ....packet import Packet
from ....definitions import *
from ....types import * from ....types import *
from ....primitives import *
class PacketPlayerInfo(Packet): class PacketPlayerInfo(Packet):
__slots__ = ( 'id', 'action', 'data' ) __slots__ = ( 'id', 'action', 'data' )
@ -11,12 +11,12 @@ class PacketPlayerInfo(Packet):
action : int action : int
data : list data : list
def __init__(self, proto:int, def __init__(self,
action:int=None, action:int | None = None,
data:list=None, data:list | None = None,
**kwargs **kwargs
): ):
super().__init__(proto, super().__init__(
action=action, action=action,
data=data data=data
) )

Some files were not shown because too many files have changed in this diff Show more