diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index fb10ad8ab..428219a52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -337,11 +337,13 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat val resolve = ent.getEnergySided(-side) if (resolve !== old) { - val weak = WeakReference(this) + if (resolve.isPresent) { + val weak = WeakReference(this) - resolve.addListener { - if (SERVER_IS_LIVE) - weak.get()?.checkSurroundings() + resolve.addListener { + if (SERVER_IS_LIVE) + weak.get()?.checkSurroundings() + } } return resolve