WorldGenerationControl
** NOTE: This no longer works as of 1.4+, and /destroyAndRegenerateArea is broken as of 1.2+. I may get around to rewriting this at some point, but no promises. Patches are welcome! See GitHub. **
WorldGenerationControl 2.6
Formerly ForceGenChunks
Which is a dumb name so I changed it
This is a very simple plugin to allow you to pre-generate a region of your world. It does not affect already generated regions. As of 2.0, it can also repair lighting of existing regions.
Features
- Generate arbitrary regions by coordinates
- Queue multiple generations
- Various speed settings to control lag vs generation time
- Works on a live server
- Doesn't lock up the server (unless you use the /allAtOnce option)
- Low ram usage, works fine on servers with 1gig of memory.
- Generates trees & ore, not just land
- Can generate valid lighting
- Can force regenerate lighting on existing chunks, to fix light issues.
Bugs/Quirks
- Generating land takes a lot of CPU - nothing the plugin can do to prevent that! If you don't want to lag a live server, use the /slow or /veryslow modes.
- Designed for servers with at least 1gig of memory allocated to them (-Xmx1024M). Servers with lower memory limits may encounter heap exceptions. If you have less than 1gig of memory, try using /slow or /veryslow modes.
Commands
The /genregion (or /generateregion) command can be entered by any server op, the server console, or anyone with the appropriate permission (see below).
The syntax is:
/genregion WorldName StartX StartZ EndX EndZ
For circles (/generatecircularregion or /gencircle):
/gencircle Radius [WorldName xCenter zCenter]
The world and center coordinates for the circle command are [optional] if you are a player (not the console). It will default to your current/world position.
All coordinates are in normal, in-game coordinates - but will be adjusted to the nearest chunk boundary (inclusive).
Options
All commands can have options applied to them like so:
/gencircle 1600 MyWorld 0 0 /fast /lighting
Options are not case sensitive. The available options are:
- /allAtOnce - Don't pause between steps, generate everything requested all at once. This will make the server basically unusable until the generation completes, but get the job done fastest. Very useful in conjunction with /onlyWhenEmpty
- /veryFast, /fast, /slow, /verySlow - Adjust speed. Has no effect if /allAtOnce specified. Normally the plugin will cause mild lag while generating usually doing around 700ms of work per three seconds (depending on the server CPU). Raising the speed with fast or veryfast will cause more lag but speed up the generation, slow or veryslow will reduce lag while increasing generation times. Veryfast will cause a lot of lag. Veryslow will cause almost no lag, but will take something like 10x longer.
- /forceKeepUp - Force the server to 'keep up' with garbage collection and chunk saving. In particular, 1.9 Has a new async chunk saver, which appears to be rate limited, meaning it may not keep up with fast generations. This option forces the chunks to be saved immediately, rather than on a separate thread. You should use this option if you notice the plugin spending a lot of time "waiting for the server to catch up" and don't mind the minor increase in CPU usage caused by forcing it to keep up. /allAtOnce mode will always use this option.
- /lighting:none - Skip generating light data for loaded chunks. See Notes on Lighting below.
- /lighting:force - Reset and regenerate lighting for all chunks we pass over, even if they already have lighting data. Useful for fixing areas with corrupt lighting.
- /verbose - Print detailed timing info while generating. Doubles the amount of spam the plugin prints!
- /quitAfter - Shutdown the server once this (and any other pending generations) are complete. See the Using in a Script section below.
- /onlyWhenEmpty - Only do generating when the server is empty. The plugin will pause generation and wait until players leave, allowing you to generate lots of land without worrying at all about the extra CPU. You can use this in conjunction with /allAtOnce to have the server use 100% when it is empty towards generating land, without causing any lag when players are online.
- /destroyAndRegenerateArea - As the name says, this will delete and destroy all land in the area given, generating new land instead. I cannot stress enough how this will delete your world (or the specified area of it at least), so please understand what you're doing and make backups!
Permissions
Permissions are optional. Server ops and the server console can always use generation commands. However, if you have permissions installed, the following permissions are used:
- worldgenerationcontrol.generate - Allows user to queue generations. Implicitly grants worldgenerationcontrol.statusupdates
- worldgenerationcontrol.statusupdates - Allows user to see generation progress messages. These can be quite spammy, explicitly removing this permission will cause only the server console to see these messages.
Examples
/genregion OurBeautifulWorld -50 -50 50 50
Would generate from -50,-50 to 50,50 in game coordinates. Simple!
/genregion "Bob and Sam's \"Awesome\" World" -50 -50 50 50
The same command for world: Bob and Sam's "Awesome" World. Quotes can be placed around world names with spaces, world names with actual quotes in them can be escaped with backlashes.
/gencircle 1000 /fast /verbose /lighting
Would generate a 1000 block radius circle around the issuing player, using the /fast speed setting, with verbose output, with lighting!
/gencircle 1000 MyWorld 100 100 /veryslow
Would generate a 1000 block radius centered in MyWorld at 100x, 100z, using the veryslow speed setting so as not to cause lag.
/gencircle 10000 MyWorld 100 100 /allAtOnce /onlyWhenEmpty
Would generate a HEUG circle centered at MyWorld 100,100 at max possible speed, but pause the generation when players join. Useful if you want your server to use 100% on generating when it would otherwise be idle.
Notes on Lighting
By default, minecraft only generates lighting info for a chunk when it is first approached by a player. This is fine, but if you want to generate an external map with something like Minecraft Overviewer, it means the areas players haven't visited will only have 'fast' lighting, with pitch black shadows.
To fix this, by default, WorldGenerationControl forces new chunks to have lighting info, as if a player were nearby. This shouldn't cause any problems, but takes about 8% more CPU-time. You can skip this step with /lighting:none -- the chunks will still be lit when a player wanders by, so this is only an issue for external tools as mentioned above.
There is also /lighting:force, which will force-generate lighting for all chunks it passes over (even those already generated and with proper lighting), which is useful for making Minecraft recalculate the lighting in areas with glitched shadows.
Using in a Script
The /quitAfter option lets this plugin be used as part of a script. For example, some users like to generate maps for a lot of random seeds to share with the community or post on /r/minecraft for delicious karma. Because Bukkit/java freaks out when EOF is encountered in input, the proper way to do this would be something like:
echo "gencircle 1000 TestWorld 0 0 /allatonce /quitafter" | cat - /dev/full | java -jar craftbukkit-0.0.1-SNAPSHOT.jar --nojline
Download
https://github.com/downloads/Nephyrin/WorldGenerationControl/WorldGenerationControl_v2.6.jar
Source
https://github.com/Nephyrin/WorldGenerationControl
ChangeLog
-
2.6
- Updated to work with 1.0.1 / 1.1 builds.
-
2.5
- /forceKeepUp now keeps up on garbage collection as well
- Renamed /forceSave to /forceKeepUp to reflect that it also keeps up on garbage collection.
- When the server is floating at >80% memory for too long, try invoking a GC. This fixes the issue where the default Java GC options would have it float at 80% memory forever as long as nothing forced it to catch up.
- Cleaned up /verbose output a little.
- Check if we have <200Megs free in addition to <20% free, prevents out of memory errors on 512Meg ram servers (which this plugin doesn't technically support)
-
2.4
- Add /forceSave workaround for 1.9's AsyncChunkLoader silliness.
- /allAtOnce now implies /forceSave
- Make the memory limit a little more conservative to ensure we don't hit GC overhead errors on low memory servers
- Once the memory limit has been hit, wait for ram to decrease below the limit by at least 10% before resuming
- Tweak the NextTickList bug workaround - instead of flushing the list, just ensure it stays below a threshold. Should fix the minor lag spikes from the fix.
- Minor optimizations
-
2.3 - Death to Memory Issues edition
- Includes a fix for CraftBukkit's poor NextTickList handling, allowing high generation speeds on low memory servers
- Invokes the GC directly when running close to memory limits to prevent GC Overhead errors
- Takes a break if memory usage gets unacceptably high to let the server catch up.
-
2.2
- Lighting now talks directly to CraftBukkit and is now approximately 115 times faster. Yep.
- Because lighting has gone from taking up 92% of processing time to a trivial amount, the plugin no longer splits lighting/generating/saving into separate steps.
- Because lighting is now very fast, /lighting is now the default. It can still be disabled with /lighting:none
- /lighting:extreme is now named /lighting:force, and only eats a little bit more CPU.
- Added /destroyAndRegenerateArea - which regenerates all chunks in the region. Beware!
- Removed /lightExisting, lighting is now only done as-needed either way, and /lighting:force can be used to try and fix corrupt light areas.
- Fixed /gencircle being centered incorrectly when called by a player without coordinates
- Improved accuracy of some fuzzy math logic to ensure only requested areas are generated
- Added /onlyWhenEmpty - this causes the plugin to only do its work when the server is empty, pausing and resuming as needed when players join/leave.
- Minor speed/overhead improvements
-
2.1
- Fixed issue with /allAtOnce being too aggressive on lighting, causing memory issues on low-memory servers.
- allAtOnce mode now returns into the server briefly between ticks, allowing other commands (such as /cancelgen) to be run.
-
2.0
- Name changed to WorldGenerationControl from ForceGenChunks
- Large rewrite
- Supports Minecraft 1.8's lighting methods
- Added options: lighting, speed, verbose, quitafter
- Added permissions support
- Normal speed is much, much less laggy. Speed options provide control over lag during generation.
- No longer trusts server to cleanup chunks, manages process through lighting step and cleans up chunks directly. maxLoadedChunks removed as a result, even on high speed settings the plugin will never load more than 1024 chunks into memory.
- Cleaned up and improved status messages.
- Use block coordinates instead of chunk coordinates
- Support queueing multiple generations
- Better in-plugin API for other plugins to interact with this one.
- Other things I likely forgot
-
1.4
- Added progress % to generating status messages.
-
1.3
- Added support for quotes and spaces in worldnames via quotes and escape sequences.
- To generate for map: Bob's "Wonderful" Funland
- /forcegen "Bob's \"Wonderful\" Funland" -10 -10 10 10
- Fixed the "Invalid world name" error message giving the wrong world name for /forcegencircle commands.
- Separated generation and cleanup phases - plugin now prints a message when generation is complete, and a second message later when cleanup is complete.
- New generations can be started even if cleanup isn't done, the remaining cleanup will just be merged with the new task's cleanup.
- Removed warnings about players being in the world, with above changes there is no harm in them being there.
- Added some colors to plugin messages. Pretty.
- Plugin messages now show who did what.
- Tested with recommended builds 1000 and 1060.
-
1.2
- Added /forcegencircle
- Players who use the command now see the progress, not just the 'generation started' message.
- A few minor text tweaks.
-
1.1
- Wait for chunks to unload, instead of assuming our unload requests succeed. Fixes a 'leak' of loaded chunks in large generations, chunks that never unload until a reboot.
- Add a optional maxLoadedChunks argument to /forcegen, setting this higher reduces the time spent waiting for old chunks to unload, but causes more chunks to reside in ram, increasing memory usage.
- Added /cancelforcegen, to cancel generation in progress.
-
1.0
- Release
I consider this plugin essential for server management, but have had the same problems with lighting glitches that other people have been reporting. At an earlier point, I was using LightFixer to force lighting to be calculated correctly, but that plugin no longer works, and the author won't update it for a while, if at all.
NoLagg's automatic lighting solution (applied on chunk generation) doesn't work alongside this plugin, no matter what settings I generate terrain with. I'm not sure it even works with player-generated terrain. The "/lag fix" command does work, but only on loaded chunks. I haven't been able to use MCEdit to recalculate lighting on large maps.
Beside being ugly, the dark shadows are causing Orebfuscator to visibly affect stone blocks on the surface of the world. I'm not sure what my options are, or what I can do to fix the lighting calculation for good, or all at once on pre-generated terrain, but if anyone could offer me advice, I'd be grateful.
@WayGroovy
whoa... fancy seeing you here... in my expeerience the answer is if its a destructive gen then no it will gen exactly to your specifications each time. however a normal generation will only generate ungenerated land
Out of curiosity, does WGC know what it's already rendered?
For example, If I were to perform "/gencircle 10000 MyWorld 100 100 /slow", the the server crashes into the render, and I restart at a later time with the same command "/gencircle 10000 MyWorld 100 100 /slow" does it start rendering again at the far north, checking each chunks existence? The plugin seems to take a long time to restart If I were to do this. Same if I start a new circle with a larger radius, for example "/gencircle 4000 MyWorld 100 100 /slow", then subsequently "/gencircle 5000 MyWorld 100 100 /slow".
Finally, is there any way to direct the plugin to generate from the center out, instead of from north to south?
Thanks for the plugin, works great as described.
@Nephyrin
Looks like it wasn't your plugin after all... The checkerboard generation problem is finally getting some attention as a CB issue:
https://bukkit.atlassian.net/browse/BUKKIT-2306
Thank you. You are amazing! Not planning to go crazy, but I am trying to test some other plugins as well, and it works better with a large map. Running around to load it just to destroy it a half dozen times is getting old.... When we get them all working though, I love to set up a good big map (I went with a radius of 10k for my last server) for my players.
EDIT: Wow! It is working amazingly well! I have been able to set up several maps and just about have everything working again. Cheers!
@Springfield45
I've compiled a version of the git rev 3dcd00d69cf6 here: http://nemu.pointysoftware.net/sink/WorldGenerationControl_2.7pre.jar
However /lighting is still partially broken, and /destroyAndRegenerateArea is untested and I believe has a remaining grid-bug, so I'm not sure its a great idea to go crazy with this just yet.
I love this plugin and used it with my 1.2x servers, but I am afraid that I know nothing about java to use the source code. Could you package a snapshot of your current source for us to test with 1.3?
@realcube
If that chest bug is actually only occuring with land generated by this plugin, it's probably a bukkit bug. This plugin ultimately just calls loadChunk() to cause chunks to be loaded, which is a bukkit API call, so it should not affect that.
The github repo has some fixes for 1.3.1, including fixing /destroyAndRegenerateArea, but doesn't fully fix /lighting (partially, though!)
I'm guessing you'll probably have to wait for 1.4 and the new plugin API for me to properly fix everything though
Great plug-in. In you post (Aug 8 2012) you confirmed some problems with 1.3.1 Do you plan a new release that will fix this or any new release at all?
One other funny thing with you plugin: when I go to a desert temple the content of the chests are different from the bukkit default. I can reproduce this. It's alway the same (but different from bukkit default) content.
@bgernert
It's possible /lighting was broken by 1.3, as the notice up top says this hasn't been officially tested there. I'll take a look later today (the lighting stuff is obfuscated craftbukkit calls, so This is probably the problem)
Hi,
I am using this plugin to generate a 3000 radius for my 1.3.1 world. The chunks are generated successfully but if I render my map with Overviewer, I can see lots of lighting errors (way too dark shadows under cliffs, trees, etc.). I tried to fix this with the /lighting:force option but the error still occurs. Any suggestions?
@Nephyrin
Hey! Just thought I would give you an update on my situation. I found the problem to be a conflict in NoLagg. Once I removed the NoLagg plugin I found that WorldGenerationControl ran at a pretty constant 9-10% while generating my 1.3.1 terrain. Woo hoo!
Generated a 3500 radius circle world with 1.3.1 craftbukkit dev, no issues so far...
...in addition.
I just noticed something really weird. I had forgotten that I had Dynmap doing a full render of my world and did a chunk generation at the same time. The odd thing about that is the memory seemed to bounce around and not climb as fast as it did before. So, instead of a 500 chunk gen taking 40% of my memory away it only took half of that. I dunno why that would be, but maybe that strange incident means more to you on a programming end than it does to me.
But again, that chunk generation had ended with the memory at 43.67% and the next one started 3 minutes later at 42.77% memory usage and it's climbing. I'm thinking Bukkit memory hole, but I dunno for sure.
@Nephyrin
You're more than likely right that it's some kind of bug in Bukkit. I love your plugin, so I'm definitely not saying anything against it. I just noticed this weird problem. The other plugins I have installed are;
They're all the latest (non-dev) versions, and I've used them before with WorldGenerationControl without any issues. As for the system it's running on, the CPU is pretty shitty but it's running enough RAM.
The issue is fairly strange in that you can literally watch the memory usage. One generation will stop at like 17.3% memory usage and when I start the next one (not immediately) it will start at exactly 17.3% and climb. I've even tried using a memory manager (MemTurbo) to clear memory between the generations, but it doesn't help at all. The only thing that fixes it is restarting Bukkit. Which runs at a pretty constant 12% memory usage when I'm not running a world generation.
I think your right that it's a Bukkit issue, but just in case it wasn't I figured I should let you know. At the moment I'm doing 800 radius areas and restarting the server after every completed world generation.
@ViperZeroOne
I fear what you're seeing is either a bug in bukkit, or a bug in another plugin you have loaded.
I have successfully generated over 10,000 radius areas in one go with this plugin, on a server with 1Gig of ram. A good chunk of the plugin's code is basically dedicated to making sure it *doesn't* go OOM - when I wrote this, the only other plugin that did this just blindly called loadChunk() until the server crashed, so it was useless for large generations. It's the entire point of this plugin!
That said, there have been numerous issues with bukkit builds with memory leaks (/forcekeepup is a hack to work around an old bukkit memory leak), and other plugins that have chunk-load hooks that misbehave. I can take a look at the build you're using and see what's up, but last three pull requests I sent to CraftBukkit have been ignored, so I'm not sure I can really fix anything on their end :-P
I love this plugin as, for my little under powered server, it saves me major lag from users running around loading chunks all on their own. My only issue with the plugin is that it doesn't seem to free the memory it's used to chunk generate. The memory usage just climbs and climbs while it generates away. I realize that some of the chunks have to stay in memory until they're saved, but when you generate a radius of 1000 there should be no reason why that first chunk is still in memory when you get to 60% complete. I never see a decrease in the memory used, it just keeps climbing until it "runs out" and has to wait. Even using the /forcekeepup and /veryslow options don't help with this memory hogging. When generating 1000 radius I always run out of memory at the same place, around 65% to 70%.
My Bukkit is release #2291 version 1.3.1-R0.1
EDIT: I've confirmed the memory hole that I thought existed. I ran a 500 block generation which took the memory usage (reported by WorldGen) up to 46%. I then waited about 10 minutes, because I was busy making supper, and then started another 500 block generation and the memory usage STARTED at 46% and climbed to 73% before stating that it ran out of memory. This plugin isn't clearing the memory when it's done generating. The only way I can get the memory freed is by actually stopping the server and starting it back up again. I fully admit this could be due to using an unsupported Bukkit version, but it seems like a pretty big problem considering everything else seems to work fine.
Does it work with the 1.3 version ?
@NichBot
The 'cancelgen' command will stop the current generation. Restarting the server will obviously stop anything a plugin is doing. Unloading the plugin will also work...
How do i quit it? i tried deleting the file from the plugin folder... but when i start the server it still continues to generate the world, i did /regencircle 10000 /verbose /fast /light its been 3-4hours now with a 2.4GHz dual core and its only 5% done. I want to QUIT IT!!