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

I'm just now finally getting around to adding blocks/items for the first time, and for some reason I cannot get the item for my block into my creative tab.

The creative tab exists with the correct icon, and the item itself can be obtained with /give (and has no issues)

 

Main suspects in my eyes are the registry handler class...

 

Spoiler

package com.fantasticsource.wardstones;

import com.fantasticsource.wardstones.block.BlockWardstone;
import com.fantasticsource.wardstones.block.BlockWardstoneBase;
import com.fantasticsource.wardstones.item.ItemWardstone;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;

public class BlocksAndItems
{
    @GameRegistry.ObjectHolder("wardstones:wardstonebase")
    public static BlockWardstoneBase blockWardstoneBase;

    @GameRegistry.ObjectHolder("wardstones:wardstone")
    public static BlockWardstone blockWardstone;


    @GameRegistry.ObjectHolder("wardstones:wardstone")
    public static Item itemWardstone;


    public static CreativeTabs creativeTab = new CreativeTabs(Wardstones.MODID)
    {
        @Override
        public ItemStack getTabIconItem()
        {
            return new ItemStack(blockWardstone);
        }

        @Override
        public void displayAllRelevantItems(NonNullList<ItemStack> p_78018_1_)
        {
            super.displayAllRelevantItems(p_78018_1_);
        }
    };


    @SubscribeEvent
    public static void onBlockRegistry(RegistryEvent.Register<Block> event)
    {
        IForgeRegistry<Block> registry = event.getRegistry();
        registry.register(new BlockWardstoneBase());
        registry.register(new BlockWardstone());
    }

    @SubscribeEvent
    public static void onItemRegistry(RegistryEvent.Register<Item> event)
    {
        IForgeRegistry<Item> registry = event.getRegistry();
        registry.register(new ItemWardstone());
    }

    @SubscribeEvent
    public static void onModelRegistry(ModelRegistryEvent event)
    {
        ModelLoader.setCustomModelResourceLocation(itemWardstone, 0, new ModelResourceLocation("wardstones:wardstone", "inventory"));
    }
}

 

 

...and the item class...

 

Spoiler

package com.fantasticsource.wardstones.item;

import com.fantasticsource.wardstones.BlocksAndItems;
import com.fantasticsource.wardstones.Wardstones;
import net.minecraft.item.ItemBlock;

public class ItemWardstone extends ItemBlock
{
    public ItemWardstone()
    {
        super(BlocksAndItems.blockWardstone);

        setUnlocalizedName(Wardstones.MODID + ":wardstone");
        setRegistryName("wardstone");
        setCreativeTab(BlocksAndItems.creativeTab);
    }
}

 

 

...and here's a link to the repo:
https://github.com/Laike-Endaril/Wardstones/tree/1.12.2/src/main/java/com/fantasticsource/wardstones

Edited by Laike_Endaril
Solved

ItemBlock uses the Block's creative tab, so calling Item#setCreativeTab on an ItemBlock won't do anything.

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.

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.