diff --git a/minecraft_script/compiler/build_templates/builtins/log.mcfunction b/minecraft_script/compiler/build_templates/builtins/log.mcfunction index 627162d..1dbd9a5 100644 --- a/minecraft_script/compiler/build_templates/builtins/log.mcfunction +++ b/minecraft_script/compiler/build_templates/builtins/log.mcfunction @@ -1 +1 @@ -$tellraw @a ["", {"storage": "$(s0)", "nbt": "$(n0)"}, {"text": " "}, {"storage": "$(s1)", "nbt": "$(n1)"}, {"text": " "}, {"storage": "$(s2)", "nbt": "$(n2)"}, {"text": " "}, {"storage": "$(s3)", "nbt": "$(n3)"}, {"text": " "}, {"storage": "$(s4)", "nbt": "$(n4)"}] \ No newline at end of file +$tellraw @a {text:'',extra:[{storage:'$(s0)',nbt:'$(n0)'},{text:' '},{storage:'$(s1)',nbt:'$(n1)'},{text:' '},{storage:'$(s2)',nbt:'$(n2)'},{text:' '},{storage:'$(s3)',nbt:'$(n3)'},{text:' '},{storage:'$(s4)',nbt:'$(n4)'}]} diff --git a/minecraft_script/compiler/build_templates/tags/blocks/no_collision.json b/minecraft_script/compiler/build_templates/tags/block/no_collision.json similarity index 100% rename from minecraft_script/compiler/build_templates/tags/blocks/no_collision.json rename to minecraft_script/compiler/build_templates/tags/block/no_collision.json diff --git a/minecraft_script/compiler/builtin_functions.py b/minecraft_script/compiler/builtin_functions.py index 650cab7..e8f2d25 100644 --- a/minecraft_script/compiler/builtin_functions.py +++ b/minecraft_script/compiler/builtin_functions.py @@ -41,9 +41,9 @@ def get_block(interpreter, args, context) -> function_output: fnc_commands = ( f"data modify storage {mcs_obj.get_storage()} {mcs_obj.get_nbt()} set value \"\"", "summon armor_stand ~ ~5 ~ {Invisible:1b, NoBasePlate:1b, NoGravity:1b, Tags:[\"mcs_get_block_temp\"]}", - "$loot replace entity @e[type=armor_stand, limit=1, sort=nearest, tag=mcs_get_block_temp] armor.head mine $(x) $(y) $(z) netherite_pickaxe[minecraft:enchantments={levels:{\"minecraft:silk_touch\":1}}]", + "$loot replace entity @e[type=armor_stand, limit=1, sort=nearest, tag=mcs_get_block_temp] armor.head mine $(x) $(y) $(z) netherite_pickaxe[minecraft:enchantments={silk_touch:1}]", # NOQA - f"data modify storage {mcs_obj.get_storage()} {mcs_obj.get_nbt()} set from entity @e[type=minecraft:armor_stand, tag=mcs_get_block_temp, limit=1, sort=nearest] ArmorItems[3].id", + f"data modify storage {mcs_obj.get_storage()} {mcs_obj.get_nbt()} set from entity @e[type=minecraft:armor_stand, tag=mcs_get_block_temp, limit=1, sort=nearest] equipment.head.id", # NOQA "kill @e[type=armor_stand, tag=mcs_get_block_temp]" ) @@ -292,7 +292,7 @@ def give_clickable_item(interpreter, args, context) -> function_output: name: MCSString = args[1] if len(args) > 1 else None custom_model_data: MCSNumber = args[2] if len(args) > 2 else None - "give @s minecraft:carrot_on_a_stick[minecraft:custom_data={mcs_click: VALUE}, minecraft:item_name=NAME, minecraft:custom_model_data=0]" + "give @s minecraft:carrot_on_a_stick[minecraft:custom_data={mcs_click:VALUE},minecraft:custom_name={text:'NAME'},minecraft:custom_model_data=0]" "function interpreter.datapack_id:clickable_items/id" click_function_id = interpreter.click_item_lookup.get(click_function) @@ -328,7 +328,7 @@ def give_clickable_item(interpreter, args, context) -> function_output: local_context.mcfunction_name, "$give @s carrot_on_a_stick[" "minecraft:custom_data={mcs_click:" f"{click_function_id}" "}, " - "minecraft:item_name='{\"text\": \"$(name)\"}'" + # + needed here otherwise ternary applies to whole string + "minecraft:custom_name={text:'$(name)'}" + # + needed here otherwise ternary applies to whole string (", minecraft:custom_model_data=$(model)]" if custom_model_data is not None else "]") ) diff --git a/minecraft_script/compiler/compiler.py b/minecraft_script/compiler/compiler.py index 66cecf3..05b96e0 100644 --- a/minecraft_script/compiler/compiler.py +++ b/minecraft_script/compiler/compiler.py @@ -27,7 +27,7 @@ def make_init_file(self): "\n" f"function {self.datapack_id}:user_functions/init\n" ) - with open(f'{self.root_folder}/data/{self.datapack_id}/functions/init.mcfunction', 'xt') as init_file: + with open(f'{self.root_folder}/data/{self.datapack_id}/function/init.mcfunction', 'xt') as init_file: init_file.write(text) def make_main_file(self): text = ( @@ -41,7 +41,7 @@ def make_main_file(self): "\n" f"function {self.datapack_id}:user_functions/main\n" ) - with open(f'{self.root_folder}/data/{self.datapack_id}/functions/main.mcfunction', 'xt') as main_file: + with open(f'{self.root_folder}/data/{self.datapack_id}/function/main.mcfunction', 'xt') as main_file: main_file.write(text) def make_kill_file(self): text = ( @@ -59,7 +59,7 @@ def make_kill_file(self): "\n" f"datapack disable \"file/{self.datapack_name}\"\n" ) - with open(f'{self.root_folder}/data/{self.datapack_id}/functions/kill.mcfunction', 'xt') as kill_file: + with open(f'{self.root_folder}/data/{self.datapack_id}/function/kill.mcfunction', 'xt') as kill_file: kill_file.write(text) def make_click_item_check_file(self): check_text = ( @@ -68,7 +68,7 @@ def make_click_item_check_file(self): "data modify storage mcs_click id set from entity @s SelectedItem.components.\"minecraft:custom_data\".mcs_click\n" f"function {self.datapack_id}:clickable_items/run with storage mcs_click\n" ) - click_path = f'{self.root_folder}/data/{self.datapack_id}/functions/clickable_items' + click_path = f'{self.root_folder}/data/{self.datapack_id}/function/clickable_items' mkdir(click_path) with open(f'{click_path}/check.mcfunction', 'xt') as check_file: check_file.write(check_text) @@ -77,7 +77,7 @@ def make_click_item_check_file(self): def import_math_files(self, used_math_ops): if not used_math_ops: return - math_folder = f'{self.root_folder}/data/{self.datapack_id}/functions/math' + math_folder = f'{self.root_folder}/data/{self.datapack_id}/function/math' mkdir(math_folder) source_folder = f'{module_folder}/compiler/build_templates/math' for filename in listdir(source_folder): @@ -90,7 +90,7 @@ def import_math_files(self, used_math_ops): def import_builtins_files(self, used_builtins): if not used_builtins: return - builtins_folder = f'{self.root_folder}/data/{self.datapack_id}/functions/builtins' + builtins_folder = f'{self.root_folder}/data/{self.datapack_id}/function/builtins' mkdir(builtins_folder) source_folder = f'{module_folder}/compiler/build_templates/builtins' for filename in listdir(source_folder): @@ -129,18 +129,18 @@ def generate_builtin_functions(self, used_math_ops, used_builtins): if self.verbose: print('\rBuilding built-in functions... 50%', end="") self.import_math_files(used_math_ops) - self.clean_empty_folder(f'{self.root_folder}/data/{self.datapack_id}/functions/math') + self.clean_empty_folder(f'{self.root_folder}/data/{self.datapack_id}/function/math') if self.verbose: print('\rBuilding built-in functions... 67%', end="") self.import_builtins_files(used_builtins) - self.clean_empty_folder(f'{self.root_folder}/data/{self.datapack_id}/functions/builtins') + self.clean_empty_folder(f'{self.root_folder}/data/{self.datapack_id}/function/builtins') if self.verbose: print('\rBuilding built-in functions... 83%', end="") self.make_click_item_check_file() if self.verbose: print('\rBuilding builtin-in functions... Done!') def clean_empty_code_blocks(self): - code_blocks_folder = f'{self.root_folder}/data/{self.datapack_id}/functions/code_blocks' + code_blocks_folder = f'{self.root_folder}/data/{self.datapack_id}/function/code_blocks' if os.path.exists(code_blocks_folder) and not os.listdir(code_blocks_folder): rmdir(code_blocks_folder) def build(self): @@ -157,11 +157,11 @@ def build(self): print('Creating default folders...', end=" ") mkdir(f'{self.root_folder}/data/minecraft') mkdir(f'{self.root_folder}/data/minecraft/tags') - mkdir(f'{self.root_folder}/data/minecraft/tags/functions') + mkdir(f'{self.root_folder}/data/minecraft/tags/function') mkdir(f'{self.root_folder}/data/{self.datapack_id}') - mkdir(f'{self.root_folder}/data/{self.datapack_id}/functions') - mkdir(f'{self.root_folder}/data/{self.datapack_id}/functions/code_blocks') - mkdir(f'{self.root_folder}/data/{self.datapack_id}/functions/user_functions') + mkdir(f'{self.root_folder}/data/{self.datapack_id}/function') + mkdir(f'{self.root_folder}/data/{self.datapack_id}/function/code_blocks') + mkdir(f'{self.root_folder}/data/{self.datapack_id}/function/user_functions') if self.verbose: print('Done!') print('Building Templates...', end=" ") @@ -174,8 +174,8 @@ def build(self): copyfile(f'{module_folder}/compiler/build_templates/pack.png', f'{self.root_folder}/pack.png') with ( open(f'{module_folder}/compiler/build_templates/function_tags.json', 'rt') as template_file, - open(f'{self.root_folder}/data/minecraft/tags/functions/tick.json', 'xt') as tick_file, - open(f'{self.root_folder}/data/minecraft/tags/functions/load.json', 'xt') as load_file + open(f'{self.root_folder}/data/minecraft/tags/function/tick.json', 'xt') as tick_file, + open(f'{self.root_folder}/data/minecraft/tags/function/load.json', 'xt') as load_file ): template_content = template_file.read() tick_file.write(template_content.replace('NAME', self.datapack_id).replace('FILETYPE', 'main')) @@ -184,7 +184,7 @@ def build(self): print("Done!") used_math_ops, used_builtins = mcs_compile( self.ast, - f'{self.root_folder}/data/{self.datapack_id}/functions', + f'{self.root_folder}/data/{self.datapack_id}/function', self.datapack_id ) self.generate_builtin_functions(used_math_ops, used_builtins) diff --git a/minecraft_script/config_utils.py b/minecraft_script/config_utils.py index 286c6ee..8007dcb 100644 --- a/minecraft_script/config_utils.py +++ b/minecraft_script/config_utils.py @@ -5,7 +5,7 @@ def reset_config() -> None: default_config = { - "pack_format": "41", + "pack_format": "71", "debug_comments": True, "verbose": True, "default_output_path": "."