mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 20:47:59 +01:00
Change the swimming animation (again) and add some motion lerp
This commit is contained in:
parent
39b491b5ed
commit
9314089484
2 changed files with 25 additions and 20 deletions
|
@ -12,6 +12,7 @@ import com.minelittlepony.pony.data.PonyData;
|
||||||
import com.minelittlepony.pony.data.PonySize;
|
import com.minelittlepony.pony.data.PonySize;
|
||||||
import com.minelittlepony.render.model.PlaneRenderer;
|
import com.minelittlepony.render.model.PlaneRenderer;
|
||||||
import com.minelittlepony.render.model.PonyRenderer;
|
import com.minelittlepony.render.model.PonyRenderer;
|
||||||
|
import com.minelittlepony.util.math.MathUtil;
|
||||||
import com.minelittlepony.util.render.AbstractBoxRenderer;
|
import com.minelittlepony.util.render.AbstractBoxRenderer;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
@ -54,6 +55,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
||||||
*/
|
*/
|
||||||
protected boolean rainboom;
|
protected boolean rainboom;
|
||||||
|
|
||||||
|
protected double motionLerp;
|
||||||
|
|
||||||
public PlaneRenderer upperTorso;
|
public PlaneRenderer upperTorso;
|
||||||
public PlaneRenderer neck;
|
public PlaneRenderer neck;
|
||||||
|
|
||||||
|
@ -73,8 +76,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
||||||
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
|
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
|
||||||
*/
|
*/
|
||||||
protected void checkRainboom(Entity entity, float swing) {
|
protected void checkRainboom(Entity entity, float swing) {
|
||||||
|
double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ);
|
||||||
|
|
||||||
rainboom = (isFlying() && canFly()) || isElytraFlying();
|
rainboom = (isFlying() && canFly()) || isElytraFlying();
|
||||||
rainboom &= Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
|
rainboom &= zMotion > 0.4F;
|
||||||
|
|
||||||
|
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLivingState(EntityLivingBase entity, IPony pony) {
|
public void updateLivingState(EntityLivingBase entity, IPony pony) {
|
||||||
|
@ -299,26 +306,21 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
||||||
*/
|
*/
|
||||||
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
|
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
|
||||||
|
|
||||||
float forward = ROTATE_270 - ROTATE_90/3;
|
float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * (float)motionLerp;
|
||||||
float down = ROTATE_90;
|
|
||||||
|
|
||||||
float leftX = down + MathHelper.sin((move / 3) + 2*PI/3) / 2;
|
float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)motionLerp;
|
||||||
float leftY = -forward - MathHelper.sin((move / 3) + 2*PI/3);
|
float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)motionLerp;
|
||||||
|
|
||||||
float rightX = down + MathHelper.sin(move / 3) / 2;
|
bipedLeftArm.rotateAngleX = -left;
|
||||||
float rightY = down - MathHelper.sin((move / 3) + 2);
|
bipedLeftArm.rotateAngleY = -left/2;
|
||||||
|
bipedLeftArm.rotateAngleZ = left/2;
|
||||||
|
|
||||||
|
bipedRightArm.rotateAngleX = -right;
|
||||||
|
bipedRightArm.rotateAngleY = right/2;
|
||||||
|
bipedRightArm.rotateAngleZ = -right/2;
|
||||||
|
|
||||||
bipedLeftArm.rotateAngleX = -leftX;
|
bipedLeftLeg.rotateAngleX = legLeft;
|
||||||
bipedLeftArm.rotateAngleY = -rightY/4 - leftX/3;
|
bipedRightLeg.rotateAngleX = right;
|
||||||
bipedLeftArm.rotateAngleZ = -leftY/10 - leftX/3;
|
|
||||||
|
|
||||||
bipedRightArm.rotateAngleX = -rightX;
|
|
||||||
bipedRightArm.rotateAngleY = -leftY/4 - leftX/3;
|
|
||||||
bipedRightArm.rotateAngleZ = -rightY/10 - leftX/3;
|
|
||||||
|
|
||||||
bipedLeftLeg.rotateAngleX = leftX;
|
|
||||||
bipedRightLeg.rotateAngleX = rightX;
|
|
||||||
|
|
||||||
bipedLeftLeg.rotateAngleY = 0;
|
bipedLeftLeg.rotateAngleY = 0;
|
||||||
bipedRightLeg.rotateAngleY = 0;
|
bipedRightLeg.rotateAngleY = 0;
|
||||||
|
@ -724,7 +726,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCrouching() {
|
public boolean isCrouching() {
|
||||||
return !rainboom && isSneak && !isFlying;
|
return !rainboom && !isSwimming && isSneak && !isFlying;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,11 +2,12 @@ package com.minelittlepony.transform;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
import com.minelittlepony.util.math.MathUtil;
|
||||||
|
|
||||||
public class PostureSwimming extends PostureFlight {
|
public class PostureSwimming extends PostureFlight {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
||||||
|
|
||||||
motionX *= 2;
|
motionX *= 2;
|
||||||
motionZ *= 2;
|
motionZ *= 2;
|
||||||
|
|
||||||
|
@ -15,6 +16,8 @@ public class PostureSwimming extends PostureFlight {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
||||||
return super.calculateIncline(player, motionX, motionY, motionZ);
|
double motionLerp = MathUtil.clampLimit(Math.sqrt(motionX * motionX + motionZ * motionZ) * 30, 1);
|
||||||
|
|
||||||
|
return super.calculateIncline(player, motionX, motionY, motionZ) * motionLerp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue