2020-09-07 21:48:16 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
print('Run main.py instead.')
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
USERNAME = ''
|
|
|
|
PASSWORD = ''
|
|
|
|
SERVER = ''
|
|
|
|
|
|
|
|
from custom.managers import DataManager, ChunksManager, ChatManager
|
|
|
|
|
2020-09-07 22:08:59 +00:00
|
|
|
import monkey_patch
|
2020-09-07 21:48:16 +00:00
|
|
|
|
|
|
|
from minecraft import authentication
|
|
|
|
from minecraft.exceptions import YggdrasilError
|
|
|
|
from minecraft.networking.connection import Connection
|
|
|
|
from minecraft.networking.packets import Packet, clientbound, serverbound
|
|
|
|
|
|
|
|
def bot(global_state):
|
|
|
|
g = global_state
|
|
|
|
|
|
|
|
if 'mcdata' not in g:
|
|
|
|
g.mcdata = DataManager('./mcdata')
|
|
|
|
|
|
|
|
if 'connection' not in g:
|
|
|
|
auth_token = authentication.AuthenticationToken()
|
|
|
|
try:
|
|
|
|
auth_token.authenticate(USERNAME, PASSWORD)
|
|
|
|
except YggdrasilError as e:
|
|
|
|
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.chunks = ChunksManager(g.mcdata)
|
|
|
|
g.chunks.register(g.connection)
|
|
|
|
|
|
|
|
g.chat = ChatManager()
|
|
|
|
g.chat.register(g.connection)
|
|
|
|
|
|
|
|
g.connection.connect()
|
|
|
|
|
|
|
|
time.sleep(1)
|