Try to avoid synchronization when no players are listening
This commit is contained in:
parent
f6cf694967
commit
d1d35f0730
@ -25,13 +25,19 @@ import java.util.WeakHashMap
|
||||
|
||||
abstract class SynchronizedBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_) {
|
||||
val synchronizer = FieldSynchronizer {
|
||||
if (!isRemoved && level?.isClientSide == false) {
|
||||
if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) {
|
||||
onceServer {
|
||||
synchronizeToPlayers(true)
|
||||
}
|
||||
} else {
|
||||
markSynchronizerClean()
|
||||
}
|
||||
}
|
||||
|
||||
private fun markSynchronizerClean() {
|
||||
synchronizer.markClean()
|
||||
}
|
||||
|
||||
init {
|
||||
synchronizer.defaultEndpoint.markUnused()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user