Skip to content

Commit

Permalink
Disable the mod while submerged in water (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Sep 5, 2023
1 parent a571af1 commit b772a1a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/do_a_barrel_roll/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b772a1a

Please sign in to comment.