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

So as I started modding using forge, I got started by following some tutorials. Now as I work through the tutorial that explains how to create and add blocks to the game that contain metadata (so the block has a different texture depending on the metadata value), I messed up and the textures didn't load. In the end I got it to work but while searching for an answer I found out something of which I question it's necessity.

 

My block class has the following method:

 

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2) {
System.out.println(icons[par2].getIconName());
return icons[par2];
}

 

As it turns out, under the following conditions, this console print happened a lot as if this method got called every render:

-The block was visible in the GUI (hotbar, inventory, creative tabs)

-The block was on the floor as a (hovering) item (as in: not plonked down in the world) and within vision

 

Yet it seems this method didn't need to be called at all, if the block only needed to be rendered as a block that is a part of the world instead of being an item.

 

Now what I wonder is, why would this method have to be called so much when all it(forge?) gets from the call is a Icon object that won't change at all during the entire life-cycle? Does this have anything to do with item animations? Or could there be a optimization possible here?

 

(Yes I know it gets called once for rendering every side of the block, I found that out by printing par1 :P)

 

edit: typo fix

First: If it is not placed on the world grid, it is not a block. It is an Item (ItemBlock by default) or an EntityItem.

 

Second: It needs to be called that much, since the renderer doesn't know when the texture is going to change. Because, yes, it can change. You can return a random icon if you like.

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.