65 lines
3.2 KiB
Java
65 lines
3.2 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.model;
|
|
|
|
import net.minecraft.client.model.AbstractEquineModel;
|
|
import net.minecraft.client.model.EquineSaddleModel;
|
|
import net.minecraft.client.model.geom.ModelPart;
|
|
import net.minecraft.client.model.geom.PartPose;
|
|
import net.minecraft.client.model.geom.builders.CubeDeformation;
|
|
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
|
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
|
import net.minecraft.client.model.geom.builders.MeshTransformer;
|
|
import net.minecraft.client.model.geom.builders.PartDefinition;
|
|
import net.minecraft.client.renderer.entity.state.DonkeyRenderState;
|
|
|
|
public class DonkeyModel
|
|
extends AbstractEquineModel<DonkeyRenderState> {
|
|
public static final float DONKEY_SCALE = 0.87f;
|
|
public static final float MULE_SCALE = 0.92f;
|
|
private static final MeshTransformer DONKEY_TRANSFORMER = mesh -> {
|
|
DonkeyModel.modifyMesh(mesh.getRoot());
|
|
return mesh;
|
|
};
|
|
private final ModelPart leftChest;
|
|
private final ModelPart rightChest;
|
|
|
|
public DonkeyModel(ModelPart root) {
|
|
super(root);
|
|
this.leftChest = this.body.getChild("left_chest");
|
|
this.rightChest = this.body.getChild("right_chest");
|
|
}
|
|
|
|
public static LayerDefinition createBodyLayer(float scale) {
|
|
return LayerDefinition.create(AbstractEquineModel.createBodyMesh(CubeDeformation.NONE), 64, 64).apply(DONKEY_TRANSFORMER).apply(MeshTransformer.scaling(scale));
|
|
}
|
|
|
|
public static LayerDefinition createBabyLayer(float scale) {
|
|
return LayerDefinition.create(AbstractEquineModel.createFullScaleBabyMesh(CubeDeformation.NONE), 64, 64).apply(DONKEY_TRANSFORMER).apply(BABY_TRANSFORMER).apply(MeshTransformer.scaling(scale));
|
|
}
|
|
|
|
public static LayerDefinition createSaddleLayer(float scale, boolean baby) {
|
|
return EquineSaddleModel.createFullScaleSaddleLayer(baby).apply(DONKEY_TRANSFORMER).apply(baby ? AbstractEquineModel.BABY_TRANSFORMER : MeshTransformer.IDENTITY).apply(MeshTransformer.scaling(scale));
|
|
}
|
|
|
|
private static void modifyMesh(PartDefinition root) {
|
|
PartDefinition body = root.getChild("body");
|
|
CubeListBuilder chest = CubeListBuilder.create().texOffs(26, 21).addBox(-4.0f, 0.0f, -2.0f, 8.0f, 8.0f, 3.0f);
|
|
body.addOrReplaceChild("left_chest", chest, PartPose.offsetAndRotation(6.0f, -8.0f, 0.0f, 0.0f, -1.5707964f, 0.0f));
|
|
body.addOrReplaceChild("right_chest", chest, PartPose.offsetAndRotation(-6.0f, -8.0f, 0.0f, 0.0f, 1.5707964f, 0.0f));
|
|
PartDefinition head = root.getChild("head_parts").getChild("head");
|
|
CubeListBuilder ear = CubeListBuilder.create().texOffs(0, 12).addBox(-1.0f, -7.0f, 0.0f, 2.0f, 7.0f, 1.0f);
|
|
head.addOrReplaceChild("left_ear", ear, PartPose.offsetAndRotation(1.25f, -10.0f, 4.0f, 0.2617994f, 0.0f, 0.2617994f));
|
|
head.addOrReplaceChild("right_ear", ear, PartPose.offsetAndRotation(-1.25f, -10.0f, 4.0f, 0.2617994f, 0.0f, -0.2617994f));
|
|
}
|
|
|
|
@Override
|
|
public void setupAnim(DonkeyRenderState state) {
|
|
super.setupAnim(state);
|
|
this.leftChest.visible = state.hasChest;
|
|
this.rightChest.visible = state.hasChest;
|
|
}
|
|
}
|
|
|