Posted July 17, 201312 yr I have a block with four subblocks including itself. The first two have their appropriate names, the last two have the same name. I tested adding a fifth sub block, and its name was the same as the other two as well. Here are the snippets of interest: In the Block.class: private Icon[] icons; ... public void registerIcons(IconRegister iconRegister) { blockTextures = new Icon[4]; //Change this according to how many blocks there are for (int i = 0; i < blockTextures.length; i++) { this.setUnlocalizedName("XailiteBlock|" + i); blockTextures[i] = iconRegister.registerIcon("xailite:" + (i == 0 ? "XailiteOre" : i == 1 ? "XailiteBlock" : i == 2 ? "TemperedXailiteOre" : i == 3 ? "RefinedXailiteBlock" : null)); } } In the ItemBlock.class: public String getUnlocalizedName(ItemStack itemstack) { String name; switch (itemstack.getItemDamage()) { case 0: name = "world"; break; case 1: name = "nether"; break; default: name = "broken"; break; } return this.getUnlocalizedName() + "." + name; } Registering the block: GameRegistry.registerBlock(xailiteBlock, ItemXailiteBlock.class, "Xailite" + xailiteBlock.getUnlocalizedName().substring(5)); Giving them display names: LanguageRegistry.addName(new ItemStack(xailiteBlock, 1, 2), "Refined Xailite Block"); LanguageRegistry.addName(new ItemStack(xailiteBlock, 1, 3), "Tempered Xailite Ore"); The two blocks with the same name are the refined block and the tempered ore. They return the correct block when broken, the recipes are correct, etc. the only discrepancy is them having the same name.
July 17, 201312 yr Try moving this.setUnlocalizedName() method to its own method: @Override public String getUnlocalizedName(ItemStack item) { return this.getUnlocalizedName() + "." + <YOUR NAME HERE>; } Use a "." instead of a "|" in the name. That might be another cause of the problem. http://i.imgur.com/gWwyMMO.jpg[/img]
July 17, 201312 yr Author Well, here's the block file now: public class XailiteBlock extends Block { public XailiteBlock(int id) { super(id, Material.rock); this.setCreativeTab(Xailite.xailiteTab); this.setHardness(5.5F); } @SideOnly(Side.CLIENT) private Icon[] blockTextures; public void registerIcons(IconRegister iconRegister) { blockTextures = new Icon[4]; //Change this according to how many blocks there are for (int i = 0; i < blockTextures.length; i++) { blockTextures[i] = iconRegister.registerIcon("xailite:" + (i == 0 ? "XailiteOre" : i == 1 ? "XailiteBlock" : i == 2 ? "TemperedXailiteOre" : i == 3 ? "RefinedXailiteBlock" : null)); } } @Override public Icon getIcon(int id, int metadata) { return blockTextures[metadata]; } @Override public void getSubBlocks(int id, CreativeTabs tab, List subBlockList) { for (int i = 0; i < blockTextures.length; ++i) { subBlockList.add(new ItemStack(id, 1, i)); } } @Override public int damageDropped(int metadata) { this.setUnlocalizedName("XailiteBlock|" + metadata); return metadata; } @Override public boolean isBeaconBase(World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { return worldObj.getBlockMetadata(x, y, z) == 1; } public String getUnlocalizedName(ItemStack itemStack) { return this.getUnlocalizedName() + "Xailite"; } } But it doesn't seem to work. And it's definitely the last two blocks having the same unlocalized name.
July 18, 201312 yr Author Fixed it! It turns out that the unlocalized name switch needed the cases for the two other damage values in order to make a different unlocalized name.
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.