Minecraft Modding (Fabric/Java) Cheat Sheet
A one-page printable reference for project structure, registering items & blocks, textures, custom mobs, loot tables and Fabric API events. Pin it next to your monitor!
A one-page printable reference for project structure, registering items & blocks, textures, custom mobs, loot tables and Fabric API events. Pin it next to your monitor!
| fabric.mod.json | Mod metadata, ID, entrypoints, dependencies |
| Main mod class | Implements ModInitializer, runs onInitialize() |
| src/main/java/ | All your Java source code |
| src/main/resources/ | Assets, data, and the mod.json |
| assets/modid/ | Textures, models, lang files |
| data/modid/ | Recipes, loot tables, tags |
public class ModItems { public static final Item RUBY = Registry.register( Registries.ITEM, new Identifier("mymod", "ruby"), new Item(new Item.Settings()) ); public static void registerItems() { // called from onInitialize() } }
Every registered item needs a unique Identifier namespace + path.
public static final Block RUBY_BLOCK = Registry.register( Registries.BLOCK, new Identifier("mymod", "ruby_block"), new Block(AbstractBlock.Settings.create() .strength(4.0f) .requiresTool()) ); // give the block an item form so it appears in the inventory Registry.register( Registries.ITEM, new Identifier("mymod", "ruby_block"), new BlockItem(RUBY_BLOCK, new Item.Settings()) );
| Item texture | assets/modid/textures/item/name.png |
| Block texture | assets/modid/textures/block/name.png |
| Blockstate JSON | assets/modid/blockstates/name.json maps states to models |
| Item model JSON | assets/modid/models/item/name.json |
| Block model JSON | assets/modid/models/block/name.json |
| Lang file | assets/modid/lang/en_us.json for display names |
public class RubyGolemEntity extends HostileEntity { public RubyGolemEntity(EntityType extends HostileEntity> type, World world) { super(type, world); } } // register the entity type public static final EntityTypeRUBY_GOLEM = Registry.register( Registries.ENTITY_TYPE, new Identifier("mymod", "ruby_golem"), EntityType.Builder.create(RubyGolemEntity::new, SpawnGroup.MONSTER) .dimensions(0.9f, 2.2f) .build() );
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "mymod:ruby"
}
],
"conditions": [
{ "condition": "minecraft:survives_explosion" }
]
}
]
}
Save under data/modid/loot_tables/blocks/name.json.
// listen for block break PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { if (!world.isClient) { player.sendMessage(Text.of("Block broken!"), true); } }); // listen for server tick ServerTickEvents.END_SERVER_TICK.register(server -> { // runs once per tick on the server });
Fabric API events use a static .register() call inside onInitialize().
// ModItems.java public class ModItems { public static final Item RUBY = registerItem("ruby", new Item(new Item.Settings())); private static Item registerItem(String name, Item item) { return Registry.register(Registries.ITEM, new Identifier("mymod", name), item); } public static void registerModItems() { // add the item to the Ingredients creative tab ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS) .register(entries -> entries.add(RUBY)); } } // MyMod.java entrypoint public class MyMod implements ModInitializer { public static final String MOD_ID = "mymod"; @Override public void onInitialize() { ModItems.registerModItems(); } } // assets/mymod/models/item/ruby.json { "parent": "minecraft:item/generated", "textures": { "layer0": "mymod:item/ruby" } } // assets/mymod/lang/en_us.json { "item.mymod.ruby": "Ruby" }
Follow one of our free step-by-step workshops in the Workshop hub.
๐ง Browse Workshops โ