29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
|
package io.gitlab.jfronny.libjf.config.impl.network.packet;
|
||
|
|
||
|
import io.gitlab.jfronny.libjf.config.impl.network.RequestRouter;
|
||
|
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||
|
import net.minecraft.network.PacketByteBuf;
|
||
|
import net.minecraft.network.codec.PacketCodec;
|
||
|
import net.minecraft.network.packet.CustomPayload;
|
||
|
|
||
|
public record ResponsePacket(long request, int status, PacketByteBuf aux) implements CustomPayload {
|
||
|
public static final CustomPayload.Id<ResponsePacket> ID = CustomPayload.id(RequestRouter.MOD_ID + ":response");
|
||
|
public static final PacketCodec<PacketByteBuf, ResponsePacket> CODEC = PacketCodec.of(
|
||
|
(value, buf) -> {
|
||
|
buf.writeLong(value.request());
|
||
|
buf.writeInt(value.status());
|
||
|
buf.writeBytes(value.aux());
|
||
|
},
|
||
|
buf -> {
|
||
|
long request = buf.readLong();
|
||
|
int status = buf.readInt();
|
||
|
return new ResponsePacket(request, status, PacketByteBufs.copy(buf));
|
||
|
}
|
||
|
);
|
||
|
|
||
|
@Override
|
||
|
public Id<? extends CustomPayload> getId() {
|
||
|
return ID;
|
||
|
}
|
||
|
}
|