Skip to content

Commit

Permalink
Fix choppy shark animations
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Dec 13, 2019
1 parent f7e0d80 commit df9a726
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package its_meow.betteranimalsplus.client.model;

import its_meow.betteranimalsplus.common.entity.EntityShark;
import its_meow.betteranimalsplus.util.ModMathHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -222,16 +225,22 @@ public ModelShark() {

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
if ((Math.abs(entity.motionY) > 0 && (Math.abs(entity.motionX) > 0.05 || Math.abs(entity.motionZ) > 0.05)) || Math.abs(entity.motionY) > 0.25) {
float rotX = -((float) Math.atan(entity.motionY / Math.sqrt(Math.pow(entity.motionX, 2) + Math.pow(entity.motionZ, 2))) / 1.5F);
if (rotX < 0) {
rotX /= 3;
if(entity instanceof EntityShark) {
EntityShark shark = (EntityShark) entity;
if ((Math.abs(entity.motionY) > 0.01 && (Math.abs(entity.motionX) > 0.01 || Math.abs(entity.motionZ) > 0.01)) || Math.abs(entity.motionY) > 0.03) {
float rotX = -((float) Math.atan(entity.motionY / Math.sqrt(Math.pow(entity.motionX, 2) + Math.pow(entity.motionZ, 2))) / 1.5F);
if (rotX < 0) {
rotX /= 2;
}
rotX += 0.022863813201125717F;
rotX = ModMathHelper.interpolateRotation(shark.lastBodyRotation, rotX, Minecraft.getMinecraft().getRenderPartialTicks());
this.body.rotateAngleX = rotX;
shark.lastBodyRotation = rotX;
} else {
this.body.rotateAngleX = 0.022863813201125717F;
}
this.body.rotateAngleX = rotX + 0.022863813201125717F;
} else {
this.body.rotateAngleX = 0.022863813201125717F;
}
if(entity.motionX > 0.02F || entity.motionZ > 0.02F) {
if(entity.motionX > 0.02F || entity.motionZ > 0.02F || Math.abs(entity.motionY) > 0.02F) {
float mul = 100F;
this.tail00.rotateAngleY = MathHelper.cos(f2 * 0.0025F * mul) * 0.15F;
this.tail01.rotateAngleY = MathHelper.cos(f2 * 0.0025F * mul) * 0.15F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class EntityShark extends EntitySharkBase implements IVariantTypes {
private float lastAttack = 0;
private float lastGrab = 0;
private float lastTickHealth = 0;
public float lastBodyRotation = 0;

public EntityShark(World world) {
super(world);
Expand Down

0 comments on commit df9a726

Please sign in to comment.