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

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

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.

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.