This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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<ClientboundShellOutputPayload> TYPE = new CustomPacketPayload.Type<>(SHELL_OUTPUT_PAYLOAD_ID);
|
||||
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundShellOutputPayload> CODEC =
|
||||
StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
ClientboundShellOutputPayload::text,
|
||||
ClientboundShellOutputPayload::new
|
||||
);
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user