package net.tropicraft.core.client.entity.render;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.tropicraft.core.client.TropicraftRenderUtils;
import net.tropicraft.core.common.entity.projectile.PoisonBlotEntity;

import javax.annotation.Nullable;

@OnlyIn(Dist.CLIENT)
public class PoisonBlotRenderer extends EntityRenderer<PoisonBlotEntity> {

    public PoisonBlotRenderer(EntityRendererProvider.Context context) {
        super(context);
    }

    public void render(final PoisonBlotEntity entity, float entityYaw, float partialTicks, PoseStack stack, MultiBufferSource bufferIn, int packedLightIn) {
        stack.pushPose();
        stack.mulPose(this.entityRenderDispatcher.cameraOrientation());
        stack.mulPose(Vector3f.YP.rotationDegrees(180.0F));
        final VertexConsumer buffer = TropicraftRenderUtils.getEntityCutoutBuilder(bufferIn, getTextureLocation(entity));
        buffer.vertex(-.5, -.5, 0).uv(0, 1).endVertex();
        buffer.vertex( .5, -.5, 0).uv(1, 1).endVertex();
        buffer.vertex( .5,  .5, 0).uv(1, 0).endVertex();
        buffer.vertex(-.5,  .5, 0).uv(0, 0).endVertex();
        stack.popPose();
        super.render(entity, entityYaw, partialTicks, stack, bufferIn, packedLightIn);
    }

    @Nullable
    @Override
    public ResourceLocation getTextureLocation(PoisonBlotEntity entity) {
        return TropicraftRenderUtils.getTextureEntity("treefrog/blot");
    }
}

@@ -141,64 +141,8 @@
 er;%0A
-import net.minecraft.client.renderer.MultiBufferSource;%0A
 impo
@@ -207,37 +207,33 @@
 enderer.
-entity.EntityRenderer
+MultiBufferSource
 ;%0Aimport
@@ -282,24 +282,16 @@
 tyRender
-Dispatch
 er;%0Aimpo
@@ -350,24 +350,85 @@
 erProvider;%0A
+import net.minecraft.client.renderer.texture.OverlayTexture;%0A
 import net.m
@@ -1372,225 +1372,295 @@
     
-buffer.vertex(
+final PoseStack.Pose pose = stack.last();%0A        vertex(pose, buffer, 
 -.5
+f
 , -.5
+f
 , 0
-).uv(0, 1).endVertex();%0A        buffer.vertex(
+, 1, packedLightIn);%0A        vertex(pose, buffer,
  .5
+f
 , -.5
+f
 , 
-0).uv(1, 1).endVertex();%0A        buffer.vertex(
+1, 1, packedLightIn);%0A        vertex(pose, buffer,
  .5
+f
 ,
- 
  .5
+f
 , 
-0).uv(1, 0).endVertex();%0A        buffer.vertex(
+1, 0, packedLightIn);%0A        vertex(pose, buffer, 
 -.5
+f
 ,
- 
  .5
+f
 , 0
-).uv(0, 0).endVertex(
+, 0, packedLightIn
 );%0A 
@@ -1773,24 +1773,419 @@
 In);%0A    %7D%0A%0A
+    private static void vertex(PoseStack.Pose pose, VertexConsumer buffer, float x, float y, float u, float v, int light) %7B%0A        buffer.vertex(pose.pose(), x, y, 0f)%0A                .color(255, 255, 255, 255)%0A                .uv(u, v)%0A                .overlayCoords(OverlayTexture.NO_OVERLAY)%0A                .uv2(light)%0A                .normal(pose.normal(), 0f, 0f, 1f).endVertex();%0A    %7D%0A%0A
     @Nullabl

Fix #439: crashing poison blot renderer