Add vectored afterburner nozzle with afterburner key and exhaust style
- Add vectored afterburner nozzle block with AzureLib model, deflection, throttle and afterburner state - Drive nozzles from the vehicle control node and map pitch, roll and yaw to differential deflection - Add afterburner toggle key and packet, linked to the control node - Replace Warium exhaust effect entities with improved flames, particles and sounds when exhaustStyle is improved - Add /aero seedgen to measure the air ceiling for the air placeholder - Upgrade Warium VS to 1.1.7 and make the lift use horizontal speed
This commit is contained in:
1 parent
1e659816b8
commit
70eb237d70
56 files changed
+2197
-12
No files matched your search
@@ -0,0 +1,70 @@
|
||||
package dev.lumareth.improvedAerodynamics.exhaust;
|
||||
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* {@code /aero nozzle <pos> ...}: moves a vectored afterburner nozzle by hand, for testing it without the flight system.
|
||||
* {@code deflection <degrees>}, {@code throttle <0..1>}, {@code afterburner <true|false>} and {@code right <true|false>}.
|
||||
*/
|
||||
public final class NozzleCommands {
|
||||
private NozzleCommands() {
|
||||
}
|
||||
|
||||
public static LiteralArgumentBuilder<CommandSourceStack> node() {
|
||||
return Commands.literal("nozzle").then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||
.executes(context -> status(context.getSource(), BlockPosArgument.getLoadedBlockPos(context, "pos")))
|
||||
.then(Commands.literal("deflection").then(Commands.argument("degrees", FloatArgumentType.floatArg(-90.0F, 90.0F))
|
||||
.executes(context -> {
|
||||
float degrees = FloatArgumentType.getFloat(context, "degrees");
|
||||
return modify(context.getSource(), BlockPosArgument.getLoadedBlockPos(context, "pos"),
|
||||
nozzle -> nozzle.setDeflectionTarget((float) Math.toRadians(degrees)));
|
||||
})))
|
||||
.then(Commands.literal("throttle").then(Commands.argument("throttle", FloatArgumentType.floatArg(0.0F, 1.0F))
|
||||
.executes(context -> {
|
||||
float throttle = FloatArgumentType.getFloat(context, "throttle");
|
||||
return modify(context.getSource(), BlockPosArgument.getLoadedBlockPos(context, "pos"),
|
||||
nozzle -> nozzle.setThrottle(throttle));
|
||||
})))
|
||||
.then(Commands.literal("afterburner").then(Commands.argument("on", BoolArgumentType.bool())
|
||||
.executes(context -> {
|
||||
boolean on = BoolArgumentType.getBool(context, "on");
|
||||
return modify(context.getSource(), BlockPosArgument.getLoadedBlockPos(context, "pos"),
|
||||
nozzle -> nozzle.setAfterburner(on));
|
||||
})))
|
||||
.then(Commands.literal("right").then(Commands.argument("right", BoolArgumentType.bool())
|
||||
.executes(context -> {
|
||||
boolean right = BoolArgumentType.getBool(context, "right");
|
||||
return modify(context.getSource(), BlockPosArgument.getLoadedBlockPos(context, "pos"),
|
||||
nozzle -> nozzle.setRightEngine(right));
|
||||
}))));
|
||||
}
|
||||
|
||||
private static int modify(CommandSourceStack source, BlockPos pos, Consumer<NozzleBlockEntity> change) {
|
||||
if (!(source.getLevel().getBlockEntity(pos) instanceof NozzleBlockEntity nozzle)) {
|
||||
source.sendFailure(Component.literal("There is no vectored afterburner nozzle at " + pos.toShortString()));
|
||||
return 0;
|
||||
}
|
||||
change.accept(nozzle);
|
||||
return status(source, pos);
|
||||
}
|
||||
|
||||
private static int status(CommandSourceStack source, BlockPos pos) {
|
||||
if (!(source.getLevel().getBlockEntity(pos) instanceof NozzleBlockEntity nozzle)) {
|
||||
source.sendFailure(Component.literal("There is no vectored afterburner nozzle at " + pos.toShortString()));
|
||||
return 0;
|
||||
}
|
||||
source.sendSuccess(() -> Component.literal(String.format("Nozzle at %s: deflection %.1f deg, throttle %.2f, afterburner %s, %s engine",
|
||||
pos.toShortString(), Math.toDegrees(nozzle.getDeflectionTarget()), nozzle.getThrottle(),
|
||||
nozzle.isAfterburner() ? "on" : "off", nozzle.isRightEngine() ? "right" : "left")), false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user