aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/gui/crystalhollowwaypoints
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2022-08-15 20:40:34 -0400
committerGitHub <noreply@github.com>2022-08-15 20:40:34 -0400
commit3aa11b859a2a22be30a5035f7273e1a604a4dde4 (patch)
tree8f428b29a6b56cc9d010b0441bf41b6b78373548 /src/main/java/me/Danker/gui/crystalhollowwaypoints
parent33710ac6d9f57fa59e8dfb19a81b053346f1b097 (diff)
parentdaceea1e42371c295c36f80b3246601a6ffb2cc5 (diff)
downloadSkyblockMod-1.8.7.tar.gz
SkyblockMod-1.8.7.tar.bz2
SkyblockMod-1.8.7.zip
Merge pull request #124 from bowser0000/developmentHEADv1.8.7master
1.8.7
Diffstat (limited to 'src/main/java/me/Danker/gui/crystalhollowwaypoints')
-rw-r--r--src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java133
-rw-r--r--src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointActionGui.java93
-rw-r--r--src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointsGui.java150
3 files changed, 376 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java
new file mode 100644
index 0000000..52c0fba
--- /dev/null
+++ b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java
@@ -0,0 +1,133 @@
+package me.Danker.gui.crystalhollowwaypoints;
+
+import me.Danker.features.CrystalHollowWaypoints;
+import me.Danker.handlers.TextRenderer;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.BlockPos;
+
+import java.io.IOException;
+
+public class CrystalHollowAddWaypointGui extends GuiScreen {
+
+ private GuiButton cancel;
+
+ private GuiTextField name;
+ private GuiButton curPos;
+ private GuiTextField x;
+ private GuiTextField y;
+ private GuiTextField z;
+ private GuiButton add;
+
+ private int xPos = -1;
+ private int yPos = -1;
+ private int zPos = -1;
+
+ public CrystalHollowAddWaypointGui() {}
+
+ public CrystalHollowAddWaypointGui(int x, int y, int z) {
+ xPos = x;
+ yPos = y;
+ zPos = z;
+ }
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ int height = sr.getScaledHeight();
+ int width = sr.getScaledWidth();
+
+ cancel = new GuiButton(0, 2, height - 30, 100, 20, "Cancel");
+
+ name = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.1), 200, 20);
+ curPos = new GuiButton(0, width / 2 - 50, (int) (height * 0.25), 100, 20, "Current Position");
+ x = new GuiTextField(0, this.fontRendererObj, width / 2 - 85, (int) (height * 0.4), 50, 20);
+ y = new GuiTextField(0, this.fontRendererObj, width / 2 - 25, (int) (height * 0.4), 50, 20);
+ z = new GuiTextField(0, this.fontRendererObj, width / 2 + 35, (int) (height * 0.4), 50, 20);
+ add = new GuiButton(0, width / 2 - 25, (int) (height * 0.6), 50, 20, "Add");
+
+ name.setVisible(true);
+ name.setEnabled(true);
+ x.setVisible(true);
+ x.setEnabled(true);
+ if (xPos != -1) x.setText(xPos + "");
+ y.setVisible(true);
+ y.setEnabled(true);
+ if (yPos != -1) y.setText(yPos + "");
+ z.setVisible(true);
+ z.setEnabled(true);
+ if (zPos != -1) z.setText(zPos + "");
+
+ this.buttonList.add(cancel);
+ this.buttonList.add(curPos);
+ this.buttonList.add(add);
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ this.drawDefaultBackground();
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ name.drawTextBox();
+ x.drawTextBox();
+ y.drawTextBox();
+ z.drawTextBox();
+
+ new TextRenderer(mc, "X:", width / 2 - 85, (int) (height * 0.35), 1D);
+ new TextRenderer(mc, "Y:", width / 2 - 25, (int) (height * 0.35), 1D);
+ new TextRenderer(mc, "Z:", width / 2 + 35, (int) (height * 0.35), 1D);
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ EntityPlayer player = Minecraft.getMinecraft().thePlayer;
+
+ if (button == cancel) {
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ } else if (button == curPos) {
+ x.setText(Integer.toString(player.getPosition().getX()));
+ y.setText(Integer.toString(player.getPosition().getY()));
+ z.setText(Integer.toString(player.getPosition().getZ()));
+ } else if (button == add) {
+ String loc = name.getText().length() == 0 ? Integer.toString(CrystalHollowWaypoints.waypoints.size()) : name.getText();
+ int xPos = x.getText().matches("[-]?\\d+") ? Integer.parseInt(x.getText()) : player.getPosition().getX();
+ int yPos = y.getText().matches("[-]?\\d+") ? Integer.parseInt(y.getText()) : player.getPosition().getY();
+ int zPos = z.getText().matches("[-]?\\d+") ? Integer.parseInt(z.getText()) : player.getPosition().getZ();
+
+ BlockPos pos = new BlockPos(xPos, yPos, zPos);
+ CrystalHollowWaypoints.waypoints.add(new CrystalHollowWaypoints.Waypoint(loc, pos));
+
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ name.mouseClicked(mouseX, mouseY, mouseButton);
+ x.mouseClicked(mouseX, mouseY, mouseButton);
+ y.mouseClicked(mouseX, mouseY, mouseButton);
+ z.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ name.textboxKeyTyped(typedChar, keyCode);
+ x.textboxKeyTyped(typedChar, keyCode);
+ y.textboxKeyTyped(typedChar, keyCode);
+ z.textboxKeyTyped(typedChar, keyCode);
+ }
+
+}
diff --git a/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointActionGui.java b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointActionGui.java
new file mode 100644
index 0000000..8d6fa85
--- /dev/null
+++ b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointActionGui.java
@@ -0,0 +1,93 @@
+package me.Danker.gui.crystalhollowwaypoints;
+
+import me.Danker.DankersSkyblockMod;
+import me.Danker.features.CrystalHollowWaypoints;
+import me.Danker.utils.RenderUtils;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.util.EnumChatFormatting;
+
+public class CrystalHollowWaypointActionGui extends GuiScreen {
+
+ private int id;
+
+ private GuiButton goBack;
+ private GuiButton toggle;
+ private GuiButton sendNormal;
+ private GuiButton sendDSM;
+ private GuiButton sendSBE;
+ private GuiButton delete;
+
+ public CrystalHollowWaypointActionGui(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ int height = sr.getScaledHeight();
+ int width = sr.getScaledWidth();
+
+ CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);
+
+ goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back");
+ toggle = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Set Visibility: " + Utils.getColouredBoolean(waypoint.toggled));
+ sendNormal = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Send Location And Coordinates");
+ sendDSM = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Send DSM Formatted Waypoint");
+ sendSBE = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Send SBE Formatted Waypoint");
+ delete = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), EnumChatFormatting.RED + "Delete Waypoint");
+
+ this.buttonList.add(toggle);
+ this.buttonList.add(sendNormal);
+ this.buttonList.add(sendDSM);
+ this.buttonList.add(sendSBE);
+ this.buttonList.add(delete);
+ this.buttonList.add(goBack);
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ this.drawDefaultBackground();
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);
+
+ RenderUtils.drawCenteredText(waypoint.location + " @ " + waypoint.getPos(), width, 10, 1D);
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (button == goBack) {
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ DankersSkyblockMod.guiToOpen = "crystalwaypoints";
+ } else if (button == toggle) {
+ waypoint.toggle();
+ toggle.displayString = "Set Visibility: " + Utils.getColouredBoolean(waypoint.toggled);
+ } else if (button == sendNormal) {
+ player.sendChatMessage(waypoint.location + " @ " + waypoint.getPos());
+ } else if (button == sendDSM) {
+ player.sendChatMessage("$DSMCHWP:" + waypoint.getFormattedWaypoint());
+ } else if (button == sendSBE) {
+ player.sendChatMessage("$SBECHWP:" + waypoint.getFormattedWaypoint());
+ } else if (button == delete) {
+ CrystalHollowWaypoints.waypoints.remove(id);
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ return;
+ }
+ CrystalHollowWaypoints.waypoints.set(id, waypoint);
+ }
+
+}
diff --git a/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointsGui.java b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointsGui.java
new file mode 100644
index 0000000..6780542
--- /dev/null
+++ b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowWaypointsGui.java
@@ -0,0 +1,150 @@
+package me.Danker.gui.crystalhollowwaypoints;
+
+import me.Danker.commands.ToggleCommand;
+import me.Danker.features.CrystalHollowWaypoints;
+import me.Danker.gui.DankerGui;
+import me.Danker.gui.buttons.FeatureButton;
+import me.Danker.handlers.ConfigHandler;
+import me.Danker.utils.RenderUtils;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CrystalHollowWaypointsGui extends GuiScreen {
+
+ private final int page;
+ private final List<GuiButton> allButtons = new ArrayList<>();
+
+ private GuiButton goBack;
+ private GuiButton backPage;
+ private GuiButton nextPage;
+ private GuiButton sendDSM;
+ private GuiButton sendSBE;
+ private GuiButton add;
+ private FeatureButton crystalHollowWaypoints;
+ private FeatureButton crystalAutoWaypoints;
+ private FeatureButton crystalAutoPlayerWaypoints;
+
+ public CrystalHollowWaypointsGui(int page) {
+ this.page = page;
+ }
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ int height = sr.getScaledHeight();
+ int width = sr.getScaledWidth();
+
+ goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back");
+ backPage = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), 80, 20, "< Back");
+ nextPage = new GuiButton(0, width / 2 + 20, (int) (height * 0.8), 80, 20, "Next >");
+ sendDSM = new GuiButton(0, 2, 10, 175, 20, "Send DSM Formatted Waypoints");
+ sendSBE = new GuiButton(0, 2, 40, 175, 20, "Send SBE Formatted Waypoints");
+ add = new GuiButton(0, 0, 0, "Add Waypoint");
+ crystalHollowWaypoints = new FeatureButton("Crystal Hollows Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalHollowWaypoints), "Shows waypoints to various places in the Crystal Hollows.");
+ crystalAutoWaypoints = new FeatureButton("Auto Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalAutoWaypoints), "Automatically creates waypoints when you visit a special place in the Crystal Hollows.");
+ crystalAutoPlayerWaypoints = new FeatureButton("Auto Add Player Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalAutoPlayerWaypoints), "Automatically adds waypoints sent from players.");
+
+ allButtons.clear();
+ allButtons.add(add);
+ allButtons.add(crystalHollowWaypoints);
+ allButtons.add(crystalAutoWaypoints);
+ allButtons.add(crystalAutoPlayerWaypoints);
+ for (int i = 0; i < CrystalHollowWaypoints.waypoints.size(); i++) {
+ CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(i);
+ GuiButton button = new GuiButton(i, 0, 0, waypoint.location + " >");
+ allButtons.add(button);
+ }
+
+ reInit();
+ }
+
+ public void reInit() {
+ this.buttonList.clear();
+
+ for (int i = (page - 1) * 7, iteration = 0; iteration < 7 && i < allButtons.size(); i++, iteration++) {
+ GuiButton button = allButtons.get(i);
+ button.xPosition = width / 2 - 100;
+ button.yPosition = (int) (height * (0.1 * (iteration + 1)));
+ this.buttonList.add(button);
+ }
+
+ if (page > 1) this.buttonList.add(backPage);
+ if (page < Math.ceil(allButtons.size() / 7D)) this.buttonList.add(nextPage);
+
+ this.buttonList.add(goBack);
+ this.buttonList.add(sendDSM);
+ this.buttonList.add(sendSBE);
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ this.drawDefaultBackground();
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ String pageText = "Page: " + page + "/" + (int) Math.ceil(allButtons.size() / 7D);
+ RenderUtils.drawCenteredText(pageText, width, 10, 1D);
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (button == goBack) {
+ mc.displayGuiScreen(new DankerGui(1, ""));
+ } else if (button == nextPage) {
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(page + 1));
+ } else if (button == backPage) {
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(page - 1));
+ } else if (button == sendDSM) {
+ if (CrystalHollowWaypoints.waypoints.size() > 0) {
+ StringBuilder message = new StringBuilder();
+ for (CrystalHollowWaypoints.Waypoint waypoint : CrystalHollowWaypoints.waypoints) {
+ if (message.length() > 0) message.append("\\n");
+ message.append(waypoint.getFormattedWaypoint());
+ }
+ message.insert(0, "$DSMCHWP:");
+ player.sendChatMessage(message.toString());
+ }
+ } else if (button == sendSBE) {
+ if (CrystalHollowWaypoints.waypoints.size() > 0) {
+ StringBuilder message = new StringBuilder();
+ for (CrystalHollowWaypoints.Waypoint waypoint : CrystalHollowWaypoints.waypoints) {
+ if (message.length() > 0) message.append("\\n");
+ message.append(waypoint.getFormattedWaypoint());
+ }
+ message.insert(0, "$SBECHWP:");
+ player.sendChatMessage(message.toString());
+ }
+ } else if (button == add) {
+ mc.displayGuiScreen(new CrystalHollowAddWaypointGui());
+ } else if (button == crystalHollowWaypoints) {
+ ToggleCommand.crystalHollowWaypoints = !ToggleCommand.crystalHollowWaypoints;
+ ConfigHandler.writeBooleanConfig("toggles", "CrystalHollowWaypoints", ToggleCommand.crystalHollowWaypoints);
+ crystalHollowWaypoints.displayString = "Crystal Hollows Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalHollowWaypoints);
+ } else if (button == crystalAutoWaypoints) {
+ ToggleCommand.crystalAutoWaypoints = !ToggleCommand.crystalAutoWaypoints;
+ ConfigHandler.writeBooleanConfig("toggles", "CrystalAutoWaypoints", ToggleCommand.crystalAutoWaypoints);
+ crystalAutoWaypoints.displayString = "Auto Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalAutoWaypoints);
+ } else if (button == crystalAutoPlayerWaypoints) {
+ ToggleCommand.crystalAutoPlayerWaypoints = !ToggleCommand.crystalAutoPlayerWaypoints;
+ ConfigHandler.writeBooleanConfig("toggles", "CrystalAutoPlayerWaypoints", ToggleCommand.crystalAutoPlayerWaypoints);
+ crystalAutoPlayerWaypoints.displayString = "Auto Add Player Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalAutoPlayerWaypoints);
+ } else {
+ mc.displayGuiScreen(new CrystalHollowWaypointActionGui(button.id));
+ }
+ }
+
+}