Fix imports

This commit is contained in:
Tanner Collin 2021-04-22 00:46:54 +00:00
parent d099ae6965
commit 38f3b0ed67
28 changed files with 167 additions and 169 deletions

View File

@ -5,7 +5,7 @@ set -eu
VERSION="1.16.4" VERSION="1.16.4"
wget -Omcdata.zip "https://apimon.de/mcdata/$VERSION/$VERSION.zip" wget -Omcdata.zip "https://apimon.de/mcdata/$VERSION/$VERSION.zip"
rm -r mosfet/minecraft_data rm -r minecraft_data || true
mkdir mosfet/minecraft_data mkdir minecraft_data
unzip mcdata.zip -d mosfet/minecraft_data unzip mcdata.zip -d minecraft_data
rm mcdata.zip rm mcdata.zip

View File

@ -11,7 +11,7 @@ from munch import Munch
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler from watchdog.events import PatternMatchingEventHandler
import bot from mosfet import bot
global_state = Munch() global_state = Munch()
g = global_state g = global_state

View File

@ -1,7 +1,7 @@
import json import json
import importlib import importlib
import mcdata from mosfet import mcdata
MCD_BLOCKS = {} MCD_BLOCKS = {}
for d in mcdata.mcd.blocks.values(): for d in mcdata.mcd.blocks.values():

View File

@ -13,28 +13,27 @@ PASSWORD = os.environ['PASSWORD']
SERVER = os.environ['SERVER'] SERVER = os.environ['SERVER']
PORT = int(os.environ.get('PORT', 25565)) PORT = int(os.environ.get('PORT', 25565))
import monkey_patch # must be before any possible pyCraft imports from . import monkey_patch # must be before any possible pyCraft imports
from minecraft import authentication from minecraft import authentication
from minecraft.exceptions import YggdrasilError from minecraft.exceptions import YggdrasilError
from minecraft.networking.connection import Connection from minecraft.networking.connection import Connection
from minecraft.networking.packets import Packet, clientbound, serverbound from minecraft.networking.packets import Packet, clientbound, serverbound
from protocol.managers import DataManager, ChunksManager, ChatManager, ChunkNotLoadedException from mosfet.protocol.managers import DataManager, ChunksManager, ChatManager, ChunkNotLoadedException
from munch import Munch from munch import Munch
from vector import Point3D, Vector3D
import blocks from mosfet import blocks
import game from mosfet import game
import items from mosfet import items
import job from mosfet import job
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
import path from mosfet import path
import print_help from mosfet import print_help
import utils from mosfet import utils
import vector from mosfet import vector
for module in [ for module in [
blocks, blocks,
@ -52,9 +51,9 @@ for module in [
last_tick = time.time() last_tick = time.time()
PITCH_ANGLE_DIR = Vector3D((0, 1, 0)) PITCH_ANGLE_DIR = vector.Vector3D((0, 1, 0))
YAW_ANGLE_DIR = Vector3D((0, 0, -1)) YAW_ANGLE_DIR = vector.Vector3D((0, 0, -1))
YAW_ANGLE_REF = Vector3D((0, 1, 0)) YAW_ANGLE_REF = vector.Vector3D((0, 1, 0))
YAW_LOOK_AHEAD = 4 YAW_LOOK_AHEAD = 4
@ -116,7 +115,7 @@ def tick(global_state):
########## player physics ########## ########## player physics ##########
if g.path and len(g.path): if g.path and len(g.path):
target = Point3D(g.path[0]) target = vector.Point3D(g.path[0])
target.x += 0.5 target.x += 0.5
target.z += 0.5 target.z += 0.5
@ -169,11 +168,11 @@ def tick(global_state):
g.y_a = 0 g.y_a = 0
if g.look_at: if g.look_at:
look_at = Point3D(g.look_at) look_at = vector.Point3D(g.look_at)
elif g.path and len(g.path) > YAW_LOOK_AHEAD: elif g.path and len(g.path) > YAW_LOOK_AHEAD:
look_at = Point3D(g.path[YAW_LOOK_AHEAD]) look_at = vector.Point3D(g.path[YAW_LOOK_AHEAD])
elif g.path and len(g.path): elif g.path and len(g.path):
look_at = Point3D(g.path[-1]) look_at = vector.Point3D(g.path[-1])
else: else:
look_at = None look_at = None

View File

@ -8,12 +8,10 @@ from itertools import count
from munch import Munch from munch import Munch
from copy import copy from copy import copy
from vector import Point3D
from minecraft.networking.packets import Packet, clientbound, serverbound from minecraft.networking.packets import Packet, clientbound, serverbound
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.packets import ( from mosfet.protocol.packets import (
SetSlotPacket, PlayerDiggingPacket, SetSlotPacket, PlayerDiggingPacket,
BlockBreakAnimationPacket, AcknowledgePlayerDiggingPacket, BlockBreakAnimationPacket, AcknowledgePlayerDiggingPacket,
HeldItemChangePacket, PickItemPacket, OpenWindowPacket, HeldItemChangePacket, PickItemPacket, OpenWindowPacket,
@ -24,16 +22,17 @@ from protocol.packets import (
SelectTradePacket, DisconnectPacket, SelectTradePacket, DisconnectPacket,
) )
from protocol.types import Slot from mosfet.protocol.types import Slot
import print_help
import utils from mosfet import print_help
import path from mosfet import utils
import blocks from mosfet import path
import items from mosfet import blocks
import mcdata from mosfet import items
import mobs from mosfet import mcdata
import bot from mosfet import mobs
from mosfet import bot
from mosfet import vector
class MCWorld: class MCWorld:
def __init__(self, global_state): def __init__(self, global_state):
@ -387,7 +386,7 @@ class Game:
def handle_block_change(self, packet): def handle_block_change(self, packet):
if packet.block_state_id == blocks.SOUL_TORCH: if packet.block_state_id == blocks.SOUL_TORCH:
try: try:
self.g.goal = Point3D((packet.location[0], packet.location[1], packet.location[2])) self.g.goal = vector.Point3D((packet.location[0], packet.location[1], packet.location[2]))
print('new waypoint:', self.g.goal) print('new waypoint:', self.g.goal)
start = time.time() start = time.time()
@ -414,7 +413,7 @@ class Game:
def handle_position_and_look(self, packet): def handle_position_and_look(self, packet):
print(packet) print(packet)
p = Point3D((packet.x, packet.y, packet.z)) p = vector.Point3D((packet.x, packet.y, packet.z))
self.g.pos = p self.g.pos = p
confirm_packet = serverbound.play.TeleportConfirmPacket() confirm_packet = serverbound.play.TeleportConfirmPacket()

View File

@ -7,16 +7,16 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
from jobs import ( from mosfet.jobs import (
cache_items, cache_items,
check_threats, check_threats,
clear_leaves, clear_leaves,

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class CacheItemsStates: class CacheItemsStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class CheckThreatsStates: class CheckThreatsStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class ClearLeavesStates: class ClearLeavesStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class EatFoodStates: class EatFoodStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class FillBlocksStates: class FillBlocksStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class FindGappleStates: class FindGappleStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GatherCropStates: class GatherCropStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GatherSandStates: class GatherSandStates:
def bair(self, p): def bair(self, p):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GatherWartStates: class GatherWartStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GatherWoodStates: class GatherWoodStates:
def bair(self, p): def bair(self, p):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GrabSandStates: class GrabSandStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GrabSaplingStates: class GrabSaplingStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class GrabSuppliesStates: class GrabSuppliesStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class PlantTreeStates: class PlantTreeStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class SellToVillagerStates: class SellToVillagerStates:
def idle(self): def idle(self):

View File

@ -7,14 +7,14 @@ from math import hypot, floor
from minecraft.networking.types import BlockFace from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException from mosfet.protocol.managers import ChunkNotLoadedException
import utils from mosfet import utils
import path from mosfet import path
import blocks from mosfet import blocks
import items from mosfet import items
import mcdata from mosfet import mcdata
import mobs from mosfet import mobs
class SleepWithBedStates: class SleepWithBedStates:
def idle(self): def idle(self):

View File

@ -1,5 +1,5 @@
import minecraft.networking.packets import minecraft.networking.packets
from protocol import packets from .protocol import packets
def get_packets(old_get_packets): def get_packets(old_get_packets):
def wrapper(func, context): def wrapper(func, context):

View File

@ -5,8 +5,8 @@ from math import hypot, sqrt
from astar import AStar from astar import AStar
import blocks from mosfet import blocks
import utils from mosfet import utils
class AStarTimeout(Exception): class AStarTimeout(Exception):
pass pass

View File

@ -1,6 +1,6 @@
HELP_LINES = [] HELP_LINES = []
with open('game.py', 'r') as f: with open('mosfet/game.py', 'r') as f:
for line in f.readlines(): for line in f.readlines():
if line.strip().startswith('## '): if line.strip().startswith('## '):
HELP_LINES.append(line.strip()[3:]) HELP_LINES.append(line.strip()[3:])

View File

@ -4,9 +4,9 @@ import json
import time import time
from minecraft.networking.packets import clientbound, serverbound from minecraft.networking.packets import clientbound, serverbound
from protocol import packets from mosfet.protocol import packets
import utils from mosfet import utils
class DataManager: class DataManager:
def __init__(self, directory): def __init__(self, directory):

View File

@ -8,9 +8,9 @@ from minecraft.networking.types import (
Float, Direction, PositionAndLook Float, Direction, PositionAndLook
) )
from protocol.types import Nbt, Slot, Entry, Trade from .types import Nbt, Slot, Entry, Trade
import blocks from mosfet import blocks
class ChunkDataPacket(Packet): class ChunkDataPacket(Packet):

View File

@ -2,8 +2,8 @@ import importlib
import collections import collections
from math import floor, ceil, sqrt, hypot from math import floor, ceil, sqrt, hypot
import blocks from mosfet import blocks
import mcdata from mosfet import mcdata
TICK = 0.05 TICK = 0.05