Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm making a multiple item, and i managed to set different icons for it, but i'm stuck at names... Here's the code.

package net.railowar.src;

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class ItemWideRails extends Item
{
    public static final String[] wNames = new String[] {"Straight", "Right", "Left", "S", "Z"};
    public static final String[] wTex = new String[] {"rails", "rails_r", "rails_l", "rails_s", "rails_z"};
    @SideOnly(Side.CLIENT)
    private Icon[] ico;
    
    public ItemWideRails(int par1)
    {
        super(par1);
        this.setHasSubtypes(true);
        this.setMaxDamage(0);
        this.maxStackSize = 1;
        setCreativeTab(CreativeTabs.tabTransport);
        setUnlocalizedName("Rails");
    }
    
    @SideOnly(Side.CLIENT)
    public Icon getIconFromDamage(int par1)
    {
        int j = MathHelper.clamp_int(par1, 0, 4);
        return this.ico[j];
    }

    public String getUnlocalizedName(ItemStack par1ItemStack)
    {
        int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 4);
        return super.getUnlocalizedName() + "." + wNames[i];
    }

@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
        for (int j = 0; j < 5; ++j)
        {
            par3List.add(new ItemStack(par1, 1, j));
        }
    }

    @SideOnly(Side.CLIENT)
    public void updateIcons(IconRegister par1IconRegister)
    {
        this.ico = new Icon[wTex.length];
        for (int i = 0; i < wTex.length; ++i)
        {
            this.ico[i] = par1IconRegister.registerIcon("RoW:" + wTex[i]);
        }
    }
}

Please, help.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

So, no ideas?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

In your item constructor, put:

 

LanguageRegistry.addName(this, "Your Item Name Here");

 

EDIT: Ah, wait, I missed a word - let me get back to you on this.

 

EDIT 2: Check this out - it looks like you need to pass in the names one at a time while also passing in an ItemStack with the desired damage value:

http://www.minecraftforge.net/wiki/Metadata_Based_Subblocks#Block_and_Language_Registration

  • Author

Thanks, that helped.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.