Jump to content

[1.8] Custom walls displaying duplicate creative tab items *SOLVED*


csb123

Recommended Posts

Hey Folks,

 

I'm pretty new to all of this, so please bear with me.

 

I'm trying to make a simple mod that adds more different types of wall to the game. My walls seem to work, but the problem I'm having is that for each new type of wall I add, I get two items in the creative tab - one displaying the correct model and one not.

 

Here's my code:

 

 

 

I'm declaring the block variables as type Block, and instantiating them by creating an instance of BlockWall.

 

Declaration:

public static Block wallBrick;

 

My preInit method:

 

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
wallBrick = new BlockWall(Blocks.brick_block).setUnlocalizedName("brick_wall").setCreativeTab(wallsTab);
GameRegistry.registerBlock(wallBrick, wallBrick.getUnlocalizedName().substring(5));
}

 

The blocks are being rendered using a client side proxy from the initialization method:

 

@EventHandler
public void init(FMLInitializationEvent event)
{
proxy.registerRender(wallBrick);
}

public static void registerRender(Block block)
{
Item item = Item.getItemFromBlock(block);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(WallsMod.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}

 

 

 

And this is what my creative tab looks like:

 

 

hfW56Ig.png

 

 

 

Can anybody tell me what I'm doing wrong, and how to remove the duplicates from the creative tab?

 

Thanks  :)

Link to comment
Share on other sites

Hi,

 

Thanks for the replies :)

 

@TheGreyGhost:

No I have no warnings in the console regarding missing models.

 

When I cursor over the models, both say "tile.brick_wall.name". I can place either version in the world and they both work the same.

 

@deadrecon98

Sure - should I post the full classes? I'm not sure what you mean when you say "give that block a texture" as I don't want that block to show up at all - I just want the one that looks like a wall :)

 

 

Thanks

Link to comment
Share on other sites

Some ideas:

 

Do you still get two duplicates if you search for your item on the search tab?

What if you set the tab to a vanilla creative tab instead of your custom?

 

Do your blocks have multiple metadata?  What does your getSubItems() (or Block.getSubBlocks() ) look like?

 

You could try adding a breakpoint into ItemModelMesher.getItemModel()

        if (ibakedmodel == null)

        {

            ibakedmodel = this.modelManager.getMissingModel();

        }

 

- this is where it silently substitutes the missing model if it can't find the one it's looking for.  This will tell you what stack it's looking for, and with any luck why it's not finding it.

 

-TGG

  • Like 1
Link to comment
Share on other sites

It was the sub blocks!

 

BlockWall.getSubBlocks() adds a sub block for the mossy variant, which is why my instance of BlockWall was displaying two items.

 

I've now subclassed BlockWall and overriden the getSubBlocks() method to return a single item like Block does, and no more duplicates.

 

Thanks for your help TGG :)

  • Like 1
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.