feat(flight): enhance flight model with transonic drag and vortex lift features

This commit is contained in:
richard committed 2026-10-28 23:14:37 +01:00
1 parent 599ecae21f
commit 44a5f7f9bc
12 files changed
+177 -26

No files matched your search

@@ -8,6 +8,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -17,6 +18,7 @@ import java.util.List;
/**
* /improvedaerodynamics (or /aero) to read and change the most important server config values in game.
* {@code /aero} lists them, {@code /aero <option>} shows one, {@code /aero <option> <value>} sets and saves it.
* Needs operator rights, except for the owner of a singleplayer world, who may use them without cheats.
* All of them are read live, so changes apply immediately.
*/
public final class ConfigCommands {
@@ -32,6 +34,13 @@ public final class ConfigCommands {
new Option<>("lift_scale", Config.LIFT_SCALE, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("stall_angle_scale", Config.STALL_ANGLE_SCALE, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("stabilizer_drag", Config.STABILIZER_DRAG, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("transonic_drag", Config.TRANSONIC_DRAG, BoolArgumentType.bool(), Boolean.class),
new Option<>("speed_of_sound", Config.SPEED_OF_SOUND, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("transonic_peak_drag", Config.TRANSONIC_PEAK_DRAG, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("supersonic_drag", Config.SUPERSONIC_DRAG, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("vortex_lift", Config.VORTEX_LIFT, BoolArgumentType.bool(), Boolean.class),
new Option<>("vortex_stall_bonus", Config.VORTEX_STALL_BONUS, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("vortex_lift_strength", Config.VORTEX_LIFT_STRENGTH, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("trim_authority", Config.TRIM_AUTHORITY, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("trim_min_speed", Config.TRIM_MIN_SPEED, DoubleArgumentType.doubleArg(), Double.class),
new Option<>("air_placeholder", Config.ENABLE_AIR_PLACEHOLDER, BoolArgumentType.bool(), Boolean.class),
@@ -40,17 +49,26 @@ public final class ConfigCommands {
private ConfigCommands() {
}
/** Operators, and the owner of a singleplayer world even when cheats are off. */
private static boolean mayUse(CommandSourceStack source) {
if (source.hasPermission(2)) {
return true;
}
return source.getEntity() instanceof ServerPlayer player
&& source.getServer().isSingleplayerOwner(player.getGameProfile());
}
@SubscribeEvent
public static void onRegisterCommands(RegisterCommandsEvent event) {
LiteralArgumentBuilder<CommandSourceStack> root = Commands.literal("improvedaerodynamics")
.requires(source -> source.hasPermission(2))
.requires(ConfigCommands::mayUse)
.executes(context -> list(context.getSource()));
for (Option<?> option : OPTIONS) {
root.then(optionNode(option));
}
LiteralCommandNode<CommandSourceStack> node = event.getDispatcher().register(root);
event.getDispatcher().register(Commands.literal("aero")
.requires(source -> source.hasPermission(2))
.requires(ConfigCommands::mayUse)
.executes(context -> list(context.getSource()))
.redirect(node));
}