Skip to content

Commit

Permalink
Merge pull request #31 from half-drop/fabric-1.20.1
Browse files Browse the repository at this point in the history
Apply Persistent mode fix for 1.20.1
  • Loading branch information
Wudji authored Nov 12, 2024
2 parents cecab93 + 485ca79 commit fdffa76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/main/java/troy/autofish/Autofish.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ 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 @@ -234,7 +237,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 fdffa76

Please sign in to comment.