aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt
new file mode 100644
index 0000000..97082e2
--- /dev/null
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt
@@ -0,0 +1,23 @@
+package moe.nea.notenoughupdates.rei
+
+import io.github.moulberry.repo.data.NEUItem
+import me.shedaniel.rei.api.common.entry.EntrySerializer
+import me.shedaniel.rei.api.common.entry.EntryStack
+import net.minecraft.nbt.NbtCompound
+import moe.nea.notenoughupdates.repo.RepoManager
+import moe.nea.notenoughupdates.util.SkyblockId
+
+object NEUItemEntrySerializer : EntrySerializer<NEUItem?> {
+ override fun supportSaving(): Boolean = true
+ override fun supportReading(): Boolean = true
+
+ override fun read(tag: NbtCompound): NEUItem? {
+ return RepoManager.getNEUItem(SkyblockId(tag.getString("SKYBLOCK_ID")))
+ }
+
+ override fun save(entry: EntryStack<NEUItem?>, value: NEUItem?): NbtCompound {
+ return NbtCompound().apply {
+ putString("SKYBLOCK_ID", value?.skyblockItemId ?: "null")
+ }
+ }
+}