Is it possible to re-execute populator for defined area (chunks)?

Discussion in 'Plugin Development' started by fromgate, May 26, 2012.

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

    fromgate

    Hello!

    I need to repopulate some area (after hard players activities some regions of our server are turned to wastelands :)).
    Is there a way to execute populator and get a new trees, grass, animals, villages (and may be strongholds) in defined area/chunk?
     
  2. Offline

    dwi

    You can use //regen from WorldEdit or delete .mca files directly (hardcore way)
     
  3. Offline

    fromgate

    Mmmmm.... This forum is called "Plugin Development" and think no one will ask here about world edit commands :)

    WorldEdit use world.regenerateChunk(x,z) method. But this method is regenerating full chunk (deleting old chunk and create new one). But I don't need to regenerate full chunk. I just need to repopulate it: i need new trees, grass, villages... etc.
     
  4. Offline

    Njol

    I think you can do it manually by first getting a list of all populators of a world with world.getPopulators(), then invoking populator.populate(World world, Random random, Chunk source) for each populator and on every chunk you want to repopulate.
     
    fromgate likes this.
  5. dont forget to set the random parameter as like craftbukkit code
     
    fromgate likes this.
  6. Offline

    fromgate

    Thank you! I'll try to do it today.
     
  7. Offline

    Njol

    Or you could make it completely random, resulting in a new landscape every time the same chunks are repopulated.
     
  8. Offline

    fromgate


    Hello... sometimes ago I found some time to test it.
    And I find that word.getPopulators() is empty everytime. So I cannot start populator from this list...
     
  9. its empty when its generated by minecraft code, minecraft works else than bukkit if you want populators
     
  10. Offline

    fromgate

    Yes, world is generated without any additional generators. But I need to repopulate area? Is there a way to access a minecraft populators and force to repopulate chunks/area?
     
  11. Offline

    hatstand

    Did you try world.regenerateChunk(x, z)?
     
  12. Offline

    fireblast709

    hatstand read the full post please :3

    fromgate trees and grass is quite easy: randomly use world.generateTree(Location l, TreeType type) for trees and get like x locations with air above the highest block and set that to grass. (Though, the grass might not look as good as you want)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  13. Offline

    fromgate

  14. Offline

    fireblast709

    I found some WorldGen classes for trees, but in the end the Bukkit world.generateTree() method uses that to generate them. I however found a few generators in NMS code you might like (I got this from decompiled, deobfuscated minecraft. The classes are usable if you use CB.jar)
    Code:java
    1. // WorldGen classes + initialization
    2. WorldGenBigMushroom gen = WorldGenBigMushroom(int mush_id);
    3. WorldGenBigTree gen = WorldGenBigTree(true);
    4. WorldGenCactus gen = WorldGenCactus();
    5. WorldGenDeadBush gen = WorldGenDeadBush(int deadbush_id);
    6. WorldGenFlowers gen = WorldGenFlowers(int flower_id);
    7. WorldGenForest gen = WorldGenForest(true);
    8. WorldGenHugeTrees gen = WorldGenHugeTrees(true, int baseHeight, int woodMetadata, int leavesMetadata);
    9. WorldGenPumpkin gen = WorldGenPumpkin();
    10. WorldGenReed gen = WorldGenReed();
    11. WorldGenShrub gen = WorldGenShrub();
    12. WorldGenTallGrass gen = WorldGenTallGrass(int id, int metadata);
    13. WorldGenTrees gen = WorldGenTrees(true, int minHeight, int metaWood, int metaLeaves, boolean vinesGrow);
    14. WorldGenVines gen = WorldGenVines();
    15. WorldGenWaterLily gen = WorldGenWaterLily();
    16. // Choose ONE of the above, then call
    17. // Random is a self defined random (might be usefull to make weighted randoms)
    18. gen.(net.minecraft.World world, Random random, int x, int y, int z);

    Note that it will not exactly spawn one thing at Location (x,y,z), but it will actually "generate" randomly
     
    fromgate likes this.
  15. Offline

    hatstand

    ...This is what I get for replying to stuff when I've been up all night.
     
  16. Offline

    fireblast709

    x3
     
  17. Offline

    fromgate

Thread Status:
Not open for further replies.

Share This Page