Last active
October 23, 2022 14:56
-
-
Save TheonlyTazz/a61cab41ac4272954f43807b70ef6cc1 to your computer and use it in GitHub Desktop.
Minecolonies Blueprint Changer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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