Shell and folders
Some checks failed
build / build (push) Failing after 1m37s

This commit is contained in:
2026-10-07 19:13:25 +02:00
parent 7a115445ab
commit 5897870725
53 changed files with 6626 additions and 450 deletions

View File

@@ -0,0 +1,40 @@
package com.aranroig.payloads;
import com.aranroig.Codecraft;
import com.aranroig.editor.Edit;
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;
/**
* One keystroke's worth of changes to {@code file}, made against version
* {@code baseVersion} of it. The server rebases the edit onto the current
* version, applies it, and hands it to everyone else editing the file.
*/
public record ServerboundEditPayload(String file, int baseVersion, Edit edit) implements CustomPacketPayload {
public static final Identifier EDIT_PAYLOAD_ID = Identifier.fromNamespaceAndPath(Codecraft.MOD_ID, "edit");
public static final CustomPacketPayload.Type<ServerboundEditPayload> TYPE = new CustomPacketPayload.Type<>(EDIT_PAYLOAD_ID);
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundEditPayload> CODEC =
StreamCodec.composite(
ByteBufCodecs.STRING_UTF8,
ServerboundEditPayload::file,
ByteBufCodecs.VAR_INT,
ServerboundEditPayload::baseVersion,
Edit.STREAM_CODEC,
ServerboundEditPayload::edit,
ServerboundEditPayload::new
);
@Override
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}