Change biome between x:0,z:0 and x:10,z:10 to jungle

Discussion in 'Plugin Development' started by ice374, Aug 16, 2013.

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

    ice374

    How would i change biome between the coordinates x:0 , z:0 and x:10 , z:10 to jungle biome?
     
    etaxi341 likes this.
  2. Offline

    CubieX

    I think you need WorldEdit for this.
    So include WorldEdit in your plugins BuildPath as dependency, add
    Code:
    depend: [WorldEdit]
    to your Plugin.yml and get an instance of the WorldEdit plugin.
    Code:
    WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
    (You should check if "null != worldEdit" before using it)

    Now you can use WE's methods to set the biome of a defined area.
    Here is the WE API documentation.
    I had only a quick look at it.
    The "BukkitWorld" class has a "setBiome(Vector2D pt, BiomeType type)" method.
    With this you should be able to set the biome type in a given area.
    So get your world as "BukkitWorld" and call setBiome(...) on it.

    I can't provide a code example. Maybe searching the board for this will help. (if you didn't do this already)
     
  3. Offline

    ZachBora

    You don't need worldedit if you do it in code.

    Code:java
    1.  
    2. int bottomX = 0;
    3. int topX = 10;
    4. int bottomZ = 0;
    5. int topZ = 10;
    6.  
    7. for(int x = bottomX; x <= topX; x++)
    8. {
    9. for(int z = bottomZ; z <= topZ; z++)
    10. {
    11. world.getBlockAt(x, 0, z).setBiome(biome);
    12. }
    13. }
    14. //Optionally, refresh the chunks so they are updated on clients
    15.  
    16. int minChunkX = (int) Math.floor((double) bottomX / 16);
    17. int maxChunkX = (int) Math.floor((double) topX / 16);
    18. int minChunkZ = (int) Math.floor((double) bottomZ / 16);
    19. int maxChunkZ = (int) Math.floor((double) topZ / 16);
    20.  
    21. for(int x = minChunkX; x <= maxChunkX; x++)
    22. {
    23. for(int z = minChunkZ; z <= maxChunkZ; z++)
    24. {
    25. world.refreshChunk(x, z);
    26. }
    27. }
    28.  
     
Thread Status:
Not open for further replies.

Share This Page