Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Forging a Minecraft mod

Basic Minecraft modding with Minecraft Forge

Different names for block subtypes

  • 2013-08-21 00:52:52
    I know that for items, when we want to give different names to the subtypes, we loop through each type like this:

    for (int i = 0; i < ItemInfo.CARD_NAMES.length; i++) {
    LanguageRegistry.addName(new ItemStack(card, 1, i), ItemInfo.CARD_NAMES[i]);

    But when I tried doing this for blocks, it didn't work, and I'm guessing it's because I can't use ItemStacks for blocks. So how would I do this for blocks?
  • 2013-08-21 02:40:03
    Well, now when I tried doing it, it set the name of all of the subtypes to the name of the last subtype. I'm kind of confused now.

    public static void addNames() {
            for (int i = 0; i < BlockInfo.Box_Names.length; i++) {
                LanguageRegistry.addName(new ItemStack(box, 1, i), BlockInfo.Box_Names[i]);

    Block Names:
    public static final String[] Box_Names = {"Red Box", "Green Box", "Blue Box"};
  • 2013-08-21 06:16:03
    Are you doing this to block itself or its ItemBlock?
  • 2013-08-21 07:09:32
    you need to create an ItemBlock and then give it different names. its the name of the ItemBlock that you will be looking at no matter what.
  • 2013-08-21 08:15:11
    you override getItemDisplayName(ItemStack) in your itemblock class and return the names.

    public String getItemDisplayName(ItemStack itemstack){
        return BlockInfo.Box_Names[itemstack.getItemDamage()];
  • 2013-08-21 14:00:21
    Okay, thanks!
  • Log in or sign up to reply to this thread