Begin port to 26.3: movement
This commit is contained in:
+34
-6
@@ -65,12 +65,23 @@ def tick(global_state):
|
||||
target = None
|
||||
|
||||
# make sure current chunks are loaded for physics
|
||||
if not g.chunks.check_loaded(g.info.render_distance):
|
||||
required_distance = getattr(g, 'physics_render_distance',
|
||||
g.info.render_distance)
|
||||
if not g.chunks.check_loaded(required_distance):
|
||||
if not g.chunks.loading:
|
||||
print('Loading chunks', end='', flush=True)
|
||||
g.chunks.loading = time.time()
|
||||
packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=0, yaw=0, on_ground=True)
|
||||
if getattr(g, 'protocol_version', 0) == 777:
|
||||
from minecraft.networking.modern import PlayerPositionRotation
|
||||
packet = PlayerPositionRotation(
|
||||
x=p.x, y=p.y, z=p.z, pitch=0, yaw=0, on_ground=True)
|
||||
else:
|
||||
packet = serverbound.play.PositionAndLookPacket(
|
||||
x=p.x, feet_y=p.y, z=p.z, pitch=0, yaw=0, on_ground=True)
|
||||
g.connection.write_packet(packet, force=True)
|
||||
if getattr(g, 'protocol_version', 0) == 777:
|
||||
from minecraft.networking.modern import ClientTickEnd
|
||||
g.connection.write_packet(ClientTickEnd(), force=True)
|
||||
return
|
||||
else:
|
||||
if g.chunks.loading:
|
||||
@@ -197,11 +208,28 @@ def tick(global_state):
|
||||
target_pitch_d = 0 - g.pitch
|
||||
g.pitch += utils.cap(target_pitch_d, 10)
|
||||
|
||||
packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=g.pitch, yaw=g.yaw, on_ground=(not in_air))
|
||||
g.connection.write_packet(packet)
|
||||
if getattr(g, 'protocol_version', 0) == 777:
|
||||
from minecraft.networking.modern import PlayerPositionRotation
|
||||
packet = PlayerPositionRotation(
|
||||
x=p.x, y=p.y, z=p.z, pitch=g.pitch, yaw=g.yaw,
|
||||
on_ground=(not in_air))
|
||||
else:
|
||||
packet = serverbound.play.PositionAndLookPacket(
|
||||
x=p.x, feet_y=p.y, z=p.z, pitch=g.pitch, yaw=g.yaw,
|
||||
on_ground=(not in_air))
|
||||
if getattr(g, 'protocol_version', 0) == 777:
|
||||
from minecraft.networking.modern import ClientTickEnd
|
||||
# Keep the client-tick boundary after its movement packet on the wire;
|
||||
# force=True on only the latter could overtake the queued position.
|
||||
g.connection.write_packet(packet, force=True)
|
||||
g.connection.write_packet(ClientTickEnd(), force=True)
|
||||
else:
|
||||
g.connection.write_packet(packet)
|
||||
|
||||
g.job.tick()
|
||||
g.game.tick() # order important for correction_count
|
||||
if g.job:
|
||||
g.job.tick()
|
||||
if g.game:
|
||||
g.game.tick() # order important for correction_count
|
||||
|
||||
|
||||
def init(global_state):
|
||||
|
||||
Reference in New Issue
Block a user