Skip to content

Commit e7a663f

Browse files
committed
Add option to include empty block data
1 parent 46d93b9 commit e7a663f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Structure-spawner-generator.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
("Up offset", 0),
3232
("Include air", False),
3333
("Include blocks", True),
34+
("Include null block data", False),
3435
("Include entities", False),
3536
("Include \"gamerule commandBlockOutput false\" command", True),
3637
("Include \"gamerule logAdminCommands false\" command", True),
@@ -56,6 +57,7 @@ def perform(level, box, options):
5657
execution_center = (box.maxx + options["Forward offset"] - 1, box.miny - options["Up offset"] + 2, (box.minz + box.maxz) // 2 - options["Left offset"])
5758
include_air = options["Include air"]
5859
include_blocks = options["Include blocks"]
60+
include_null_block_data = options["Include null block data"]
5961
include_entities = options["Include entities"]
6062
include_commandblockoutput_command = options["Include \"gamerule commandBlockOutput false\" command"]
6163
include_logadmincommands_command = options["Include \"gamerule logAdminCommands false\" command"]
@@ -120,9 +122,12 @@ def perform(level, box, options):
120122
unformatted_command += ","
121123
first_element = False
122124
if volume(cuboid[0][0], cuboid[0][1], cuboid[0][2], cuboid[1][0], cuboid[1][1], cuboid[1][2]) == 1:
123-
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"setblock ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " minecraft:air\"}"
125+
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"setblock ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " minecraft:air"
124126
else:
125-
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"fill ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " ~" + str(cuboid[1][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[1][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[1][2] + box.minz - execution_center[2]) + " minecraft:air\"}"
127+
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"fill ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " ~" + str(cuboid[1][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[1][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[1][2] + box.minz - execution_center[2]) + " minecraft:air"
128+
if include_null_block_data:
129+
command_part += " 0"
130+
command_part += "\"}"
126131
command += "\n\t" + command_part
127132
unformatted_command += command_part
128133

@@ -145,10 +150,10 @@ def perform(level, box, options):
145150
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"setblock ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " " + materials.block_map[block[0]]
146151
else:
147152
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"fill ~" + str(cuboid[0][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[0][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[0][2] + box.minz - execution_center[2]) + " ~" + str(cuboid[1][0] + box.minx - execution_center[0]) + " ~" + str(cuboid[1][1] + box.miny - execution_center[1]) + " ~" + str(cuboid[1][2] + box.minz - execution_center[2]) + " " + materials.block_map[block[0]]
148-
if block[1] != 0 and block[2] is None:
153+
if include_null_block_data or (block[1] != 0 and block[2] is not None):
149154
command_part += " " + str(block[1])
150155
if block[2] is not None:
151-
command_part += " " + str(block[1]) + " replace " + escape_string(nbt_to_string(block[2], nbt_tags_to_ignore))
156+
command_part += " replace " + escape_string(nbt_to_string(block[2], nbt_tags_to_ignore))
152157
command_part += "\"}"
153158
if block[0] not in blocks_to_enqueue:
154159
if not first_element:
@@ -209,7 +214,10 @@ def perform(level, box, options):
209214
if not first_element:
210215
command += ","
211216
unformatted_command += ","
212-
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"setblock ~ ~1 ~ minecraft:command_block 0 replace {auto:1b,Command:\\\"fill ~ ~-3 ~ ~ ~ ~ minecraft:air\\\"}\"}"
217+
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"setblock ~ ~1 ~ minecraft:command_block 0 replace {auto:1b,Command:\\\"fill ~ ~-3 ~ ~ ~ ~ minecraft:air"
218+
if include_null_block_data:
219+
command_part += " 0"
220+
command_part += "\\\"}\"}"
213221
command += "\n\t" + command_part
214222
unformatted_command += command_part
215223
command_part = "{id:\"minecraft:commandblock_minecart\",Command:\"kill @e[type=minecraft:commandblock_minecart,r=0]\"}\n]}]}"

0 commit comments

Comments
 (0)