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
This commit is contained in:
10 files changed
+133
-20
No files matched your search
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user