Jump to content

[SOLVED] 152 -> 162 IItemRender changes (only uses item texture sheet)


Recommended Posts

Posted

So, finally updating my mod to 1.6.2.

 

Most things went as smooth as they could, but I've been banging my head against a problem for a few hours now, something that makes absolutely no sense.

 

What changed with IItemRenders between 1.5 and 1.6?  I had an item that rendered as a block in 1.5.2, but in 1.6.2 it refuses to bind the block icons.  It instead renders a random icon off of the items icon sheet -- it seems completely random as I get fish, golden carrots, and icons from my own mod used, though it is consistent for a give id/meta.  I'm guessing its not switching the base-texture sheet from the item sheet but still using the UV from my block Icon.

 

Any way to force it to use the block texture sheet?  Should I just double-register all of my icons for use as an item icon (no clue if this will work...)?  Any other simple methods for rendering an item as a block?  (the item is not an ItemBlock -- the Item and Block are completely separate for whatever reason I designed it that way....NFC anymore, and will probably just end up rewriting the whole system if I can't get this weird shit figured out)

 

 

Strangely, if I pull the icon instance out and query it for iconName -- it returns the proper icon path for what I would expect, only the texture that is rendered is wrong.

 

Anyhow..here is the render code.  Its pretty standard, taken almost exactly from the RenderBlocks methods.  It worked fine in 1.5.2.

 

(i have the par2/meta value set to 0 until I figure out the icon issues -- 0 is a valid meta and should be pulling up the same icon as the block uses to render)

 

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
  {
  if(type==ItemRenderType.FIRST_PERSON_MAP)
    {
    return;
    }  
  RenderBlocks render = (RenderBlocks)data[0];
  int blockNum = item.getItemDamage()/16;

  
  Block blk = null;
  switch(blockNum)
    {
    case 0:
    blk = BlockLoader.civicBlock1;
    break;
    
    case 1:
    blk = BlockLoader.civicBlock2;
    break;
    
    case 2:
    blk = BlockLoader.civicBlock3;
    break;
    
    case 3:
    blk = BlockLoader.civicBlock4;
    break;
    
    default:
    blk = BlockLoader.civicBlock1;
    break;
    }
  
  GL11.glPushMatrix();
  if(type!=ItemRenderType.ENTITY)
    {
    GL11.glTranslatef(0.5f, 0.5f, 0.5f);
    GL11.glRotatef(180, 0, 1, 0);
    }
  else
    {
    GL11.glScalef(0.5f, 0.5f, 0.5f);
    }    
   
  int par2 = 0;//meta value
  Block par1Block = blk;
  Tessellator tessellator = Tessellator.instance;
  par1Block.setBlockBoundsForItemRender();
  render.setRenderBoundsFromBlock(par1Block);
  GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
  GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
  tessellator.startDrawingQuads();
  tessellator.setNormal(0.0F, -1.0F, 0.0F);
  render.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 0, par2));
  tessellator.draw();

  tessellator.startDrawingQuads();
  tessellator.setNormal(0.0F, 1.0F, 0.0F);
  render.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 1, par2));
  tessellator.draw();


  tessellator.startDrawingQuads();
  tessellator.setNormal(0.0F, 0.0F, -1.0F);
  render.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 2, par2));
  tessellator.draw();
  tessellator.startDrawingQuads();
  tessellator.setNormal(0.0F, 0.0F, 1.0F);
  render.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 3, par2));
  tessellator.draw();
  tessellator.startDrawingQuads();
  tessellator.setNormal(-1.0F, 0.0F, 0.0F);
  render.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 4, par2));
  tessellator.draw();
  tessellator.startDrawingQuads();
  tessellator.setNormal(1.0F, 0.0F, 0.0F);
  render.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, render.getBlockIconFromSideAndMetadata(par1Block, 5, par2));
  tessellator.draw();
  GL11.glTranslatef(0.5F, 0.5F, 0.5F);
  GL11.glPopMatrix();
  }

Posted

int blockNum = item.getItemDamage()/16;

  
  Block blk = null;
  switch(blockNum)
    {
    case 0:
    blk = BlockLoader.civicBlock1;
    break;

So what are those blocks in BlockLoader class ? Do they have a texture returned by block.getIcon(int,int) ?

Posted

Further testing reveals that if I register the same icon names as item icons (and duplicate all of my block textures =\ ), the IItemRenderer will render the block as intended.

 

More and more it is looking like the IItemRenderer is for some reason not checking the type/origin of the icon to bind the proper texture sheet.  Not sure why it worked in 1.5.2.

 

I will update with more information as I come across it.

Posted

int blockNum = item.getItemDamage()/16;

  
  Block blk = null;
  switch(blockNum)
    {
    case 0:
    blk = BlockLoader.civicBlock1;
    break;

So what are those blocks in BlockLoader class ? Do they have a texture returned by block.getIcon(int,int) ?

 

Yes, the blocks return an icon from that method.  The blocks themselves render fine in the world once placed.  Only the IItemRenderer is binding icons from the item sheet with the same texture UV as the block icons that I am actually using to render.

 

I have a feeling its just a context problem -- e.g. IItemRenderer is called when the render-engine is setup to render items, and has the item texture sheet bound, with no easy way to force it to use the block texture sheet.  (Hence, I give it an icon...it pulls the UV from the icon, but never binds the texture-sheet the icon belongs to)

 

 

 

Posted

It probably has to do with the item renderer pulling icons from the item texture sheet, as the Icon class does not (appear to) contain any information as to which stitched sheet the Icon resides in.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

It probably has to do with the item renderer pulling icons from the item texture sheet, as the Icon class does not (appear to) contain any information as to which stitched sheet the Icon resides in.

 

Thats pretty much what I'm thinking at this point.

 

I registered the same icons as item icons (after copying the textures to the /items/ path), and the blocks register just fine.  Going to have to find a different method though, as I don't like having to duplicate resources to work around a bug. 

 

I should probably just create a proper ItemBlock for the thing, as my other ItemBlock stuff renders fine pulling in block icons/textures.

 

Any way to manually set what texture sheet the render-engine pulls from? 

 

 

Thanks for the input -- one more problem solved/figured out :) (at least for now)

 

 

if(type==ItemRenderType.FIRST_PERSON_MAP)
    {
    return;
    }  

What about ItemRenderType.INVENTORY ? You don't check for that one ?

 

for all types but FIRST_PERSON_MAP it will execute the rest code block following the if/return block.  No need to check explicitly for the INVENTORY type, as that is included in the set of remaining render types.

 

The problem isn't that its not rendering, merely that it was binding textures from the wrong texture sheet for the passed in icon.

Posted

Hi

 

I had the same problem I think.  If your Item's custom renderer uses an icon from the block texture map, make sure that Item.getSpriteNumber() returns 0, otherwise the tessellator will render using the item texture map, i.e. the wrong icons will be used.

 

-TGG

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.