Skip to content

Commit

Permalink
Fixed several bugs related to Persistent mode
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Wudji committed Sep 16, 2024
1 parent 51da910 commit 283a9de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/main/java/troy/autofish/Autofish.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/troy/autofish/FabricModAutofish.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 283a9de

Please sign in to comment.