Move the snout, bat wings, and tail to json

This commit is contained in:
Sollace 2019-11-25 15:05:14 +02:00
parent d5bcd31145
commit c71475be28
11 changed files with 366 additions and 130 deletions

View file

@ -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<T extends LivingEntity> extends AbstractPonyModel<T> implements IArmour {
@ -77,7 +77,7 @@ public class ModelPonyArmour<T extends LivingEntity> extends AbstractPonyModel<T
@Deprecated
protected void initEars(ModelPart head, float yOffset, float stretch) {
stretch /= 2;
head.tex(0, 0).box(-4, -6, 1, 2, 2, 2, stretch) // right ear
((Part)head).tex(0, 0).box(-4, -6, 1, 2, 2, 2, stretch) // right ear
.tex(0, 4).box( 2, -6, 1, 2, 2, 2, stretch); // left ear
}
@ -91,7 +91,7 @@ public class ModelPonyArmour<T extends LivingEntity> extends AbstractPonyModel<T
// fits the legacy player's torso to our pony bod.
upperTorso = new com.minelittlepony.client.util.render.Part(this, 24, 0);
((MsonPart)upperTorso).offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
((Part)upperTorso).offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(32, 23).east( 4, -4, -4, 8, 8, stretch)
.west(-4, -4, -4, 8, 8, stretch)

View file

@ -6,7 +6,6 @@ import com.minelittlepony.model.IModel;
import com.minelittlepony.model.IPegasus;
import com.minelittlepony.pony.meta.Race;
import com.minelittlepony.pony.meta.Wearable;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID;
@ -33,7 +32,7 @@ public class SaddleBags extends AbstractGear {
private IModel model;
@Override
@Deprecated
public void init(float yOffset, float stretch) {
leftBag = new Part(this, 56, 19);
rightBag = new Part(this, 56, 19);
@ -43,7 +42,7 @@ public class SaddleBags extends AbstractGear {
int x = 4;
int z = -1;
strap.offset(-x, y + 0.2F, z + 3).around(0, 4, 4)
((Part)strap).offset(-x, y + 0.2F, z + 3).around(0, 4, 4)
.tex(56, 31).top(0, 0, 0, 8, 1, stretch)
.top(0, 0, 1, 8, 1, stretch)
.south(0, 0, 2, 8, 1, stretch)
@ -55,7 +54,7 @@ public class SaddleBags extends AbstractGear {
.west(-4.0002F, -1, 0, 1, 3, stretch)
.pitch = ROTATE_270;
leftBag.offset(x, y, z).around(0, 4, 4)
((Part)leftBag).offset(x, y, z).around(0, 4, 4)
.tex(56, 25).south(0, 0, 0, 3, 6, stretch)
.tex(59, 25).south(0, 0, 8, 3, 6, stretch)
.tex(56, 19) .west(3, 0, 0, 6, 8, stretch)
@ -67,7 +66,7 @@ public class SaddleBags extends AbstractGear {
x += 3;
rightBag.offset(-x, y, z).around(0, 4, 4).flipX()
((Part)rightBag).offset(-x, y, z).around(0, 4, 4).flipX()
.tex(56, 25).south(0, 0, 0, 3, 6, stretch)
.tex(59, 25).south(0, 0, 8, 3, 6, stretch)
.tex(56, 19).west(3, 0, 0, 6, 8, stretch)

View file

@ -10,18 +10,16 @@ import com.minelittlepony.model.IModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable;
import java.util.UUID;
public class WitchHat extends AbstractGear implements IStackable {
private static final Identifier WITCH_TEXTURES = new Identifier("textures/entity/witch.png");
private ModelPart witchHat;
@Override
@Deprecated
public void init(float yOffset, float stretch) {
accept(witchHat = new Part(this).size(64, 128));
witchHat.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
((Part)witchHat).around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(0, 64).box(-5, -6, -7, 10, 2, 10, stretch)
.child(0).around(1.75F, -4, 2)
.tex(0, 76).box(-5, -5, -7, 7, 4, 7, stretch)

View file

@ -6,19 +6,10 @@ import net.minecraft.client.util.math.MatrixStack;
import com.minelittlepony.model.IPegasus;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID;
public class BatWings<T extends Model & IPegasus> extends PegasusWings<T> {
@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<T extends Model & IPegasus> extends PegasusWings<T> {
}
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;

View file

@ -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<ModelPart> head;
public <T extends Model & ICapitated<ModelPart>> 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<ModelPart> 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) {
}

View file

@ -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);
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);
public void setOwner(int index, PonyTail tail) {
this.index = index;
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);
}
}

View file

@ -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> T getContext() throws ClassCastException {
return (T)this;
}
@Override
public Locals getLocals() {
return null;
}
@Override
public float getScale() {
return 0;
}
@Override
public <T> T computeIfAbsent(String name, ContentSupplier<T> supplier) {
return null;
}
@Override
public <T> 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;
}
}

View file

@ -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"

View file

@ -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]
]
}
}

View file

@ -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"
}
}

View file

@ -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]
}
}