
package studio.halbear.hem.entity.renderer;

import studio.halbear.hem.entity.EmberleafMilitaryRobotLowerHalfEntity;

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

					@Override
					public ResourceLocation getEntityTexture(Entity entity) {
						return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotdestroyed.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 ModelEmberleafMilitaryBotLowerHalf extends EntityModel<Entity> {
		private final ModelRenderer LeftLeg;
		private final ModelRenderer RightLeg;
		private final ModelRenderer UpperHalf;
		private final ModelRenderer cube_r1;
		private final ModelRenderer cube_r2;
		private final ModelRenderer Spine;
		private final ModelRenderer cube_r3;
		private final ModelRenderer bb_main;

		public ModelEmberleafMilitaryBotLowerHalf() {
			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);
			UpperHalf = new ModelRenderer(this);
			UpperHalf.setRotationPoint(0.025F, 2.2F, 2.025F);
			setRotationAngle(UpperHalf, 0.0F, 0.0F, 0.0873F);
			UpperHalf.setTextureOffset(61, 14).addBox(-2.025F, -16.2F, -2.025F, 4.0F, 9.0F, 0.0F, 0.0F, false);
			cube_r1 = new ModelRenderer(this);
			cube_r1.setRotationPoint(0.0F, -5.6F, -4.55F);
			UpperHalf.addChild(cube_r1);
			setRotationAngle(cube_r1, 0.2182F, 0.0F, -3.1416F);
			cube_r1.setTextureOffset(17, 76).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
			cube_r2 = new ModelRenderer(this);
			cube_r2.setRotationPoint(-0.025F, 0.05F, -0.025F);
			UpperHalf.addChild(cube_r2);
			setRotationAngle(cube_r2, 0.0873F, 0.0F, 0.0F);
			cube_r2.setTextureOffset(17, 75).addBox(-4.0F, -6.0F, -4.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
			Spine = new ModelRenderer(this);
			Spine.setRotationPoint(-0.025F, -15.7F, -1.9375F);
			UpperHalf.addChild(Spine);
			setRotationAngle(Spine, 0.0F, 0.0F, 0.1309F);
			cube_r3 = new ModelRenderer(this);
			cube_r3.setRotationPoint(0.0F, 0.0F, 0.0F);
			Spine.addChild(cube_r3);
			setRotationAngle(cube_r3, 0.0F, 0.0F, 2.0071F);
			cube_r3.setTextureOffset(61, 14).addBox(-2.0305F, -7.8824F, 0.0F, 4.0F, 9.0F, 0.0F, 0.0F, false);
			bb_main = new ModelRenderer(this);
			bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
			bb_main.setTextureOffset(76, 0).addBox(-2.0F, -21.75F, -2.0F, 4.0F, 5.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);
			UpperHalf.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.RightLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
			this.Spine.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
		}
	}

}
