Compare commits

..

2 Commits

Author SHA1 Message Date
2e635ecd2c Add setup.py 2021-04-22 00:47:16 +00:00
38f3b0ed67 Fix imports 2021-04-22 00:46:54 +00:00
29 changed files with 191 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

24
setup.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# DO NOT EDIT THIS FILE!
# This file has been autogenerated by dephell <3
# https://github.com/dephell/dephell
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
readme = ''
setup(
long_description=readme,
name='mosfet',
version='0.0.0',
packages=['mosfet', 'mosfet.jobs', 'mosfet.protocol'],
package_dir={"": "."},
package_data={"mosfet": ["minecraft_data/*.json", "minecraft_data/*.txt", "minecraft_data/advancements/adventure/*.json", "minecraft_data/advancements/end/*.json", "minecraft_data/advancements/husbandry/*.json", "minecraft_data/advancements/nether/*.json", "minecraft_data/advancements/recipes/*.json", "minecraft_data/advancements/recipes/brewing/*.json", "minecraft_data/advancements/recipes/building_blocks/*.json", "minecraft_data/advancements/recipes/combat/*.json", "minecraft_data/advancements/recipes/decorations/*.json", "minecraft_data/advancements/recipes/food/*.json", "minecraft_data/advancements/recipes/misc/*.json", "minecraft_data/advancements/recipes/redstone/*.json", "minecraft_data/advancements/recipes/tools/*.json", "minecraft_data/advancements/recipes/transportation/*.json", "minecraft_data/advancements/story/*.json", "minecraft_data/biomes/*.json", "minecraft_data/loot_tables/blocks/*.json", "minecraft_data/loot_tables/chests/*.json", "minecraft_data/loot_tables/chests/village/*.json", "minecraft_data/loot_tables/entities/*.json", "minecraft_data/loot_tables/entities/sheep/*.json", "minecraft_data/loot_tables/gameplay/*.json", "minecraft_data/loot_tables/gameplay/fishing/*.json", "minecraft_data/loot_tables/gameplay/hero_of_the_village/*.json", "minecraft_data/recipes/*.json", "minecraft_data/tags/blocks/*.json", "minecraft_data/tags/entity_types/*.json", "minecraft_data/tags/fluids/*.json", "minecraft_data/tags/items/*.json"]},
install_requires=['appdirs==1.4.3', 'astar==0.93', 'cachecontrol==0.12.6', 'certifi==2019.11.28', 'cffi==1.14.5', 'chardet==3.0.4', 'click==7.1.2', 'colorama==0.4.3', 'contextlib2==0.6.0', 'cryptography==3.4.7', 'distlib==0.3.0', 'distro==1.4.0', 'flask==1.1.2', 'html5lib==1.0.1', 'idna==2.8', 'ipaddr==2.2.0', 'itsdangerous==1.1.0', 'jinja2==2.11.3', 'lockfile==0.12.2', 'markupsafe==1.1.1', 'minecraft-data==2.82.2', 'msgpack==0.6.2', 'munch==2.5.0', 'mutf8==1.0.3', 'packaging==20.3', 'pep517==0.8.2', 'progress==1.5', 'pycparser==2.20', 'pycraft.git@2813d02ae7fb8182c3e5227a73de2240b09878d9', 'pynbt==3.1.0', 'pyparsing==2.4.6', 'pytoml==0.1.21', 'requests==2.22.0', 'retrying==1.3.3', 'six==1.14.0', 'urllib3==1.25.8', 'watchdog==2.0.2', 'webencodings==0.5.1', 'werkzeug==1.0.1'],
dependency_links=['git+https://github.com/ammaraskar/pyCraft.git@2813d02ae7fb8182c3e5227a73de2240b09878d9#egg=pycraft-git@2813d02ae7fb8182c3e5227a73de2240b09878d9'],
)