====== OnChunkGenerated hook callback function ======
This callback function is called when world generator finished its work on chunk. The chunk data has already been generated and is about to be stored in the world. A plugin may provide some last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the world, so regular [[API:cWorld|cWorld block API]] will not work! Instead, use the provided [[API:cChunkDesc|cChunkDesc]] object.

===== Function signature =====
<code lua>
function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
</code>
Parameters:
| World | cWorld | The world to which the chunk belongs |
| ChunkX | number | X-coord of the chunk |
| ChunkZ | number | Z-coord of the chunk |
| ChunkDesc | [[API:cChunkDesc|cChunkDesc]] | Generated chunk data. Plugins may still modify the chunk data contained. |

===== Return Values =====
If the plugin returns false or no value, MCServer will call other plugins' callbacks for this event. If a plugin returns true, no other callback is called for this event.

In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world.

===== Register Callback =====
To register your plugin to receive a callback through this function, use the hook [[api:plugin:hooks | HOOK_CHUNK_GENERATED]]
<code lua>
PluginManager = cPluginManager:GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED)
</code>