Jump to content

Recommended Posts

Posted

I have an entity with a custom model and whenever it is holding an item the item doesn't show up. How would I tell my model where to render the held item?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

I did, in fact I searched those up and down before coming here. I found LayerRenderer but what is it and how do I use it?

 

Thanks

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

I did, in fact I searched those up and down before coming here. I found LayerRenderer but what is it and how do I use it?

Did you look at the code for rendering bipeds, i.e. RenderBiped, or any non-abstract render class? RenderBiped has a couple layers and should provide more than enough of an example to see what they are and how to use them.

Posted

Ok I looked at LayerHeld Item and applied it to my Renderer but nothing happens. I looked into the code and there is also one for the Witch. I looked at that at I was wondering a) do I have to make my own LayerHeldItem for my mob and b) if I do, does the GLStateManager#translate position it on the model?

 

Thanks

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Model:

 

package com.apmods.creeps.models.floob;

import java.util.HashMap;

import com.apmods.creeps.entity.EntityFloob;
import com.apmods.creeps.models.MCALibs.client.MCAClientLibrary.MCAModelRenderer;
import com.apmods.creeps.models.MCALibs.common.MCACommonLibrary.MCAVersionChecker;
import com.apmods.creeps.models.MCALibs.common.MCACommonLibrary.animation.AnimationHandler;
import com.apmods.creeps.models.MCALibs.common.MCACommonLibrary.math.Matrix4f;
import com.apmods.creeps.models.MCALibs.common.MCACommonLibrary.math.Quaternion;

import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;

public class ModelFloob extends ModelBase {
public final int MCA_MIN_REQUESTED_VERSION = 5;
public HashMap<String, MCAModelRenderer> parts = new HashMap<String, MCAModelRenderer>();

MCAModelRenderer head;
MCAModelRenderer body;
MCAModelRenderer rightLeg;
MCAModelRenderer leftLeg;
MCAModelRenderer leftEye;
MCAModelRenderer rightEye;
MCAModelRenderer rightArm;
MCAModelRenderer leftArm;

public ModelFloob()
{
MCAVersionChecker.checkForLibraryVersion(getClass(), MCA_MIN_REQUESTED_VERSION);

textureWidth = 64;
textureHeight = 32;

head = new MCAModelRenderer(this, "head", 0, 0);
head.mirror = false;
head.addBox(0.0F, 0.0F, 0.0F, 6, 12, 6);
head.setInitialRotationPoint(0.0F, 0.0F, 0.0F);
head.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
head.setTextureSize(64, 32);
parts.put(head.boxName, head);

body = new MCAModelRenderer(this, "body", 8, 19);
body.mirror = false;
body.addBox(0.0F, 0.0F, 0.0F, 8, 8, 4);
body.setInitialRotationPoint(-1.0F, -8.0F, 1.0F);
body.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
body.setTextureSize(64, 32);
parts.put(body.boxName, body);

rightLeg = new MCAModelRenderer(this, "rightLeg", 24, 0);
rightLeg.mirror = false;
rightLeg.addBox(0.0F, 0.0F, 0.0F, 3, 16, 3);
rightLeg.setInitialRotationPoint(-1.0F, -24.0F, 1.5F);
rightLeg.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
rightLeg.setTextureSize(64, 32);
parts.put(rightLeg.boxName, rightLeg);

leftLeg = new MCAModelRenderer(this, "leftLeg", 24, 0);
leftLeg.mirror = false;
leftLeg.addBox(0.0F, 0.0F, 0.0F, 3, 16, 3);
leftLeg.setInitialRotationPoint(4.0F, -24.0F, 1.5F);
leftLeg.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
leftLeg.setTextureSize(64, 32);
parts.put(leftLeg.boxName, leftLeg);

leftEye = new MCAModelRenderer(this, "leftEye", 1, 19);
leftEye.mirror = false;
leftEye.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1);
leftEye.setInitialRotationPoint(3.5F, 8.0F, 5.5F);
leftEye.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
leftEye.setTextureSize(64, 32);
parts.put(leftEye.boxName, leftEye);
head.addChild(leftEye);

rightEye = new MCAModelRenderer(this, "rightEye", 1, 19);
rightEye.mirror = false;
rightEye.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1);
rightEye.setInitialRotationPoint(0.5F, 8.0F, 5.5F);
rightEye.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
rightEye.setTextureSize(64, 32);
parts.put(rightEye.boxName, rightEye);
head.addChild(rightEye);

rightArm = new MCAModelRenderer(this, "rightArm", 36, 0);
rightArm.mirror = false;
rightArm.addBox(0.0F, 0.0F, 0.0F, 3, 13, 3);
rightArm.setInitialRotationPoint(-3.0F, 5.0F, 13.0F);
rightArm.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.70710677F, 0.0F, 0.0F, 0.70710677F)).transpose());
rightArm.setTextureSize(64, 32);
parts.put(rightArm.boxName, rightArm);
body.addChild(rightArm);

leftArm = new MCAModelRenderer(this, "leftArm", 36, 0);
leftArm.mirror = false;
leftArm.addBox(0.0F, 0.0F, 0.0F, 3, 13, 3);
leftArm.setInitialRotationPoint(8.0F, -5.0F, 0.5F);
leftArm.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose());
leftArm.setTextureSize(64, 32);
parts.put(leftArm.boxName, leftArm);
body.addChild(leftArm);

}

@Override
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) 
{
	EntityFloob entity = (EntityFloob)par1Entity;

	AnimationHandler.performAnimationInModel(parts, entity);

	//Render every non-child part
	head.render(par7);
	body.render(par7);
	rightLeg.render(par7);
	leftLeg.render(par7);
}
@Override
public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {

}

public MCAModelRenderer getModelRendererFromName(String name)
{
	return parts.get(name);
}
}

 

 

Renderer:

 

package com.apmods.creeps.client;

import org.lwjgl.opengl.GL11;

import com.apmods.creeps.Creeps;
import com.apmods.creeps.entity.EntityFloob;
import com.apmods.creeps.models.floob.ModelFloob;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;

public class RenderFloob extends RenderLiving {

public static final ResourceLocation Floob_texture = new ResourceLocation(Creeps.MODID + ":textures/models/Floob.png");
public static ModelFloob modelFloob = new ModelFloob();	
public static float modelHeight = 3F;

public RenderFloob()
    {
        super(Minecraft.getMinecraft().getRenderManager(), modelFloob, 0.5F);
        this.addLayer(new LayerHeldItem(this));
    }

@Override
public void doRender(Entity _entity, double posX, double posY, double posZ, float var8, float var9) {
	EntityFloob entity = (EntityFloob) _entity;

	GL11.glPushMatrix();
	GL11.glDisable(GL11.GL_CULL_FACE);
	super.doRender(_entity, posX, posY, posZ, var8, var9);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glPopMatrix();
}

@Override
protected void preRenderCallback(EntityLivingBase entityliving, float f)
{
	GL11.glRotatef(180F, 0, 1F, 0F);
	GL11.glRotatef(180F, 0, 0, 1F);
	GL11.glTranslatef(0, modelHeight, 0);
//		GL11.glScaled(1.7, 1.7, 1.7);
}

@Override
protected ResourceLocation getEntityTexture(Entity var1) {
	return Floob_texture;
}
}

 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.