Add serialisation and tests for Explosion, {Multi,}BlockChange, and CombatEvent packets.
This commit is contained in:
1 parent
92f2eff681
commit
709b80b539
11 files changed
+278
-136
No files matched your search
@@ -3,8 +3,8 @@ from minecraft.networking.packets import (
|
||||
)
|
||||
|
||||
from minecraft.networking.types import (
|
||||
Integer, UnsignedByte, Byte, Boolean, UUID, Short, Position,
|
||||
VarInt, Double, Float, String, Enum,
|
||||
Integer, UnsignedByte, Byte, Boolean, UUID, Short, VarInt, Double, Float,
|
||||
String, Enum,
|
||||
)
|
||||
|
||||
from .combat_event_packet import CombatEventPacket
|
||||
@@ -13,6 +13,7 @@ from .player_list_item_packet import PlayerListItemPacket
|
||||
from .player_position_and_look_packet import PlayerPositionAndLookPacket
|
||||
from .spawn_object_packet import SpawnObjectPacket
|
||||
from .block_change_packet import BlockChangePacket, MultiBlockChangePacket
|
||||
from .explosion_packet import ExplosionPacket
|
||||
|
||||
|
||||
# Formerly known as state_playing_clientbound.
|
||||
@@ -176,42 +177,6 @@ class UpdateHealthPacket(Packet):
|
||||
])
|
||||
|
||||
|
||||
class ExplosionPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x1D if context.protocol_version >= 345 else \
|
||||
0x1C if context.protocol_version >= 332 else \
|
||||
0x1D if context.protocol_version >= 318 else \
|
||||
0x1C if context.protocol_version >= 80 else \
|
||||
0x1B if context.protocol_version >= 67 else \
|
||||
0x27
|
||||
|
||||
packet_name = 'explosion'
|
||||
|
||||
class Record(Position):
|
||||
pass
|
||||
|
||||
def read(self, file_object):
|
||||
self.x = Float.read(file_object)
|
||||
self.y = Float.read(file_object)
|
||||
self.z = Float.read(file_object)
|
||||
self.radius = Float.read(file_object)
|
||||
records_count = VarInt.read(file_object)
|
||||
self.records = []
|
||||
for i in range(records_count):
|
||||
rec_x = Byte.read(file_object)
|
||||
rec_y = Byte.read(file_object)
|
||||
rec_z = Byte.read(file_object)
|
||||
record = ExplosionPacket.Record(rec_x, rec_y, rec_z)
|
||||
self.records.append(record)
|
||||
self.player_motion_x = Float.read(file_object)
|
||||
self.player_motion_y = Float.read(file_object)
|
||||
self.player_motion_z = Float.read(file_object)
|
||||
|
||||
def write(self, socket, compression_threshold=None):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
|
||||
Reference in new issue
Block a user