Advertisement
Guest User

Generating a world with a custom BlockPopulator

a guest
Oct 27th, 2012
1,234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public World createWorld()
  2. {
  3.     plugin.getServer().getPluginManager().registerEvents(this, plugin); // listen for events
  4.    
  5.     WorldCreator wc = new WorldCreator(Settings.killerWorldName).environment(Environment.NORMAL);
  6.     World newWorld = wc.createWorld();
  7.    
  8.     HandlerList.unregisterAll(this); // stop listening for events
  9.    
  10.     return newWorld;
  11. }
  12.  
  13. @EventHandler
  14. public void onWorldInit(WorldInitEvent e)
  15. {
  16.     e.getWorld().getPopulators().add(new CustomPopulator());
  17. }
  18.  
  19. public class CustomPopulator extends BlockPopulator
  20. {
  21.     public void populate(World world, Random random, Chunk chunk)
  22.     {
  23.         chunk.getBlock(8, 72, 8).setType(Material.GLOWSTONE);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement