diff --git a/src/main/java/com/minelittlepony/client/model/armour/ModelPonyArmour.java b/src/main/java/com/minelittlepony/client/model/armour/ModelPonyArmour.java index 313588e2..8b2cd35f 100644 --- a/src/main/java/com/minelittlepony/client/model/armour/ModelPonyArmour.java +++ b/src/main/java/com/minelittlepony/client/model/armour/ModelPonyArmour.java @@ -7,10 +7,10 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import com.minelittlepony.client.model.AbstractPonyModel; +import com.minelittlepony.client.util.render.Part; import com.minelittlepony.model.IModel; import com.minelittlepony.model.armour.ArmourVariant; import com.minelittlepony.model.armour.IArmour; -import com.minelittlepony.mson.api.model.MsonPart; public class ModelPonyArmour extends AbstractPonyModel implements IArmour { @@ -77,7 +77,7 @@ public class ModelPonyArmour extends AbstractPonyModel extends AbstractPonyModel extends PegasusWings { - @Deprecated - public void init(float yOffset, float stretch) { - /*leftWing = new Wing(pegasus, false, false, yOffset, stretch, 16); - rightWing = new Wing(pegasus, true, false, yOffset, stretch, 16); - legacyWing = rightWing;*/ - } - @Override public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) { stack.push(); @@ -30,50 +21,6 @@ public class BatWings extends PegasusWings { } public static class Wing extends PegasusWings.Wing { - - @Deprecated - protected void addClosedWing(boolean right, float y, float scale) { - float x = right ? -3.5F : 3.5F; - - folded.around(HEAD_RP_X - 0.5F, WING_FOLDED_RP_Y + y - 1, WING_FOLDED_RP_Z - 2) - .mirror(right) - .tex(56, 16).box(x * 0.9F, 5, 4, 1, 4, 1, scale) - .tex(56, 16).box(x, 5, 6, 1, 7, 1, scale) - .box(x, 5, 5, 1, 6, 1, scale) - .tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale) - .pitch = ROTATE_90; - } - - @Deprecated - protected void addFeathers(boolean right, float rotationPointY) { - float r = right ? -1 : 1; - - extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3) - .mirror(right) - .yaw = r * 3; - - extended.child().tex(60, 16) - .mirror(right) // children are unaware of their parents being mirrored, sadly - .rotate(0.1F, 0, 0) - .box(-0.5F, -1, 0, 1, 8, 1, 0.001F) // this was enough to fix z-fighting - .child().tex(60, 16) - .mirror(right) - .rotate(-0.5F, 0, 0) - .around(0, -1, -2) - .box(-0.5F, 0, 2, 1, 7, 1, 0); - extended.child(0) - .child().tex(60, 16) - .mirror(right) - .rotate(-0.5F, 0, 0) - .around(0, 4, -2.4F) - .box(-0.5F, 0, 3, 1, 7, 1, 0); - - extended.child(0).child(new Part(pegasus) //skin - .tex(56, 32) - .mirror(right) - .west(0, 0, -7, 16, 8, 0)); - } - @Override public void rotateWalking(float swing) { folded.yaw = swing * 0.05F; diff --git a/src/main/java/com/minelittlepony/client/model/part/PonySnout.java b/src/main/java/com/minelittlepony/client/model/part/PonySnout.java index b7ff074c..0a24abc9 100644 --- a/src/main/java/com/minelittlepony/client/model/part/PonySnout.java +++ b/src/main/java/com/minelittlepony/client/model/part/PonySnout.java @@ -1,12 +1,10 @@ package com.minelittlepony.client.model.part; -import net.minecraft.client.model.Model; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; import com.minelittlepony.client.MineLittlePony; -import com.minelittlepony.client.util.render.Part; import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.IPart; import com.minelittlepony.mson.api.model.MsonPart; @@ -21,44 +19,13 @@ public class PonySnout implements IPart { private ModelPart mare; private ModelPart stallion; - private final ICapitated head; - - public > PonySnout(T pony, int y, int z) { - head = pony; - - mare = new Part(pony).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z + 0.25F); - stallion = new Part(pony).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z); - - pony.getHead().addChild(stallion); - pony.getHead().addChild(mare); - } + private ICapitated head; public void rotate(float x, float y, float z) { ((MsonPart)mare).rotate(x, y, z); ((MsonPart)stallion).rotate(x, y, z); } - @Deprecated - public void init(float yOffset, float stretch) { - mare.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) - .tex(10, 14).south(-2, 2, -5, 4, 2, stretch) - .tex(11, 13).south(-1, 1, -5, 2, 1, stretch) - .tex(9, 14) .top(-2, 2, -5, 1, 1, stretch) - .tex(14, 14) .top( 1, 2, -5, 1, 1, stretch) - .tex(11, 12) .top(-1, 1, -5, 2, 1, stretch) - .tex(18, 7).bottom(-2, 4, -5, 4, 1, stretch) - .tex(9, 14) .west(-2, 2, -5, 2, 1, stretch) - .tex(14, 14) .east( 2, 2, -5, 2, 1, stretch) - .tex(11, 12) .west(-1, 1, -5, 1, 1, stretch) - .tex(12, 12) .east( 1, 1, -5, 1, 1, stretch); - stallion.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) - .tex(10, 13).south(-2, 1, -5, 4, 3, stretch) - .tex(10, 13) .top(-2, 1, -5, 4, 1, stretch) - .tex(18, 7).bottom(-2, 4, -5, 4, 1, stretch) - .tex(10, 13) .west(-2, 1, -5, 3, 1, stretch) - .tex(13, 13) .east( 2, 1, -5, 3, 1, stretch); - } - @Override public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) { } diff --git a/src/main/java/com/minelittlepony/client/model/part/PonyTail.java b/src/main/java/com/minelittlepony/client/model/part/PonyTail.java index 7e120191..a22c02b8 100644 --- a/src/main/java/com/minelittlepony/client/model/part/PonyTail.java +++ b/src/main/java/com/minelittlepony/client/model/part/PonyTail.java @@ -7,14 +7,11 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.client.util.render.Part; import com.minelittlepony.model.IPart; import java.util.UUID; -public class PonyTail extends Part implements IPart { - - private static final int SEGMENTS = 4; +public class PonyTail extends ModelPart implements IPart { private final AbstractPonyModel theModel; @@ -23,10 +20,6 @@ public class PonyTail extends Part implements IPart { public PonyTail(AbstractPonyModel model) { super(model); theModel = model; - - for (int i = 0; i < SEGMENTS; i++) { - addChild(new TailSegment(theModel, i)); - } } @Override @@ -80,34 +73,24 @@ public class PonyTail extends Part implements IPart { render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha); } - private class TailSegment extends ModelPart { + private static class Segment extends ModelPart { - private final int index; + public PonyTail tail; - public TailSegment(Model model, int index) { + int index; + + public Segment(Model model) { super(model); + } + + public void setOwner(int index, PonyTail tail) { this.index = index; - - pivotY = ((float)index)/4 + 0.063f; - - int texX = (index % 2) * 4; - - around(TAIL_RP_X, TAIL_RP_Y, 0); - - if (index == 0) { - tex(32, 0).top(-2, 0, 2, 4, 4, 0); - } - - tex(36, texX) .east( 2, 0, 2, 4, 4, 0) - .west(-2, 0, 2, 4, 4, 0); - tex(32, texX).south(-2, 0, 2, 4, 4, 0) - .north(-2, 0, 6, 4, 4, 0); - tex(32, 0) .bottom(-2, 4, 2, 4, 4, 0); + this.tail = tail; } @Override public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha) { - if (index < tailStop) { + if (index < tail.tailStop) { super.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha); } } diff --git a/src/main/java/com/minelittlepony/client/util/render/Part.java b/src/main/java/com/minelittlepony/client/util/render/Part.java index b301c9d2..f33df977 100644 --- a/src/main/java/com/minelittlepony/client/util/render/Part.java +++ b/src/main/java/com/minelittlepony/client/util/render/Part.java @@ -3,10 +3,15 @@ package com.minelittlepony.client.util.render; import net.minecraft.client.model.Model; import net.minecraft.client.model.ModelPart; +import com.minelittlepony.mson.api.ModelContext; +import com.minelittlepony.mson.api.model.BoxBuilder; +import com.minelittlepony.mson.api.model.BoxBuilder.ContentAccessor; +import com.minelittlepony.mson.api.model.Face; import com.minelittlepony.mson.api.model.MsonPart; +import com.minelittlepony.mson.api.model.QuadsBuilder; @Deprecated -public class Part extends ModelPart implements MsonPart { +public class Part extends ModelPart implements MsonPart, ModelContext { public Part(Model model) { super(model); @@ -16,4 +21,160 @@ public class Part extends ModelPart implements MsonPart { super(model, texX, texY); } + @Deprecated + public Part child() { + return this; + } + + @Deprecated + public Part flipX() { + return this; + } + + @Deprecated + public Part flipZ() { + return this; + } + + @Deprecated + public Part child(int i) { + return this; + } + + @Deprecated + public Part child(Part prt) { + return prt; + } + + @Deprecated + public Part mirror(boolean m) { + this.mirror = m; + return this; + } + + @Deprecated + public Part size(int u, int v) { + this.setTextureSize(u, v); + return this; + } + + @Deprecated + public Part tex(int u, int v) { + this.setTextureOffset(u, v); + return this; + } + + @Override + @Deprecated + public Part offset(float x, float y, float z) { + return this; + } + + @Override + @Deprecated + public Part around(float x, float y, float z) { + this.setPivot(x, y, z); + return this; + } + @Override + @Deprecated + public Part rotate(float x, float y, float z) { + MsonPart.super.rotate(x, y, z); + return this; + } + + @Deprecated + public Part face(float x, float y, float z, int w, int h, float stretch, Face face) { + ((ContentAccessor)this).cubes().add(new BoxBuilder(this) + .pos(face.transformPosition(new float[] {x, y, z}, this)) + .size(face.getAxis(), new int[] {w, h}) + .stretch(stretch, stretch, stretch) + .build(QuadsBuilder.plane(face))); + return this; + } + + @Deprecated + public Part box(float x, float y, float z, int w, int h, int d, float stretch) { + ((ContentAccessor)this).cubes().add(new BoxBuilder(this) + .pos(x, y, z) + .size(w, h, d) + .stretch(stretch, stretch, stretch) + .build()); + return this; + } + + @Deprecated + public Part east(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.EAST); + } + + @Deprecated + public Part west(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.WEST); + } + + @Deprecated + public Part north(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.NORTH); + } + + @Deprecated + public Part south(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.SOUTH); + } + + @Deprecated + public Part top(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.UP); + } + + @Deprecated + public Part bottom(float x, float y, float z, int w, int h, float stretch) { + return face(x, y, z, w, h, stretch, Face.DOWN); + } + + @Override + public Model getModel() { + return null; + } + + @SuppressWarnings("unchecked") + @Override + public T getContext() throws ClassCastException { + return (T)this; + } + + @Override + public Locals getLocals() { + return null; + } + + @Override + public float getScale() { + return 0; + } + + @Override + public T computeIfAbsent(String name, ContentSupplier supplier) { + return null; + } + + @Override + public T findByName(String name) { + return null; + } + + @Override + public void findByName(String name, ModelPart output) { + } + + @Override + public ModelContext getRoot() { + return this; + } + + @Override + public ModelContext resolve(Object child) { + return this; + } } diff --git a/src/main/resources/assets/minelittlepony/models/components/bat_wings.json b/src/main/resources/assets/minelittlepony/models/components/bat_wings.json index b638da83..80261d50 100644 --- a/src/main/resources/assets/minelittlepony/models/components/bat_wings.json +++ b/src/main/resources/assets/minelittlepony/models/components/bat_wings.json @@ -4,7 +4,54 @@ "name": "wings", "implementation": "com.minelittlepony.client.model.part.BatWings$Wing", "content": { - "__comment": "TODO" + "folded": { + "texture": {"u": 56, "v": 16}, + "rotate": [1.571, 0, 0], + "center": [-0.5, 13, -4], + "cubes": [ + { "from": [3.15, 5, 4], "size": [1, 4, 1] }, + { "from": [ 3.5, 5, 6], "size": [1, 7, 1] }, + { "from": [ 3.5, 5, 5], "size": [1, 6, 1] }, + { "from": [3.15, 5, 7], "size": [1, 7, 1] } + ] + }, + "extended": { + "texture": {"u": 56, "v": 19}, + "center": [2.5, 5.3, 3], + "rotate": [3, 0, 0], + "children": [ + { + "texture": {"u": 60, "v": 16}, + "rotate": [0.1, 0, 0], + "cubes": [ + { "from": [-0.5, -1, 0], "size": [1, 8, 1], "stretch": 0.001 } + ], + "children": [ + { + "texture": {"u": 60, "v": 16}, + "rotate": [-0.5, 0, 0], + "center": [0, -1, -2], + "cubes": [ + { "from": [-0.5, 0, 2], "size": [1, 7, 1] } + ] + }, + { + "texture": {"u": 60, "v": 16}, + "rotate": [-0.5, 0, 0], + "center": [0, 4, -2.4], + "cubes": [ + { "from": [-0.5, 0, 3], "size": [1, 7, 1] } + ] + }, + { + "type": "mson:planar", + "texture": {"u": 56, "v": 32}, + "west": [0, 0, -7, 16, 8, 0] + } + ] + } + ] + } } }, "right_wing": { @@ -12,7 +59,59 @@ "name": "wings", "implementation": "com.minelittlepony.client.model.part.BatWings$Wing", "content": { - "__comment": "TODO" + "folded": { + "texture": {"u": 56, "v": 16}, + "rotate": [1.571, 0, 0], + "center": [-0.5, 13, -4], + "mirror": true, + "cubes": [ + { "from": [-3.15, 5, 4], "size": [1, 4, 1] }, + { "from": [ -3.5, 5, 6], "size": [1, 7, 1] }, + { "from": [ -3.5, 5, 5], "size": [1, 6, 1] }, + { "from": [-3.15, 5, 7], "size": [1, 7, 1] } + ] + }, + "extended": { + "texture": {"u": 56, "v": 19}, + "center": [-2.5, 5.3, 3], + "rotate": [-3, 0, 0], + "mirror": true, + "children": [ + { + "texture": {"u": 60, "v": 16}, + "rotate": [0.1, 0, 0], + "cubes": [ + { "from": [-0.5, -1, 0], "size": [1, 8, 1], "stretch": 0.001 } + ], + "children": [ + { + "texture": {"u": 60, "v": 16}, + "rotate": [-0.5, 0, 0], + "center": [0, -1, -2], + "mirror": true, + "cubes": [ + { "from": [-0.5, 0, 2], "size": [1, 7, 1] } + ] + }, + { + "texture": {"u": 60, "v": 16}, + "rotate": [-0.5, 0, 0], + "center": [0, 4, -2.4], + "mirror": true, + "cubes": [ + { "from": [-0.5, 0, 3], "size": [1, 7, 1] } + ] + }, + { + "type": "mson:planar", + "texture": {"u": 56, "v": 32}, + "mirror": true, + "west": [0, 0, -7, 16, 8, 0] + } + ] + } + ] + } } }, "legacy_right_wing": "#right_wing" diff --git a/src/main/resources/assets/minelittlepony/models/components/snout.json b/src/main/resources/assets/minelittlepony/models/components/snout.json new file mode 100644 index 00000000..54fafd1b --- /dev/null +++ b/src/main/resources/assets/minelittlepony/models/components/snout.json @@ -0,0 +1,34 @@ +{ + "texture": {"w": 16, "h": 8}, + "stallion": { + "type": "mson:planar", + "offset": [0, -1, -2], + "south": [-2, 1, -5, 4, 3, 10, 13], + "up": [-2, 1, -5, 4, 1, 10, 13], + "down": [-2, 4, -5, 4, 1, 18, 7], + "west": [-2, 1, -5, 3, 1, 10, 13], + "east": [ 2, 1, -5, 3, 1, 13, 13] + }, + "mare": { + "type": "mson:planar", + "offset": [0, -1, -1.75], + "south": [ + [-2, 2, -5, 4, 2, 10, 14], + [-1, 1, -5, 2, 1, 11, 13] + ], + "up": [ + [-2, 2, -5, 1, 1, 9, 14], + [ 1, 2, -5, 1, 1, 14, 14], + [-1, 1, -5, 2, 1, 11, 12] + ], + "down": [-2, 4, -5, 4, 1, 18, 7], + "west": [ + [-2, 2, -5, 2, 1, 9, 14], + [-1, 1, -5, 1, 1, 11, 12] + ], + "east": [ + [ 2, 2, -5, 2, 1, 14, 14], + [ 1, 1, -5, 1, 1, 12, 12] + ] + } +} diff --git a/src/main/resources/assets/minelittlepony/models/components/tail.json b/src/main/resources/assets/minelittlepony/models/components/tail.json new file mode 100644 index 00000000..5740e469 --- /dev/null +++ b/src/main/resources/assets/minelittlepony/models/components/tail.json @@ -0,0 +1,30 @@ +{ + "texture": {"w": 64, "h": 64}, + "locals": { + "segments": 4 + }, + "segment_0": { + "type": "mson:slot", + "implementation": "com.minelittlepony.client.model.part.PonyTail$Segment", + "locals": { "segment_index": 0 }, + "content": "minelittlepony:components/tail_segment" + }, + "segment_1": { + "type": "mson:slot", + "implementation": "com.minelittlepony.client.model.part.PonyTail$Segment", + "locals": { "segment_index": 1 }, + "content": "minelittlepony:components/tail_segment" + }, + "segment_2": { + "type": "mson:slot", + "implementation": "com.minelittlepony.client.model.part.PonyTail$Segment", + "locals": { "segment_index": 2 }, + "content": "minelittlepony:components/tail_segment" + }, + "segment_3": { + "type": "mson:slot", + "implementation": "com.minelittlepony.client.model.part.PonyTail$Segment", + "locals": { "segment_index": 3 }, + "content": "minelittlepony:components/tail_segment" + } +} diff --git a/src/main/resources/assets/minelittlepony/models/components/tail_segment.json b/src/main/resources/assets/minelittlepony/models/components/tail_segment.json new file mode 100644 index 00000000..5638d183 --- /dev/null +++ b/src/main/resources/assets/minelittlepony/models/components/tail_segment.json @@ -0,0 +1,18 @@ +{ + "texture": {"w": 64, "h": 64}, + "locals": { + "segment_index": 0, + "segment_y": [["#segment_index", "/", 4], "+", 0.063], + "tex_x": [["#segment_index", "%", 2], "*", 4] + }, + "segment": { + "type": "mson:planar", + "center": [0, "#segment_y", 0], + "up": [-2, 0, 2, 4, 4, 32, 0], + "east": [ 2, 0, 2, 4, 4, 36, "#tex_x"], + "west": [-2, 0, 2, 4, 4, 36, "#tex_x"], + "south":[-2, 0, 2, 4, 4, 32, "#tex_x"], + "north":[-2, 0, 6, 4, 4, 32, "#tex_x"], + "down": [-2, 4, 2, 4, 4, 32, 0] + } +}