Laike_Endaril Posted February 23, 2019 Posted February 23, 2019 (edited) 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 February 23, 2019 by Laike_Endaril Solved Quote
Choonster Posted February 23, 2019 Posted February 23, 2019 ItemBlock uses the Block's creative tab, so calling Item#setCreativeTab on an ItemBlock won't do anything. Quote 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.
Laike_Endaril Posted February 23, 2019 Author Posted February 23, 2019 Ah, tyvm Choonster. Setting the creative tab in the block solved the issue. Quote
Recommended Posts
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.