package net.geforcemods.securitycraft.renderers;

import com.mojang.blaze3d.matrix.MatrixStack;

import net.geforcemods.securitycraft.SCContent;
import net.geforcemods.securitycraft.entity.BouncingBettyEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.EmptyModelData;

@OnlyIn(Dist.CLIENT)
public class BouncingBettyRenderer extends EntityRenderer<BouncingBettyEntity> {

	public BouncingBettyRenderer(EntityRendererManager renderManager)
	{
		super(renderManager);
		shadowSize = 0.5F;
	}

	@Override
	public void render(BouncingBettyEntity entity, float p_225623_2_, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffer, int p_225623_6_)
	{
		int overlayTextureToUse;

		matrix.push();
		matrix.translate(0.0D, 0.5D, 0.0D);

		if (entity.fuse - partialTicks + 1.0F < 10.0F)
		{
			float alpha = 1.0F - (entity.fuse - partialTicks + 1.0F) / 10.0F;
			alpha = MathHelper.clamp(alpha, 0.0F, 1.0F);
			alpha *= alpha;
			alpha *= alpha;
			float scale = 1.0F + alpha * 0.3F;
			matrix.scale(scale, scale, scale);
		}

		if (entity.fuse / 5 % 2 == 0)
			overlayTextureToUse = OverlayTexture.packLight(OverlayTexture.lightToInt(1.0F), 10);
		else
			overlayTextureToUse = OverlayTexture.DEFAULT_LIGHT;

		matrix.rotate(Vector3f.YP.rotationDegrees(-90.0F));
		matrix.translate(-0.5D, -0.5D, 0.5D);
		matrix.rotate(Vector3f.YP.rotationDegrees(90.0F));
		Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(SCContent.bouncingBetty.getDefaultState(), matrix, buffer, p_225623_6_, overlayTextureToUse, EmptyModelData.INSTANCE);
		matrix.pop();
		super.render(entity, p_225623_2_, partialTicks, matrix, buffer, p_225623_6_);
	}

	@Override
	public ResourceLocation getEntityTexture(BouncingBettyEntity entity)
	{
		return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
	}
}
@@ -778,68 +778,8 @@
 yIn;
-%0Aimport net.minecraftforge.client.model.data.EmptyModelData;
 %0A%0A@O
@@ -1063,27 +1063,25 @@
 , float 
-p_225623_2_
+entityYaw
 , float 
@@ -1149,50 +1149,22 @@
 nt p
-_225623_6_)%0A%09%7B%0A%09%09int overlayTextureToUse;%0A
+ackedLight)%0A%09%7B
 %0A%09%09m
@@ -1216,25 +1216,24 @@
 0.0D);%0A%0A%09%09if
- 
 (entity.fuse
@@ -1508,191 +1508,8 @@
 %09%7D%0A%0A
-%09%09if (entity.fuse / 5 %25 2 == 0)%0A%09%09%09overlayTextureToUse = OverlayTexture.packLight(OverlayTexture.lightToInt(1.0F), 10);%0A%09%09else%0A%09%09%09overlayTextureToUse = OverlayTexture.DEFAULT_LIGHT;%0A%0A
 %09%09ma
@@ -1782,21 +1782,21 @@
 r, p
-_225623_6_, o
+ackedLight, O
 verl
@@ -1808,38 +1808,22 @@
 ture
-ToUse, EmptyModelData.INSTANCE
+.DEFAULT_LIGHT
 );%0A%09
@@ -1864,19 +1864,17 @@
 ty, 
-p_225623_2_
+entityYaw
 , pa
@@ -1906,18 +1906,18 @@
 r, p
-_225623_6_
+ackedLight
 );%0A%09

change bouncing betty renderer a bit