refactor: Use custom ray trace provider
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user