diff --git a/config.yaml b/config.yaml index 9f2e17d..41b8a19 100644 --- a/config.yaml +++ b/config.yaml @@ -44,32 +44,243 @@ VERSION_NUMBER: "1.1.0" #NEVER EDIT THIS IF YOU DON'T KNOW WHAT ARE YOU DOING ## Structure Generation ## SYS_GEN: | You are a minecraft structure builder bot. You should design a building or a structure based on user's instructions. + You operate in a 3D Space. You work in a X,Y,Z coordinate system. X denotes width, Y denotes depth, Z denotes height. Response in json like this: { - "materials": [ - "A: \"minecraft:air\"", - "S: \"minecraft:stone\"" - ], "structures": [ { - "floor": 0, - "structure": "SSSSSSSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 0 }, { - "floor": 1, - "structure": "SSGGGGSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 0 }, { - "floor": 2, - "structure": "SSGGGGSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 0 }, { - "floor": 3, - "structure": "SSSSSSSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 0 }, { - "floor": 4, - "structure": "SSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\n" + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_logs", + "x": 1, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_logs", + "x": 2, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_logs", + "x": 3, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 2 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 3 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 1, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 2, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 3, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 4, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 3 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 2 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 1 } ] } @@ -114,34 +325,245 @@ IMG_TAG_USR_GEN: | ### Stucture Generation (Advanced with gpt-4-vision) ### SYS_GEN_ADV: | You are a minecraft structure builder bot. You should design a building or a structure based on designer's architectural programme AND the design image. + You operate in a 3D Space. You work in a X,Y,Z coordinate system. X denotes width, Y denotes depth, Z denotes height. Response in json like this: { - "materials": [ - "A: \"minecraft:air\"", - "S: \"minecraft:stone\"" - ], - "structures": [ - { - "floor": 0, - "structure": "SSSSSSSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" - }, - { - "floor": 1, - "structure": "SSGGGGSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" - }, - { - "floor": 2, - "structure": "SSGGGGSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" - }, - { - "floor": 3, - "structure": "SSSSSSSS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSAAAAAAS\nSSSSSSSS" - }, - { - "floor": 4, - "structure": "SSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\nSSSSSSSS\n" - } - ] + "structures": [ + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 0 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 1 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 2 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 3 + }, + { + "block": "minecraft:oak_planks", + "x": 0, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 1, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 2, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 3, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_planks", + "x": 4, + "y": 0, + "z": 4 + }, + { + "block": "minecraft:oak_logs", + "x": 1, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_logs", + "x": 2, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_logs", + "x": 3, + "y": 1, + "z": 1 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 2 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 3 + }, + { + "block": "minecraft:oak_fence", + "x": 0, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 1, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 2, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 3, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 4, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 4 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 3 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 2 + }, + { + "block": "minecraft:oak_fence", + "x": 5, + "y": 1, + "z": 1 + } + ] } Never response anything else. Do not design a building which is too large (more than 10 floors). Never use markdown format. Use \n for line feed. diff --git a/core.py b/core.py index 84f2bb9..4b15b63 100644 --- a/core.py +++ b/core.py @@ -128,30 +128,17 @@ def text_to_schem(text: str): """ try: data = json.loads(text) - block_id_dict = {} logger(f"text_to_command: loaded JSON data {data}") schematic = mcschematic.MCSchematic() - # Iterate over the materials - for material in data["materials"]: - key, value = material.split(": ") - block_id_dict[key.strip()] = value.strip('"') - - # Iterate over the structures for structure in data["structures"]: - floor = structure["floor"] - structure_data = structure["structure"] - - # Iterate over the rows of the structure - rows = structure_data.split("\n") - - for y, row in enumerate(rows): - # Iterate over the blocks in each row - for x, block_id in enumerate(row): - # Get the corresponding block from the materials dictionary - block = block_id_dict.get(block_id) - if block: - schematic.setBlock((x, floor, y), block) + block_id = structure["block"] + x = structure["x"] + y = structure["y"] + z = structure["z"] + + schematic.setBlock((x, y, z), block_id) + return schematic except (json.decoder.JSONDecodeError, KeyError, TypeError, ValueError, AttributeError, IndexError) as e: