package net.minecraft.client.model.animal.camel;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.animation.definitions.CamelAnimation;
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;

@Environment(EnvType.CLIENT)
public class AdultCamelModel extends CamelModel {
	public AdultCamelModel(final ModelPart root) {
		super(
			root,
			CamelAnimation.CAMEL_WALK,
			CamelAnimation.CAMEL_SIT,
			CamelAnimation.CAMEL_SIT_POSE,
			CamelAnimation.CAMEL_STANDUP,
			CamelAnimation.CAMEL_IDLE,
			CamelAnimation.CAMEL_DASH
		);
	}

	public static LayerDefinition createBodyLayer() {
		return LayerDefinition.create(createBodyMesh(), 128, 128);
	}

	protected static MeshDefinition createBodyMesh() {
		MeshDefinition mesh = new MeshDefinition();
		PartDefinition root = mesh.getRoot();
		PartDefinition body = root.addOrReplaceChild(
			"body", CubeListBuilder.create().texOffs(0, 25).addBox(-7.5F, -12.0F, -23.5F, 15.0F, 12.0F, 27.0F), PartPose.offset(0.0F, 4.0F, 9.5F)
		);
		body.addOrReplaceChild("hump", CubeListBuilder.create().texOffs(74, 0).addBox(-4.5F, -5.0F, -5.5F, 9.0F, 5.0F, 11.0F), PartPose.offset(0.0F, -12.0F, -10.0F));
		body.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(122, 0).addBox(-1.5F, 0.0F, 0.0F, 3.0F, 14.0F, 0.0F), PartPose.offset(0.0F, -9.0F, 3.5F));
		PartDefinition head = body.addOrReplaceChild(
			"head",
			CubeListBuilder.create()
				.texOffs(60, 24)
				.addBox(-3.5F, -7.0F, -15.0F, 7.0F, 8.0F, 19.0F)
				.texOffs(21, 0)
				.addBox(-3.5F, -21.0F, -15.0F, 7.0F, 14.0F, 7.0F)
				.texOffs(50, 0)
				.addBox(-2.5F, -21.0F, -21.0F, 5.0F, 5.0F, 6.0F),
			PartPose.offset(0.0F, -3.0F, -19.5F)
		);
		head.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(45, 0).addBox(-0.5F, 0.5F, -1.0F, 3.0F, 1.0F, 2.0F), PartPose.offset(2.5F, -21.0F, -9.5F));
		head.addOrReplaceChild(
			"right_ear", CubeListBuilder.create().texOffs(67, 0).addBox(-2.5F, 0.5F, -1.0F, 3.0F, 1.0F, 2.0F), PartPose.offset(-2.5F, -21.0F, -9.5F)
		);
		root.addOrReplaceChild(
			"left_hind_leg", CubeListBuilder.create().texOffs(58, 16).addBox(-2.5F, 2.0F, -2.5F, 5.0F, 21.0F, 5.0F), PartPose.offset(4.9F, 1.0F, 9.5F)
		);
		root.addOrReplaceChild(
			"right_hind_leg", CubeListBuilder.create().texOffs(94, 16).addBox(-2.5F, 2.0F, -2.5F, 5.0F, 21.0F, 5.0F), PartPose.offset(-4.9F, 1.0F, 9.5F)
		);
		root.addOrReplaceChild(
			"left_front_leg", CubeListBuilder.create().texOffs(0, 0).addBox(-2.5F, 2.0F, -2.5F, 5.0F, 21.0F, 5.0F), PartPose.offset(4.9F, 1.0F, -10.5F)
		);
		root.addOrReplaceChild(
			"right_front_leg", CubeListBuilder.create().texOffs(0, 26).addBox(-2.5F, 2.0F, -2.5F, 5.0F, 21.0F, 5.0F), PartPose.offset(-4.9F, 1.0F, -10.5F)
		);
		return mesh;
	}
}
