Animation in legs don't work.

Started by Neoelfeo on Tue, 12/12/2017 - 10:38

Topic category: Bugs and solutions

Last seen on 10:14, 13. Oct 2020
Joined Jun 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Animation in legs don't work.
Tue, 12/12/2017 - 10:48 (edited)

 There is an option to choose what piece is a leg, head or an arm

it use to work fine, even with custom models.

it used to work fine, even with custom models.

But now it doesn't work anymore, my Mcreator version is 1.7.3 for Minecraft 1.7.10

watch the legs

watch her legs, they are totaly still.

Here is my code, please check it out.

package mod.mcreator;

import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.World;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelBase;

import java.util.Random;

import cpw.mods.fml.relauncher.SideOnly;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.client.registry.RenderingRegistry;

@SuppressWarnings("unchecked")
public class mcreator_aldean2 {

	public static int mobid = 0;
	public Object instance;

	public void load() {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public int addFuel(ItemStack fuel) {
		return 0;
	}

	@SideOnly(Side.CLIENT)
	public void registerRenderers() {
		RenderingRegistry.registerEntityRenderingHandler(mcreator_aldean2.Entityaldean2.class,
				new RenderLiving(new mcreator_aldean2.ModelAldean(), 0) {
					protected ResourceLocation getEntityTexture(Entity par1Entity) {
						return new ResourceLocation("Aldean.png");
					}
				});

	}

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
		int entityID = EntityRegistry.findGlobalUniqueEntityId();
		mobid = entityID;
		EntityRegistry.registerGlobalEntityID(mcreator_aldean2.Entityaldean2.class, "aldean2", entityID);
		EntityRegistry.registerModEntity(mcreator_aldean2.Entityaldean2.class, "aldean2", entityID, instance, 64, 1, true);
		EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, (0 << 16) + (61 << 8) + 86, (56 << 16)
				+ (45 << 8) + 26));
		EntityRegistry.addSpawn(mcreator_aldean2.Entityaldean2.class, 0, 1, 1, EnumCreatureType.creature, new BiomeGenBase[]{BiomeGenBase.ocean,
				BiomeGenBase.plains, BiomeGenBase.desert, BiomeGenBase.extremeHills, BiomeGenBase.forest, BiomeGenBase.taiga, BiomeGenBase.swampland,
				BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.icePlains, BiomeGenBase.iceMountains,
				BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.beach, BiomeGenBase.desertHills,
				BiomeGenBase.forestHills, BiomeGenBase.taigaHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.jungle, BiomeGenBase.jungleHills,
				BiomeGenBase.jungleEdge, BiomeGenBase.deepOcean, BiomeGenBase.stoneBeach, BiomeGenBase.coldBeach, BiomeGenBase.birchForest,
				BiomeGenBase.birchForestHills, BiomeGenBase.roofedForest, BiomeGenBase.coldTaiga, BiomeGenBase.coldTaigaHills,
				BiomeGenBase.megaTaiga, BiomeGenBase.megaTaigaHills, BiomeGenBase.extremeHillsPlus, BiomeGenBase.savanna,
				BiomeGenBase.savannaPlateau, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau_F, BiomeGenBase.mesaPlateau});

	}

	/*
	 * public Entity spawnEntity(int var1, World var2, double var3, double var5,
	 * double var7) { if(var1==mobid) return new
	 * mcreator_aldean2.Entityaldean2(var2); else return null; }
	 */

	public static class Entityaldean2 extends EntityVillager {
		World world = null;

		public Entityaldean2(World var1) {
			super(var1);
			world = var1;
			experienceValue = 5;
			this.isImmuneToFire = false;
			addRandomArmor();
			this.tasks.addTask(0, new EntityAISwimming(this));
			this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
			this.tasks.addTask(8, new EntityAILookIdle(this));

		}

		protected void addRandomArmor() {

		}

		protected void dropRareDrop(int par1) {
			this.dropItem(mcreator_goldCoin.block, 1);
		}

		public boolean isAIEnabled() {
			return true;
		}

		@Override
		protected Item getDropItem() {
			return new ItemStack(Items.rotten_flesh).getItem();
		}

		/**
		 * Returns the sound this mob makes while it's alive.
		 */
		protected String getLivingSound() {
			return "";
		}

		/**
		 * Returns the sound this mob makes when it is hurt.
		 */
		protected String getHurtSound() {
			return "";
		}

		/**
		 * Returns the sound this mob makes on death.
		 */
		protected String getDeathSound() {
			return "";
		}

		public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
			super.onStruckByLightning(entityLightningBolt);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		protected void fall(float l) {
			super.fall(l);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			super.fall(l);
			Entity entity = this;

		}

		public void onDeath(DamageSource dsource) {
			super.onDeath(dsource);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		public void onKillEntity(EntityLiving entityLiving) {
			super.onKillEntity(entityLiving);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		public boolean interact(EntityPlayer entity) {
			super.interact(entity);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;

			return true;
		}

		public String getEntityName() {
			return "aldean2";
		}

	}

	// Date: 12/12/2017 3:06:07
	// Template version 1.1
	// Java generated by Techne
	// Keep in mind that you still need to fill in some blanks
	// - ZeuX

	public static class ModelAldean extends ModelBase {
		// fields
		ModelRenderer body;
		ModelRenderer arms;
		ModelRenderer rightleg;
		ModelRenderer leftleg;
		ModelRenderer body2;
		ModelRenderer headM;
          ModelRenderer head;
          ModelRenderer nose;
          ModelRenderer hair;

		public ModelAldean() {
			textureWidth = 128;
			textureHeight = 64;

			body = new ModelRenderer(this, 16, 16);
			body.addBox(-4F, 0F, -2F, 8, 6, 4);
			body.setRotationPoint(0F, 0F, 0F);
			body.setTextureSize(128, 64);
			body.mirror = true;
			setRotation(body, -0.1570796F, 0F, 0F);
			arms = new ModelRenderer(this, 40, 16);
			arms.addBox(-3F, -2F, -2F, 16, 7, 3);
			arms.setRotationPoint(-5F, 3F, -1F);
			arms.setTextureSize(128, 64);
			arms.mirror = true;
			setRotation(arms, -0.7102147F, 0F, 0F);
			rightleg = new ModelRenderer(this, 0, 16);
			rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
			rightleg.setRotationPoint(-2F, 12F, 0F);
			rightleg.setTextureSize(128, 64);
			rightleg.mirror = true;
			setRotation(rightleg, 0F, 0F, 0F);
			leftleg = new ModelRenderer(this, 0, 16);
			leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
			leftleg.setRotationPoint(2F, 12F, 0F);
			leftleg.setTextureSize(128, 64);
			leftleg.mirror = true;
			setRotation(leftleg, 0F, 0F, 0F);
			body2 = new ModelRenderer(this, 16, 27);
			body2.addBox(-4F, 6F, -3F, 8, 6, 4);
			body2.setRotationPoint(0F, 0F, -1F);
			body2.setTextureSize(128, 64);
			body2.mirror = true;
			setRotation(body2, 0.1532585F, 0F, 0F);
			headM = new ModelRenderer(this, "headM");
			headM.setRotationPoint(0F, 0F, 0F);
			setRotation(headM, 0F, 0F, 0F);
			headM.mirror = true;
			head = new ModelRenderer(this, 0, 0);
			head.addBox(-4F, -8F, -4F, 8, 8, 8);
			head.setRotationPoint(0F, 0F, 0F);
			head.setTextureSize(128, 64);
			head.mirror = true;
			setRotation(head, 0F, 0F, 0F);
			hair = new ModelRenderer(this, 0, 39);
			hair.addBox(-5F, -9F, -5F, 10, 12, 10);
			hair.setRotationPoint(0F, 0F, 0F);
			hair.setTextureSize(128, 64);
			hair.mirror = true;
			setRotation(hair, 0F, 0F, 0F);
			nose = new ModelRenderer(this, 17, 2);
			nose.addBox(-1F, 0F, 0F, 2, 2, 1);
			nose.setRotationPoint(0F, -3F, -5F);
			nose.setTextureSize(128, 64);
			nose.mirror = true;
			setRotation(nose, 0F, 0F, 0F);
			headM.addChild(head);
			headM.addChild(nose);
			headM.addChild(hair);
		}

		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);
			body.render(f5);
			arms.render(f5);
			rightleg.render(f5);
			leftleg.render(f5);
			body2.render(f5);
			headM.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.headM.rotateAngleY = f3 / (180F / (float)Math.PI);
			this.headM.rotateAngleX = f4 / (180F / (float)Math.PI);
		}

	}

}

 

I also try adding this lines of code:

 

this.leftleg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
this.rightleg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;

But this error comes up:

Hate this

 

Edited by Neoelfeo on Tue, 12/12/2017 - 10:48
Last seen on 14:08, 15. Mar 2018
Joined Feb 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Hello, replace this code…
Mon, 03/05/2018 - 16:48

Hello, replace this code with your "public void setRotationAngles" code at the end of your mob's code.

(If your mob's leftleg, rightleg, rightarm and leftarm not so called like those in my code, then change the name of your mob's leftleg, rightleg, rightarm and leftarm with those in the code)

Code:

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

        {
            super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
            this.leftleg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
            this.rightleg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
            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;
        }

    }

}

Last seen on 14:08, 15. Mar 2018
Joined Feb 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Oh, and put this code on the…
Mon, 03/05/2018 - 17:16

Oh, and put this code on the top of your mob's code(This code is very important):

import net.minecraft.util.MathHelper;

 

And if you have make your mob ridetable replace this code under the "protected void dropRareDrop" code with your code(But if your mob is not ridetable, then you don't need this code):

        public void moveEntityWithHeading(float par1, float par2) {
            if (this.riddenByEntity != null) {
                this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
                this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
                this.setRotation(this.rotationYaw, this.rotationPitch);
                this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
                par1 = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
                par2 = ((EntityLivingBase) this.riddenByEntity).moveForward;
                this.stepHeight = 1.0F;
                this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
                if (!this.worldObj.isRemote) {
                    this.setAIMoveSpeed((float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
                    super.moveEntityWithHeading(par1, par2);
                }
                this.prevLimbSwingAmount = this.limbSwingAmount;
                double d0 = this.posX - this.prevPosX;
                double d1 = this.posZ - this.prevPosZ;
                float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F;
                if (f4 > 1.0F) {
                    f4 = 1.0F;
                }
                this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
                this.limbSwing += this.limbSwingAmount;
            } else {
                this.stepHeight = 0.5F;
                this.jumpMovementFactor = 0.02F;
                super.moveEntityWithHeading(par1, par2);
            }
        }