@@ -1,11 +1,13 @@
|
||||
package com.aranroig.editor;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
public class EditorFile {
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, EditorFile> CODEC =
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, EditorFile> STREAM_CODEC =
|
||||
StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
EditorFile::getName,
|
||||
@@ -16,6 +18,13 @@ public class EditorFile {
|
||||
EditorFile::new
|
||||
);
|
||||
|
||||
public static final Codec<EditorFile> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Codec.STRING.fieldOf("name").forGetter(EditorFile::getName),
|
||||
Codec.STRING.fieldOf("text").forGetter(EditorFile::getText)
|
||||
).apply(instance, EditorFile::new)
|
||||
);
|
||||
|
||||
// Class with file info
|
||||
private String name;
|
||||
private String text;
|
||||
|
||||
9
src/main/java/com/aranroig/editor/Project.java
Normal file
9
src/main/java/com/aranroig/editor/Project.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.aranroig.editor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Project(List<EditorFile> editorFiles) {
|
||||
/*
|
||||
TODO: Acabar esto. En principio hay que sustituir las listas de los archivos de proyecto por esta clase
|
||||
*/
|
||||
}
|
||||
30
src/main/java/com/aranroig/editor/RunInfo.java
Normal file
30
src/main/java/com/aranroig/editor/RunInfo.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.aranroig.editor;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
public class RunInfo {
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, RunInfo> CODEC =
|
||||
StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
RunInfo::getEntrypoint,
|
||||
|
||||
RunInfo::new
|
||||
);
|
||||
|
||||
// Class with file info
|
||||
private String entrypoint;
|
||||
|
||||
public RunInfo(String entrypoint) {
|
||||
this.entrypoint = entrypoint;
|
||||
}
|
||||
|
||||
public String getEntrypoint() {
|
||||
return entrypoint;
|
||||
}
|
||||
|
||||
public void setEntrypoint(String entrypoint) {
|
||||
this.entrypoint = entrypoint;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user