From 5458dd54cbec29ac62ed498c415dc386fc6a54ae Mon Sep 17 00:00:00 2001 From: Dit05 Date: Thu, 25 Dec 2025 23:46:59 +0100 Subject: [PATCH 1/2] Add randomness settings to AutoFish --- .../systems/modules/player/AutoFish.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java index a6685d4853..54f71f7c46 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java @@ -55,6 +55,15 @@ public class AutoFish extends Module { .build() ); + private final Setting castDelayVariance = sgGeneral.add(new IntSetting.Builder() + .name("cast-delay-variance") + .description("Variance of randomness added to cast delay.") + .defaultValue(0) + .min(0) + .sliderMax(20) + .build() + ); + private final Setting catchDelay = sgGeneral.add(new IntSetting.Builder() .name("catch-delay") .description("How long to wait after hooking a fish to reel it in.") @@ -64,6 +73,15 @@ public class AutoFish extends Module { .build() ); + private final Setting catchDelayVariance = sgGeneral.add(new IntSetting.Builder() + .name("catch-delay-variance") + .description("Variance of randomness added to catch delay.") + .defaultValue(0) + .min(0) + .sliderMax(6) // This is the highest possible variance that won't miss fish (assuming the base catch delay is less than 2). Since the randomization is clamped to 3 standard deviations, 6 would produce a maximum delay of 18 ticks, which is just within the shortest Java edition catch window of 1 second. + .build() + ); + public AutoFish() { super(Categories.Player, "auto-fish", "Automatically fishes for you."); } @@ -118,7 +136,7 @@ private void tryCatch() { if (!wasHooked) { if (((FishingBobberEntityAccessor) mc.player.fishHook).meteor$hasCaughtFish()) { - catchDelayLeft = catchDelay.get(); + catchDelayLeft = catchDelay.get() + getRandomExtraDelay(catchDelayVariance.get()); wasHooked = true; } @@ -136,7 +154,7 @@ private void tryCatch() { private void useRod() { Utils.rightClick(); wasHooked = false; - castDelayLeft = castDelay.get(); + castDelayLeft = castDelay.get() + getRandomExtraDelay(castDelayVariance.get()); } private int findBestRod() { @@ -166,4 +184,15 @@ private int findBestRod() { return bestSlot; } + + private double getRandomExtraDelay(int variance) { + if(variance == 0) { + return 0; + } + + // Generate a value with standard normal distribution via Box-Muller transform + double scale = Math.sqrt(-2 * Math.log(Utils.random(0.0001, 1.0))); + double angle = Math.PI * Utils.random(0.0, 1.0); // Multiply by only 1 pi to avoid negative values + return Math.round(Math.min(scale * Math.sin(angle), 3.0) * variance); // Clamp to 3 standard deviations + } } From 12a0894209b921dd9cc13bb70dc632b1386fa13c Mon Sep 17 00:00:00 2001 From: Dit05 Date: Sat, 27 Dec 2025 20:53:24 +0100 Subject: [PATCH 2/2] Better AutoFish randomization --- .../systems/modules/player/AutoFish.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java index 54f71f7c46..ae630c33a1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java @@ -57,10 +57,10 @@ public class AutoFish extends Module { private final Setting castDelayVariance = sgGeneral.add(new IntSetting.Builder() .name("cast-delay-variance") - .description("Variance of randomness added to cast delay.") + .description("Maximum amount of randomness added to cast delay.") .defaultValue(0) .min(0) - .sliderMax(20) + .sliderMax(30) .build() ); @@ -75,10 +75,10 @@ public class AutoFish extends Module { private final Setting catchDelayVariance = sgGeneral.add(new IntSetting.Builder() .name("catch-delay-variance") - .description("Variance of randomness added to catch delay.") + .description("Maximum amount of randomness added to catch delay.") .defaultValue(0) .min(0) - .sliderMax(6) // This is the highest possible variance that won't miss fish (assuming the base catch delay is less than 2). Since the randomization is clamped to 3 standard deviations, 6 would produce a maximum delay of 18 ticks, which is just within the shortest Java edition catch window of 1 second. + .sliderMax(10) // Since the shortest Java edition catch window is 20 ticks, this is the highest possible variance that won't miss fish. .build() ); @@ -136,7 +136,7 @@ private void tryCatch() { if (!wasHooked) { if (((FishingBobberEntityAccessor) mc.player.fishHook).meteor$hasCaughtFish()) { - catchDelayLeft = catchDelay.get() + getRandomExtraDelay(catchDelayVariance.get()); + catchDelayLeft = randomizeDelay(catchDelay.get(), catchDelayVariance.get()); wasHooked = true; } @@ -154,7 +154,7 @@ private void tryCatch() { private void useRod() { Utils.rightClick(); wasHooked = false; - castDelayLeft = castDelay.get() + getRandomExtraDelay(castDelayVariance.get()); + castDelayLeft = randomizeDelay(castDelay.get(), castDelayVariance.get()); } private int findBestRod() { @@ -185,14 +185,19 @@ private int findBestRod() { return bestSlot; } - private double getRandomExtraDelay(int variance) { - if(variance == 0) { - return 0; - } + private double randomizeDelay(int delay, int variance) { + if (variance == 0) return delay; - // Generate a value with standard normal distribution via Box-Muller transform + // Sample the standard normal distribution via Box-Muller transform double scale = Math.sqrt(-2 * Math.log(Utils.random(0.0001, 1.0))); - double angle = Math.PI * Utils.random(0.0, 1.0); // Multiply by only 1 pi to avoid negative values - return Math.round(Math.min(scale * Math.sin(angle), 3.0) * variance); // Clamp to 3 standard deviations + double angle = Math.TAU * Utils.random(0.0, 1.0); + double norm = scale * Math.cos(angle); + + // Clamp to 3 standard deviations and re-scale to [-3.0, +3.0] + final double MAX_SD = 3.0; + norm = Math.clamp(norm, -MAX_SD, MAX_SD) / MAX_SD; + + delay += Math.round((float)(norm * variance)); + return Math.max(1, delay); } }