Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pymclevel import MCSchematic
- from pymclevel import TAG_Compound
- from pymclevel import TAG_Short
- from pymclevel import TAG_Byte
- from pymclevel import TAG_Byte_Array
- from pymclevel import TAG_String
- from numpy import zeros
- import random
- displayName = "Biome tools"
- inputs = (
- ("Biome 1", ("Desert",
- "Mushroom Island",
- "Ocean",
- "Plains",
- "Mountains",
- "Forest",
- "Taiga",
- "Swamp",
- "River",
- "Nether",
- "Sky",
- "Frozen Ocean",
- "Frozen River",
- "Ice Plains",
- "Ice Mountains",
- "Mushroom Shore",
- "Beach",
- "Desert Hills",
- "Forest Hills",
- "Taiga Hills",
- "Mountains Edge",
- "Jungle",
- "Jungle Hills",
- )),
- ("Biome 2", ("Desert",
- "Mushroom Island",
- "Ocean",
- "Plains",
- "Mountains",
- "Forest",
- "Taiga",
- "Swamp",
- "River",
- "Nether",
- "Sky",
- "Frozen Ocean",
- "Frozen River",
- "Ice Plains",
- "Ice Mountains",
- "Mushroom Shore",
- "Beach",
- "Desert Hills",
- "Forest Hills",
- "Taiga Hills",
- "Mountains Edge",
- "Jungle",
- "Jungle Hills",
- )),
- ("Random", False),
- ("Chance", (50, 0, 100)),
- ("Outline check", False),
- )
- biomes = {
- "Ocean":0,
- "Plains":1,
- "Desert":2,
- "Mountains":3,
- "Forest":4,
- "Taiga":5,
- "Swamp":6,
- "River":7,
- "Nether":8,
- "Sky":9,
- "Frozen Ocean":10,
- "Frozen River":11,
- "Ice Plains":12,
- "Ice Mountains":13,
- "Mushroom Island":14,
- "Mushroom Shore":15,
- "Beach":16,
- "Desert Hills":17,
- "Forest Hills":18,
- "Taiga Hills":19,
- "Mountains Edge":20,
- "Jungle":21,
- "Jungle Hills":22,
- }
- def perform(level, box, options):
- biome1 = biomes[options["Biome 1"]]
- biome2 = biomes[options["Biome 2"]]
- chance = options["Chance"]
- opRandom = options["Random"]
- opOutline = options["Outline check"]
- if opRandom == True and opOutline == True:
- createBiome = 1
- elif opOutline:
- createBiome = 2
- elif opRandom:
- createBiome = 3
- else:
- createBiome = 4
- minx = int(box.minx/16)*16
- minz = int(box.minz/16)*16
- for x in xrange(minx, box.maxx, 16):
- for z in xrange(minz, box.maxz, 16):
- chunk = level.getChunk(x / 16, z / 16)
- chunk.decompress()
- chunk.dirty = True
- array = chunk.root_tag["Level"]["Biomes"].value
- chunkx = int(x/16)*16
- chunkz = int(z/16)*16
- for bx in xrange(max(box.minx, chunkx), min(box.maxx, chunkx+16)):
- for bz in xrange(max(box.minz, chunkz), min(box.maxz, chunkz+16)):
- idx = 16*(bz-chunkz)+(bx-chunkx)
- if createBiome == 1:
- randomOutline(level, box, options, bx, y, bz, chance, array, idx, biome1, biome2)
- elif createBiome == 2:
- OutlineBiome(level, box, options, bx, bz, array, idx, biome1)
- elif createBiome == 3:
- randomBiome(level, box, options, chance, array, idx, biome1, biome2)
- else:
- setBiome(level, box, options, array, idx, biome1)
- chunk.root_tag["Level"]["Biomes"].value = array
- def randomGen():
- return int(random.random() * 99) + 1
- def OutlineBiome(level, box, options, bx, bz, array, idx, biome1):
- ground = 0
- for y in xrange(box.miny, box.maxy):
- if level.blockAt(bx, y, bz) != 0:
- ground = 1
- break
- if ground:
- array[idx] = biome1
- def randomBiome(level, box, options, chance, array, idx, biome1, biome2):
- if randomGen() <= chance:
- array[idx] = biome1
- else:
- array[idx] = biome2
- def randomOutline(level, box, options, bx, y, bz, chance, array, idx, biome1, biome2):
- for y in xrange(box.miny, box.maxy):
- if level.blockAt(bx, y, bz) != 0:
- ground = 1
- break
- if ground:
- if randomGen() <= chance:
- array[idx] = biome1
- else:
- array[idx] = biome2
- def setBiome(level, box, options, array, idx, biome1):
- array[idx] = biome1
Advertisement
Add Comment
Please, Sign In to add comment