Jump to content

[1.8] How to render chest-like block?


RoseCotton

Recommended Posts

I'm editing code from my custom block mod for a new mod and having a hard time registering a new type of block.

I'm trying to make shelves, so the block is more like a chest.  I'm taking this in baby steps and I've borrowed many of the methods from the BlockChest class, but it extends BlockContainer, which I can't seem to find anywhere, instead of Block.

 

So when I try the code to render the item in my main mod class (ShelvesMod.java), it chokes on my attempts to use methods like "getName" and "renderItem.getItemModelMesher":

 

  @EventHandler

  public void init(FMLInitializationEvent event)

  {

  if(event.getSide() == Side.CLIENT)

  {

  renderItem.getItemModelMesher().register(Item.getItemFromBlock(shelfBlock), 0, new ModelResourceLocation(ShelvesMod.MODID + ":" + ((BlockShelf)shelfBlock).getName(), "shelfBlock"));

  Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(shelfBlock),0, new ModelResourceLocation(ShelvesMod.MODID+":"+ ((BlockShelf)shelfBlock).getName(), "inventory"));

  }

  }

 

Sorry I can't figure out how to "insert code"; the button above doesn't seem to do anything.

 

I plan to figure out how to actually render the texture of the shelves plus icons of the items on the shelves next, but for now I just want to know how I should be handling this item. 

 

Any suggestions on how to render a chest-like item?

 

UPDATE:  Ok nevermind.... I'd forgotten to un-comment my declaration of renderItem

 

  RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();

 

  renderItem.getItemModelMesher().register(Item.getItemFromBlock(shelfBlock), 0, new ModelResourceLocation(ShelvesMod.MODID + ":" + "shelfBlock", "shelfBlock"));

  Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(shelfBlock),0, new ModelResourceLocation(ShelvesMod.MODID+":"+ "shelfBlock", "inventory"));

 

 

UPDATE2: code runs, but the placeholder model doesn't show up, even though in the BlockShelf class I'm specifying a tab in which it should appear. 

 

        this.setCreativeTab(CreativeTabs.tabMisc);

hw developer in a sw world

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.