diff --git a/gradle.properties b/gradle.properties index 851ac81..a6413fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1 mod_id=improved_aerodynamics mod_name=VS: Improved Aerodynamics mod_license=MIT -mod_version=0.4.0 +mod_version=0.4.2 azurelib_version=3.2.7 mod_group_id=dev.lumareth.improvedaerodynamics mod_authors=Lumareth diff --git a/src/main/java/dev/lumareth/improvedAerodynamics/Config.java b/src/main/java/dev/lumareth/improvedAerodynamics/Config.java index e1ae0e0..c74a93a 100644 --- a/src/main/java/dev/lumareth/improvedAerodynamics/Config.java +++ b/src/main/java/dev/lumareth/improvedAerodynamics/Config.java @@ -204,6 +204,47 @@ public final class Config { .comment("The nozzle gives off light while its afterburner is lit") .define("lightEnabled", true); + static { + BUILDER.pop(); + BUILDER.comment("Cursor aim: the mouse moves a cursor on screen, a virtual pilot flies the control node's craft by it").push("cursor_aim"); + } + + public static final ForgeConfigSpec.BooleanValue CURSOR_AIM_ENABLED = BUILDER.comment("Whether pilots may use cursor aim on this server") + .define("enabled", true); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_FULL_DEFLECTION_DEGREES = BUILDER.comment("Angle of the cursor from the gun reticle at which the virtual pilot turns as hard as it can: the maximum bank", + "sideways, the full pitch rate up or down. Closer than that it turns more gently, so the reticle settles onto", + "the cursor. How fast the craft can turn is worked out from the craft itself") + .defineInRange("fullDeflectionDegrees", 30.0, 5.0, 90.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_DEADZONE_DEGREES = BUILDER.comment("Radius around the gun reticle in degrees inside which the pilot stops steering towards the cursor. The reticle", + "then settles this far from the cursor. Outside it the command grows from zero, there is no jump at the edge") + .defineInRange("deadzoneDegrees", 0.0, 0.0, 15.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MAX_ROLL_RATE_DEGREES = BUILDER.comment("Fastest roll in degrees per second the pilot asks for when it rolls to a bank angle") + .defineInRange("maxRollRateDegrees", 150.0, 10.0, 720.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MAX_BANK_DEGREES = BUILDER.comment("Bank angle the pilot rolls to when the cursor is at full sideways deflection, at most. Craft whose wings", + "cannot hold that bank in a level turn get less") + .defineInRange("maxBankDegrees", 70.0, 10.0, 90.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_BANK_GAIN = BUILDER.comment("Roll rate in rad/s per radian of bank angle error, how eagerly the pilot rolls to the wanted bank and levels the wings") + .defineInRange("bankGain", 3.0, 0.2, 20.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_RATE_GAIN = BUILDER.comment("How hard the pilot corrects its turn rate, in angular acceleration per rad/s of rate error. Lower is smoother,", + "higher follows the cursor tighter and can start to oscillate") + .defineInRange("rateGain", 5.0, 0.5, 40.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_PUSH_FACTOR = BUILDER.comment("A cursor below the gun reticle pushes the nose down. This is how much of the pull rate that may be, since", + "negative g is harder on the craft and the pilot") + .defineInRange("pushFactor", 0.4, 0.0, 1.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_STALLED_PITCH_FACTOR = BUILDER.comment("Multiplier for the pitch rate the pilot asks for while the wings are stalled, so it does not keep pulling") + .defineInRange("stalledPitchFactor", 0.3, 0.0, 1.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MIN_SPEED = BUILDER.comment("Below this speed in blocks per second the pilot does nothing, the surfaces have no effect anyway") + .defineInRange("minSpeed", 15.0, 0.0, 200.0); + static { BUILDER.pop(); } @@ -225,6 +266,40 @@ public final class Config { "fixed 20 degree steps. Needs physicsRateAerodynamics on the server") .define("animateControlSurfaces", true); + static { + CLIENT_BUILDER.comment("Cursor aim, client side").push("cursor_aim"); + } + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_LOOK_AHEAD = CLIENT_BUILDER.comment("How strongly the camera looks into the direction of the turn. 0 never moves it, 1 (100%) turns it quickly", + "to look where the cursor points. In between it follows more slowly") + .defineInRange("lookAhead", 0.0, 0.0, 1.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MOUSE_SENSITIVITY = CLIENT_BUILDER.comment("Multiplier for how far the mouse moves the cursor (or the camera while the free look key is held)") + .defineInRange("mouseSensitivity", 1.0, 0.05, 10.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_SPRING_BACK_SECONDS = CLIENT_BUILDER.comment("The cursor drifts to the gun reticle with this time constant in seconds, which ends the turn by itself.", + "0, the default, keeps it where you put it in the world, so the craft turns until the reticle is on it") + .defineInRange("springBackSeconds", 0.0, 0.0, 10.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MAX_ANGLE_DEGREES = CLIENT_BUILDER.comment("Furthest the cursor can go from the gun reticle, 135 is a 270 degree cone") + .defineInRange("maxCursorAngleDegrees", 135.0, 10.0, 180.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_ZOOM_STEP = CLIENT_BUILDER.comment("Blocks the camera moves per mouse wheel notch") + .defineInRange("zoomStep", 2.0, 0.1, 20.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_ZOOM_MAX = CLIENT_BUILDER.comment("Furthest the camera can be pulled back from its normal distance, in blocks") + .defineInRange("zoomMax", 80.0, 0.0, 500.0); + + public static final ForgeConfigSpec.DoubleValue CURSOR_AIM_MARKER_SIZE = CLIENT_BUILDER.comment("Radius of the cursor ring on screen") + .defineInRange("markerSize", 0.04, 0.01, 0.3); + + public static final ForgeConfigSpec.BooleanValue CURSOR_AIM_SHOW_RETICLE = CLIENT_BUILDER.comment("Draw a small cross where the gun reticle points, the zero of the cursor, so you can see it when the camera looks away") + .define("showReticle", true); + + static { + CLIENT_BUILDER.pop(); + } + static final ForgeConfigSpec CLIENT_SPEC = CLIENT_BUILDER.build(); private Config() { diff --git a/src/main/java/dev/lumareth/improvedAerodynamics/ImprovedAerodynamics.java b/src/main/java/dev/lumareth/improvedAerodynamics/ImprovedAerodynamics.java index f984cbb..5ef43ea 100644 --- a/src/main/java/dev/lumareth/improvedAerodynamics/ImprovedAerodynamics.java +++ b/src/main/java/dev/lumareth/improvedAerodynamics/ImprovedAerodynamics.java @@ -1,11 +1,9 @@ package dev.lumareth.improvedAerodynamics; import com.mojang.logging.LogUtils; -import dev.lumareth.improvedAerodynamics.client.aim.CursorAimClientConfig; import dev.lumareth.improvedAerodynamics.client.pipper.PipperConfig; import dev.lumareth.improvedAerodynamics.exhaust.ExhaustSync; import dev.lumareth.improvedAerodynamics.exhaust.NozzleContent; -import dev.lumareth.improvedAerodynamics.flight.CursorAimConfig; import dev.lumareth.improvedAerodynamics.flight.PhysicsBridge; import dev.lumareth.improvedAerodynamics.network.Network; import dev.lumareth.improvedAerodynamics.terrain.LookaheadLoader; @@ -34,8 +32,6 @@ public class ImprovedAerodynamics { ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_SPEC); // Own file name: the default one is taken by Config.CLIENT_SPEC ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, PipperConfig.SPEC, "improved_aerodynamics-pipper-client.toml"); - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CursorAimConfig.SPEC, "improved_aerodynamics-cursor-aim.toml"); - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CursorAimClientConfig.SPEC, "improved_aerodynamics-cursor-aim-client.toml"); NozzleContent.register(FMLJavaModLoadingContext.get().getModEventBus()); Network.register(); } diff --git a/src/main/java/dev/lumareth/improvedAerodynamics/client/aim/CursorAimClient.java b/src/main/java/dev/lumareth/improvedAerodynamics/client/aim/CursorAimClient.java index 2f9b252..02d3e78 100644 --- a/src/main/java/dev/lumareth/improvedAerodynamics/client/aim/CursorAimClient.java +++ b/src/main/java/dev/lumareth/improvedAerodynamics/client/aim/CursorAimClient.java @@ -1,5 +1,6 @@ package dev.lumareth.improvedAerodynamics.client.aim; +import dev.lumareth.improvedAerodynamics.Config; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferUploader; @@ -44,9 +45,10 @@ import java.lang.reflect.Method; /** * Cursor aim, the client side. While it is on: *