aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-06-30 09:42:26 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-06-30 09:42:26 +0300
commitdaf17d0f9df2fe43624748b4e9672dc2ca16f60b (patch)
tree41d1564e2a0fc1c2ccf0e707027baaf47f362e4a /src/main/java/de/hysky/skyblocker/skyblock
parent0d12a0c928e8d5f36a02a343fbe01ea9f732d4fd (diff)
downloadSkyblocker-daf17d0f9df2fe43624748b4e9672dc2ca16f60b.tar.gz
Skyblocker-daf17d0f9df2fe43624748b4e9672dc2ca16f60b.tar.bz2
Skyblocker-daf17d0f9df2fe43624748b4e9672dc2ca16f60b.zip
Actually fix it this time
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java b/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
index f419eb89..620da37c 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
@@ -116,7 +116,8 @@ public class EggFinder {
private static void handleFoundEgg(ArmorStandEntity entity, EggType eggType) {
eggType.egg = new Egg(entity, new Waypoint(entity.getBlockPos().up(2), SkyblockerConfigManager.get().helpers.chocolateFactory.waypointType, ColorUtils.getFloatComponents(eggType.color)));
- if (!SkyblockerConfigManager.get().helpers.chocolateFactory.sendEggFoundMessages) return;
+ if (!SkyblockerConfigManager.get().helpers.chocolateFactory.sendEggFoundMessages || System.currentTimeMillis() - eggType.messageLastSent < 1000) return;
+ eggType.messageLastSent = System.currentTimeMillis();
MinecraftClient.getInstance().player.sendMessage(
Constants.PREFIX.get()
.append("Found a ")
@@ -150,8 +151,7 @@ public class EggFinder {
matcher.usePattern(newEggPattern);
if (matcher.find()) {
try {
- Egg egg = EggType.valueOf(matcher.group(1).toUpperCase()).egg;
- if (egg != null) egg.waypoint.setFound();
+ EggType.valueOf(matcher.group(1).toUpperCase()).egg = null;
} catch (IllegalArgumentException e) {
logger.error("[Skyblocker Egg Finder] Failed to find egg type for egg spawn message. Tried to match against: " + matcher.group(0), e);
}
@@ -169,6 +169,14 @@ public class EggFinder {
private Egg egg = null;
public final int color;
public final String texture;
+ /*
+ When a new egg spawns in the player's range, the order of packets/messages goes like this:
+ set_equipment -> new egg message -> set_entity_data
+ We have to set the egg to null to prevent the highlight from staying where it was before the new egg spawned,
+ and doing so causes the found message to get sent twice. This is the reason for the existence of this field, so that we can not send the 2nd message.
+ This doesn't fix the field being set twice, but that's not an issue anyway. It'd be much harder to fix the highlight issue mentioned above if it wasn't being set twice.
+ */
+ private long messageLastSent = 0;
//This is to not create an array each time we iterate over the values
public static final ObjectImmutableList<EggType> entries = ObjectImmutableList.of(BREAKFAST, LUNCH, DINNER);