120 lines
3.2 KiB
Python
120 lines
3.2 KiB
Python
"""Minecraft 26.3 item registry data and automation selectors."""
|
|
from mosfet.info import mcdata
|
|
|
|
ITEMS = {
|
|
'minecraft:' + name: dict(item, protocol_id=item['id'])
|
|
for name, item in mcdata.mcd.items.items()
|
|
}
|
|
|
|
BEDS = [
|
|
'white_bed', 'orange_bed', 'magenta_bed', 'light_blue_bed',
|
|
'yellow_bed', 'lime_bed', 'pink_bed', 'gray_bed', 'light_gray_bed',
|
|
'cyan_bed', 'purple_bed', 'blue_bed', 'brown_bed', 'green_bed',
|
|
'red_bed', 'black_bed',
|
|
]
|
|
SHOVELS = [
|
|
'wooden_shovel', 'stone_shovel', 'golden_shovel', 'iron_shovel',
|
|
'diamond_shovel', 'netherite_shovel',
|
|
]
|
|
AXES = [
|
|
'wooden_axe', 'stone_axe', 'golden_axe', 'iron_axe',
|
|
'diamond_axe', 'netherite_axe',
|
|
]
|
|
SAPLINGS = [
|
|
name for name in mcdata.mcd.blocks
|
|
if name.endswith('_sapling') or name.endswith('_propagule')
|
|
]
|
|
FOOD = [
|
|
'cooked_porkchop', 'cooked_beef', 'bread', 'cooked_chicken',
|
|
'cooked_cod', 'cooked_salmon',
|
|
]
|
|
LOGS = [
|
|
name for name in mcdata.mcd.blocks
|
|
if name.endswith(('_log', '_wood', '_stem', '_hyphae'))
|
|
]
|
|
|
|
|
|
def get_set(names):
|
|
return {
|
|
ITEMS['minecraft:' + name]['protocol_id']
|
|
for name in names if 'minecraft:' + name in ITEMS
|
|
}
|
|
|
|
|
|
BED_IDS = get_set(BEDS)
|
|
SHOVEL_IDS = get_set(SHOVELS)
|
|
AXE_IDS = get_set(AXES)
|
|
FOOD_IDS = get_set(FOOD)
|
|
SAPLING_IDS = get_set(SAPLINGS)
|
|
LOG_IDS = get_set(LOGS)
|
|
ITEM_NAMES = {item['protocol_id']: name.removeprefix('minecraft:')
|
|
for name, item in ITEMS.items()}
|
|
|
|
|
|
def get_id(name):
|
|
return ITEMS['minecraft:' + name]['protocol_id']
|
|
|
|
|
|
def get_sapling_id(tree_type):
|
|
"""Return the plantable sapling/propagule item for a tree species."""
|
|
for suffix in ('_sapling', '_propagule'):
|
|
item = ITEMS.get('minecraft:' + tree_type + suffix)
|
|
if item is not None:
|
|
return item['protocol_id']
|
|
return None
|
|
|
|
|
|
def get_name(idx):
|
|
return ITEM_NAMES[idx]
|
|
|
|
|
|
CHEST_ID = get_id('chest')
|
|
GAPPLE_ID = get_id('enchanted_golden_apple')
|
|
SAND_ID = get_id('sand')
|
|
NETHERWART_ID = get_id('nether_wart')
|
|
CARROT_ID = get_id('carrot')
|
|
POTATO_ID = get_id('potato')
|
|
WHEAT_ID = get_id('wheat')
|
|
WHEAT_SEEDS_ID = get_id('wheat_seeds')
|
|
BEETROOT_SEEDS_ID = get_id('beetroot_seeds')
|
|
PUMPKIN_ID = get_id('pumpkin')
|
|
BEETROOT_ID = get_id('beetroot')
|
|
EMERALD_ID = get_id('emerald')
|
|
BERRIES_ID = get_id('sweet_berries')
|
|
IRON_INGOT_ID = get_id('iron_ingot')
|
|
|
|
|
|
_LABEL_ITEM_IDS = {
|
|
'seeds': get_set({
|
|
'beetroot', 'beetroot_seeds', 'carrot', 'melon_seeds',
|
|
'nether_wart', 'pitcher_pod', 'potato', 'pumpkin_seeds',
|
|
'torchflower_seeds', 'wheat_seeds',
|
|
}),
|
|
'wheat': {WHEAT_ID},
|
|
}
|
|
|
|
|
|
def storage_item_ids_for_label(label):
|
|
"""Return protocol item IDs assigned to a sign storage label."""
|
|
normalized = ' '.join(str(label).casefold().split()).strip(' :')
|
|
normalized = (normalized.rstrip('s')
|
|
if normalized not in ('seeds', 'beds') else normalized)
|
|
return set(_LABEL_ITEM_IDS.get(normalized, ()))
|
|
|
|
|
|
INIT_NEEDED_ITEMS = BED_IDS | FOOD_IDS
|
|
INIT_NEEDED_ITEMS.add(CHEST_ID)
|
|
NEEDED_ITEMS = INIT_NEEDED_ITEMS
|
|
INIT_WANTED_ITEMS = set()
|
|
WANTED_ITEMS = INIT_WANTED_ITEMS
|
|
|
|
|
|
def set_needed(items):
|
|
global NEEDED_ITEMS
|
|
NEEDED_ITEMS = INIT_NEEDED_ITEMS | items
|
|
|
|
|
|
def set_wanted(items):
|
|
global WANTED_ITEMS
|
|
WANTED_ITEMS = INIT_WANTED_ITEMS | items
|