aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-09-09 19:33:28 +0200
committernea <nea@nea.moe>2023-09-09 19:33:28 +0200
commit5b8361e41aaa5171f10059e15ffc4326de9780ea (patch)
tree2ded97e3f21133877425517474baafa770a3bcde /src/main/java
parent13a2f67df489e6a77fb3e61d790ef9c9c5e3576e (diff)
parentce52a805da551f4cef1b14beab58821887e349b9 (diff)
downloadNotEnoughUpdates-5b8361e41aaa5171f10059e15ffc4326de9780ea.tar.gz
NotEnoughUpdates-5b8361e41aaa5171f10059e15ffc4326de9780ea.tar.bz2
NotEnoughUpdates-5b8361e41aaa5171f10059e15ffc4326de9780ea.zip
Merge branch 'master' of github.com:NotEnoughUpdates/NotEnoughUpdates into moulconfig
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java127
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java131
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java134
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java87
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.java1094
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt213
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java270
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt302
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java38
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java48
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java47
26 files changed, 968 insertions, 1662 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
index b3a84c52..5f501115 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
@@ -311,27 +311,29 @@ public class RenderUtils {
public static void renderBoundingBox(
BlockPos worldPos,
int rgb,
- float partialTicks
+ float partialTicks,
+ boolean disableDepth
) {
Vector3f interpolatedPlayerPosition = getInterpolatedPlayerPosition(partialTicks);
renderBoundingBoxInViewSpace(
worldPos.getX() - interpolatedPlayerPosition.x,
worldPos.getY() - interpolatedPlayerPosition.y,
worldPos.getZ() - interpolatedPlayerPosition.z,
- rgb
+ rgb,
+ disableDepth
);
}
- private static void renderBoundingBoxInViewSpace(double x, double y, double z, int rgb) {
+ private static void renderBoundingBoxInViewSpace(double x, double y, double z, int rgb, boolean disableDepth) {
AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
- GlStateManager.disableDepth();
+ if (disableDepth) GlStateManager.disableDepth();
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, (rgb >> 24) & 0xFF, rgb));
GlStateManager.enableTexture2D();
GlStateManager.enableCull();
- GlStateManager.enableDepth();
+ if (disableDepth) GlStateManager.enableDepth();
}
public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, float partialTicks) {
@@ -395,7 +397,7 @@ public class RenderUtils {
if (distSq > 10 * 10) {
RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
} else {
- RenderUtils.renderBoundingBoxInViewSpace(x, y, z, rgb);
+ RenderUtils.renderBoundingBoxInViewSpace(x, y, z, rgb, true);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
index 4a5df63f..0b4e3934 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -45,6 +45,7 @@ import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.NotificationHandler;
import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.TabSkillInfoParser;
import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.util.XPInformation;
import net.minecraft.client.Minecraft;
@@ -171,8 +172,7 @@ public class NEUEventListener {
CrystalOverlay.tick();
FairySouls.getInstance().tick();
- XPInformation.getInstance().tick();
- ProfileApiSyncer.getInstance().tick();
+ TabSkillInfoParser.parseSkillInfo();
ItemCustomizeManager.tick();
BackgroundBlur.markDirty();
NPCRetexturing.getInstance().tick();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 016c17f0..726856cb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -22,8 +22,6 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -36,11 +34,8 @@ import io.github.moulberry.notenoughupdates.listener.RenderListener;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
-import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
-import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
-import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.util.XPInformation;
import net.minecraft.client.Minecraft;
@@ -54,7 +49,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
-import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@@ -156,6 +150,10 @@ public class PetInfoOverlay extends TextOverlay {
private static long lastPetSelect = -1;
private static PetConfig config = new PetConfig();
+ public static PetConfig getConfig() {
+ return config;
+ }
+
private static long lastUpdate = 0;
private static float levelXpLast = 0;
@@ -281,110 +279,6 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- private static void getAndSetPet(SkyblockProfiles profile) {
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getLatestProfile().getLevelingInfo();
- Map<String, JsonArray> invInfo = profile.getLatestProfile().getInventoryInfo();
- JsonObject profileInfo = profile.getLatestProfile().getProfileJson();
- if (invInfo != null && profileInfo != null) {
- JsonObject stats = profileInfo.get("stats").getAsJsonObject();
- boolean hasBeastmasterCrest = false;
- Rarity currentBeastRarity = Rarity.COMMON;
- for (JsonElement talisman : invInfo.get("talisman_bag")) {
- if (talisman.isJsonNull()) continue;
- String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
- if (internalName.startsWith("BEASTMASTER_CREST")) {
- hasBeastmasterCrest = true;
- try {
- Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
- if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer)
- currentBeastRarity = talismanRarity;
- } catch (Exception ignored) {
- }
- }
- }
- if (hasBeastmasterCrest) {
- if (stats.has("mythos_kills")) {
- int mk = stats.get("mythos_kills").getAsInt();
- float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f :
- mk > 1000
- ? 0.6f
- : mk > 500
- ? 0.5f
- : mk > 250
- ? 0.4f
- : mk > 100
- ? 0.3f
- : mk > 25 ? 0.2f : 0.1f;
- config.beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer;
- } else {
- config.beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer;
- }
- }
- }
- if (skyblockInfo != null && profile.getLatestProfile().skillsApiEnabled()) {
- config.tamingLevel = (int) skyblockInfo.get("taming").level;
- }
-
- //JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
- /*JsonObject petsJson = Constants.PETS;
- if(petsJson != null) {
- if(petObject != null) {
- boolean forceUpdateLevels = System.currentTimeMillis() - lastXpGain > 30000;
- Set<String> foundPets = new HashSet<>();
- Set<Pet> addedPets = new HashSet<>();
- for(int i = 0; i < petObject.getAsJsonArray("pets").size(); i++) {
- JsonElement petElement = petObject.getAsJsonArray("pets").get(i);
- JsonObject petObj = petElement.getAsJsonObject();
- Pet pet = new Pet();
- pet.petType = petObj.get("type").getAsString();
- Rarity rarity;
- try {
- rarity = Rarity.valueOf(petObj.get("tier").getAsString());
- } catch(Exception ignored) {
- rarity = Rarity.COMMON;
- }
- pet.rarity = rarity;
- pet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), rarity.petOffset, petObj.get("exp").getAsFloat());
- JsonElement heldItem = petObj.get("heldItem");
- pet.petItem = heldItem.isJsonNull() ? null : heldItem.getAsString();
- if(rarity != Rarity.MYTHIC && pet.petItem != null && pet.petItem.equals("PET_ITEM_TIER_BOOST")) {
- rarity = Rarity.values()[rarity.ordinal()+1];
- }
- JsonObject petTypes = petsJson.get("pet_types").getAsJsonObject();
- pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown";
-
- Pet closest = null;
- if(petList.containsKey(pet.petType + ";" + pet.rarity.petId)) {
- closest = getClosestPet(pet);
- if(addedPets.contains(closest)) {
- closest = null;
- }
-
- if(closest != null) {
- if(!forceUpdateLevels || Math.floor(pet.petLevel.level) < Math.floor(closest.petLevel.level)) {
- pet.petLevel = closest.petLevel;
- }
- petList.get(pet.petType + ";" + pet.rarity.petId).remove(closest);
- }
- }
- foundPets.add(pet.petType + ";" + pet.rarity.petId);
- petList.computeIfAbsent(pet.petType + ";" + pet.rarity.petId, k->new HashSet<>()).add(pet);
- addedPets.add(pet);
-
- if(petObj.get("active").getAsBoolean()) {
- if(currentPet == null && !setActivePet) {
- currentPet = pet;
- } else if(closest == currentPet) {
- currentPet = pet;
- }
- }
- }
- petList.keySet().retainAll(foundPets);
- setActivePet = true;
- }
- }*/
- }
-
private float interp(float now, float last) {
float interp = now;
if (last >= 0 && last != now) {
@@ -659,12 +553,6 @@ public class PetInfoOverlay extends TextOverlay {
return;
}
- int updateTime = 60000;
-
- if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet);
- }
-
Pet currentPet = getCurrentPet();
if (currentPet == null) {
overlayStrings = null;
@@ -1097,13 +985,6 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- @SubscribeEvent
- public void switchWorld(WorldEvent.Load event) {
- if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {}, PetInfoOverlay::getAndSetPet);
- }
- }
-
private int lastLevelHovered = 0;
private static final Pattern AUTOPET_EQUIP = Pattern.compile(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java
new file mode 100644
index 00000000..61c96aad
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2023 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.miscfeatures.world;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import net.minecraft.block.Block;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
+import net.minecraft.network.play.server.S22PacketMultiBlockChange;
+import net.minecraft.network.play.server.S23PacketBlockChange;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+@NEUAutoSubscribe
+public class CrystalHollowChestHighlighter extends GenericBlockHighlighter {
+
+ // Because ConcurrentModificationException is the bane of me
+ public static CopyOnWriteArrayList<BlockPos> markedBlocks = new CopyOnWriteArrayList<>();
+
+ public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
+ BlockPos pos = packetIn.getBlockPosition();
+ if (packetIn.blockState == null) return;
+ checkForChest(pos, packetIn.blockState);
+ }
+
+ public static void processMultiBlockChangePacket(S22PacketMultiBlockChange packetIn) {
+ for (S22PacketMultiBlockChange.BlockUpdateData blockChanged : packetIn.getChangedBlocks()) {
+ BlockPos pos = blockChanged.getPos();
+ checkForChest(pos, blockChanged.getBlockState());
+ }
+ }
+
+ public static void checkForChest(BlockPos pos, IBlockState blockState) {
+ IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
+
+ if ((oldState.getBlock() == Blocks.air || oldState.getBlock() == Blocks.stone) &&
+ blockState.getBlock() == Blocks.chest) {
+
+ // Only add if in a 10x10x10 area. Minimises other players' chests being caught
+ if (Minecraft.getMinecraft().thePlayer.getEntityBoundingBox().expand(10, 10, 10).isVecInside(new Vec3(pos))) {
+ markedBlocks.add(pos);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (!isEnabled()) return;
+
+ markedBlocks.forEach(this::tryRegisterInterest);
+
+ // Here to catch chests that get highlighted by other people after they open them, and
+ // any highlighted blocks in which the chest despawned in
+ List<BlockPos> blockToRemove = new ArrayList<>();
+ highlightedBlocks.forEach(it -> {
+ if (Minecraft.getMinecraft().theWorld.getBlockState(it).getBlock() != Blocks.chest) {
+ blockToRemove.add(it);
+ }
+ });
+
+ blockToRemove.forEach(highlightedBlocks::remove);
+ }
+
+ @SubscribeEvent
+ public void onBlockInteraction(PlayerInteractEvent event) {
+ if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ markedBlocks.remove(event.pos);
+ highlightedBlocks.remove(event.pos);
+ }
+ }
+
+ @Override
+ public void onWorldRenderLast(RenderWorldLastEvent event) {
+ if (!isEnabled()) return;
+ World w = Minecraft.getMinecraft().theWorld;
+ if (w == null) return;
+ for (BlockPos blockPos : highlightedBlocks) {
+ RenderUtils.renderBoundingBox(blockPos, getColor(blockPos), event.partialTicks, false);
+ }
+ }
+
+ @Override
+ protected boolean isEnabled() {
+ return "crystal_hollows".equals(SBInfo.getInstance().getLocation()) &&
+ NotEnoughUpdates.INSTANCE.config.world.highlightCrystalHollowChests;
+ }
+
+ @Override
+ protected boolean isValidHighlightSpot(BlockPos key) {
+ World w = Minecraft.getMinecraft().theWorld;
+ if (w == null) return false;
+ Block b = w.getBlockState(key).getBlock();
+ return b == Blocks.chest;
+ }
+
+ @Override
+ protected int getColor(BlockPos blockPos) {
+ return SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.world.crystalHollowChestColor);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
index 67d6f46e..5cacff2b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
@@ -49,7 +49,7 @@ public abstract class GenericBlockHighlighter {
World w = Minecraft.getMinecraft().theWorld;
if (w == null) return;
for (BlockPos blockPos : highlightedBlocks) {
- RenderUtils.renderBoundingBox(blockPos, getColor(blockPos), event.partialTicks);
+ RenderUtils.renderBoundingBox(blockPos, getColor(blockPos), event.partialTicks, true);
}
}
@@ -110,6 +110,10 @@ public abstract class GenericBlockHighlighter {
highlightedBlocks.clear();
}
+ public boolean tryRegisterInterest(BlockPos pos) {
+ return tryRegisterInterest(pos.getX(), pos.getY(), pos.getZ());
+ }
+
public boolean tryRegisterInterest(double x, double y, double z) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean contains = highlightedBlocks.contains(blockPos);
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..c83b310c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
@@ -26,7 +26,9 @@ 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.JsonUtils;
import io.github.moulberry.notenoughupdates.util.SkyBlockTime;
import io.github.moulberry.notenoughupdates.util.Utils;
import kotlin.Pair;
@@ -53,6 +55,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -63,13 +66,12 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
+import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -87,6 +89,11 @@ 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;
+ List<Pair<Long, SBEvent>> externalEvents = new ArrayList<>();
public static void setEnabled(boolean enabled) {
CalendarOverlay.enabled = enabled;
@@ -127,6 +134,11 @@ public class CalendarOverlay {
private static final ItemStack DA_STACK; // Dark Auction
private static final ItemStack JF_STACK; // Jacob's Farming Contest
+ private static final ItemStack STAR_CULT_STACK = Utils.createItemStack(
+ Items.nether_star,
+ "Cult of the Fallen Star",
+ "NEU Calendar Item"
+ ); // Star Cult Stack
static {
NBTTagCompound tag = new NBTTagCompound();
@@ -209,7 +221,7 @@ public class CalendarOverlay {
}
public Set<SBEvent> getEventsAt(long timestamp) {
- return eventMap.computeIfAbsent(timestamp, k -> new HashSet<>());
+ return eventMap.computeIfAbsent(timestamp, k -> new TreeSet<>());
}
JsonObject getFarmingEventTypes() {
@@ -256,30 +268,70 @@ public class CalendarOverlay {
}
public void populateDefaultEvents() {
- if (eventMap.isEmpty() || eventMap.size() <= 20) {
+ if (eventMap.size() <= 20) {
fillRepeatingEvents(25 - eventMap.size());
fillSpecialMayors(4);
fillWeather();
+ fillRepoMandatedEvents();
+ fillStarCult();
+ }
+ }
+
+ public void fillRepoMandatedEvents() {
+ for (Pair<Long, SBEvent> externalEvent : externalEvents) {
+ addEvent(
+ SkyBlockTime.Companion.fromInstant(Instant.ofEpochMilli(externalEvent.component1())),
+ externalEvent.component2()
+ );
+ }
+ }
+
+ public void fillStarCult() {
+ SkyBlockTime now = SkyBlockTime.now();
+
+ long STAR_CULT_DURATION = 60 * 1000L * 6;
+ List<SkyBlockTime> allTimes = new ArrayList<>();
+ allTimes.add(new SkyBlockTime(now.getYear() - 1, 12, 28, 0, 0, 0));
+ for (int i = 1; i <= 12; i++) {
+ for (int d = 7; d < 30; d += 7) {
+ allTimes.add(new SkyBlockTime(now.getYear(), i, d, 0, 0, 0));
+ }
+ }
+ for (SkyBlockTime allTime : allTimes) {
+ addEvent(
+ allTime,
+ new SBEvent(
+ "starcult",
+ "§3Cult of the Fallen Star",
+ false,
+ STAR_CULT_STACK,
+ Arrays.asList(
+ "§3The Cult of the Fallen Star meets then.",
+ "§3Attending may give a reward",
+ "§3You can find them near the Star in the Dwarven Mines"
+ ),
+ STAR_CULT_DURATION,
+ true
+ )
+ );
}
}
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 +343,7 @@ public class CalendarOverlay {
false,