38 lines
1009 B
Kotlin
38 lines
1009 B
Kotlin
package codes.som.hibiscus.subsystems.xray
|
|
|
|
import codes.som.hibiscus.Hibiscus
|
|
import codes.som.hibiscus.features.visual.Xray
|
|
import net.minecraft.block.BlockState
|
|
import net.minecraft.util.registry.Registry
|
|
import kotlin.streams.asSequence
|
|
|
|
object XraySystem {
|
|
@JvmStatic
|
|
fun shouldRenderXray(): Boolean {
|
|
try {
|
|
return Hibiscus.features.getFeature<Xray>().enabled
|
|
} catch (_: Exception) {
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
@JvmStatic
|
|
fun isXrayBlock(blockState: BlockState): Boolean {
|
|
try {
|
|
val blockId = Registry.BLOCK.getId(blockState.block).toString()
|
|
val tags = blockState.streamTags().asSequence().map { "#" + it.id.toString() }
|
|
|
|
val checkedStrings = (sequenceOf(blockId) + tags).toSet()
|
|
|
|
return Hibiscus.features
|
|
.getFeature<Xray>()
|
|
.xrayBlocks
|
|
.any(checkedStrings::contains)
|
|
} catch (_: Exception) {
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|