Files
codecraft/src/main/java/com/aranroig/payloads/ServerboundShellResizePayload.java
Aran Roig 5897870725
Some checks failed
build / build (push) Failing after 1m37s
Shell and folders
2026-10-07 19:13:25 +02:00

38 lines
1.6 KiB
Java

package com.aranroig.payloads;
import com.aranroig.Codecraft;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.Identifier;
/**
* The terminal pane's grid changed size. Not keystrokes — the shell's input
* is left alone: the server resizes the pseudo-terminal itself, and the
* kernel signals whatever runs in it the way it signals a real window's
* resize. That is what lets a full-screen program reflow while it holds the
* screen, which a typed {@code stty} at a prompt that is not there could
* never do.
*/
public record ServerboundShellResizePayload(int rows, int cols) implements CustomPacketPayload {
public static final Identifier SHELL_RESIZE_PAYLOAD_ID = Identifier.fromNamespaceAndPath(Codecraft.MOD_ID, "shell_resize");
public static final CustomPacketPayload.Type<ServerboundShellResizePayload> TYPE = new CustomPacketPayload.Type<>(SHELL_RESIZE_PAYLOAD_ID);
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundShellResizePayload> CODEC =
StreamCodec.composite(
ByteBufCodecs.VAR_INT,
ServerboundShellResizePayload::rows,
ByteBufCodecs.VAR_INT,
ServerboundShellResizePayload::cols,
ServerboundShellResizePayload::new
);
@Override
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}