|  | 
|  | 1 | +# SethBling's SetBiome Filter | 
|  | 2 | +# Directions: Just select a region and use this filter, it will apply the | 
|  | 3 | +# biome to all columns within the selected region. It can be used on regions | 
|  | 4 | +# of any size, they need not correspond to chunks. | 
|  | 5 | +# | 
|  | 6 | +# If you modify and redistribute this code, please credit SethBling | 
|  | 7 | + | 
|  | 8 | +from pymclevel import MCSchematic | 
|  | 9 | +from pymclevel import TAG_Compound | 
|  | 10 | +from pymclevel import TAG_Short | 
|  | 11 | +from pymclevel import TAG_Byte | 
|  | 12 | +from pymclevel import TAG_Byte_Array | 
|  | 13 | +from pymclevel import TAG_String | 
|  | 14 | +from numpy import zeros | 
|  | 15 | + | 
|  | 16 | +inputs = ( | 
|  | 17 | +    ("Biome", ("Desert", | 
|  | 18 | +               "Mushroom Island", | 
|  | 19 | +               "Ocean", | 
|  | 20 | +               "Plains", | 
|  | 21 | +               "Mountains", | 
|  | 22 | +               "Forest", | 
|  | 23 | +               "Taiga", | 
|  | 24 | +               "Swamp", | 
|  | 25 | +               "River", | 
|  | 26 | +               "Nether", | 
|  | 27 | +               "Sky", | 
|  | 28 | +               "Frozen Ocean", | 
|  | 29 | +               "Frozen River", | 
|  | 30 | +               "Ice Plains", | 
|  | 31 | +               "Ice Mountains", | 
|  | 32 | +               "Mushroom Shore", | 
|  | 33 | +               "Beach", | 
|  | 34 | +               "Desert Hills", | 
|  | 35 | +               "Forest Hills", | 
|  | 36 | +               "Taiga Hills", | 
|  | 37 | +               "Mountains Edge", | 
|  | 38 | +               "Jungle", | 
|  | 39 | +               "Jungle Hills", | 
|  | 40 | +               )), | 
|  | 41 | +) | 
|  | 42 | + | 
|  | 43 | +biomes = { | 
|  | 44 | +    "Ocean":0, | 
|  | 45 | +    "Plains":1, | 
|  | 46 | +    "Desert":2, | 
|  | 47 | +    "Mountains":3, | 
|  | 48 | +    "Forest":4, | 
|  | 49 | +    "Taiga":5, | 
|  | 50 | +    "Swamp":6, | 
|  | 51 | +    "River":7, | 
|  | 52 | +    "Nether":8, | 
|  | 53 | +    "Sky":9, | 
|  | 54 | +    "Frozen Ocean":10, | 
|  | 55 | +    "Frozen River":11, | 
|  | 56 | +    "Ice Plains":12, | 
|  | 57 | +    "Ice Mountains":13, | 
|  | 58 | +    "Mushroom Island":14, | 
|  | 59 | +    "Mushroom Shore":15, | 
|  | 60 | +    "Beach":16, | 
|  | 61 | +    "Desert Hills":17, | 
|  | 62 | +    "Forest Hills":18, | 
|  | 63 | +    "Taiga Hills":19, | 
|  | 64 | +    "Mountains Edge":20, | 
|  | 65 | +    "Jungle":21, | 
|  | 66 | +    "Jungle Hills":22, | 
|  | 67 | +    } | 
|  | 68 | + | 
|  | 69 | +def perform(level, box, options): | 
|  | 70 | +    biome = biomes[options["Biome"]] | 
|  | 71 | + | 
|  | 72 | +    minx = int(box.minx/16)*16 | 
|  | 73 | +    minz = int(box.minz/16)*16 | 
|  | 74 | + | 
|  | 75 | +    for x in xrange(minx, box.maxx, 16): | 
|  | 76 | +        for z in xrange(minz, box.maxz, 16): | 
|  | 77 | +            chunk = level.getChunk(x / 16, z / 16) | 
|  | 78 | +            chunk.decompress() | 
|  | 79 | +            chunk.dirty = True | 
|  | 80 | +            array = chunk.root_tag["Level"]["Biomes"].getValue() | 
|  | 81 | + | 
|  | 82 | +            chunkx = int(x/16)*16 | 
|  | 83 | +            chunkz = int(z/16)*16 | 
|  | 84 | + | 
|  | 85 | +            for bx in xrange(max(box.minx, chunkx), min(box.maxx, chunkx+16)): | 
|  | 86 | +                for bz in xrange(max(box.minz, chunkz), min(box.maxz, chunkz+16)): | 
|  | 87 | +                    idx = 16*(bz-chunkz)+(bx-chunkx) | 
|  | 88 | +                    array[idx] = biome | 
|  | 89 | + | 
|  | 90 | +            chunk.root_tag["Level"]["Biomes"].setValue(array) | 
0 commit comments