diff options
author | olim <bobq4582@gmail.com> | 2024-04-08 22:07:29 +0100 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-04-08 22:07:29 +0100 |
commit | cec065a79d10319aaf0b6c3e96b4d76001f3e93b (patch) | |
tree | ca9833dd9f44ed715b24b129964c2f72303d8171 /src | |
parent | b3623837bda701610868552005a25a5e5c148b8f (diff) | |
download | Skyblocker-cec065a79d10319aaf0b6c3e96b4d76001f3e93b.tar.gz Skyblocker-cec065a79d10319aaf0b6c3e96b4d76001f3e93b.tar.bz2 Skyblocker-cec065a79d10319aaf0b6c3e96b4d76001f3e93b.zip |
add option for timer above rod when fishing
give option to show how long a rod has been out for
Diffstat (limited to 'src')
4 files changed, 51 insertions, 2 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 06ac748a..3e292ba4 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -349,6 +349,12 @@ public class SkyblockerConfig { public static class Fishing { @SerialEntry public boolean enableFishingHelper = true; + + @SerialEntry + public boolean enableFishingTimer = true; + + @SerialEntry + public float fishingTimerScale = 1f; } public static class FairySouls { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index e310cb85..b1e02ee3 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -226,6 +226,20 @@ public class GeneralCategory { newValue -> config.general.fishing.enableFishingHelper = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.fishing.enableFishingTimer")) + .binding(defaults.general.fishing.enableFishingTimer, + () -> config.general.fishing.enableFishingTimer, + newValue -> config.general.fishing.enableFishingTimer = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Float>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.fishing.fishingTimerScale")) + .binding(defaults.general.fishing.fishingTimerScale, + () -> config.general.fishing.fishingTimerScale, + newValue -> config.general.fishing.fishingTimerScale = newValue) + .controller(FloatFieldControllerBuilder::create) + .build()) .build()) //Fairy Souls Helper diff --git a/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java index 9e7cf541..fb368e30 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/FishingHelper.java @@ -1,9 +1,12 @@ package de.hysky.skyblocker.skyblock; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.dwarven.CrystalsLocationsManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.RenderHelper; import de.hysky.skyblocker.utils.render.title.Title; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -11,6 +14,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.FishingRodItem; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.MathHelper; @@ -19,6 +23,7 @@ import net.minecraft.util.math.Vec3d; public class FishingHelper { private static final Title title = new Title("skyblocker.fishing.reelNow", Formatting.GREEN); private static long startTime; + private static long startTimeFish; private static Vec3d normalYawVector; public static void init() { @@ -36,31 +41,51 @@ public class FishingHelper { } return TypedActionResult.pass(stack); }); + WorldRenderEvents.AFTER_TRANSLUCENT.register(FishingHelper::render); } public static void start(PlayerEntity player) { startTime = System.currentTimeMillis(); + startTimeFish = System.currentTimeMillis(); float yawRad = player.getYaw() * 0.017453292F; normalYawVector = new Vec3d(-MathHelper.sin(yawRad), 0, MathHelper.cos(yawRad)); } public static void reset() { startTime = 0; + startTimeFish = 0; + } + + public static void resetFish() { + startTimeFish = 0; } public static void onSound(PlaySoundS2CPacket packet) { String path = packet.getSound().value().getId().getPath(); - if (SkyblockerConfigManager.get().general.fishing.enableFishingHelper && startTime != 0 && System.currentTimeMillis() >= startTime + 2000 && ("entity.generic.splash".equals(path) || "entity.player.splash".equals(path))) { + if (SkyblockerConfigManager.get().general.fishing.enableFishingHelper && startTimeFish != 0 && System.currentTimeMillis() >= startTimeFish + 2000 && ("entity.generic.splash".equals(path) || "entity.player.splash".equals(path))) { ClientPlayerEntity player = MinecraftClient.getInstance().player; if (player != null && player.fishHook != null) { Vec3d soundToFishHook = player.fishHook.getPos().subtract(packet.getX(), 0, packet.getZ()); if (Math.abs(normalYawVector.x * soundToFishHook.z - normalYawVector.z * soundToFishHook.x) < 0.2D && Math.abs(normalYawVector.dotProduct(soundToFishHook)) < 4D && player.getPos().squaredDistanceTo(packet.getX(), packet.getY(), packet.getZ()) > 1D) { RenderHelper.displayInTitleContainerAndPlaySound(title, 10); - reset(); + resetFish(); } } else { reset(); } } } + + public static void render(WorldRenderContext context) { + if (SkyblockerConfigManager.get().general.fishing.enableFishingTimer && startTime != 0) { + ClientPlayerEntity player = MinecraftClient.getInstance().player; + if (player != null && player.fishHook != null) { + float time = Math.round((System.currentTimeMillis()-startTime) / 100f) / 10f; //leave 1dp in seconds + float scale = SkyblockerConfigManager.get().general.fishing.fishingTimerScale; + Vec3d pos = player.fishHook.getPos().add(0,0.4 + scale / 10,0); + RenderHelper.renderText(context, Text.of(String.valueOf(time)), pos, scale, true); + } + } + + } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 84409b9f..5c590d57 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -35,6 +35,10 @@ "text.autoconfig.skyblocker.option.general.etherwarpOverlay": "Etherwarp Overlay", "text.autoconfig.skyblocker.option.general.fishing": "Fishing Helper", "text.autoconfig.skyblocker.option.general.fishing.enableFishingHelper": "Enable Fishing Helper", + "text.autoconfig.skyblocker.option.general.fishing.enableFishingTimer": "Enable Timer", + "text.autoconfig.skyblocker.option.general.fishing.enableFishingTimer.@Tooltip": "Display fishing time above bobber", + "text.autoconfig.skyblocker.option.general.fishing.fishingTimerScale": "Fishing Timer Scale", + "text.autoconfig.skyblocker.option.general.fishing.fishingTimerScale.@Tooltip": "How big to display the fishing timer", "text.autoconfig.skyblocker.option.general.fairySouls": "Fairy Souls Helper", "text.autoconfig.skyblocker.option.general.fairySouls.enableFairySoulsHelper": "Enable Fairy Souls Helper", "text.autoconfig.skyblocker.option.general.fairySouls.highlightFoundSouls": "Highlight found fairy souls", |