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

Hi!

I am trying to find out how to create items with the new (i think its not that new but...) 1.8 version.

 

I didn't find a lot of tutorials for this topic, (I am sure there are a lot but i didn't find a good one)

so i went there and just read the code. I started by reading the "net.minecraft.init.Items" class.

I struggled, because all the items seem to be registered somewhere else. there is just the function:

static
    {
        if (!Bootstrap.isRegistered())
        {
            throw new RuntimeException("Accessed Items before Bootstrap!");
        }
        else
        {
                iron_shovel = getRegisteredItem("iron_shovel");
                // ...

 

I ctrl-clicked the method, but i didn't found anything usefull.

 

Where are the definitions of the Items hidden? (I know that net.minecraft.item is holding some of them, but i can't find any example for a "something_ingot".

Item.registerItems

instantiates and registers all vanilla items. The static initialiser of

Items

gets the

Item

instances from the item registry and assigns them to the static fields.

 

Item creation and registration hasn't really changed in 1.8, only the model system has.

 

BedrockMiner has a tutorial on creating a basic item in 1.8 here.

 

I register my mod's items using this class. I register my models using this class.

 

This code is for 1.8. Switch to the 1.8.8 branch to see the 1.8.9 code.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

I think it is important to understand that an Item instance is never really useful on its own. You really need an ItemStack or an EntityItem depending on whether it is in an inventory or on the ground. If you only have a single item, you are really holding an ItemStack with quantity 1.

 

I think there are only one main instance of each Item class, and it describes the behavior of items generally. But if you want a specific item of that type to be a bit different then you need to use the ItemStack and a combination of metadata and/or NBT data. So you don't name an Item, you name an ItemStack. You don't damage an Item, you damage an ItemStack.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.