diff --git a/src/client/java/com/emonadeo/autorun/AutoRunMod.java b/src/client/java/com/emonadeo/autorun/AutoRunMod.java index 6305637..7afea4c 100644 --- a/src/client/java/com/emonadeo/autorun/AutoRunMod.java +++ b/src/client/java/com/emonadeo/autorun/AutoRunMod.java @@ -33,6 +33,7 @@ public class AutoRunMod implements ClientModInitializer { private static boolean originalAutoJumpSetting; private static boolean toggleAutoJump; + private static boolean togglePersistAutoRun; @Override public void onInitializeClient() { @@ -40,6 +41,7 @@ public void onInitializeClient() { AutoRunMod.timeActivated = -1; AutoRunMod.delayBuffer = 20; AutoRunMod.toggleAutoJump = true; + AutoRunMod.togglePersistAutoRun = false; AutoRunMod.keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.autorun.toggle", InputUtil.Type.KEYSYM, @@ -95,8 +97,11 @@ public void onInitializeClient() { ClientEntityEvents.ENTITY_UNLOAD.register((entity, clientWorld) -> { if (entity instanceof ClientPlayerEntity) { restoreAutoJump(MinecraftClient.getInstance()); - toggled.clear(); - } + if (!togglePersistAutoRun){ + toggled.clear(); + } + }; + }); } @@ -127,6 +132,7 @@ public static void loadConfig(File file) { cfg.load(new FileInputStream(file)); delayBuffer = Integer.parseInt(cfg.getProperty("delayBuffer", "20")); toggleAutoJump = Boolean.parseBoolean(cfg.getProperty("toggleAutoJump", "true")); + togglePersistAutoRun = Boolean.parseBoolean(cfg.getProperty("togglePersistAutoRun", "false")); // Re-save so that new properties will appear in old config files saveConfig(file); @@ -140,6 +146,7 @@ public static void saveConfig(File file) { FileOutputStream fos = new FileOutputStream(file, false); fos.write(("delayBuffer=" + delayBuffer + "\n").getBytes()); fos.write(("toggleAutoJump=" + toggleAutoJump + "\n").getBytes()); + fos.write(("togglePersistAutoRun=" + togglePersistAutoRun + "\n").getBytes()); fos.close(); } catch (IOException e) { e.printStackTrace(); @@ -165,4 +172,13 @@ public static boolean isToggleAutoJump() { public static void setToggleAutoJump(boolean toggleAutoJump) { AutoRunMod.toggleAutoJump = toggleAutoJump; } + + public static boolean isPersistAutoRun() { + return togglePersistAutoRun; + } + + public static void setPersistAutoRun(boolean togglePersistAutoRun) { + AutoRunMod.togglePersistAutoRun = togglePersistAutoRun; + } + } diff --git a/src/client/java/com/emonadeo/autorun/AutoRunModMenu.java b/src/client/java/com/emonadeo/autorun/AutoRunModMenu.java index 5859442..9b3983c 100644 --- a/src/client/java/com/emonadeo/autorun/AutoRunModMenu.java +++ b/src/client/java/com/emonadeo/autorun/AutoRunModMenu.java @@ -30,6 +30,14 @@ public Screen create(Screen screen) { .setSaveConsumer(AutoRunMod::setToggleAutoJump) .build()); + // Toogle run on start + general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config." + AutoRunMod.MODID + ".togglePersistAutoRun"), AutoRunMod.isPersistAutoRun()) + .setDefaultValue(false) + .setTooltip(Text.translatable("config." + AutoRunMod.MODID + ".togglePersistAutoRun.description")) + .setSaveConsumer(AutoRunMod::setPersistAutoRun) + .build()); + + // Delay Buffer general.addEntry(entryBuilder.startIntField(Text.translatable("config." + AutoRunMod.MODID + ".delayBuffer"), AutoRunMod.getDelayBuffer()) .setDefaultValue(20) diff --git a/src/main/resources/assets/autorun/lang/en_us.json b/src/main/resources/assets/autorun/lang/en_us.json index 286bea6..ddd70c2 100644 --- a/src/main/resources/assets/autorun/lang/en_us.json +++ b/src/main/resources/assets/autorun/lang/en_us.json @@ -1,5 +1,7 @@ { "key.autorun.toggle": "Toggle Auto-Run", + "config.autorun.togglePersistAutoRun": "Persist Auto-Run", + "config.autorun.togglePersistAutoRun.description": "Keep Auto-Run toggled between leaving and joining worlds or servers", "title.autorun.config": "AutoRun", "config.autorun.general": "General", "config.autorun.delayBuffer": "Delay Buffer",