Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have a custom entity, which works fine except when it moves its head.

It looks like this:

 

http://www.kepfeltoltes.hu/view/151028/topic_www.kepfeltoltes.hu_.jpg

 

His ears and nose doesn't move along with his head, which also has a pretty bad rotation point.

Here are my codes. What should I change to make it work?

 

package net.Aethoscraft.mod.renderer;

import net.Aethoscraft.mod.Aethoscraft;
import net.Aethoscraft.mod.entity.npc.EntityImpVendor;
import net.Aethoscraft.mod.models.ModelImp;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;

public class RenderImp extends RenderLiving{

private static final ResourceLocation DefTextures = new ResourceLocation(Aethoscraft.modid + ":" + "textures/model/entities/DefImp.png");

protected ModelImp modelEntity;

public RenderImp(ModelImp model, float f) {
	super(model, f);

	modelEntity = ((ModelImp)mainModel);
}

protected void renderEquippedItems(EntityImpVendor entity, float par2)
    {
        super.renderEquippedItems((EntityLiving)entity, par2);
    }
    
    protected void renderEquippedItems(EntityLivingBase entityLivingBase, float par2)
    {
        this.renderEquippedItems((EntityImpVendor)entityLivingBase, par2);
    }
    
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {

	return this.DefTextures;
}}

 

package net.Aethoscraft.mod.models;

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

public class ModelImp extends ModelBase
{
  //fields
    ModelRenderer RightLeg;
    ModelRenderer LeftLeg;
    ModelRenderer Chest;
    ModelRenderer Head;
    ModelRenderer LeftArm;
    ModelRenderer RightArm;
    ModelRenderer Nose;
    ModelRenderer LeftEar;
    ModelRenderer RightEar;
  
  public ModelImp()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      RightLeg = new ModelRenderer(this, 0, 9);
      RightLeg.addBox(0F, 0F, 0F, 2, 6, 2);
      RightLeg.setRotationPoint(-4F, 18F, 0F);
      RightLeg.setTextureSize(64, 64);
      RightLeg.mirror = true;
      setRotation(RightLeg, 0F, 0F, 0F);
      LeftLeg = new ModelRenderer(this, 0, 9);
      LeftLeg.addBox(0F, 0F, 0F, 2, 6, 2);
      LeftLeg.setRotationPoint(1F, 18F, 0F);
      LeftLeg.setTextureSize(64, 64);
      LeftLeg.mirror = true;
      setRotation(LeftLeg, 0F, 0F, 0F);
      Chest = new ModelRenderer(this, 0, 0);
      Chest.addBox(0F, 0F, 0F, 7, 7, 2);
      Chest.setRotationPoint(-4F, 11F, 0F);
      Chest.setTextureSize(64, 64);
      Chest.mirror = true;
      setRotation(Chest, 0F, 0F, 0F);
      Head = new ModelRenderer(this, 0, 17);
      Head.addBox(0F, 0F, 0F, 5, 4, 4);
      Head.setRotationPoint(-3F, 7F, -1F);
      Head.setTextureSize(64, 64);
      Head.mirror = true;
      setRotation(Head, 0F, 0F, 0F);
      LeftArm = new ModelRenderer(this, 0, 25);
      LeftArm.addBox(0F, 0F, 0F, 2, 6, 2);
      LeftArm.setRotationPoint(3F, 11F, 0F);
      LeftArm.setTextureSize(64, 64);
      LeftArm.mirror = true;
      setRotation(LeftArm, 0F, 0F, 0F);
      RightArm = new ModelRenderer(this, 0, 25);
      RightArm.addBox(0F, 0F, 0F, 2, 6, 2);
      RightArm.setRotationPoint(-6F, 11F, 0F);
      RightArm.setTextureSize(64, 64);
      RightArm.mirror = true;
      setRotation(RightArm, 0F, 0F, 0F);
      Nose = new ModelRenderer(this, 9, 10);
      Nose.addBox(0F, 0F, 0F, 1, 1, 2);
      Nose.setRotationPoint(-1F, 9F, -3F);
      Nose.setTextureSize(64, 64);
      Nose.mirror = true;
      setRotation(Nose, 0F, 0F, 0F);
      LeftEar = new ModelRenderer(this, 18, 25);
      LeftEar.addBox(0F, 0F, 0F, 0, 2, 5);
      LeftEar.setRotationPoint(2F, 7F, 0F);
      LeftEar.setTextureSize(64, 64);
      LeftEar.mirror = true;
      setRotation(LeftEar, 0F, 0.8551081F, 0F);
      RightEar = new ModelRenderer(this, 8, 25);
      RightEar.addBox(0F, 0F, 0F, 0, 2, 5);
      RightEar.setRotationPoint(-3F, 7F, 0F);
      RightEar.setTextureSize(64, 64);
      RightEar.mirror = true;
      setRotation(RightEar, 0F, -0.8551081F, 0F);
  }
  
  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);
    RightLeg.render(f5);
    LeftLeg.render(f5);
    Chest.render(f5);
    Head.render(f5);
    LeftArm.render(f5);
    RightArm.render(f5);
    Nose.render(f5);
    LeftEar.render(f5);
    RightEar.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 entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    
    this.Head.rotateAngleY = f3 / (180F / (float)Math.PI);
    this.Head.rotateAngleX = f4 / (180F / (float)Math.PI);
    this.RightArm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 2.0F * f1 * 0.5F;
    this.LeftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
    this.RightArm.rotateAngleZ = 0.0F;
    this.LeftArm.rotateAngleZ = 0.0F;
    this.RightLeg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.LeftLeg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    this.RightLeg.rotateAngleY = 0.0F;
    this.LeftLeg.rotateAngleY = 0.0F;
  }

}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.