This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user