Compare commits
No commits in common. "6c9f228862e8fcb08a3425d5ed980ccf5209836e" and "b754a4746da8c4aba4a8ccbfa9cb5483cfd28fcb" have entirely different histories.
6c9f228862
...
b754a4746d
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -102,4 +102,4 @@ ENV/
|
|||
*.swp
|
||||
*.swo
|
||||
|
||||
minecraft_data/
|
||||
mcdata/
|
||||
|
|
25
blocks.py
25
blocks.py
|
@ -1,14 +1,14 @@
|
|||
import json
|
||||
import importlib
|
||||
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import data
|
||||
importlib.reload(data)
|
||||
|
||||
MCD_BLOCKS = {}
|
||||
for d in mcdata.mcd.blocks.values():
|
||||
for d in data.mcd.blocks.values():
|
||||
MCD_BLOCKS[d['name']] = d
|
||||
|
||||
with open('minecraft_data/blocks.json') as f:
|
||||
with open('mcdata/blocks.json') as f:
|
||||
JSON_BLOCKS = json.load(f)
|
||||
|
||||
BLOCKS = {}
|
||||
|
@ -237,6 +237,14 @@ SAPLINGS = [
|
|||
'dark_oak_sapling',
|
||||
]
|
||||
|
||||
CHESTS = [
|
||||
'chest',
|
||||
]
|
||||
|
||||
TRAPPED_CHESTS = [
|
||||
'trapped_chest',
|
||||
]
|
||||
|
||||
INDEXED = [
|
||||
'chest',
|
||||
'trapped_chest',
|
||||
|
@ -270,20 +278,15 @@ for block_name in LEAVES:
|
|||
LEAF_IDS.add(state['id'])
|
||||
|
||||
CHEST_IDS = set()
|
||||
for block_name in ['chest']:
|
||||
for block_name in CHESTS:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
CHEST_IDS.add(state['id'])
|
||||
|
||||
TRAPPED_CHEST_IDS = set()
|
||||
for block_name in ['trapped_chest']:
|
||||
for block_name in TRAPPED_CHESTS:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
TRAPPED_CHEST_IDS.add(state['id'])
|
||||
|
||||
NETHERWART_IDS = set()
|
||||
for block_name in ['nether_wart']:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
NETHERWART_IDS.add(state['id'])
|
||||
|
||||
INDEXED_IDS = set()
|
||||
for block_name in INDEXED:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
|
|
11
bot.py
11
bot.py
|
@ -36,8 +36,6 @@ import path
|
|||
importlib.reload(path)
|
||||
import jobs
|
||||
importlib.reload(jobs)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
|
||||
last_tick = time.time()
|
||||
|
||||
|
@ -213,7 +211,7 @@ def bot(global_state):
|
|||
g = global_state
|
||||
|
||||
if not g.mcdata:
|
||||
g.mcdata = DataManager('./minecraft_data')
|
||||
g.mcdata = DataManager('./mcdata')
|
||||
|
||||
if not g.connection:
|
||||
auth_token = authentication.AuthenticationToken()
|
||||
|
@ -264,10 +262,3 @@ def bot(global_state):
|
|||
g.connection.early_outgoing_packet_listeners = []
|
||||
|
||||
print('Bot module loaded.')
|
||||
|
||||
print(mcdata.mcd.blockCollisionShapes['blocks']['brewing_stand'])
|
||||
print(mcdata.mcd.blockCollisionShapes['shapes']['107'])
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import minecraft_data
|
|||
|
||||
mcd = minecraft_data('1.16.4')
|
||||
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
with open('mcdata/registries.json') as f:
|
||||
DATA = json.load(f)
|
||||
|
||||
SINGLE_CHEST = 2
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION="1.16.4"
|
||||
VERSION="1.16.2"
|
||||
|
||||
wget -O/tmp/mcdata.zip https://apimon.de/mcdata/$VERSION/$VERSION.zip
|
||||
rm -rf minecraft_data
|
||||
mkdir minecraft_data
|
||||
unzip /tmp/mcdata.zip -d minecraft_data
|
||||
rm -rf mcdata
|
||||
mkdir mcdata
|
||||
unzip /tmp/mcdata.zip -d mcdata
|
||||
rm /tmp/mcdata.zip
|
||||
|
||||
|
|
30
game.py
30
game.py
|
@ -33,8 +33,8 @@ import blocks
|
|||
importlib.reload(blocks)
|
||||
import items
|
||||
importlib.reload(items)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import data
|
||||
importlib.reload(data)
|
||||
import mobs
|
||||
importlib.reload(mobs)
|
||||
|
||||
|
@ -588,23 +588,6 @@ class Game:
|
|||
tree = next(self.g.world.find_trees(pos, 50))
|
||||
reply = str(tree)[1:-1]
|
||||
|
||||
if command == 'block':
|
||||
try:
|
||||
data = data.replace('(', ' ').replace(')', ' ').replace(',', ' ')
|
||||
x1, y1, z1 = [int(x) for x in data.split()]
|
||||
except (AttributeError, ValueError):
|
||||
reply = 'usage: !block x1 y1 z1'
|
||||
|
||||
if not reply:
|
||||
coord = (x1, y1, z1)
|
||||
block = self.g.world.block_at(*coord)
|
||||
|
||||
if not reply and block is None:
|
||||
reply = 'first coord out of range'
|
||||
|
||||
if not reply:
|
||||
reply = blocks.BLOCKS[block] + ':' + str(block)
|
||||
|
||||
|
||||
################# Specific commands ##########################
|
||||
if for_me:
|
||||
|
@ -639,9 +622,6 @@ class Game:
|
|||
elif data == 'sand':
|
||||
self.g.job.state = self.g.job.farm_sand
|
||||
reply = 'ok'
|
||||
elif data == 'wart':
|
||||
self.g.job.state = self.g.job.farm_wart
|
||||
reply = 'ok'
|
||||
|
||||
if reply:
|
||||
for i in self.g.inv.values():
|
||||
|
@ -1013,7 +993,7 @@ class Game:
|
|||
player.y += packet.delta_y / 4096.0
|
||||
player.z += packet.delta_z / 4096.0
|
||||
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_position_rotation(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
|
@ -1028,7 +1008,7 @@ class Game:
|
|||
player.y += packet.delta_y / 4096.0
|
||||
player.z += packet.delta_z / 4096.0
|
||||
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_teleport(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
|
@ -1043,7 +1023,7 @@ class Game:
|
|||
player.y = packet.y
|
||||
player.z = packet.z
|
||||
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_velocity(self, packet):
|
||||
obj = self.g.objects.get(packet.entity_id, None)
|
||||
|
|
6
items.py
6
items.py
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
with open('mcdata/registries.json') as f:
|
||||
ITEMS = json.load(f)['minecraft:item']['entries']
|
||||
|
||||
BEDS = [
|
||||
|
@ -62,7 +62,5 @@ GAPPLE_ID = set([ITEMS['minecraft:enchanted_golden_apple']['protocol_id']])
|
|||
|
||||
SAND_ID = set([ITEMS['minecraft:sand']['protocol_id']])
|
||||
|
||||
NETHERWART_ID = set([ITEMS['minecraft:nether_wart']['protocol_id']])
|
||||
|
||||
NEEDED_ITEMS = BED_IDS | CHEST_ID
|
||||
WANTED_ITEMS = SAPLING_IDS | NETHERWART_ID
|
||||
WANTED_ITEMS = SAPLING_IDS
|
||||
|
|
124
jobs.py
124
jobs.py
|
@ -19,8 +19,8 @@ import blocks
|
|||
importlib.reload(blocks)
|
||||
import items
|
||||
importlib.reload(items)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import data
|
||||
importlib.reload(data)
|
||||
import mobs
|
||||
importlib.reload(mobs)
|
||||
|
||||
|
@ -124,113 +124,6 @@ class FindGappleStates:
|
|||
self.state()
|
||||
|
||||
|
||||
class GatherWartStates:
|
||||
def idle(self):
|
||||
return None
|
||||
|
||||
def init(self):
|
||||
self.g.chopped_tree = False
|
||||
self.state = self.find_new_wart
|
||||
|
||||
def find_new_wart(self):
|
||||
print('Finding new tree...')
|
||||
w = self.g.world
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
mature_wart = max(blocks.NETHERWART_IDS)
|
||||
for wart in w.find_blocks_3d(p, [mature_wart], 100):
|
||||
print('Found wart:', wart)
|
||||
if wart not in self.bad_warts:
|
||||
break
|
||||
else: # for
|
||||
print('No good warts left, aborting.')
|
||||
self.state = self.cleanup
|
||||
return
|
||||
|
||||
self.wart = wart
|
||||
self.state = self.nav_to_wart
|
||||
|
||||
def nav_to_wart(self):
|
||||
w = self.g.world
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
navpath = w.path_to_place(p, self.wart)
|
||||
|
||||
if navpath:
|
||||
self.g.path = navpath
|
||||
self.g.look_at = utils.padd(self.wart, path.BLOCK_BELOW)
|
||||
self.state = self.going_to_wart
|
||||
else:
|
||||
self.bad_warts.append(wart)
|
||||
self.state = self.find_new_wart
|
||||
|
||||
def going_to_wart(self):
|
||||
if utils.pint(self.g.pos) == self.wart:
|
||||
print('At the wart')
|
||||
self.state = self.break_wart
|
||||
|
||||
def break_wart(self):
|
||||
self.g.game.break_block(self.wart)
|
||||
self.wait_time = 0.5
|
||||
self.state = self.wait
|
||||
|
||||
def wait(self):
|
||||
# wait for the item
|
||||
if self.wait_time > 0:
|
||||
self.wait_time -= utils.TICK
|
||||
else:
|
||||
self.state = self.select_wart
|
||||
|
||||
def select_wart(self):
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
if self.g.game.select_item(items.NETHERWART_ID):
|
||||
self.state = self.wait_select
|
||||
self.wait_time = 0.5
|
||||
else:
|
||||
print('Aborting planting, no wart')
|
||||
self.state = self.cleanup
|
||||
|
||||
def wait_select(self):
|
||||
# wait a bit to select
|
||||
if self.wait_time > 0:
|
||||
self.wait_time -= utils.TICK
|
||||
else:
|
||||
self.state = self.place_wart
|
||||
|
||||
def place_wart(self):
|
||||
p = utils.pint(self.g.pos)
|
||||
self.g.game.place_block(p, BlockFace.TOP)
|
||||
print('Placed wart')
|
||||
self.state = self.wait_place
|
||||
self.wait_time = 0.5
|
||||
|
||||
def wait_place(self):
|
||||
# wait a bit for chunk data to update
|
||||
if self.wait_time > 0:
|
||||
self.wait_time -= utils.TICK
|
||||
else:
|
||||
self.state = self.cleanup
|
||||
|
||||
def cleanup(self):
|
||||
self.g.look_at = None
|
||||
self.state = self.done
|
||||
|
||||
def done(self):
|
||||
# never gets ran, placeholder
|
||||
return None
|
||||
|
||||
def __init__(self, global_state):
|
||||
self.g = global_state
|
||||
self.state = self.idle
|
||||
|
||||
self.wart = None
|
||||
self.bad_warts = []
|
||||
self.wait_time = 0
|
||||
|
||||
def run(self):
|
||||
self.state()
|
||||
|
||||
class GatherWoodStates:
|
||||
def bair(self, p):
|
||||
return self.g.chunks.get_block_at(*p) in blocks.NON_SOLID_IDS
|
||||
|
@ -829,7 +722,7 @@ class CacheItemsStates:
|
|||
if self.g.item_lock: return
|
||||
|
||||
w = self.g.window
|
||||
w_info = mcdata.WINDOWS[w.data.window_type]
|
||||
w_info = data.WINDOWS[w.data.window_type]
|
||||
w_inventory_slots = w_info.inventory
|
||||
|
||||
slot_list = []
|
||||
|
@ -1432,7 +1325,6 @@ class JobStates:
|
|||
self.grab_sand_states = GrabSandStates(self.g)
|
||||
self.fill_blocks_states = FillBlocksStates(self.g)
|
||||
self.check_threats_states = CheckThreatsStates(self.g)
|
||||
self.gather_wart_states = GatherWartStates(self.g)
|
||||
|
||||
def run_machines(self, machines):
|
||||
for m in machines:
|
||||
|
@ -1501,16 +1393,6 @@ class JobStates:
|
|||
self.cache_items_states.silent = True
|
||||
return machines
|
||||
|
||||
def farm_wart(self):
|
||||
machines = [
|
||||
self.gather_wart_states,
|
||||
self.sleep_with_bed_states,
|
||||
self.cache_items_states,
|
||||
]
|
||||
self.sleep_with_bed_states.silent = True
|
||||
self.cache_items_states.silent = True
|
||||
return machines
|
||||
|
||||
def fill_blocks(self):
|
||||
machines = [
|
||||
self.fill_blocks_states,
|
||||
|
|
2
mobs.py
2
mobs.py
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
with open('mcdata/registries.json') as f:
|
||||
MOBS = json.load(f)['minecraft:entity_type']['entries']
|
||||
|
||||
EVIL = [
|
||||
|
|
5
utils.py
5
utils.py
|
@ -4,8 +4,7 @@ from math import floor, ceil, sqrt, hypot
|
|||
|
||||
import blocks
|
||||
importlib.reload(blocks)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import data
|
||||
|
||||
TICK = 0.05
|
||||
|
||||
|
@ -87,7 +86,7 @@ def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantmen
|
|||
|
||||
can_harvest = 'harvestTools' not in block_data or str(held_item) in block_data['harvestTools']
|
||||
material = block_data.get('material', 'n/a')
|
||||
tool_multipliers = mcdata.mcd.materials.get(material, [])
|
||||
tool_multipliers = data.mcd.materials.get(material, [])
|
||||
is_best_tool = held_item in tool_multipliers
|
||||
time = block_data['hardness']
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user