Advertisement
jtjj222

Image generator for minecraft biome map

Aug 1st, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. /**
  2. * This is some code that you can put into your plugin to generate a biome map, similar to the ones in
  3. * the tutorial.
  4. */
  5. public void onEnable() {
  6.     BufferedImage image = new BufferedImage(1920, 1080, BufferedImage.TYPE_INT_RGB);
  7.     BiomeGenerator gen = new BiomeGenerator(getServer().getWorld("world"));
  8.        
  9.     for (int x = 0; x < image.getWidth(); x++) {
  10.         for (int z=0; z < image.getHeight(); z++) {
  11.             HashMap<Biomes, Double> biomes = gen.getBiomes(x, z);
  12.             image.setRGB(x, z, getRbg(biomes));
  13.         }
  14.     }
  15.        
  16.     try {
  17.         ImageIO.write(image, "png", new File(getDataFolder().getAbsoluteFile().toString() + File.pathSeparator + "image.png"));
  18.     } catch (IOException e) {
  19.         // TODO Auto-generated catch block
  20.         e.printStackTrace();
  21.     }
  22. }
  23. private int getRbg(HashMap<Biomes, Double> biomes) {
  24.     int color = 0;
  25.    
  26.     double maxNoiz = 0.0;
  27.     for (Biomes biome : biomes.keySet()) {
  28.         if (biomes.get(biome) > maxNoiz) color = getBiomeColor(biome);
  29.     }
  30.    
  31.     return color;
  32. }
  33.  
  34. private int getBiomeColor(Biomes biome) {
  35.     switch(biome) {
  36.     case DESERT: return Color.ORANGE.getRGB();
  37.     case FOREST: return Color.GREEN.darker().getRGB();
  38.     case PLAINS: return Color.GREEN.getRGB();
  39.     case SWAMP:  return Color.GREEN.darker().darker().getRGB();
  40.     case HILLS:  return Color.GREEN.brighter().getRGB();
  41.     default:     return Color.white.getRGB();
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement