102 lines
5.5 KiB
Java
102 lines
5.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.model;
|
|
|
|
import net.minecraft.client.model.EntityModel;
|
|
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.MeshDefinition;
|
|
import net.minecraft.client.model.geom.builders.MeshTransformer;
|
|
import net.minecraft.client.model.geom.builders.PartDefinition;
|
|
import net.minecraft.client.renderer.entity.state.BeeRenderState;
|
|
import net.minecraft.util.Mth;
|
|
|
|
public class BeeModel
|
|
extends EntityModel<BeeRenderState> {
|
|
public static final MeshTransformer BABY_TRANSFORMER = MeshTransformer.scaling(0.5f);
|
|
private static final String BONE = "bone";
|
|
private static final String STINGER = "stinger";
|
|
private static final String LEFT_ANTENNA = "left_antenna";
|
|
private static final String RIGHT_ANTENNA = "right_antenna";
|
|
private static final String FRONT_LEGS = "front_legs";
|
|
private static final String MIDDLE_LEGS = "middle_legs";
|
|
private static final String BACK_LEGS = "back_legs";
|
|
private final ModelPart bone;
|
|
private final ModelPart rightWing;
|
|
private final ModelPart leftWing;
|
|
private final ModelPart frontLeg;
|
|
private final ModelPart midLeg;
|
|
private final ModelPart backLeg;
|
|
private final ModelPart stinger;
|
|
private final ModelPart leftAntenna;
|
|
private final ModelPart rightAntenna;
|
|
private float rollAmount;
|
|
|
|
public BeeModel(ModelPart root) {
|
|
super(root);
|
|
this.bone = root.getChild(BONE);
|
|
ModelPart body = this.bone.getChild("body");
|
|
this.stinger = body.getChild(STINGER);
|
|
this.leftAntenna = body.getChild(LEFT_ANTENNA);
|
|
this.rightAntenna = body.getChild(RIGHT_ANTENNA);
|
|
this.rightWing = this.bone.getChild("right_wing");
|
|
this.leftWing = this.bone.getChild("left_wing");
|
|
this.frontLeg = this.bone.getChild(FRONT_LEGS);
|
|
this.midLeg = this.bone.getChild(MIDDLE_LEGS);
|
|
this.backLeg = this.bone.getChild(BACK_LEGS);
|
|
}
|
|
|
|
public static LayerDefinition createBodyLayer() {
|
|
MeshDefinition mesh = new MeshDefinition();
|
|
PartDefinition root = mesh.getRoot();
|
|
PartDefinition bone = root.addOrReplaceChild(BONE, CubeListBuilder.create(), PartPose.offset(0.0f, 19.0f, 0.0f));
|
|
PartDefinition body = bone.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-3.5f, -4.0f, -5.0f, 7.0f, 7.0f, 10.0f), PartPose.ZERO);
|
|
body.addOrReplaceChild(STINGER, CubeListBuilder.create().texOffs(26, 7).addBox(0.0f, -1.0f, 5.0f, 0.0f, 1.0f, 2.0f), PartPose.ZERO);
|
|
body.addOrReplaceChild(LEFT_ANTENNA, CubeListBuilder.create().texOffs(2, 0).addBox(1.5f, -2.0f, -3.0f, 1.0f, 2.0f, 3.0f), PartPose.offset(0.0f, -2.0f, -5.0f));
|
|
body.addOrReplaceChild(RIGHT_ANTENNA, CubeListBuilder.create().texOffs(2, 3).addBox(-2.5f, -2.0f, -3.0f, 1.0f, 2.0f, 3.0f), PartPose.offset(0.0f, -2.0f, -5.0f));
|
|
CubeDeformation wingDeformation = new CubeDeformation(0.001f);
|
|
bone.addOrReplaceChild("right_wing", CubeListBuilder.create().texOffs(0, 18).addBox(-9.0f, 0.0f, 0.0f, 9.0f, 0.0f, 6.0f, wingDeformation), PartPose.offsetAndRotation(-1.5f, -4.0f, -3.0f, 0.0f, -0.2618f, 0.0f));
|
|
bone.addOrReplaceChild("left_wing", CubeListBuilder.create().texOffs(0, 18).mirror().addBox(0.0f, 0.0f, 0.0f, 9.0f, 0.0f, 6.0f, wingDeformation), PartPose.offsetAndRotation(1.5f, -4.0f, -3.0f, 0.0f, 0.2618f, 0.0f));
|
|
bone.addOrReplaceChild(FRONT_LEGS, CubeListBuilder.create().addBox(FRONT_LEGS, -5.0f, 0.0f, 0.0f, 7, 2, 0, 26, 1), PartPose.offset(1.5f, 3.0f, -2.0f));
|
|
bone.addOrReplaceChild(MIDDLE_LEGS, CubeListBuilder.create().addBox(MIDDLE_LEGS, -5.0f, 0.0f, 0.0f, 7, 2, 0, 26, 3), PartPose.offset(1.5f, 3.0f, 0.0f));
|
|
bone.addOrReplaceChild(BACK_LEGS, CubeListBuilder.create().addBox(BACK_LEGS, -5.0f, 0.0f, 0.0f, 7, 2, 0, 26, 5), PartPose.offset(1.5f, 3.0f, 2.0f));
|
|
return LayerDefinition.create(mesh, 64, 64);
|
|
}
|
|
|
|
@Override
|
|
public void setupAnim(BeeRenderState state) {
|
|
float speed;
|
|
super.setupAnim(state);
|
|
this.rollAmount = state.rollAmount;
|
|
this.stinger.visible = state.hasStinger;
|
|
if (!state.isOnGround) {
|
|
speed = state.ageInTicks * 120.32113f * ((float)Math.PI / 180);
|
|
this.rightWing.yRot = 0.0f;
|
|
this.rightWing.zRot = Mth.cos(speed) * (float)Math.PI * 0.15f;
|
|
this.leftWing.xRot = this.rightWing.xRot;
|
|
this.leftWing.yRot = this.rightWing.yRot;
|
|
this.leftWing.zRot = -this.rightWing.zRot;
|
|
this.frontLeg.xRot = 0.7853982f;
|
|
this.midLeg.xRot = 0.7853982f;
|
|
this.backLeg.xRot = 0.7853982f;
|
|
}
|
|
if (!state.isAngry && !state.isOnGround) {
|
|
speed = Mth.cos(state.ageInTicks * 0.18f);
|
|
this.bone.xRot = 0.1f + speed * (float)Math.PI * 0.025f;
|
|
this.leftAntenna.xRot = speed * (float)Math.PI * 0.03f;
|
|
this.rightAntenna.xRot = speed * (float)Math.PI * 0.03f;
|
|
this.frontLeg.xRot = -speed * (float)Math.PI * 0.1f + 0.3926991f;
|
|
this.backLeg.xRot = -speed * (float)Math.PI * 0.05f + 0.7853982f;
|
|
this.bone.y -= Mth.cos(state.ageInTicks * 0.18f) * 0.9f;
|
|
}
|
|
if (this.rollAmount > 0.0f) {
|
|
this.bone.xRot = Mth.rotLerpRad(this.rollAmount, this.bone.xRot, 3.0915928f);
|
|
}
|
|
}
|
|
}
|
|
|