Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 0xFF 0x0 0x0 0x0 0x1 //header
- coords = (x << 4 | z);
- */
- //String data = "";
- byte[] data = new byte[512*512*32];
- int index = -1;
- void addint(int b){
- index++;
- data[index] = (byte)((b>>24)&0xFF);
- index++;
- data[index] = (byte)((b>>16)&0xFF);
- index++;
- data[index] = (byte)((b>>8)&0xFF);
- index++;
- data[index] = (byte)((b)&0xFF);
- }
- void addbyte(int b){
- index++;
- data[index] = (byte)(b);
- }
- int secsize;
- boolean exists = true;
- void setup(){
- //draw settings
- size(1024,1024);
- colorMode(HSB,255,255,255);
- secsize = width/8;
- //0xff and version
- addbyte(255);
- addint(1);
- for (int sectionX = 0; sectionX < 8; sectionX++){
- for (int sectionZ = 0; sectionZ < 8; sectionZ++) {
- //add section coordinate
- addbyte(((char)sectionX << 4 | (char)sectionZ));
- println("Added section: "+sectionX+" "+sectionZ);
- int chunk = 0;
- print("Added chunk: ");
- for (int chunkX = 0; chunkX < 4; chunkX++){
- for (int chunkZ = 0; chunkZ < 4; chunkZ++) {
- chunk +=1;
- print(chunk+" ");
- if(!exists){ //chunk doesnt exist so add 0xFFFFFFFF
- addbyte(-1); //empty
- continue;
- }
- //draw chunks
- int chunksize = secsize / 4;
- //pixel loop
- for (int x = 0; x < 16; x++) {
- for (int z = 0; z < 16; z++) {
- boolean notGrass = false; //if its not grass add a extra int for blockstate!
- boolean hasOverlays = false; // has overlays, for example water and ice (extra data!)
- boolean heightextrabyte = false; //old height (extra byte!)
- boolean isCaveBlock = false; // is cave block
- boolean hasBiome = false; //has biome (grass & foliage colortype only) (extra byte!)
- char light = 15; //light level 0-15
- char heightlevel = 64; // height level 0-255
- char colortype = 0; //0 - normal, 1 - grass, 2 - foliage, 3 - custom color
- char heightshade= 0; //0 - no slope, 1 - bright slope, 2 - dark slope, 3 - unknown slope
- int pp = 0;
- pp = pp | (notGrass ? 1 : 0) & 0x1;
- pp = pp | ((hasOverlays ? 1 : 0)<<1)& 0x1;
- pp = pp | (colortype & 0x3 )<<2;
- pp = pp | (heightshade & 0x3)<<4;
- pp = pp | ((heightextrabyte ? 1 : 0)<<6);
- pp = pp | ((isCaveBlock ? 1 : 0)<<7);
- pp = pp | (light & 0xF)<<8;
- pp = pp | ((char)heightlevel)<<12;
- pp = pp | (hasBiome ? 0x1 : 0x0)<<20;
- addint(pp);
- if(notGrass){
- int blockstate = 0; //dunno what to add, color palette?
- addint(blockstate);
- }
- if(colortype == 3){
- int customColorMultiplier = 0;
- addint(customColorMultiplier);
- }
- if(hasBiome || (colortype != 0 && colortype != 3)){
- char biome = 0;
- addbyte(biome);
- }
- if(hasOverlays){
- //skip, no overlays today, i dont need that.
- //one byte for amount
- //few ints and bytes for each...
- }
- if(heightextrabyte){ // old height. one byte. dont need that.
- char oldheight = 0;
- addbyte(oldheight);
- }
- //fill chunks
- strokeWeight(0);
- fill(heightlevel,255,255);
- rect(((sectionX*secsize)+(chunkX*chunksize)+x*(secsize/64)),((sectionZ*secsize)+(chunkZ*chunksize)+z*(secsize/64)),(secsize/64),(secsize/64));
- }
- }
- //draw chunk
- strokeWeight(1);
- fill(0,0,0,0);
- stroke(0);
- rect((sectionX*secsize)+(chunkX*chunksize), (sectionZ*secsize)+(chunkZ*chunksize),chunksize,chunksize);
- }
- }
- //draw sections
- fill(0,0,0,0);
- stroke(0);
- strokeWeight(2);
- rect((sectionX*secsize),(sectionZ*secsize),secsize,secsize);
- println(".. done");
- }
- }
- //new array & copy so it wont write 512x512x32 bytes of 0x0...
- byte[] b = new byte[index];
- for(int i = 0; i < index ; i++){
- b[i] = data[i];
- }
- saveBytes("region.xaero",b);
- b=null;
- data=null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement