mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-12-22 16:48:33 +01:00
Fix: EntityPositionDeltaPacket.delta_{x,y,z} use wrong format
This commit is contained in:
parent
eae6e5c9cd
commit
cf93923acc
@ -240,14 +240,14 @@ class EntityPositionDeltaPacket(Packet):
|
||||
]
|
||||
|
||||
# The following transforms are retained for backward compatibility;
|
||||
# they represent the delta values as fixed-point integers with 5 bits
|
||||
# they represent the delta values as fixed-point integers with 12 bits
|
||||
# of fractional part, regardless of the protocol version.
|
||||
delta_x = attribute_transform('delta_x_float', lambda x: int(x * 32),
|
||||
lambda x: x / 32)
|
||||
delta_y = attribute_transform('delta_y_float', lambda y: int(y * 32),
|
||||
lambda y: y / 32)
|
||||
delta_z = attribute_transform('delta_z_float', lambda z: int(z * 32),
|
||||
lambda z: z / 32)
|
||||
delta_x = attribute_transform(
|
||||
'delta_x_float', lambda x: int(x * 4096), lambda x: x / 4096)
|
||||
delta_y = attribute_transform(
|
||||
'delta_y_float', lambda y: int(y * 4096), lambda y: y / 4096)
|
||||
delta_z = attribute_transform(
|
||||
'delta_z_float', lambda z: int(z * 4096), lambda z: z / 4096)
|
||||
|
||||
|
||||
class TimeUpdatePacket(Packet):
|
||||
|
@ -163,12 +163,12 @@ class ClassMemberAliasesTest(unittest.TestCase):
|
||||
|
||||
def test_entity_position_delta_packet(self):
|
||||
packet = clientbound.play.EntityPositionDeltaPacket()
|
||||
packet.delta_x = -128
|
||||
packet.delta_x = -32768
|
||||
packet.delta_y = 33
|
||||
packet.delta_z = 127
|
||||
self.assertEqual(packet.delta_x_float, -4.0)
|
||||
self.assertEqual(packet.delta_y_float, 1.03125)
|
||||
self.assertEqual(packet.delta_z_float, 3.96875)
|
||||
self.assertEqual(packet.delta_x, -128)
|
||||
packet.delta_z = 32767
|
||||
self.assertEqual(packet.delta_x_float, -8.0)
|
||||
self.assertEqual(packet.delta_y_float, 0.008056640625)
|
||||
self.assertEqual(packet.delta_z_float, 7.999755859375)
|
||||
self.assertEqual(packet.delta_x, -32768)
|
||||
self.assertEqual(packet.delta_y, 33)
|
||||
self.assertEqual(packet.delta_z, 127)
|
||||
self.assertEqual(packet.delta_z, 32767)
|
||||
|
Loading…
Reference in New Issue
Block a user