Fixed seaponies

This commit is contained in:
Sollace 2018-12-09 23:02:04 +02:00
parent 5f01814441
commit 21fab5e5fe
5 changed files with 156 additions and 76 deletions

View file

@ -129,11 +129,77 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
swingItem(entity); swingItem(entity);
if (isCrouching()) { if (isCrouching()) {
adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); ponyCrouch();
sneakLegs();
setHead(0, 6, -2);
} else if (isRiding) { } else if (isRiding) {
adjustBodyRiding(); ponyRide();
} else {
adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(ticks);
setHead(0, 0, 0);
}
if (isSleeping) {
ponySleep();
}
animateWears();
snout.setGender(metadata.getGender());
}
@Override
public float getWobbleAmount() {
if (swingProgress <= 0) {
return 0;
}
return MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F;
}
/**
* Aligns legs to a sneaky position.
*/
protected void ponyCrouch() {
adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
setHead(0, 6, -2);
bipedRightArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
}
protected void ponySleep() {
bipedRightArm.rotateAngleX = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90;
setHead(1, 2, isSneak ? -1 : 1);
AbstractBoxRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6);
AbstractBoxRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6);
AbstractBoxRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8);
AbstractBoxRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
}
protected void ponyRide() {
if (isRidingInteractive) {
adjustBodyComponents(BODY_ROT_X_RIDING * 2, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK * 2, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK - 4);
setHead(0, -2, -5);
} else {
adjustBodyComponents(BODY_ROT_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
setHead(0, 0, 0);
}
bipedLeftLeg.rotationPointZ = 15; bipedLeftLeg.rotationPointZ = 15;
bipedLeftLeg.rotationPointY = 9; bipedLeftLeg.rotationPointY = 9;
bipedLeftLeg.rotateAngleX = -PI / 4; bipedLeftLeg.rotateAngleX = -PI / 4;
@ -160,50 +226,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
bipedRightLeg.rotationPointZ = 10; bipedRightLeg.rotationPointZ = 10;
bipedRightLeg.rotationPointY = 7; bipedRightLeg.rotationPointY = 7;
bipedLeftArm.rotateAngleX = PI / 6; bipedLeftArm.rotateAngleX = PI / 6;
bipedRightArm.rotateAngleX = PI / 6; bipedRightArm.rotateAngleX = PI / 6;
bipedLeftArm.rotateAngleZ *= 2; bipedLeftArm.rotateAngleZ *= 2;
bipedRightArm.rotateAngleZ *= 2; bipedRightArm.rotateAngleZ *= 2;
} }
} else {
adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(ticks);
setHead(0, 0, 0);
}
if (isSleeping) ponySleep();
animateWears();
snout.setGender(metadata.getGender());
}
public float getWobbleAmount() {
if (swingProgress <= 0) {
return 0;
}
return MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F;
}
protected void adjustBodyRiding() {
if (isRidingInteractive) {
adjustBodyComponents(BODY_ROT_X_RIDING * 2, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK * 2, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK - 4);
setHead(0, -2, -5);
} else {
adjustBodyComponents(BODY_ROT_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
setHead(0, 0, 0);
}
} }
/** /**
@ -387,8 +415,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
} }
protected float getLegOutset() { protected float getLegOutset() {
if (isSleeping()) return 3.6f; if (isSleeping()) {
if (isCrouching()) return 1; return 3.6f;
}
if (isCrouching()) {
return 1;
}
return 5; return 5;
} }
@ -455,6 +489,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F); arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F);
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F;
arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
if (isSneak) { if (isSneak) {
arm.rotationPointY += 4; arm.rotationPointY += 4;
} }
@ -498,7 +533,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/ */
protected void swingArms(float ticks) { protected void swingArms(float ticks) {
if (isSleeping()) return; if (isSleeping()) {
return;
}
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
@ -533,30 +570,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
} }
/**
* Aligns legs to a sneaky position.
*/
protected void sneakLegs() {
bipedRightArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
}
protected void ponySleep() {
bipedRightArm.rotateAngleX = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90;
setHead(1, 2, isSneak ? -1 : 1);
AbstractBoxRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6);
AbstractBoxRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6);
AbstractBoxRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8);
AbstractBoxRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
}
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
boxList.clear(); boxList.clear();

View file

@ -88,6 +88,11 @@ public interface IModel extends ICapitated {
*/ */
float getSwingAmount(); float getSwingAmount();
/**
* Gets the step woddle used for various hair bits and animations.
*/
float getWobbleAmount();
/** /**
* Gets the y-offset applied to entities riding this one. * Gets the y-offset applied to entities riding this one.
*/ */

View file

@ -1,6 +1,7 @@
package com.minelittlepony.model.components; package com.minelittlepony.model.components;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.capabilities.IModel;
import com.minelittlepony.model.capabilities.IModelPart; import com.minelittlepony.model.capabilities.IModelPart;
import com.minelittlepony.render.model.PlaneRenderer; import com.minelittlepony.render.model.PlaneRenderer;
import com.minelittlepony.render.model.PonyRenderer; import com.minelittlepony.render.model.PonyRenderer;
@ -21,7 +22,11 @@ public class SeaponyTail implements IModelPart {
private PlaneRenderer tailTip; private PlaneRenderer tailTip;
private PlaneRenderer tailFins; private PlaneRenderer tailFins;
private IModel model;
public SeaponyTail(AbstractPonyModel model) { public SeaponyTail(AbstractPonyModel model) {
this.model = model;
tailBase = new PonyRenderer(model, 0, 38); tailBase = new PonyRenderer(model, 0, 38);
tailTip = new PlaneRenderer(model, 24, 0); tailTip = new PlaneRenderer(model, 24, 0);
tailFins = new PlaneRenderer(model, 56, 20); tailFins = new PlaneRenderer(model, 56, 20);
@ -32,8 +37,11 @@ public class SeaponyTail implements IModelPart {
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
tailBase.rotate(TAIL_ROTX, 0, 0).around(-2, 14, 8) tailBase.rotate(TAIL_ROTX, 0, 0)
.box( 0, 0, 0, 4, 6, 4, stretch).flip(); .offset(0, -4, -2)
.around(-2, 10, 8)
.box( 0, 0, 0, 4, 6, 4, stretch)
.flip();
tailTip.rotate(0, 0, 0).around(1, 5, 1) tailTip.rotate(0, 0, 0).around(1, 5, 1)
.box(0, 0, 0, 2, 6, 1, stretch); .box(0, 0, 0, 2, 6, 1, stretch);
@ -45,9 +53,7 @@ public class SeaponyTail implements IModelPart {
@Override @Override
public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) { public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) {
float rotation = MathHelper.sin(ticks * 0.536f) / 4; float rotation = model.isSleeping() ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
tailBase.offset(0, -4, -2).around(-2, 10, 8);
tailBase.rotateAngleX = TAIL_ROTX + rotation; tailBase.rotateAngleX = TAIL_ROTX + rotation;
tailTip.rotateAngleX = rotation; tailTip.rotateAngleX = rotation;

View file

@ -127,8 +127,8 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
} }
@Override @Override
protected void sneakLegs() { protected void ponyCrouch() {
super.sneakLegs(); super.ponyCrouch();
unicornArmRight.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; unicornArmRight.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
unicornArmLeft.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; unicornArmLeft.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ;
} }

View file

@ -1,6 +1,8 @@
package com.minelittlepony.model.ponies; package com.minelittlepony.model.ponies;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.ModelPonyArmor;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.model.components.SeaponyTail; import com.minelittlepony.model.components.SeaponyTail;
import com.minelittlepony.model.player.ModelUnicorn; import com.minelittlepony.model.player.ModelUnicorn;
import com.minelittlepony.pony.data.IPony; import com.minelittlepony.pony.data.IPony;
@ -27,6 +29,11 @@ public class ModelSeapony extends ModelUnicorn {
textureHeight = 64; textureHeight = 64;
} }
@Override
public PonyArmor createArmour() {
return new PonyArmor(new Armour(), new Armour());
}
@Override @Override
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(EntityLivingBase entity, IPony pony) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony);
@ -35,6 +42,16 @@ public class ModelSeapony extends ModelUnicorn {
isSneak = false; isSneak = false;
} }
@Override
protected void ponySleep() {
// noop
}
@Override
protected void ponyRide() {
// noop
}
@Override @Override
protected void initLegs(float yOffset, float stretch) { protected void initLegs(float yOffset, float stretch) {
super.initLegs(yOffset, stretch); super.initLegs(yOffset, stretch);
@ -75,11 +92,20 @@ public class ModelSeapony extends ModelUnicorn {
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float finAngle = FIN_ROT_Y + MathHelper.cos(ticks / 10) / 5; float flapMotion = MathHelper.cos(ticks / 10) / 5;
if (isSleeping()) {
flapMotion /= 2;
}
float finAngle = FIN_ROT_Y + flapMotion;
leftFin.rotateAngleY = finAngle; leftFin.rotateAngleY = finAngle;
rightFin.rotateAngleY = -finAngle; rightFin.rotateAngleY = -finAngle;
centerFin.rotateAngleZ = MathHelper.cos(ticks / 10) / 5;
if (!isSleeping()) {
centerFin.rotateAngleZ = flapMotion;
}
if (!entity.isInWater()) { if (!entity.isInWater()) {
bipedLeftArm.rotateAngleX -= 0.5F; bipedLeftArm.rotateAngleX -= 0.5F;
@ -101,7 +127,6 @@ public class ModelSeapony extends ModelUnicorn {
bipedRightArm.rotateAngleY += 0.3F; bipedRightArm.rotateAngleY += 0.3F;
} }
@Override @Override
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) { protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
super.rotateLegsOnGround(move, swing, ticks, entity); super.rotateLegsOnGround(move, swing, ticks, entity);
@ -117,6 +142,8 @@ public class ModelSeapony extends ModelUnicorn {
@Override @Override
public void transform(BodyPart part) { public void transform(BodyPart part) {
GlStateManager.translate(0, 0.6F, 0); GlStateManager.translate(0, 0.6F, 0);
super.transform(part);
} }
@Override @Override
@ -155,4 +182,33 @@ public class ModelSeapony extends ModelUnicorn {
bipedLeftLegwear.showModel = false; bipedLeftLegwear.showModel = false;
bipedRightLegwear.showModel = false; bipedRightLegwear.showModel = false;
} }
class Armour extends ModelPonyArmor {
@Override
public void showBoots() {
bipedRightArm.showModel = true;
bipedLeftArm.showModel = true;
}
@Override
public void updateLivingState(EntityLivingBase entity, IPony pony) {
super.updateLivingState(entity, pony);
// Seaponies can't sneak, silly
isSneak = false;
}
@Override
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
super.rotateLegsOnGround(move, swing, ticks, entity);
}
@Override
public void transform(BodyPart part) {
GlStateManager.translate(0, 0.6F, 0);
super.transform(part);
}
}
} }