Posted May 5, 201510 yr Why would four pieces of each armor, ie, 4 helmet, 4 chestplates , 4 leggings, and 4 boots be created when overriding getSubItems? @Override public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List list){ ItemStack enchant0 = new ItemStack(GlistreMod.MyHelmet_2); ItemStack enchant1 = new ItemStack(GlistreMod.MyChestplate_2); ItemStack enchant2 = new ItemStack(GlistreMod.MyLeggings_2); ItemStack enchant3 = new ItemStack(GlistreMod.MyBoots_2); enchant0.addEnchantment(Enchantment.blastProtection, 9); enchant1.addEnchantment(Enchantment.blastProtection, 9); enchant2.addEnchantment(Enchantment.blastProtection, 9); enchant3.addEnchantment(Enchantment.blastProtection, 9); list.add(enchant0); list.add(enchant1); list.add(enchant2); list.add(enchant3); } I am sure there is a simple explanation and easier way to write this code such as an array
May 5, 201510 yr getSubItems is getting called for each of your armor pieces because all of the armor pieces you have registered are an instance of your class that is adding the subitems. Each armor piece is adding a full set to the game. Try only adding one sub item to the list. So it would be something like this: ItemStack stack = new ItemStack(this); stack.addEnchantment(enchantmenthere); list.add(stack);
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.