// Date: 4/14/2013 12:59:03 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX

package twilightforest.client.model.entity;

import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.util.Mth;
import twilightforest.client.JappaPackReloadListener;
import twilightforest.entity.monster.HelmetCrab;

public class HelmetCrabModel extends HierarchicalModel<HelmetCrab> {

	private final ModelPart root;
	private final ModelPart body;
	private final ModelPart leftClaw;
	private final ModelPart rightClaw;
	private final ModelPart rightLeg1;
	private final ModelPart rightLeg2;
	private final ModelPart leftLeg1;
	private final ModelPart leftLeg2;

	public HelmetCrabModel(ModelPart root) {
		this.root = root;

		this.body = root.getChild("body");
		this.rightClaw = root.getChild("right_claw");
		this.leftClaw = root.getChild("left_claw");

		this.rightLeg1 = root.getChild("right_leg_1");
		this.rightLeg2 = root.getChild("right_leg_2");
		this.leftLeg1 = root.getChild("left_leg_1");
		this.leftLeg2 = root.getChild("left_leg_2");
	}

	public static LayerDefinition checkForPack() {
		return JappaPackReloadListener.INSTANCE.isJappaPackLoaded() ? createJappaModel() : create();
	}

	private static LayerDefinition create() {
		MeshDefinition meshdefinition = new MeshDefinition();
		PartDefinition partdefinition = meshdefinition.getRoot();

		var body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create()
				.texOffs(32, 4)
				.addBox(-2.5F, -2.5F, -5.0F, 5.0F, 5.0F, 5.0F),
			PartPose.offset(0.0F, 19.0F, 0.0F));

		body.addOrReplaceChild("right_eye", CubeListBuilder.create()
				.texOffs(10, 0)
				.addBox(-1.0F, -3.0F, -1.0F, 2.0F, 3.0F, 2.0F),
			PartPose.offsetAndRotation(-1.0F, -1.0F, -4.0F, (Mth.PI / 4.0F), 0.0F, -(Mth.PI / 4.0F)));

		body.addOrReplaceChild("left_eye", CubeListBuilder.create()
				.texOffs(10, 0)
				.addBox(-1.0F, -3.0F, -1.0F, 2.0F, 3.0F, 2.0F),
			PartPose.offsetAndRotation(1.0F, -1.0F, -4.0F, (Mth.PI / 4.0F), 0.0F, (Mth.PI / 4.0F)));

		var helmetBase = partdefinition.addOrReplaceChild("helmet_base", CubeListBuilder.create(),
			PartPose.offsetAndRotation(0.0F, 18.0F, 0.0F, -100F * Mth.DEG_TO_RAD, -30.0F * Mth.DEG_TO_RAD, 0.0F));

		helmetBase.addOrReplaceChild("helmet", CubeListBuilder.create()
				.texOffs(0, 14)
				.addBox(-3.5F, -11.0F, -3.5F, 7.0F, 11.0F, 7.0F),
			PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.0F, 45.0F * Mth.DEG_TO_RAD, 0.0F));

		var rightHorn = helmetBase.addOrReplaceChild("right_horn_1", CubeListBuilder.create()
				.texOffs(28, 14)
				.addBox(-6F, -1.5F, -1.5F, 7.0F, 3.0F, 3.0F),
			PartPose.offsetAndRotation(-3.5F, -9.0F, 0.0F, 0.0F, -15.0F * Mth.DEG_TO_RAD, 10.0F * Mth.DEG_TO_RAD));

		rightHorn.addOrReplaceChild("right_horn_2", CubeListBuilder.create()
				.texOffs(28, 20)
				.addBox(-3.0F, -1.0F, -1.0F, 3.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-5.5F, 0.0F, 0.0F, 0.0F, -15.0F * Mth.DEG_TO_RAD, 10.0F * Mth.DEG_TO_RAD));

		var leftHorn = helmetBase.addOrReplaceChild("left_horn_1", CubeListBuilder.create().mirror()
				.texOffs(28, 14)
				.addBox(-1.0F, -1.5F, -1.5F, 7.0F, 3.0F, 3.0F),
			PartPose.offsetAndRotation(3.5F, -9.0F, 0.0F, 0.0F, 15.0F * Mth.DEG_TO_RAD, -10.0F * Mth.DEG_TO_RAD));

		leftHorn.addOrReplaceChild("left_horn_2", CubeListBuilder.create()
				.texOffs(28, 20)
				.addBox(0.0F, -1.0F, -1.0F, 3.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(5.5F, 0.0F, 0.0F, 0.0F, 15.0F * Mth.DEG_TO_RAD, -10.0F * Mth.DEG_TO_RAD));

		var rightArm = partdefinition.addOrReplaceChild("right_claw", CubeListBuilder.create()
				.texOffs(38, 0)
				.addBox(-7.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-3.0F, 20.0F, -3.0F, 0.0F, -1.319531F, -0.1919862F));

		var clawBase = rightArm.addOrReplaceChild("claw_base", CubeListBuilder.create()
				.texOffs(0, 0)
				.addBox(0.0F, -1.5F, -1.0F, 3.0F, 3.0F, 2.0F),
			PartPose.offsetAndRotation(-6.0F, 0.0F, -0.5F, 0.0F, Mth.HALF_PI, 0.0F));

		clawBase.addOrReplaceChild("claw_bottom", CubeListBuilder.create()
				.texOffs(0, 8)
				.addBox(0.0F, -0.5F, -1.0F, 3.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(3.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.2602503F));

		clawBase.addOrReplaceChild("claw_top", CubeListBuilder.create()
				.texOffs(0, 5)
				.addBox(0.0F, -0.5F, -1.0F, 3.0F, 1.0F, 2.0F),
			PartPose.offsetAndRotation(3.0F, -1.0F, 0.0F, 0.0F, 0.0F, -0.1858931F));

		partdefinition.addOrReplaceChild("left_claw", CubeListBuilder.create()
				.texOffs(18, 0)
				.addBox(-1.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(3.0F, 20.0F, -3.0F, 0.0F, 0.5759587F, 0.1919862F));

		partdefinition.addOrReplaceChild("right_leg_1", CubeListBuilder.create()
				.texOffs(18, 0)
				.addBox(-7.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-3.0F, 20.0F, -1.0F, 0.0F, 0.2792527F, -0.1919862F));

		partdefinition.addOrReplaceChild("left_leg_1", CubeListBuilder.create()
				.texOffs(18, 0)
				.addBox(-1.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(3.0F, 20.0F, -1.0F, 0.0F, -0.2792527F, 0.1919862F));

		partdefinition.addOrReplaceChild("right_leg_2", CubeListBuilder.create()
				.texOffs(18, 0)
				.addBox(-7.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-3.0F, 20.0F, -2.0F, 0.0F, -0.2792527F, -0.1919862F));

		partdefinition.addOrReplaceChild("left_leg_2", CubeListBuilder.create()
				.texOffs(18, 0)
				.addBox(-1.0F, -1.0F, -1.0F, 8.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(3.0F, 20.0F, -2.0F, 0.0F, 0.2792527F, 0.1919862F));

		return LayerDefinition.create(meshdefinition, 64, 32);
	}

	private static LayerDefinition createJappaModel() {
		MeshDefinition meshdefinition = new MeshDefinition();
		PartDefinition partdefinition = meshdefinition.getRoot();

		var body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create()
				.texOffs(0, 9)
				.addBox(-2.5F, -4.0F, -2.5F, 5.0F, 4.0F, 5.0F)
				.texOffs(58, 0)
				.addBox(-1.5F, -5.0F, -3.5F, 1.0F, 2.0F, 1.0F)
				.texOffs(58, 3)
				.addBox(0.5F, -5.0F, -3.5F, 1.0F, 2.0F, 1.0F),
			PartPose.offset(0.0F, 21.0F, 0.0F));

		var helmet = body.addOrReplaceChild("helmet", CubeListBuilder.create()
				.texOffs(40, 0)
				.addBox(-4.0F, -8.0F, -4.0F, 6.0F, 8.0F, 6.0F)
				.texOffs(16, 0)
				.addBox(-4.0F, -8.0F, -4.0F, 6.0F, 8.0F, 6.0F, new CubeDeformation(-0.25F)),
			PartPose.offsetAndRotation(0.0F, -1.0F, 0.5F, -1.3089969389957472F, -0.2617993877991494F, 0.7463027588580033F));

		helmet.addOrReplaceChild("horns", CubeListBuilder.create()
				.texOffs(18, 23)
				.addBox(-11.5F, -12.0F, -0.67F, 23.0F, 9.0F, 0.0F),
			PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.0F, 0.7853981633974483F, 0.0F));

		partdefinition.addOrReplaceChild("right_claw", CubeListBuilder.create()
				.texOffs(0, 0)
				.addBox(-1.0F, -3.0F, -5.0F, 2.0F, 4.0F, 5.0F),
			PartPose.offsetAndRotation(-2.0F, 21.0F, -2.0F, 0.0F, 0.39269908169872414F, 0.0F));

		partdefinition.addOrReplaceChild("left_claw", CubeListBuilder.create()
				.texOffs(0, 23)
				.addBox(-1.0F, -3.0F, -5.0F, 2.0F, 4.0F, 5.0F),
			PartPose.offsetAndRotation(2.0F, 21.0F, -2.0F, 0.0F, -0.39269908169872414F, 0.0F));

		partdefinition.addOrReplaceChild("right_leg_1", CubeListBuilder.create()
				.texOffs(32, 15)
				.addBox(-6.0F, -1.0F, -1.0F, 6.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-2.0F, 21.0F, 0.0F, 0.2181661564992912F, 0.4363323129985824F, -0.4363323129985824F));

		partdefinition.addOrReplaceChild("left_leg_1", CubeListBuilder.create()
				.texOffs(48, 19)
				.addBox(0.0F, -1.0F, -1.0F, 6.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(2.0F, 21.0F, 0.0F, 0.2181661564992912F, -0.4363323129985824F, 0.4363323129985824F));

		partdefinition.addOrReplaceChild("right_leg_2", CubeListBuilder.create()
				.texOffs(32, 19)
				.addBox(-6.0F, -1.0F, -1.0F, 6.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(-2.0F, 21.0F, -1.5F, 0.2181661564992912F, 0.0F, -0.4363323129985824F));

		partdefinition.addOrReplaceChild("left_leg_2", CubeListBuilder.create()
				.texOffs(48, 15)
				.addBox(0.0F, -1.0F, -1.0F, 6.0F, 2.0F, 2.0F),
			PartPose.offsetAndRotation(2.0F, 21.0F, -1.5F, 0.2181661564992912F, 0.0F, 0.4363323129985824F));


		return LayerDefinition.create(meshdefinition, 64, 32);
	}

	@Override
	public ModelPart root() {
		return this.root;
	}

	@Override
	public void setupAnim(HelmetCrab entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		this.body.yRot = netHeadYaw * Mth.DEG_TO_RAD;
		this.body.xRot = headPitch * Mth.DEG_TO_RAD;

		float f6 = (Mth.PI / 4F);
		this.rightLeg1.zRot = -f6 * 0.74F;
		this.leftLeg1.zRot = f6 * 0.74F;
		this.rightLeg2.zRot = -f6 * 0.74F;
		this.leftLeg2.zRot = f6 * 0.74F;
		float f7 = -0.0F;
		float f8 = 0.3926991F;
		this.rightLeg1.yRot = f8 + f7;
		this.leftLeg1.yRot = -f8 - f7;
		this.rightLeg2.yRot = -f8 + f7;
		this.leftLeg2.yRot = f8 - f7;
		float f10 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + Mth.PI) * 0.4F) * limbSwingAmount;
		float f11 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + Mth.HALF_PI) * 0.4F) * limbSwingAmount;
		float f12 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + (Mth.PI * 3.0F / 2.0F)) * 0.4F) * limbSwingAmount;
		float f14 = Math.abs(Mth.sin(limbSwing * 0.6662F + Mth.PI) * 0.4F) * limbSwingAmount;
		float f15 = Math.abs(Mth.sin(limbSwing * 0.6662F + Mth.HALF_PI) * 0.4F) * limbSwingAmount;
		float f16 = Math.abs(Mth.sin(limbSwing * 0.6662F + (Mth.PI * 3.0F / 2.0F)) * 0.4F) * limbSwingAmount;
		this.rightLeg1.yRot += f10;
		this.leftLeg1.yRot -= f10;
		this.rightLeg2.yRot += f11;
		this.leftLeg2.yRot -= f11;
		this.rightLeg1.zRot += f14;
		this.leftLeg1.zRot -= f14;
		this.rightLeg2.zRot += f15;
		this.leftLeg2.zRot -= f15;

		// swing right arm as if it were an arm, not a leg
		if (JappaPackReloadListener.INSTANCE.isJappaPackLoaded()) {
			this.rightClaw.yRot = 0.319531F;
			this.rightClaw.yRot += (Mth.cos(limbSwing * 0.6662F + Mth.PI) * 2.0F * limbSwingAmount * 0.5F) / 2;
			this.leftClaw.yRot = -0.319531F;
			this.leftClaw.yRot += -(Mth.cos(limbSwing * 0.6662F + Mth.PI) * 2.0F * limbSwingAmount * 0.5F) / 2;
		} else {
			this.rightClaw.yRot = -1.319531F;
			this.rightClaw.yRot += Mth.cos(limbSwing * 0.6662F + Mth.PI) * 2.0F * limbSwingAmount * 0.5F;
			this.leftClaw.zRot = f6;
			this.leftClaw.yRot = f8 * 2.0F - f7;
			this.leftClaw.yRot -= f12;
			this.leftClaw.zRot -= f16;
		}
	}
}
