Skip to content

Instantly share code, notes, and snippets.

@TheonlyTazz
Last active October 23, 2022 14:56
Show Gist options
  • Save TheonlyTazz/a61cab41ac4272954f43807b70ef6cc1 to your computer and use it in GitHub Desktop.
Save TheonlyTazz/a61cab41ac4272954f43807b70ef6cc1 to your computer and use it in GitHub Desktop.
Minecolonies Blueprint Changer
import nbtlib
from nbtlib.tag import *
import os
IF = 'warped/'
OF = 'crimson/'
#Block Palette List
palettelist = [
['warped', 'crimson'],
['warped_wart', 'nether_wart'],
['minecraft:jungle_stairs', 'infernalexp:basalt_stairs'],
['minecraft:bookshelf', 'quark:crimson_bookshelf'],
['minecraft:lantern', 'minecraft:soul_lantern'],
['quark:crimson_ladder', 'minecraft:ladder'],
['minecraft:torch', 'minecraft:soul_torch'],
['minecraft:twisting_vines', 'minecraft:weeping_vines'],
['minecraft:nether_sprouts', 'minecraft:crimson_roots']
]
#Block Entities List
belist = [
['cyan_brick_extra', 'red_brick_extra'],
['minecraft:acacia_planks', 'minecraft:basalt'],
['minecraft:oak_planks', 'minecraft:basalt']
]
# Get all files from InputFolder
listfiles = os.listdir(IF)
for filename in listfiles:
if '.blueprint' in filename:
nbt_file = nbtlib.load(IF+filename, gzipped=True)
# Open first Compound NBT
file = nbt_file[""]
te = file['tile_entities']
palette = file['palette']
# Change block textures
for x in palette:
name = ''
name = x.get('Name')
for y in palettelist:
if 'Name' in x:
if y[0] in name:
replace = name.replace(y[0], y[1])
x.update({'Name': String(replace)})
# Change Tile Entities
for x in te:
for y in x:
if 'textureData' in y:
for block in x[y]:
for replace in belist:
if replace[0] in x[y][block]:
new = x[y][block].replace(replace[0], replace[1])
x[y].update({block: String(new)})
nbt_file.save(OF+filename)
print('saved '+OF+filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment