diff --git a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java index 0b16a590..438809f3 100644 --- a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java +++ b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java @@ -8,7 +8,6 @@ import com.minelittlepony.util.MathUtil; import java.util.*; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Arm; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -32,10 +31,6 @@ public class ModelAttributes { * from regular flying in that there are actual "wings" involved. */ public boolean isGliding; - /** - * True if the model is rotated 90degs (players) - */ - public boolean isHorizontal; /** * True if the model is using riptide (players) */ @@ -123,6 +118,7 @@ public class ModelAttributes { isGoingFast = (isFlying && hasWings) || isGliding; isGoingFast &= zMotion > 0.4F; isGoingFast |= entity.isUsingRiptide(); + isGoingFast |= entity.isFallFlying(); motionLerp = MathUtil.clampLimit(zMotion * 30, 1); @@ -143,13 +139,12 @@ public class ModelAttributes { visualHeight = entity.getHeight() + 0.125F; isSitting = PonyPosture.isSitting(entity); isCrouching = !isSitting && mode == Mode.THIRD_PERSON && PonyPosture.isCrouching(pony, entity); - isSleeping = entity.isSleeping(); + isSleeping = entity.isAlive() && entity.isSleeping(); isFlying = mode == Mode.THIRD_PERSON && PonyPosture.isFlying(entity); isGliding = entity.isFallFlying(); isSwimming = mode == Mode.THIRD_PERSON && PonyPosture.isSwimming(entity); - isSwimmingRotated = isSwimming && (entity instanceof PlayerEntity || entity instanceof Swimmer); + isSwimmingRotated = isSwimming; isRiptide = entity.isUsingRiptide(); - isHorizontal = isSwimming; isRidingInteractive = PonyPosture.isRidingAPony(entity); interpolatorId = entity.getUuid(); isLeftHanded = entity.getMainArm() == Arm.LEFT; @@ -161,10 +156,4 @@ public class ModelAttributes { THIRD_PERSON, OTHER } - - /** - * Special interface to mark entities that rotate horizontally when they swim. - */ - public interface Swimmer { - } } diff --git a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java index 82b38b48..0005b529 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java +++ b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java @@ -2,7 +2,6 @@ package com.minelittlepony.client.hdskins; import net.minecraft.client.world.ClientWorld; -import com.minelittlepony.api.model.ModelAttributes; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPonyManager; import com.minelittlepony.client.IPreviewModel; @@ -14,7 +13,7 @@ import java.util.UUID; /** * Dummy model used for the skin uploading screen. */ -class DummyPony extends DummyPlayer implements IPreviewModel, ModelAttributes.Swimmer, IPonyManager.ForcedPony, EquineRenderManager.RegistrationHandler { +class DummyPony extends DummyPlayer implements IPreviewModel, IPonyManager.ForcedPony, EquineRenderManager.RegistrationHandler { public DummyPony(ClientWorld world, PlayerSkins textures) { super(world, textures); diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index 5520611e..97e5d7c9 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -147,8 +147,6 @@ public abstract class AbstractPonyModel extends ClientPo } if (attributes.isSwimmingRotated) { - head.setPivot(0, HEAD_RP_Y_SWIM, HEAD_RP_Z_SWIM); - rightLeg.pivotZ -= 1.5F; leftLeg.pivotZ -= 1.5F; } @@ -270,15 +268,11 @@ public abstract class AbstractPonyModel extends ClientPo headYaw = attributes.isSleeping ? (Math.abs(attributes.interpolatorId.getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F; headPitch = attributes.isSleeping ? 0.1f : headPitch / 57.29578F; - if (attributes.isSwimming && attributes.motionPitch != 0) { - headPitch -= 0.9F; - } - float pitch = (float)Math.toRadians(attributes.motionPitch); head.setAngles( MathHelper.clamp(headPitch, -1.25f - pitch, 0.5f - pitch), - attributes.isSwimmingRotated ? 0 : headYaw, - attributes.isSwimmingRotated ? -headYaw : 0 + headYaw, + 0 ); } @@ -601,10 +595,6 @@ public abstract class AbstractPonyModel extends ClientPo stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180)); } - if (part == BodyPart.HEAD) { - stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(attributes.motionPitch)); - } - PonyTransformation.forSize(getSize()).transform(this, part, stack); } } diff --git a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java index 3c8fc402..4827db26 100644 --- a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java +++ b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java @@ -17,8 +17,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import java.util.Objects; -import org.jetbrains.annotations.NotNull; - import net.fabricmc.api.EnvType; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Frustum; @@ -31,7 +29,7 @@ import net.minecraft.util.Identifier; public class EquineRenderManager & IPonyModel> { - public ModelWrapper playerModel; + private ModelWrapper playerModel; private IPony pony; @@ -107,34 +105,14 @@ public class EquineRenderManager) getPosture(player)).apply(player, getModel(), stack, yaw, ticks, 1); + ((PonyPosture) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, 1); } @SuppressWarnings("unchecked") public void applyPostureRiding(T player, MatrixStack stack, float yaw, float ticks) { - ((PonyPosture) getPosture(player)).apply(player, getModel(), stack, yaw, ticks, -1); + ((PonyPosture) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, -1); } - @NotNull - private PonyPosture getPosture(T entity) { - if (entity.isFallFlying()) { - return PonyPosture.ELYTRA; - } - - if (entity.isAlive() && entity.isSleeping()) { - return PonyPosture.STANDING; - } - - if (getModel().getAttributes().isHorizontal) { - return PonyPosture.SWIMMING; - } - - if (getModel().getAttributes().isGoingFast && !getModel().getAttributes().isRiptide) { - return PonyPosture.FLYING; - } - - return PonyPosture.FALLING; - } public M getModel() { return playerModel.body(); @@ -159,7 +137,7 @@ public class EquineRenderManager & IPonyModel> extends PonyModelConstants, IGear.Context { - /** - * Gets the wrapped pony model for this renderer. - */ - ModelWrapper getModelWrapper(); - IPony getEntityPony(T entity); EquineRenderManager getInternalRenderer(); @@ -30,8 +24,8 @@ public interface IPonyRenderContext getModelWrapper() { - return manager.playerModel; - } - @Override protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) { stack.push(); diff --git a/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java index e3695d43..005487ca 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java @@ -171,11 +171,6 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen return manager.getTexture(player); } - @Override - public ModelWrapper> getModelWrapper() { - return manager.playerModel; - } - @Override public EquineRenderManager> getInternalRenderer() { return manager; diff --git a/src/main/java/com/minelittlepony/client/render/entity/PlayerSeaponyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PlayerSeaponyRenderer.java index be2faf86..d70219c0 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PlayerSeaponyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PlayerSeaponyRenderer.java @@ -23,7 +23,7 @@ public class PlayerSeaponyRenderer extends PlayerPonyRenderer { super(context, slim, key); normalPony = ModelType.getPlayerModel(Race.UNICORN).>create(slim); - seapony = getModelWrapper(); + seapony = getInternalRenderer().getModelWrapper(); } @Override diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/AbstractPonyFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/AbstractPonyFeature.java index 4942c378..8643ef28 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/AbstractPonyFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/AbstractPonyFeature.java @@ -43,7 +43,7 @@ public abstract class AbstractPonyFeature getModelWrapper() { - return getContext().getModelWrapper(); + protected ModelWrapper getModelWrapper() { + return context.getInternalRenderer().getModelWrapper(); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java index 5ae72b51..b5cceace 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java @@ -30,7 +30,7 @@ public class ArmourFeature & IP @Override public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { - ModelWrapper pony = getContext().getModelWrapper(); + ModelWrapper pony = getModelWrapper(); for (EquipmentSlot i : EquipmentSlot.values()) { if (i.getType() == EquipmentSlot.Type.ARMOR) { diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java index 8b480ade..4c1fed3b 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java @@ -43,7 +43,7 @@ public class SkullFeature & IPo public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.HEAD); if (!itemstack.isEmpty()) { - M model = getContext().getModelWrapper().body(); + M model = getModelWrapper().body(); Item item = itemstack.getItem(); stack.push(); diff --git a/src/main/java/com/minelittlepony/client/transform/PonyPosture.java b/src/main/java/com/minelittlepony/client/transform/PonyPosture.java index 27df404e..f88e4210 100644 --- a/src/main/java/com/minelittlepony/client/transform/PonyPosture.java +++ b/src/main/java/com/minelittlepony/client/transform/PonyPosture.java @@ -1,33 +1,95 @@ package com.minelittlepony.client.transform; +import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.*; -import com.minelittlepony.api.model.IModel; -import com.minelittlepony.api.model.RenderPass; +import org.jetbrains.annotations.NotNull; + +import com.minelittlepony.api.model.*; public interface PonyPosture { + PonyPosture STANDING = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> { + model.getAttributes().motionPitch /= 10; + model.getAttributes().motionLerp /= 10; + model.getAttributes().motionRoll /= 10; + }; + PonyPosture ELYTRA = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> { + stack.translate(0, entity.isInSneakingPose() ? -0.825F : -1, 0); + }; + PonyPosture FLYING = new PostureFlight(1, 0); + PonyPosture SWIMMING = new PostureFlight(2, -0.9F); + PonyPosture FALLING = STANDING; - PonyPosture STANDING = new PostureStanding();; - PonyPosture ELYTRA = new PostureElytra(); - PonyPosture FLYING = new PostureFlight(); - PonyPosture SWIMMING = new PostureSwimming(); - PonyPosture FALLING = new PostureFalling(); - - default boolean applies(LivingEntity entity) { - return true; - } - - default void apply(T player, IModel model, MatrixStack stack, float yaw, float ticks, int invert) { - if (RenderPass.getCurrent() == RenderPass.WORLD && applies(player)) { - double motionX = player.getX() - player.prevX; - double motionY = player.isOnGround() ? 0 : player.getY() - player.prevY; - double motionZ = player.getZ() - player.prevZ; - - transform(model, player, stack, motionX, invert * motionY, motionZ, yaw, ticks); + @NotNull + static PonyPosture getPosture(ModelAttributes attributes, LivingEntity entity) { + if (attributes.isGliding) { + return ELYTRA; } + + if (attributes.isSleeping) { + return STANDING; + } + + if (attributes.isSwimming) { + return SWIMMING; + } + + if (attributes.isGoingFast && !attributes.isRiptide) { + return FLYING; + } + + return FALLING; } - void transform(IModel model, T entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks); + default void apply(T player, IModel model, MatrixStack stack, float yaw, float tickDelta, int invert) { + + if (RenderPass.getCurrent() == RenderPass.GUI || RenderPass.getCurrent() == RenderPass.WORLD) { + // this reverts the rotations done in PlayerEntityRenderer#setupTransforms + if (player instanceof PlayerEntity) { + float leaningPitch = player.getLeaningPitch(tickDelta); + if (player.isFallFlying()) { + + if (RenderPass.getCurrent() == RenderPass.GUI) { + Vec3d vec3d = player.getRotationVec(tickDelta); + Vec3d vec3d2 = ((AbstractClientPlayerEntity)player).lerpVelocity(tickDelta); + double d = vec3d2.horizontalLengthSquared(); + double e = vec3d.horizontalLengthSquared(); + if (d > 0.0 && e > 0.0) { + double l = (vec3d2.x * vec3d.x + vec3d2.z * vec3d.z) / Math.sqrt(d * e); + double m = vec3d2.x * vec3d.z - vec3d2.z * vec3d.x; + stack.multiply(RotationAxis.NEGATIVE_Y.rotation((float)(Math.signum(m) * Math.acos(l)))); + } + } + + float roll = (float)player.getRoll() + tickDelta; + float targetRoll = MathHelper.clamp(roll * roll / 100F, 0, 1); + if (!player.isUsingRiptide()) { + stack.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(targetRoll * (-90 - player.getPitch()))); + } + + } else if (leaningPitch > 0) { + if (player.isInSwimmingPose()) { + stack.translate(0.0f, 1.0f, -0.3f); + } + float pitch = MathHelper.lerp(leaningPitch, 0, player.isTouchingWater() ? -90 - player.getPitch() : -90); + stack.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(pitch)); + } + } + } + + if (RenderPass.getCurrent() != RenderPass.WORLD) { + return; + } + + double motionX = player.getX() - player.prevX; + double motionY = player.isOnGround() ? 0 : player.getY() - player.prevY; + double motionZ = player.getZ() - player.prevZ; + + transform(model, player, stack, motionX, invert * motionY, motionZ, yaw, tickDelta); + } + + void transform(IModel model, T entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta); } diff --git a/src/main/java/com/minelittlepony/client/transform/PonyTransformation.java b/src/main/java/com/minelittlepony/client/transform/PonyTransformation.java index ed4cba8b..95142fb1 100644 --- a/src/main/java/com/minelittlepony/client/transform/PonyTransformation.java +++ b/src/main/java/com/minelittlepony/client/transform/PonyTransformation.java @@ -27,7 +27,6 @@ public enum PonyTransformation { break; case HEAD: if (model.getAttributes().isCrouching) stack.translate(0, 0.1F, 0); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.37F, 0.45F); break; case BACK: stack.translate(riderOffset.x, riderOffset.y, riderOffset.z); @@ -49,13 +48,11 @@ public enum PonyTransformation { stack.translate(0, -0.2F, -0.05F); stack.scale(1, 1.3F, 1); if (model.getAttributes().isCrouching) stack.translate(-0.03F, 0.01F, 0.2F); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.5F, 0.25F); break; case HEAD: stack.translate(0, -0.14F, -0.04F); if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.45F, 0.45F); break; case BODY: stack.translate(0, -0.2F, -0.04F); @@ -86,13 +83,11 @@ public enum PonyTransformation { stack.translate(0, -0.2F, -0.07F); stack.scale(1, 1.3F, 1); if (model.getAttributes().isCrouching) stack.translate(-0.03F, -0.07F, 0.09F); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.5F, 0.25F); break; case HEAD: stack.translate(0, -0.14F, -0.06F); if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.15F, 0.25F); break; case BODY: stack.translate(0, -0.2F, -0.04F); @@ -116,7 +111,7 @@ public enum PonyTransformation { public void transform(IModel model, BodyPart part, MatrixStack stack) { if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0); - if (model.getAttributes().isSleeping) stack.translate(0, -0.65F, -0.3F); + if (model.getAttributes().isSleeping) stack.translate(0, -0.8F, -0.3F); if (model.isRiding()) stack.translate(0, -0.6F, -0.2F); stack.translate(0, 0.2F, 0); @@ -128,7 +123,6 @@ public enum PonyTransformation { if (model.getAttributes().isCrouching) stack.translate(-0.03F, -0.16F, 0.15F); break; case HEAD: - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.9F, 0.9F); stack.scale(1.3F, 1.3F, 1.3F); break; case LEGS: @@ -158,7 +152,6 @@ public enum PonyTransformation { case HEAD: stack.translate(0, -0.11F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.04F, 0); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.17F, 0.25F); break; case BODY: case TAIL: @@ -181,7 +174,7 @@ public enum PonyTransformation { public void transform(IModel model, BodyPart part, MatrixStack stack) { if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0); - if (model.getAttributes().isSleeping) stack.translate(0, -0.4F, -0.3F); + if (model.getAttributes().isSleeping) stack.translate(0, -0.45F, -0.3F); if (model.isRiding()) stack.translate(0, -0.4F, -0.2F); switch (part) { @@ -193,7 +186,6 @@ public enum PonyTransformation { case HEAD: stack.translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.04F, 0); - if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.8F, 0.85F); stack.scale(1.15F, 1.15F, 1.15F); break; case BODY: diff --git a/src/main/java/com/minelittlepony/client/transform/PostureElytra.java b/src/main/java/com/minelittlepony/client/transform/PostureElytra.java deleted file mode 100644 index 0d68aa30..00000000 --- a/src/main/java/com/minelittlepony/client/transform/PostureElytra.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.minelittlepony.client.transform; - -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.RotationAxis; - -import com.minelittlepony.api.model.IModel; - -import net.minecraft.entity.LivingEntity; - -public class PostureElytra implements PonyPosture { - @Override - public void transform(IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { - stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90)); - stack.translate(0, model.getAttributes().isCrouching ? 0.2F : -1, 0); - } -} diff --git a/src/main/java/com/minelittlepony/client/transform/PostureFalling.java b/src/main/java/com/minelittlepony/client/transform/PostureFalling.java deleted file mode 100644 index 4bbeee8a..00000000 --- a/src/main/java/com/minelittlepony/client/transform/PostureFalling.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.minelittlepony.client.transform; - -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; - -import com.minelittlepony.api.model.IModel; - -public class PostureFalling implements PonyPosture { - @Override - public void transform(IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { - model.getAttributes().motionPitch = 0; - } -} diff --git a/src/main/java/com/minelittlepony/client/transform/PostureFlight.java b/src/main/java/com/minelittlepony/client/transform/PostureFlight.java index 5aadafe7..a621d064 100644 --- a/src/main/java/com/minelittlepony/client/transform/PostureFlight.java +++ b/src/main/java/com/minelittlepony/client/transform/PostureFlight.java @@ -3,25 +3,29 @@ package com.minelittlepony.client.transform; import com.minelittlepony.api.model.IModel; import com.minelittlepony.common.util.animation.MotionCompositor; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.RotationAxis; import net.minecraft.entity.LivingEntity; -public class PostureFlight extends MotionCompositor implements PonyPosture { - @Override - public boolean applies(LivingEntity entity) { - return entity instanceof PlayerEntity; +public class PostureFlight extends MotionCompositor implements PonyPosture { + + private final float xScale; + private final float yOffset; + + public PostureFlight(float xScale, float yOffset) { + this.xScale = xScale; + this.yOffset = yOffset; } @Override - public void transform(IModel model, PlayerEntity player, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { - model.getAttributes().motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ); - model.getAttributes().motionRoll = (float)calculateRoll(player, motionX, motionY, motionZ); + public void transform(IModel model, LivingEntity player, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { + model.getAttributes().motionPitch = (float)calculateIncline(player, motionX, motionY, motionZ); + model.getAttributes().motionRoll = (float)calculateRoll(player, motionX * xScale, motionY, motionZ * xScale); model.getAttributes().motionRoll = model.getMetadata().getInterpolator(model.getAttributes().interpolatorId).interpolate("pegasusRoll", model.getAttributes().motionRoll, 10); stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(model.getAttributes().motionPitch)); stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(model.getAttributes().motionRoll)); + stack.translate(0, yOffset, 0); } } diff --git a/src/main/java/com/minelittlepony/client/transform/PostureStanding.java b/src/main/java/com/minelittlepony/client/transform/PostureStanding.java deleted file mode 100644 index 30ce2ebc..00000000 --- a/src/main/java/com/minelittlepony/client/transform/PostureStanding.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.minelittlepony.client.transform; - -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; - -import com.minelittlepony.api.model.IModel; - -public class PostureStanding implements PonyPosture { - @Override - public boolean applies(LivingEntity entity) { - return false; - } - - @Override - public void transform(IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { - } -} diff --git a/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java b/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java deleted file mode 100644 index feafeebc..00000000 --- a/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.minelittlepony.client.transform; - -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; - -import com.minelittlepony.api.model.IModel; - -public class PostureSwimming extends PostureFlight { - - @Override - public double calculateRoll(LivingEntity entity, double motionX, double motionY, double motionZ) { - motionX *= 2; - motionZ *= 2; - - return super.calculateRoll(entity, motionX, motionY, motionZ); - } - - @Override - public double calculateIncline(LivingEntity entity, double motionX, double motionY, double motionZ) { - return 90; // mojang handles this - } - - @Override - public void transform(IModel model, PlayerEntity player, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { - stack.translate(0, 0.9, -1); - super.transform(model, player, stack, motionX, motionY, motionZ, yaw, ticks); - } -}