Exemple #1
0
from pathlib import Path
import common
import collections

data = common.load_feather_json("inventory.json")

# Areas
areas = []
for area in data['areas']:
    areas.append(common.camel_case(area))

# Windows
windows = []
names = {}
inventories = {}
area_offsets = collections.OrderedDict()

for name, window in data['windows'].items():
    variant = common.camel_case(name)
    windows.append(variant)

    names[variant] = name
    inventories[variant] = window['inventories']

    ao = collections.OrderedDict()
    slot_counter = 0
    for inventory_and_area, number_of_slots in window['slots'].items():
        parts = inventory_and_area.split(":")
        inventory = parts[0]
        area_in_inventory = parts[1]
        ao[(inventory, area_in_inventory)] = (slot_counter, number_of_slots)
from common import load_minecraft_json, load_feather_json, camel_case, generate_enum, generate_enum_property, output
from re import compile

blocks = load_minecraft_json("blocks.json")
simplified_block = load_feather_json("simplified_block.json")

regexes = {}
for name, regex in simplified_block['regexes'].items():
    regexes[name] = compile(regex)

variants = []
mapping = {}
for name in regexes:
    variants.append(camel_case(name))

for block in blocks:
    name = block['name']
    block_variant = camel_case(name)

    # Detect which SimplifiedBlockKind matches this block.
    found = False
    for simplified, regex in regexes.items():
        if regex.match(name) is not None:
            mapping[block_variant] = "SimplifiedBlockKind::" + camel_case(simplified)
            found = True
            break

    if not found:
        # Default to block variant
        variants.append(block_variant)
        mapping[block_variant] = "SimplifiedBlockKind::" + block_variant
Exemple #3
0
import common
import re

blocks = common.load_minecraft_json("blocks.json")
simplified_block = common.load_feather_json("simplified_block.json")

regexes = {}
for name, regex in simplified_block['regexes'].items():
    regexes[name] = re.compile(regex)

variants = []
mapping = {}
for name in regexes:
    variants.append(common.camel_case(name))

for block in blocks:
    name = block['name']
    block_variant = common.camel_case(name)

    # Detect which SimplifiedBlockKind matches this block.
    found = False
    for simplified, regex in regexes.items():
        if regex.match(name) is not None:
            mapping[
                block_variant] = "SimplifiedBlockKind::" + common.camel_case(
                    simplified)
            found = True
            break

    if not found:
        # Default to block variant