Skip to content

Commit

Permalink
Hopefully this fixes the crash with pose animation
Browse files Browse the repository at this point in the history
  • Loading branch information
mchorse committed Feb 7, 2021
1 parent bfbc710 commit ef468a2
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions src/main/java/mchorse/blockbuster_pack/morphs/CustomMorph.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public ModelPose getPose(EntityLivingBase target, boolean ignoreCustom, float pa
{
ModelPose pose = this.getCurrentPose(target, ignoreCustom);

if (this.animation.isInProgress())
if (this.animation.isInProgress() && pose != null)
{
return this.animation.calculatePose(pose, partialTicks);
}
Expand Down Expand Up @@ -481,12 +481,12 @@ public void update(EntityLivingBase target)

if (target.world.isRemote)
{
this.updateCape(target);
this.updateCapeVariables(target);
}
}

@SideOnly(Side.CLIENT)
private void updateCape(EntityLivingBase target)
private void updateCapeVariables(EntityLivingBase target)
{
this.prevCapeX = this.capeX;
this.prevCapeY = this.capeY;
Expand All @@ -495,48 +495,29 @@ private void updateCape(EntityLivingBase target)
double dX = target.posX - this.capeX;
double dY = target.posY - this.capeY;
double dZ = target.posZ - this.capeZ;
double distance = 10.0D;
double multiplier = 0.25D;

if (dX > distance)
if (Math.abs(dX) > 10)
{
this.capeX = target.posX;
this.prevCapeX = this.capeX;
}

if (dZ > distance)
{
this.capeZ = target.posZ;
this.prevCapeZ = this.capeZ;
}

if (dY > distance)
if (Math.abs(dY) > 10)
{
this.capeY = target.posY;
this.prevCapeY = this.capeY;
}

if (dX < -distance)
{
this.capeX = target.posX;
this.prevCapeX = this.capeX;
}

if (dZ < -distance)
if (Math.abs(dZ) > 10)
{
this.capeZ = target.posZ;
this.prevCapeZ = this.capeZ;
}

if (dY < -distance)
{
this.capeY = target.posY;
this.prevCapeY = this.capeY;
}

this.capeX += dX * multiplier;
this.capeZ += dZ * multiplier;
this.capeY += dY * multiplier;
this.capeZ += dZ * multiplier;
}

@Override
Expand Down

0 comments on commit ef468a2

Please sign in to comment.