// Date: 4/28/2012 9:46:20 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.passive.Raven;

public class RavenLegacyModel extends HierarchicalModel<Raven> {
	final ModelPart root;
	//fields
	final ModelPart head;
	ModelPart rightarm;
	ModelPart leftarm;
	ModelPart rightleg;
	ModelPart leftleg;

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

		this.head = root.getChild("head");
		this.rightarm = root.getChild("right_wing");
		this.leftarm = root.getChild("left_wing");
		this.rightleg = root.getChild("right_leg");
		this.leftleg = root.getChild("left_leg");
	}

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

		PartDefinition headpart = base.addOrReplaceChild("head", CubeListBuilder.create()
						.texOffs(0, 0)
						.addBox(-1.5F, -1.5F, -3F, 3, 3, 3)
						.mirror(),
				PartPose.offset(0F, 18F, 0F));
		headpart.addOrReplaceChild("beak1", CubeListBuilder.create()
						.texOffs(12, 0)
						.addBox(-0.5F, -1F, -2F, 1, 1, 2),
				PartPose.offsetAndRotation(0F, 0F, -2.5F, 0.2617994F, 0.0F, 0.0F));
		headpart.addOrReplaceChild("beak2", CubeListBuilder.create()
						.texOffs(12, 0)
						.addBox(-0.5F, 0F, -2F, 1, 1, 2),
				PartPose.offsetAndRotation(0F, 0F, -2.5F, -0.2617994F, 0.0F, 0.0F));
		base.addOrReplaceChild("body", CubeListBuilder.create()
						.texOffs(0, 6)
						.addBox(-1.5F, 0F, -1F, 3, 4, 6),
				PartPose.offsetAndRotation(0F, 17F, 1F, -0.5235988F, 0F, 0F));
		base.addOrReplaceChild("right_wing", CubeListBuilder.create()
						.texOffs(0, 16)
						.addBox(-1F, 0F, -1.5F, 1, 3, 6),
				PartPose.offset(-1.5F, 18F, 1F));
		base.addOrReplaceChild("left_wing", CubeListBuilder.create()
						.texOffs(0, 16)
						.addBox(0F, 0F, -1.5F, 1, 3, 6),
				PartPose.offset(1.5F, 18F, 1F));
		PartDefinition rightlegpart = base.addOrReplaceChild("right_leg", CubeListBuilder.create()
						.texOffs(14, 16)
						.addBox(0F, 0F, 0F, 1, 2, 1),
				PartPose.offset(-1.5F, 21F, 1F));
		rightlegpart.addOrReplaceChild("right_foot", CubeListBuilder.create()
						.texOffs(14, 20)
						.addBox(0F, -1F, -2F, 1, 1, 2),
				PartPose.offsetAndRotation(0F, 2F, 1F, 0.5235988F, 0F, 0F));
		PartDefinition leftlegpart = base.addOrReplaceChild("left_leg", CubeListBuilder.create()
						.texOffs(14, 16)
						.addBox(0F, 0F, 0F, 1, 2, 1),
				PartPose.offset(0.5F, 21F, 1F));
		leftlegpart.addOrReplaceChild("left_foot", CubeListBuilder.create()
						.texOffs(14, 20)
						.addBox(0F, -1F, -2F, 1, 1, 2),
				PartPose.offsetAndRotation(0F, 2F, 1F, 0.5235988F, 0F, 0F));
		base.addOrReplaceChild("tail", CubeListBuilder.create()
						.texOffs(0, 25)
						.addBox(-1.5F, -0.5F, 0F, 3, 1, 3),
				PartPose.offsetAndRotation(0F, 21F, 4F, -0.5235988F, 0F, 0F));

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

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

	@Override
	public void setupAnim(Raven entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		head.xRot = headPitch / (180F / (float) Math.PI);
		head.yRot = netHeadYaw / (180F / (float) Math.PI);
		head.zRot = netHeadYaw > 5 ? -0.2617994F : 0;

		rightleg.xRot = Mth.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
		leftleg.xRot = Mth.cos(limbSwing * 0.6662F + (float) Math.PI) * 1.4F * limbSwingAmount;

		rightarm.zRot = ageInTicks;
		leftarm.zRot = -ageInTicks;

		if (entity.isBirdLanded()) {
			rightleg.y = 21;
			leftleg.y = 21;
		} else {
			rightleg.y = 20F;
			leftleg.y = 20F;
		}
	}
}
