Add missing stabilizerClientCount sync

This commit is contained in:
DBotThePony 2022-09-29 20:41:51 +07:00
parent 60cd9d5bef
commit 5aeef8d6ce
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -35,6 +35,7 @@ import ru.dbotthepony.mc.otm.registry.MRegistry
import ru.dbotthepony.mc.otm.core.getSphericalBlockPositions
import ru.dbotthepony.mc.otm.core.mapIf
import ru.dbotthepony.mc.otm.core.set
import java.util.LinkedList
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt
@ -97,20 +98,22 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Synchro
sleepTicks = 4
}
private val stabilizers = ArrayList<GravitationStabilizerBlockEntity>()
private var stabilizerClientCount = 0
private val stabilizers = LinkedList<GravitationStabilizerBlockEntity>()
private var stabilizerClientCount by synchronizer.int()
fun stabilizerAttached(stabilizer: GravitationStabilizerBlockEntity) {
if (stabilizers.contains(stabilizer))
if (stabilizer in stabilizers)
return
stabilizers.add(stabilizer)
mass = mass
stabilizerClientCount = stabilizers.size
}
fun stabilizerDetached(stabilizer: GravitationStabilizerBlockEntity) {
if (stabilizers.remove(stabilizer)) {
mass = mass
stabilizerClientCount = stabilizers.size
}
}