aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-07-15 12:07:13 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-07-15 12:07:13 +0300
commiteecce3d586317dea4c1adbdd16b51904c3e3d71d (patch)
tree5104e68838b43d5de94a7e69631d0a4231fef25d /src/main/java
parent0c183f6a183ffaa53eeaf301e7cc9bb34be28adf (diff)
downloadSkyblocker-eecce3d586317dea4c1adbdd16b51904c3e3d71d.tar.gz
Skyblocker-eecce3d586317dea4c1adbdd16b51904c3e3d71d.tar.bz2
Skyblocker-eecce3d586317dea4c1adbdd16b51904c3e3d71d.zip
Don't highlight eggs if the same egg was found on another island
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java45
1 files changed, 23 insertions, 22 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 e2e70653..83d0c3ce 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
@@ -52,11 +52,10 @@ public class EggFinder {
*/
private static boolean isLocationCorrect = false;
- private EggFinder() {
- }
+ private EggFinder() {}
public static void init() {
- ClientPlayConnectionEvents.JOIN.register((ignored, ignored2, ignored3) -> invalidateState());
+ ClientPlayConnectionEvents.JOIN.register((ignored, ignored2, ignored3) -> isLocationCorrect = false);
SkyblockEvents.LOCATION_CHANGE.register(EggFinder::handleLocationChange);
ClientReceiveMessageEvents.GAME.register(EggFinder::onChatMessage);
WorldRenderEvents.AFTER_TRANSLUCENT.register(EggFinder::renderWaypoints);
@@ -69,6 +68,11 @@ public class EggFinder {
}
}
});
+ SkyblockTime.HOUR_CHANGE.register(hour -> {
+ for (EggType type : EggType.entries) {
+ if (hour == type.resetHour) type.collected = false;
+ }
+ });
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE)
.then(literal("eggFinder")
.then(literal("shareLocation")
@@ -116,7 +120,7 @@ public class EggFinder {
ItemUtils.getHeadTextureOptional(itemStack).ifPresent(texture -> {
for (EggType type : EggType.entries) { //Compare blockPos rather than entity to avoid incorrect matches when the entity just moves rather than a new one being spawned elsewhere
if (texture.equals(type.texture) && (type.egg == null || !type.egg.entity.getBlockPos().equals(armorStand.getBlockPos()))) {
- handleFoundEgg(armorStand, type);
+ type.egg = new Egg(armorStand, new Waypoint(armorStand.getBlockPos().up(2), SkyblockerConfigManager.get().helpers.chocolateFactory.waypointType, ColorUtils.getFloatComponents(type.color)), false);
return;
}
}
@@ -124,18 +128,6 @@ public class EggFinder {
}
}
- private static void invalidateState() {
- if (!SkyblockerConfigManager.get().helpers.chocolateFactory.enableEggFinder) return;
- isLocationCorrect = false;
- for (EggType type : EggType.entries) {
- type.egg = null;
- }
- }
-
- 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)), false);
- }
-
private static void renderWaypoints(WorldRenderContext context) {
if (!SkyblockerConfigManager.get().helpers.chocolateFactory.enableEggFinder) return;
for (EggType type : EggType.entries) {
@@ -149,7 +141,9 @@ public class EggFinder {
Matcher matcher = eggFoundPattern.matcher(text.getString());
if (matcher.find()) {
try {
- Egg egg = EggType.valueOf(matcher.group(1).toUpperCase()).egg;
+ EggType eggType = EggType.valueOf(matcher.group(1).toUpperCase());
+ eggType.collected = true;
+ Egg egg = eggType.egg;
if (egg != null) egg.waypoint.setFound();
} catch (IllegalArgumentException e) {
logger.error("[Skyblocker Egg Finder] Failed to find egg type for egg found message. Tried to match against: " + matcher.group(0), e);
@@ -159,7 +153,7 @@ public class EggFinder {
matcher.usePattern(newEggPattern);
if (matcher.find()) {
try {
- EggType.valueOf(matcher.group(1).toUpperCase()).egg = null;
+ EggType.valueOf(matcher.group(1).toUpperCase());
} 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);
}
@@ -180,13 +174,15 @@ public class EggFinder {
@SuppressWarnings("DataFlowIssue") //Removes that pesky "unboxing of Integer might cause NPE" warning when we already know it's not null
public enum EggType {
- LUNCH(Formatting.BLUE.getColorValue(), "ewogICJ0aW1lc3RhbXAiIDogMTcxMTQ2MjU2ODExMiwKICAicHJvZmlsZUlkIiA6ICI3NzUwYzFhNTM5M2Q0ZWQ0Yjc2NmQ4ZGUwOWY4MjU0NiIsCiAgInByb2ZpbGVOYW1lIiA6ICJSZWVkcmVsIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzdhZTZkMmQzMWQ4MTY3YmNhZjk1MjkzYjY4YTRhY2Q4NzJkNjZlNzUxZGI1YTM0ZjJjYmM2NzY2YTAzNTZkMGEiCiAgICB9CiAgfQp9"),
- DINNER(Formatting.GREEN.getColorValue(), "ewogICJ0aW1lc3RhbXAiIDogMTcxMTQ2MjY0OTcwMSwKICAicHJvZmlsZUlkIiA6ICI3NGEwMzQxNWY1OTI0ZTA4YjMyMGM2MmU1NGE3ZjJhYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZXp6aXIiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTVlMzYxNjU4MTlmZDI4NTBmO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ZUlkIiA6ICI3NGEwMzQxNWY1OTI0ZTA4YjMyMGM2MmU1NGE3ZjJhYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZXp6aXIiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTVlMzYxNjU4MTlmZDI4NTBmOTg1NTJlZGNkNzYzZmY5ODYzMTMxMTkyODNjMTI2YWNlMGM0Y2M0OTVlNzZhOCIKICAgIH0KICB9Cn0"),
+ BREAKFAST(Formatting.GOLD.getColorValue(), 7, "ewogICJ0aW1lc3RhbXAiIDogMTcxMTQ2MjY3MzE0OSwKICAicHJvZmlsZUlkIiA6ICJiN2I4ZTlhZjEwZGE0NjFmOTY2YTQxM2RmOWJiM2U4OCIsCiAgInByb2ZpbGVOYW1lIiA6ICJBbmFiYW5hbmFZZzciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTQ5MzMzZDg1YjhhMzE1ZDAzMzZlYjJkZjM3ZDhhNzE0Y2EyNGM1MWI4YzYwNzRmMWI1YjkyN2RlYjUxNmMyNCIKICAgIH0KICB9Cn0");
private Egg egg = null;
public final int color;
public final String texture;
+ public final int resetHour;
+ boolean collected = false;
/*
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
@@ -201,14 +197,19 @@ public class EggFinder {
//This is to not create an array each time we iterate over the values
public static final ObjectImmutableList<EggType> entries = ObjectImmutableList.of(EggType.values());
- EggType(int color, String texture) {
+ EggType(int color, int resetHour, String texture) {
this.color = color;
+ this.resetHour = resetHour;
this.texture = texture;
}
public void setSeen() {
egg.seen = true;
if (!SkyblockerConfigManager.get().helpers.chocolateFactory.sendEggFoundMessages || System.currentTimeMillis() - messageLastSent < 1000) return;
+ if (collected) {
+ egg.waypoint.setFound();
+ return;
+ }
messageLastSent = System.currentTimeMillis();
MinecraftClient.getInstance().player.sendMessage(
Constants.PREFIX.get()