Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.