
package studio.halbear.hem.entity.renderer;

import studio.halbear.hem.entity.GiantButterflyWalkingEntity;

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 GiantButterflyWalkingRenderer {
	public static class ModelRegisterHandler {
		@SubscribeEvent
		@OnlyIn(Dist.CLIENT)
		public void registerModels(ModelRegistryEvent event) {
			RenderingRegistry.registerEntityRenderingHandler(GiantButterflyWalkingEntity.entity, renderManager -> {
				return new MobRenderer(renderManager, new ModelGiantButterflyWalking(), 0.5f) {

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

	// Made with Blockbench 4.12.4
	// 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 ModelGiantButterflyWalking extends EntityModel<Entity> {
		private final ModelRenderer Head;
		private final ModelRenderer antenna2;
		private final ModelRenderer antenna_r1;
		private final ModelRenderer antenna;
		private final ModelRenderer antenna_r2;
		private final ModelRenderer Body;
		private final ModelRenderer cube_r1;
		private final ModelRenderer LeftUpperWIngouter1;
		private final ModelRenderer LeftUpperWIng;
		private final ModelRenderer LeftUpperWIng_r1;
		private final ModelRenderer RightUpperWIngouter1;
		private final ModelRenderer RightUpperWIng;
		private final ModelRenderer RightUpperWIng_r1;
		private final ModelRenderer LeftLowerWIngouter1;
		private final ModelRenderer LeftLowerWing;
		private final ModelRenderer LeftLowerWing_r1;
		private final ModelRenderer RightLowerWIngouter1;
		private final ModelRenderer RightLowerWing;
		private final ModelRenderer RightLowerWing_r1;
		private final ModelRenderer RightLegs;
		private final ModelRenderer cube_r2;
		private final ModelRenderer cube_r3;
		private final ModelRenderer LeftLegs;
		private final ModelRenderer cube_r4;
		private final ModelRenderer cube_r5;
		private final ModelRenderer RightLegs2;
		private final ModelRenderer cube_r6;
		private final ModelRenderer LeftLegs2;
		private final ModelRenderer cube_r7;
		private final ModelRenderer butt;
		private final ModelRenderer cube_r8;

		public ModelGiantButterflyWalking() {
			textureWidth = 256;
			textureHeight = 256;
			Head = new ModelRenderer(this);
			Head.setRotationPoint(0.0F, 8.0F, -5.0F);
			Head.setTextureOffset(138, 135).addBox(-4.0F, -4.0F, -9.0F, 8.0F, 9.0F, 9.0F, 0.0F, false);
			Head.setTextureOffset(0, 142).addBox(0.0F, -2.0F, -16.0F, 0.0F, 18.0F, 10.0F, 0.0F, false);
			antenna2 = new ModelRenderer(this);
			antenna2.setRotationPoint(2.0F, -4.0F, -4.0F);
			Head.addChild(antenna2);
			antenna_r1 = new ModelRenderer(this);
			antenna_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			antenna2.addChild(antenna_r1);
			setRotationAngle(antenna_r1, 1.5708F, 1.1345F, 1.9635F);
			antenna_r1.setTextureOffset(91, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
			antenna = new ModelRenderer(this);
			antenna.setRotationPoint(-2.0F, -4.0F, -4.0F);
			Head.addChild(antenna);
			antenna_r2 = new ModelRenderer(this);
			antenna_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
			antenna.addChild(antenna_r2);
			setRotationAngle(antenna_r2, 1.5708F, -1.1345F, -1.9635F);
			antenna_r2.setTextureOffset(114, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
			Body = new ModelRenderer(this);
			Body.setRotationPoint(0.0F, 8.0F, -5.0F);
			cube_r1 = new ModelRenderer(this);
			cube_r1.setRotationPoint(0.0F, 4.563F, 14.5211F);
			Body.addChild(cube_r1);
			setRotationAngle(cube_r1, 1.3963F, 0.0F, 0.0F);
			cube_r1.setTextureOffset(0, 111).addBox(-6.0F, -16.0F, -9.0F, 12.0F, 16.0F, 15.0F, 0.0F, false);
			LeftUpperWIngouter1 = new ModelRenderer(this);
			LeftUpperWIngouter1.setRotationPoint(6.0F, -2.637F, 8.5211F);
			Body.addChild(LeftUpperWIngouter1);
			setRotationAngle(LeftUpperWIngouter1, 0.0F, 0.0F, -0.6109F);
			LeftUpperWIng = new ModelRenderer(this);
			LeftUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
			LeftUpperWIngouter1.addChild(LeftUpperWIng);
			LeftUpperWIng_r1 = new ModelRenderer(this);
			LeftUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			LeftUpperWIng.addChild(LeftUpperWIng_r1);
			setRotationAngle(LeftUpperWIng_r1, 1.44F, 0.0768F, 0.7941F);
			LeftUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, false);
			RightUpperWIngouter1 = new ModelRenderer(this);
			RightUpperWIngouter1.setRotationPoint(-6.0F, -2.637F, 8.5211F);
			Body.addChild(RightUpperWIngouter1);
			setRotationAngle(RightUpperWIngouter1, 0.0F, 0.0F, 0.6109F);
			RightUpperWIng = new ModelRenderer(this);
			RightUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
			RightUpperWIngouter1.addChild(RightUpperWIng);
			RightUpperWIng_r1 = new ModelRenderer(this);
			RightUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			RightUpperWIng.addChild(RightUpperWIng_r1);
			setRotationAngle(RightUpperWIng_r1, 1.44F, -0.0768F, -0.7941F);
			RightUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, true);
			LeftLowerWIngouter1 = new ModelRenderer(this);
			LeftLowerWIngouter1.setRotationPoint(6.0F, -2.0F, 8.0F);
			Body.addChild(LeftLowerWIngouter1);
			setRotationAngle(LeftLowerWIngouter1, 0.0F, -0.2618F, -0.7854F);
			LeftLowerWing = new ModelRenderer(this);
			LeftLowerWing.setRotationPoint(0.05F, -0.037F, 2.7711F);
			LeftLowerWIngouter1.addChild(LeftLowerWing);
			LeftLowerWing_r1 = new ModelRenderer(this);
			LeftLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			LeftLowerWing.addChild(LeftLowerWing_r1);
			setRotationAngle(LeftLowerWing_r1, 1.4319F, 0.2446F, 0.7479F);
			LeftLowerWing_r1.setTextureOffset(97, 3).addBox(0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, false);
			RightLowerWIngouter1 = new ModelRenderer(this);
			RightLowerWIngouter1.setRotationPoint(-6.0F, -2.0F, 8.0F);
			Body.addChild(RightLowerWIngouter1);
			setRotationAngle(RightLowerWIngouter1, 0.0F, 0.2618F, 0.7854F);
			RightLowerWing = new ModelRenderer(this);
			RightLowerWing.setRotationPoint(-0.05F, -0.037F, 2.7711F);
			RightLowerWIngouter1.addChild(RightLowerWing);
			RightLowerWing_r1 = new ModelRenderer(this);
			RightLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
			RightLowerWing.addChild(RightLowerWing_r1);
			setRotationAngle(RightLowerWing_r1, 1.4319F, -0.2446F, -0.7479F);
			RightLowerWing_r1.setTextureOffset(97, 3).addBox(-0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, true);
			RightLegs = new ModelRenderer(this);
			RightLegs.setRotationPoint(-6.0F, 3.063F, 7.5211F);
			Body.addChild(RightLegs);
			setRotationAngle(RightLegs, 0.0F, 0.0F, 0.3491F);
			cube_r2 = new ModelRenderer(this);
			cube_r2.setRotationPoint(0.0F, -0.063F, -3.5211F);
			RightLegs.addChild(cube_r2);
			setRotationAngle(cube_r2, 1.5708F, 0.0873F, -1.0472F);
			cube_r2.setTextureOffset(139, 237).addBox(-22.0F, 3.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
			cube_r3 = new ModelRenderer(this);
			cube_r3.setRotationPoint(0.0F, -0.063F, -2.0211F);
			RightLegs.addChild(cube_r3);
			setRotationAngle(cube_r3, 1.5708F, -0.0873F, -1.0472F);
			cube_r3.setTextureOffset(141, 187).addBox(-22.0F, -9.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
			LeftLegs = new ModelRenderer(this);
			LeftLegs.setRotationPoint(6.0F, 3.063F, 7.5211F);
			Body.addChild(LeftLegs);
			setRotationAngle(LeftLegs, 0.0F, 0.0F, -0.3491F);
			cube_r4 = new ModelRenderer(this);
			cube_r4.setRotationPoint(0.0F, -0.063F, -3.5211F);
			LeftLegs.addChild(cube_r4);
			setRotationAngle(cube_r4, 1.5708F, -0.0873F, 1.0472F);
			cube_r4.setTextureOffset(139, 237).addBox(0.0F, 3.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
			cube_r5 = new ModelRenderer(this);
			cube_r5.setRotationPoint(0.0F, -0.063F, -2.0211F);
			LeftLegs.addChild(cube_r5);
			setRotationAngle(cube_r5, 1.5708F, 0.0873F, 1.0472F);
			cube_r5.setTextureOffset(141, 187).addBox(0.0F, -9.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
			RightLegs2 = new ModelRenderer(this);
			RightLegs2.setRotationPoint(-6.0F, 3.063F, 5.5211F);
			Body.addChild(RightLegs2);
			setRotationAngle(RightLegs2, 0.0F, 0.0F, 0.3491F);
			cube_r6 = new ModelRenderer(this);
			cube_r6.setRotationPoint(0.0F, -0.063F, 0.4789F);
			RightLegs2.addChild(cube_r6);
			setRotationAngle(cube_r6, 1.4835F, 0.0F, -1.0472F);
			cube_r6.setTextureOffset(139, 218).addBox(-22.0F, -4.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
			LeftLegs2 = new ModelRenderer(this);
			LeftLegs2.setRotationPoint(6.0F, 3.063F, 5.5211F);
			Body.addChild(LeftLegs2);
			setRotationAngle(LeftLegs2, 0.0F, 0.0F, -0.3491F);
			cube_r7 = new ModelRenderer(this);
			cube_r7.setRotationPoint(0.0F, -0.063F, 0.4789F);
			LeftLegs2.addChild(cube_r7);
			setRotationAngle(cube_r7, 1.4835F, 0.0F, 1.0472F);
			cube_r7.setTextureOffset(139, 218).addBox(0.0F, -4.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
			butt = new ModelRenderer(this);
			butt.setRotationPoint(0.0F, 5.863F, 13.1711F);
			Body.addChild(butt);
			setRotationAngle(butt, -0.0436F, 0.0F, 0.0F);
			cube_r8 = new ModelRenderer(this);
			cube_r8.setRotationPoint(0.0F, -4.5F, 0.25F);
			butt.addChild(cube_r8);
			setRotationAngle(cube_r8, 1.2654F, 0.0F, 0.0F);
			cube_r8.setTextureOffset(54, 135).addBox(-4.0F, 0.2132F, -9.2426F, 8.0F, 21.0F, 10.0F, 0.0F, false);
		}

		@Override
		public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
				float alpha) {
			Head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
			Body.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.antenna.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
			this.RightLegs2.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
			this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
			this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
			this.RightLegs.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
			this.LeftLegs.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
			this.LeftLegs2.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
			this.antenna2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
			this.butt.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
		}
	}

}
