Friday 27 December 2013

Forge - World generation, loading, saving

Registries for World generation, loading, saving

The registries involved in world generation are:
  • Dimension: DimensionManager.registerProviderType (in conjunction with WorldProvider) can be used to add new dimensions in addition to the Overworld, Ender, and Nether.
  • Terrain generation: GameRegistry.registerWorldGenerator(IWorldGenerator) – allows you to register an IWorldGenerator to generate new chunks as they are required.
  • Villages: VillageRegistry contains several methods to alter the random generation of village components (huts, farms, etc).
  • Biomes: There are a bunch of registries relating to Biomes that to be honest I don’t properly understand.  If you are interested, these are
    * GameRegistry.addBiome(BiomeGenBase).
    * BiomeManager.addSpawnBiome allows the new Biome to be used during random world generation,  .addStrongholdBiome and .addVillageBiome are used to control whether Strongholds and Villages will randomly spawn in this biome.
    * BiomeDictionary – types of Biomes (HILLS, PLAINS, etc)
  • Loot Chests: ChestGenHooks is used to create new types of random loot chests (DUNGEON_CHEST, VILLAGE_BLACKSMITH, etc).
  • Mob spawners: DungeonHooks addDungeonMob will let you add new mobs to the vanilla spawner.

New methods and classes

  • WorldProvider- has been modified to  allow player to override many methods related to a custom world they have made
  • IRenderHandler has been added to WorldProvider – it can be used by mods to perform a custom render of the sky or the clouds – setSkyRenderer() and setCloudRenderer(). 
  • Although Forge has added a rather tempting setAdditionalProperties() method to WorldInfo, the way it has been coded means it’s not actually useful for mods to use when storing permanent data about a world.    Use world.perWorldStorage instead (used by vanilla for villages, but can be hijacked for your own purposes relatively easily).

Events         

  • TickRegistry.registerTickHandler for WORLD ticks (every world update)
  • TickRegistry.registerTickHandler for WORLDLOAD event (when world is loaded)
  • WorldEvent.Load, .Unload, .Save

There’s an impressive pile of events related to world generation, biomes, loading and saving of chunks.  I don’t understand most of them so I’ll leave that for a later time.  Perhaps.



~Overview of Forge (and what it can do for you)
    Forge concepts
           Some general notes
           How Forge starts up your code (@Mod, @SidedProxy, etc)  
           Registering your classes
           Extra methods for vanilla base classes
           Events
     Forge summary - grouped by task
           Blocks
           Items
           TileEntities
           Entities
           World generation, loading, saving
           Miscellaneous - player input, rendering, GUI, chat, sounds

3 comments:

  1. I just discovered your blog and it has been wonderful for helping me to understand the game and add my own code. Thank you very much

    ReplyDelete
  2. Hi, I'm a developer of Minecraft-like game from Belarus. The articles you've posted is very interesting and usefull, thanks a lot for your job!

    ReplyDelete
  3. Thank you for this blog. Learning Java is not difficult for me, but finding good information on how all the classes interact with each other can be elusive at times.

    ReplyDelete