mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
Add proper ponified models for armour stands
This commit is contained in:
parent
08d131d846
commit
d357f46068
4 changed files with 175 additions and 1 deletions
|
@ -2,6 +2,7 @@ package com.minelittlepony.client.model;
|
|||
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.entity.model.ArmorStandEntityModel;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.VexEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -16,6 +17,7 @@ import com.minelittlepony.client.model.entity.IllagerPonyModel;
|
|||
import com.minelittlepony.client.model.entity.ParaspriteModel;
|
||||
import com.minelittlepony.client.model.entity.PiglinPonyModel;
|
||||
import com.minelittlepony.client.model.entity.PillagerPonyModel;
|
||||
import com.minelittlepony.client.model.entity.PonyArmourStandModel;
|
||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||
import com.minelittlepony.client.model.entity.VillagerPonyModel;
|
||||
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
||||
|
@ -72,6 +74,7 @@ public final class ModelType {
|
|||
public static final ModelKey<PonyElytra<?>> ELYTRA = register("elytra", PonyElytra::new);
|
||||
public static final ModelKey<PonySkullModel> SKULL = register("skull", PonySkullModel::new);
|
||||
|
||||
public static final ModelKey<ArmorStandEntityModel> ARMOUR_STAND = register("armour_stand", PonyArmourStandModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> ARMOUR_INNER = register("armour_inner", PonyArmourModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> ARMOUR_OUTER = register("armour_outer", PonyArmourModel::new);
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.minelittlepony.client.model.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.entity.model.ArmorStandEntityModel;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
|
||||
import com.minelittlepony.mson.api.model.MsonPart;
|
||||
|
||||
public class PonyArmourStandModel extends ArmorStandEntityModel {
|
||||
|
||||
public PonyArmourStandModel(ModelPart modelPart) {
|
||||
super(modelPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(ArmorStandEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||
this.leftArm.visible = true;
|
||||
this.rightArm.visible = true;
|
||||
|
||||
MsonPart.of(this.leftLeg).rotateTo(this.leftArm);
|
||||
MsonPart.of(this.rightLeg).rotateTo(this.rightArm);
|
||||
|
||||
leftLeg.pitch *= -1;
|
||||
rightLeg.pitch *= -1;
|
||||
}
|
||||
|
||||
public void applyAnglesTo(BipedEntityModel<ArmorStandEntity> dest) {
|
||||
MsonPart.of(dest.head).rotateTo(head);
|
||||
MsonPart.of(dest.helmet).rotateTo(helmet);
|
||||
MsonPart.of(dest.leftLeg).rotateTo(leftLeg);
|
||||
MsonPart.of(dest.rightLeg).rotateTo(rightLeg);
|
||||
MsonPart.of(dest.leftArm).rotateTo(leftArm);
|
||||
MsonPart.of(dest.rightArm).rotateTo(rightArm);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ import net.minecraft.entity.decoration.ArmorStandEntity;
|
|||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entity.PonyArmourStandModel;
|
||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||
import com.minelittlepony.client.pony.PonyData;
|
||||
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
||||
|
@ -24,8 +25,12 @@ import com.minelittlepony.model.armour.ArmourLayer;
|
|||
|
||||
public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
||||
|
||||
private final PonyArmourStandModel pony = ModelType.ARMOUR_STAND.createModel();
|
||||
private final ArmorStandArmorEntityModel human;
|
||||
|
||||
public PonyStandRenderer(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
human = model;
|
||||
|
||||
features.clear();
|
||||
addFeature(new Armour(this, context));
|
||||
|
@ -34,6 +39,18 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
addFeature(new HeadFeatureRenderer<>(this, context.getModelLoader()));
|
||||
}
|
||||
|
||||
public void render(ArmorStandEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
this.model = isPonita(entity) ? pony : human;
|
||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||
}
|
||||
|
||||
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float f, float g, float h) {
|
||||
super.setupTransforms(entity, stack, f, g, h);
|
||||
if (isPonita(entity)) {
|
||||
stack.translate(0, 0, -4/16F);
|
||||
}
|
||||
}
|
||||
|
||||
class Armour extends ArmorFeatureRenderer<ArmorStandEntity, ArmorStandArmorEntityModel, ArmorStandArmorEntityModel> {
|
||||
private final ModelWrapper<ArmorStandEntity, EarthPonyModel<ArmorStandEntity>> pony = new ModelWrapper<>(ModelType.EARTH_PONY.getKey(false));
|
||||
|
||||
|
@ -48,13 +65,14 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, ArmorStandEntity entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
if (entity.hasCustomName() && "Ponita".equals(entity.getCustomName().asString())) {
|
||||
if (isPonita(entity)) {
|
||||
|
||||
headPitch = 0.017453292F * entity.getHeadRotation().getPitch();
|
||||
headYaw = 0.017453292F * entity.getHeadRotation().getYaw();
|
||||
|
||||
pony.getBody().animateModel(entity, limbDistance, limbAngle, tickDelta);
|
||||
pony.getBody().setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
PonyStandRenderer.this.pony.applyAnglesTo(pony.getBody());
|
||||
|
||||
for (EquipmentSlot i : EquipmentSlot.values()) {
|
||||
if (i.getType() == EquipmentSlot.Type.ARMOR) {
|
||||
|
@ -67,4 +85,8 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isPonita(ArmorStandEntity entity) {
|
||||
return entity.hasCustomName() && "Ponita".equals(entity.getCustomName().asString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
{
|
||||
"texture": { "w": 64, "h": 64 },
|
||||
"head": {
|
||||
"center": [ 0, 5, 0 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, -7, -1 ], "size": [ 2, 7, 2 ] }
|
||||
]
|
||||
},
|
||||
"hat": {
|
||||
"center": [ 0, 5, 0 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, -7, -1 ], "size": [ 2, 7, 2 ], "stretch": 0.5 }
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"texture": { "u": 0, "v": 48 },
|
||||
"center": [ 0, 0, 1 ],
|
||||
"cubes": [
|
||||
{ "from": [ -4, 10, -1 ], "size": [ 8, 2, 2 ] }
|
||||
]
|
||||
},
|
||||
"right_arm": {
|
||||
"texture": { "u": 8 },
|
||||
"center": [ -1.9, 12, 1 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 0, -1 ], "size": [ 2, 11, 2 ] }
|
||||
]
|
||||
},
|
||||
"left_arm": {
|
||||
"texture": { "u": 40, "v": 16 },
|
||||
"center": [ 1.9, 12, 1 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 0, -1 ], "size": [ 2, 11, 2 ] }
|
||||
]
|
||||
},
|
||||
"right_leg": {
|
||||
"texture": { "u": 8 },
|
||||
"center": [ -1.9, 12, 10 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 0, -1 ], "size": [2, 11, 2 ] }
|
||||
]
|
||||
},
|
||||
"left_leg": {
|
||||
"texture": { "u": 40, "v": 16 },
|
||||
"center": [ 1.9, 12, 10 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 0, -1 ], "size": [2, 11, 2 ] }
|
||||
]
|
||||
},
|
||||
"right_body_stick": {
|
||||
"texture": { "u": 16 },
|
||||
"children": [
|
||||
{
|
||||
"rotate": [ 10, 0, 15 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 4, -1 ], "size": [ 2, 7, 2 ] }
|
||||
]
|
||||
}
|
||||
],
|
||||
"cubes": [
|
||||
{ "from": [ -3, 3, -1 ], "size": [ 2, 2, 2 ] }
|
||||
]
|
||||
},
|
||||
"left_body_stick": {
|
||||
"texture": { "u": 48, "v": 16 },
|
||||
"children": [
|
||||
{
|
||||
"rotate": [ 10, 0, -15 ],
|
||||
"cubes": [
|
||||
{ "from": [ -1, 4, -1 ], "size": [ 2, 7, 2 ] }
|
||||
]
|
||||
}
|
||||
],
|
||||
"cubes": [
|
||||
{ "from": [ 1, 3, -1 ], "size": [ 2, 2, 2 ] }
|
||||
]
|
||||
},
|
||||
"shoulder_stick": {
|
||||
"texture": { "v": 48 },
|
||||
"center": [ 0, 0, 10 ],
|
||||
"children": [
|
||||
{
|
||||
"texture": { "u": 16, "v": 0 },
|
||||
"rotate": [ 90, 0, 0 ],
|
||||
"center": [ -1, 0, 0 ],
|
||||
"children": [
|
||||
{
|
||||
"rotate": [ 45, 0, 0 ],
|
||||
"cubes": [
|
||||
{ "from": [ 0, -8, -9 ], "size": [ 2, 7, 2 ] }
|
||||
]
|
||||
}
|
||||
],
|
||||
"cubes": [
|
||||
{ "from": [ 2, -8, -12 ], "size": [ 2, 7, 2 ] },
|
||||
{ "from": [ -2, -8, -12 ], "size": [ 2, 7, 2 ] }
|
||||
]
|
||||
}
|
||||
],
|
||||
"cubes": [
|
||||
{ "from": [ -4, 10, -1 ], "size": [ 8, 2, 2 ] }
|
||||
]
|
||||
},
|
||||
"base_plate": {
|
||||
"texture": { "v": 32 },
|
||||
"center": [ 0, 12, 4 ],
|
||||
"cubes": [
|
||||
{ "from": [ -6, 11, -6 ], "size": [ 12, 1, 12 ] }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue