Jump to content

[SOLVED][1.7.2] ItemBlock not appearing


Recommended Posts

I have this block that does not appear in the game (in creative tabs). I will not post all code here, but only that which is relevant... I know some code (texture, most likely) will not work because I'm in the process of porting this from 1.6.4 to 1.7.2 (and these classes are still in development, hence some weird constructor stuff). Any idea what might be wrong?


Edit: The block did show up in 1.6.4 before I made some change to support 1.7.2.


This is the Item which extends a base item.

public class ItemDoorArtDeco1 extends ItemBaseDoor
    public ItemDoorArtDeco1(Block block)
        super("kgblocks:itemartdecodoor1", block);


This is the parent item. I will only paste constructor.

public class ItemBaseDoor extends ItemBlock
    public ItemBaseDoor(String textureName, Block blk)
        this.maxStackSize = 1;
        this.block = blk;


This is the relevant block.

public class BlockArtDecoDoor1 extends BaseDoor
    public BlockArtDecoDoor1()


This is the parent block. Again I will ommit all non-constructor code.

public abstract class BaseDoor extends Block
    public BaseDoor(String textureName)
        float f = 0.5F;
        float f1 = 1.0F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);


Now this code below is from the main mod class. I create the block and pass it to a method called registerBlockWithItemBlock.


		blockArtDecoDoor1 = new BlockArtDecoDoor1();
	registerBlockWithItemBlock(blockArtDecoDoor1, ItemDoorArtDeco1.class, "blockArtDecoDoor");


And here's the method in question:

	public void registerBlockWithItemBlock(Block block, Class<? extends ItemBlock> itemclass, String name){
	GameRegistry.registerBlock(block, itemclass, name);

Link to comment
Share on other sites

I'm not sure what exactly is wrong, but I think it has to do with you registering creative tabs for your ItemBlock, as well as setting texture names all over the place. Here is a class I use for my ItemBlocks with blocks that have metadata. Keep in mind that this is the entire class:

public class ItemMetadataBlock extends ItemBlockWithMetadata {
public ItemMetadataBlock(Block block) {
	super(block, block);

Yes, just that. Here's how I register a block to use that class:

// this is all for creating the block, since I set the tab and register several icons in the block class
pedestal = new BlockPedestal().setBlockName("zss.pedestal");

GameRegistry.registerBlock(pedestal, ItemMetadataBlock.class, pedestal.getUnlocalizedName());

It uses the icons from the block class, so whatever texture you set / register for your block, that is what will render in the inventory. Likewise, whatever Creative Tab you set for your block in the block class is the one that will be used.


Simple as those few lines. If your block doesn't use metadata, you could probably just use the vanilla ItemBlock class. ItemBlockWithMetadata doesn't have a single Block argument constructor, however, so it will crash the game, which is why I made that wrapper class above.

Link to comment
Share on other sites

I removed all the set texture code and I made sure only the Block was registered with a creative tab.


Still does not show up... I can get normal blocks to show up, and items to show up, but not itemblocks...

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.

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.