feat: only register resource reload on client

This commit is contained in:
xtex 2023-07-02 10:56:44 +08:00
parent 7e3611bc9e
commit 0127fda59b
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -1,5 +1,6 @@
package quaedam.projection.swarm package quaedam.projection.swarm
import dev.architectury.platform.Platform
import dev.architectury.registry.ReloadListenerRegistry import dev.architectury.registry.ReloadListenerRegistry
import net.fabricmc.api.EnvType import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment import net.fabricmc.api.Environment
@ -113,12 +114,17 @@ data class ProjectedPersonShape(
var skins = emptyList<ResourceLocation>() var skins = emptyList<ResourceLocation>()
init { init {
@Environment(EnvType.CLIENT)
if (Platform.getEnv() == EnvType.CLIENT) {
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, ReloadListener, id) ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, ReloadListener, id)
} }
}
@Environment(EnvType.CLIENT)
operator fun get(index: Int) = skins[abs(index) % skins.size] operator fun get(index: Int) = skins[abs(index) % skins.size]
fun random(random: Random) = random.nextInt() fun random(random: Random) = random.nextInt()
@Environment(EnvType.CLIENT)
private object ReloadListener : PreparableReloadListener { private object ReloadListener : PreparableReloadListener {
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")