Jump to content

Block getIcon(par1, par2) called every render when it's an item?


Recommended Posts

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:


public Icon getIcon(int par1, int par2) {
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

Link to comment
Share on other sites

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.

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.