Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: Java  |  size: 1.69 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package net.nexustools.craftedplatformstest.world;
  6.  
  7. /**
  8.  *
  9.  * @author Luke
  10.  */
  11. public class GlowMushGenerator {
  12.  
  13.     public static int COMMONALITY = 512;
  14.  
  15.     public static void seed(World w, Block b) {
  16.         int tx = 0;
  17.         int ty = 0;
  18.         for (int i = 0; i < COMMONALITY; i++) {
  19.             try {
  20.                 tx = (int) Math.round(Math.random() * 255);
  21.                 ty = (int) Math.round(Math.random() * 255);
  22.                 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) {
  23.                     w.chunks.get(0).blocks.data[tx][ty].id = Blocks.GLOWMUSH.id;
  24.                     w.chunks.get(0).light.data[tx][ty] = 128;
  25.                 }
  26.             } catch (Throwable r) {
  27.             }
  28.         }
  29.     }
  30.  
  31.     public static void expand(World w, Block b) {
  32.         for (int x = 0; x < 255; x++) {
  33.             for (int y = 0; y < 255; y++) {
  34.                 if(w.chunks.get(0).blocks.data[x][y].id == Blocks.GLOWMUSH.id){
  35.                     for(int xe = x - 8; xe < x + 9; xe++){
  36.                         for(int ye = y - 8; ye < y + 9; ye++){
  37.                             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){}
  38.                         }
  39.                     }
  40.                     w.chunks.get(0).light.data[x][y] = 64;
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }