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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user