MC烟花生成 适用1.12+

自动生成烟花字符,随机烟花弹幕

实体烟花的属性可以通过命令方块生成,这里提供了一个生成烟花的脚本,可以生成字符烟花和随机烟花弹幕。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
from enum import Enum
import random

import pyperclip


class FireWork:
class Type(Enum):
SMALL = 0
LARGE = 1
STAR = 2
CREEPER = 3
BURST = 4

def __init__(self, x, y, z=-15):
self.x = x
self.y = y
self.z = z - 6
self.flight = 1
self.wait = 20
self.type = self.Type.SMALL
self.color = [11743532, 6719955, 14602026, 14188952]
self.fade_color = [15790320, 11250603]

def __str__(self):
return f"""summon firework_rocket ~{self.x} ~{self.y} ~{self.z} """ + \
f"""{{LifeTime:{self.wait},FireworksItem:{{id:firework_rocket,Count:1,tag:{{Fireworks:""" + \
f"""{{Flight:{self.flight},Explosions:[{{{"Type:" + str(self.type.value) + "," if self.type else ""}""" + \
f"""Flicker:1b,Colors:[I;{','.join([str(i) for i in self.color])}],""" + \
f"""FadeColors:[I;{','.join([str(i) for i in self.fade_color])}]}}]}}}}}}}}"""


def gen_command(blocks_):
res = '''summon falling_block ~ ~1 ~ {BlockState:{Name:redstone_block},Passengers:[
{id:armor_stand,Health:0,Passengers:[
{id:falling_block,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:'gamerule commandBlockOutput false'},'''
for block in blocks_:
res += f'''{{id:command_block_minecart,Command:'{str(block)}'}},'''
res += """{id:command_block_minecart,Command:""" + \
"""'setblock ~ ~1 ~ command_block{auto:1,Command:"fill ~ ~ ~ ~ ~-2 ~ air"}'""" + \
"""},{id:command_block_minecart,Command:'""" + \
"""kill @e[type=command_block_minecart,distance=..1]'}]}]}]}"""

print(res)
pyperclip.copy(res)
exit()


def gen_word(word_):
blocks = []
max_len = max([len(i) for i in word_])
for line_idx, line in enumerate(word_):
for char_idx, char in enumerate(line):
if char == "#":
blocks.append(FireWork(30, (len(word_) // 2 - line_idx) * 3 + 20, (char_idx - max_len // 2) * 3 - 5))
gen_command(blocks)


def gen_roll():
blocks = []
color = [0x19CAAD, 0x8CC7B5, 0xA0EEE1, 0xBEE7E9, 0xBEEDC7, 0xD6D5B7, 0xD1BA74, 0xE6CEAC, 0xECAD9E, 0xF4606C,
0x19CAAD, 0x8CC7B5, 0xA0EEE1, 0xBEE7E9, 0xBEEDC7, 0xD6D5B7, 0xD1BA74, 0xE6CEAC, 0xECAD9E, 0xF4606C]
last = 16
for i in range(last + 1):
if i != last:
firework = FireWork(15, 5, -8 + i)
firework.color = [color[i]]
firework.wait = 10 + i * 2
firework.fade_color = [color[i] // 2]
blocks.append(firework)
firework = FireWork(15, 5, 8 - i)
firework.color = [color[i]]
firework.wait = 10 + i * 2
firework.fade_color = [color[i] // 2]
blocks.append(firework)
else:
for j in range(last):
firework = FireWork(15, 5, -8 + j)
firework.color = [color[j]]
firework.wait = 10 + i * 2
firework.fade_color = [color[j] // 2]
blocks.append(firework)
gen_command(blocks)


def gen_random():
blocks = []
for i in range(random.randint(40, 120)):
firework = FireWork(random.randint(10, 25), 5, random.randint(-30, 20))
firework.color = [random.randint(0, 0xffffff) for _ in range(random.randint(1, 7))]
firework.wait = random.randint(10, 60)
firework.fade_color = [random.randint(0, 0x7f7f7f) for _ in range(random.randint(1, 5))]
if random.randint(0, 10) > 6:
firework.type = FireWork.Type(random.randint(1, 4))
blocks.append(firework)
gen_command(blocks)


if __name__ == "__main__":
gen_roll()
gen_random()
gen_word('''
# # #
# # #
###### #
# # #
# # #
# # #
'''.split("\n"))
gen_word('''
#### ### #### #####
# # # # # # # #
# # # # # #
#### # # # #### #####
# # # # # #
# # # # # #
###### ### ###### #####
'''.split("\n"))
gen_word('''
# #
##############
# #
######
# # #########
# # # # #
# # # # #
###### #########
# # #
# # #
#########
'''.split("\n"))
作者

Frank Wu

发布于

2023-01-22

更新于

2024-05-05

许可协议