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; /** * Everything the shell printed, in order — stdout and stderr merged, line * endings already normalised to {@code \n}. A message can hold any number of * lines and can stop in the middle of one: the pane just appends it. */ public record ClientboundShellOutputPayload(String text) implements CustomPacketPayload { public static final Identifier SHELL_OUTPUT_PAYLOAD_ID = Identifier.fromNamespaceAndPath(Codecraft.MOD_ID, "shell_output"); public static final CustomPacketPayload.Type TYPE = new CustomPacketPayload.Type<>(SHELL_OUTPUT_PAYLOAD_ID); public static final StreamCodec CODEC = StreamCodec.composite( ByteBufCodecs.STRING_UTF8, ClientboundShellOutputPayload::text, ClientboundShellOutputPayload::new ); @Override public Type type() { return TYPE; } }