Add handlers

master
Tanner Collin 4 years ago
parent db8d8d7b85
commit 0b59e8c438
  1. 17
      bot.py
  2. 17
      packet_handlers.py
  3. 1
      requirements.txt

@ -21,6 +21,8 @@ from minecraft.networking.packets import Packet, clientbound, serverbound
from custom.networking.packets.clientbound.play.block_change_packet import BlockChangePacket
from panda3d.core import LPoint3f
import packet_handlers
importlib.reload(packet_handlers)
@ -44,14 +46,7 @@ def bot(global_state):
print(e)
sys.exit()
print("Logged in as %s..." % auth_token.username)
g.connection = Connection(
SERVER, 25565, auth_token=auth_token)
def handle_join_game(join_game_packet):
print('Connected.')
g.connection.register_packet_listener(
handle_join_game, clientbound.play.JoinGamePacket)
g.connection = Connection(SERVER, 25565, auth_token=auth_token)
g.chunks = ChunksManager(g.mcdata)
g.chunks.register(g.connection)
@ -67,9 +62,15 @@ def bot(global_state):
handler(packet, g)
return wrapper
h = packet_wrapper(packet_handlers.handle_join_game)
g.connection.register_packet_listener(h, clientbound.play.JoinGamePacket)
h = packet_wrapper(packet_handlers.handle_block_change)
g.connection.register_packet_listener(h, BlockChangePacket)
h = packet_wrapper(packet_handlers.handle_position_and_look)
g.connection.register_packet_listener(h, clientbound.play.PlayerPositionAndLookPacket)
try:
#while not player_info.pos:
# time.sleep(TICK)

@ -1,3 +1,16 @@
def handle_block_change(p, g):
from panda3d.core import *
def handle_join_game(packet, g):
print('Connected.')
print(packet)
g.info = packet
def handle_block_change(packet, g):
print('block change:')
print(p)
print(packet)
def handle_position_and_look(packet, g):
print('pos and look:')
print(packet)
p = LPoint3f(x=packet.x, y=packet.y, z=packet.z)
g.pos = p

@ -9,6 +9,7 @@ idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
panda3d==1.10.6.post2
pathtools==0.1.2
pycparser==2.20
pyCraft @ git+https://github.com/ammaraskar/pyCraft.git@cf93923acc2dcfbc076379b43842228d77aea188

Loading…
Cancel
Save