Files
VS--Improved-Aerodynamics/src/main/java/dev/lumareth/improvedAerodynamics/network/ControlModePacket.java
T
Claude 2f4f90c773 Choose cursor aim with /aero controls instead of a keybind
/aero controls keyboard|cursor_aim is open to every player, stored per player
and synced to the client, which switches on automatically when seated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVREx3uo7nz1FEhzveWTUh
2026-11-11 18:29:27 +01:00

33 lines
1.1 KiB
Java

package dev.lumareth.improvedAerodynamics.network;
import dev.lumareth.improvedAerodynamics.client.aim.CursorAimClient;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
/** Tells a client whether its player flies with cursor aim, see {@code /aero controls}. */
public final class ControlModePacket {
private final boolean cursorAim;
public ControlModePacket(boolean cursorAim) {
this.cursorAim = cursorAim;
}
public void encode(FriendlyByteBuf buffer) {
buffer.writeBoolean(cursorAim);
}
public static ControlModePacket decode(FriendlyByteBuf buffer) {
return new ControlModePacket(buffer.readBoolean());
}
public void handle(Supplier<NetworkEvent.Context> context) {
boolean value = cursorAim;
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CursorAimClient.setMode(value));
context.get().setPacketHandled(true);
}
}