Tuesday, 19 May 2020

Minecraft By Example

In parallel with this blog, I created a tutorial project MinecraftByExample.
The purpose of MinecraftByExample is to give simple working examples of the important concepts in Minecraft and Forge. If you're anything like me, a good code example is worth several screens of waffling explanation, and can very quickly explain the key concepts. I also find it much easier to adapt and debug something that already works, than to have to synthesize something from scratch and spend hours trying to discover the missing bit of information I didn't know about.
Each example is split up to be totally independent of all the others. The only part of the code which is common to more than one example is the MinecraftByExample class.
The topics covered are:


  • MBE02 - a block with a more complicated shape

  • MBE03 - two types of blocks which vary their appearance / shape:
a block (coloured signpost) with multiple variants- four colours, can be placed facing in four directions

a block (3D Web) with multiple parts (multipart) similar to a vanilla fence.

  • MBE04 - dynamically created block models
    a camouflage ("secret door") block which dynamically changes its appearance to match adjacent blocks - uses IBlockModel.getQuads(), ModelBakeEvent, IForgeBakedModel and IModelData

an "altimeter" block which shows the block altitude (y coordinate) on the side in digital display - as camouflage block but uses programmatic generation of quads 

  • MBE05 - multilayer block (lantern block with transparent glass) with animated flame texture

  • MBE06 - several different types of block which use redstone

  • MBE08 - how to add a creative tab for organising your custom blocks / items


  • MBE11 - an item with multiple variants - rendered using multiple models and multiple layers

  • MBE12 - an item that stores extra information in NBT, also illustrates the "in use" animation similar to drawing a bow

  • X MBE13 - customise Mining behaviour of Blocks and Items - several test classes that show how mining works

  • MBE15 - a chessboard item with 1 - 64 pieces; uses ItemOverrideList.getModelWithOverrides(), IBlockModel.getQuads() and onModelBakeEvent()


  • MBE20 - using a tile entity to store information about a block - also shows examples of using NBT storage

  • MBE21 - using the TileEntityRenderer to render unusual shapes or animations

Containers (Inventories)

  • MBE30 - a simple container for storing items in the world - similar to a Chest

  • MBE31 - a functional container such as a Furnace or Crafting Table

  • MBE32 an item (bag of flowers) which can store other items inside it.  Also shows how to use Capability.

Recipes (Crafting/Furnace)

  • MBE35 - some typical example crafting recipes and furnace (smelting) recipes


  • MBE45 - custom commands

Particles - particle effects

  • MBE50 - shows how to use vanilla Particles; also how to generate your own custom Particles


  • MBE60 - send network messages between client and server


  • MBE65 - Adding a capability to objects (A Capability is a way to attach information and behaviours to minecraft objects) 

Testing tools

  • MBE75 - a tool to help you automate testing of your classes in-game.

Entities and Models

  • MBE80 - Shows the basics of Models (eg PigModel), model parameters adjustable in real time using commands

  • MBE81 - Two examples of projectile entities: a) a simple thrown projectile similar to a snowball; b) a boomerang- which follows a more-complicated flight path


  1. Great work but the X MBE40 Heads Up Display link can't be reached for some reason

    1. Ah, that's because I haven't converted that example. I'll remove the link...

  2. can u make a MBE for sounds?

  3. OK will do; hopefully in the next few weeks over the holidays..

  4. Been looking for basic block/item/etc. modding examples and I've finally struck gold. You're a hero and a scholar.

  5. Dang, this is super useful stuff! Thanks

  6. Wow, how much efforts did you give to write this article... I really appreciate your efforts. Nice post, very informative.. Minecraft is one of the most popular games in the world, and no matter whether you are just starting out or are an experienced player, modifications are an essential part of the experience. OptiFine is one of the most popular mods available, with millions of players around the world using it. However, how much do you know about Minecraft OptiFine
    Minecraft Server List