aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.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/handlers/CrystalWaypoints.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/handlers/CrystalWaypoints.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java90
1 files changed, 90 insertions, 0 deletions
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;
+ }
+ });
+ }
+
+ }
+}