Files
generate_kanto_arena.py
Code
1 297
generate_kanto_arena.py
import argparse
import gzip
import struct
from array import array
from pathlib import Path
WIDTH = 160
LENGTH = 120
HEIGHT = 55
DATA_VERSION = 3953
VOLUME = WIDTH * LENGTH * HEIGHT
palette = {"minecraft:air": 0}
blocks = array("I", [0]) * VOLUME
def block_id(name):
if name not in palette:
palette[name] = len(palette)
return palette[name]
def index(x, y, z):
return x + z * WIDTH + y * WIDTH * LENGTH
def fill(x1, y1, z1, x2, y2, z2, name):
if not (0 <= x1 <= x2 < WIDTH and 0 <= y1 <= y2 < HEIGHT and 0 <= z1 <= z2 < LENGTH):
raise ValueError(f"Cuboid fora dos limites: {(x1, y1, z1, x2, y2, z2)}")
state = block_id(name)
row = array("I", [state]) * (x2 - x1 + 1)
for y in range(y1, y2 + 1):
layer = y * WIDTH * LENGTH
for z in range(z1, z2 + 1):
start = layer + z * WIDTH + x1
blocks[start:start + len(row)] = row
def ring(x1, z1, x2, z2, y1, y2, thickness, name):
fill(x1, y1, z1, x2, y2, z1 + thickness - 1, name)
fill(x1, y1, z2 - thickness + 1, x2, y2, z2, name)
fill(x1, y1, z1 + thickness, x1 + thickness - 1, y2, z2 - thickness, name)
fill(x2 - thickness + 1, y1, z1 + thickness, x2, y2, z2 - thickness, name)
def build_base_and_plaza():
fill(0, 0, 0, WIDTH - 1, 3, LENGTH - 1, "minecraft:deepslate_bricks")
fill(0, 4, 0, WIDTH - 1, 4, LENGTH - 1, "minecraft:smooth_stone")
ring(1, 1, 158, 118, 5, 5, 2, "minecraft:light_gray_concrete")
ring(3, 3, 156, 116, 5, 5, 1, "minecraft:gold_block")
def build_arena_floor():
blue = (31, 33, 75, 76)
red = (84, 33, 128, 76)
for bounds, color in ((blue, "minecraft:light_blue_concrete"), (red, "minecraft:red_concrete")):
x1, z1, x2, z2 = bounds
fill(x1, 7, z1, x2, 7, z2, color)
fill(x1, 7, z1, x2, 7, z1 + 1, "minecraft:smooth_quartz")
fill(x1, 7, z2 - 1, x2, 7, z2, "minecraft:smooth_quartz")
fill(x1, 7, z1 + 2, x1 + 1, 7, z2 - 2, "minecraft:smooth_quartz")
fill(x2 - 1, 7, z1 + 2, x2, 7, z2 - 2, "minecraft:smooth_quartz")
center = (x1 + x2) // 2
fill(center, 7, z1 + 2, center, 7, z2 - 2, "minecraft:white_concrete")
fill(x1 + 3, 7, z1 + 5, x2 - 3, 7, z1 + 5, "minecraft:white_concrete")
fill(x1 + 3, 7, z2 - 5, x2 - 3, 7, z2 - 5, "minecraft:white_concrete")
fill(x1 + 3, 7, z1 + 3, x1 + 4, 7, z1 + 6, "minecraft:white_concrete")
fill(x2 - 4, 7, z2 - 6, x2 - 3, 7, z2 - 3, "minecraft:white_concrete")
fill(x1 + 3, 8, z1 + 2, x1 + 6, 8, z1 + 5, "minecraft:sea_lantern")
fill(x2 - 6, 8, z2 - 5, x2 - 3, 8, z2 - 2, "minecraft:sea_lantern")
fill(76, 6, 31, 83, 6, 78, "minecraft:polished_blackstone_bricks")
fill(77, 7, 33, 82, 7, 76, "minecraft:smooth_quartz")
fill(77, 8, 51, 82, 8, 58, "minecraft:sea_lantern")
fill(28, 5, 29, 131, 5, 30, "minecraft:quartz_bricks")
fill(28, 5, 79, 131, 5, 80, "minecraft:quartz_bricks")
def build_stands():
for x in range(11, 31, 2):
level = 10 + (29 - x) // 2
for z1, z2 in ((20, 49), (60, 91)):
fill(x, 4, z1, x + 1, level - 1, z2, "minecraft:polished_andesite")
seat = "minecraft:blue_concrete" if z1 == 20 else "minecraft:light_gray_concrete"
fill(x, level, z1, x + 1, level, z2, seat)
for x in range(129, 149, 2):
level = 10 + (x - 129) // 2
for z1, z2 in ((20, 49), (60, 91)):
fill(x, 4, z1, x + 1, level - 1, z2, "minecraft:polished_andesite")
seat = "minecraft:red_concrete" if z1 == 20 else "minecraft:light_gray_concrete"
fill(x, level, z1, x + 1, level, z2, seat)
for z in range(12, 32, 2):
level = 10 + (31 - z) // 2
fill(22, 4, z, 137, level - 1, z + 1, "minecraft:polished_andesite")
fill(22, level, z, 137, level, z + 1, "minecraft:light_gray_concrete")
for z in range(79, 103, 2):
level = 10 + (z - 79) // 2
fill(22, 4, z, 137, level - 1, z + 1, "minecraft:polished_andesite")
fill(22, level, z, 137, level, z + 1, "minecraft:light_gray_concrete")
for x in range(29, 10, -1):
level = 8 + (30 - x + 1) // 2
fill(x, level + 1, 50, x + 1, min(HEIGHT - 1, level + 4), 59, "minecraft:air")
fill(x, 4, 50, x + 1, level - 1, 59, "minecraft:polished_andesite")
fill(x, level, 50, x + 1, level, 59, "minecraft:smooth_quartz")
for x in range(130, 149):
level = 8 + (x - 129 + 1) // 2
fill(x, level + 1, 50, x + 1, min(HEIGHT - 1, level + 4), 59, "minecraft:air")
fill(x, 4, 50, x + 1, level - 1, 59, "minecraft:polished_andesite")
fill(x, level, 50, x + 1, level, 59, "minecraft:smooth_quartz")
def build_walls_and_roof():
fill(4, 5, 4, 7, 44, 115, "minecraft:light_gray_concrete")
fill(152, 5, 4, 155, 44, 115, "minecraft:light_gray_concrete")
fill(8, 5, 4, 151, 44, 7, "minecraft:light_gray_concrete")
fill(8, 5, 112, 151, 44, 115, "minecraft:light_gray_concrete")
for y in (12, 25, 38):
fill(4, y, 9, 7, y + 3, 110, "minecraft:blue_stained_glass")
fill(152, y, 9, 155, y + 3, 110, "minecraft:red_stained_glass")
fill(10, y, 4, 149, y + 3, 7, "minecraft:glass")
fill(10, y, 112, 149, y + 3, 115, "minecraft:glass")
fill(68, 5, 112, 91, 13, 115, "minecraft:air")
fill(68, 5, 116, 91, 5, 119, "minecraft:smooth_quartz")
fill(68, 5, 96, 91, 5, 111, "minecraft:quartz_bricks")
fill(69, 6, 96, 90, 6, 111, "minecraft:white_concrete")
fill(70, 5, 92, 89, 12, 95, "minecraft:light_gray_concrete")
fill(73, 6, 93, 86, 8, 94, "minecraft:gold_block")
fill(75, 6, 88, 84, 6, 91, "minecraft:sea_lantern")
for x in (62, 97):
fill(x, 5, 99, x + 2, 20, 101, "minecraft:quartz_bricks")
fill(x, 21, 99, x + 2, 21, 101, "minecraft:gold_block")
fill(62, 20, 99, 99, 22, 101, "minecraft:smooth_quartz")
fill(63, 23, 99, 98, 23, 101, "minecraft:sea_lantern")
for x in (8, 31, 64, 95, 128, 151):
for z in (9, 28, 50, 81, 109):
fill(x, 5, z, x + 2, 36, z + 2, "minecraft:quartz_bricks")
fill(x, 36, z, x + 2, 37, z + 2, "minecraft:gold_block")
ring(5, 5, 154, 114, 37, 39, 3, "minecraft:light_gray_concrete")
ring(7, 7, 152, 112, 40, 40, 1, "minecraft:iron_block")
fill(30, 31, 8, 129, 40, 77, "minecraft:air")
for x in range(12, 149, 18):
fill(x, 36, 8, x + 1, 36, 111, "minecraft:cut_copper")
fill(x, 35, 8, x + 1, 35, 111, "minecraft:sea_lantern")
for z in range(14, 110, 16):
fill(8, 36, z, 151, 36, z + 1, "minecraft:cut_copper")
fill(8, 35, z, 151, 35, z + 1, "minecraft:sea_lantern")
fill(68, 24, 112, 91, 50, 115, "minecraft:quartz_bricks")
fill(65, 44, 110, 94, 46, 117, "minecraft:gold_block")
fill(68, 50, 111, 91, 52, 116, "minecraft:smooth_quartz")
fill(71, 53, 112, 88, 54, 115, "minecraft:sea_lantern")
fill(75, 24, 111, 84, 42, 111, "minecraft:blue_concrete")
fill(75, 24, 116, 84, 42, 116, "minecraft:red_concrete")
def build_entry_emblem():
pattern = [
"....RRR....",
"..RRRRRRR..",
".RRRRRRRRR.",
".RRRRRRRRR.",
"RRRRRRRRRRR",
"BBBBBBBBBBB",
"BBBBBBBBBBB",
"WWWWWWWWWWW",
".WWWWWWWWW.",
".WWWWWWWWW.",
"..WWWWWWW..",
]
colors = {"R": "minecraft:red_concrete", "B": "minecraft:polished_blackstone", "W": "minecraft:white_concrete"}
for row, line in enumerate(pattern):
for column, pixel in enumerate(line):
if pixel != ".":
fill(74 + column, 38 - row, 116, 74 + column, 38 - row, 117, colors[pixel])
POKEMON = [
("Pikachu", ["....B.B....", "...YBYB...", "..YYYYYYY..", ".YYYYYYYYY.", ".YYBYYYBYY.", ".YYYYYYYYY.", "..YRYRY...", "..YYYYYYY..", "...YYYYY...", "..YY...YY..", ".YY.....YY.", ".Y.......Y."], {"Y": "minecraft:yellow_concrete", "B": "minecraft:black_concrete", "R": "minecraft:red_concrete"}),
("Charizard", ["....B...B....", "...OOBBOO...", "..OOOOOOOOO..", ".OOOOOOOOOOO.", ".OOBOOOOBOOO.", "..OOOOOOOOO..", "...OOOWOOO...", "..OOOOOOOOO..", ".OOO..O..OOO.", "OOO...O...OOO", "....OOO....", "...O...O..."], {"O": "minecraft:orange_concrete", "B": "minecraft:light_blue_concrete", "W": "minecraft:light_gray_concrete"}),
("Blastoise", ["...CCCCCCC...", "..CCCCCCCCC..", ".CCCCCCCCCCC.", ".CCWCCCCCWCC.", ".CCCCCCCCCCC.", "..CCCCCCCCC..", "...CCCCCCC...", "..CC..C..CC..", ".CC...C...CC.", "CC...CCC...CC", "....CCCCC....", "...CC...CC..."], {"C": "minecraft:light_blue_concrete", "W": "minecraft:white_concrete"}),
("Venusaur", ["....GGGGG....", "...GGGGGGG...", "..GGGPPPGGG..", ".GGPPPPPPPGG.", "..GGPPPPPGG..", "...GGGGGGG...", "..GGGGGGGGG..", ".GGGGGGGGGGG.", ".GGWGGGGGWGG.", "..GGGGGGGGG..", "...GG...GG...", "..GG.....GG.."], {"G": "minecraft:green_concrete", "P": "minecraft:magenta_concrete", "W": "minecraft:white_concrete"}),
("Gengar", ["....PPPPP....", "..PPPPPPPPP..", ".PPPPPPPPPPP.", "PPPPPPPPPPPPP", "PPPPPPPPPPPPP", "PPWPPPPPPWPPP", "PPWPPPPPPWPPP", "PPPPPPPPPPPPP", ".PPPPPPPPPPP.", "..PPPPPPPPP..", "...PP...PP...", "..PP.....PP.."], {"P": "minecraft:purple_concrete", "W": "minecraft:white_concrete"}),
("Snorlax", ["...BBBBBBB...", "..BWWBWWWB...", ".BBBBBBBBBBB.", ".BBBBBBBBBBB.", ".BBWWWWWWWBB.", ".BBWWWWWWWBB.", "..BBBBBBBBB..", "..BBBBBBBBB..", "..BB.....BB..", ".BBB.....BBB.", "BBB.......BBB", "BB.........BB"], {"B": "minecraft:blue_concrete", "W": "minecraft:white_concrete"}),
("Eevee", ["..BBBB...BBBB..", ".BBTTB...BTTBB.", "..TTTTTTTTTT...", ".TTTTTTTTTTTTT.", ".TTWTTTTTTWTTT.", ".TTTTTTTTTTTTT.", "..TTTTTTTTTTT..", "...TTTTTTTTT...", "..TTT...TTT....", ".TTT.....TTT...", "TTT.......TTT..", "TT..........TT."], {"T": "minecraft:brown_concrete", "B": "minecraft:black_concrete", "W": "minecraft:white_concrete"}),
]
def build_statues():
placements = [