How to change a model during an action

Started by Adinot on Thu, 06/25/2020 - 17:21

Topic category: Help with MCreator software

Last seen on 11:37, 6. Sep 2020
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to change a model during an action
Thu, 06/25/2020 - 17:21

Hello, I am creating a mod with animals, and I have added birds and is it possible to change the model of the birds as soon as it starts to fly and as soon as it returns to the ground it resumes the basic model ?

 

Last seen on 11:53, 5. May 2021
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I don't know a way to change…
Fri, 06/26/2020 - 01:48

I don't know a way to change models, but I know how to change model animations depending on the situation, although it requires messing with the code a little.

I managed to do this to make my raptor creature open its mouth and rear back whenever it is not on ground.

If you care to read through, take a look at http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-creating.html . Otherwise, here's the short version:

See the part of the code with the void setRotationAngles, where you manage the creature's animations

public void setRotationAngles(Entity e, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
			this.body.rotateAngleX = 0F;
			
			//head
			this.head.rotateAngleY = netHeadYaw / (180F / (float) Math.PI);
			this.head.rotateAngleX = (headPitch / (180F / (float) Math.PI)) + (float) Math.PI / 4F ;

			//legs
            this.legl.rotateAngleX = MathHelper.cos(limbSwing * 1F) * 1F * limbSwingAmount;
            this.legr.rotateAngleX = MathHelper.cos(limbSwing * 1F + (float) Math.PI) * 1F * limbSwingAmount;
			
			if (!e.onGround && !e.isInWater()) {
				this.body.rotateAngleX = - (float) (Math.PI / 6);
				this.head.rotateAngleX = (float) (Math.PI / 2);
				this.jaw.rotateAngleX = (float) (Math.PI / 4);

				
				
			} else {
				this.jaw.rotateAngleX = (float) (Math.PI / 18);
			}
		}

With "e" standing for my entity, I can make checks like 

if (e.onGround) {
    // do ground animations
} else {
    // do flying animations
}

There are other parameters you can check like inLava, inWater, dimension, getEquipment, getFireTimer etc you can mess with!

Last seen on 11:37, 6. Sep 2020
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thank you very much for your…
Fri, 06/26/2020 - 14:43

Thank you very much for your help ^^*