From 845f3536ad413d56019700bab4d954da21cd39c9 Mon Sep 17 00:00:00 2001 From: PolyacovYury Date: Mon, 11 Jun 2018 18:51:38 +0300 Subject: [PATCH] Merging together @PolyacovYury and @Sollace's visions on saddlebags. (#69) --- .../model/PonyModelConstants.java | 2 +- .../model/components/ModelWing.java | 42 +++++++++++-------- .../model/components/PegasusWings.java | 10 ++--- .../model/components/SaddleBags.java | 11 +++-- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 42686b39..f99bfdc3 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -47,7 +47,7 @@ public final class PonyModelConstants { HORN_Z = HEAD_CENTRE_Z - 1.5F, LEFT_WING_EXT_RP_X = 4.5F, - LEFT_WING_EXT_RP_Y = 6, + LEFT_WING_EXT_RP_Y = 5.3F, LEFT_WING_EXT_RP_Z = 6, LEFT_WING_ROTATE_ANGLE_Z_SNEAK = 4, diff --git a/src/main/java/com/minelittlepony/model/components/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java index 590f912e..c5aacc25 100644 --- a/src/main/java/com/minelittlepony/model/components/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -4,7 +4,9 @@ import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.capabilities.IModelPegasus; +import com.minelittlepony.pony.data.PonyWearable; import com.minelittlepony.render.PonyRenderer; +import net.minecraft.client.renderer.GlStateManager; public class ModelWing { @@ -13,18 +15,14 @@ public class ModelWing { private final PonyRenderer extended; private final PonyRenderer folded; - public ModelWing(T pegasus, boolean right, float y, float scale, int texX, int texY) { + public ModelWing(T pegasus, boolean right, boolean legacy, float y, float scale, int texX, int texY) { this.pegasus = pegasus; - if (right) { - texX ++; - } - - folded = new PonyRenderer(pegasus, 56, texY); + folded = new PonyRenderer(pegasus, 56, texY).mirror(legacy); extended = new PonyRenderer(pegasus, texX, texY + 3); addClosedWing(right, y, scale); - addFeathers(right, y, scale); + addFeathers(right, legacy, y, scale); } private void addClosedWing(boolean right, float y, float scale) { @@ -37,20 +35,21 @@ public class ModelWing { .rotateAngleX = ROTATE_90; } - private void addFeathers(boolean right, float rotationPointY, float scale) { + private void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { float r = right ? -1 : 1; - extended.around(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + rotationPointY, LEFT_WING_EXT_RP_Z); - addFeather(0, 6, 0, 8, scale + 0.1F); - addFeather(1, -1.2F, -0.2F, 8, scale + 0.2F) .rotateAngleX = -0.85F; - addFeather(2, 1.8F, 1.3F, 8, scale + 0.1F) .rotateAngleX = -0.75F; - addFeather(3, 5, 2, 8, scale) .rotateAngleX = -0.5F; - addFeather(4, 0, -0.2F, 6, scale + 0.3F); - addFeather(5, 0, 0.2F, 3, scale + 0.19F).rotateAngleX = -0.85F; + extended.around(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + rotationPointY, LEFT_WING_EXT_RP_Z) + .rotateAngleY = r * 3; + addFeather(0, l, 6, 0, 8, scale + 0.1F); + addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .rotateAngleX = -0.85F; + addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; + addFeather(3, l, 5, 2, 8, scale) .rotateAngleX = -0.5F; + addFeather(4, l, 0, -0.2F, 6, scale + 0.3F); + addFeather(5, l, 0, 0, 3, scale + 0.19F).rotateAngleX = -0.85F; } - private PonyRenderer addFeather(int i, float y, float z, int h, float scale) { - return extended.child(i).around(0, 0, 0).box(0, y, z, 1, h, 2, scale); + private PonyRenderer addFeather(int i, boolean l, float y, float z, int h, float scale) { + return extended.child(i).around(0, 0, 0).mirror(l).box(-0.5F, y, z, 1, h, 2, scale); } public void rotateWalking(float swing) { @@ -62,11 +61,18 @@ public class ModelWing { } public void render(float scale) { - extended.rotateAngleY = 3; if (pegasus.wingsAreOpen()) { extended.render(scale); } else { + boolean bags = pegasus.isWearing(PonyWearable.SADDLE_BAGS); + if (bags) { + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 0.198F); + } folded.render(scale); + if (bags) { + GlStateManager.popMatrix(); + } } } } diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index d92fd805..40602684 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -28,10 +28,10 @@ public class PegasusWings implement public void init(float yOffset, float stretch) { int x = 57; - leftWing = new ModelWing(pegasus, false, yOffset, stretch, x, 32); - rightWing = new ModelWing(pegasus, true, yOffset, stretch, x, 16); + leftWing = new ModelWing(pegasus, false, false, yOffset, stretch, x, 32); + rightWing = new ModelWing(pegasus, true, false, yOffset, stretch, x - 1, 16); - legacyWing = new ModelWing(pegasus, true, yOffset, stretch, x - 1, 32); + legacyWing = new ModelWing(pegasus, true, true, yOffset, stretch, x, 32); } public ModelWing getLeft() { @@ -63,8 +63,8 @@ public class PegasusWings implement if (pegasus.wingsAreOpen()) { float flapAngle = pegasus.getWingRotationFactor(ticks); - if (pegasus.isWearing(PonyWearable.SADDLE_BAGS)) { - flapAngle -= 0.6F; + if (!pegasus.isCrouching() && pegasus.isWearing(PonyWearable.SADDLE_BAGS)) { + flapAngle -= 1F; } getLeft().rotateFlying(flapAngle); getRight().rotateFlying(-flapAngle); diff --git a/src/main/java/com/minelittlepony/model/components/SaddleBags.java b/src/main/java/com/minelittlepony/model/components/SaddleBags.java index 5d537eb5..c95699d3 100644 --- a/src/main/java/com/minelittlepony/model/components/SaddleBags.java +++ b/src/main/java/com/minelittlepony/model/components/SaddleBags.java @@ -40,7 +40,13 @@ public class SaddleBags implements IModelPart { .tex(56, 31).addTopPlane(0, 0, 0, 8, 1, stretch) .addTopPlane(0, 0, 1, 8, 1, stretch) .addBackPlane(0, 0, 2, 8, 1, stretch) - .addFrontPlane(0, 0, 0, 8, 1, stretch); + .addFrontPlane(0, 0, 0, 8, 1, stretch) + .child(0).offset(0, -3, -0.305F).tex(56, 31) + .addWestPlane(4.0002F, 0, 0, 1, 3, stretch) // 0.0001 is there + .addWestPlane(4.0002F, -1, 0, 1, 3, stretch) // otherwise straps + .addWestPlane(-4.0002F, 0, 0, 1, 3, stretch) // clip into the body + .addWestPlane(-4.0002F, -1, 0, 1, 3, stretch) + .rotateAngleX = ROTATE_270; leftBag.offset(x, y, z).around(0, 4, 4) .tex(56, 25).addBackPlane(0, 0, 0, 3, 6, stretch) @@ -104,11 +110,10 @@ public class SaddleBags implements IModelPart { leftBag.render(scale); rightBag.render(scale); - strap.render(scale); - if (hangLow) { GlStateManager.popMatrix(); } + strap.render(scale); } }