aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/gamemodes
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
commitb09f774d422263ce15b97d6d0804beddf856176d (patch)
treee542258481d7496b15679f3c329ef9e087c7d8fc /src/main/java/io/github/moulberry/notenoughupdates/gamemodes
parent22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 (diff)
downloadnotenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.gz
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.bz2
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.zip
feat: improve formating :)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/gamemodes')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java589
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java637
2 files changed, 636 insertions, 590 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
index b02ef127..77305904 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
@@ -18,291 +18,306 @@ import java.util.List;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class GuiGamemodes extends GuiScreen {
- private final String currentProfile;
- private SBGamemodes.Gamemode currentGamemode = null;
- private final boolean upgradeOverride;
-
- private int guiLeft = 100;
- private int guiTop = 100;
- private final int xSize = 200;
- private final int ySize = 232;
-
- public GuiGamemodes(boolean upgradeOverride) {
- this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
- this.upgradeOverride = upgradeOverride;
- }
-
- private boolean canChange(int from, int to) {
- if (from >= to) {
- return true;
- } else {
- return !currentGamemode.locked || upgradeOverride;
- }
- }
-
- @Override
- public void updateScreen() {
- if (this.currentProfile == null) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED + "Couldn't detect current profile. Maybe try later?"));
- }
-
- if (currentGamemode == null) {
- currentGamemode = SBGamemodes.getGamemode();
- if (currentGamemode == null) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED + "Couldn't automatically detect current profile." +
- "If you have only 1 profile, try using /api new so that NEU can detect your profile."));
- }
- }
-
- String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
- if (!this.currentProfile.equals(currentProfile)) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED + "Profile change detected. Closing gamemodes menu."));
- }
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- SBGamemodes.saveToFile();
- }
-
- super.handleKeyboardInput();
- }
-
- public void drawStringShadow(String str, float x, float y, int len) {
- for (int xOff = -2; xOff <= 2; xOff++) {
- for (int yOff = -2; yOff <= 2; yOff++) {
- if (Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringScaledMaxWidth(Utils.cleanColourNotModifiers(str),
- Minecraft.getMinecraft().fontRendererObj,
- x + xOff / 2f, y + yOff / 2f, false, len,
- new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- Utils.drawStringScaledMaxWidth(str,
- Minecraft.getMinecraft().fontRendererObj,
- x, y, false, len,
- new Color(64, 64, 64, 255).getRGB());
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if (mouseButton == 0) {
- SBGamemodes.HardcoreMode setHC = SBGamemodes.HardcoreMode.NORMAL;
- SBGamemodes.IronmanMode setIM = SBGamemodes.IronmanMode.NORMAL;
- int setMod = 0;
-
- if (mouseX > guiLeft + xSize - 27 && mouseX < guiLeft + xSize - 9) {
- if (mouseY > guiTop + 30 && mouseY < guiTop + 30 + 16) {
- setHC = SBGamemodes.HardcoreMode.SOFTCORE;
- } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
- setHC = SBGamemodes.HardcoreMode.HARDCORE;
- } else if (mouseY > guiTop + 80 && mouseY < guiTop + 80 + 16) {
- setIM = SBGamemodes.IronmanMode.IRONMAN;
- } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
- setIM = SBGamemodes.IronmanMode.IRONMANPLUS;
- } else if (mouseY > guiTop + 120 && mouseY < guiTop + 120 + 16) {
- setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN;
- } else if (mouseY > guiTop + 140 && mouseY < guiTop + 140 + 16) {
- setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS;
- } else if (mouseY > guiTop + 170 && mouseY < guiTop + 170 + 16) {
- setMod = SBGamemodes.MODIFIER_DEVILISH;
- } else if (mouseY > guiTop + 190 && mouseY < guiTop + 190 + 16) {
- setMod = SBGamemodes.MODIFIER_NOBANK;
- } else if (mouseY > guiTop + 210 && mouseY < guiTop + 210 + 16) {
- setMod = SBGamemodes.MODIFIER_SMALLISLAND;
- }
- }
-
- if (setHC != SBGamemodes.HardcoreMode.NORMAL) {
- if (currentGamemode.hardcoreMode == setHC) {
- currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL;
- } else {
- if (canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
- currentGamemode.hardcoreMode = setHC;
- }
- }
- } else if (setIM != SBGamemodes.IronmanMode.NORMAL) {
- if (currentGamemode.ironmanMode == setIM) {
- currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL;
- } else {
- if (canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
- currentGamemode.ironmanMode = setIM;
- }
- }
- } else if (setMod != 0) {
- if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ setMod)) {
- currentGamemode.gamemodeModifiers ^= setMod;
- }
- }
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawDefaultBackground();
-
- guiLeft = (width - xSize) / 2;
- guiTop = (height - ySize) / 2;
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodes);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
-
- if (currentGamemode == null) return;
-
- Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj,
- guiLeft + xSize / 2f, guiTop + 14, false, new Color(64, 64, 64).getRGB());
-
- drawStringShadow(SBGamemodes.HardcoreMode.SOFTCORE.display, guiLeft + 10, guiTop + 30, xSize - 47);
- drawStringShadow(SBGamemodes.HardcoreMode.HARDCORE.display, guiLeft + 10, guiTop + 50, xSize - 47);
-
- drawStringShadow(SBGamemodes.IronmanMode.IRONMAN.display, guiLeft + 10, guiTop + 80, xSize - 47);
- drawStringShadow(SBGamemodes.IronmanMode.IRONMANPLUS.display, guiLeft + 10, guiTop + 100, xSize - 47);
- drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.display, guiLeft + 10, guiTop + 120, xSize - 47);
- drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.display, guiLeft + 10, guiTop + 140, xSize - 47);
-
- drawStringShadow(SBGamemodes.MODIFIER_DEVILISH_DISPLAY, guiLeft + 10, guiTop + 170, xSize - 47);
- drawStringShadow(SBGamemodes.MODIFIER_NOBANK_DISPLAY, guiLeft + 10, guiTop + 190, xSize - 47);
- drawStringShadow(SBGamemodes.MODIFIER_SMALLISLAND_DISPLAY, guiLeft + 10, guiTop + 210, xSize - 47);
-
- String tooltipToDisplay = null;
-
- GlStateManager.color(1, 1, 1, 1);
- if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.SOFTCORE.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.SOFTCORE ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 30 - 4 && mouseY < guiTop + 30 + 12) {
- tooltipToDisplay = SBGamemodes.HardcoreMode.SOFTCORE.desc;
- }
- }
- }
- if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.HARDCORE.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.HARDCORE ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 50 - 4 && mouseY < guiTop + 50 + 12) {
- tooltipToDisplay = SBGamemodes.HardcoreMode.HARDCORE.desc;
- }
- }
- }
-
- if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMAN.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMAN ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 80 - 4 && mouseY < guiTop + 80 + 12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.IRONMAN.desc;
- }
- }
- }
- if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMANPLUS.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMANPLUS ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 100 - 4 && mouseY < guiTop + 100 + 12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.IRONMANPLUS.desc;
- }
- }
- }
- if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMAN ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 120 - 4 && mouseY < guiTop + 120 + 12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.desc;
- }
- }
- }
- if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 140 - 4 && mouseY < guiTop + 140 + 12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.desc;
- }
- }
- }
-
- if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_DEVILISH)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_DEVILISH) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 170 - 4 && mouseY < guiTop + 170 + 12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_DEVILISH_DESC;
- }
- }
- }
- if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_NOBANK)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_NOBANK) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 190 - 4 && mouseY < guiTop + 190 + 12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_NOBANK_DESC;
- }
- }
- }
- if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_SMALLISLAND)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_SMALLISLAND) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
- if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
- if (mouseY > guiTop + 210 - 4 && mouseY < guiTop + 210 + 12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_SMALLISLAND_DESC;
- }
- }
- }
-
- if (tooltipToDisplay != null) {
- List<String> lines = new ArrayList<>();
- for (String line : tooltipToDisplay.split("\n")) {
- lines.add(EnumChatFormatting.GRAY + line);
- }
- Utils.drawHoveringText(lines, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
+ private final String currentProfile;
+ private SBGamemodes.Gamemode currentGamemode = null;
+ private final boolean upgradeOverride;
+
+ private int guiLeft = 100;
+ private int guiTop = 100;
+ private final int xSize = 200;
+ private final int ySize = 232;
+
+ public GuiGamemodes(boolean upgradeOverride) {
+ this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
+ this.upgradeOverride = upgradeOverride;
+ }
+
+ private boolean canChange(int from, int to) {
+ if (from >= to) {
+ return true;
+ } else {
+ return !currentGamemode.locked || upgradeOverride;
+ }
+ }
+
+ @Override
+ public void updateScreen() {
+ if (this.currentProfile == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Couldn't detect current profile. Maybe try later?"));
+ }
+
+ if (currentGamemode == null) {
+ currentGamemode = SBGamemodes.getGamemode();
+ if (currentGamemode == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Couldn't automatically detect current profile." +
+ "If you have only 1 profile, try using /api new so that NEU can detect your profile."));
+ }
+ }
+
+ String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
+ if (!this.currentProfile.equals(currentProfile)) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Profile change detected. Closing gamemodes menu."));
+ }
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ SBGamemodes.saveToFile();
+ }
+
+ super.handleKeyboardInput();
+ }
+
+ public void drawStringShadow(String str, float x, float y, int len) {
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringScaledMaxWidth(Utils.cleanColourNotModifiers(str),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()
+ );
+ }
+ }
+ }
+
+ Utils.drawStringScaledMaxWidth(str,
+ Minecraft.getMinecraft().fontRendererObj,
+ x, y, false, len,
+ new Color(64, 64, 64, 255).getRGB()
+ );
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ if (mouseButton == 0) {
+ SBGamemodes.HardcoreMode setHC = SBGamemodes.HardcoreMode.NORMAL;
+ SBGamemodes.IronmanMode setIM = SBGamemodes.IronmanMode.NORMAL;
+ int setMod = 0;
+
+ if (mouseX > guiLeft + xSize - 27 && mouseX < guiLeft + xSize - 9) {
+ if (mouseY > guiTop + 30 && mouseY < guiTop + 30 + 16) {
+ setHC = SBGamemodes.HardcoreMode.SOFTCORE;
+ } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
+ setHC = SBGamemodes.HardcoreMode.HARDCORE;
+ } else if (mouseY > guiTop + 80 && mouseY < guiTop + 80 + 16) {
+ setIM = SBGamemodes.IronmanMode.IRONMAN;
+ } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
+ setIM = SBGamemodes.IronmanMode.IRONMANPLUS;
+ } else if (mouseY > guiTop + 120 && mouseY < guiTop + 120 + 16) {
+ setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN;
+ } else if (mouseY > guiTop + 140 && mouseY < guiTop + 140 + 16) {
+ setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS;
+ } else if (mouseY > guiTop + 170 && mouseY < guiTop + 170 + 16) {
+ setMod = SBGamemodes.MODIFIER_DEVILISH;
+ } else if (mouseY > guiTop + 190 && mouseY < guiTop + 190 + 16) {
+ setMod = SBGamemodes.MODIFIER_NOBANK;
+ } else if (mouseY > guiTop + 210 && mouseY < guiTop + 210 + 16) {
+ setMod = SBGamemodes.MODIFIER_SMALLISLAND;
+ }
+ }
+
+ if (setHC != SBGamemodes.HardcoreMode.NORMAL) {
+ if (currentGamemode.hardcoreMode == setHC) {
+ currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL;
+ } else {
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
+ currentGamemode.hardcoreMode = setHC;
+ }
+ }
+ } else if (setIM != SBGamemodes.IronmanMode.NORMAL) {
+ if (currentGamemode.ironmanMode == setIM) {
+ currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL;
+ } else {
+ if (canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
+ currentGamemode.ironmanMode = setIM;
+ }
+ }
+ } else if (setMod != 0) {
+ if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ setMod)) {
+ currentGamemode.gamemodeModifiers ^= setMod;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawDefaultBackground();
+
+ guiLeft = (width - xSize) / 2;
+ guiTop = (height - ySize) / 2;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodes);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
+
+ if (currentGamemode == null) return;
+
+ Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + xSize / 2f, guiTop + 14, false, new Color(64, 64, 64).getRGB()
+ );
+
+ drawStringShadow(SBGamemodes.HardcoreMode.SOFTCORE.display, guiLeft + 10, guiTop + 30, xSize - 47);
+ drawStringShadow(SBGamemodes.HardcoreMode.HARDCORE.display, guiLeft + 10, guiTop + 50, xSize - 47);
+
+ drawStringShadow(SBGamemodes.IronmanMode.IRONMAN.display, guiLeft + 10, guiTop + 80, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.IRONMANPLUS.display, guiLeft + 10, guiTop + 100, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.display, guiLeft + 10, guiTop + 120, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.display, guiLeft + 10, guiTop + 140, xSize - 47);
+
+ drawStringShadow(SBGamemodes.MODIFIER_DEVILISH_DISPLAY, guiLeft + 10, guiTop + 170, xSize - 47);
+ drawStringShadow(SBGamemodes.MODIFIER_NOBANK_DISPLAY, guiLeft + 10, guiTop + 190, xSize - 47);
+ drawStringShadow(SBGamemodes.MODIFIER_SMALLISLAND_DISPLAY, guiLeft + 10, guiTop + 210, xSize - 47);
+
+ String tooltipToDisplay = null;
+
+ GlStateManager.color(1, 1, 1, 1);
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.SOFTCORE.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.SOFTCORE ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 30 - 4 && mouseY < guiTop + 30 + 12) {
+ tooltipToDisplay = SBGamemodes.HardcoreMode.SOFTCORE.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.HARDCORE.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.HARDCORE ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 50 - 4 && mouseY < guiTop + 50 + 12) {
+ tooltipToDisplay = SBGamemodes.HardcoreMode.HARDCORE.desc;
+ }
+ }
+ }
+
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMAN.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMAN ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 80 - 4 && mouseY < guiTop + 80 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.IRONMAN.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMANPLUS.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMANPLUS ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 100 - 4 && mouseY < guiTop + 100 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.IRONMANPLUS.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMAN ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 120 - 4 && mouseY < guiTop + 120 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS
+ ? radial_circle_on
+ : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 140 - 4 && mouseY < guiTop + 140 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.desc;
+ }
+ }
+ }
+
+ if (canChange(
+ currentGamemode.gamemodeModifiers,
+ currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_DEVILISH
+ )) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_DEVILISH) != 0
+ ? radial_square_on
+ : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 170 - 4 && mouseY < guiTop + 170 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_DEVILISH_DESC;
+ }
+ }
+ }
+ if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_NOBANK)) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_NOBANK) != 0 ? radial_square_on : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 190 - 4 && mouseY < guiTop + 190 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_NOBANK_DESC;
+ }
+ }
+ }
+ if (canChange(
+ currentGamemode.gamemodeModifiers,
+ currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_SMALLISLAND
+ )) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_SMALLISLAND) != 0
+ ? radial_square_on
+ : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 210 - 4 && mouseY < guiTop + 210 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_SMALLISLAND_DESC;
+ }
+ }
+ }
+
+ if (tooltipToDisplay != null) {
+ List<String> lines = new ArrayList<>();
+ for (String line : tooltipToDisplay.split("\n")) {
+ lines.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(lines, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
index 1726a4de..ddd4a4ba 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
@@ -25,285 +25,315 @@ import java.util.Base64;
import java.util.HashMap;
public class SBGamemodes {
- private static final Gson gson = new Gson();
-
- public static final int MODIFIER_DEVILISH = 0b1;
- public static final int MODIFIER_NOBANK = 0b10;
- public static final int MODIFIER_SMALLISLAND = 0b100;
-
- public static final String MODIFIER_DEVILISH_DISPLAY = EnumChatFormatting.DARK_PURPLE + "Devilish";
- public static final String MODIFIER_NOBANK_DISPLAY = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank";
- public static final String MODIFIER_SMALLISLAND_DISPLAY = EnumChatFormatting.GREEN + "SmallIsland";
-
- public static final String MODIFIER_DEVILISH_DESC = EnumChatFormatting.DARK_PURPLE + "Devilish\n" +
- "You are NOT allowed to use fairy souls.";
- public static final String MODIFIER_NOBANK_DESC = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank\n" +
- "You are NOT allowed to use the bank.";
- public static final String MODIFIER_SMALLISLAND_DESC = EnumChatFormatting.GREEN + "SmallIsland\n" +
- "Your private island is 1/4 the normal size.";
-
- private static HashMap<String, Gamemode> currentGamemode = new HashMap<>();
- private static long lastDeathExemption = 0;
-
- public static class Gamemode {
- public HardcoreMode hardcoreMode = HardcoreMode.NORMAL;
- public IronmanMode ironmanMode = IronmanMode.NORMAL;
- public int gamemodeModifiers = 0;
-
- public boolean locked = true;
- }
-
- public enum HardcoreMode {
- NORMAL("Normal", "Normal"),
- SOFTCORE(EnumChatFormatting.RED + "Soft" + EnumChatFormatting.DARK_RED + "core\n" +
- "You only have 1 life.\nDying will remove your hardcore status.\nDeaths to the void or 'unknown' are exempted.",
- "You died.", "You fell into the void"),
- HARDCORE(EnumChatFormatting.DARK_RED + "Hardcore\n" +
- "You only have 1 life.\nDying will remove your hardcore status.");
-
- public final String display;
- public final String desc;
- private final String[] exemptions;
-
- HardcoreMode(String display, String... exemptions) {
- this.display = display.split("\n")[0];
- this.desc = display;
- this.exemptions = exemptions;
- }
-
- public boolean isExemption(String line) {
- for (String exemption : exemptions) {
- if (line.contains(exemption)) return true;
- }
- return false;
- }
- }
-
- public enum IronmanMode {
- NORMAL("Normal"),
- IRONMAN(EnumChatFormatting.WHITE + "Ironman\n" +
- "You are NOT allowed to trade or use the auction house.",
- "You ", "Auction House", "Auctions Browser", "Auction View"),
- IRONMANPLUS(EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD + "+\n" +
- "You are NOT allowed to trade, use the auction house or bazaar.",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar"),
- ULTIMATE_IRONMAN(EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman\n" +
- "You are NOT allowed to trade or use the auction house.\n" +
- "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Chest",
- "Wardrobe", "Weapon Rack", "Shelves"),
- ULTIMATE_IRONMANPLUS(EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD + "+\n" +
- "You are NOT allowed to trade, use the auction house or bazaar.\n" +
- "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar",
- "Chest", "Wardrobe", "Weapon Rack", "Shelves");
-
- public final String display;
- public final String desc;
- private final String[] bannedInventories;
-
- IronmanMode(String display, String... bannedInventories) {
- this.display = display.split("\n")[0];
- this.desc = display;
- this.bannedInventories = bannedInventories;
- }
-
- public boolean isBanned(String inventoryName) {
- for (String banned : bannedInventories) {
- if (inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true;
- }
- return false;
- }
- }
-
- public static Gamemode getGamemode() {
- String currentProfile = SBInfo.getInstance().currentProfile;
-
- if (currentProfile == null || currentProfile.isEmpty()) return null;
-
- return currentGamemode.computeIfAbsent(currentProfile, k -> new Gamemode());
- }
-
- public static void loadFromFile() {
- File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
- File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json");
- gamemodeFile.getParentFile().mkdirs();
-
- if (!gamemodeFile.exists()) {
- return;
- }
-
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(gamemodeFile), StandardCharsets.UTF_8))) {
- String line = reader.readLine();
- String decoded = decrypt(line);
- currentGamemode = gson.fromJson(decoded, GamemodeWrapper.class).currentGamemode;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static class GamemodeWrapper {
- private final HashMap<String, Gamemode> currentGamemode;
-
- public GamemodeWrapper(HashMap<String, Gamemode> currentGamemode) {
- this.currentGamemode = currentGamemode;
- }
- }
-
- public static void saveToFile() {
- File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
- File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json");
- gamemodeFile.getParentFile().mkdirs();
-
- try {
- gamemodeFile.createNewFile();
-
- try (BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(gamemodeFile), StandardCharsets.UTF_8))) {
- JsonObject obj = new JsonObject();
- writer.write(encrypt(gson.toJson(new GamemodeWrapper(currentGamemode), GamemodeWrapper.class)));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static Key getKeyFromPlayerUUID() {
- byte[] bytes = ByteBuffer.allocate(2 * Long.SIZE / Byte.SIZE)
- .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getLeastSignificantBits())
- .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getMostSignificantBits())
- .array();
- SecretKeySpec key = new SecretKeySpec(bytes, "AES");
-
- return key;
- }
-
- public static String encrypt(String value) {