From ee710e220764a69327329579ef199e4f1fbde16e Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Fri, 12 Jul 2024 02:12:05 -0400 Subject: [PATCH] Improve Fishing Helper Accuracy --- .../mixins/ClientPlayNetworkHandlerMixin.java | 1 + .../skyblocker/skyblock/FishingHelper.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 7bbbac818e..cec8af3a72 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -118,6 +118,7 @@ public abstract class ClientPlayNetworkHandlerMixin { EggFinder.checkIfEgg(armorStandEntity); try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers CompactDamage.compactDamage(armorStandEntity); + FishingHelper.checkIfFishWasCaught(armorStandEntity); } catch (Exception e) { LOGGER.error("[Skyblocker Compact Damage] Failed to compact damage number", e); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java index 79239825c7..0de2b15b3a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java @@ -9,6 +9,7 @@ import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.FishingRodItem; import net.minecraft.item.ItemStack; @@ -75,6 +76,23 @@ public static void onSound(PlaySoundS2CPacket packet) { } } + // Sends a title notification if a fish is caught, the sound method is kept still in case the player doesn't have this skyblock option on + public static void checkIfFishWasCaught(ArmorStandEntity armorStand) { + if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().helpers.fishing.enableFishingHelper) { + if (!armorStand.isInvisible() || !armorStand.hasCustomName() || !armorStand.isCustomNameVisible()) return; + + ClientPlayerEntity player = MinecraftClient.getInstance().player; + if (player != null && player.fishHook != null) { + String name = armorStand.getCustomName().getString(); + + if (name.equals("!!!") && player.fishHook.getBoundingBox().expand(4D).contains(armorStand.getPos())) { + RenderHelper.displayInTitleContainerAndPlaySound(title, 10); + resetFish(); + } + } + } + } + public static void render(WorldRenderContext context) { if (SkyblockerConfigManager.get().helpers.fishing.enableFishingTimer && startTime != 0) { ClientPlayerEntity player = MinecraftClient.getInstance().player;