forked from arvitus/mcascripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReplaceBlockPairs.groovy
24 lines (22 loc) · 995 Bytes
/
ReplaceBlockPairs.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import net.querz.mcaselector.io.mca.ChunkData
import net.querz.nbt.CompoundTag
/**
* Replaces the original block in each block pair with its respective destination block.
* Note: Block states are not updated, only the block name is changed.
*
* @type Change NBT (Ctrl + N)
* @difficulty INTERMEDIATE
*/
static void apply(ChunkData data) {
// Specify blocks here as comma-separated pairs in the format 'source:original_block': 'source:new_block'
def blockpairs = ['byg:red_rock': 'byg:travertine', 'byg:aspen_log': 'byg:pendorite_block']
for (section in data.region()?.data?.getListTag("sections") as List<CompoundTag>) {
var blockPalette = section.getCompoundTag("block_states")?.getListTag("palette")
if (!blockPalette) continue
for (block in blockPalette as List<CompoundTag>) {
if (block.getString("Name") in blockpairs) {
block.putString("Name", blockpairs[block.getString("Name")])
}
}
}
}