diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index c482650e4..c404ee458 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -342,7 +342,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc optional.invalidate() if (SERVER_IS_LIVE) - level?.once { setChanged() } + level?.once { if (!this@MatteryBlockEntity.isRemoved) setChanged() } } } @@ -354,7 +354,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc optional = LazyOptional.of { capability } if (SERVER_IS_LIVE) - level?.once { setChanged() } + level?.once { if (!this@MatteryBlockEntity.isRemoved) setChanged() } } } } @@ -365,7 +365,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc optional.invalidate() if (SERVER_IS_LIVE) - level?.once { setChanged() } + level?.once { if (!this@MatteryBlockEntity.isRemoved) setChanged() } } } @@ -377,7 +377,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc optional = LazyOptional.of { capability } if (SERVER_IS_LIVE) - level?.once { setChanged() } + level?.once { if (!this@MatteryBlockEntity.isRemoved) setChanged() } } } } @@ -491,8 +491,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (isRemoved) markSynchronizerClean() if (level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { - ru.dbotthepony.mc.otm.onceServer { - synchronizeToPlayers(true) + onceServer { + if (!isRemoved) { + synchronizeToPlayers(true) + } } } else { markSynchronizerClean() @@ -527,8 +529,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } else { level.once { - for (side in _sides.values) { - side.updateTracked() + if (!isRemoved) { + for (side in _sides.values) { + side.updateTracked() + } } } } @@ -671,7 +675,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (!blockEntities.add(blockEntity)) return onceServer { - blockEntity.synchronizeToPlayers(false) + if (!blockEntity.isRemoved && blockEntity in blockEntities) { + blockEntity.synchronizeToPlayers(false) + } } if (blockEntity.synchronizer.hasObservers && blockEntity.tickList.ticks == 0) {