aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-11 22:58:53 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-11 22:58:53 -0230
commit06587d2dc10241ec6a8f5e21c8f55ae710c5cc8d (patch)
tree2a384a70822d75cff3a0706d34385f1bfd1a8763 /src/main/java/com/thatgravyboat/skyblockhud/Utils.java
parent901fd75034e6b013c543abc6d77f1f89fd7f3068 (diff)
downloadSkyblockHud-Death-Defied-06587d2dc10241ec6a8f5e21c8f55ae710c5cc8d.tar.gz
SkyblockHud-Death-Defied-06587d2dc10241ec6a8f5e21c8f55ae710c5cc8d.tar.bz2
SkyblockHud-Death-Defied-06587d2dc10241ec6a8f5e21c8f55ae710c5cc8d.zip
Added crystal hollow waypoints
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/Utils.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/Utils.java89
1 files changed, 85 insertions, 4 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
index 5455c0a..e988677 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java
@@ -1,9 +1,5 @@
package com.thatgravyboat.skyblockhud;
-import java.nio.FloatBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
@@ -12,16 +8,24 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
+import java.nio.FloatBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+
public class Utils {
private static LinkedList<Integer> guiScales = new LinkedList<>();
@@ -273,4 +277,81 @@ public class Utils {
fr.drawString(str, 0, 0, colour, shadow);
GL11.glTranslatef(-x2, -y2, 0);
}
+
+ public static void renderWaypointText(String str, BlockPos loc, float partialTicks) {
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ GlStateManager.pushMatrix();
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+
+ double x = loc.getX() - viewerX;
+ double y = loc.getY() - viewerY - viewer.getEyeHeight();
+ double z = loc.getZ() - viewerZ;
+
+ double distSq = x*x + y*y + z*z;
+ double dist = Math.sqrt(distSq);
+ if(distSq > 144) {
+ x *= 12/dist;
+ y *= 12/dist;
+ z *= 12/dist;
+ }
+ GlStateManager.translate(x, y, z);
+ GlStateManager.translate(0, viewer.getEyeHeight(), 0);
+
+ drawNametag(str);
+
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.translate(0, -0.25f, 0);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+
+ drawNametag(EnumChatFormatting.YELLOW.toString()+Math.round(dist)+"m");
+
+ GlStateManager.popMatrix();
+
+ GlStateManager.disableLighting();
+ }
+
+ public static void drawNametag(String str) {
+ FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
+ float f = 1.6F;
+ float f1 = 0.016666668F * f;
+ GlStateManager.pushMatrix();
+ GL11.glNormal3f(0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.scale(-f1, -f1, f1);
+ GlStateManager.disableLighting();
+ GlStateManager.depthMask(false);
+ GlStateManager.disableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ int i = 0;
+
+ int j = fontrenderer.getStringWidth(str) / 2;
+ GlStateManager.disableTexture2D();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
+ GlStateManager.depthMask(true);
+
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
+
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
}