Someplace i don't fucking know

This commit is contained in:
DBotThePony 2025-02-21 19:38:26 +07:00
parent 60f5876280
commit ba5d3a4043
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 23 additions and 11 deletions

View File

@ -48,10 +48,12 @@ import ru.dbotthepony.mc.otm.isClient
import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.matter.MatterManager
import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.runIfClient
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
import kotlin.math.pow import kotlin.math.pow
import kotlin.math.roundToInt import kotlin.math.roundToInt
import kotlin.math.sqrt import kotlin.math.sqrt
import kotlin.properties.Delegates
class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) { class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) {
var mass by syncher.decimal(ServerConfig.Blackhole.BASELINE_MASS, setter = setter@{ field, mass -> var mass by syncher.decimal(ServerConfig.Blackhole.BASELINE_MASS, setter = setter@{ field, mass ->
@ -174,7 +176,27 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
} }
} }
private var ambientSound: BlackHoleAmbientSoundInstance? = null
private fun stopSound() {
minecraft.soundManager.stop(ambientSound!!)
ambientSound = null
}
override fun setRemoved() {
super.setRemoved()
if (ambientSound != null) {
stopSound()
}
}
fun clientTick() { fun clientTick() {
if (ambientSound == null) {
ambientSound = BlackHoleAmbientSoundInstance(this)
minecraft.soundManager.play(ambientSound!!)
}
if (--sleepTicks > 0) return if (--sleepTicks > 0) return
val ply = Minecraft.getInstance().player ?: return val ply = Minecraft.getInstance().player ?: return
val center = Vec3.atCenterOf(blockPos) val center = Vec3.atCenterOf(blockPos)
@ -310,14 +332,6 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
} }
} }
private val ambientSound: BlackHoleAmbientSoundInstance
@OnlyIn(Dist.CLIENT)
get() = BlackHoleAmbientSoundInstance(this)
init {
if (isClient) minecraft.soundManager.play(ambientSound)
}
companion object { companion object {
const val ITERATIONS = 30_000 const val ITERATIONS = 30_000
val HAWKING_MASS_LOSE_STEP = Decimal(-100) val HAWKING_MASS_LOSE_STEP = Decimal(-100)

View File

@ -9,9 +9,7 @@ import net.neoforged.api.distmarker.OnlyIn
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents import ru.dbotthepony.mc.otm.registry.game.MSoundEvents
@OnlyIn(Dist.CLIENT) class BlackHoleAmbientSoundInstance(val tile: BlackHoleBlockEntity) : AbstractSoundInstance(MSoundEvents.BLACK_HOLE, SoundSource.AMBIENT, SoundInstance.createUnseededRandom()) {
class BlackHoleAmbientSoundInstance(val tile: BlackHoleBlockEntity)
: AbstractSoundInstance(MSoundEvents.BLACK_HOLE, SoundSource.AMBIENT, SoundInstance.createUnseededRandom()) {
private val center = Vec3.atCenterOf(tile.blockPos) private val center = Vec3.atCenterOf(tile.blockPos)
init { init {