diff options
author | Linnea Gräf <nea@nea.moe> | 2025-03-06 21:43:11 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-03-08 16:01:00 +0100 |
commit | 8a4bfe24b364612e3e783ed9569082b130aa2bfc (patch) | |
tree | 5a98ab8ebecbde6e32e13479a8fb9e17632a93ba /src/main/kotlin/util/mc | |
parent | 9099abe955d88f7e0f1a1a8feba519a8a098858d (diff) | |
download | Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.tar.gz Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.tar.bz2 Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.zip |
refactor: Use custom ray trace provider
Diffstat (limited to 'src/main/kotlin/util/mc')
-rw-r--r-- | src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt b/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt index 012f52e..0866665 100644 --- a/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt +++ b/src/main/kotlin/util/mc/FirmamentDataComponentTypes.kt @@ -1,12 +1,15 @@ package moe.nea.firmament.util.mc import com.mojang.serialization.Codec +import io.netty.buffer.ByteBuf import net.minecraft.component.ComponentType +import net.minecraft.network.codec.PacketCodec import net.minecraft.registry.Registries import net.minecraft.registry.Registry import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.ClientInitEvent +import moe.nea.firmament.repo.MiningRepoData object FirmamentDataComponentTypes { @@ -26,11 +29,32 @@ object FirmamentDataComponentTypes { ) } + fun <T> errorCodec(message: String): PacketCodec<in ByteBuf, T> = + object : PacketCodec<ByteBuf, T> { + override fun decode(buf: ByteBuf?): T? { + error(message) + } + + override fun encode(buf: ByteBuf?, value: T?) { + error(message) + } + } + + fun <T, B : ComponentType.Builder<T>> B.neverEncode(message: String = "This element should never be encoded or decoded"): B { + packetCodec(errorCodec(message)) + codec(null) + return this + } + val IS_BROKEN = register<Boolean>( "is_broken" ) { it.codec(Codec.BOOL.fieldOf("is_broken").codec()) } + val CUSTOM_MINING_BLOCK_DATA = register<MiningRepoData.CustomMiningBlock>("custom_mining_block") { + it.neverEncode() + } + } |