Files
codecraft/src/main/java/com/aranroig/payloads/ServerboundRenameFilePayload.java
Aran Roig 5897870725
Some checks failed
build / build (push) Failing after 1m37s
Shell and folders
2026-10-07 19:13:25 +02:00

38 lines
1.4 KiB
Java

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;
/**
* Asks the server to rename a project file: its copy in the saved project and
* its live document move to the new name, the sessions of everyone editing it
* follow, and the other editors are told
* ({@link ClientboundRenameFilePayload}).
*/
public record ServerboundRenameFilePayload(String oldName, String newName) implements CustomPacketPayload {
public static final Identifier RENAME_FILE_PAYLOAD_ID = Identifier.fromNamespaceAndPath(Codecraft.MOD_ID, "rename_file");
public static final CustomPacketPayload.Type<ServerboundRenameFilePayload> TYPE = new CustomPacketPayload.Type<>(RENAME_FILE_PAYLOAD_ID);
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundRenameFilePayload> CODEC =
StreamCodec.composite(
ByteBufCodecs.STRING_UTF8,
ServerboundRenameFilePayload::oldName,
ByteBufCodecs.STRING_UTF8,
ServerboundRenameFilePayload::newName,
ServerboundRenameFilePayload::new
);
@Override
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}