โœฆ JVDesignStudio ยท No Sign-Up Required

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!

๐Ÿ—‚๏ธ Project Structure

fabric.mod.jsonMod metadata, ID, entrypoints, dependencies
Main mod classImplements 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

๐ŸŽ Registering an Item

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.

๐Ÿงฑ Registering a Block

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())
);

๐Ÿ–ผ๏ธ Textures & Models

Item textureassets/modid/textures/item/name.png
Block textureassets/modid/textures/block/name.png
Blockstate JSONassets/modid/blockstates/name.json maps states to models
Item model JSONassets/modid/models/item/name.json
Block model JSONassets/modid/models/block/name.json
Lang fileassets/modid/lang/en_us.json for display names

๐Ÿฒ Custom Mobs

public class RubyGolemEntity extends HostileEntity {
    public RubyGolemEntity(EntityTypeextends HostileEntity> type, World world) {
        super(type, world);
    }
}

// register the entity type
public static final EntityType RUBY_GOLEM =
    Registry.register(
        Registries.ENTITY_TYPE,
        new Identifier("mymod", "ruby_golem"),
        EntityType.Builder.create(RubyGolemEntity::new, SpawnGroup.MONSTER)
            .dimensions(0.9f, 2.2f)
            .build()
    );

๐ŸŽ Loot Tables

{
  "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.

๐Ÿ“ก Events

// 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().

๐Ÿ› ๏ธ Common Patterns Minimal Item from Start to Finish

// 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" }

Want to build a whole game?

Follow one of our free step-by-step workshops in the Workshop hub.

๐Ÿ”ง Browse Workshops โ†’