aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/SkyblockId.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-03 01:24:24 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-09 01:01:18 +0100
commit22f0cc59a2d3bc7900764e3916c670075ff9d35e (patch)
treeb503ff607cf818a539cbbaa403f6851ef979e03d /src/main/kotlin/util/SkyblockId.kt
parent646843ba3b960ac48f9866b3640438d3cc1dafc4 (diff)
downloadFirmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.tar.gz
Firmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.tar.bz2
Firmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.zip
1.21.3 WIP
Diffstat (limited to 'src/main/kotlin/util/SkyblockId.kt')
-rw-r--r--src/main/kotlin/util/SkyblockId.kt7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index 059e746..9c9287b 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -2,6 +2,7 @@
package moe.nea.firmament.util
+import com.mojang.serialization.Codec
import io.github.moulberry.repo.data.NEUIngredient
import io.github.moulberry.repo.data.NEUItem
import io.github.moulberry.repo.data.Rarity
@@ -16,6 +17,9 @@ import net.minecraft.component.type.NbtComponent
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.nbt.NbtCompound
+import net.minecraft.network.RegistryByteBuf
+import net.minecraft.network.codec.PacketCodec
+import net.minecraft.network.codec.PacketCodecs
import net.minecraft.util.Identifier
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.set
@@ -68,6 +72,9 @@ value class SkyblockId(val neuItem: String) {
val NULL: SkyblockId = SkyblockId("null")
val PET_NULL: SkyblockId = SkyblockId("null_pet")
private val illlegalPathRegex = "[^a-z0-9_.-/]".toRegex()
+ val CODEC = Codec.STRING.xmap({ SkyblockId(it) }, { it.neuItem })
+ val PACKET_CODEC: PacketCodec<in RegistryByteBuf, SkyblockId> =
+ PacketCodecs.STRING.xmap({ SkyblockId(it) }, { it.neuItem })
}
}