Jump to content

[1.7.10] 3D Item Rendering Issues


UnnamedProdigy

Recommended Posts

I am trying to render an item in 3D and I have the model class and renderer set up and it is registered with MinecraftForgeClient.registerItemRenderer() in my client proxy but whenever I go in game and look at it in Third Person nothing is there and the player is floating of the ground at weird angles and the blocks render below the player but the hit box is above the player.

Here is my item renderer class

 

 

package mymod.items.render;

 

import net.minecraft.client.Minecraft;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.ForgeHooksClient;

import net.minecraftforge.client.IItemRenderer;

 

import org.lwjgl.opengl.GL11;

 

public class GunRenderer implements IItemRenderer {

 

private GunModel gunmodel;

 

public static ResourceLocation location = new ResourceLocation("mymod:" + "textures/items/models/Gun.png");

 

 

@Override

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

switch(type)

{

case EQUIPPED: return true;

case EQUIPPED_FIRST_PERSON: return true;

default: return false;

}

}

 

@Override

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,

ItemRendererHelper helper) {

 

return false;

}

 

@Override

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

gunmodel = new GunModel();

switch(type)

{

case EQUIPPED:

{

GL11.glPushMatrix();

 

Minecraft.getMinecraft().renderEngine.bindTexture(location);

GL11.glRotatef(0, 0, 0, 0);

GL11.glScalef(1.4F, 1.4F, 1.4F);

GL11.glTranslatef(0, 3, 0);

 

 

this.gunmodel.renderGun(0.0625F);

 

GL11.glPopMatrix();

 

 

}

case EQUIPPED_FIRST_PERSON:

{

 

}

default:

break;

}

}

}

 

 

 

 

 

Here is my model class

 

 

// Date: 6/18/2015 7:30:35 PM

// Template version 1.1

// Java generated by Techne

// Keep in mind that you still need to fill in some blanks

// - ZeuX

 

 

 

 

 

 

package mymod.items.render;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class GunModel extends ModelBase

{

//fields

public ModelRenderer Scope;

public ModelRenderer TriggerGuard1;

public ModelRenderer TriggerGuard2;

public ModelRenderer TriggerGuard3;

public ModelRenderer Barrel;

public ModelRenderer Handle;

public ModelRenderer Trigger;

 

public GunModel()

{

textureWidth = 64;

textureHeight = 64;

 

Scope = new ModelRenderer(this, 0, 13);

Scope.addBox(0F, -1F, -1F, 3, 1, 1);

Scope.setRotationPoint(0F, 17F, 1.3F);

Scope.setTextureSize(64, 64);

Scope.mirror = true;

setRotation(Scope, 0.7853982F, 0F, 0F);

TriggerGuard1 = new ModelRenderer(this, 0, 23);

TriggerGuard1.addBox(0F, 0F, 0F, 0, 1, 1);

TriggerGuard1.setRotationPoint(1.1F, 18.7F, 0F);

TriggerGuard1.setTextureSize(64, 64);

TriggerGuard1.mirror = true;

setRotation(TriggerGuard1, 0F, 0F, -0.5980662F);

TriggerGuard2 = new ModelRenderer(this, 0, 26);

TriggerGuard2.addBox(0F, 0F, 0F, 0, 1, 1);

TriggerGuard2.setRotationPoint(1.6F, 19.4F, 0F);

TriggerGuard2.setTextureSize(64, 64);

TriggerGuard2.mirror = true;

setRotation(TriggerGuard2, 0F, 0F, -1.151917F);

TriggerGuard3.mirror = true;

TriggerGuard3 = new ModelRenderer(this, 0, 29);

TriggerGuard3.addBox(0F, 0F, 0F, 0, 1, 1);

TriggerGuard3.setRotationPoint(2.5F, 19.8F, 0F);

TriggerGuard3.setTextureSize(64, 64);

TriggerGuard3.mirror = true;

setRotation(TriggerGuard3, 0F, 0F, -1.579523F);

TriggerGuard3.mirror = false;

Barrel = new ModelRenderer(this, 0, 10);

Barrel.addBox(0F, 0F, -1F, 8, 1, 1);

Barrel.setRotationPoint(-4F, 17.5F, 0.5F);

Barrel.setTextureSize(64, 64);

Barrel.mirror = true;

setRotation(Barrel, 0.7853982F, 0F, 0F);

Handle = new ModelRenderer(this, 0, 7);

Handle.addBox(0F, 0F, 0F, 3, 1, 1);

Handle.setRotationPoint(3.5F, 21.5F, 0F);

Handle.setTextureSize(64, 64);

Handle.mirror = true;

setRotation(Handle, 0F, 0F, -1.745329F);

Trigger = new ModelRenderer(this, 0, 32);

Trigger.addBox(0F, 0F, 0F, 0, 1, 1);

Trigger.setRotationPoint(3F, 18.5F, 0F);

Trigger.setTextureSize(64, 64);

Trigger.mirror = true;

setRotation(Trigger, 0F, 0F, 0.5061455F);

}

 

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)

{

super.render(entity, f, f1, f2, f3, f4, f5);

setRotationAngles(f, f1, f2, f3, f4, f5, entity);

Scope.render(f5);

TriggerGuard1.render(f5);

TriggerGuard2.render(f5);

TriggerGuard3.render(f5);

Barrel.render(f5);

Handle.render(f5);

Trigger.render(f5);

}

 

public void renderGun(float f5)

{

Scope.render(f5);

TriggerGuard1.render(f5);

TriggerGuard2.render(f5);

TriggerGuard3.render(f5);

Barrel.render(f5);

Handle.render(f5);

Trigger.render(f5);

}

 

 

private void setRotation(ModelRenderer model, float x, float y, float z)

{

model.rotateAngleX = x;

model.rotateAngleY = y;

model.rotateAngleZ = z;

}

 

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity ent)

{

super.setRotationAngles(f, f1, f2, f3, f4, f5, ent);

}

 

}

 

 

 

And here is the part of the client proxy that registers the renderer

 

 

public void registerRenderThings(){

MinecraftForgeClient.registerItemRenderer(LightningMaterials.Gun_1, (IItemRenderer)new GunRenderer());

}

 

 

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.