Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tooldelta/constants/netease.py

This file was deleted.

3 changes: 3 additions & 0 deletions tooldelta/mc_bytes_packet/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@
from .structure_template_data_response import (
StructureTemplateDataResponse,
)
from .py_rpc import PyRpc


class BytesPacketIDs(IntEnum):
SubChunkRequest = PacketIDS.IDSubChunkRequest
LevelChunk = PacketIDS.IDLevelChunk
SubChunk = PacketIDS.IDSubChunk
StructureTemplateDataResponse = PacketIDS.IDStructureTemplateDataResponse
PyRpc = PacketIDS.PyRpc


BYTES_PACKET_ID_POOL: dict[int, Callable[[], BaseBytesPacket]] = {
PacketIDS.IDSubChunkRequest: lambda: SubChunkRequest(),
PacketIDS.IDLevelChunk: lambda: LevelChunk(),
PacketIDS.IDSubChunk: lambda: SubChunk(),
PacketIDS.IDStructureTemplateDataResponse: lambda: StructureTemplateDataResponse(),
PacketIDS.IDPyRpc: lambda: PyRpc()
}


Expand Down
41 changes: 41 additions & 0 deletions tooldelta/mc_bytes_packet/py_rpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import struct
import msgpack
from dataclasses import dataclass
from io import BytesIO
from tooldelta.constants.packets import PacketIDS
from tooldelta.mc_bytes_packet.base_bytes_packet import BaseBytesPacket
from typing import Any

PYRPC_OP_SEND = 0x05DB23AE
PYRPC_OP_RECV = 0x0094D408


@dataclass
class PyRpc(BaseBytesPacket):
Value: Any = None
OperationType: int = 0

def name(self) -> str:
return "PyRpc"

def custom_packet_id(self) -> int:
return 4

def real_packet_id(self) -> int:
return PacketIDS.IDPyRpc

def encode(self) -> bytes:
writer = BytesIO()
payload = msgpack.packb(self.Value, use_bin_type=True)
writer.write(struct.pack("<I", len(payload))) # type: ignore
writer.write(payload) # type: ignore
writer.write(struct.pack("<I", self.OperationType))
return writer.getvalue()

def decode(self, bs: bytes):
reader = BytesIO(bs)
length = struct.unpack("<I", reader.read(4))[0]
self.Value = msgpack.unpackb(
reader.read(length), raw=False, strict_map_key=False
)
self.OperationType = struct.unpack("<I", reader.read(4))[0]