package dev.crucifixbeta.api.utils.render;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.api.utils.Wrapper;
import java.awt.Color;
import java.util.ArrayList;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer.TextLayerType;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.BuiltBuffer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.VertexConsumerProvider.Immediate;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.util.BufferAllocator;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.MatrixStack.Entry;
import net.minecraft.entity.Entity;
import net.minecraft.text.Text;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix4f;
import org.joml.Vector3f;

@Environment(EnvType.CLIENT)
public class Render3DUtil implements Wrapper {
   public static void endBuilding(BufferBuilder bb) {
      BuiltBuffer var1 = bb.end();
      if (var1 != null) {
         BufferRenderer.drawWithGlobalProgram(var1);
      }
   }

   public static MatrixStack matrixFrom(double x, double y, double z) {
      MatrixStack var6 = new MatrixStack();
      Camera var7 = mc.gameRenderer.getCamera();
      var6.multiply(RotationAxis.POSITIVE_X.rotationDegrees(var7.getPitch()));
      var6.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(var7.getYaw() + 180.0F));
      var6.translate(x - var7.getPos().x, y - var7.getPos().y, z - var7.getPos().z);
      return var6;
   }

   public static void drawText3D(String text, Vec3d vec3d, Color color) {
      drawText3D(Text.of(text), vec3d.x, vec3d.y, vec3d.z, 0.0, 0.0, 1.0, color.getRGB());
   }

   public static void drawText3D(String text, Vec3d vec3d, Color color, boolean shadow) {
      drawText3D(Text.of(text), vec3d.x, vec3d.y, vec3d.z, 0.0, 0.0, 1.0, color.getRGB(), shadow);
   }

   public static void drawText3D(String text, Vec3d vec3d, int color) {
      drawText3D(Text.of(text), vec3d.x, vec3d.y, vec3d.z, 0.0, 0.0, 1.0, color);
   }

   public static void drawText3D(Text text, Vec3d vec3d, double offX, double offY, double scale, Color color) {
      drawText3D(text, vec3d.x, vec3d.y, vec3d.z, offX, offY, scale, color.getRGB());
   }

   public static void drawText3D(Text text, double x, double y, double z, double offX, double offY, double scale, int color) {
      drawText3D(text, x, y, z, offX, offY, scale, color, false);
   }

   public static void drawText3D(Text text, double x, double y, double z, double offX, double offY, double scale, int color, boolean shadow) {
      RenderSystem.disableDepthTest();
      MatrixStack var15 = matrixFrom(x, y, z);
      Camera var16 = mc.gameRenderer.getCamera();
      var15.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-var16.getYaw()));
      var15.multiply(RotationAxis.POSITIVE_X.rotationDegrees(var16.getPitch()));
      RenderSystem.enableBlend();
      var15.translate(offX, offY, 0.0);
      var15.scale(-0.025F * (float)scale, -0.025F * (float)scale, 1.0F);
      int var17 = mc.textRenderer.getWidth(text) / 2;
      Immediate var18 = VertexConsumerProvider.immediate(new BufferAllocator(1536));
      mc.textRenderer.draw(text.copy(), (float)(-var17), 0.0F, color, false, var15.peek().getPositionMatrix(), var18, TextLayerType.SEE_THROUGH, 0, 15728880);
      var18.draw();
      RenderSystem.disableBlend();
      RenderSystem.enableDepthTest();
   }

   public static void drawFill(MatrixStack matrixStack, Box bb, Color fillColor) {
      draw3DBox(matrixStack, bb, fillColor, new Color(0, 0, 0, 0), false, true);
   }

   public static void drawBox(MatrixStack matrixStack, Box bb, Color outlineColor) {
      draw3DBox(matrixStack, bb, new Color(0, 0, 0, 0), outlineColor, true, false);
   }

   public static void drawBox(MatrixStack matrixStack, Box bb, Color outlineColor, float lineWidth) {
      draw3DBox(matrixStack, bb, new Color(0, 0, 0, 0), outlineColor, true, false, lineWidth);
   }

   public static void draw3DBox(MatrixStack matrixStack, Box box, Color fillColor, Color outlineColor) {
      draw3DBox(matrixStack, box, fillColor, outlineColor, true, true);
   }

   public static void draw3DBox(MatrixStack matrixStack, Box box, Color fillColor, Color outlineColor, boolean outline, boolean fill) {
      draw3DBox(matrixStack, box, fillColor, outlineColor, outline, fill, 1.5F);
   }

   public static void draw3DBox(MatrixStack matrixStack, Box box, Color fillColor, Color outlineColor, boolean outline, boolean fill, float lineWidth) {
      box = box.offset(mc.gameRenderer.getCamera().getPos().negate());
      RenderSystem.enableBlend();
      RenderSystem.disableDepthTest();
      Matrix4f var7 = matrixStack.peek().getPositionMatrix();
      if (outline) {
         float var8 = (float)outlineColor.getAlpha() / 255.0F;
         float var9 = (float)outlineColor.getRed() / 255.0F;
         float var10 = (float)outlineColor.getGreen() / 255.0F;
         float var11 = (float)outlineColor.getBlue() / 255.0F;
         RenderSystem.setShader(GameRenderer::getPositionColorProgram);
         RenderSystem.lineWidth(lineWidth);
         BufferBuilder var12 = Tessellator.getInstance().begin(DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var9, var10, var11, var8);
         var12.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var9, var10, var11, var8);
         BufferRenderer.drawWithGlobalProgram(var12.end());
      }

      if (fill) {
         float var14 = (float)fillColor.getAlpha() / 255.0F;
         float var15 = (float)fillColor.getRed() / 255.0F;
         float var16 = (float)fillColor.getGreen() / 255.0F;
         float var17 = (float)fillColor.getBlue() / 255.0F;
         RenderSystem.setShader(GameRenderer::getPositionColorProgram);
         BufferBuilder var18 = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.maxX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.minZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.minY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.maxZ).color(var15, var16, var17, var14);
         var18.vertex(var7, (float)box.minX, (float)box.maxY, (float)box.minZ).color(var15, var16, var17, var14);
         BufferRenderer.drawWithGlobalProgram(var18.end());
      }

      RenderSystem.enableDepthTest();
      RenderSystem.disableBlend();
   }

   public static void drawFadeFill(MatrixStack stack, Box box, Color c, Color c1) {
      RenderSystem.enableBlend();
      RenderSystem.disableDepthTest();
      RenderSystem.disableCull();
      RenderSystem.setShader(GameRenderer::getPositionColorProgram);
      BufferBuilder var4 = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR);
      Matrix4f var5 = stack.peek().getPositionMatrix();
      float var6 = (float)(box.minX - mc.getEntityRenderDispatcher().camera.getPos().getX());
      float var7 = (float)(box.minY - mc.getEntityRenderDispatcher().camera.getPos().getY());
      float var8 = (float)(box.minZ - mc.getEntityRenderDispatcher().camera.getPos().getZ());
      float var9 = (float)(box.maxX - mc.getEntityRenderDispatcher().camera.getPos().getX());
      float var10 = (float)(box.maxY - mc.getEntityRenderDispatcher().camera.getPos().getY());
      float var11 = (float)(box.maxZ - mc.getEntityRenderDispatcher().camera.getPos().getZ());
      var4.vertex(var5, var6, var7, var8).color(c.getRGB());
      var4.vertex(var5, var9, var7, var8).color(c.getRGB());
      var4.vertex(var5, var9, var7, var11).color(c.getRGB());
      var4.vertex(var5, var6, var7, var11).color(c.getRGB());
      var4.vertex(var5, var6, var7, var8).color(c.getRGB());
      var4.vertex(var5, var6, var10, var8).color(c1.getRGB());
      var4.vertex(var5, var9, var10, var8).color(c1.getRGB());
      var4.vertex(var5, var9, var7, var8).color(c.getRGB());
      var4.vertex(var5, var9, var7, var8).color(c.getRGB());
      var4.vertex(var5, var9, var10, var8).color(c1.getRGB());
      var4.vertex(var5, var9, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var9, var7, var11).color(c.getRGB());
      var4.vertex(var5, var6, var7, var11).color(c.getRGB());
      var4.vertex(var5, var9, var7, var11).color(c.getRGB());
      var4.vertex(var5, var9, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var6, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var6, var7, var8).color(c.getRGB());
      var4.vertex(var5, var6, var7, var11).color(c.getRGB());
      var4.vertex(var5, var6, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var6, var10, var8).color(c1.getRGB());
      var4.vertex(var5, var6, var10, var8).color(c1.getRGB());
      var4.vertex(var5, var6, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var9, var10, var11).color(c1.getRGB());
      var4.vertex(var5, var9, var10, var8).color(c1.getRGB());
      BufferRenderer.drawWithGlobalProgram(var4.end());
      RenderSystem.enableDepthTest();
      RenderSystem.enableCull();
      RenderSystem.disableBlend();
   }

   public static void drawLine(Vec3d start, Vec3d end, Color color) {
      drawLine(start.x, start.getY(), start.z, end.getX(), end.getY(), end.getZ(), color, 1.0F);
   }

   public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, Color color, float width) {
      RenderSystem.enableBlend();
      MatrixStack var14 = matrixFrom(x1, y1, z1);
      RenderSystem.disableCull();
      RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram);
      RenderSystem.lineWidth(width);
      BufferBuilder var15 = Tessellator.getInstance().begin(DrawMode.LINES, VertexFormats.LINES);
      vertexLine(var14, var15, 0.0, 0.0, 0.0, (double)((float)(x2 - x1)), (double)((float)(y2 - y1)), (double)((float)(z2 - z1)), color);
      BufferRenderer.drawWithGlobalProgram(var15.end());
      RenderSystem.enableCull();
      RenderSystem.lineWidth(1.0F);
      RenderSystem.disableBlend();
   }

   public static void vertexLine(MatrixStack matrices, VertexConsumer buffer, double x1, double y1, double z1, double x2, double y2, double z2, Color lineColor) {
      Matrix4f var15 = matrices.peek().getPositionMatrix();
      Entry var16 = matrices.peek();
      Vector3f var17 = getNormal((float)x1, (float)y1, (float)z1, (float)x2, (float)y2, (float)z2);
      buffer.vertex(var15, (float)x1, (float)y1, (float)z1)
         .color(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), lineColor.getAlpha())
         .normal(var16, var17.x(), var17.y(), var17.z());
      buffer.vertex(var15, (float)x2, (float)y2, (float)z2)
         .color(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), lineColor.getAlpha())
         .normal(var16, var17.x(), var17.y(), var17.z());
   }

   public static Vector3f getNormal(float x1, float y1, float z1, float x2, float y2, float z2) {
      float var6 = x2 - x1;
      float var7 = y2 - y1;
      float var8 = z2 - z1;
      float var9 = MathHelper.sqrt(var6 * var6 + var7 * var7 + var8 * var8);
      return new Vector3f(var6 / var9, var7 / var9, var8 / var9);
   }

   public static void drawTargetEsp(MatrixStack stack, @NotNull Entity target, Color color) {
      ArrayList var3 = new ArrayList();
      ArrayList var4 = new ArrayList();
      ArrayList var5 = new ArrayList();
      double var6 = target.prevX + (target.getX() - target.prevX) * (double)getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getX();
      double var8 = target.prevY + (target.getY() - target.prevY) * (double)getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getY();
      double var10 = target.prevZ + (target.getZ() - target.prevZ) * (double)getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getZ();
      double var12 = (double)target.getHeight();

      for (int var14 = 0; var14 <= 361; var14++) {
         double var15 = Math.sin(Math.toRadians((double)var14));
         double var17 = Math.cos(Math.toRadians((double)var14));
         Vec3d var19 = new Vec3d((double)((float)(var17 * 0.5)), var12, (double)((float)(var15 * 0.5)));
         var3.add(var19);
         double var20 = Math.sin(Math.toRadians((double)((var14 + 120) % 360)));
         double var22 = Math.cos(Math.toRadians((double)(var14 + 120)) % 360.0);
         Vec3d var24 = new Vec3d((double)((float)(var22 * 0.5)), var12, (double)((float)(var20 * 0.5)));
         var4.add(var24);
         double var25 = Math.sin(Math.toRadians((double)((var14 + 240) % 360)));
         double var27 = Math.cos(Math.toRadians((double)((var14 + 240) % 360)));
         Vec3d var29 = new Vec3d((double)((float)(var27 * 0.5)), var12, (double)((float)(var25 * 0.5)));
         var5.add(var29);
         var12 -= 0.004F;
      }

      stack.push();
      stack.translate(var6, var8, var10);
      RenderSystem.enableBlend();
      RenderSystem.disableCull();
      RenderSystem.disableDepthTest();
      RenderSystem.setShader(GameRenderer::getPositionColorProgram);
      BufferBuilder var33 = Tessellator.getInstance().begin(DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR);
      Matrix4f var30 = stack.peek().getPositionMatrix();

      for (int var31 = 0; var31 < var3.size() - 1; var31++) {
         float var32 = 1.0F - ((float)var31 + (float)(System.currentTimeMillis() - CrucifixBeta.initTime) / 5.0F) % 360.0F / 60.0F;
         var33.vertex(var30, (float)((Vec3d)var3.get(var31)).x, (float)((Vec3d)var3.get(var31)).y, (float)((Vec3d)var3.get(var31)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var31 / 20.0F)), 10, 1.0), (int)(var32 * 255.0F)).getRGB());
         var33.vertex(var30, (float)((Vec3d)var3.get(var31 + 1)).x, (float)((Vec3d)var3.get(var31 + 1)).y + 0.1F, (float)((Vec3d)var3.get(var31 + 1)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var31 / 20.0F)), 10, 1.0), (int)(var32 * 255.0F)).getRGB());
      }

      endBuilding(var33);
      RenderSystem.setShader(GameRenderer::getPositionColorProgram);
      var33 = Tessellator.getInstance().begin(DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR);

      for (int var36 = 0; var36 < var4.size() - 1; var36++) {
         float var38 = 1.0F - ((float)var36 + (float)(System.currentTimeMillis() - CrucifixBeta.initTime) / 5.0F) % 360.0F / 60.0F;
         var33.vertex(var30, (float)((Vec3d)var4.get(var36)).x, (float)((Vec3d)var4.get(var36)).y, (float)((Vec3d)var4.get(var36)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var36 / 20.0F)), 10, 1.0), (int)(var38 * 255.0F)).getRGB());
         var33.vertex(var30, (float)((Vec3d)var4.get(var36 + 1)).x, (float)((Vec3d)var4.get(var36 + 1)).y + 0.1F, (float)((Vec3d)var4.get(var36 + 1)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var36 / 20.0F)), 10, 1.0), (int)(var38 * 255.0F)).getRGB());
      }

      endBuilding(var33);
      RenderSystem.setShader(GameRenderer::getPositionColorProgram);
      var33 = Tessellator.getInstance().begin(DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR);

      for (int var37 = 0; var37 < var5.size() - 1; var37++) {
         float var39 = 1.0F - ((float)var37 + (float)(System.currentTimeMillis() - CrucifixBeta.initTime) / 5.0F) % 360.0F / 60.0F;
         var33.vertex(var30, (float)((Vec3d)var5.get(var37)).x, (float)((Vec3d)var5.get(var37)).y, (float)((Vec3d)var5.get(var37)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var37 / 20.0F)), 10, 1.0), (int)(var39 * 255.0F)).getRGB());
         var33.vertex(var30, (float)((Vec3d)var5.get(var37 + 1)).x, (float)((Vec3d)var5.get(var37 + 1)).y + 0.1F, (float)((Vec3d)var5.get(var37 + 1)).z)
            .color(ColorUtil.injectAlpha(ColorUtil.pulseColor(color, (double)((int)((float)var37 / 20.0F)), 10, 1.0), (int)(var39 * 255.0F)).getRGB());
      }

      endBuilding(var33);
      RenderSystem.enableCull();
      stack.translate(-var6, -var8, -var10);
      RenderSystem.disableBlend();
      RenderSystem.enableDepthTest();
      stack.pop();
   }

   public static float getTickDelta() {
      return mc.getRenderTickCounter().getTickDelta(true);
   }
}
