Hello Minecraft!
Your First Custom Item
Install your mod tools, set up a Fabric project and add a brand-new Crystal Gem item to Minecraft. You'll hold it in your hand by the end!
Install your mod tools, set up a Fabric project and add a brand-new Crystal Gem item to Minecraft. You'll hold it in your hand by the end!
Get Java JDK 21 installed so your computer can run and compile Java code.
java version and press Enter.openjdk version "21.0.x". If you do, Java is ready!java version shows version 21 in the terminalInstall IntelliJ IDEA Community Edition it's the best free editor for Java modding.
Download the Fabric Example Mod template it gives you a complete working mod structure to start from.
fabric-example-mod-main to CrystalMod. This is your mod's project folder!Open the CrystalMod project in IntelliJ and wait for Gradle to download all the Minecraft files it needs.
gradle.org and services.gradle.org.Rename the mod to CrystalMod and update fabric.mod.json with your mod's details.
"YourNameHere" to your actual name!Set up CrystalMod.java the class Fabric calls when your mod loads into the game.
CrystalMod.java is the blueprint for our whole mod it's the first thing that runs when Minecraft loads it.ModItems shows red we haven't made that file yet! We'll fix that in the next step.Create a new Java class called ModItems and use it to register a Crystal Gem item with Minecraft.
CRYSTAL_GEM creates the item object with default settingsregisterItem() tells Minecraft "this item exists and its ID is crystalmod:crystal_gem"registerModItems() adds the gem to the Ingredients creative tab so you can find itModItems in CrystalMod.java should disappear now.package com.example.crystalmod;. (2) They forget to call ModItems.registerModItems() in CrystalMod.java, so the item never appears in-game even though it compiles fine.com.example.crystalmod package (same folder as CrystalMod.java). Check the very first line says package com.example.crystalmod;.ModItems.registerModItems(); inside onInitialize().net.minecraft.registry.Registry and net.minecraft.registry.Registries.net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents.Create a PNG texture and a model JSON file so your Crystal Gem has a proper appearance in Minecraft.
crystalmod → inside it textures → inside that item.crystalmod create: models → inside that item.crystalmod create a folder called lang.assets/crystalmod/textures/item/ folder you just created.models/item folder → New → File. Name it crystal_gem.json. Paste this inside:lang folder → New → File. Name it en_us.json. Paste this:Launch Minecraft from IntelliJ using the Fabric run configuration and find your Crystal Gem in the creative inventory.
Crystal Mod loaded! 💎 in the log that's your LOGGER message!/give @p crystalmod:crystal_gem and press Enter.Add a Crystal Dust item or any item you invent using the same pattern you just learned.
crystal_dust (or anything you like!).public static final Item CRYSTAL_DUST = registerItem("crystal_dust", new Item(new Item.Settings()));registerModItems(), add: entries.add(CRYSTAL_DUST);models/item folder (same as crystal_gem.json, just change the texture path).textures/item/."item.crystalmod.crystal_dust": "Crystal Dust" to your en_us.json.