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"""
# from .client import Client
from .mc import * # TODO move mc out of mc
from .client import AbstractMinecraftClient
from .server import AbstractMinecraftServer
from .client import MinecraftClient
from .server import MinecraftServer
from .mc.auth import MicrosoftAuthenticator, MojangAuthenticator
from .types import *
from .auth import MicrosoftAuthenticator, MojangAuthenticator
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
from json.decoder import JSONDecodeError
from ..definitions import GameProfile
from ..types import GameProfile
logger = logging.getLogger(__file__)
@ -26,7 +26,7 @@ class AuthException(Exception):
class AuthInterface:
accessToken : str
selectedProfile : GameProfile
session_server_override : str
session_server_override : str | None = None
SESSION_SERVER = "https://sessionserver.mojang.com/session/minecraft"
TIMEOUT = aiohttp.ClientTimeout(total=3)

View file

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

View file

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

View file

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

View file

@ -1,19 +1,18 @@
import io
import asyncio
import contextlib
import zlib
import logging
from typing import Type, AsyncIterator
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 cryptography.hazmat.primitives.ciphers import CipherContext
from .mc import proto as minecraft_protocol
from .mc.types import VarInt, Context
from .mc.packet import Packet
from .mc.definitions import ConnectionState
from . import proto as minecraft_protocol
from .primitives import VarInt, Context
from .packet import Packet
from .types import ConnectionState
from .util import encryption
LOGGER = logging.getLogger(__name__)
@ -29,11 +28,11 @@ class Dispatcher:
_is_server : bool # True when receiving packets from clients
_down : StreamReader
_reader : Optional[Task]
_reader : Task | None
_decryptor : CipherContext
_up : StreamWriter
_writer : Optional[Task]
_writer : Task | None
_encryptor : CipherContext
_dispatching : bool
@ -41,8 +40,8 @@ class Dispatcher:
_incoming : Queue
_outgoing : Queue
_packet_whitelist : Optional[Set[Type[Packet]]]
_packet_id_whitelist : Optional[Set[int]]
_packet_whitelist : set[Type[Packet]] | None
_packet_id_whitelist : set[int] | None
_log_ignored_packets : bool
@ -52,20 +51,39 @@ class Dispatcher:
_proto : int
_encryption : bool
_compression : Optional[int]
_compression : int | None
state : ConnectionState # TODO make getter/setter ?
logger : logging.Logger
def __init__(self, server:bool = False):
self._proto = 757
def __init__(
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._host = "localhost"
self._port = 25565
self._dispatching = False
self._packet_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
def proto(self) -> int:
@ -84,7 +102,7 @@ class Dispatcher:
return self._encryption
@property
def compression(self) -> Optional[int]:
def compression(self) -> int | None:
return self._compression
@property
@ -112,7 +130,7 @@ class Dispatcher:
except asyncio.TimeoutError:
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:
cipher = encryption.create_AES_cipher(secret)
self._encryptor = cipher.encryptor()
@ -122,52 +140,20 @@ class Dispatcher:
else:
self._encryption = False
self.logger.info("Encryption disabled")
return self
def whitelist(self, ids:Optional[List[Type[Packet]]]) -> 'Dispatcher':
self._packet_whitelist = set(ids) if ids 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(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
def update_compression_threshold(self, threshold: int | None):
self._compression = threshold or 0
async def connect(self,
reader : Optional[StreamReader] = None,
writer : Optional[StreamWriter] = None,
queue_size : int = 100,
) -> 'Dispatcher':
reader : StreamReader | None = None,
writer : StreamWriter | None = None,
queue_size : int = 100,
):
if self.connected:
raise InvalidState("Dispatcher already connected")
self.logger = LOGGER.getChild(f"on({self._host}:{self._port})")
self._encryption = False
self._compression = None
self._incoming = Queue(queue_size)
@ -191,7 +177,7 @@ class Dispatcher:
self.logger.info("Connected")
return self
async def disconnect(self, block:bool=True) -> 'Dispatcher':
async def disconnect(self, block:bool=True):
self._dispatching = False
if block and self._writer and self._reader:
await asyncio.gather(self._writer, self._reader)
@ -314,7 +300,7 @@ class Dispatcher:
self.logger.debug("%s", buffer.getvalue())
await self.disconnect(block=False)
async def _up_worker(self, timeout=1):
async def _up_worker(self, timeout:float = 1.):
while self._dispatching:
try:
packet : Packet = await asyncio.wait_for(self._outgoing.get(), timeout=timeout)
@ -325,7 +311,7 @@ class Dispatcher:
return
try:
buffer = packet.serialize()
buffer = packet.serialize(self.proto)
length = len(buffer.getvalue()) # ewww TODO
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 typing import Tuple, List, Dict, Any
from .types import Type, VarInt, Context
from .primitives import Type, VarInt, Context
MAX_FIELD_PRINT_SIZE = 255
class Packet:
__slots__ = 'id', 'definition', '_processed', '_proto', '_state'
id : int
definition : List[Tuple[str, Type]]
id : int | None
definition : List[Tuple[str, Type]] | None
_processed : Event
_proto : int
_proto : int | None
_state : int
_ids : Dict[int, int] # 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):
self._proto = proto
def __init__(self, **kwargs):
if not self._definitions:
raise NotImplementedError("cannot instantiate Packet base class")
self.id = None
self.definition = None
self._proto = None
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:
proto -= 1
self.definition = self._definitions[proto]
self.id = self._ids[proto]
for name, t in self.definition:
if name in kwargs and kwargs[name] is not None:
setattr(self, name, kwargs[name])
return self.id
@property
def processed(self) -> Event:
"""Returns an event which will be set only after the packet has been processed (either sent or raised exc)"""
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
def deserialize(cls, proto:int, buffer:io.BytesIO):
ctx = Context(_proto=proto)
@ -43,10 +56,13 @@ class Packet:
fallback_proto -= 1
for k, t in cls._definitions[fallback_proto]:
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] })
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)
buf = io.BytesIO()
VarInt.write(self.id, buf, ctx=ctx)
@ -60,9 +76,11 @@ class Packet:
def __eq__(self, other) -> bool:
if not isinstance(other, self.__class__):
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
for name, t in self.definition:
for name in self.slots:
if getattr(self, name) != getattr(other, name):
return False
return True
@ -73,13 +91,13 @@ class Packet:
obj["_proto"] = self._proto
obj["_state"] = self._state
obj["_id"] = f"0x{self.id:02x}"
for key, t in self.definition:
for key in self.slots:
obj[key] = getattr(self, key, None)
return json.dumps(obj, indent=2, default=str)
def __repr__(self) -> str:
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)})"

View file

@ -1,15 +1,14 @@
import io
import struct
import asyncio
import json
import uuid
import logging
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:
def __init__(self, **kwargs):
@ -390,7 +389,7 @@ class ParticleType(Type):
# TODO this changes across versions!
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
while proto not in ParticlesDefinitions._definitions:
proto -= 1
@ -414,7 +413,7 @@ class EntityMetadataType(Type):
buffer.write(b'\xFF')
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
while proto not in MetadataDefinitions._definitions:
proto -= 1

View file

@ -1,4 +1,4 @@
from ..types import *
from ..primitives import *
class MetadataDefinitions:
_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 ), )},
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 ), )},
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 ), )},
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 ), )},
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 ), )}
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 ), ), 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 ), ), 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 ....packet import Packet
from ....definitions import *
from ....types import *
from ....primitives import *
class PacketLegacyServerListPing(Packet):
__slots__ = ( 'id', 'payload' )
payload : int
def __init__(self, proto:int,
payload:int=None,
def __init__(self,
payload:int | None = None,
**kwargs
):
super().__init__(proto,
super().__init__(
payload=payload
)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,33 +2,36 @@
from typing import Tuple, List, Dict, Union, Optional
from ....packet import Packet
from ....definitions import *
from ....types import *
from ....primitives import *
class PacketEntitySoundEffect(Packet):
__slots__ = ( 'id', 'entityId', 'pitch', 'seed', 'soundCategory', 'soundId', 'volume' )
__slots__ = ( 'id', 'entityId', 'pitch', 'seed', 'soundCategory', 'soundEvent', 'soundId', 'volume' )
entityId : int
pitch : float
seed : int
soundCategory : int
soundEvent : Union[None, dict]
soundId : int
volume : float
def __init__(self, proto:int,
entityId:int=None,
pitch:float=None,
seed:int=None,
soundCategory:int=None,
soundId:int=None,
volume:float=None,
def __init__(self,
entityId:int | None = None,
pitch:float | None = None,
seed:int | None = None,
soundCategory:int | None = None,
soundEvent:Union[None, dict] | None = None,
soundId:int | None = None,
volume:float | None = None,
**kwargs
):
super().__init__(proto,
super().__init__(
entityId=entityId,
pitch=pitch,
seed=seed,
soundCategory=soundCategory,
soundEvent=soundEvent,
soundId=soundId,
volume=volume
)
@ -75,5 +78,5 @@ class PacketEntitySoundEffect(Packet):
758 : [ ( '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 ) ],
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 ....packet import Packet
from ....definitions import *
from ....types import *
from ....primitives import *
class PacketEntityStatus(Packet):
__slots__ = ( 'id', 'entityId', 'entityStatus' )
@ -11,12 +11,12 @@ class PacketEntityStatus(Packet):
entityId : int
entityStatus : int
def __init__(self, proto:int,
entityId:int=None,
entityStatus:int=None,
def __init__(self,
entityId:int | None = None,
entityStatus:int | None = None,
**kwargs
):
super().__init__(proto,
super().__init__(
entityId=entityId,
entityStatus=entityStatus
)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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