Move bot files into mosfet/

master
Tanner Collin 3 years ago
parent 4d2b09e578
commit 3c373ccfe3
  1. 0
      mosfet/__init__.py
  2. 0
      mosfet/blocks.py
  3. 0
      mosfet/bot.py
  4. 0
      mosfet/game.py
  5. 0
      mosfet/items.py
  6. 0
      mosfet/job.py
  7. 0
      mosfet/jobs/__init__.py
  8. 0
      mosfet/jobs/cache_items.py
  9. 0
      mosfet/jobs/check_threats.py
  10. 0
      mosfet/jobs/clear_leaves.py
  11. 0
      mosfet/jobs/eat_food.py
  12. 0
      mosfet/jobs/fill_blocks.py
  13. 0
      mosfet/jobs/find_gapple.py
  14. 0
      mosfet/jobs/gather_crop.py
  15. 0
      mosfet/jobs/gather_sand.py
  16. 0
      mosfet/jobs/gather_wart.py
  17. 0
      mosfet/jobs/gather_wood.py
  18. 0
      mosfet/jobs/grab_sand.py
  19. 0
      mosfet/jobs/grab_sapling.py
  20. 0
      mosfet/jobs/grab_supplies.py
  21. 0
      mosfet/jobs/plant_tree.py
  22. 0
      mosfet/jobs/sell_to_villager.py
  23. 0
      mosfet/jobs/sleep_with_bed.py
  24. 0
      mosfet/main.py
  25. 0
      mosfet/mcdata.py
  26. 0
      mosfet/mobs.py
  27. 0
      mosfet/monkey_patch.py
  28. 0
      mosfet/path.py
  29. 0
      mosfet/print_help.py
  30. 0
      mosfet/protocol/__init__.py
  31. 0
      mosfet/protocol/managers.py
  32. 0
      mosfet/protocol/packets.py
  33. 0
      mosfet/protocol/types.py
  34. 0
      mosfet/utils.py
  35. 0
      mosfet/vector.py
  36. 157
      test_pycraft.py

@ -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<host>[^\[\]:]+)|\[(?P<addr>[^\[\]]+)\])"
r"(:(?P<port>\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()
Loading…
Cancel
Save