diff --git a/src/client/java/nl/enjarai/doabarrelroll/DoABarrelRollClient.java b/src/client/java/nl/enjarai/doabarrelroll/DoABarrelRollClient.java index 4d2c322f..35518d4e 100644 --- a/src/client/java/nl/enjarai/doabarrelroll/DoABarrelRollClient.java +++ b/src/client/java/nl/enjarai/doabarrelroll/DoABarrelRollClient.java @@ -106,6 +106,12 @@ public static boolean isFallFlying() { } var player = MinecraftClient.getInstance().player; - return player != null && player.isFallFlying(); + if (player == null) { + return false; + } + if (ModConfig.INSTANCE.getDisableWhenSubmerged() && player.isSubmergedInWater()) { + return false; + } + return player.isFallFlying(); } } diff --git a/src/client/java/nl/enjarai/doabarrelroll/compat/yacl/YACLImplementation.java b/src/client/java/nl/enjarai/doabarrelroll/compat/yacl/YACLImplementation.java index 31bff1cf..3b80a461 100644 --- a/src/client/java/nl/enjarai/doabarrelroll/compat/yacl/YACLImplementation.java +++ b/src/client/java/nl/enjarai/doabarrelroll/compat/yacl/YACLImplementation.java @@ -70,6 +70,9 @@ public static Screen generateConfigScreen(Screen parent) { .enumClass(ActivationBehaviour.class)) .binding(ActivationBehaviour.VANILLA, () -> ModConfig.INSTANCE.getActivationBehaviour(), value -> ModConfig.INSTANCE.setActivationBehaviour(value)) .build()) + .option(getBooleanOption("controls", "disable_when_submerged", true, false) + .binding(true, () -> ModConfig.INSTANCE.getDisableWhenSubmerged(), value -> ModConfig.INSTANCE.setDisableWhenSubmerged(value)) + .build()) .build()) .group(OptionGroup.createBuilder() .name(getText("hud")) diff --git a/src/client/java/nl/enjarai/doabarrelroll/config/ModConfig.java b/src/client/java/nl/enjarai/doabarrelroll/config/ModConfig.java index 198527b0..c5a6d72e 100644 --- a/src/client/java/nl/enjarai/doabarrelroll/config/ModConfig.java +++ b/src/client/java/nl/enjarai/doabarrelroll/config/ModConfig.java @@ -43,6 +43,7 @@ static class Controls { double momentum_mouse_deadzone = 0.2; boolean show_momentum_widget = true; ActivationBehaviour activation_behaviour = ActivationBehaviour.VANILLA; + boolean disable_when_submerged = true; } Hud hud = new Hud(); @@ -123,6 +124,10 @@ public ActivationBehaviour getActivationBehaviour() { return general.controls.activation_behaviour; } //= ActivationBehaviour.VANILLA; + public boolean getDisableWhenSubmerged() { + return general.controls.disable_when_submerged; + } //= true; + public boolean getShowHorizon() { return general.hud.show_horizon; } @@ -268,6 +273,10 @@ public void setActivationBehaviour(ActivationBehaviour behaviour) { general.controls.activation_behaviour = behaviour; } + public void setDisableWhenSubmerged(boolean enabled) { + general.controls.disable_when_submerged = enabled; + } + public void setShowHorizon(boolean enabled) { general.hud.show_horizon = enabled; } diff --git a/src/main/resources/assets/do_a_barrel_roll/lang/en_us.yml b/src/main/resources/assets/do_a_barrel_roll/lang/en_us.yml index 94b3907e..8cd00c67 100644 --- a/src/main/resources/assets/do_a_barrel_roll/lang/en_us.yml +++ b/src/main/resources/assets/do_a_barrel_roll/lang/en_us.yml @@ -50,6 +50,10 @@ config.do_a_barrel_roll: invert_pitch: Invert Pitch invert_pitch.description: > Inverts the pitch axis while flying with a mouse. + disable_when_submerged: Disable When Submerged + disable_when_submerged.description: > + Disables the mod while you are underwater. + It is recommended to keep this enabled to prevent loss of control while swimming. hud: .: HUD show_horizon: Show Horizon Widget