Jump to content

1.11 - Why are blocks not showing up in my creative tab?


Eria8

Recommended Posts

Items all show up, but blocks don't. The block is definitely being registered, and so is its model (I know because I finally got it to stop giving block model errors by renaming the file), but it just won't appear in my creative tab. I'm probably just overlooking something stupid again, but I can't figure out what.

 

Registry

	public static Block quickSilverOre;

	public static Block[] blocks = new Block[]
	{
			quickSilverOre = new BloodBlock("quickSilverOre", Material.ROCK).setTool("pickaxe", 2)
	};
	public static void load()
	{
		for (Block block : blocks)
		{
			GameRegistry.register(block);
		}
	}
	public static void registerRenderers()
	{
		int i = Main.MODID.length() + 1;

		for (Block block : blocks)
		{
			Main.proxy.registerBlockRenderer(block, 0, block.getRegistryName().toString().substring(i));
		}
	}

 

Main

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		Registry.load();
		proxy.init();
	}

 

ClientProxy

	@Override
	public void init()
	{
		Registry.registerRenderers();
	}

	@Override
	public void registerBlockRenderer(Block item, int meta, String name)
	{
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(item), meta,
				new ModelResourceLocation(Main.MODID + ":" + name, "inventory"));
	}

 

And JSONs (I don't know if these are even relevant to the problem, but it saves the trouble of asking)

// BlockState
{
  "variants": {
    "normal": {
      "model": "bloodborne:quicksilverore"
    }
  }
}

// Model
{
  "parent": "block/cube_all",
  "textures": {
    "all": "bloodborne:blocks/quickilverore"
  }
}

// Item
{
  "parent": "bloodborne:block/quicksilverore"
}

 

Link to comment
Share on other sites

Indeed, only "items" can appear in inventories such as creative tabs, even if those items look like blocks and get replaced by blocks when "placed" (used against a solid surface) in the world. That's why we have item-blocks, which are items used to represent blocks.

 

From the point of view of a player, a world-block, a floating broken block itemStack entity and an inventory itemStack of item-blocks are all "blocks". However, from a programming standpoint, each is a distinct class of objects with differing storage. It's the programming that replaces one with another when certain actions are taken.

 

The floaters are blessedly automatic, so if we've made itemBlocks for inventory, then we don't need to do any more, but we are still on the hook to declare the itemBlock for each block type that is to appear in inventory. In rare cases, such as when I made a device that gave off smoke blocks, I deliberately withheld the itemBlock (making it unobtanium like air, water and lava).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.



×
×
  • Create New...

Important Information

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