import json position = [74, 96, 12] text = r"""[{"text":"W","color":"light_purple"},{"text":"e","color":"#f83ffe"},{"text":"l","color":"#f33ffe"},{"text":"c","color":"#ed3ffe"},{"text":"o","color":"#e83ffe"},{"text":"m","color":"#e23ffe"},{"text":"e ","color":"#dd3ffe"},{"text":"t","color":"#d73ffe"},{"text":"o ","color":"#d23ffe"},{"text":"M","color":"#cc3ffe"},{"text":"e","color":"#c73ffe"},{"text":"t","color":"#c13ffe"},{"text":"a","color":"#bc3ffe"},{"text":"c","color":"#b73ffe"},{"text":"r","color":"#b13ffe"},{"text":"a","color":"#ac3ffe"},{"text":"f","color":"#a63ffe"},{"text":"t\n","color":"#a13ffd"},{"text":"S","color":"#9b3ffe"},{"text":"h","color":"#963ffe"},{"text":"o","color":"#903ffe"},{"text":"w ","color":"#8b3ffe"},{"text":"y","color":"#853ffe"},{"text":"o","color":"#803ffe"},{"text":"u","color":"#7b3ffe"},{"text":"r ","color":"#753ffe"},{"text":"T","color":"#703ffe"},{"text":"i","color":"#6a3ffe"},{"text":"c","color":"#653ffe"},{"text":"k","color":"#5f3ffe"},{"text":"e","color":"#5a3ffe"},{"text":"t\n","color":"#543ffe"},{"text":"H","color":"#4f3ffe"},{"text":"a","color":"#493ffe"},{"text":"h","color":"#443ffe"},{"text":"a\n","color":"blue"}]""" # 清除附近盔甲架 # /kill @e[type=minecraft:armor_stand,distance=..10] position[1] += 1.5 line_height = 0.25 text_obj = json.loads(text) commands = [] def build_command(text): text = json.dumps(text) base_command = """/summon minecraft:armor_stand {x} %s {z} """.format( x=position[0], z=position[2] ) nbt = """{Invisible:1,Marker:1,CustomNameVisible:1,CustomName:'%s'}""" cmd = base_command cmd += " " + (nbt % text) return cmd line_num = 0 new_text = [] for part in text_obj: if part["text"] and "\n" in part["text"]: lines = part["text"].split("\n") for line in lines: if line: new_part = {} new_part.update(part) new_part["text"] = line new_text.append(new_part) if new_text: commands.append(build_command(new_text)) line_num += 1 new_text = [] else: new_text.append(part) position[1] += line_num * line_height for i, cmd in enumerate(commands): cmd = cmd % (position[1] - i * line_height) print(cmd) print()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question