aboutsummaryrefslogtreecommitdiff
path: root/src/main
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
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')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java12
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/Utils.java89
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/events/LocationChangeEvent.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java7
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java90
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java5
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java16
7 files changed, 216 insertions, 19 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index 85dc914..0633916 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -20,11 +20,6 @@ import com.thatgravyboat.skyblockhud.overlay.OverlayHud;
import com.thatgravyboat.skyblockhud.overlay.RPGHud;
import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing;
import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler;
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.scoreboard.ScoreObjective;
@@ -42,6 +37,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.input.Keyboard;
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Set;
+
@Mod(modid = SkyblockHud.MODID, version = SkyblockHud.VERSION)
public class SkyblockHud {
@@ -82,6 +83,7 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new ComponentHandler());
MinecraftForge.EVENT_BUS.register(new ActionBarParsing());
+ MinecraftForge.EVENT_BUS.register(new CrystalWaypoints());
Commands.init();
configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json");
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();
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/LocationChangeEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/LocationChangeEvent.java
new file mode 100644
index 0000000..cb11337
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/LocationChangeEvent.java
@@ -0,0 +1,16 @@
+package com.thatgravyboat.skyblockhud.api.events;
+
+import com.thatgravyboat.skyblockhud.location.Locations;
+import net.minecraftforge.fml.common.eventhandler.Event;
+
+public class LocationChangeEvent extends Event {
+
+ public Locations oldLocation;
+ public Locations newLocation;
+
+ public LocationChangeEvent(Locations oldLocation, Locations newLocation){
+ this.oldLocation = oldLocation;
+ this.newLocation = newLocation;
+ }
+}
+
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
index de5fa7e..8c4ec60 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
@@ -6,11 +6,10 @@ import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.api.LeaderboardGetter;
import com.thatgravyboat.skyblockhud.config.SBHConfigEditor;
import com.thatgravyboat.skyblockhud.core.GuiScreenElementWrapper;
+import com.thatgravyboat.skyblockhud.handlers.CrystalWaypoints;
import com.thatgravyboat.skyblockhud.handlers.MapHandler;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.playerstats.ActionBarParsing;
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.util.ChatComponentText;
@@ -18,6 +17,9 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.ClientCommandHandler;
import org.apache.commons.lang3.StringUtils;
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
+
public class Commands {
private static boolean devMode = false;
@@ -84,6 +86,7 @@ public class Commands {
ClientCommandHandler.instance.registerCommand(settingsCommand3);
ClientCommandHandler.instance.registerCommand(mapCommand);
ClientCommandHandler.instance.registerCommand(devCommand);
+ ClientCommandHandler.instance.registerCommand(new CrystalWaypoints.WaypointCommand());
}
private static void sendSBHMessage(ICommandSender sender, String message) {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java
new file mode 100644
index 0000000..cd016e6
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java
@@ -0,0 +1,90 @@
+package com.thatgravyboat.skyblockhud.handlers;
+
+import com.google.common.collect.Lists;
+import com.thatgravyboat.skyblockhud.Utils;
+import com.thatgravyboat.skyblockhud.api.events.LocationChangeEvent;
+import com.thatgravyboat.skyblockhud.commands.SimpleCommand;
+import com.thatgravyboat.skyblockhud.location.LocationCategory;
+import com.thatgravyboat.skyblockhud.location.LocationHandler;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+public class CrystalWaypoints {
+
+ public static final HashMap<String, BlockPos> waypoints = new HashMap<>();
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ waypoints.forEach((text, pos) -> {
+ GlStateManager.disableCull();
+ GlStateManager.disableDepth();
+ Utils.renderWaypointText(text, pos,event.partialTicks);
+ });
+ GlStateManager.enableCull();
+ GlStateManager.enableDepth();
+ }
+
+ @SubscribeEvent
+ public void onLocationChange(LocationChangeEvent event) {
+ if (!event.newLocation.getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){
+ waypoints.clear();
+ }
+ }
+
+ public static class WaypointCommand extends SimpleCommand {
+
+ public WaypointCommand() {
+ super("sbhpoints", new ProcessCommandRunnable() {
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ String subCommand = args[0].toLowerCase();
+ String name = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
+ switch (subCommand) {
+ case "add":
+ if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){
+ if (!CrystalWaypoints.waypoints.containsKey(name)){
+ CrystalWaypoints.waypoints.put(name, sender.getPosition().add(0.5,0.5,0.5));
+ }else {
+ sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint already exists!"));
+ }
+ }
+ break;
+ case "remove":
+ if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){
+ if (CrystalWaypoints.waypoints.containsKey(name)){
+ CrystalWaypoints.waypoints.remove(name);
+ }else {
+ sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint doesnt exist!"));
+ }
+ }
+ break;
+ case "clear":
+ CrystalWaypoints.waypoints.clear();
+ break;
+ }
+ }
+ }, new TabCompleteRunnable() {
+ @Override
+ public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {
+ return getListOfStringsMatchingLastWord(args, waypoints.keySet());
+ }
+ if (args.length == 1) {
+ return getListOfStringsMatchingLastWord(args, Lists.newArrayList("add", "clear", "remove"));
+ }
+ return null;
+ }
+ });
+ }
+
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java
index f3e4955..d64a217 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java
@@ -2,10 +2,11 @@ package com.thatgravyboat.skyblockhud.handlers.mapicons;
import com.thatgravyboat.skyblockhud.ComponentBuilder;
import com.thatgravyboat.skyblockhud.handlers.MapHandler;
+import net.minecraft.util.ResourceLocation;
+
+import javax.vecmath.Vector2f;
import java.util.ArrayList;
import java.util.List;
-import javax.vecmath.Vector2f;
-import net.minecraft.util.ResourceLocation;
public class DwarvenIcons {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
index d4a0d0e..7796799 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
@@ -1,9 +1,12 @@
package com.thatgravyboat.skyblockhud.location;
+import com.thatgravyboat.skyblockhud.api.events.LocationChangeEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
-import java.util.Locale;
+import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import java.util.Locale;
+
public class LocationHandler {
private static Locations currentLocation = Locations.NONE;
@@ -20,10 +23,6 @@ public class LocationHandler {
}
}
- public static void setCurrentLocation(String location) {
- currentLocation = Locations.get(location);
- }
-
public static void setCurrentLocation(Locations location) {
currentLocation = location;
}
@@ -35,7 +34,12 @@ public class LocationHandler {
public static void handleLocation(String locationLine) {
String location = locationLine.replace(" ", "").toUpperCase(Locale.ENGLISH).trim();
if (location.startsWith("THECATACOMBS")) {
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, Locations.CATACOMBS));
currentLocation = Locations.CATACOMBS;
- } else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", ""));
+ } else {
+ Locations locations = Locations.get(location.replaceAll("[^A-Za-z0-9]", ""));
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, locations));
+ currentLocation = locations;
+ }
}
}