def send_with_context(value, socket, context):
     if context.protocol_version < 204:
         value *= 63.5
     if context.protocol_version >= 201:
         Float.send(value, socket)
     else:
         Byte.send(int(value), socket)
 def send_with_context(value, socket, context):
     if context.protocol_earlier(204):
         value *= 63.5
     if context.protocol_later_eq(201):
         Float.send(value, socket)
     else:
         Byte.send(int(value), socket)
 def read(self, file_object):
     self.entity_id = VarInt.read(file_object)
     self.type = Type(VarInt.read(file_object))
     if self.type == Type.INTERACT_AT:
         self.x = Float.read(file_object)
         self.y = Float.read(file_object)
         self.z = Float.read(file_object)
     if self.type == Type.INTERACT or self.type == Type.INTERACT_AT:
         self.hand = VarInt.read(file_object)
     self.sneaking = Boolean.read(file_object)
 def read_with_context(file_object, context):
     if context.protocol_version >= 201:
         value = Float.read(file_object)
     else:
         value = Byte.read(file_object)
     if context.protocol_version < 204:
         value /= 63.5
     return value
 def read_with_context(file_object, context):
     if context.protocol_later_eq(201):
         value = Float.read(file_object)
     else:
         value = Byte.read(file_object)
     if context.protocol_earlier(204):
         value /= 63.5
     return value
 def write_fields(self, packet_buffer):
     VarInt.send(self.entity_id, packet_buffer)
     VarInt.send(int(self.type), packet_buffer)
     if self.type == self.Type.INTERACT_AT:
         Float.send(x, packet_buffer)
         Float.send(y, packet_buffer)
         Float.send(z, packet_buffer)
     if self.type == self.Type.INTERACT or self.type == self.Type.INTERACT_AT:
         VarInt.send(self.hand, packet_buffer)
     Boolean.send(self.sneaking, packet_buffer)
 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 = Integer.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)
Exemple #8
0
 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 = Integer.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_fields(self, packet_buffer):
     Float.send(self.x, packet_buffer)
     Float.send(self.y, packet_buffer)
     Float.send(self.z, packet_buffer)
     Float.send(self.radius, packet_buffer)
     Integer.send(len(self.records), packet_buffer)
     for record in self.records:
         Byte.send(record.x, packet_buffer)
         Byte.send(record.y, packet_buffer)
         Byte.send(record.z, packet_buffer)
     Float.send(self.player_motion_x, packet_buffer)
     Float.send(self.player_motion_y, packet_buffer)
     Float.send(self.player_motion_z, packet_buffer)
Exemple #10
0
 def write_fields(self, packet_buffer):
     Float.send(self.x, packet_buffer)
     Float.send(self.y, packet_buffer)
     Float.send(self.z, packet_buffer)
     Float.send(self.radius, packet_buffer)
     Integer.send(len(self.records), packet_buffer)
     for record in self.records:
         Byte.send(record.x, packet_buffer)
         Byte.send(record.y, packet_buffer)
         Byte.send(record.z, packet_buffer)
     Float.send(self.player_motion_x, packet_buffer)
     Float.send(self.player_motion_y, packet_buffer)
     Float.send(self.player_motion_z, packet_buffer)