aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-24 00:10:30 +0200
committernea <nea@nea.moe>2023-08-24 00:10:30 +0200
commit32c6eeacb2a13d15fb2f3825b268c9ca32c4bf69 (patch)
tree0af6b36e04a5681a2c185d2fc747091356d0a7fa
parentafd676b9377b336ab3d0eafc6b37190001b69414 (diff)
downloadNotEnoughUpdates-32c6eeacb2a13d15fb2f3825b268c9ca32c4bf69.tar.gz
NotEnoughUpdates-32c6eeacb2a13d15fb2f3825b268c9ca32c4bf69.tar.bz2
NotEnoughUpdates-32c6eeacb2a13d15fb2f3825b268c9ca32c4bf69.zip
Add repo updateable rain timers
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
index 61c5915d..452187f3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
@@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
+import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
import io.github.moulberry.notenoughupdates.util.SkyBlockTime;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -69,7 +70,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -87,6 +87,10 @@ public class CalendarOverlay {
private static boolean enabled = false;
public static boolean ableToClickCalendar = true;
+ long thunderStormEpoch = 1692826500000L;
+ long rainInterval = 3600000L;
+ long thunderFrequency = 3;
+ long rainDuration = 1200 * 1000L;
public static void setEnabled(boolean enabled) {
CalendarOverlay.enabled = enabled;
@@ -256,7 +260,7 @@ public class CalendarOverlay {
}
public void populateDefaultEvents() {
- if (eventMap.isEmpty() || eventMap.size() <= 20) {
+ if (eventMap.size() <= 20) {
fillRepeatingEvents(25 - eventMap.size());
fillSpecialMayors(4);
fillWeather();
@@ -264,22 +268,20 @@ public class CalendarOverlay {
}
private void fillWeather() {
- long rainInterval = 4850 * 1000L;
- long rainingTime = 1000 * 1000L;
- long thunderStormEpoch = 1668551956000L - rainingTime;
+
long currentTime = System.currentTimeMillis();
- long timeSinceLastThunderStart = (currentTime - thunderStormEpoch) % (rainInterval * 4);
+ long timeSinceLastThunderStart = (currentTime - thunderStormEpoch) % (rainInterval * thunderFrequency);
long lastThunderStart = currentTime - timeSinceLastThunderStart;
for (int i = 0; i < 11; i++) {
long eventTimer = lastThunderStart + rainInterval * i;
- if (i % 4 == 0) {
+ if (i % thunderFrequency == 0) {
addEvent(SkyBlockTime.Companion.fromInstant(Instant.ofEpochMilli(eventTimer)), new SBEvent(
"spiders_den_thunder",
"§9Spider's Den Thunder",
true,
new ItemStack(Blocks.slime_block),
Arrays.asList("§aIt will rain in the Spider's Den", "§aand Toxic Rain Slimes will spawn"),
- rainingTime,
+ rainDuration,
true
));
} else {
@@ -291,7 +293,7 @@ public class CalendarOverlay {
false,
new ItemStack(Items.slime_ball),
Arrays.asList("§aIt will rain in the Spider's Den", "§aand Rain Slimes will spawn"),
- rainingTime,
+ rainDuration,
true
)
);
@@ -301,6 +303,27 @@ public class CalendarOverlay {
}
@SubscribeEvent
+ public void tick(RepositoryReloadEvent event) {
+ JsonObject calendarJson = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(
+ event.getRepositoryRoot(),
+ "constants/calendar.json"
+ ));
+ if (calendarJson == null) return;
+ if (calendarJson.has("thunderEpochStart")) {
+ thunderStormEpoch = calendarJson.get("thunderEpochStart").getAsLong();
+ }
+ if (calendarJson.has("rainInterval")) {
+ rainInterval = calendarJson.get("rainInterval").getAsLong();
+ }
+ if (calendarJson.has("thunderFrequency")) {
+ thunderFrequency = calendarJson.get("thunderFrequency").getAsLong();
+ }
+ if (calendarJson.has("rainDuration")) {
+ rainDuration = calendarJson.get("rainDuration").getAsLong();
+ }
+ }
+
+ @SubscribeEvent
public void tick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
handleJinglePlayer();
@@ -338,7 +361,7 @@ public class CalendarOverlay {
}
public void addEvent(SkyBlockTime time, SBEvent event) {
- if (time.toInstant().isBefore(Instant.now())&&
+ if (time.toInstant().isBefore(Instant.now()) &&
time.toInstant().plus(event.lastsFor, ChronoUnit.MILLIS).isBefore(Instant.now())) return;
getEventsAt(time.toMillis()).add(event);
}
@@ -1316,7 +1339,6 @@ public class CalendarOverlay {
}
}
-
if (nextEvent != null) {
GlStateManager.translate(0, 0, 50);
boolean toastRendered = renderToast(nextEvent, timeUntilNext);