Posted October 14, 20168 yr Okay, so i've created my own Item with 4 metadata value. The problem is that I want each of my metadata items to have a different name instead of having one uniformed name. As you can see in the image below, I used one localization and all the metadata's names have the same name. ItemMetadata class: public class MetaRing extends Item { public MetaRing() { this.setHasSubtypes(true); this.setUnlocalizedName("meta_ring"); this.setRegistryName("meta_ring"); this.setHasSubtypes(true); this.setCreativeTab(Main.tabBrothers); } @Override public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) { subItems.add(new ItemStack(itemIn, 1, 0)); subItems.add(new ItemStack(itemIn, 1, 1)); subItems.add(new ItemStack(itemIn, 1, 2)); subItems.add(new ItemStack(itemIn, 1, 3)); } } RegisterItems class: public class RegisterItems { public static Item meta_ring; public static void main() { init(); register(); } private static void init() { meta_ring = new MetaRing(); } private static void register() { GameRegistry.registerItem(meta_ring, meta_ring.getRegistryName()); } public static void registerRenders() { PlayHelper.registerRenderMetaItems(meta_ring, 0, "white_meta_ring"); PlayHelper.registerRenderMetaItems(meta_ring, 1, "red_meta_ring"); PlayHelper.registerRenderMetaItems(meta_ring, 2, "blue_meta_ring"); PlayHelper.registerRenderMetaItems(meta_ring, 3, "green_meta_ring"); } } Registered RegisterItems#main in my Mod class's preInit and RegisterItems#registerRenders in my ClientProxy's preInit. http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
October 15, 20168 yr Author You need to override getUnlocalizedName(ItemStack) in your Item class and return whatever unlocalized name you want based on the metadata. Hm, can I use the if statements and check if the ItemDamage is equals to a specific value, then return the String of the name? http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
October 15, 20168 yr Author Thanks diesieben07! It worked! http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
October 15, 20168 yr Or you could pull a string from an array of strings using meta as the index. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
October 15, 20168 yr Or you could pull a string from an array of strings using meta as the index. Would this really be better, just because the code is a bit shorter? I mean you store the Strings in the Array the whole time with that solution
October 15, 20168 yr You'd be stunned by how much data is stored by Minecraft in order to avoid calculating it every time it is needed. Just think of the model bakery... A switch statement would compile into a jump table much like the array I suggested. The only difference might be where the strings are stored (or maybe only where the pointers to the strings are stored). For a compact data set with known contiguous index, a static array should fit perfectly. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
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.