package Gibbon.model;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * BaleMonkeyModel - Either Mojang or a mod author (Taken From Memory)
 * Created using Tabula 8.0.0
 */
@OnlyIn(Dist.CLIENT)
public class BaleMonkeyModel<T extends Entity> extends EntityModel<T> {
    public ModelRenderer head;
    public ModelRenderer leg1;
    public ModelRenderer leg4;
    public ModelRenderer leg2;
    public ModelRenderer tail;
    public ModelRenderer leg3;
    public ModelRenderer body;
    public ModelRenderer mustaches;
    public ModelRenderer bone;
    public ModelRenderer tail2;

    public BaleMonkeyModel() {
        this.textureWidth = 64;
        this.textureHeight = 64;
        this.tail = new ModelRenderer(this, 15, 23);
        this.tail.setRotationPoint(0.0F, 14.0F, 7.0F);
        this.tail.addBox(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 10.0F, 0.0F, 0.0F, 0.0F);
        this.setRotateAngle(tail, -0.7417000175460193F, 0.0F, 0.0F);
        this.mustaches = new ModelRenderer(this, 41, 0);
        this.mustaches.setRotationPoint(0.0F, -1.0F, -4.0F);
        this.mustaches.addBox(-2.0F, 0.5F, 0.1F, 4.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F);
        this.setRotateAngle(mustaches, -0.13089999350519735F, 0.0F, 0.0F);
        this.leg2 = new ModelRenderer(this, 11, 36);
        this.leg2.setRotationPoint(-3.0F, 14.0F, -4.5F);
        this.leg2.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 10.0F, 3.0F, 0.0F, 0.0F, 0.0F);
        this.leg4 = new ModelRenderer(this, 0, 0);
        this.leg4.setRotationPoint(-2.75F, 14.0F, 5.5F);
        this.leg4.addBox(-1.0F, 2.0F, -2.0F, 2.0F, 8.0F, 3.0F, 0.0F, 0.0F, 0.0F);
        this.body = new ModelRenderer(this, 0, 0);
        this.body.setRotationPoint(0.0F, 17.0F, 0.0F);
        this.body.addBox(-3.0F, -5.0F, -7.0F, 6.0F, 5.0F, 14.0F, 0.0F, 0.0F, 0.0F);
        this.setRotateAngle(body, -0.08730000178469466F, 0.0F, 0.0F);
        this.head = new ModelRenderer(this, 0, 0);
        this.head.setRotationPoint(0.0F, 13.0F, -6.5F);
        this.head.setTextureOffset(27, 0).addBox(-2.0F, -4.0F, -4.0F, 4.0F, 5.0F, 5.0F, 0.0F, 0.0F, 0.0F);
        this.head.setTextureOffset(5, 20).addBox(2.0F, -3.0F, -1.0F, 1.0F, 2.0F, 1.0F, 0.0F, 0.0F, 0.0F);
        this.head.setTextureOffset(0, 20).addBox(-3.0F, -3.0F, -1.0F, 1.0F, 2.0F, 1.0F, 0.0F, 0.0F, 0.0F);
        this.leg1 = new ModelRenderer(this, 22, 36);
        this.leg1.setRotationPoint(3.0F, 14.0F, -4.5F);
        this.leg1.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 10.0F, 3.0F, 0.0F, 0.0F, 0.0F);
        this.leg3 = new ModelRenderer(this, 0, 33);
        this.leg3.setRotationPoint(2.75F, 14.0F, 5.5F);
        this.leg3.addBox(-1.0F, 2.0F, -2.0F, 2.0F, 8.0F, 3.0F, 0.0F, 0.0F, 0.0F);
        this.bone = new ModelRenderer(this, 0, 0);
        this.bone.setRotationPoint(0.0F, -0.25F, -4.75F);
        this.setRotateAngle(bone, -0.30540002866516786F, 0.0F, 0.0F);
        this.tail2 = new ModelRenderer(this, 0, 20);
        this.tail2.setRotationPoint(0.0F, 0.6451F, 8.5045F);
        this.tail2.addBox(-1.0F, -1.5981F, -0.5F, 2.0F, 2.0F, 10.0F, 0.0F, 0.0F, 0.0F);
        this.setRotateAngle(tail2, 0.6545000008155003F, 0.0F, 0.0F);
        this.head.addChild(this.mustaches);
        this.head.addChild(this.bone);
        this.tail.addChild(this.tail2);
    }

    @Override
    public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { 
        ImmutableList.of(this.tail, this.leg2, this.leg4, this.body, this.head, this.leg1, this.leg3).forEach((modelRenderer) -> { 
            modelRenderer.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
        });
    }

    @Override
    public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {}

    /**
     * This is a helper function from Tabula to set the rotation of model parts
     */
    public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
}
