mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07:59 +01:00
Update some things and remove PonyModelConstants
This commit is contained in:
parent
ec2a901ee2
commit
5f1dcf1647
28 changed files with 205 additions and 256 deletions
|
@ -26,7 +26,9 @@ public interface IModel {
|
||||||
/**
|
/**
|
||||||
* Gets the skin metadata associated with this model.
|
* Gets the skin metadata associated with this model.
|
||||||
*/
|
*/
|
||||||
IPonyData getMetadata();
|
default IPonyData getMetadata() {
|
||||||
|
return getAttributes().metadata;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the pony metadata object associated with this model.
|
* Sets the pony metadata object associated with this model.
|
||||||
|
@ -42,8 +44,13 @@ public interface IModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this model is riding a boat, horse, or other animals.
|
* Returns true if this model is riding a boat, horse, or other animals.
|
||||||
|
*
|
||||||
|
* @deprecated User model#getAttributes().isSitting
|
||||||
*/
|
*/
|
||||||
boolean isRiding();
|
@Deprecated
|
||||||
|
default boolean isRiding() {
|
||||||
|
return getAttributes().isSitting;
|
||||||
|
}
|
||||||
|
|
||||||
default Race getRace() {
|
default Race getRace() {
|
||||||
return PonyConfig.getEffectiveRace(getMetadata().getRace());
|
return PonyConfig.getEffectiveRace(getMetadata().getRace());
|
||||||
|
@ -70,7 +77,7 @@ public interface IModel {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * PonyModelConstants.PI * 2) * 0.04F;
|
return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * MathHelper.PI * 2) * 0.04F;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.api.model;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
public interface IPart extends PonyModelConstants {
|
public interface IPart {
|
||||||
/**
|
/**
|
||||||
* Sets the model's various rotation angles.
|
* Sets the model's various rotation angles.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -2,8 +2,12 @@ package com.minelittlepony.api.model;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.client.MineLittlePony;
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
public interface IPegasus extends IModel {
|
public interface IPegasus extends IModel {
|
||||||
|
public static final float WINGS_HALF_SPREAD_ANGLE = MathUtil.Angles._270_DEG;
|
||||||
|
public static final float WINGS_FULL_SPREAD_ANGLE = MathUtil.Angles._270_DEG + 0.4F;
|
||||||
|
public static final float WINGS_RAISED_ANGLE = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the wings are spread.
|
* Returns true if the wings are spread.
|
||||||
|
|
|
@ -14,10 +14,6 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.ROTATE_270;
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.WING_ROT_Z_SNEAK;
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.WING_ROT_Z_FLYING;
|
|
||||||
|
|
||||||
public class ModelAttributes {
|
public class ModelAttributes {
|
||||||
/**
|
/**
|
||||||
* True if the model is sleeping in a bed.
|
* True if the model is sleeping in a bed.
|
||||||
|
@ -128,12 +124,12 @@ public class ModelAttributes {
|
||||||
|
|
||||||
private float calcWingRotationFactor(float ticks) {
|
private float calcWingRotationFactor(float ticks) {
|
||||||
if (isSwimming) {
|
if (isSwimming) {
|
||||||
return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270;
|
return (MathHelper.sin(ticks * 0.136f) / 2) + MathUtil.Angles._270_DEG;
|
||||||
}
|
}
|
||||||
if (isFlying) {
|
if (isFlying) {
|
||||||
return MathHelper.sin(ticks * 0.536f) + WING_ROT_Z_FLYING;
|
return MathHelper.sin(ticks * 0.536f) + IPegasus.WINGS_FULL_SPREAD_ANGLE;
|
||||||
}
|
}
|
||||||
return WING_ROT_Z_SNEAK;
|
return IPegasus.WINGS_RAISED_ANGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLivingState(LivingEntity entity, IPony pony, Mode mode) {
|
public void updateLivingState(LivingEntity entity, IPony pony, Mode mode) {
|
||||||
|
|
13
src/main/java/com/minelittlepony/api/model/Pivot.java
Normal file
13
src/main/java/com/minelittlepony/api/model/Pivot.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package com.minelittlepony.api.model;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.ModelPart;
|
||||||
|
|
||||||
|
public record Pivot(float x, float y, float z) {
|
||||||
|
public void set(ModelPart part) {
|
||||||
|
part.setPivot(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(ModelPart part) {
|
||||||
|
part.setPivot(part.pivotX + x, part.pivotY + y, part.pivotZ + z);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,55 +0,0 @@
|
||||||
package com.minelittlepony.api.model;
|
|
||||||
|
|
||||||
public interface PonyModelConstants {
|
|
||||||
float
|
|
||||||
PI = (float)Math.PI,
|
|
||||||
|
|
||||||
ROTATE_270 = 4.712F,
|
|
||||||
ROTATE_90 = 1.571F,
|
|
||||||
|
|
||||||
BASE_MODEL_SCALE = 15/16F,
|
|
||||||
|
|
||||||
BODY_ROT_X = 0,
|
|
||||||
BODY_ROT_X_SNEAK = 0.4F,
|
|
||||||
BODY_ROT_X_RIDING = PI * 3.8F,
|
|
||||||
|
|
||||||
BODY_RP_Y = 0,
|
|
||||||
BODY_RP_Y_SNEAK = 7,
|
|
||||||
BODY_RP_Y_RIDING = 1,
|
|
||||||
|
|
||||||
BODY_RP_Z = 0,
|
|
||||||
BODY_RP_Z_SNEAK = -4,
|
|
||||||
BODY_RP_Z_RIDING = 4,
|
|
||||||
|
|
||||||
FRONT_LEG_RP_Y = 8,
|
|
||||||
FRONT_LEG_RP_Y_SNEAK = 8,
|
|
||||||
|
|
||||||
WING_ROT_Z_FLYING = ROTATE_270 + 0.4F,
|
|
||||||
WING_ROT_Z_SNEAK = 4,
|
|
||||||
|
|
||||||
LEG_ROT_X_SNEAK_ADJ = 0.4F,
|
|
||||||
|
|
||||||
LEG_SLEEP_OFFSET_Y = 2,
|
|
||||||
FRONT_LEG_SLEEP_OFFSET_Z = 6,
|
|
||||||
BACK_LEG_SLEEP_OFFSET_Z = -8,
|
|
||||||
|
|
||||||
TAIL_RP_Z = 14,
|
|
||||||
TAIL_RP_Z_SNEAK = 15,
|
|
||||||
|
|
||||||
TAIL_RP_Y_RIDING = 3,
|
|
||||||
TAIL_RP_Z_RIDING = 13,
|
|
||||||
|
|
||||||
HEAD_RP_X_SNEAK = 0,
|
|
||||||
HEAD_RP_Y_SNEAK = 6,
|
|
||||||
HEAD_RP_Z_SNEAK = -2,
|
|
||||||
|
|
||||||
HEAD_RP_X_SLEEP = 1,
|
|
||||||
HEAD_RP_Y_SLEEP = 2,
|
|
||||||
|
|
||||||
HEAD_RP_Y_SWIM = -2,
|
|
||||||
HEAD_RP_Z_SWIM = -4,
|
|
||||||
|
|
||||||
NECK_ROT_X = 0.166F,
|
|
||||||
|
|
||||||
FIN_ROT_Y = PI / 6;
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
||||||
import com.minelittlepony.api.pony.meta.Sizes;
|
import com.minelittlepony.api.pony.meta.Sizes;
|
||||||
import com.minelittlepony.client.transform.PonyTransformation;
|
import com.minelittlepony.client.transform.PonyTransformation;
|
||||||
import com.minelittlepony.client.util.render.RenderList;
|
import com.minelittlepony.client.util.render.RenderList;
|
||||||
import com.minelittlepony.mson.util.PartUtil;
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,6 +22,19 @@ import net.minecraft.util.math.*;
|
||||||
* Foundation class for all types of ponies.
|
* Foundation class for all types of ponies.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
|
public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
|
||||||
|
public static final float NECK_X = 0.166F;
|
||||||
|
public static final float LEG_SNEAKING_PITCH_ADJUSTMENT = 0.4F;
|
||||||
|
public static final float BODY_RIDING_PITCH = MathHelper.PI * 3.8F;
|
||||||
|
public static final float BODY_SNEAKING_PITCH = 0.4F;
|
||||||
|
public static final float FRONT_LEGS_Y = 8;
|
||||||
|
|
||||||
|
public static final Pivot ORIGIN = new Pivot(0, 0, 0);
|
||||||
|
public static final Pivot HEAD_SNEAKING = new Pivot(0, 6, -2);
|
||||||
|
public static final Pivot HEAD_SLEEPING = new Pivot(1, 2, 0);
|
||||||
|
public static final Pivot BODY_SNEAKING = new Pivot(0, 7, -4);
|
||||||
|
public static final Pivot BODY_RIDING = new Pivot(0, 1, 4);
|
||||||
|
public static final Pivot FONT_LEGS_SLEEPING = new Pivot(0, 2, 6);
|
||||||
|
public static final Pivot BACK_LEGS_SLEEPING = new Pivot(0, 2, -6);
|
||||||
|
|
||||||
protected final ModelPart neck;
|
protected final ModelPart neck;
|
||||||
|
|
||||||
|
@ -133,10 +146,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
} else if (riding) {
|
} else if (riding) {
|
||||||
ponySit();
|
ponySit();
|
||||||
} else {
|
} else {
|
||||||
adjustBody(BODY_ROT_X, BODY_RP_Y, BODY_RP_Z);
|
adjustBody(0, ORIGIN);
|
||||||
|
|
||||||
rightLeg.pivotY = FRONT_LEG_RP_Y;
|
rightLeg.pivotY = FRONT_LEGS_Y;
|
||||||
leftLeg.pivotY = FRONT_LEG_RP_Y;
|
leftLeg.pivotY = FRONT_LEGS_Y;
|
||||||
|
|
||||||
if (!attributes.isSleeping) {
|
if (!attributes.isSleeping) {
|
||||||
animateBreathing(animationProgress);
|
animateBreathing(animationProgress);
|
||||||
|
@ -165,76 +178,76 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
* Aligns legs to a sneaky position.
|
* Aligns legs to a sneaky position.
|
||||||
*/
|
*/
|
||||||
protected void ponyCrouch() {
|
protected void ponyCrouch() {
|
||||||
adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
|
adjustBody(BODY_SNEAKING_PITCH, BODY_SNEAKING);
|
||||||
head.setPivot(HEAD_RP_X_SNEAK, HEAD_RP_Y_SNEAK, HEAD_RP_Z_SNEAK);
|
HEAD_SNEAKING.set(head);
|
||||||
|
|
||||||
rightArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
|
rightArm.pitch -= LEG_SNEAKING_PITCH_ADJUSTMENT;
|
||||||
leftArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
|
leftArm.pitch -= LEG_SNEAKING_PITCH_ADJUSTMENT;
|
||||||
|
|
||||||
leftLeg.pivotY = FRONT_LEG_RP_Y_SNEAK;
|
leftLeg.pivotY = FRONT_LEGS_Y;
|
||||||
rightLeg.pivotY = FRONT_LEG_RP_Y_SNEAK;
|
rightLeg.pivotY = FRONT_LEGS_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ponySleep() {
|
protected void ponySleep() {
|
||||||
rightArm.pitch = -ROTATE_90;
|
rightArm.pitch = -MathUtil.Angles._90_DEG;
|
||||||
leftArm.pitch = -ROTATE_90;
|
leftArm.pitch = -MathUtil.Angles._90_DEG;
|
||||||
|
|
||||||
rightLeg.pitch = ROTATE_90;
|
rightLeg.pitch = MathUtil.Angles._90_DEG;
|
||||||
leftLeg.pitch = ROTATE_90;
|
leftLeg.pitch = MathUtil.Angles._90_DEG;
|
||||||
|
|
||||||
head.setPivot(HEAD_RP_X_SLEEP, HEAD_RP_Y_SLEEP, sneaking ? -1 : 1);
|
HEAD_SLEEPING.set(head);
|
||||||
|
head.pivotZ = sneaking ? -1 : 1;
|
||||||
|
|
||||||
PartUtil.shift(rightArm, 0, LEG_SLEEP_OFFSET_Y, FRONT_LEG_SLEEP_OFFSET_Z);
|
FONT_LEGS_SLEEPING.add(rightArm);
|
||||||
PartUtil.shift(leftArm, 0, LEG_SLEEP_OFFSET_Y, FRONT_LEG_SLEEP_OFFSET_Z);
|
FONT_LEGS_SLEEPING.add(leftArm);
|
||||||
PartUtil.shift(rightLeg, 0, LEG_SLEEP_OFFSET_Y, BACK_LEG_SLEEP_OFFSET_Z);
|
BACK_LEGS_SLEEPING.add(rightLeg);
|
||||||
PartUtil.shift(leftLeg, 0, LEG_SLEEP_OFFSET_Y, BACK_LEG_SLEEP_OFFSET_Z);
|
BACK_LEGS_SLEEPING.add(leftLeg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ponySit() {
|
protected void ponySit() {
|
||||||
|
adjustBodyComponents(BODY_RIDING_PITCH * (attributes.isRidingInteractive ? 2 : 1), BODY_RIDING);
|
||||||
if (attributes.isRidingInteractive) {
|
if (attributes.isRidingInteractive) {
|
||||||
adjustBodyComponents(BODY_ROT_X_RIDING * 2, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
|
neck.setPivot(NECK_X, 0, -4);
|
||||||
neck.setPivot(NECK_ROT_X + BODY_ROT_X * 2, BODY_RP_Y, BODY_RP_Z - 4);
|
|
||||||
head.setPivot(0, -2, -5);
|
head.setPivot(0, -2, -5);
|
||||||
} else {
|
} else {
|
||||||
adjustBodyComponents(BODY_ROT_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
|
neck.setPivot(NECK_X, 0, 0);
|
||||||
neck.setPivot(NECK_ROT_X + BODY_ROT_X, BODY_RP_Y, BODY_RP_Z);
|
|
||||||
head.setPivot(0, 0, 0);
|
head.setPivot(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
leftLeg.pivotZ = 14;
|
leftLeg.pivotZ = 14;
|
||||||
leftLeg.pivotY = 17;
|
leftLeg.pivotY = 17;
|
||||||
leftLeg.pitch = -PI / 4;
|
leftLeg.pitch = -MathHelper.PI / 4;
|
||||||
leftLeg.yaw = -PI / 7;
|
leftLeg.yaw = -MathHelper.PI / 7;
|
||||||
|
|
||||||
leftLeg.pitch += body.pitch;
|
leftLeg.pitch += body.pitch;
|
||||||
|
|
||||||
rightLeg.pivotZ = 15;
|
rightLeg.pivotZ = 15;
|
||||||
rightLeg.pivotY = 17;
|
rightLeg.pivotY = 17;
|
||||||
rightLeg.pitch = -PI / 4;
|
rightLeg.pitch = -MathHelper.PI / 4;
|
||||||
rightLeg.yaw = PI / 7;
|
rightLeg.yaw = MathHelper.PI / 7;
|
||||||
|
|
||||||
rightLeg.pitch += body.pitch;
|
rightLeg.pitch += body.pitch;
|
||||||
|
|
||||||
leftArm.roll = -PI * 0.06f;
|
leftArm.roll = -MathHelper.PI * 0.06f;
|
||||||
leftArm.pitch += body.pitch;
|
leftArm.pitch += body.pitch;
|
||||||
rightArm.roll = PI * 0.06f;
|
rightArm.roll = MathHelper.PI * 0.06f;
|
||||||
rightArm.pitch += body.pitch;
|
rightArm.pitch += body.pitch;
|
||||||
|
|
||||||
if (attributes.isRidingInteractive) {
|
if (attributes.isRidingInteractive) {
|
||||||
leftLeg.yaw = PI / 15;
|
leftLeg.yaw = MathHelper.PI / 15;
|
||||||
leftLeg.pitch = PI / 9;
|
leftLeg.pitch = MathHelper.PI / 9;
|
||||||
|
|
||||||
leftLeg.pivotZ = 10;
|
leftLeg.pivotZ = 10;
|
||||||
leftLeg.pivotY = 7;
|
leftLeg.pivotY = 7;
|
||||||
|
|
||||||
rightLeg.yaw = -PI / 15;
|
rightLeg.yaw = -MathHelper.PI / 15;
|
||||||
rightLeg.pitch = PI / 9;
|
rightLeg.pitch = MathHelper.PI / 9;
|
||||||
|
|
||||||
rightLeg.pivotZ = 10;
|
rightLeg.pivotZ = 10;
|
||||||
rightLeg.pivotY = 7;
|
rightLeg.pivotY = 7;
|
||||||
|
|
||||||
leftArm.pitch = PI / 6;
|
leftArm.pitch = MathHelper.PI / 6;
|
||||||
rightArm.pitch = PI / 6;
|
rightArm.pitch = MathHelper.PI / 6;
|
||||||
|
|
||||||
leftArm.roll *= 2;
|
leftArm.roll *= 2;
|
||||||
rightArm.roll *= 2;
|
rightArm.roll *= 2;
|
||||||
|
@ -285,10 +298,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
|
|
||||||
float lerp = entity.isSwimming() ? (float)attributes.motionLerp : 1;
|
float lerp = entity.isSwimming() ? (float)attributes.motionLerp : 1;
|
||||||
|
|
||||||
float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * lerp;
|
float legLeft = (MathUtil.Angles._90_DEG + MathHelper.sin((move / 3) + 2 * MathHelper.PI/3) / 2) * lerp;
|
||||||
|
|
||||||
float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * lerp;
|
float left = (MathUtil.Angles._90_DEG + MathHelper.sin((move / 3) + 2 * MathHelper.PI) / 2) * lerp;
|
||||||
float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * lerp;
|
float right = (MathUtil.Angles._90_DEG + MathHelper.sin(move / 3) / 2) * lerp;
|
||||||
|
|
||||||
leftArm.setAngles(-left, -left/2, left/2);
|
leftArm.setAngles(-left, -left/2, left/2);
|
||||||
rightArm.setAngles(-right, right/2, -right/2);
|
rightArm.setAngles(-right, right/2, -right/2);
|
||||||
|
@ -301,7 +314,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void rotateLegsOnGround(float move, float swing, float ticks, T entity) {
|
protected void rotateLegsOnGround(float move, float swing, float ticks, T entity) {
|
||||||
float angle = PI * (float) Math.pow(swing, 16);
|
float angle = MathHelper.PI * (float) Math.pow(swing, 16);
|
||||||
|
|
||||||
float baseRotation = move * 0.6662F; // magic number ahoy
|
float baseRotation = move * 0.6662F; // magic number ahoy
|
||||||
float scale = swing / 4;
|
float scale = swing / 4;
|
||||||
|
@ -313,10 +326,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
);
|
);
|
||||||
float yAngle = 0.2F * rainboomLegLotation;
|
float yAngle = 0.2F * rainboomLegLotation;
|
||||||
|
|
||||||
leftArm.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + angle) * scale, -ROTATE_90 * rainboomLegLotation), -yAngle, 0);
|
leftArm.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + angle) * scale, -MathUtil.Angles._90_DEG * rainboomLegLotation), -yAngle, 0);
|
||||||
rightArm.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + PI + angle / 2) * scale, -ROTATE_90 * rainboomLegLotation), yAngle, 0);
|
rightArm.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + MathHelper.PI + angle / 2) * scale, -MathUtil.Angles._90_DEG * rainboomLegLotation), yAngle, 0);
|
||||||
leftLeg.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale, ROTATE_90 * rainboomLegLotation), yAngle, leftLeg.roll);
|
leftLeg.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + MathHelper.PI - (angle * 0.4f)) * scale, MathUtil.Angles._90_DEG * rainboomLegLotation), yAngle, leftLeg.roll);
|
||||||
rightLeg.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + angle / 5) * scale, ROTATE_90 * rainboomLegLotation), -yAngle, rightLeg.roll);
|
rightLeg.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + angle / 5) * scale, MathUtil.Angles._90_DEG * rainboomLegLotation), -yAngle, rightLeg.roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float getLegOutset() {
|
protected float getLegOutset() {
|
||||||
|
@ -372,8 +385,8 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
|
|
||||||
float mult = 1 - swag/2;
|
float mult = 1 - swag/2;
|
||||||
arm.pitch = arm.pitch * mult - (PI / 10) * swag;
|
arm.pitch = arm.pitch * mult - (MathHelper.PI / 10) * swag;
|
||||||
arm.roll = -sigma * (PI / 15);
|
arm.roll = -sigma * (MathHelper.PI / 15);
|
||||||
|
|
||||||
if (attributes.isCrouching) {
|
if (attributes.isCrouching) {
|
||||||
arm.pivotX -= sigma * 2;
|
arm.pivotX -= sigma * 2;
|
||||||
|
@ -386,9 +399,9 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
break;
|
break;
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
arm.pitch = (arm.pitch / 2 - 0.9424779F) - 0.3F;
|
arm.pitch = (arm.pitch / 2 - 0.9424779F) - 0.3F;
|
||||||
arm.yaw = sigma * PI / 9;
|
arm.yaw = sigma * MathHelper.PI / 9;
|
||||||
if (complement == pose) {
|
if (complement == pose) {
|
||||||
arm.yaw -= sigma * PI / 18;
|
arm.yaw -= sigma * MathHelper.PI / 18;
|
||||||
}
|
}
|
||||||
arm.pivotX += sigma;
|
arm.pivotX += sigma;
|
||||||
arm.pivotZ += 3;
|
arm.pivotZ += 3;
|
||||||
|
@ -402,7 +415,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
case CROSSBOW_HOLD:
|
case CROSSBOW_HOLD:
|
||||||
aimBow(arm, limbSpeed);
|
aimBow(arm, limbSpeed);
|
||||||
|
|
||||||
arm.pitch = head.pitch - ROTATE_90;
|
arm.pitch = head.pitch - MathUtil.Angles._90_DEG;
|
||||||
arm.yaw = head.yaw + 0.06F;
|
arm.yaw = head.yaw + 0.06F;
|
||||||
break;
|
break;
|
||||||
case CROSSBOW_CHARGE:
|
case CROSSBOW_CHARGE:
|
||||||
|
@ -412,7 +425,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
arm.yaw = head.yaw + 0.06F;
|
arm.yaw = head.yaw + 0.06F;
|
||||||
break;
|
break;
|
||||||
case THROW_SPEAR:
|
case THROW_SPEAR:
|
||||||
arm.pitch = ROTATE_90 * 2;
|
arm.pitch = MathUtil.Angles._90_DEG * 2;
|
||||||
break;
|
break;
|
||||||
case SPYGLASS:
|
case SPYGLASS:
|
||||||
float addedPitch = sneaking ? -0.2617994F : 0;
|
float addedPitch = sneaking ? -0.2617994F : 0;
|
||||||
|
@ -439,7 +452,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void aimBow(ModelPart arm, float limbSpeed) {
|
protected void aimBow(ModelPart arm, float limbSpeed) {
|
||||||
arm.pitch = ROTATE_270 + head.pitch + (MathHelper.sin(limbSpeed * 0.067F) * 0.05F);
|
arm.pitch = MathUtil.Angles._270_DEG + head.pitch + (MathHelper.sin(limbSpeed * 0.067F) * 0.05F);
|
||||||
arm.yaw = head.yaw - 0.06F;
|
arm.yaw = head.yaw - 0.06F;
|
||||||
arm.roll = MathHelper.cos(limbSpeed * 0.09F) * 0.05F + 0.05F;
|
arm.roll = MathHelper.cos(limbSpeed * 0.09F) * 0.05F + 0.05F;
|
||||||
|
|
||||||
|
@ -469,8 +482,8 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
protected void swingArm(ModelPart arm) {
|
protected void swingArm(ModelPart arm) {
|
||||||
float swing = 1 - (float)Math.pow(1 - getSwingAmount(), 3);
|
float swing = 1 - (float)Math.pow(1 - getSwingAmount(), 3);
|
||||||
|
|
||||||
float deltaX = MathHelper.sin(swing * PI);
|
float deltaX = MathHelper.sin(swing * MathHelper.PI);
|
||||||
float deltaZ = MathHelper.sin(getSwingAmount() * PI);
|
float deltaZ = MathHelper.sin(getSwingAmount() * MathHelper.PI);
|
||||||
|
|
||||||
float deltaAim = deltaZ * (0.7F - head.pitch) * 0.75F;
|
float deltaAim = deltaZ * (0.7F - head.pitch) * 0.75F;
|
||||||
|
|
||||||
|
@ -502,15 +515,15 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
protected void adjustBody(float pitch, Pivot pivot) {
|
||||||
adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
|
adjustBodyComponents(pitch, pivot);
|
||||||
neck.setPivot(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
|
neck.setPivot(NECK_X + pitch, pivot.y(), pivot.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
protected void adjustBodyComponents(float pitch, Pivot pivot) {
|
||||||
body.pitch = rotateAngleX;
|
body.pitch = pitch;
|
||||||
body.pivotY = rotationPointY;
|
body.pivotY = pivot.y();
|
||||||
body.pivotZ = rotationPointZ;
|
body.pivotZ = pivot.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,20 +56,15 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyAttributes(BipedEntityModel<T> other) {
|
public final void copyAttributes(BipedEntityModel<T> other) {
|
||||||
copyStateTo(other);
|
copyStateTo(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelAttributes getAttributes() {
|
public final ModelAttributes getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPonyData getMetadata() {
|
|
||||||
return attributes.metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Size getSize() {
|
public Size getSize() {
|
||||||
return child ? Sizes.FOAL : getMetadata().getSize();
|
return child ? Sizes.FOAL : getMetadata().getSize();
|
||||||
|
@ -80,22 +75,11 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
||||||
attributes.metadata = meta;
|
attributes.metadata = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModelPart getHead() {
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRiding() {
|
|
||||||
return riding;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSwingAmount() {
|
public float getSwingAmount() {
|
||||||
return handSwingProgress;
|
return handSwingProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelPart getArm(Arm side) {
|
public ModelPart getArm(Arm side) {
|
||||||
return super.getArm(side);
|
return super.getArm(side);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.PonyModelConstants;
|
|
||||||
import com.minelittlepony.mson.util.PartUtil;
|
import com.minelittlepony.mson.util.PartUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,8 +19,8 @@ public interface IMobModel {
|
||||||
* @param ticks Render partial ticks
|
* @param ticks Render partial ticks
|
||||||
*/
|
*/
|
||||||
static void rotateArmHolding(ModelPart arm, float direction, float swingProgress, float ticks) {
|
static void rotateArmHolding(ModelPart arm, float direction, float swingProgress, float ticks) {
|
||||||
float swing = MathHelper.sin(swingProgress * PonyModelConstants.PI);
|
float swing = MathHelper.sin(swingProgress * MathHelper.PI);
|
||||||
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PonyModelConstants.PI);
|
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * MathHelper.PI);
|
||||||
|
|
||||||
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) / 10;
|
float sin = MathHelper.sin(ticks * 0.067F) / 10;
|
||||||
|
|
|
@ -43,11 +43,6 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
|
||||||
mixin().transform(part, stack);
|
mixin().transform(part, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default IPonyData getMetadata() {
|
|
||||||
return mixin().getMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ModelAttributes getAttributes() {
|
default ModelAttributes getAttributes() {
|
||||||
return mixin().getAttributes();
|
return mixin().getAttributes();
|
||||||
|
@ -63,11 +58,6 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
|
||||||
mixin().setMetadata(meta);
|
mixin().setMetadata(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean isRiding() {
|
|
||||||
return mixin().isRiding();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default float getSwingAmount() {
|
default float getSwingAmount() {
|
||||||
return mixin().getSwingAmount();
|
return mixin().getSwingAmount();
|
||||||
|
|
|
@ -8,11 +8,10 @@ import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.ICapitated;
|
import com.minelittlepony.api.model.ICapitated;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
import com.minelittlepony.api.model.ModelAttributes;
|
||||||
import com.minelittlepony.api.model.PonyModelConstants;
|
|
||||||
import com.minelittlepony.api.pony.IPony;
|
import com.minelittlepony.api.pony.IPony;
|
||||||
import com.minelittlepony.mson.api.MsonModel;
|
import com.minelittlepony.mson.api.MsonModel;
|
||||||
|
|
||||||
public interface IPonyModel<T extends LivingEntity> extends PonyModelConstants, IModel, ICapitated<ModelPart>, MsonModel {
|
public interface IPonyModel<T extends LivingEntity> extends IModel, ICapitated<ModelPart>, MsonModel {
|
||||||
|
|
||||||
void copyAttributes(BipedEntityModel<T> other);
|
void copyAttributes(BipedEntityModel<T> other);
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,11 @@ import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.entity.model.AnimalModel;
|
import net.minecraft.client.render.entity.model.AnimalModel;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified from ModelElytra.
|
* Modified from ModelElytra.
|
||||||
*/
|
*/
|
||||||
|
@ -42,11 +41,11 @@ public class PonyElytra<T extends LivingEntity> extends AnimalModel<T> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float limbDistance, float limbAngle, float age, float headYaw, float headPitch) {
|
public void setAngles(T entity, float limbDistance, float limbAngle, float age, float headYaw, float headPitch) {
|
||||||
float rotateX = PI / 2;
|
float rotateX = MathHelper.PI / 2;
|
||||||
float rotateY = PI / 8;
|
float rotateY = MathHelper.PI / 8;
|
||||||
float rotateZ = PI / 12;
|
float rotateZ = MathHelper.PI / 12;
|
||||||
|
|
||||||
float rpY = BODY_RP_Y;
|
float rpY = 0;
|
||||||
|
|
||||||
if (entity.isFallFlying()) {
|
if (entity.isFallFlying()) {
|
||||||
float velY = 1;
|
float velY = 1;
|
||||||
|
@ -56,13 +55,13 @@ public class PonyElytra<T extends LivingEntity> extends AnimalModel<T> {
|
||||||
velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5);
|
velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
|
rotateX = velY * MathHelper.PI * (2 / 3F) + (1 - velY) * rotateX;
|
||||||
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
|
rotateY = velY * (MathHelper.PI / 2) + (1 - velY) * rotateY;
|
||||||
} else if (isSneaking) {
|
} else if (isSneaking) {
|
||||||
rotateX = PI * 1.175F;
|
rotateX = MathHelper.PI * 1.175F;
|
||||||
rotateY = PI / 2;
|
rotateY = MathHelper.PI / 2;
|
||||||
rotateZ = PI / 4;
|
rotateZ = MathHelper.PI / 4;
|
||||||
rpY = BODY_RP_Y_SNEAK;
|
rpY = AbstractPonyModel.BODY_SNEAKING.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
leftWing.pivotX = 5;
|
leftWing.pivotX = 5;
|
||||||
|
|
|
@ -10,8 +10,6 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.PI;
|
|
||||||
|
|
||||||
public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
|
|
||||||
private ModelPart neck;
|
private ModelPart neck;
|
||||||
|
@ -48,13 +46,13 @@ public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
leftArm.pitch = MathHelper.cos(move * 0.6662F) * swing;
|
leftArm.pitch = MathHelper.cos(move * 0.6662F) * swing;
|
||||||
leftArm.roll = 0;
|
leftArm.roll = 0;
|
||||||
|
|
||||||
rightArm.setAngles(swing * MathHelper.cos(move * 0.6662F + PI), 0, 0);
|
rightArm.setAngles(swing * MathHelper.cos(move * 0.6662F + MathHelper.PI), 0, 0);
|
||||||
leftLeg .setAngles(swing * MathHelper.cos(move * 0.6662F + PI) * 1.4F, 0, 0);
|
leftLeg .setAngles(swing * MathHelper.cos(move * 0.6662F + MathHelper.PI) * 1.4F, 0, 0);
|
||||||
rightLeg.setAngles(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0);
|
rightLeg.setAngles(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0);
|
||||||
|
|
||||||
if (riding) {
|
if (riding) {
|
||||||
leftArm.pitch += -PI / 5;
|
leftArm.pitch += -MathHelper.PI / 5;
|
||||||
rightArm.pitch += -PI / 5;
|
rightArm.pitch += -MathHelper.PI / 5;
|
||||||
|
|
||||||
rotateLegRiding(leftLeg, -1);
|
rotateLegRiding(leftLeg, -1);
|
||||||
rotateLegRiding(rightLeg, 1);
|
rotateLegRiding(rightLeg, 1);
|
||||||
|
@ -100,11 +98,11 @@ public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
|
|
||||||
|
|
||||||
protected void rotateLegRiding(ModelPart leg, float factor) {
|
protected void rotateLegRiding(ModelPart leg, float factor) {
|
||||||
leg.setAngles(-1.4137167F, factor * PI / 10, factor * 0.07853982F);
|
leg.setAngles(-1.4137167F, factor * MathHelper.PI / 10, factor * 0.07853982F);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void swingArms(Arm mainHand) {
|
protected void swingArms(Arm mainHand) {
|
||||||
body.yaw = MathHelper.sin(MathHelper.sqrt(handSwingProgress) * PI * 2) / 5;
|
body.yaw = MathHelper.sin(MathHelper.sqrt(handSwingProgress) * MathHelper.TAU) / 5;
|
||||||
|
|
||||||
if (mainHand == Arm.LEFT) {
|
if (mainHand == Arm.LEFT) {
|
||||||
body.yaw *= -1;
|
body.yaw *= -1;
|
||||||
|
@ -124,13 +122,13 @@ public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
|
|
||||||
float swingAmount = 1 - (float)Math.pow(1 - handSwingProgress, 4);
|
float swingAmount = 1 - (float)Math.pow(1 - handSwingProgress, 4);
|
||||||
|
|
||||||
float swingFactorX = MathHelper.sin(swingAmount * PI);
|
float swingFactorX = MathHelper.sin(swingAmount * MathHelper.PI);
|
||||||
float swingX = MathHelper.sin(handSwingProgress * PI) * (0.7F - head.pitch) * 0.75F;
|
float swingX = MathHelper.sin(handSwingProgress * MathHelper.PI) * (0.7F - head.pitch) * 0.75F;
|
||||||
|
|
||||||
ModelPart mainArm = getArm(mainHand);
|
ModelPart mainArm = getArm(mainHand);
|
||||||
mainArm.pitch -= swingFactorX * 1.2F + swingX;
|
mainArm.pitch -= swingFactorX * 1.2F + swingX;
|
||||||
mainArm.yaw += body.yaw * 2;
|
mainArm.yaw += body.yaw * 2;
|
||||||
mainArm.roll -= MathHelper.sin(handSwingProgress * PI) * 0.4F;
|
mainArm.roll -= MathHelper.sin(handSwingProgress * MathHelper.PI) * 0.4F;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rotateArm(ModelPart arm, ArmPose pose, float factor) {
|
protected void rotateArm(ModelPart arm, ArmPose pose, float factor) {
|
||||||
|
@ -139,7 +137,7 @@ public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
arm.yaw = 0;
|
arm.yaw = 0;
|
||||||
break;
|
break;
|
||||||
case ITEM:
|
case ITEM:
|
||||||
arm.pitch = arm.pitch / 2 - (PI / 10);
|
arm.pitch = arm.pitch / 2 - (MathHelper.PI / 10);
|
||||||
arm.yaw = 0;
|
arm.yaw = 0;
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
arm.pitch = arm.pitch / 2 - 0.9424779F;
|
arm.pitch = arm.pitch / 2 - 0.9424779F;
|
||||||
|
@ -151,9 +149,9 @@ public class BreezieModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
|
|
||||||
protected void raiseArm(ModelPart up, ModelPart down, float factor) {
|
protected void raiseArm(ModelPart up, ModelPart down, float factor) {
|
||||||
up.yaw = head.yaw + (factor / 10);
|
up.yaw = head.yaw + (factor / 10);
|
||||||
up.pitch = head.pitch - (PI / 2);
|
up.pitch = head.pitch - MathHelper.HALF_PI;
|
||||||
|
|
||||||
down.yaw = head.yaw - (factor / 2);
|
down.yaw = head.yaw - (factor / 2);
|
||||||
down.pitch = head.pitch - (PI / 2);
|
down.pitch = head.pitch - MathHelper.HALF_PI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,6 @@ public class EnderStallionModel extends SkeleponyModel<EndermanEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getWingRotationFactor(float ticks) {
|
public float getWingRotationFactor(float ticks) {
|
||||||
return MathHelper.sin(ticks) + WING_ROT_Z_SNEAK;
|
return MathHelper.sin(ticks) + WINGS_HALF_SPREAD_ANGLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
||||||
if (rot > 1) rot = 1;
|
if (rot > 1) rot = 1;
|
||||||
if (rot < -1) rot = -1;
|
if (rot < -1) rot = -1;
|
||||||
|
|
||||||
float legDrinkingAngle = -1 * PI/3 + rot;
|
float legDrinkingAngle = -1 * MathHelper.PI/3 + rot;
|
||||||
|
|
||||||
rightArm.pitch = legDrinkingAngle;
|
rightArm.pitch = legDrinkingAngle;
|
||||||
rightArm.yaw = 0.1F;
|
rightArm.yaw = 0.1F;
|
||||||
|
|
|
@ -18,8 +18,8 @@ public class ChangelingModel<T extends LivingEntity> extends AlicornModel<T> {
|
||||||
@Override
|
@Override
|
||||||
public float getWingRotationFactor(float ticks) {
|
public float getWingRotationFactor(float ticks) {
|
||||||
if (isFlying()) {
|
if (isFlying()) {
|
||||||
return MathHelper.sin(ticks * 3) + ROTATE_270;
|
return MathHelper.sin(ticks * 3) + WINGS_HALF_SPREAD_ANGLE;
|
||||||
}
|
}
|
||||||
return WING_ROT_Z_SNEAK;
|
return WINGS_RAISED_ANGLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
|
|
||||||
|
private static final float FIN_Y_ANGLE = MathHelper.PI / 6;
|
||||||
|
|
||||||
private final ModelPart leftFin;
|
private final ModelPart leftFin;
|
||||||
private final ModelPart centerFin;
|
private final ModelPart centerFin;
|
||||||
private final ModelPart rightFin;
|
private final ModelPart rightFin;
|
||||||
|
@ -62,7 +64,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
flapMotion /= 2;
|
flapMotion /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float finAngle = FIN_ROT_Y + flapMotion;
|
float finAngle = FIN_Y_ANGLE + flapMotion;
|
||||||
|
|
||||||
leftFin.yaw = finAngle;
|
leftFin.yaw = finAngle;
|
||||||
rightFin.yaw = -finAngle;
|
rightFin.yaw = -finAngle;
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
||||||
@Override
|
@Override
|
||||||
protected void ponyCrouch() {
|
protected void ponyCrouch() {
|
||||||
super.ponyCrouch();
|
super.ponyCrouch();
|
||||||
unicornArmRight.pitch -= LEG_ROT_X_SNEAK_ADJ;
|
unicornArmRight.pitch -= LEG_SNEAKING_PITCH_ADJUSTMENT;
|
||||||
unicornArmLeft.pitch -= LEG_ROT_X_SNEAK_ADJ;
|
unicornArmLeft.pitch -= LEG_SNEAKING_PITCH_ADJUSTMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,14 +8,13 @@ import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.model.PonyModelConstants;
|
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.common.util.Color;
|
import com.minelittlepony.common.util.Color;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ChristmasHat extends AbstractWearableGear implements PonyModelConstants {
|
public class ChristmasHat extends AbstractWearableGear {
|
||||||
|
|
||||||
private static boolean dayChecked = false;
|
private static boolean dayChecked = false;
|
||||||
private static boolean dayResult = false;
|
private static boolean dayResult = false;
|
||||||
|
@ -49,7 +48,7 @@ public class ChristmasHat extends AbstractWearableGear implements PonyModelConst
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
||||||
float pi = PI * (float) Math.pow(swing, 16);
|
float pi = MathHelper.PI * (float) Math.pow(swing, 16);
|
||||||
|
|
||||||
float mve = move * 0.6662f;
|
float mve = move * 0.6662f;
|
||||||
float srt = swing / 10;
|
float srt = swing / 10;
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.minelittlepony.client.model.gear;
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.model.IPegasus;
|
import com.minelittlepony.api.model.IPegasus;
|
||||||
import com.minelittlepony.api.model.PonyModelConstants;
|
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class SaddleBags extends AbstractWearableGear implements PonyModelConstants {
|
public class SaddleBags extends AbstractWearableGear {
|
||||||
|
|
||||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/saddlebags.png");
|
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/saddlebags.png");
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class SaddleBags extends AbstractWearableGear implements PonyModelConstan
|
||||||
hangLow = model.canFly() && ((IPegasus)model).wingsAreOpen();
|
hangLow = model.canFly() && ((IPegasus)model).wingsAreOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
float pi = PI * (float) Math.pow(swing, 16);
|
float pi = MathHelper.PI * (float) Math.pow(swing, 16);
|
||||||
|
|
||||||
float mve = move * 0.6662f;
|
float mve = move * 0.6662f;
|
||||||
float srt = swing / 10;
|
float srt = swing / 10;
|
||||||
|
@ -54,7 +54,7 @@ public class SaddleBags extends AbstractWearableGear implements PonyModelConstan
|
||||||
rightBag.pitch = bodySwing;
|
rightBag.pitch = bodySwing;
|
||||||
|
|
||||||
if (model instanceof IPegasus && model.isFlying()) {
|
if (model instanceof IPegasus && model.isFlying()) {
|
||||||
bodySwing = ((IPegasus)model).getWingRotationFactor(ticks) - ROTATE_270;
|
bodySwing = ((IPegasus)model).getWingRotationFactor(ticks) - MathUtil.Angles._270_DEG;
|
||||||
bodySwing /= 10;
|
bodySwing /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,16 @@ import com.minelittlepony.api.model.ModelAttributes;
|
||||||
import com.minelittlepony.api.pony.meta.TailShape;
|
import com.minelittlepony.api.pony.meta.TailShape;
|
||||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.mson.api.*;
|
import com.minelittlepony.mson.api.*;
|
||||||
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PonyTail implements IPart, MsonModel {
|
public class PonyTail implements IPart, MsonModel {
|
||||||
|
private static final float TAIL_Z = 14;
|
||||||
|
private static final float TAIL_RIDING_Y = 3;
|
||||||
|
private static final float TAIL_RIDING_Z = 13;
|
||||||
|
private static final float TAIL_SNEAKING_Z = 15;
|
||||||
|
|
||||||
private ModelPart tail;
|
private ModelPart tail;
|
||||||
private AbstractPonyModel<?> model;
|
private AbstractPonyModel<?> model;
|
||||||
|
@ -49,15 +54,16 @@ public class PonyTail implements IPart, MsonModel {
|
||||||
tail.yaw = bodySwing * 5;
|
tail.yaw = bodySwing * 5;
|
||||||
|
|
||||||
if (model.getAttributes().isCrouching && !rainboom) {
|
if (model.getAttributes().isCrouching && !rainboom) {
|
||||||
rotateSneak();
|
tail.setPivot(0, 0, TAIL_SNEAKING_Z);
|
||||||
} else if (model.isRiding()) {
|
tail.pitch = -model.body.pitch + 0.1F;
|
||||||
tail.pivotZ = TAIL_RP_Z_RIDING;
|
} else if (model.getAttributes().isSitting) {
|
||||||
tail.pivotY = TAIL_RP_Y_RIDING;
|
tail.pivotZ = TAIL_RIDING_Z;
|
||||||
tail.pitch = PI / 5;
|
tail.pivotY = TAIL_RIDING_Y;
|
||||||
|
tail.pitch = MathHelper.PI / 5;
|
||||||
} else {
|
} else {
|
||||||
tail.setPivot(0, 0, TAIL_RP_Z);
|
tail.setPivot(0, 0, TAIL_Z);
|
||||||
if (rainboom) {
|
if (rainboom) {
|
||||||
tail.pitch = ROTATE_90 + MathHelper.sin(move) / 10;
|
tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(move) / 10;
|
||||||
} else {
|
} else {
|
||||||
tail.pitch = swing / 2;
|
tail.pitch = swing / 2;
|
||||||
|
|
||||||
|
@ -77,11 +83,6 @@ public class PonyTail implements IPart, MsonModel {
|
||||||
tail.yaw += sinTickFactor;
|
tail.yaw += sinTickFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rotateSneak() {
|
|
||||||
tail.setPivot(0, 0, TAIL_RP_Z_SNEAK);
|
|
||||||
tail.pitch = -BODY_ROT_X_SNEAK + 0.1F;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible, ModelAttributes attributes) {
|
public void setVisible(boolean visible, ModelAttributes attributes) {
|
||||||
tail.visible = visible;
|
tail.visible = visible;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.api.model.*;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.mson.api.ModelView;
|
import com.minelittlepony.mson.api.ModelView;
|
||||||
import com.minelittlepony.mson.api.MsonModel;
|
import com.minelittlepony.mson.api.MsonModel;
|
||||||
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
||||||
|
|
||||||
|
@ -57,9 +58,9 @@ public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
||||||
float progress = pegasus.getSwingAmount();
|
float progress = pegasus.getSwingAmount();
|
||||||
|
|
||||||
if (progress > 0) {
|
if (progress > 0) {
|
||||||
flap = MathHelper.sin(MathHelper.sqrt(progress) * PI * 2);
|
flap = MathHelper.sin(MathHelper.sqrt(progress) * MathHelper.TAU);
|
||||||
} else {
|
} else {
|
||||||
float pi = PI * (float) Math.pow(swing, 16);
|
float pi = MathHelper.PI * (float) Math.pow(swing, 16);
|
||||||
|
|
||||||
float mve = move * 0.6662f; // magic number ahoy (actually 2/3)
|
float mve = move * 0.6662f; // magic number ahoy (actually 2/3)
|
||||||
float srt = swing / 4;
|
float srt = swing / 4;
|
||||||
|
@ -70,7 +71,7 @@ public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
||||||
getLeft().rotateWalking(flap);
|
getLeft().rotateWalking(flap);
|
||||||
getRight().rotateWalking(-flap);
|
getRight().rotateWalking(-flap);
|
||||||
|
|
||||||
float flapAngle = ROTATE_270;
|
float flapAngle = MathUtil.Angles._270_DEG;
|
||||||
|
|
||||||
if (pegasus.wingsAreOpen()) {
|
if (pegasus.wingsAreOpen()) {
|
||||||
flapAngle = pegasus.getWingRotationFactor(ticks);
|
flapAngle = pegasus.getWingRotationFactor(ticks);
|
||||||
|
@ -78,7 +79,7 @@ public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
||||||
flapAngle -= 1F;
|
flapAngle -= 1F;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flapAngle = ROTATE_270 - 0.9F + (float)Math.sin(ticks / 10) / 15F;
|
flapAngle = MathUtil.Angles._270_DEG - 0.9F + (float)Math.sin(ticks / 10) / 15F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pegasus.isFlying()) {
|
if (!pegasus.isFlying()) {
|
||||||
|
@ -120,8 +121,8 @@ public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
|
||||||
folded.yaw = swing * walkingRotationSpeed;
|
folded.yaw = swing * walkingRotationSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotateFlying(float angle) {
|
public void rotateFlying(float roll) {
|
||||||
extended.roll = angle;
|
extended.roll = roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||||
|
|
|
@ -10,9 +10,6 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class SeaponyTail implements IPart, MsonModel {
|
public class SeaponyTail implements IPart, MsonModel {
|
||||||
|
|
||||||
private static final float TAIL_ROTX = PI / 2;
|
|
||||||
|
|
||||||
private final ModelPart tailBase;
|
private final ModelPart tailBase;
|
||||||
|
|
||||||
private final ModelPart tailTip;
|
private final ModelPart tailTip;
|
||||||
|
@ -28,9 +25,9 @@ public class SeaponyTail implements IPart, MsonModel {
|
||||||
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) {
|
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) {
|
||||||
float rotation = attributes.isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
|
float rotation = attributes.isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
|
||||||
|
|
||||||
tailBase.pitch = TAIL_ROTX + rotation;
|
tailBase.pitch = MathHelper.HALF_PI + rotation;
|
||||||
tailTip.pitch = rotation;
|
tailTip.pitch = rotation;
|
||||||
tailFins.pitch = rotation - TAIL_ROTX;
|
tailFins.pitch = rotation - MathHelper.HALF_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.minelittlepony.client.render;
|
package com.minelittlepony.client.render;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.PonyModelConstants;
|
|
||||||
import com.minelittlepony.api.model.gear.IGear;
|
import com.minelittlepony.api.model.gear.IGear;
|
||||||
import com.minelittlepony.api.pony.IPony;
|
import com.minelittlepony.api.pony.IPony;
|
||||||
import com.minelittlepony.client.model.*;
|
import com.minelittlepony.client.model.*;
|
||||||
|
@ -11,7 +10,7 @@ import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
|
||||||
public interface IPonyRenderContext<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends PonyModelConstants, IGear.Context<T, M> {
|
public interface IPonyRenderContext<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends IGear.Context<T, M> {
|
||||||
|
|
||||||
IPony getEntityPony(T entity);
|
IPony getEntityPony(T entity);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
|
||||||
import net.minecraft.entity.mob.MobEntity;
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
|
|
||||||
public class PonyRenderer<T extends MobEntity, M extends ClientPonyModel<T>> extends AbstractPonyRenderer<T, M> {
|
public class PonyRenderer<T extends MobEntity, M extends ClientPonyModel<T>> extends AbstractPonyRenderer<T, M> {
|
||||||
|
protected static final float BASE_MODEL_SCALE = 15/16F;
|
||||||
|
|
||||||
public PonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture) {
|
public PonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture) {
|
||||||
this(context, key, texture, 1);
|
this(context, key, texture, 1);
|
||||||
|
|
|
@ -4,8 +4,6 @@ import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.client.model.ClientPonyModel;
|
import com.minelittlepony.client.model.ClientPonyModel;
|
||||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||||
|
|
||||||
import static com.minelittlepony.api.model.PonyModelConstants.PI;
|
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
@ -43,8 +41,8 @@ public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>>
|
||||||
|
|
||||||
float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw);
|
float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw);
|
||||||
|
|
||||||
double sin = MathHelper.sin(motionYaw * PI / 180);
|
double sin = MathHelper.sin(motionYaw * MathHelper.RADIANS_PER_DEGREE);
|
||||||
double cos = (-MathHelper.cos(motionYaw * PI / 180));
|
double cos = -MathHelper.cos(motionYaw * MathHelper.RADIANS_PER_DEGREE);
|
||||||
|
|
||||||
float capeMotionY = (float) capeY * 10;
|
float capeMotionY = (float) capeY * 10;
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,15 @@ package com.minelittlepony.client.transform;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.api.pony.meta.Size;
|
import com.minelittlepony.api.pony.meta.Size;
|
||||||
import com.minelittlepony.api.pony.meta.Sizes;
|
import com.minelittlepony.api.pony.meta.Sizes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public enum PonyTransformation {
|
public enum PonyTransformation {
|
||||||
|
|
||||||
|
@ -19,7 +21,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0);
|
if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0);
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.61F, 0.1F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.61F, 0.1F);
|
||||||
if (model.isRiding()) stack.translate(0, -0.2F, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, -0.2F, -0.2F);
|
||||||
|
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NECK:
|
case NECK:
|
||||||
|
@ -29,7 +31,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, 0.1F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, 0.1F, 0);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
translateForRider(stack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -41,7 +43,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0);
|
if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0);
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.15F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.15F);
|
||||||
if (model.isRiding()) stack.translate(0, 0, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F);
|
||||||
|
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NECK:
|
case NECK:
|
||||||
|
@ -66,7 +68,7 @@ public enum PonyTransformation {
|
||||||
stack.scale(0.9F, 1.12F, 0.9F);
|
stack.scale(0.9F, 1.12F, 0.9F);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
translateForRider(stack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +78,7 @@ public enum PonyTransformation {
|
||||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.25F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.25F);
|
||||||
if (model.isRiding()) stack.translate(0, 0, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F);
|
||||||
|
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NECK:
|
case NECK:
|
||||||
|
@ -101,7 +103,7 @@ public enum PonyTransformation {
|
||||||
stack.scale(1.15F, 1.12F, 1.15F);
|
stack.scale(1.15F, 1.12F, 1.15F);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
translateForRider(stack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +114,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0);
|
if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0);
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.8F, -0.3F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.8F, -0.3F);
|
||||||
if (model.isRiding()) stack.translate(0, -0.6F, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, -0.6F, -0.2F);
|
||||||
|
|
||||||
stack.translate(0, 0.2F, 0);
|
stack.translate(0, 0.2F, 0);
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ public enum PonyTransformation {
|
||||||
stack.scale(1, 0.81F, 1);
|
stack.scale(1, 0.81F, 1);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
translateForRider(stack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -141,7 +143,7 @@ public enum PonyTransformation {
|
||||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.5F, 0.35F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.5F, 0.35F);
|
||||||
if (model.isRiding()) stack.translate(0, 0.1F, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, 0.1F, -0.2F);
|
||||||
|
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NECK:
|
case NECK:
|
||||||
|
@ -163,8 +165,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
|
if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
riderOffset = new Vec3d(0, 2.2F, 0.75F);
|
translateForRider(stack);
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +176,7 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0);
|
if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0);
|
||||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||||
if (model.getAttributes().isSleeping) stack.translate(0, -0.45F, -0.3F);
|
if (model.getAttributes().isSleeping) stack.translate(0, -0.45F, -0.3F);
|
||||||
if (model.isRiding()) stack.translate(0, -0.4F, -0.2F);
|
if (model.getAttributes().isSitting) stack.translate(0, -0.4F, -0.2F);
|
||||||
|
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NECK:
|
case NECK:
|
||||||
|
@ -198,23 +199,16 @@ public enum PonyTransformation {
|
||||||
if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
|
if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
translateForRider(stack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Map<Sizes, PonyTransformation> REGISTRY = Maps.newEnumMap(Sizes.class);
|
private static final Map<Sizes, PonyTransformation> REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(i -> i.size, Function.identity()));
|
||||||
|
|
||||||
static {
|
|
||||||
for (PonyTransformation i : values()) {
|
|
||||||
REGISTRY.put(i.size, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Vec3d riderOffset;
|
|
||||||
|
|
||||||
private final Sizes size;
|
private final Sizes size;
|
||||||
|
private final Vec3d riderOffset;
|
||||||
|
|
||||||
PonyTransformation(Sizes size, float rX, float rY, float rZ) {
|
PonyTransformation(Sizes size, float rX, float rY, float rZ) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
@ -225,6 +219,10 @@ public enum PonyTransformation {
|
||||||
return riderOffset;
|
return riderOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void translateForRider(MatrixStack stack) {
|
||||||
|
stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void transform(IModel model, BodyPart part, MatrixStack stack);
|
public abstract void transform(IModel model, BodyPart part, MatrixStack stack);
|
||||||
|
|
||||||
public static PonyTransformation forSize(Size size) {
|
public static PonyTransformation forSize(Size size) {
|
||||||
|
|
|
@ -2,13 +2,19 @@ package com.minelittlepony.util;
|
||||||
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class MathUtil {
|
public interface MathUtil {
|
||||||
|
interface Angles {
|
||||||
|
float
|
||||||
|
_270_DEG = 270 * MathHelper.RADIANS_PER_DEGREE,
|
||||||
|
_90_DEG = 90 * MathHelper.RADIANS_PER_DEGREE
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
public static double clampLimit(double num, double limit) {
|
static double clampLimit(double num, double limit) {
|
||||||
return MathHelper.clamp(num, -limit, limit);
|
return MathHelper.clamp(num, -limit, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int mod(int value, int mod) {
|
static int mod(int value, int mod) {
|
||||||
value %= mod;
|
value %= mod;
|
||||||
|
|
||||||
while (value < 0) value += mod;
|
while (value < 0) value += mod;
|
||||||
|
@ -16,7 +22,7 @@ public class MathUtil {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float interpolateDegress(float prev, float current, float partialTicks) {
|
static float interpolateDegress(float prev, float current, float partialTicks) {
|
||||||
float difference = current - prev;
|
float difference = current - prev;
|
||||||
|
|
||||||
while (difference < -180) difference += 360;
|
while (difference < -180) difference += 360;
|
||||||
|
@ -25,7 +31,7 @@ public class MathUtil {
|
||||||
return prev + partialTicks * difference;
|
return prev + partialTicks * difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean compareFloats(float a, float b) {
|
static boolean compareFloats(float a, float b) {
|
||||||
return Math.abs(a - b) <= 0.001F;
|
return Math.abs(a - b) <= 0.001F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue