
package studio.halbear.hem.entity.renderer;

import studio.halbear.hem.entity.EmberleafMilitaryBotEntity;

import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;

import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.MobRenderer;

import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.blaze3d.matrix.MatrixStack;

@OnlyIn(Dist.CLIENT)
public class EmberleafMilitaryBotRenderer {
	public static class ModelRegisterHandler {
		@SubscribeEvent
		@OnlyIn(Dist.CLIENT)
		public void registerModels(ModelRegistryEvent event) {
			RenderingRegistry.registerEntityRenderingHandler(EmberleafMilitaryBotEntity.entity, renderManager -> {
				return new MobRenderer(renderManager, new ModelEmberleafMilitaryBot(), 0.5f) {

					@Override
					public ResourceLocation getEntityTexture(Entity entity) {
						return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotawake.png");
					}
				};
			});
		}
	}

	// Made with Blockbench 4.12.5
	// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
	// Paste this class into your mod and generate all required imports
	public static class ModelEmberleafMilitaryBot extends EntityModel<Entity> {
		private final ModelRenderer LeftLeg;
		private final ModelRenderer RightLeg;
		private final ModelRenderer UpperBody;
		private final ModelRenderer leftArm;
		private final ModelRenderer rightArm;
		private final ModelRenderer HeadX;
		private final ModelRenderer cube_r1;
		private final ModelRenderer bb_main;
		private final ModelRenderer cube_r2;

		public ModelEmberleafMilitaryBot() {
			textureWidth = 128;
			textureHeight = 128;
			LeftLeg = new ModelRenderer(this);
			LeftLeg.setRotationPoint(-1.75F, 5.0F, 0.0F);
			LeftLeg.setTextureOffset(24, 47).addBox(-5.25F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, false);
			LeftLeg.setTextureOffset(0, 75).addBox(-4.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, false);
			RightLeg = new ModelRenderer(this);
			RightLeg.setRotationPoint(1.75F, 5.0F, 0.0F);
			RightLeg.setTextureOffset(24, 47).addBox(-0.75F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, true);
			RightLeg.setTextureOffset(0, 75).addBox(0.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, true);
			UpperBody = new ModelRenderer(this);
			UpperBody.setRotationPoint(0.0F, -5.25F, 0.0F);
			UpperBody.setTextureOffset(48, 90).addBox(-11.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, false);
			UpperBody.setTextureOffset(48, 90).addBox(8.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, true);
			UpperBody.setTextureOffset(68, 38).addBox(4.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
			UpperBody.setTextureOffset(0, 111).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.25F, false);
			UpperBody.setTextureOffset(0, 0).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.0F, false);
			UpperBody.setTextureOffset(56, 27).addBox(-13.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
			UpperBody.setTextureOffset(44, 0).addBox(-1.5F, -16.5F, -1.5F, 3.0F, 7.0F, 3.0F, 0.0F, false);
			leftArm = new ModelRenderer(this);
			leftArm.setRotationPoint(-10.0F, -7.5F, 0.0F);
			UpperBody.addChild(leftArm);
			leftArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, false);
			leftArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, false);
			leftArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, false);
			rightArm = new ModelRenderer(this);
			rightArm.setRotationPoint(10.0F, -7.5F, 0.0F);
			UpperBody.addChild(rightArm);
			rightArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, true);
			rightArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, true);
			rightArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, true);
			HeadX = new ModelRenderer(this);
			HeadX.setRotationPoint(0.0F, -13.0F, 0.0F);
			UpperBody.addChild(HeadX);
			cube_r1 = new ModelRenderer(this);
			cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			HeadX.addChild(cube_r1);
			setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F);
			cube_r1.setTextureOffset(68, 49).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.0F, false);
			cube_r1.setTextureOffset(68, 64).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.25F, false);
			bb_main = new ModelRenderer(this);
			bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
			bb_main.setTextureOffset(17, 75).addBox(-4.0F, -27.75F, -2.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
			bb_main.setTextureOffset(76, 0).addBox(-2.0F, -21.75F, -2.0F, 4.0F, 5.0F, 4.0F, 0.0F, false);
			cube_r2 = new ModelRenderer(this);
			cube_r2.setRotationPoint(0.0F, -30.75F, 0.0F);
			bb_main.addChild(cube_r2);
			setRotationAngle(cube_r2, 0.0F, 0.0F, -3.1416F);
			cube_r2.setTextureOffset(17, 76).addBox(-4.0F, -3.0F, -2.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
		}

		@Override
		public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
				float alpha) {
			LeftLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
			RightLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
			UpperBody.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
			bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
		}

		public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
			modelRenderer.rotateAngleX = x;
			modelRenderer.rotateAngleY = y;
			modelRenderer.rotateAngleZ = z;
		}

		public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
			this.LeftLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
			this.UpperBody.rotateAngleX = f4 / (180F / (float) Math.PI);
			this.RightLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
			this.rightArm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
			this.leftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
			this.HeadX.rotateAngleY = f3 / (180F / (float) Math.PI);
		}
	}

}
