minecraft-bot/items.py

123 lines
2.3 KiB
Python
Raw Normal View History

2020-09-17 02:11:42 +00:00
import json
2020-12-14 05:40:17 +00:00
with open('minecraft_data/registries.json') as f:
2020-09-17 02:11:42 +00:00
ITEMS = json.load(f)['minecraft:item']['entries']
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',
]
2020-12-02 11:12:51 +00:00
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 = [
'oak_sapling',
'spruce_sapling',
'birch_sapling',
'jungle_sapling',
'acacia_sapling',
'dark_oak_sapling',
]
2021-01-05 05:57:06 +00:00
FOOD = [
'cooked_porkchop',
'cooked_beef',
'bread',
'cooked_chicken',
'cooked_cod',
'cooked_salmon',
]
2021-02-15 08:27:56 +00:00
LOGS = [
'oak_log',
'spruce_log',
'birch_log',
'jungle_log',
'acacia_log',
'dark_oak_log',
]
2020-09-17 02:11:42 +00:00
2021-04-18 23:02:16 +00:00
def get_set(ids):
result = set()
for item_name in ids:
result.add(ITEMS['minecraft:'+item_name]['protocol_id'])
return result
2020-12-02 11:12:51 +00:00
2021-04-18 23:02:16 +00:00
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)
2021-02-15 08:27:56 +00:00
2020-09-17 02:11:42 +00:00
ITEM_NAMES = {}
for item_name, item in ITEMS.items():
ITEM_NAMES[ITEMS[item_name]['protocol_id']] = item_name.replace('minecraft:', '')
2021-04-18 23:02:16 +00:00
2020-12-15 22:36:03 +00:00
def get_id(name):
return ITEMS['minecraft:' + name]['protocol_id']
2020-12-15 22:36:03 +00:00
CHEST_ID = get_id('chest')
GAPPLE_ID = get_id('enchanted_golden_apple')
SAND_ID = get_id('sand')
NETHERWART_ID = get_id('nether_wart')
2020-12-16 06:14:04 +00:00
CARROT_ID = get_id('carrot')
POTATO_ID = get_id('potato')
WHEAT_ID = get_id('wheat')
2020-12-16 06:14:04 +00:00
WHEAT_SEEDS_ID = get_id('wheat_seeds')
BEETROOT_SEEDS_ID = get_id('beetroot_seeds')
2021-02-24 08:21:25 +00:00
PUMPKIN_ID = get_id('pumpkin')
2020-12-16 06:14:04 +00:00
2021-02-24 01:02:00 +00:00
EMERALD_ID = get_id('emerald')
2021-02-28 23:33:31 +00:00
BERRIES_ID = get_id('sweet_berries')
IRON_INGOT_ID = get_id('iron_ingot')
2021-02-24 01:02:00 +00:00
2021-04-18 23:02:16 +00:00
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):
2021-04-18 22:41:03 +00:00
NEEDED_ITEMS = INIT_NEEDED_ITEMS | items
def set_wanted(items):
WANTED_ITEMS = INIT_WANTED_ITEMS | items