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 TYPE = new CustomPacketPayload.Type<>(SHELL_RESIZE_PAYLOAD_ID); public static final StreamCodec CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, ServerboundShellResizePayload::rows, ByteBufCodecs.VAR_INT, ServerboundShellResizePayload::cols, ServerboundShellResizePayload::new ); @Override public Type type() { return TYPE; } }