Jump to content

Recommended Posts

Posted

So I cant seem to get my 3D block model to display whilst holding a block. Ive followed a lot of 1.7.2 guides (couldnt find any 1.7.10 ones) and it dosnt seem to work. I have a 2d image to display in the hand but not the render for the block. Im not too good at explaining. So to cut to the chase, I want my block called an Endite reactor to display in my hand as the 3d model it has when placed in the game. Here is my code:

 

Client Proxy:

 

  Reveal hidden contents

 

 

Block Class :

 

  Reveal hidden contents

 

 

Model Class:

 

  Reveal hidden contents

 

 

Item Render:

 

  Reveal hidden contents

 

 

Render Class:

 

  Reveal hidden contents

 

 

Tile Entity:

 

  Reveal hidden contents

 

 

There are no errors in eclipse and the block works fine. I just cant get it to display in my hand. I have probably just made some stupid mistake but im not seeing it. This is also my first time doing 3d modelling so im new to it. Here is an image to to show what is happening.

 

Thanks for helping

-iLegendx98

 

 

Posted

Hi

 

This link might help explain some of the background concepts; see the Item Rendering sections

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

Your code wouldn't work in 1.7.2 anyway, it is missing several things.

 

For example this- what happens if render type is EQUIPPED_BLOCK?

   @Override
   public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
      if(type == IItemRenderer.ItemRenderType.ENTITY)
         GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
      this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
   }

 

-TGG

Posted

You also need to render the model. For an item or a block model, i always make a new render(float r) method, then make all the model componates render it, make the r = 0.0652F (i think, thats just off my head) then call that method inside your item renderer

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Posted

The code from this in the model class:

 

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
part.render(f5);
par1.render(f5);
par3.render(f5);
}

 

make a new method:

public void render(){
float r = 0.0625F;
part.render(r);
par1.render(r);
par3.render(r);
}

 

and in the ItemRenderer class that you made

float scale = 1.0F;
	GL11.glPushMatrix();
	GL11.glRotatef(180F, 0.0F, 0.0F, 4.0F);
switch(type){
		case EQUIPPED:
			scale = 1.5F;
			GL11.glScalef(scale, scale, scale);
			GL11.glTranslatef(-0.6F, -1.0F, 0.4F); //Sets where the model is placed (you can mess around with this to suit you)
			break;
		case ENTITY:
			scale = 3.0F;
			GL11.glScalef(scale, scale, scale);
			GL11.glTranslatef(0.0F, -1.5F, 0.0F);
			break;
		case INVENTORY:
			scale = 0.8F;
			GL11.glScalef(scale, scale, scale);
			GL11.glTranslatef(0.0F, -0.5F, 0.0F);
			break;
		case EQUIPPED_FIRST_PERSON:
			scale = 1.5F;
			GL11.glScalef(scale, scale, scale);
			GL11.glTranslatef(0.0F, -1.0F, 0.4F);
			break;
		default: break;
		}
		new ModelYourBlock().render();
GL11.glPopMatrix();

 

the switch statement is from my item render code and it goes in this method:

@Override
public void renderItem(ItemRenderType type, ItemStack i, Object...data)

 

That should be all you need :)

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Posted

Ive done what you said and it still isnt working. I could maybe be missing something in my main. Is there any thing that has to go in there in relation to the render. I have the block registry in there and stuff to do with the proxies. I havent had to register anything like render classes, maybe thats it? I have updated my post with my current code after modifying it.

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.