Jump to content

[1.12.2-SOLVED] Block Item Missing from Custom Creative Tab


Laike_Endaril

Recommended Posts

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
Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.