Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def run():

time.sleep(1)

run()
run()
2 changes: 1 addition & 1 deletion global_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ def get_num_blocks(self):

def get_num_block_states(self):
blocks = self.get_block_state_list(True)
return len(blocks)
return len(blocks)
22 changes: 11 additions & 11 deletions mcworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_latest_log_file(self):
return logfile

def write_functions(self, functions):
function_dir = f'data/{self.namespace}/functions/'
function_dir = f'data/{self.namespace}/function/'

for name in functions:
filename = os.path.join(function_dir, f"{name}.mcfunction")
Expand All @@ -34,7 +34,7 @@ def write_functions(self, functions):
self.zip.writestr(filename, text)

def write_tags(self, clocks, block_tags, entity_tags, item_tags):
tag_dir = 'data/minecraft/tags/functions/'
tag_dir = 'data/minecraft/tags/function/'

tick_tag_file = os.path.join(tag_dir, 'tick.json')
self.zip.writestr(tick_tag_file, json.dumps({'values':[f'{self.namespace}:{name}'for name in clocks]}, indent=4))
Expand All @@ -43,9 +43,9 @@ def write_tags(self, clocks, block_tags, entity_tags, item_tags):
self.zip.writestr(load_tag_file, json.dumps({'values':[f'{self.namespace}:reset']}, indent=4))

for name, list in [
('blocks', block_tags),
('items', item_tags),
('entity_types', entity_tags)
('block', block_tags),
('item', item_tags),
('entity_type', entity_tags)
]:
if len(list) > 0:
tag_dir = f'data/{self.namespace}/tags/{name}/'
Expand All @@ -58,7 +58,7 @@ def write_tags(self, clocks, block_tags, entity_tags, item_tags):

def write_recipes(self, recipes):
if len(recipes) > 0:
recipe_dir = f'data/{self.namespace}/recipes/'
recipe_dir = f'data/{self.namespace}/recipe/'

id = 0
for recipe in recipes:
Expand All @@ -70,7 +70,7 @@ def write_recipes(self, recipes):

def write_advancements(self, advancements):
if len(advancements) > 0:
advancement_dir = f'data/{self.namespace}/advancements/'
advancement_dir = f'data/{self.namespace}/advancement/'

for name in advancements:
advancement_file = os.path.join(advancement_dir, f'{name}.json')
Expand All @@ -84,25 +84,25 @@ def write_loot_tables(self, loot_tables):
parts = name.split(':')
if len(parts) != 2:
raise CompileError(f'Invalid loot tables name "{name}"')
loot_table_dir = f'data/{parts[0]}/loot_tables/{type}/'
loot_table_dir = f'data/{parts[0]}/loot_table/{type}/'
filename = parts[1]
else:
loot_table_dir = f'data/{self.namespace}/loot_tables/{type}/'
loot_table_dir = f'data/{self.namespace}/loot_table/{type}/'
filename = name
loot_table_file = os.path.join(loot_table_dir, f'{filename}.json')
self.zip.writestr(loot_table_file, contents)

def write_predicates(self, predicates):
if len(predicates) > 0:
predicate_dir = f'data/{self.namespace}/predicates/'
predicate_dir = f'data/{self.namespace}/predicate/'

for name in predicates:
predicate_file = os.path.join(predicate_dir, f'{name}.json')
self.zip.writestr(predicate_file, predicates[name])

def write_item_modifiers(self, item_modifiers):
if len(item_modifiers) > 0:
item_modifier_dir = f'data/{self.namespace}/item_modifiers/'
item_modifier_dir = f'data/{self.namespace}/item_modifier/'

for name in item_modifiers:
item_modifier_file = os.path.join(item_modifier_dir, f'{name}.json')
Expand Down
4 changes: 2 additions & 2 deletions scriptlex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'at', 'as', 'on', 'facing', 'rotated', 'align', 'here', 'the_end', 'the_nether', 'overworld',
'move', 'create', 'tell', 'title', 'subtitle', 'actionbar',
'reset', 'clock', 'function', 'if', 'unless', 'then', 'do', 'else', 'switch', 'case', 'default',
'return', 'while', 'macro', 'block', 'block_data', 'block_tag', 'entity_tag', 'item_tag', 'define', 'array', 'remove', 'success', 'result',
'return', 'while', 'macro', 'entity', 'block', 'block_data', 'block_tag', 'entity_tag', 'item_tag', 'define', 'array', 'remove', 'success', 'result',
'shaped', 'recipe', 'keys', 'eyes', 'feet', 'advancement', 'loot_table', 'predicate', "item_modifier",
'push', 'pop', 'true', 'false',
)
Expand Down Expand Up @@ -159,4 +159,4 @@ def find_column(input, token):
line_start = input.rfind('\n', 0, token.lexpos) + 1
return (token.lexpos - line_start) + 1

lexer = lex.lex(debug=0)
lexer = lex.lex(debug=0)
6 changes: 4 additions & 2 deletions scriptparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,9 +1818,11 @@ def p_advancement_definition(p):

#### Loot Tables
def p_loot_table_type(p):
'''loot_table_type : block'''
'''loot_table_type : block
| entity'''
types = {
'block': 'blocks',
'entity': 'entities',
}
if p[1] not in types:
raise SyntaxError(f'Invalid loot table type "{p[1]}" at line {p.lineno(1)}.')
Expand Down Expand Up @@ -1867,4 +1869,4 @@ def parse(data,debug=0):
except SyntaxError as e:
print(e)
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc())