aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java58
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java2
4 files changed, 26 insertions, 84 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
index 22448cbc..82e06d73 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
@@ -193,7 +193,6 @@ public class ChatListener {
public void onGuiChat(ClientChatReceivedEvent e) {
if (e.type == 2) {
CrystalMetalDetectorSolver.process(e.message);
- TimersOverlay.processActionBar(e.message.getUnformattedText());
e.message = processChatComponent(e.message);
return;
} else if (e.type == 0) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java
deleted file mode 100644
index 3727a441..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.listener;
-
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.overlays.TimersOverlay;
-
-public class ScoreboardLocationChangeListener {
-
- public ScoreboardLocationChangeListener(String oldLocation, String newLocation) {
- if (oldLocation.equals("Belly of the Beast") && newLocation.equals("Matriarchs Lair")) {
- //Check inventory pearl count for AFTER they complete to see if it is the same as before + (amount available on actionbar)
- Thread thread = new Thread(() -> {
- try {
- Thread.sleep(3000);
- TimersOverlay.afterPearls = TimersOverlay.heavyPearlCount();
- //Utils.sendMessageToPlayer(EnumChatFormatting.YELLOW+"You exited the beast with ["+EnumChatFormatting.AQUA+(TimersOverlay.afterPearls-TimersOverlay.beforePearls)+EnumChatFormatting.YELLOW+"/"+EnumChatFormatting.AQUA+TimersOverlay.availablePearls+EnumChatFormatting.YELLOW+"] Heavy Pearls!");
- if (TimersOverlay.afterPearls - TimersOverlay.beforePearls == TimersOverlay.availablePearls) {
- NotEnoughUpdates.INSTANCE.config.getProfileSpecific().dailyHeavyPearlCompleted = System.currentTimeMillis();
- //Utils.sendMessageToPlayer(EnumChatFormatting.GREEN+"Daily "+EnumChatFormatting.DARK_AQUA+"Heavy Pearls"+EnumChatFormatting.GREEN+" Complete!");
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- });
- thread.start();
- } else if (oldLocation.equals("Matriarchs Lair") && newLocation.equals("Belly of the Beast")) {
- //Check inventory pearl count BEFORE they complete so we can later check if it is complete.
- TimersOverlay.beforePearls = TimersOverlay.heavyPearlCount();
- }
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
index 44149582..e4a411b0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -30,17 +30,19 @@ import lombok.var;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.util.vector.Vector2f;
import java.time.ZoneId;
@@ -1060,40 +1062,32 @@ public class TimersOverlay extends TextTabOverlay {
return false;
}
- public static int beforePearls = -1;
- public static int afterPearls = -1;
- public static int availablePearls = -1;
+ AxisAlignedBB matriarchArea = new AxisAlignedBB(-555, 36, -904, -532, 52, -870);
- public static int heavyPearlCount() {
- int heavyPearls = 0;
-
- List<ItemStack> inventory = Minecraft.getMinecraft().thePlayer.inventoryContainer.getInventory();
- for (ItemStack item : inventory) {
- if (item == null) {
- continue;
- } else if (!item.hasTagCompound()) {
- continue;
- }
- NBTTagCompound itemData = item.getSubCompound("ExtraAttributes", false);
- if (itemData == null) {
- continue;
- }
- if (itemData.getString("id").equals("HEAVY_PEARL")) {
- heavyPearls += item.stackSize;
+ @SubscribeEvent
+ public void onMatriarchTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.END) return;
+ if (!"crimson_isle".equals(SBInfo.getInstance().getLocation())) return;
+ var player = Minecraft.getMinecraft().thePlayer;
+ if (player == null) return;
+ if (!matriarchArea.isVecInside(player.getPositionVector())) return;
+ var matriarchRelevantArmorStands = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABB(
+ EntityArmorStand.class,
+ matriarchArea
+ );
+ boolean noMorePearlsAvailable = false;
+ for (var entityArmorStand : matriarchRelevantArmorStands) {
+ if (entityArmorStand.hasCustomName() &&
+ entityArmorStand.getCustomNameTag().contains("Heavy Pearls Available: 0")) {
+ noMorePearlsAvailable = true;
+ break;
}
}
- return heavyPearls;
- }
-
- public static void processActionBar(String msg) {
- if (SBInfo.getInstance().location.equals("Belly of the Beast") && msg.contains("Pearls Collected")) {
- try {
- msg = Utils.cleanColour(msg);
- msg = msg.substring(msg.indexOf("Pearls Collected: ") + 18);
- availablePearls = Integer.parseInt(msg.substring(msg.indexOf("/") + 1));
- } catch (Exception e) {
- e.printStackTrace();
- }
+ if (noMorePearlsAvailable) {
+ var profileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (profileSpecific != null)
+ profileSpecific.dailyHeavyPearlCompleted
+ = System.currentTimeMillis();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index e5a0e1b8..82708669 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -23,7 +23,6 @@ import com.google.common.reflect.TypeToken;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
-import io.github.moulberry.notenoughupdates.listener.ScoreboardLocationChangeListener;
import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
@@ -434,7 +433,6 @@ public class SBInfo {
if (line.contains("⏣")) {
String l = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
if (!l.equals(location)) {
- new ScoreboardLocationChangeListener(location, l);
lastLocation = location;
location = l;
}