An overview of the Forge code related to Blocks.
- GameRegistry.registerBlock to register your block and (optionally) associate it with an ItemBlock. If you don’t provide an ItemBlock, it will make a default one itself and register it for you. If you provide an ItemBlock, you don’t need to register the ItemBlock yourself separately. GameRegistry.findBlock can be used to retrieve the block corresponding to a given name.
- RenderingRegistry.registerBlockHandler (in conjunction with an ISimpleBlockRenderingHandler class). RenderingRegistry uses a unique renderID, returned by the class’s getRenderType, to find the renderer with the matching .getRenderID() method. RenderingRegistry.getNextAvailableRenderId() is useful for getting a unique ID for the linked classes to share. See here for more information.
- MinecraftForge.addGrassPlant (and .addGrassSeed for the corresponding Item) are used to add new types of grass.
- MinecraftForge has a several methods used to add new tools and control their effectiveness against different blocks, in particular setToolClass and setBlockHarvestLevel.
- LanguageRegistry.addNameForObject – allows you to add a displayed name for your Blocks. Apparently it’s better to use a Language Pack instead of this registry. I haven’t tried those yet so I don’t know.
- ChestGenHooks is used to control the spawning of loot chests during world generation. See the World generation section.
- RotationHelper: a couple of functions to help rotate vanilla blocks to face the desired direction (eg piston, doors, etc), convert from block’s metadata to a standard “direction value”.
New methods and classes
- Block has many methods added to let mods change behaviour more easily – ladder, fire, tileentities, beds, harvesting, leaves interaction, explosion interaction, plant interactions, redstone, and a few more. They are defined after the comment in the Block code
/*===========Forge Start ========*/.
- IPlantable interface for plants
- IShearable interface for blocks which can be “shorn” by shears – eg like tallgrass or vines
- Fluids: A variety of classes to let you define your own fluids (like lava and water) and control their behaviour; comprised of BlockFluidBase, BlockFluidClassic, Fluid and FluidStack.
- BreakEvent – when a block is broken
- DrawBlockHighlightEvent – draw the highlight box around the block when your cursor is pointing at it
- PlayerInteractEvent – among other things - when a player left-clicks a block
- HarvestDropsEvent – when a block is harvested
- HarvestCheck – can the player break this block with this tool?
- BreakSpeed – speed of breaking this block with this tool
- BonemealEvent – when bonemeal is used on a plant
- Various FluidEvents related to the Forge Fluids classes
~Overview of Forge (and what it can do for you)
Some general notes
How Forge starts up your code (@Mod, @SidedProxy, etc)
Registering your classes
Extra methods for vanilla base classes
Forge summary - grouped by task
World generation, loading, saving
Miscellaneous - player input, rendering, GUI, chat, sounds