Compare commits

...

2 Commits

Author SHA1 Message Date
5ff0394dc3 Simplify handling block and item ids 2021-04-18 23:02:16 +00:00
fac4309e43 Adjust item counts 2021-04-18 22:41:03 +00:00
4 changed files with 46 additions and 109 deletions

100
blocks.py
View File

@ -28,10 +28,6 @@ EMERALD_BLOCK = 5407
TEST_BLOCK = (616, 78, 496) TEST_BLOCK = (616, 78, 496)
WATER = [
'water',
]
AVOID = [ AVOID = [
'lava', 'lava',
'water', 'water',
@ -263,89 +259,37 @@ INDEXED = [
'barrel', 'barrel',
] + BEDS ] + BEDS
def get_set(ids):
NON_SOLID_IDS = set([SINGLE_SNOW]) result = set()
for block_name in NON_SOLID: for block_name in ids:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']: for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
NON_SOLID_IDS.add(state['id']) result.add(state['id'])
return result
AVOID_IDS = set()
for block_name in AVOID:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
AVOID_IDS.add(state['id'])
WATER_IDS = set()
for block_name in WATER:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
WATER_IDS.add(state['id'])
LOG_IDS = set()
for block_name in LOGS:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
LOG_IDS.add(state['id'])
LEAF_IDS = set()
for block_name in LEAVES:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
LEAF_IDS.add(state['id'])
CHEST_IDS = set()
for block_name in ['chest']:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
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()
for block_name in ['trapped_chest']:
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'])
WHEAT_IDS = set()
for block_name in ['wheat']:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
WHEAT_IDS.add(state['id'])
POTATO_IDS = set()
for block_name in ['potatoes']:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
POTATO_IDS.add(state['id'])
CARROT_IDS = set()
for block_name in ['carrots']:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
CARROT_IDS.add(state['id'])
BEETROOT_IDS = set()
for block_name in ['beetroots']:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
BEETROOT_IDS.add(state['id'])
SAPLING_IDS = set()
for block_name in SAPLINGS:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
SAPLING_IDS.add(state['id'])
BED_IDS = set()
for block_name in BEDS:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
BED_IDS.add(state['id'])
NON_SOLID_IDS = get_set(NON_SOLID)
NON_SOLID_IDS.add(SINGLE_SNOW)
AVOID_IDS = get_set(AVOID)
WATER_IDS = get_set(['water'])
LOG_IDS = get_set(LOGS)
LEAF_IDS = get_set(LEAVES)
CHEST_IDS = get_set(['chest'])
BARREL_IDS = get_set(['barrel'])
TRAPPED_CHEST_IDS = get_set(['trapped_chest'])
NETHERWART_IDS = get_set(['nether_wart'])
WHEAT_IDS = get_set(['wheat'])
POTATO_IDS = get_set(['potatoes'])
CARROT_IDS = get_set(['carrots'])
BEETROOT_IDS = get_set(['beetroots'])
SAPLING_IDS = get_set(SAPLINGS)
BED_IDS = get_set(BEDS)
INDEXED_IDS = set() INDEXED_IDS = set()
for block_name in INDEXED: for block_name in INDEXED:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']: for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
INDEXED_IDS.add(state['id']) INDEXED_IDS.add(state['id'])
MATURE_WHEAT_ID = max(WHEAT_IDS) MATURE_WHEAT_ID = max(WHEAT_IDS)
MATURE_POTATO_ID = max(POTATO_IDS) MATURE_POTATO_ID = max(POTATO_IDS)
MATURE_CARROT_ID = max(CARROT_IDS) MATURE_CARROT_ID = max(CARROT_IDS)

4
bot.py
View File

@ -226,8 +226,8 @@ def init(global_state):
g.filling = False g.filling = False
g.minimum_cache_slots = 33 g.minimum_cache_slots = 27
g.maximum_supply_slots = 27 g.maximum_supply_slots = 33
def bot(global_state): def bot(global_state):
g = global_state g = global_state

View File

@ -67,34 +67,25 @@ LOGS = [
'dark_oak_log', 'dark_oak_log',
] ]
BED_IDS = set()
for item_name in BEDS:
BED_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
SHOVEL_IDS = set() def get_set(ids):
for item_name in SHOVELS: result = set()
SHOVEL_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id']) for item_name in ids:
result.add(ITEMS['minecraft:'+item_name]['protocol_id'])
return result
AXE_IDS = set() BED_IDS = get_set(BEDS)
for item_name in AXES: SHOVEL_IDS = get_set(SHOVELS)
AXE_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id']) AXE_IDS = get_set(AXES)
FOOD_IDS = get_set(FOOD)
FOOD_IDS = set() SAPLING_IDS = get_set(SAPLINGS)
for item_name in FOOD: LOG_IDS = get_set(LOGS)
FOOD_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
SAPLING_IDS = set()
for item_name in SAPLINGS:
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
LOG_IDS = set()
for item_name in LOGS:
LOG_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
ITEM_NAMES = {} ITEM_NAMES = {}
for item_name, item in ITEMS.items(): for item_name, item in ITEMS.items():
ITEM_NAMES[ITEMS[item_name]['protocol_id']] = item_name.replace('minecraft:', '') ITEM_NAMES[ITEMS[item_name]['protocol_id']] = item_name.replace('minecraft:', '')
def get_id(name): def get_id(name):
return ITEMS['minecraft:' + name]['protocol_id'] return ITEMS['minecraft:' + name]['protocol_id']
@ -115,14 +106,16 @@ BERRIES_ID = get_id('sweet_berries')
IRON_INGOT_ID = get_id('iron_ingot') IRON_INGOT_ID = get_id('iron_ingot')
INIT_NEEDED_ITEMS = BED_IDS | FOOD_IDS | set([CHEST_ID]) INIT_NEEDED_ITEMS = BED_IDS | FOOD_IDS
INIT_NEEDED_ITEMS.add(CHEST_ID)
NEEDED_ITEMS = INIT_NEEDED_ITEMS NEEDED_ITEMS = INIT_NEEDED_ITEMS
INIT_WANTED_ITEMS = set() INIT_WANTED_ITEMS = set()
WANTED_ITEMS = INIT_WANTED_ITEMS WANTED_ITEMS = INIT_WANTED_ITEMS
def set_needed(items): def set_needed(items):
NEEDED_ITEMS = INIT_WANTED_ITEMS | items NEEDED_ITEMS = INIT_NEEDED_ITEMS | items
def set_wanted(items): def set_wanted(items):
WANTED_ITEMS = INIT_WANTED_ITEMS | items WANTED_ITEMS = INIT_WANTED_ITEMS | items

10
jobs.py
View File

@ -2298,11 +2298,11 @@ 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 = { self.grab_supplies_states.supplies = {
tuple([items.PUMPKIN_ID]): (64, 9), tuple([items.PUMPKIN_ID]): (64, 3),
tuple([items.BERRIES_ID]): (64, 9), tuple([items.BERRIES_ID]): (64, 3),
tuple([items.IRON_INGOT_ID]): (64, 9), tuple([items.IRON_INGOT_ID]): (64, 3),
tuple([items.WHEAT_ID]): (64, 9), tuple([items.WHEAT_ID]): (64, 3),
tuple([items.POTATO_ID]): (64, 9), tuple([items.POTATO_ID]): (64, 3),
} }
items.set_needed(set([ items.set_needed(set([