// Date: 11/5/2012 7:35:56 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.legacy;

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.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.util.Mth;
import twilightforest.entity.monster.PinchBeetle;

public class PinchBeetleLegacyModel extends HierarchicalModel<PinchBeetle> {

	final ModelPart root;
	final ModelPart head;
	ModelPart leg6;
	ModelPart leg4;
	ModelPart leg2;
	ModelPart leg5;
	ModelPart leg3;
	ModelPart leg1;

	ModelPart jaw1a;
	ModelPart jaw2a;


	public PinchBeetleLegacyModel(ModelPart root) {
		this.root = root;
		this.head = root.getChild("head");

		this.leg1 = root.getChild("leg_1");
		this.leg2 = root.getChild("leg_2");
		this.leg3 = root.getChild("leg_3");
		this.leg4 = root.getChild("leg_4");
		this.leg5 = root.getChild("leg_5");
		this.leg6 = root.getChild("leg_6");

		this.jaw1a = head.getChild("right_jaw_bottom");
		this.jaw2a = head.getChild("left_jaw_bottom");
	}

	public static LayerDefinition create() {
		MeshDefinition mesh = new MeshDefinition();
		PartDefinition partRoot = mesh.getRoot();

		var head = partRoot.addOrReplaceChild("head", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(-4F, -4F, -6F, 8, 6, 6),
				PartPose.offset(0F, 19F, -5F));

		head.addOrReplaceChild("right_antenna", CubeListBuilder.create()
						.texOffs(42, 4)
						.addBox(0F, -0.5F, -0.5F, 10, 1, 1),
				PartPose.offsetAndRotation(1F, -3F, -5F, 0F, 1.047198F, -0.296706F));

		head.addOrReplaceChild("left_antenna", CubeListBuilder.create()
						.texOffs(42, 4)
						.addBox(0F, -0.5F, -0.5F, 10, 1, 1),
				PartPose.offsetAndRotation(-1F, -3F, -5F,  0F, 2.094395F, 0.296706F));

		head.addOrReplaceChild("right_eye", CubeListBuilder.create()
						.texOffs(15, 12)
						.addBox(-1.5F, -1.5F, -1.5F, 3, 3, 3),
				PartPose.offset(-3F, -2F, -5F));

		head.addOrReplaceChild("left_eye", CubeListBuilder.create()
						.texOffs(15, 12)
						.addBox(-1.5F, -1.5F, -1.5F, 3, 3, 3),
				PartPose.offset(3F, -2F, -5F));

		var rightJaw = head.addOrReplaceChild("right_jaw_bottom", CubeListBuilder.create()
						.texOffs(40, 6)
						.addBox(-1F, -1F, -1.5F, 8, 2, 3),
				PartPose.offsetAndRotation(-3F, 1F, -6F, 0F, 2.6354471F, 0F));

		var rightJawTooth = rightJaw.addOrReplaceChild("right_jaw_top", CubeListBuilder.create()
						.texOffs(40, 10)
						.addBox(-1F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(7F, 0F, 0F, 0F, -1.047197F, 0F));

		rightJawTooth.addOrReplaceChild("right_tooth_1", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(9F, 0F, 0F, 0F, -0.5235987F, 0));

		rightJawTooth.addOrReplaceChild("right_tooth_2", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(6F, 0F, 0F, 0F, 1.5707963F, 0));

		rightJawTooth.addOrReplaceChild("right_tooth_3", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(3F, 0F, 0F, 0F, 1.5707963F, 0));

		var leftJaw = head.addOrReplaceChild("left_jaw_bottom", CubeListBuilder.create()
						.texOffs(40, 6)
						.addBox(-1F, -1F, -1.5F, 8, 2, 3),
				PartPose.offsetAndRotation(3F, 1F, -6F, 0F, 0.5410520F, 0F));

		var leftJawTooth = leftJaw.addOrReplaceChild("left_jaw_top", CubeListBuilder.create()
						.texOffs(40, 10)
						.addBox(-1F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(7F, 0F, 0F, 0F, 1.047197F, 0F));

		leftJawTooth.addOrReplaceChild("left_tooth_1", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(9F, 0F, 0F, 0F, 0.5235987F, 0));

		leftJawTooth.addOrReplaceChild("left_tooth_2", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(6F, 0F, 0F, 0F, -1.5707963F, 0));

		leftJawTooth.addOrReplaceChild("left_tooth_3", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(0F, -0.5F, -0F, 2, 1, 1),
				PartPose.offsetAndRotation(3F, 0F, 0F, 0F, -1.5707963F, 0));

		partRoot.addOrReplaceChild("thorax", CubeListBuilder.create()
						.texOffs(0, 22)
						.addBox(-4.5F, -4F, 0F, 9, 8, 2),
				PartPose.offset(0F, 18F, -4.5F));

		partRoot.addOrReplaceChild("connector_1", CubeListBuilder.create()
						.texOffs(0, 12)
						.addBox(-3F, -3F, 0F, 6, 6, 1),
				PartPose.offset(0F, 18F, -3F));

		partRoot.addOrReplaceChild("connector_2", CubeListBuilder.create()
						.texOffs(0, 12)
						.addBox(-3F, -3F, -1F, 6, 6, 1),
				PartPose.offset(0F, 18F, -4F));

		partRoot.addOrReplaceChild("rear", CubeListBuilder.create()
						.texOffs(28, 14)
						.addBox(-5F, -9F, -4F, 10, 10, 8),
				PartPose.offsetAndRotation(0F, 18F, 7F, 1.570796F, 0F, 0F));

		partRoot.addOrReplaceChild("leg_1", CubeListBuilder.create().mirror()
						.texOffs(40, 0)
						.addBox(-9F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(-4F, 21F, 4F, 0F, 0.6981317F, -0.3490659F));

		partRoot.addOrReplaceChild("leg_2", CubeListBuilder.create()
						.texOffs(40, 0)
						.addBox(-1F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(4F, 21F, 4F, 0F, -0.6981317F, 0.3490659F));

		partRoot.addOrReplaceChild("leg_3", CubeListBuilder.create().mirror()
						.texOffs(40, 0)
						.addBox(-9F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(-4F, 21F, -1F, 0F, 0.2792527F, -0.3490659F));

		partRoot.addOrReplaceChild("leg_4", CubeListBuilder.create()
						.texOffs(40, 0)
						.addBox(-1F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(4F, 21F, -1F, 0F, -0.2792527F, 0.3490659F));

		partRoot.addOrReplaceChild("leg_5", CubeListBuilder.create().mirror()
						.texOffs(40, 0)
						.addBox(-9F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(-4F, 21F, -4F, 0F, -0.2792527F, -0.3490659F));

		partRoot.addOrReplaceChild("leg_6", CubeListBuilder.create()
						.texOffs(40, 0)
						.addBox(-1F, -1F, -1F, 10, 2, 2),
				PartPose.offsetAndRotation(4F, 21F, -4F, 0F, 0.2792527F, 0.3490659F));

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

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

	@Override
	public void setupAnim(PinchBeetle entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		this.head.yRot = netHeadYaw / (180F / (float) Math.PI);
		this.head.xRot = headPitch / (180F / (float) Math.PI);

		float legZ = ((float) Math.PI / 11F);
		this.leg1.zRot = -legZ;
		this.leg2.zRot = legZ;
		this.leg3.zRot = -legZ * 0.74F;
		this.leg4.zRot = legZ * 0.74F;
		this.leg5.zRot = -legZ;
		this.leg6.zRot = legZ;

		float var9 = -0.0F;
		float var10 = 0.3926991F;
		this.leg1.yRot = var10 * 2.0F + var9;
		this.leg2.yRot = -var10 * 2.0F - var9;
		this.leg3.yRot = var10 + var9;
		this.leg4.yRot = -var10 - var9;
		this.leg5.yRot = -var10 * 2.0F + var9;
		this.leg6.yRot = var10 * 2.0F - var9;

		float var11 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + 0.0F) * 0.4F) * limbSwingAmount;
		float var12 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * limbSwingAmount;
		float var14 = -(Mth.cos(limbSwing * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * limbSwingAmount;

		float var15 = Math.abs(Mth.sin(limbSwing * 0.6662F + 0.0F) * 0.4F) * limbSwingAmount;
		float var16 = Math.abs(Mth.sin(limbSwing * 0.6662F + (float) Math.PI) * 0.4F) * limbSwingAmount;
		float var18 = Math.abs(Mth.sin(limbSwing * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * limbSwingAmount;

		this.leg1.yRot += var11;
		this.leg2.yRot += -var11;
		this.leg3.yRot += var12;
		this.leg4.yRot += -var12;
		this.leg5.yRot += var14;
		this.leg6.yRot += -var14;

		this.leg1.zRot += var15;
		this.leg2.zRot += -var15;

		this.leg3.zRot += var16;
		this.leg4.zRot += -var16;

		this.leg5.zRot += var18;
		this.leg6.zRot += -var18;
	}

	@Override
	public void prepareMobModel(PinchBeetle entity, float limbSwing, float limbSwingAmount, float partialTicks) {
		if (entity.isVehicle()) {
			// open jaws
			this.jaw1a.yRot = 2.96705972839036F;
			this.jaw2a.yRot = 0.3490658503988659F;
		} else {
			// close jaws
			this.jaw1a.yRot = 2.356194490192345F;
			this.jaw2a.yRot = 0.7853981633974483F;
		}
	}
}
