Wait for chunks to load and tune physics
This commit is contained in:
parent
d37f55a2db
commit
1d4adb796a
35
bot.py
35
bot.py
|
@ -14,7 +14,7 @@ from minecraft.networking.connection import Connection
|
|||
from minecraft.networking.packets import Packet, clientbound, serverbound
|
||||
from minecraft.networking.types import BlockFace, VarInt, Position, Boolean, Byte
|
||||
from minecraft.compat import input
|
||||
from minecraft.managers import ChunksManager
|
||||
from minecraft.managers import chunks, ChunksManager
|
||||
|
||||
|
||||
#class AcknowledgePlayerDiggingPacket(Packet):
|
||||
|
@ -729,12 +729,16 @@ def cap(x, amount):
|
|||
|
||||
|
||||
def tick(connection, player_info):
|
||||
s['jobstate'].run()
|
||||
|
||||
target = None
|
||||
|
||||
p = player_info.pos
|
||||
|
||||
try:
|
||||
player_info.chunks.get_block_at(*pint(p))
|
||||
except chunks.ChunkNotLoadedException:
|
||||
return
|
||||
|
||||
s['jobstate'].run()
|
||||
|
||||
if s['path'] and len(s['path']):
|
||||
target = LPoint3f(s['path'][0])
|
||||
target.x += 0.5
|
||||
|
@ -749,27 +753,33 @@ def tick(connection, player_info):
|
|||
s['y_a'] = -36.0
|
||||
|
||||
# jump gap
|
||||
if d.xz.length() > 1.9 and not s['y_v']:
|
||||
s['y_v'] = 10.0
|
||||
if d.xz.length() > 1.6 and not s['y_v']:
|
||||
s['y_v'] = 8.5
|
||||
s['y_a'] = -36.0
|
||||
|
||||
if d.length() > 0.2:
|
||||
if d.length() > 0:
|
||||
if s['y_v'] < 5:
|
||||
p.x -= cap(d.x, 0.2)
|
||||
p.z -= cap(d.z, 0.2)
|
||||
else:
|
||||
|
||||
if len(s['path']) > 1 and d.length() < 0.2:
|
||||
s['path'].pop(0)
|
||||
|
||||
|
||||
if s['y_v'] or s['y_a']:
|
||||
p.y += s['y_v'] * TICK
|
||||
s['y_v'] += s['y_a'] * TICK
|
||||
|
||||
if player_info.chunks.get_block_at(floor(p.x), ceil(p.y-1), floor(p.z)) not in blocks.NON_SOLID_IDS:
|
||||
block_below = player_info.chunks.get_block_at(floor(p.x), ceil(p.y-1), floor(p.z))
|
||||
in_air = block_below in blocks.NON_SOLID_IDS
|
||||
|
||||
if in_air:
|
||||
s['y_a'] = -36.0
|
||||
else:
|
||||
p.y = ceil(p.y)
|
||||
s['y_v'] = 0
|
||||
s['y_a'] = 0
|
||||
else:
|
||||
s['y_a'] = -36.0
|
||||
|
||||
|
||||
|
||||
if s['look_at']:
|
||||
|
@ -801,8 +811,7 @@ def tick(connection, player_info):
|
|||
s['pitch'] += cap(target_pitch_d, 10)
|
||||
|
||||
|
||||
|
||||
packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=s['pitch'], yaw=s['yaw'], on_ground=True)
|
||||
packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=s['pitch'], yaw=s['yaw'], on_ground=(not in_air))
|
||||
connection.write_packet(packet, force=True)
|
||||
|
||||
if s['break']:
|
||||
|
|
Loading…
Reference in New Issue
Block a user