Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

MinecraftByExample

> 编程语言
Open source

Working sample code for the basic concepts in Minecraft and Forge.

1.3K stars0 likes0 views
WebsiteGitHub

About

Working sample code for the basic concepts in Minecraft and Forge.

MinecraftByExample [1.16.4]

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.

I've tried to keep the code simple and obvious and to resist the urge to be clever. The examples might not be the most efficient or succinct implementation, I've deliberately left the optimization to you.

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.

If you want more information and explanatory text about the concepts, the following links might be useful:

  • The Official Forge documentation (parts of it are rather outdated but on the whole still very useful starting reference)
  • Guide to how Minecraft works (explaining the key concepts for understanding vanilla code)
  • Fabric Wiki (some of it is specific to the Fabric API, but a lot of useful general info too)
  • Forge modder support forum ask for advice from the experts
  • McJty tutorials lots of step-by-step instructions / tutorial
  • Mr Crayfish Furniture Mod (lots of examples)
  • Cadiboo's example mod some great tutorials for when you're starting out

For earlier versions, see the relevant GitHub branch:

  • MBE for Forge 1.8: 1-8final
  • MBE for Forge 1.8.9: 1-8-9final
  • MBE for Forge 1.10.2: 1-10-2final
  • MBE for Forge 1.11: 1-11final
  • MBE for Forge 1.11.2: 1-11-2final
  • MBE for Forge 1.12.2: 1-12-2final
  • MBE for Forge 1.14.4: 1-14-4partial (partially updated only)
  • MBE for Forge 1.15.2: 1-15-2
  • MBE for Forge 1.16.3: 1-16-3

If you are updating from previous forge versions, you will probably find this link and this link very helpful. For better or for worse, MCP decided to rename a very large number of classes (eg all Blocks Blockxxx --> xxxxBlock, etc) so this might save you a stack of time. If you use IntelliJ, you might find these xml mapping files useful too

List of examples

See here for pictures of what each example looks like in-game.

Blocks

  • MBE01 - a simple cube

  • 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

Items

  • MBE10 - a simple item
  • 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
  • MBE15 - a chessboard item with 1 - 64 pieces; uses ItemOverrideList.getModelWithOverrides(), IBlockModel.getQuads() and onModelBakeEvent()

TileEntities

  • 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

Commands

  • MBE45 - custom commands

Particles - particle effects

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

Network

  • MBE60 - send network messages between client and server

Capabilities

  • MBE65 - define new Capabilities and attach them to vanilla 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 - Projectile Entities (eg snowballs, arrows)

Miscellaneous Debugging Tools

  • DebuggingTools- This package is a bunch of functions and tools that I use occasionally, mostly for debugging

Usage

  • You can browse directly in GitHub, or alternatively, download it as a zip and browse it locally.

  • If you want to install it and compile it, the basic steps for beginners are:

    1. Download the project as a zip.
    2. Unzip it to an appropriate folder on your computer, such as My Documents. (Or, if you know how to fork a project on GitHub and import it into a local git repository, you can do that instead)
    3. Look at Forge's README.txt file in this folder and follow the instructions to import it into Eclipse or IntelliJ IDEA.
    4. Use the gradle task runClient to run or debug the project.

How to compile and run:

  1. Execute gradle task runClient to test the client installation or
  2. Execute gradle task runServer to test the dedicated server installation. (The first time you run this task it will exit without starting the server. You then need to edit the eula.txt file in the run directory, and execute runServer again.)

If You're Still Confused

Head over here if this didn't make sense to you (check comments for differences with latest versions of IDEA).

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •[The Official Forge documentation][forgedocs] (parts of it are rather outdated but on the whole still very useful starting reference)
  • •[Guide to how Minecraft works][greyminecraftcoder] (explaining the key concepts for understanding vanilla code)
  • •[Fabric Wiki][fabricwiki] (some of it is specific to the Fabric API, but a lot of useful general info too)
  • •[Forge modder support forum][Forge forum] ask for advice from the experts
  • •[McJty tutorials][McJty] lots of step-by-step instructions / tutorial
  • •Mr Crayfish Furniture Mod (lots of examples)
  • •Cadiboo's example mod some great tutorials for when you're starting out
  • •MBE for Forge 1.8: [1-8final][version1-8]
  • •MBE for Forge 1.8.9: [1-8-9final][version1-8-9]
  • •MBE for Forge 1.10.2: [1-10-2final][version1-10-2]

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言