[Solved] Controlled Biome Generation

Discussion in 'Spigot Plugin Development' started by Homer04, May 17, 2015.

Thread Status:
Not open for further replies.
  1. Hey there,

    I want to generate a World, nothing special until now but I want it to have a special scheme.
    In the Center, a .schematic file will be placed at the coordinates 0, 0, 0 and in a radius 200 Blocks around that will be the Biome: Plains.

    After that 200 Blocks Radius, the World will generate depending on the Sky-Direction (N, NE, E, SE, S...). Like this:
    [​IMG]

    Anybody got an Idea on how to do this?
     
  2. See the ChunkGenerator class, that should be what you're looking for. After that, you just need to implement your own algorithm for generating the terrain, which is pretty hard. I haven't looked into the generation, but you may be able to copy the built-in generation algorithms for Minecraft.
     
  3. Okay, thanks. I'll take a look...
     
  4. This could help you determine the biome (I'm not completely sure where you should put this, maybe the ChunkGenerator, I'm not sure, but the Chunk Populator Event might work):
    Code (Text):
    someMethod{
      int radius = 200;
      Block b = ????;
      int x=b.getX();
      int z=b.getZ();
      Biome biome;
      if(getDistance(x, z, 0, 0) < radius){ //getDistance is a method I put at the bottom
        biome=Biome.PLAINS;
      }else if(x>0 && z>0){
        if(z>x) biome=Biome.PLAINS;
        else biome=Biome.OCEAN;
      } else if(x>0 && z<0){
        if(-z>x) biome=Biome.FOREST;
        else biome=Biome.EXTREME_HILLS;
      } //Do the same things with the other ones
      b.setBiome(biome);
    }

    public static int getDistance(int x1, int y2, int x2, int z2){
      return Math.sqrt((x1-x2)*(x1-x2)+(z1-z2)*(z1-z2));
    }
    I hope this helped, feel free to ask me if you have any questions. Good luck with this.

    PS: This code isn't really tested, but it should at least give you some idea on how to do this.
     
    #5 MnMaxon, May 18, 2015
    Last edited: May 18, 2015
    • Like Like x 1
  5. jflory7

    jflory7 Retired Moderator
    Retired Benefactor

    Thread locked per request
     
Thread Status:
Not open for further replies.