2019-05-14 18:41:58 +02:00
|
|
|
from minecraft.networking.types import (
|
2020-08-17 06:13:24 +02:00
|
|
|
Vector, Float, Byte, Integer, PrefixedArray, multi_attribute_alias, Type,
|
2019-05-14 18:41:58 +02:00
|
|
|
)
|
2018-05-27 14:28:01 +02:00
|
|
|
from minecraft.networking.packets import Packet
|
|
|
|
|
|
|
|
|
|
|
|
class ExplosionPacket(Packet):
|
|
|
|
@staticmethod
|
|
|
|
def get_id(context):
|
2020-08-17 06:13:24 +02:00
|
|
|
return 0x1B if context.protocol_version >= 741 else \
|
|
|
|
0x1C if context.protocol_version >= 721 else \
|
2020-06-19 01:18:29 +02:00
|
|
|
0x1D if context.protocol_version >= 550 else \
|
2019-12-11 06:52:25 +01:00
|
|
|
0x1C if context.protocol_version >= 471 else \
|
2019-05-11 08:43:08 +02:00
|
|
|
0x1E if context.protocol_version >= 389 else \
|
2018-07-19 02:59:48 +02:00
|
|
|
0x1D if context.protocol_version >= 345 else \
|
2018-05-27 14:28:01 +02:00
|
|
|
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'
|
|
|
|
|
2020-08-17 06:13:24 +02:00
|
|
|
class Record(Vector, Type):
|
|
|
|
__slots__ = ()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def read(cls, file_object):
|
|
|
|
return cls(*(Byte.read(file_object) for i in range(3)))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def send(cls, record, socket):
|
|
|
|
for coord in record:
|
|
|
|
Byte.send(coord, socket)
|
|
|
|
|
|
|
|
definition = [
|
|
|
|
{'x': Float},
|
|
|
|
{'y': Float},
|
|
|
|
{'z': Float},
|
|
|
|
{'radius': Float},
|
|
|
|
{'records': PrefixedArray(Integer, Record)},
|
|
|
|
{'player_motion_x': Float},
|
|
|
|
{'player_motion_y': Float},
|
|
|
|
{'player_motion_z': Float}]
|
2018-05-27 14:28:01 +02:00
|
|
|
|
2019-06-08 15:38:20 +02:00
|
|
|
# Access the 'x', 'y', 'z' fields as a Vector tuple.
|
2019-05-14 18:41:58 +02:00
|
|
|
position = multi_attribute_alias(Vector, 'x', 'y', 'z')
|
2018-05-27 14:28:01 +02:00
|
|
|
|
2019-06-08 15:38:20 +02:00
|
|
|
# Access the 'player_motion_{x,y,z}' fields as a Vector tuple.
|
2019-05-14 18:41:58 +02:00
|
|
|
player_motion = multi_attribute_alias(
|
|
|
|
Vector, 'player_motion_x', 'player_motion_y', 'player_motion_z')
|