How would I add an Item to Minecraft with mcp-reborn?

Solution 1:

This is how I would do this. This is not the only way. Make sure to replace all the placeholders (boring mod and boring item) with whatever you want.

Create a class something like this:

package me.mcblueparrot.mods.wow;

import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;

public class BoringMod {

    public static final BoringMod INSTANCE = new BoringMod();
    public static final String NAMESPACE = "boringmod";

    public void bootstrap() {
        Registry.register(Registry.ITEM, locationOf("boringitem") /* boringmod:boringitem */, new Item(new Item.Properties()
                .tab(CreativeModeTab.TAB_MATERIALS /* whatever tab you want */)));
    }

    private ResourceLocation locationOf(String path) {
        return new ResourceLocation(NAMESPACE, path);
    }

}

In net.minecraft.client.main.Main, add this:

BoringMod.INSTANCE.bootstrap();

after this (line 141)

CrashReport.preload();
Bootstrap.bootStrap();

In net.minecraft.client.resources, change this:

super(p_174827_, "minecraft", "realms");

to

super(p_174827_, "minecraft", "realms", "boringmod");

Move your texture to "src/main/resources/assets/boringmod/textures/item/boringitem.png".

Create a new file in "src/main/resources/assets/boringmod/models/item/boringitem.json". The contents should look something like this:

{
  "parent": "minecraft:item/generated",
  "textures": {
    "layer0": "boringmod:item/boringitem"
  }
}

Create another file at "src/main/resources/assets/boringmod/lang/en_us.json":

{
  "item.boringmod.boringitem": "Boring Item"
}

Make sure to refresh the project if you are in Eclipse IDE.

When you start the game there should be a new item in the game (scroll down in the creative inventory).

Good luck modding! In future I would recommend a mod loader, or a patching system that makes updates and distribution easier.

Item in action