2

I am learning how to mod Minecraft, so I have very little experience with this yet (I have already made some resource packs). I am using MCP Reborn but I'm open to better suggestions. I have already decompiled and have been messing around with this for a couple of months but to no avail. I have already created the textures for this item.
Could someone please help me with this? (Minecraft Java Edition 1.17.1) (note: I do not want my mod to be dependent on other programs like forge.)

1
  • I know how to do this. I am just setting up an MCP environment.
    – MrParrot
    Jan 4 at 17:11

2 Answers 2

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.DefaultClientPackResources, 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

23
  • Where would I create the class? Jan 4 at 18:03
  • In whatever package you wish to. I would recommend me.yourname.mymodname.
    – MrParrot
    Jan 4 at 18:04
  • I am completely new to this so I don't know what a "package" is (sorry im such a newb) Jan 4 at 18:05
  • What IDE are you using?
    – MrParrot
    Jan 4 at 18:06
  • Eclipse IDE ||| Jan 4 at 18:08
-1

Given you are open to other suggestions I would recommend MCreator. It is very simple to get going and integrates well into the game itself and makes the workflow very simple.

6
  • I will look into this, but I still want to know how to do this with the hard-coding method, just in case anything goes wrong. Jan 3 at 23:57
  • I do not want to create mods depending on forge. I would like to make my own free-standing mod. Jan 4 at 12:34
  • I downvoted this, as it doesn't answer the question. This would fit better as a comment. I wouldn't recommend MCreator, as you learn skills that will be applicable outside of Minecraft if you code a mod in Java. Despite this, MCreator is surprisingly capable, and there have been many high quality mods made with it.
    – MrParrot
    Jan 4 at 17:12
  • I most definitely agree, as I like to get my hands dirty hard-coding things. Jan 4 at 18:05
  • An edit was made to the question ("not depending on other things") after I posted this answer. My answer was relevant before that.
    – Halesy
    Jan 5 at 9:47

Not the answer you're looking for? Browse other questions tagged .