aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-18 01:07:35 +0200
committernea <nea@nea.moe>2023-05-18 01:07:35 +0200
commit3ebe3e80b929b03ad0bcb0c76cec6b3285fe08bd (patch)
tree76ec3fb6387365320eb4805642a12d35e3ef9d65 /src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
parent13f2b320c34abff8cbe1daa196a2e5e8f3f79188 (diff)
downloadfirmament-3ebe3e80b929b03ad0bcb0c76cec6b3285fe08bd.tar.gz
firmament-3ebe3e80b929b03ad0bcb0c76cec6b3285fe08bd.tar.bz2
firmament-3ebe3e80b929b03ad0bcb0c76cec6b3285fe08bd.zip
Make recipes with higher stack counts properly display
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
index 15731cb..3e9d543 100644
--- a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
+++ b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
@@ -1,25 +1,28 @@
package moe.nea.firmament.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.firmament.repo.RepoManager
import moe.nea.firmament.util.SkyblockId
-object NEUItemEntrySerializer : EntrySerializer<NEUItem?> {
+object NEUItemEntrySerializer : EntrySerializer<SBItemStack> {
const val SKYBLOCK_ID_ENTRY = "SKYBLOCK_ID"
+ const val SKYBLOCK_ITEM_COUNT = "SKYBLOCK_ITEM_COUNT"
override fun supportSaving(): Boolean = true
override fun supportReading(): Boolean = true
- override fun read(tag: NbtCompound): NEUItem? {
- return RepoManager.getNEUItem(SkyblockId(tag.getString(SKYBLOCK_ID_ENTRY)))
+ override fun read(tag: NbtCompound): SBItemStack {
+ val id = SkyblockId(tag.getString(SKYBLOCK_ID_ENTRY))
+ val count = if (tag.contains(SKYBLOCK_ITEM_COUNT)) tag.getInt(SKYBLOCK_ITEM_COUNT) else 1
+ return SBItemStack(id, RepoManager.getNEUItem(id), count)
}
- override fun save(entry: EntryStack<NEUItem?>, value: NEUItem?): NbtCompound {
+ override fun save(entry: EntryStack<SBItemStack>, value: SBItemStack): NbtCompound {
return NbtCompound().apply {
- putString(SKYBLOCK_ID_ENTRY, value?.skyblockItemId ?: "null")
+ putString(SKYBLOCK_ID_ENTRY, value.skyblockId.neuItem)
+ putInt(SKYBLOCK_ITEM_COUNT, value.stackSize)
}
}
}