diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt index 4c95bd092..cb2989694 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt @@ -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() - private var stabilizerClientCount = 0 + private val stabilizers = LinkedList() + 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 } }