Compare commits
No commits in common. "25cc638465f5454bd5fa7a18e0cd7621cdd6b8ea" and "81f8a92cab870cfa0908be2829ea0d0ed72f2278" have entirely different histories.
25cc638465
...
81f8a92cab
|
@ -241,7 +241,6 @@ INDEXED = [
|
||||||
'chest',
|
'chest',
|
||||||
'trapped_chest',
|
'trapped_chest',
|
||||||
'emerald_block',
|
'emerald_block',
|
||||||
'barrel',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,11 +274,6 @@ for block_name in ['chest']:
|
||||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||||
CHEST_IDS.add(state['id'])
|
CHEST_IDS.add(state['id'])
|
||||||
|
|
||||||
BARREL_IDS = set()
|
|
||||||
for block_name in ['barrel']:
|
|
||||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
|
||||||
BARREL_IDS.add(state['id'])
|
|
||||||
|
|
||||||
TRAPPED_CHEST_IDS = set()
|
TRAPPED_CHEST_IDS = set()
|
||||||
for block_name in ['trapped_chest']:
|
for block_name in ['trapped_chest']:
|
||||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||||
|
|
6
bot.py
6
bot.py
|
@ -101,10 +101,6 @@ def tick(global_state):
|
||||||
target.x += 0.5
|
target.x += 0.5
|
||||||
target.z += 0.5
|
target.z += 0.5
|
||||||
|
|
||||||
if g.afk_timeout > 0:
|
|
||||||
target = None
|
|
||||||
g.afk_timeout -= utils.TICK
|
|
||||||
|
|
||||||
if target:
|
if target:
|
||||||
d = p - target
|
d = p - target
|
||||||
|
|
||||||
|
@ -209,7 +205,7 @@ def init(global_state):
|
||||||
g.job = jobs.JobStates(g)
|
g.job = jobs.JobStates(g)
|
||||||
g.chopped_tree = False
|
g.chopped_tree = False
|
||||||
|
|
||||||
g.afk_timeout = 0
|
g.queue_afk = False
|
||||||
|
|
||||||
g.filling = False
|
g.filling = False
|
||||||
|
|
||||||
|
|
15
game.py
15
game.py
|
@ -288,7 +288,7 @@ class MCWorld:
|
||||||
def find_monsters(self, center, distance):
|
def find_monsters(self, center, distance):
|
||||||
# finds monsters within distance
|
# finds monsters within distance
|
||||||
result = []
|
result = []
|
||||||
for eid, mob in copy(self.g.mobs).items():
|
for eid, mob in self.g.mobs.items():
|
||||||
if mob.type not in mobs.EVIL_IDS:
|
if mob.type not in mobs.EVIL_IDS:
|
||||||
continue
|
continue
|
||||||
pos = utils.pint((mob.x, mob.y, mob.z))
|
pos = utils.pint((mob.x, mob.y, mob.z))
|
||||||
|
@ -578,8 +578,12 @@ class Game:
|
||||||
|
|
||||||
if command == 'zzz':
|
if command == 'zzz':
|
||||||
if not self.g.afk and self.g.dimension == 'overworld':
|
if not self.g.afk and self.g.dimension == 'overworld':
|
||||||
reply = '/afk'
|
if self.g.path:
|
||||||
self.g.afk_timeout = 5.0
|
travel_time = int(len(self.g.path) * 0.4) + 2
|
||||||
|
reply = 'gimme ' + str(travel_time) + ' secs, moving'
|
||||||
|
self.g.queue_afk = True
|
||||||
|
else:
|
||||||
|
reply = '/afk'
|
||||||
|
|
||||||
if command == 'tree':
|
if command == 'tree':
|
||||||
pos = utils.pint(self.g.pos)
|
pos = utils.pint(self.g.pos)
|
||||||
|
@ -1097,3 +1101,8 @@ class Game:
|
||||||
|
|
||||||
if not self.g.path:
|
if not self.g.path:
|
||||||
self.g.correction_count = 0
|
self.g.correction_count = 0
|
||||||
|
|
||||||
|
if self.g.queue_afk:
|
||||||
|
self.g.chat.send('/afk')
|
||||||
|
self.g.queue_afk = False
|
||||||
|
|
||||||
|
|
15
items.py
15
items.py
|
@ -31,15 +31,6 @@ SHOVELS = [
|
||||||
'netherite_shovel',
|
'netherite_shovel',
|
||||||
]
|
]
|
||||||
|
|
||||||
AXES = [
|
|
||||||
'wooden_axe',
|
|
||||||
'stone_axe',
|
|
||||||
'golden_axe',
|
|
||||||
'iron_axe',
|
|
||||||
'diamond_axe',
|
|
||||||
'netherite_axe',
|
|
||||||
]
|
|
||||||
|
|
||||||
SAPLINGS = [
|
SAPLINGS = [
|
||||||
'oak_sapling',
|
'oak_sapling',
|
||||||
'spruce_sapling',
|
'spruce_sapling',
|
||||||
|
@ -57,10 +48,6 @@ SHOVEL_IDS = set()
|
||||||
for item_name in SHOVELS:
|
for item_name in SHOVELS:
|
||||||
SHOVEL_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
SHOVEL_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
||||||
|
|
||||||
AXE_IDS = set()
|
|
||||||
for item_name in AXES:
|
|
||||||
AXE_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
|
||||||
|
|
||||||
SAPLING_IDS = set()
|
SAPLING_IDS = set()
|
||||||
for item_name in SAPLINGS:
|
for item_name in SAPLINGS:
|
||||||
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
||||||
|
@ -82,5 +69,5 @@ POTATO_ID = get_id('potato')
|
||||||
WHEAT_SEEDS_ID = get_id('wheat_seeds')
|
WHEAT_SEEDS_ID = get_id('wheat_seeds')
|
||||||
BEETROOT_SEEDS_ID = get_id('beetroot_seeds')
|
BEETROOT_SEEDS_ID = get_id('beetroot_seeds')
|
||||||
|
|
||||||
NEEDED_ITEMS = BED_IDS | SHOVEL_IDS | AXE_IDS | set([CHEST_ID])
|
NEEDED_ITEMS = BED_IDS | set([CHEST_ID])
|
||||||
WANTED_ITEMS = SAPLING_IDS | set([NETHERWART_ID, CARROT_ID, POTATO_ID, WHEAT_SEEDS_ID, BEETROOT_SEEDS_ID])
|
WANTED_ITEMS = SAPLING_IDS | set([NETHERWART_ID, CARROT_ID, POTATO_ID, WHEAT_SEEDS_ID, BEETROOT_SEEDS_ID])
|
||||||
|
|
177
jobs.py
177
jobs.py
|
@ -364,10 +364,6 @@ class GatherWoodStates:
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.g.chopped_tree = False
|
self.g.chopped_tree = False
|
||||||
self.state = self.select_axe
|
|
||||||
|
|
||||||
def select_axe(self):
|
|
||||||
self.g.game.select_item(items.AXE_IDS)
|
|
||||||
self.state = self.find_new_tree
|
self.state = self.find_new_tree
|
||||||
|
|
||||||
def find_new_tree(self):
|
def find_new_tree(self):
|
||||||
|
@ -651,7 +647,7 @@ class GrabSandStates:
|
||||||
w = self.g.world
|
w = self.g.world
|
||||||
p = utils.pint(self.g.pos)
|
p = utils.pint(self.g.pos)
|
||||||
|
|
||||||
sand = w.find_objects([items.SAND_ID])
|
sand = w.find_objects(items.SAND_ID)
|
||||||
|
|
||||||
if not sand:
|
if not sand:
|
||||||
print('No sand objects found, aborting')
|
print('No sand objects found, aborting')
|
||||||
|
@ -775,7 +771,7 @@ class SleepWithBedStates:
|
||||||
self.state = self.use_bed
|
self.state = self.use_bed
|
||||||
|
|
||||||
def use_bed(self):
|
def use_bed(self):
|
||||||
if self.g.time > 12550:
|
if self.g.time >= 12542:
|
||||||
print('Sleeping')
|
print('Sleeping')
|
||||||
self.g.game.place_block(self.area, BlockFace.TOP)
|
self.g.game.place_block(self.area, BlockFace.TOP)
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
|
@ -788,8 +784,7 @@ class SleepWithBedStates:
|
||||||
|
|
||||||
threats = w.find_threats(p, 30)
|
threats = w.find_threats(p, 30)
|
||||||
if threats:
|
if threats:
|
||||||
print('Waking up due to threats:')
|
print('Waking up due to threats')
|
||||||
print(threats)
|
|
||||||
self.g.game.leave_bed()
|
self.g.game.leave_bed()
|
||||||
self.state = self.break_bed
|
self.state = self.break_bed
|
||||||
elif self.g.time < 100:
|
elif self.g.time < 100:
|
||||||
|
@ -803,7 +798,7 @@ class SleepWithBedStates:
|
||||||
def collect_bed(self):
|
def collect_bed(self):
|
||||||
if not self.g.breaking:
|
if not self.g.breaking:
|
||||||
self.g.path = [utils.padd(self.area, utils.spiral(n)) for n in range(9)]
|
self.g.path = [utils.padd(self.area, utils.spiral(n)) for n in range(9)]
|
||||||
self.wait_time = 2
|
self.wait_time = 4
|
||||||
self.state = self.wait
|
self.state = self.wait
|
||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
|
@ -1039,158 +1034,6 @@ class CacheItemsStates:
|
||||||
self.state()
|
self.state()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GrabSuppliesStates:
|
|
||||||
def idle(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def init(self):
|
|
||||||
if self.supplies:
|
|
||||||
self.state = self.check_supplies
|
|
||||||
else:
|
|
||||||
print('Aborting getting supplies, none specified')
|
|
||||||
self.state = self.cleanup
|
|
||||||
|
|
||||||
def check_supplies(self):
|
|
||||||
for items, maximum in self.supplies.items():
|
|
||||||
print('Checking items:', items)
|
|
||||||
num_items = self.g.game.count_items(items)
|
|
||||||
print('Have:', num_items)
|
|
||||||
|
|
||||||
if num_items:
|
|
||||||
print('Skipping')
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
self.target_items = items
|
|
||||||
self.maximum_items = maximum
|
|
||||||
self.count = 0
|
|
||||||
self.state = self.find_barrels
|
|
||||||
return
|
|
||||||
|
|
||||||
print('Aborting, don\'t need any more supplies')
|
|
||||||
self.state = self.cleanup
|
|
||||||
|
|
||||||
def find_barrels(self):
|
|
||||||
print('Finding barrels...')
|
|
||||||
w = self.g.world
|
|
||||||
p = utils.pint(self.g.pos)
|
|
||||||
|
|
||||||
self.barrels = w.find_blocks_indexed(p, blocks.BARREL_IDS, 100)
|
|
||||||
print('Found:', self.barrels)
|
|
||||||
self.state = self.choose_barrel
|
|
||||||
|
|
||||||
def choose_barrel(self):
|
|
||||||
print('Choosing a barrel...')
|
|
||||||
w = self.g.world
|
|
||||||
p = utils.pint(self.g.pos)
|
|
||||||
c = self.g.chunks
|
|
||||||
|
|
||||||
if not len(self.barrels):
|
|
||||||
print('No barrels')
|
|
||||||
self.state = self.cleanup
|
|
||||||
return
|
|
||||||
|
|
||||||
barrel = self.barrels[0]
|
|
||||||
|
|
||||||
tmp = c.get_block_at(*barrel)
|
|
||||||
c.set_block_at(*barrel, blocks.AIR)
|
|
||||||
navpath = w.path_to_place(p, barrel)
|
|
||||||
c.set_block_at(*barrel, tmp)
|
|
||||||
|
|
||||||
print('navpath:', navpath)
|
|
||||||
|
|
||||||
if navpath:
|
|
||||||
self.g.path = navpath[:-1]
|
|
||||||
self.opening = self.g.path[-1]
|
|
||||||
self.area = barrel
|
|
||||||
self.state = self.going_to_barrel
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.barrels.pop(0)
|
|
||||||
|
|
||||||
def going_to_barrel(self):
|
|
||||||
if utils.pint(self.g.pos) == self.opening:
|
|
||||||
self.g.look_at = self.area
|
|
||||||
self.state = self.open_barrel
|
|
||||||
|
|
||||||
def open_barrel(self):
|
|
||||||
print('Opening barrel')
|
|
||||||
self.g.game.open_container(self.area)
|
|
||||||
self.wait_time = 1
|
|
||||||
self.state = self.wait
|
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
# wait for server to send us barrel contents
|
|
||||||
if self.wait_time > 0:
|
|
||||||
self.wait_time -= utils.TICK
|
|
||||||
else:
|
|
||||||
self.state = self.grab_items
|
|
||||||
|
|
||||||
def grab_items(self):
|
|
||||||
if self.g.item_lock: return
|
|
||||||
|
|
||||||
w = self.g.window
|
|
||||||
w_info = mcdata.WINDOWS[w.data.window_type]
|
|
||||||
w_container_slots = w_info.container
|
|
||||||
|
|
||||||
for slot_num in w_container_slots:
|
|
||||||
if slot_num not in w.contents:
|
|
||||||
continue
|
|
||||||
|
|
||||||
slot = w.contents[slot_num]
|
|
||||||
|
|
||||||
if not slot.present:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if slot.item_id not in self.target_items:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if self.maximum_items and self.count >= self.maximum_items:
|
|
||||||
break
|
|
||||||
self.count += 1
|
|
||||||
|
|
||||||
print('Moving', slot)
|
|
||||||
|
|
||||||
self.g.item_lock = True
|
|
||||||
self.g.game.click_window(slot_num, 0, 1, slot)
|
|
||||||
return
|
|
||||||
|
|
||||||
print('Nothing left to move')
|
|
||||||
self.state = self.close_barrel
|
|
||||||
|
|
||||||
def close_barrel(self):
|
|
||||||
print('Closing barrel')
|
|
||||||
self.g.game.close_window()
|
|
||||||
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.supplies = {}
|
|
||||||
self.target_supplies = []
|
|
||||||
self.barrels = []
|
|
||||||
|
|
||||||
self.target_items = None
|
|
||||||
self.maximum_items = 0
|
|
||||||
self.count = 0
|
|
||||||
|
|
||||||
self.area = None
|
|
||||||
self.opening = None
|
|
||||||
self.wait_time = 0
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
self.state()
|
|
||||||
|
|
||||||
|
|
||||||
class PlantTreeStates:
|
class PlantTreeStates:
|
||||||
def idle(self):
|
def idle(self):
|
||||||
return None
|
return None
|
||||||
|
@ -1435,8 +1278,7 @@ class CheckThreatsStates:
|
||||||
threats = w.find_threats(p, 40)
|
threats = w.find_threats(p, 40)
|
||||||
|
|
||||||
if threats:
|
if threats:
|
||||||
print('Found', len(threats), 'threats, fleeing:')
|
print('Found', len(threats), 'threats, fleeing')
|
||||||
print(threats)
|
|
||||||
self.state = self.find_safety
|
self.state = self.find_safety
|
||||||
else:
|
else:
|
||||||
print('Aborting, no threats')
|
print('Aborting, no threats')
|
||||||
|
@ -1716,7 +1558,6 @@ class JobStates:
|
||||||
self.gather_sand_states = GatherSandStates(self.g)
|
self.gather_sand_states = GatherSandStates(self.g)
|
||||||
self.sleep_with_bed_states = SleepWithBedStates(self.g)
|
self.sleep_with_bed_states = SleepWithBedStates(self.g)
|
||||||
self.cache_items_states = CacheItemsStates(self.g)
|
self.cache_items_states = CacheItemsStates(self.g)
|
||||||
self.grab_supplies_states = GrabSuppliesStates(self.g)
|
|
||||||
self.find_gapple_states = FindGappleStates(self.g)
|
self.find_gapple_states = FindGappleStates(self.g)
|
||||||
self.plant_tree_states = PlantTreeStates(self.g)
|
self.plant_tree_states = PlantTreeStates(self.g)
|
||||||
self.clear_leaves_states = ClearLeavesStates(self.g)
|
self.clear_leaves_states = ClearLeavesStates(self.g)
|
||||||
|
@ -1749,7 +1590,6 @@ class JobStates:
|
||||||
|
|
||||||
def farm_sand(self):
|
def farm_sand(self):
|
||||||
machines = [
|
machines = [
|
||||||
self.grab_supplies_states,
|
|
||||||
self.check_threats_states,
|
self.check_threats_states,
|
||||||
self.gather_sand_states,
|
self.gather_sand_states,
|
||||||
self.grab_sand_states,
|
self.grab_sand_states,
|
||||||
|
@ -1758,9 +1598,6 @@ class JobStates:
|
||||||
]
|
]
|
||||||
self.sleep_with_bed_states.silent = True
|
self.sleep_with_bed_states.silent = True
|
||||||
self.cache_items_states.silent = True
|
self.cache_items_states.silent = True
|
||||||
self.grab_supplies_states.supplies = {
|
|
||||||
tuple(items.SHOVEL_IDS): 9
|
|
||||||
}
|
|
||||||
return machines
|
return machines
|
||||||
|
|
||||||
def cache_items(self):
|
def cache_items(self):
|
||||||
|
@ -1786,7 +1623,6 @@ class JobStates:
|
||||||
|
|
||||||
def farm_wood(self):
|
def farm_wood(self):
|
||||||
machines = [
|
machines = [
|
||||||
self.grab_supplies_states,
|
|
||||||
self.gather_wood_states,
|
self.gather_wood_states,
|
||||||
self.clear_leaves_states,
|
self.clear_leaves_states,
|
||||||
self.plant_tree_states,
|
self.plant_tree_states,
|
||||||
|
@ -1796,9 +1632,6 @@ class JobStates:
|
||||||
]
|
]
|
||||||
self.sleep_with_bed_states.silent = True
|
self.sleep_with_bed_states.silent = True
|
||||||
self.cache_items_states.silent = True
|
self.cache_items_states.silent = True
|
||||||
self.grab_supplies_states.supplies = {
|
|
||||||
tuple(items.AXE_IDS): 9,
|
|
||||||
}
|
|
||||||
return machines
|
return machines
|
||||||
|
|
||||||
def farm_wart(self):
|
def farm_wart(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user