Jump to content

[1.6.4] Rendering items in a tileEntity (in world)


lexwebb

Recommended Posts

So i'm making a 3D printer block, so as you can imagine ill be needing to render the item i'm printing on the printing bed of the machine. I've experimented calling an ItemRenderer with bad results.

 

Whats the best way to render an item like this in world? Would it be best to use an ItemEntity and somehow stop the rotation and make it un-pickupable? Or is there some way i can piggyback the ItemRenderer for an item as render it in my TileEntitySpecialRenderer?

 

 

Link to comment
Share on other sites

Make an EntityItem of the item you want to display and then render it.

 

I put this in my model class, because of rendering order, but you can put it in the render class as well.

 

if(es.itemEnt != null) {
GL11.glPushMatrix();
double angle = Math.toRadians(es.rotation);
float sin = (float)(Math.sin(angle));
float cos = (float)(Math.cos(angle));
sin = Math.round(sin*100)/100;
cos = Math.round(cos*100)/100;

GL11.glTranslatef((float)x + 0.5F + (float)(sin*0.25), (float)y + 0.76F, (float)z + 0.5F - (float)(cos*0.25));

GL11.glRotatef(-1*es.rotation, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);

RenderManager.instance.renderEntityWithPosYaw(es.itemEnt, 0, 0, 0, 0, 0);
GL11.glPopMatrix();
}

 

The rotation math was because the (2D) item was laying flat on the top of the TE.

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.

Link to comment
Share on other sites

Would you mind explaining where you are getting 'es.rotation' from, as i cannot seem to find a reference to it anywhere, and passing an arbitrary value in its place just seems to make the item spin uncontrollably.

 

That was the rotation of the block itself.  It's based on metadata.

 

Also, you will need to set the entity's age to 0 every frame or it will self-rotate like any other dropped item.

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.

Link to comment
Share on other sites

itemEnt.rotationYaw = 0;

 

That value is randomized when item entities are instanciated.

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.

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.