content: package com.github.alexthe666.rats.client.util;
  
  import com.mojang.blaze3d.systems.RenderSystem;
  import com.mojang.blaze3d.vertex.*;
  import net.minecraft.client.Minecraft;
  import net.minecraft.client.renderer.GameRenderer;
  import net.minecraft.core.BlockPos;
  import net.minecraft.resources.ResourceLocation;
  import net.minecraft.world.phys.AABB;
  import net.minecraft.world.phys.Vec3;
  import org.jetbrains.annotations.Nullable;
  import org.joml.Matrix4f;
  
  public class RatsIconRenderUtil {
  	public static void renderPOIIcon(ResourceLocation icon, Vec3 viewVec, @Nullable BlockPos renderPos, float bob, PoseStack stack, BufferBuilder buffer, Tesselator tesselator) {
  		if (renderPos != null && renderPos != BlockPos.ZERO) {
  			stack.pushPose();
  			RenderSystem.enableBlend();
  			RenderSystem.depthMask(false);
  			stack.translate(-viewVec.x(), -viewVec.y(), -viewVec.z());
  			stack.translate(renderPos.getX() + 0.5F, renderPos.getY() + bob, renderPos.getZ() + 0.5F);
  			stack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation());
  			Matrix4f matrix4f = stack.last().pose();
  			RenderSystem.setShader(GameRenderer::getPositionTexShader);
  			RenderSystem.setShaderTexture(0, icon);
  			RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
  			buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
  			buffer.vertex(matrix4f, -0.5F, -0.5F, 0).uv(1.0F, 1.0F).endVertex();
  			buffer.vertex(matrix4f, -0.5F, 0.5F, 0).uv(1.0F, 0.0F).endVertex();
  			buffer.vertex(matrix4f, 0.5F, 0.5F, 0).uv(0.0F, 0.0F).endVertex();
  			buffer.vertex(matrix4f, 0.5F, -0.5F, 0).uv(0.0F, 1.0F).endVertex();
  			tesselator.end();
  			RenderSystem.disableBlend();
  			RenderSystem.depthMask(true);
  			stack.popPose();
  		}
  	}
  
  	public static void renderBox(ResourceLocation texture, Vec3 viewPos, Vec3 centerPos, AABB boxSize, PoseStack stack) {
  		RenderSystem.enableBlend();
  		RenderSystem.setShader(GameRenderer::getPositionTexShader);
  		RenderSystem.setShaderTexture(0, texture);
  		RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
  		RenderSystem.disableCull();
  		RenderSystem.depthMask(false);
  		stack.pushPose();
  		stack.translate(-viewPos.x(), -viewPos.y(), -viewPos.z());
  		stack.translate(centerPos.x(), centerPos.y(), centerPos.z());
  		RenderSystem.runAsFancy(() -> renderMovingAABB(boxSize, stack));
  		stack.popPose();
  		RenderSystem.depthMask(true);
  		RenderSystem.enableCull();
  		RenderSystem.disableBlend();
  	}
  
  	public static void renderMovingAABB(AABB boundingBox, PoseStack stack) {
  		Tesselator tessellator = Tesselator.getInstance();
  		VertexConsumer vertexbuffer = tessellator.getBuilder();
  		BufferBuilder buffer = tessellator.getBuilder();
  		RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
  		float f3 = Minecraft.getInstance().isPaused() ? 0.0F : (float) (System.currentTimeMillis() % 3000L) / 3000.0F;
  		Matrix4f matrix4f = stack.last().pose();
  		float maxX = (float) boundingBox.maxX * 0.125F;
  		float minX = (float) boundingBox.minX * 0.125F;
  		float maxY = (float) boundingBox.maxY * 0.125F;
  		float minY = (float) boundingBox.minY * 0.125F;
  		float maxZ = (float) boundingBox.maxZ * 0.125F;
  		float minZ = (float) boundingBox.minZ * 0.125F;
  		buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
  		//north
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + maxY - minY).color(255, 255, 255, 255).normal(0.0F, 0.0F, -1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + maxX - minX, f3 + maxY - minY).color(255, 255, 255, 255).normal(0.0F, 0.0F, -1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 0.0F, -1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 0.0F, -1.0F).endVertex();
  
  		//south
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 0.0F, 1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 0.0F, 1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + maxY - minY).color(255, 255, 255, 255).normal(0.0F, 0.0F, 1.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + minX - maxX, f3 + maxY - minY).color(255, 255, 255, 255).normal(0.0F, 0.0F, 1.0F).endVertex();
  
  		//bottom
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, -1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, -1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + maxZ - minZ).color(255, 255, 255, 255).normal(0.0F, -1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + maxZ - minZ).color(255, 255, 255, 255).normal(0.0F, -1.0F, 0.0F).endVertex();
  
  		//top
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(0.0F, 1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + maxX - minX, f3 + maxZ - minZ).color(255, 255, 255, 255).normal(0.0F, 1.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + maxZ - minZ).color(255, 255, 255, 255).normal(0.0F, 1.0F, 0.0F).endVertex();
  
  		//west
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(-1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + maxY - minY).color(255, 255, 255, 255).normal(-1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + maxX - minX, f3 + maxY - minY).color(255, 255, 255, 255).normal(-1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.minX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(-1.0F, 0.0F, 0.0F).endVertex();
  
  		//east
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + minY - maxY).color(255, 255, 255, 255).normal(1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.minZ).uv(f3 + minX - maxX, f3 + maxY - minY).color(255, 255, 255, 255).normal(1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.maxY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + maxY - minY).color(255, 255, 255, 255).normal(1.0F, 0.0F, 0.0F).endVertex();
  		vertexbuffer.vertex(matrix4f, (float) boundingBox.maxX, (float) boundingBox.minY, (float) boundingBox.maxZ).uv(f3 + maxX - minX, f3 + minY - maxY).color(255, 255, 255, 255).normal(1.0F, 0.0F, 0.0F).endVertex();
  		tessellator.end();
  	}
  }
  