fix: dedicated server error
This commit is contained in:
parent
03861f193b
commit
2089a966e4
@ -1,6 +1,8 @@
|
|||||||
package quaedam.projection.misc
|
package quaedam.projection.misc
|
||||||
|
|
||||||
import dev.architectury.event.events.client.ClientTickEvent
|
import dev.architectury.event.events.client.ClientTickEvent
|
||||||
|
import dev.architectury.platform.Platform
|
||||||
|
import net.fabricmc.api.EnvType
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||||
import net.minecraft.client.resources.sounds.SoundInstance
|
import net.minecraft.client.resources.sounds.SoundInstance
|
||||||
@ -48,17 +50,19 @@ object NoiseProjection {
|
|||||||
}!!
|
}!!
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ClientTickEvent.CLIENT_POST.register { game ->
|
if (Platform.getEnv() == EnvType.CLIENT) {
|
||||||
val player = game.player ?: return@register
|
ClientTickEvent.CLIENT_POST.register { game ->
|
||||||
val random = (game.level ?: return@register).random
|
val player = game.player ?: return@register
|
||||||
val projections = Projector.findNearbyProjections(player.level(), player.blockPosition(), effect.get())
|
val random = (game.level ?: return@register).random
|
||||||
if (projections.isNotEmpty()) {
|
val projections = Projector.findNearbyProjections(player.level(), player.blockPosition(), effect.get())
|
||||||
val rate = projections.maxOf { it.rate }
|
if (projections.isNotEmpty()) {
|
||||||
val amount = min(projections.sumOf { it.amount }, 12)
|
val rate = projections.maxOf { it.rate }
|
||||||
if (amount != 0 && random.nextInt(1000 / rate) == 1) {
|
val amount = min(projections.sumOf { it.amount }, 12)
|
||||||
for (i in 0 until random.nextInt(amount)) {
|
if (amount != 0 && random.nextInt(1000 / rate) == 1) {
|
||||||
// play random noise
|
for (i in 0 until random.nextInt(amount)) {
|
||||||
playRandomNoise(random, game)
|
// play random noise
|
||||||
|
playRandomNoise(random, game)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user