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

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

  1. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You can use //regen from WorldEdit or delete .mca files directly (hardcore way)
  3. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    dont forget to set the random parameter as like craftbukkit code
    fromgate likes this.
  6. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thank you! I'll try to do it today.
  7. Offline

    Njol

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Or you could make it completely random, resulting in a new landscape every time the same chunks are repopulated.
  8. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)

    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. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    its empty when its generated by minecraft code, minecraft works else than bukkit if you want populators
  10. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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?

    This post has been edited 1 time. It was last edited by fromgate Nov 5, 2012.
  11. Offline

    hatstand

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Did you try world.regenerateChunk(x, z)?
  12. Offline

    fireblast709

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @hatstand read the full post please :3
  13. Offline

    fireblast709

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @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)
  14. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  15. Offline

    fireblast709

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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.
  16. Offline

    hatstand

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ...This is what I get for replying to stuff when I've been up all night.
  17. Offline

    fireblast709

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    x3
  18. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)

Share This Page