[Util] Changing the biome of a Chunk

Discussion in 'Resources' started by Skyost, Aug 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Skyost

    With a small function we can easily changing / replacing the biome of a single chunk :
    Code:java
    1. /**
    2. * Set the biome for a chunk.
    3. *
    4. * @param chunk The chunk.
    5. * @param biome The biome to set.
    6. */
    7.  
    8. public void setChunkBiome(Chunk chunk, Biome biome) {
    9. for(int x = 0 ; x < 16; x++) {
    10. for(int z = 0 ; z < 16; z++) {
    11. final Block block = chunk.getBlock(x, 0, z);
    12. block.setBiome(biome);
    13. }
    14. }
    15. }


    With some modifications, we can replace biomes :
    Code:java
    1. /**
    2. * Replace the biome for a chunk.
    3. *
    4. * @param chunk The chunk.
    5. * @param oldBiome The old biome.
    6. * @param newBiome The new biome.
    7. */
    8.  
    9. public void replaceChunkBiome(Chunk chunk, Biome oldBiome, Biome newBiome) {
    10. for(int x = 0 ; x < 16; x++) {
    11. for(int z = 0 ; z < 16; z++) {
    12. if(chunk.getBlock(x, 0, z).getBiome() == oldBiome) {
    13. final Block block = chunk.getBlock(x, 0, z);
    14. block.setBiome(newBiome);
    15. }
    16. }
    17. }
    18. }


    Thanks to the french developper Likaos for the first function !
     
    CaptainBern and nxtguy like this.
  2. Offline

    Skyost

  3. Offline

    timtower Administrator Administrator Moderator

    Skyost Would be nice if the regenchunk function wouldn't reset it
     
  4. Offline

    Skyost

    timtower This function work. See it in my Skyoseasons.
     
  5. Offline

    timtower Administrator Administrator Moderator

    I know that stuff like this works, but is it still that biome after you regenerated the area with worldedit? Last time I checked not.
     
    Skyost likes this.
Thread Status:
Not open for further replies.

Share This Page