
Untitled
By: a guest on
May 8th, 2012 | syntax:
Java | size: 1.69 KB | hits: 13 | expires: Never
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.nexustools.craftedplatformstest.world;
/**
*
* @author Luke
*/
public class GlowMushGenerator {
public static int COMMONALITY = 512;
public static void seed(World w, Block b) {
int tx = 0;
int ty = 0;
for (int i = 0; i < COMMONALITY; i++) {
try {
tx = (int) Math.round(Math.random() * 255);
ty = (int) Math.round(Math.random() * 255);
if ((w.chunks.get(0).blocks.data[tx][ty + 1].id == Blocks.DIRT.id || w.chunks.get(0).blocks.data[tx][ty + 1].id == Blocks.GRASS.id) && w.chunks.get(0).blocks.data[tx][ty - 1].id == Blocks.AIR.id) {
w.chunks.get(0).blocks.data[tx][ty].id = Blocks.GLOWMUSH.id;
w.chunks.get(0).light.data[tx][ty] = 128;
}
} catch (Throwable r) {
}
}
}
public static void expand(World w, Block b) {
for (int x = 0; x < 255; x++) {
for (int y = 0; y < 255; y++) {
if(w.chunks.get(0).blocks.data[x][y].id == Blocks.GLOWMUSH.id){
for(int xe = x - 8; xe < x + 9; xe++){
for(int ye = y - 8; ye < y + 9; ye++){
try{w.chunks.get(0).light.data[xe][ye] += (char)(64-(((xe>x?xe-x:x-xe)+(ye>y?ye-y:y-ye))*8));if(w.chunks.get(0).light.data[xe][ye] >= 250)w.chunks.get(0).light.data[xe][ye]=0;}catch(Throwable r){}
}
}
w.chunks.get(0).light.data[x][y] = 64;
}
}
}
}
}