diff --git a/jobs/__init__.py b/mosfet/__init__.py similarity index 100% rename from jobs/__init__.py rename to mosfet/__init__.py diff --git a/blocks.py b/mosfet/blocks.py similarity index 100% rename from blocks.py rename to mosfet/blocks.py diff --git a/bot.py b/mosfet/bot.py similarity index 100% rename from bot.py rename to mosfet/bot.py diff --git a/game.py b/mosfet/game.py similarity index 100% rename from game.py rename to mosfet/game.py diff --git a/items.py b/mosfet/items.py similarity index 100% rename from items.py rename to mosfet/items.py diff --git a/job.py b/mosfet/job.py similarity index 100% rename from job.py rename to mosfet/job.py diff --git a/protocol/__init__.py b/mosfet/jobs/__init__.py similarity index 100% rename from protocol/__init__.py rename to mosfet/jobs/__init__.py diff --git a/jobs/cache_items.py b/mosfet/jobs/cache_items.py similarity index 100% rename from jobs/cache_items.py rename to mosfet/jobs/cache_items.py diff --git a/jobs/check_threats.py b/mosfet/jobs/check_threats.py similarity index 100% rename from jobs/check_threats.py rename to mosfet/jobs/check_threats.py diff --git a/jobs/clear_leaves.py b/mosfet/jobs/clear_leaves.py similarity index 100% rename from jobs/clear_leaves.py rename to mosfet/jobs/clear_leaves.py diff --git a/jobs/eat_food.py b/mosfet/jobs/eat_food.py similarity index 100% rename from jobs/eat_food.py rename to mosfet/jobs/eat_food.py diff --git a/jobs/fill_blocks.py b/mosfet/jobs/fill_blocks.py similarity index 100% rename from jobs/fill_blocks.py rename to mosfet/jobs/fill_blocks.py diff --git a/jobs/find_gapple.py b/mosfet/jobs/find_gapple.py similarity index 100% rename from jobs/find_gapple.py rename to mosfet/jobs/find_gapple.py diff --git a/jobs/gather_crop.py b/mosfet/jobs/gather_crop.py similarity index 100% rename from jobs/gather_crop.py rename to mosfet/jobs/gather_crop.py diff --git a/jobs/gather_sand.py b/mosfet/jobs/gather_sand.py similarity index 100% rename from jobs/gather_sand.py rename to mosfet/jobs/gather_sand.py diff --git a/jobs/gather_wart.py b/mosfet/jobs/gather_wart.py similarity index 100% rename from jobs/gather_wart.py rename to mosfet/jobs/gather_wart.py diff --git a/jobs/gather_wood.py b/mosfet/jobs/gather_wood.py similarity index 100% rename from jobs/gather_wood.py rename to mosfet/jobs/gather_wood.py diff --git a/jobs/grab_sand.py b/mosfet/jobs/grab_sand.py similarity index 100% rename from jobs/grab_sand.py rename to mosfet/jobs/grab_sand.py diff --git a/jobs/grab_sapling.py b/mosfet/jobs/grab_sapling.py similarity index 100% rename from jobs/grab_sapling.py rename to mosfet/jobs/grab_sapling.py diff --git a/jobs/grab_supplies.py b/mosfet/jobs/grab_supplies.py similarity index 100% rename from jobs/grab_supplies.py rename to mosfet/jobs/grab_supplies.py diff --git a/jobs/plant_tree.py b/mosfet/jobs/plant_tree.py similarity index 100% rename from jobs/plant_tree.py rename to mosfet/jobs/plant_tree.py diff --git a/jobs/sell_to_villager.py b/mosfet/jobs/sell_to_villager.py similarity index 100% rename from jobs/sell_to_villager.py rename to mosfet/jobs/sell_to_villager.py diff --git a/jobs/sleep_with_bed.py b/mosfet/jobs/sleep_with_bed.py similarity index 100% rename from jobs/sleep_with_bed.py rename to mosfet/jobs/sleep_with_bed.py diff --git a/main.py b/mosfet/main.py similarity index 100% rename from main.py rename to mosfet/main.py diff --git a/mcdata.py b/mosfet/mcdata.py similarity index 100% rename from mcdata.py rename to mosfet/mcdata.py diff --git a/mobs.py b/mosfet/mobs.py similarity index 100% rename from mobs.py rename to mosfet/mobs.py diff --git a/monkey_patch.py b/mosfet/monkey_patch.py similarity index 100% rename from monkey_patch.py rename to mosfet/monkey_patch.py diff --git a/path.py b/mosfet/path.py similarity index 100% rename from path.py rename to mosfet/path.py diff --git a/print_help.py b/mosfet/print_help.py similarity index 100% rename from print_help.py rename to mosfet/print_help.py diff --git a/mosfet/protocol/__init__.py b/mosfet/protocol/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/protocol/managers.py b/mosfet/protocol/managers.py similarity index 100% rename from protocol/managers.py rename to mosfet/protocol/managers.py diff --git a/protocol/packets.py b/mosfet/protocol/packets.py similarity index 100% rename from protocol/packets.py rename to mosfet/protocol/packets.py diff --git a/protocol/types.py b/mosfet/protocol/types.py similarity index 100% rename from protocol/types.py rename to mosfet/protocol/types.py diff --git a/utils.py b/mosfet/utils.py similarity index 100% rename from utils.py rename to mosfet/utils.py diff --git a/vector.py b/mosfet/vector.py similarity index 100% rename from vector.py rename to mosfet/vector.py diff --git a/test_pycraft.py b/test_pycraft.py deleted file mode 100644 index e6ee3a9..0000000 --- a/test_pycraft.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python - -import getpass -import sys -import re -from optparse import OptionParser - -from custom.managers import DataManager, ChunksManager -from custom.networking.packets.clientbound.play import chunk_data, block_change_packet - -import minecraft.networking.packets - -def get_packets(old_get_packets): - def wrapper(func, context): - print('Monkey-patched.') - packets = func(context) - packets.add(chunk_data.ChunkDataPacket) - packets.add(block_change_packet.BlockChangePacket) - packets.add(block_change_packet.MultiBlockChangePacket) - return packets - return lambda x: wrapper(old_get_packets, x) - -minecraft.networking.packets.clientbound.play.get_packets = get_packets(minecraft.networking.packets.clientbound.play.get_packets) - -from minecraft import authentication -from minecraft.exceptions import YggdrasilError -from minecraft.networking.connection import Connection -from minecraft.networking.packets import Packet, clientbound, serverbound - - -def get_options(): - parser = OptionParser() - - parser.add_option("-u", "--username", dest="username", default=None, - help="username to log in with") - - parser.add_option("-p", "--password", dest="password", default=None, - help="password to log in with") - - parser.add_option("-s", "--server", dest="server", default=None, - help="server host or host:port " - "(enclose IPv6 addresses in square brackets)") - - parser.add_option("-o", "--offline", dest="offline", action="store_true", - help="connect to a server in offline mode " - "(no password required)") - - parser.add_option("-d", "--dump-packets", dest="dump_packets", - action="store_true", - help="print sent and received packets to standard error") - - parser.add_option("-v", "--dump-unknown-packets", dest="dump_unknown", - action="store_true", - help="include unknown packets in --dump-packets output") - - (options, args) = parser.parse_args() - - if not options.username: - options.username = input("Enter your username: ") - - if not options.password and not options.offline: - options.password = getpass.getpass("Enter your password (leave " - "blank for offline mode): ") - options.offline = options.offline or (options.password == "") - - if not options.server: - options.server = input("Enter server host or host:port " - "(enclose IPv6 addresses in square brackets): ") - # Try to split out port and address - match = re.match(r"((?P[^\[\]:]+)|\[(?P[^\[\]]+)\])" - r"(:(?P\d+))?$", options.server) - if match is None: - raise ValueError("Invalid server address: '%s'." % options.server) - options.address = match.group("host") or match.group("addr") - options.port = int(match.group("port") or 25565) - - return options - - -def main(): - options = get_options() - - mcdata = DataManager('./mcdata') - - if options.offline: - print("Connecting in offline mode...") - connection = Connection( - options.address, options.port, username=options.username) - else: - auth_token = authentication.AuthenticationToken() - try: - auth_token.authenticate(options.username, options.password) - except YggdrasilError as e: - print(e) - sys.exit() - print("Logged in as %s..." % auth_token.username) - connection = Connection( - options.address, options.port, auth_token=auth_token) - - if options.dump_packets: - def print_incoming(packet): - if type(packet) is Packet: - # This is a direct instance of the base Packet type, meaning - # that it is a packet of unknown type, so we do not print it - # unless explicitly requested by the user. - if options.dump_unknown: - print('--> [unknown packet] %s' % packet, file=sys.stderr) - else: - print('--> %s' % packet, file=sys.stderr) - - def print_outgoing(packet): - print('<-- %s' % packet, file=sys.stderr) - - connection.register_packet_listener( - print_incoming, Packet, early=True) - connection.register_packet_listener( - print_outgoing, Packet, outgoing=True) - - def handle_join_game(join_game_packet): - print('Connected.') - - connection.register_packet_listener( - handle_join_game, clientbound.play.JoinGamePacket) - - def print_chat(chat_packet): - print("Message (%s): %s" % ( - chat_packet.field_string('position'), chat_packet.json_data)) - - chunks = ChunksManager(mcdata) - chunks.register(connection) - - connection.register_packet_listener( - print_chat, clientbound.play.ChatMessagePacket) - - connection.connect() - - while True: - try: - text = input() - if text == "/respawn": - print("respawning...") - packet = serverbound.play.ClientStatusPacket() - packet.action_id = serverbound.play.ClientStatusPacket.RESPAWN - connection.write_packet(packet) - elif text == '!test': - print(chunks.get_block_at(91, 65, 57)) - else: - packet = serverbound.play.ChatPacket() - packet.message = text - connection.write_packet(packet) - except KeyboardInterrupt: - print("Bye!") - sys.exit() - - -if __name__ == "__main__": - main()