Add module for packet handlers and reload it
This commit is contained in:
21
bot.py
21
bot.py
@@ -4,14 +4,15 @@ if __name__ == '__main__':
|
||||
|
||||
import os
|
||||
import time
|
||||
import importlib
|
||||
|
||||
USERNAME = os.environ['USERNAME']
|
||||
PASSWORD = os.environ['PASSWORD']
|
||||
SERVER = os.environ['SERVER']
|
||||
|
||||
from custom.managers import DataManager, ChunksManager, ChatManager
|
||||
import monkey_patch # must be before any possible pyCraft imports
|
||||
|
||||
import monkey_patch
|
||||
from custom.managers import DataManager, ChunksManager, ChatManager
|
||||
|
||||
from minecraft import authentication
|
||||
from minecraft.exceptions import YggdrasilError
|
||||
@@ -20,6 +21,9 @@ from minecraft.networking.packets import Packet, clientbound, serverbound
|
||||
|
||||
from custom.networking.packets.clientbound.play.block_change_packet import BlockChangePacket
|
||||
|
||||
import packet_handlers
|
||||
importlib.reload(packet_handlers)
|
||||
|
||||
TICK = 0.05
|
||||
last_tick = time.time()
|
||||
|
||||
@@ -57,13 +61,14 @@ def bot(global_state):
|
||||
|
||||
g.connection.connect()
|
||||
|
||||
def packet_wrapper(handler):
|
||||
def wrapper(packet):
|
||||
print('called')
|
||||
handler(packet, g)
|
||||
return wrapper
|
||||
|
||||
def x(p):
|
||||
print('sup block change:')
|
||||
print(p)
|
||||
|
||||
g.connection.register_packet_listener(
|
||||
x, BlockChangePacket)
|
||||
h = packet_wrapper(packet_handlers.handle_block_change)
|
||||
g.connection.register_packet_listener(h, BlockChangePacket)
|
||||
|
||||
try:
|
||||
#while not player_info.pos:
|
||||
|
Reference in New Issue
Block a user