Virtual stick cursor steered through the gun reticle, server-side virtual pilot using measured control responses, client cursor/camera handling with look-ahead, free look and scroll zoom. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVREx3uo7nz1FEhzveWTUh
31 lines
1.2 KiB
Java
31 lines
1.2 KiB
Java
package dev.lumareth.improvedAerodynamics.flight;
|
|
|
|
import net.mcreator.valkyrienwarium.entity.SeatEntityEntity;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.world.entity.Entity;
|
|
|
|
/** Server side of cursor aim: takes the cursor a pilot sends and hands it to the control node's virtual pilot. */
|
|
public final class CursorAimServer {
|
|
private CursorAimServer() {
|
|
}
|
|
|
|
public static void accept(ServerPlayer player, boolean active, double cf, double cr, double cu) {
|
|
Entity vehicle = player.getVehicle();
|
|
if (!(vehicle instanceof SeatEntityEntity)) {
|
|
return;
|
|
}
|
|
AimBasis basis = AimBasis.of(vehicle.level(), vehicle.blockPosition());
|
|
if (basis == null) {
|
|
return;
|
|
}
|
|
long nodeKey = basis.nodePos().asLong();
|
|
double length = Math.sqrt(cf * cf + cr * cr + cu * cu);
|
|
if (!active || !CursorAimConfig.ENABLED.get() || !(length > 1.0E-6) || !Double.isFinite(length)) {
|
|
CursorAimRegistry.clear(nodeKey);
|
|
return;
|
|
}
|
|
CursorAimRegistry.set(nodeKey, new CursorAimRegistry.Aim(cf / length, cr / length, cu / length,
|
|
basis.forward(), basis.right(), basis.up(), System.nanoTime()));
|
|
}
|
|
}
|