aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorefefury <69400149+efefury@users.noreply.github.com>2022-11-18 15:13:02 +0000
committerGitHub <noreply@github.com>2022-11-18 16:13:02 +0100
commit5b3f8b0fad77d00f8f6bbd849fecd495421c3d91 (patch)
treeb4bbb7515dd91e309e2bcffe533b5b6612db3eda /src/main/java/io
parent99902b75ca7ced37fdcc2c0424e995355af9a80a (diff)
downloadNotEnoughUpdates-5b3f8b0fad77d00f8f6bbd849fecd495421c3d91.tar.gz
NotEnoughUpdates-5b3f8b0fad77d00f8f6bbd849fecd495421c3d91.tar.bz2
NotEnoughUpdates-5b3f8b0fad77d00f8f6bbd849fecd495421c3d91.zip
Star Cult Timer (#442)
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java91
3 files changed, 151 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
index da84e32e..001f34d8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
@@ -138,11 +138,12 @@ public class Mining {
"\u00a73Mithril Powder: \u00a726,243",
"\u00a73Gemstone Powder: \u00a7d6,243",
"\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
- "\u00a73Pickaxe CD: \u00a7a78s"
+ "\u00a73Pickaxe CD: \u00a7a78s",
+ "\u00a73Star Cult In: \u00a7a78s"
}
)
@ConfigAccordionId(id = 2)
- public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4));
+ public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5));
@Expose
public Position overlayPosition = new Position(10, 100);
@@ -199,6 +200,27 @@ public class Mining {
@ConfigAccordionId(id = 2)
public boolean forgeDisplayOnlyShowTab = false;
+ @Expose
+ @ConfigOption(
+ name = "Star Cult Location",
+ desc = "Change when the Star Cult timer gets shown"
+ )
+ @ConfigEditorDropdown(
+ values = {"Dwarven Mines+Crystal Hollows", "Everywhere except dungeons", "Everywhere"}
+ )
+ @ConfigAccordionId(id = 2)
+ public int starCultDisplayEnabledLocations = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Star Cult Tab",
+ desc = "Only show the star cult timer when tab list is open\n" +
+ "\u00A7cThis only works outside of Dwarven Caves!"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean starCultDisplayOnlyShowTab = false;
+
@ConfigOption(
name = "Metal Detector Solver",
desc = ""
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
index 7d0b9a0a..b63456f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
@@ -27,6 +27,7 @@ import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.StarCultCalculator;
import io.github.moulberry.notenoughupdates.util.TabListUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -422,10 +423,13 @@ public class MiningOverlay extends TextTabOverlay {
}
break;
case 4:
- //overlayStrings.addAll(forgeStringsEmpty); break;
- case 5:
overlayStrings.add(pickaxeCooldown);
break;
+ case 5:
+ overlayStrings.add(
+ DARK_AQUA + "Star Cult In: " + GREEN +
+ Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis()));
+ break;
}
}
} else {
@@ -433,13 +437,36 @@ public class MiningOverlay extends TextTabOverlay {
return;
}
boolean forgeDisplay = false;
+ boolean starCultDisplay = false;
for (int i = 0; i < NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.size(); i++) {
if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.get(i) == 3) {
forgeDisplay = true;
}
+ if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.get(i) == 5) {
+ starCultDisplay = true;
+ }
}
+
+ if (starCultDisplay) {
+ if(overlayStrings == null) overlayStrings = new ArrayList<>();
+
+ if (!NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayOnlyShowTab ||
+ Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayEnabledLocations == 1 &&
+ !SBInfo.getInstance().isInDungeon) {
+ overlayStrings.add(
+ DARK_AQUA + "Star Cult In: " + GREEN +
+ Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis()));
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayEnabledLocations == 2) {
+ overlayStrings.add(
+ DARK_AQUA + "Star Cult In: " + GREEN +
+ Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis()));
+ }
+ }
+ }
+
if (forgeDisplay) {
- overlayStrings = new ArrayList<>();
+ if(overlayStrings == null) overlayStrings = new ArrayList<>();
if (!NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayOnlyShowTab ||
Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) {
@@ -682,6 +709,12 @@ public class MiningOverlay extends TextTabOverlay {
.get("DIAMOND_PICKAXE"))
);
put(
+ "Star Cult In",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("FALLEN_STAR_HAT"))
+ );
+ put(
"Thyst Slayer",
NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
.getItemInformation()
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java
new file mode 100644
index 00000000..61aae416
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.util;
+
+import java.time.Instant;
+
+// cryptic helped me a "little" with the calculation
+public class StarCultCalculator {
+
+ public static final String[] SEASONS = new String[]{
+ "Early Spring",
+ "Spring",
+ "Late Spring",
+ "Early Summer",
+ "Summer",
+ "Late Summer",
+ "Early Autumn",
+ "Autumn",
+ "Late Autumn",
+ "Early Winter",
+ "Winter",
+ "Late Winter",
+ };
+
+ public static final long HOUR_MS = 50000;
+ public static final long DAY_MS = 24 * HOUR_MS;
+ public static final long MONTH_MS = 31 * DAY_MS;
+ public static final long YEAR_MS = SEASONS.length * MONTH_MS;
+ public static final long YEAR_0 = 1560275700000L;
+
+ public static int getSkyblockYear() {
+ long now = Instant.now().toEpochMilli();
+ long currentYear = Math.floorDiv((now - YEAR_0), YEAR_MS);
+ return (int) (currentYear + 1);
+ }
+
+ public static long getNextStarCult() {
+ Instant instantNow = Instant.now();
+ long nowEpoch = instantNow.toEpochMilli();
+ long currentOffset = (nowEpoch - YEAR_0) % YEAR_MS;
+
+ int currentMonth = (int) Math.floorDiv(currentOffset, MONTH_MS);
+ int currentDay = (int) Math.floorDiv((currentOffset - (long) currentMonth * MONTH_MS) % MONTH_MS, DAY_MS) + 1;
+ int out = 7;
+ if (currentDay > 21) {
+ out = 28;
+ } else if (currentDay > 14) {
+ out = 21;
+ } else if (currentDay > 7) {
+ out = 14;
+ }
+ out--;
+ Instant cultStart = Instant.ofEpochMilli(
+ YEAR_0 + (getSkyblockYear() - 1) * YEAR_MS + currentMonth * MONTH_MS + out * DAY_MS);
+ if (cultStart.isBefore(instantNow)) {
+ int curYearCult = getSkyblockYear() - 1;
+ if (out == 28) {
+ out = 7;
+ if (currentMonth == 12) {
+ currentMonth = 1;
+ curYearCult++;
+ } else {
+ currentMonth++;
+ }
+ } else {
+ out += 7;
+ }
+ cultStart = Instant.ofEpochMilli(YEAR_0 + (curYearCult) * YEAR_MS + currentMonth * MONTH_MS + out * DAY_MS);
+ }
+
+ return cultStart.toEpochMilli();
+ }
+}
+