Remove redundant module reloads

This commit is contained in:
Tanner Collin 2021-04-19 07:51:48 +00:00
parent 87bb638270
commit f88809af64
22 changed files with 24 additions and 125 deletions

View File

@ -2,7 +2,6 @@ import json
import importlib
import mcdata
importlib.reload(mcdata)
MCD_BLOCKS = {}
for d in mcdata.mcd.blocks.values():

31
bot.py
View File

@ -15,7 +15,6 @@ PORT = int(os.environ.get('PORT', 25565))
import monkey_patch # must be before any possible pyCraft imports
from minecraft import authentication
from minecraft.exceptions import YggdrasilError
from minecraft.networking.connection import Connection
@ -26,18 +25,30 @@ from protocol.managers import DataManager, ChunksManager, ChatManager, ChunkNotL
from munch import Munch
from vector import Point3D, Vector3D
import game
importlib.reload(game)
import blocks
importlib.reload(blocks)
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import game
import items
import job
importlib.reload(job)
import mcdata
importlib.reload(mcdata)
import mobs
import path
import print_help
import utils
import vector
for module in [
blocks,
game,
items,
job,
mcdata,
mobs,
path,
print_help,
utils,
vector,
]:
importlib.reload(module)
last_tick = time.time()

10
game.py
View File

@ -28,19 +28,12 @@ from protocol.types import Slot
import print_help
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
import bot
importlib.reload(bot)
class MCWorld:
def __init__(self, global_state):
@ -506,11 +499,12 @@ class Game:
else: # for
reply = 'command not found'
else:
print()
print()
for line in print_help.HELP_LINES:
print(line)
reply = 'check console'
## !ping - replies with "pong"
if command == 'ping':
reply = 'pong'

7
job.py
View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
from jobs import (
cache_items,
@ -40,6 +34,7 @@ from jobs import (
sell_to_villager,
sleep_with_bed,
)
for module in [
cache_items,
check_threats,

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class CacheItemsStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class CheckThreatsStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class ClearLeavesStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class EatFoodStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class FillBlocksStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class FindGappleStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GatherCropStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GatherSandStates:
def bair(self, p):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GatherWartStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GatherWoodStates:
def bair(self, p):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GrabSandStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GrabSaplingStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class GrabSuppliesStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class PlantTreeStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class SellToVillagerStates:
def idle(self):

View File

@ -10,17 +10,11 @@ from minecraft.networking.types import BlockFace
from protocol.managers import ChunkNotLoadedException
import utils
importlib.reload(utils)
import path
importlib.reload(path)
import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import mcdata
importlib.reload(mcdata)
import mobs
importlib.reload(mobs)
class SleepWithBedStates:
def idle(self):

View File

@ -6,9 +6,7 @@ from math import hypot, sqrt
from astar import AStar
import blocks
importlib.reload(blocks)
import utils
importlib.reload(utils)
class AStarTimeout(Exception):
pass

View File

@ -3,9 +3,7 @@ import collections
from math import floor, ceil, sqrt, hypot
import blocks
importlib.reload(blocks)
import mcdata
importlib.reload(mcdata)
TICK = 0.05