Skip to content

Commit

Permalink
Configuration option for recast delay
Browse files Browse the repository at this point in the history
Staging for release
  • Loading branch information
freneticfeline committed Aug 8, 2017
1 parent 261dd93 commit 2c13b2f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.12-1.4
========
Added configuration option for recast delay

1.12-1.3
========
Update to work on Minecraft/Forge 1.12
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AutoFish Forge Mod versions 1.x-y.z require Minecraft 1.x with compatible versio
of MinecraftForge installed.

## Installation Instructions
Copy the `mod_autofish_forge-1.8-x.x.jar` file to the `mods` directory in your Minecraft
Copy the `mod_autofish_forge-1.x-x.x.jar` file to the `mods` directory in your Minecraft
data directory.

## Usage Instructions
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

version = "1.12-1.3"
version = "1.12-1.4"
group= "net.unladenswallow.minecraft.autofish" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "mod_autofish_forge"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
Expand All @@ -24,8 +25,7 @@ public class AutoFishEventHandler {
private long startedCastDelayAt = 0L;
private boolean isFishing = false;

/** How long to wait after reeling in a catch before casting again */
private static final int CAST_QUEUE_TICK_DELAY = 30;
private static final int TICKS_PER_SECOND = 20;

/** How long to suppress checking for a bite after starting to reel in. If we check for a bite while reeling
in, we may think we have a bite and try to reel in again, which will actually cause a re-cast and lose the fish */
Expand All @@ -42,9 +42,12 @@ public class AutoFishEventHandler {
the movement method of detection. */
private static final double MOTION_Y_THRESHOLD = -0.05d;

public AutoFishEventHandler() {
this.minecraft = FMLClientHandler.instance().getClient();
}

@SubscribeEvent
public void onClientTickEvent(ClientTickEvent event) {
this.minecraft = Minecraft.getMinecraft();
if (ModAutoFish.config_autofish_enable && !this.minecraft.isGamePaused() && this.minecraft.player != null) {
this.player = this.minecraft.player;

Expand Down Expand Up @@ -233,7 +236,7 @@ private EnumActionResult playerUseRod() {
}

private boolean isTimeToCast() {
return (this.castScheduledAt != 0 && this.minecraft.world.getTotalWorldTime() > this.castScheduledAt + CAST_QUEUE_TICK_DELAY);
return (this.castScheduledAt != 0 && this.minecraft.world.getTotalWorldTime() > this.castScheduledAt + (ModAutoFish.config_autofish_recastDelay * TICKS_PER_SECOND));
}

private void tryToSwitchRods() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ModAutoFish {
public static final boolean CONFIG_DEFAULT_AUTOFISH_PREVENTBREAK = false;
public static boolean config_autofish_entityClearProtect;
public static final boolean CONFIG_DEFAULT_AUTOFISH_ENTITYCLEARPROTECT = false;
public static int config_autofish_recastDelay;
public static final int CONFIG_DEFAULT_AUTOFISH_RECASTDELAY = 2;

@SidedProxy(clientSide="net.unladenswallow.minecraft.autofish.ClientProxy", serverSide="net.unladenswallow.minecraft.autofish.ServerProxy")
public static CommonProxy proxy;
Expand All @@ -47,6 +49,7 @@ public static void syncConfig() {
config_autofish_multirod = configFile.getBoolean("Enable MultiRod", Configuration.CATEGORY_GENERAL, CONFIG_DEFAULT_AUTOFISH_MULTIROD, "Automatically switch to a new fishing rod when the current rod breaks, if one is available in the hotbar.");
config_autofish_preventBreak = configFile.getBoolean("Enable Break Protection", Configuration.CATEGORY_GENERAL, CONFIG_DEFAULT_AUTOFISH_PREVENTBREAK, "Stop fishing or switch to a new rod before the current rod breaks.");
config_autofish_entityClearProtect = configFile.getBoolean("Enable Enity Clear Protection", Configuration.CATEGORY_GENERAL, CONFIG_DEFAULT_AUTOFISH_ENTITYCLEARPROTECT, "Re-cast after the server clears entities. EXPERIMENTAL");
config_autofish_recastDelay = configFile.getInt("Re-Cast Delay", Configuration.CATEGORY_GENERAL, CONFIG_DEFAULT_AUTOFISH_RECASTDELAY, 1, 10, "Time (in seconds) to wait before automatically re-casting. Increase this value if server lag causes re-casting to fail.");

if (configFile.hasChanged()) {
configFile.save();
Expand Down

0 comments on commit 2c13b2f

Please sign in to comment.