mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-05-24 01:34:04 +02:00
Add option to disable flight inertia after releasing movement keys
Fixes #2
This commit is contained in:
parent
c1bbef8228
commit
3923a65cd8
src/main/java/chylex/bettercontrols
@ -20,6 +20,7 @@ public final class BetterControlsConfig{
|
|||||||
|
|
||||||
public final KeyBindingWithModifier keyToggleFlight = new KeyBindingWithModifier("key.bettercontrols.toggle_flight");
|
public final KeyBindingWithModifier keyToggleFlight = new KeyBindingWithModifier("key.bettercontrols.toggle_flight");
|
||||||
public SprintMode sprintModeWhileFlying = SprintMode.TAP_TO_START;
|
public SprintMode sprintModeWhileFlying = SprintMode.TAP_TO_START;
|
||||||
|
public boolean disableFlightInertia = false;
|
||||||
public boolean disableChangingFovWhileFlying = false;
|
public boolean disableChangingFovWhileFlying = false;
|
||||||
public boolean flyOnGroundInCreative = false;
|
public boolean flyOnGroundInCreative = false;
|
||||||
public float flightSpeedMpCreativeDefault = 1F;
|
public float flightSpeedMpCreativeDefault = 1F;
|
||||||
|
@ -41,6 +41,7 @@ final class ConfigSerializer implements JsonSerializer<BetterControlsConfig>, Js
|
|||||||
|
|
||||||
Json.writeKeyBinding(obj, "Flight.KeyToggle.Creative", cfg.keyToggleFlight);
|
Json.writeKeyBinding(obj, "Flight.KeyToggle.Creative", cfg.keyToggleFlight);
|
||||||
Json.setEnum(obj, "Flight.SprintMode", cfg.sprintModeWhileFlying);
|
Json.setEnum(obj, "Flight.SprintMode", cfg.sprintModeWhileFlying);
|
||||||
|
Json.setBool(obj, "Flight.DisableInertia", cfg.disableFlightInertia);
|
||||||
Json.setBool(obj, "Flight.DisableChangingFOV", cfg.disableChangingFovWhileFlying);
|
Json.setBool(obj, "Flight.DisableChangingFOV", cfg.disableChangingFovWhileFlying);
|
||||||
Json.setBool(obj, "Flight.FlyOnGround.Creative", cfg.flyOnGroundInCreative);
|
Json.setBool(obj, "Flight.FlyOnGround.Creative", cfg.flyOnGroundInCreative);
|
||||||
Json.setFloat(obj, "Flight.SpeedMp.Creative.Default", cfg.flightSpeedMpCreativeDefault);
|
Json.setFloat(obj, "Flight.SpeedMp.Creative.Default", cfg.flightSpeedMpCreativeDefault);
|
||||||
@ -79,6 +80,7 @@ final class ConfigSerializer implements JsonSerializer<BetterControlsConfig>, Js
|
|||||||
|
|
||||||
Json.readKeyBinding(obj, "Flight.KeyToggle.Creative", cfg.keyToggleFlight);
|
Json.readKeyBinding(obj, "Flight.KeyToggle.Creative", cfg.keyToggleFlight);
|
||||||
cfg.sprintModeWhileFlying = Json.getEnum(obj, "Flight.SprintMode", cfg.sprintModeWhileFlying, SprintMode.class);
|
cfg.sprintModeWhileFlying = Json.getEnum(obj, "Flight.SprintMode", cfg.sprintModeWhileFlying, SprintMode.class);
|
||||||
|
cfg.disableFlightInertia = Json.getBool(obj, "Flight.DisableInertia", cfg.disableFlightInertia);
|
||||||
cfg.disableChangingFovWhileFlying = Json.getBool(obj, "Flight.DisableChangingFOV", cfg.disableChangingFovWhileFlying);
|
cfg.disableChangingFovWhileFlying = Json.getBool(obj, "Flight.DisableChangingFOV", cfg.disableChangingFovWhileFlying);
|
||||||
cfg.flyOnGroundInCreative = Json.getBool(obj, "Flight.FlyOnGround.Creative", cfg.flyOnGroundInCreative);
|
cfg.flyOnGroundInCreative = Json.getBool(obj, "Flight.FlyOnGround.Creative", cfg.flyOnGroundInCreative);
|
||||||
cfg.flightSpeedMpCreativeDefault = Json.getFloat(obj, "Flight.SpeedMp.Creative.Default", cfg.flightSpeedMpCreativeDefault, 0.25F, 8F);
|
cfg.flightSpeedMpCreativeDefault = Json.getFloat(obj, "Flight.SpeedMp.Creative.Default", cfg.flightSpeedMpCreativeDefault, 0.25F, 8F);
|
||||||
|
@ -126,6 +126,11 @@ public class BetterControlsScreen extends SettingsScreen{
|
|||||||
|
|
||||||
y += ROW_HEIGHT;
|
y += ROW_HEIGHT;
|
||||||
|
|
||||||
|
generateLeftSideText(y, elements, text("Disable Flight Inertia"));
|
||||||
|
elements.add(new BooleanValueWidget(col2(1), y, COL2_W, cfg.disableFlightInertia, value -> cfg.disableFlightInertia = value));
|
||||||
|
|
||||||
|
y += ROW_HEIGHT;
|
||||||
|
|
||||||
generateLeftSideText(y, elements, text("Disable Field Of View Changing"));
|
generateLeftSideText(y, elements, text("Disable Field Of View Changing"));
|
||||||
elements.add(new BooleanValueWidget(col2(1), y, COL2_W, cfg.disableChangingFovWhileFlying, value -> cfg.disableChangingFovWhileFlying = value));
|
elements.add(new BooleanValueWidget(col2(1), y, COL2_W, cfg.disableChangingFovWhileFlying, value -> cfg.disableChangingFovWhileFlying = value));
|
||||||
|
|
||||||
|
@ -153,8 +153,10 @@ public final class PlayerTicker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void afterInputTick(final ClientPlayerEntity player){
|
public void afterInputTick(final ClientPlayerEntity player){
|
||||||
|
final MovementInput input = player.movementInput;
|
||||||
|
|
||||||
if (MINECRAFT.currentScreen == null && !player.abilities.isFlying){
|
if (MINECRAFT.currentScreen == null && !player.abilities.isFlying){
|
||||||
player.movementInput.jump |= toggleJump.tick();
|
input.jump |= toggleJump.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlightHelper.isFlyingCreativeOrSpectator(player)){
|
if (FlightHelper.isFlyingCreativeOrSpectator(player)){
|
||||||
@ -168,11 +170,11 @@ public final class PlayerTicker{
|
|||||||
if (Math.abs(verticalVelocity) > 1E-5F && player == MINECRAFT.getRenderViewEntity()){
|
if (Math.abs(verticalVelocity) > 1E-5F && player == MINECRAFT.getRenderViewEntity()){
|
||||||
int direction = 0;
|
int direction = 0;
|
||||||
|
|
||||||
if (player.movementInput.sneaking){
|
if (input.sneaking){
|
||||||
--direction;
|
--direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.movementInput.jump){
|
if (input.jump){
|
||||||
++direction;
|
++direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +182,16 @@ public final class PlayerTicker{
|
|||||||
player.setMotion(player.getMotion().add(0D, flightSpeed * verticalVelocity * direction, 0D));
|
player.setMotion(player.getMotion().add(0D, flightSpeed * verticalVelocity * direction, 0D));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg().disableFlightInertia){
|
||||||
|
if (input.moveForward == 0F && input.moveStrafe == 0F){
|
||||||
|
player.setMotion(player.getMotion().mul(0.0, 1.0, 0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!input.jump && !input.sneaking){
|
||||||
|
player.setMotion(player.getMotion().mul(1.0, 0.0, 1.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg().resumeSprintingAfterHittingObstacle){
|
if (cfg().resumeSprintingAfterHittingObstacle){
|
||||||
|
Loading…
Reference in New Issue
Block a user