From 283a9de77765091877b1ca900dc6730f9e74aa86 Mon Sep 17 00:00:00 2001 From: Wudji <1215168278@qq.com> Date: Mon, 16 Sep 2024 21:36:53 +0800 Subject: [PATCH] Fixed several bugs related to Persistent mode - fix #24: Sometimes persistent mode will wrongly reel in the fishing rod when it's in water, close #27 - fix #21: Useless 10-second delay when using persistent mode --- src/main/java/troy/autofish/Autofish.java | 8 +++++--- src/main/java/troy/autofish/FabricModAutofish.java | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/troy/autofish/Autofish.java b/src/main/java/troy/autofish/Autofish.java index 3787428..a8ca43e 100644 --- a/src/main/java/troy/autofish/Autofish.java +++ b/src/main/java/troy/autofish/Autofish.java @@ -49,9 +49,11 @@ public Autofish(FabricModAutofish modAutofish) { modAutofish.getScheduler().scheduleRepeatingAction(10000, () -> { if(!modAutofish.getConfig().isPersistentMode()) return; if(!isHoldingFishingRod()) return; - if(hookExists && isBobberInWater()) return; + if(hookExists){ + if(isBobberInWater()) return; + else useRod(); + } if(modAutofish.getScheduler().isRecastQueued()) return; - useRod(); }); } @@ -244,7 +246,7 @@ public void switchToFirstRod(ClientPlayerEntity player) { public boolean isBobberInWater(){ if(client.player != null && client.world != null && client.player.fishHook != null) { - return client.player.fishHook.isTouchingWater(); + return client.world.getBlockState(client.player.fishHook.getBlockPos()).getBlock() == Blocks.WATER; } else{ return false; } diff --git a/src/main/java/troy/autofish/FabricModAutofish.java b/src/main/java/troy/autofish/FabricModAutofish.java index b1c8730..9fbe645 100644 --- a/src/main/java/troy/autofish/FabricModAutofish.java +++ b/src/main/java/troy/autofish/FabricModAutofish.java @@ -42,11 +42,13 @@ public void onInitializeClient() { } public void tick(MinecraftClient client) { - if (autofishGuiKey.wasPressed()) { - client.setScreen(AutofishScreenBuilder.buildScreen(this, client.currentScreen)); + if (this.autofish != null){ + if (autofishGuiKey.wasPressed()) { + client.setScreen(AutofishScreenBuilder.buildScreen(this, client.currentScreen)); + } + autofish.tick(client); + scheduler.tick(client); } - autofish.tick(client); - scheduler.tick(client); } /**