Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This is some code that you can put into your plugin to generate a biome map, similar to the ones in
- * the tutorial.
- */
- public void onEnable() {
- BufferedImage image = new BufferedImage(1920, 1080, BufferedImage.TYPE_INT_RGB);
- BiomeGenerator gen = new BiomeGenerator(getServer().getWorld("world"));
- for (int x = 0; x < image.getWidth(); x++) {
- for (int z=0; z < image.getHeight(); z++) {
- HashMap<Biomes, Double> biomes = gen.getBiomes(x, z);
- image.setRGB(x, z, getRbg(biomes));
- }
- }
- try {
- ImageIO.write(image, "png", new File(getDataFolder().getAbsoluteFile().toString() + File.pathSeparator + "image.png"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private int getRbg(HashMap<Biomes, Double> biomes) {
- int color = 0;
- double maxNoiz = 0.0;
- for (Biomes biome : biomes.keySet()) {
- if (biomes.get(biome) > maxNoiz) color = getBiomeColor(biome);
- }
- return color;
- }
- private int getBiomeColor(Biomes biome) {
- switch(biome) {
- case DESERT: return Color.ORANGE.getRGB();
- case FOREST: return Color.GREEN.darker().getRGB();
- case PLAINS: return Color.GREEN.getRGB();
- case SWAMP: return Color.GREEN.darker().darker().getRGB();
- case HILLS: return Color.GREEN.brighter().getRGB();
- default: return Color.white.getRGB();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement