Add handlers
This commit is contained in:
17
bot.py
17
bot.py
@@ -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)
|
||||
|
Reference in New Issue
Block a user