diff --git a/build.number b/build.number index 93eb7e02..e4e355ba 100644 --- a/build.number +++ b/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Tue Apr 10 14:03:42 CAT 2018 -build.number=497 +#Sat Jun 02 16:08:02 MSK 2018 +build.number=498 diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 3e682e28..f21c0ce2 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -3,13 +3,18 @@ package com.minelittlepony.model.player; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.render.PonyRenderer; +import com.minelittlepony.render.plane.PlaneRenderer; import net.minecraft.entity.Entity; +import net.minecraft.util.math.MathHelper; + +import static com.minelittlepony.model.PonyModelConstants.*; public class ModelEarthPony extends AbstractPonyModel { private final boolean smallArms; public PonyRenderer bipedCape; + public PlaneRenderer bag; public ModelEarthPony(boolean smallArms) { super(smallArms); @@ -23,6 +28,59 @@ public class ModelEarthPony extends AbstractPonyModel { if (bipedCape != null) { bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; } + if (bag != null && metadata.hasBags()) { + float angleY = 0; + if (swingProgress > -9990.0F && !metadata.hasMagic()) { + angleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.02F; + } + bag.rotateAngleY = angleY; + } + } + + @Override + protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); + + bipedBody.postRender(this.scale); + if (bag != null && metadata.hasBags()) { + bag.render(scale); + } + } + + @Override + protected void initTextures() { + super.initTextures(); + if (metadata.hasBags()) { + bag = new PlaneRenderer(this, 56, 19); + } + } + + @Override + protected void initPositions(float yOffset, float stretch) { + super.initPositions(yOffset, stretch); + + if (bag == null || !metadata.hasBags()) { + return; + } + bag.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(56, 25).addBackPlane(-7, -5, -4, 3, 6, stretch) //right bag front + .addBackPlane(4, -5, -4, 3, 6, stretch) //left bag front + .tex(59, 25).addBackPlane(-7, -5, 4, 3, 6, stretch) //right bag back + .addBackPlane(4, -5, 4, 3, 6, stretch) //left bag back + .tex(56, 19).addWestPlane(-7, -5, -4, 6, 8, stretch) //right bag outside + .addWestPlane(7, -5, -4, 6, 8, stretch) //left bag outside + .addWestPlane(-4.01f, -5, -4, 6, 8, stretch) //right bag inside + .addWestPlane(4.01f, -5, -4, 6, 8, stretch) //left bag inside + .tex(56, 31).addTopPlane(-4, -4.5F, -1, 8, 1, stretch) //strap front + .addTopPlane(-4, -4.5F, 0, 8, 1, stretch) //strap back + .addBackPlane(-4, -4.5F, 0, 8, 1, stretch) + .addFrontPlane(-4, -4.5F, 0, 8, 1, stretch) + .child(0).tex(56, 16).addTopPlane(2, -5, -13, 8, 3, stretch) //left bag top + .addTopPlane(2, -5, -2, 8, 3, stretch) //right bag top + .tex(56, 22).flipZ().addBottomPlane(2, 1, -13, 8, 3, stretch) //left bag bottom + .flipZ().addBottomPlane(2, 1, -2, 8, 3, stretch) //right bag bottom + .rotateAngleY = 4.712389F; } protected float getLegOutset() { diff --git a/src/main/java/com/minelittlepony/pony/data/IPonyData.java b/src/main/java/com/minelittlepony/pony/data/IPonyData.java index 74756255..f61066c7 100644 --- a/src/main/java/com/minelittlepony/pony/data/IPonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/IPonyData.java @@ -35,4 +35,9 @@ public interface IPonyData extends IMetadataSection { * Returns true if and only if this metadata represents a pony that can cast magic. */ boolean hasMagic(); + + /** + * Returns true if and only if this metadata represents a pony that has bags. + */ + boolean hasBags(); } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyAccessory.java b/src/main/java/com/minelittlepony/pony/data/PonyAccessory.java new file mode 100644 index 00000000..0a226a92 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/PonyAccessory.java @@ -0,0 +1,18 @@ +package com.minelittlepony.pony.data; + +public enum PonyAccessory implements ITriggerPixelMapped { + + SADDLEBAGS(0x442300), + NONE(0); + + private int triggerValue; + + PonyAccessory(int pixel) { + triggerValue = pixel; + } + + @Override + public int getTriggerPixel() { + return triggerValue; + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/PonyData.java b/src/main/java/com/minelittlepony/pony/data/PonyData.java index 8d5f6152..06f5e9f0 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyData.java @@ -18,6 +18,7 @@ public class PonyData implements IPonyData { private final PonyGender gender; private final PonySize size; private final int glowColor; + private final PonyAccessory accessory; public PonyData() { race = PonyRace.HUMAN; @@ -25,6 +26,7 @@ public class PonyData implements IPonyData { gender = PonyGender.MARE; size = PonySize.NORMAL; glowColor = 0x4444aa; + accessory = PonyAccessory.NONE; } private PonyData(BufferedImage image) { @@ -33,6 +35,7 @@ public class PonyData implements IPonyData { size = TriggerPixels.SIZE.readValue(image); gender = TriggerPixels.GENDER.readValue(image); glowColor = TriggerPixels.GLOW.readColor(image, -1); + accessory = TriggerPixels.ACCESSORY.readValue(image); } @Override @@ -60,6 +63,10 @@ public class PonyData implements IPonyData { return glowColor; } + public boolean hasBags() { + return accessory == PonyAccessory.SADDLEBAGS; + } + @Override public boolean hasMagic() { return race != null && race.hasHorn() && glowColor != 0; diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index 05ec7afe..a6a19bf1 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -12,7 +12,8 @@ public enum TriggerPixels { TAIL(TailLengths.FULL, 1, 0), GENDER(PonyGender.MARE, 2, 0), SIZE(PonySize.LARGE, 3, 0), - GLOW(null, 0, 1); + GLOW(null, 0, 1), + ACCESSORY(PonyAccessory.NONE, 0, 2); private int x; private int y;