Failsafe when blackhole block entity gets removed

This commit is contained in:
DBotThePony 2025-02-07 21:11:07 +07:00
parent 7d075ccfc3
commit b10b1c0da4
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -162,7 +162,7 @@ class BlackHoleGeneratorBlockEntity(blockPos: BlockPos, blockState: BlockState)
if (!multiblock.update(level, blockRotation.front)) {
this.lastRange = findBlackHoleRange()
} else {
val blackHole = multiblock.blockEntities(BLACK_HOLE).first()
val blackHole = multiblock.blockEntities(BLACK_HOLE).firstOrNull() ?: return
val matterExtracted = matter.extractMatter(if (mode == Mode.TARGET_MASS && blackHole.mass != targetMass) minOf(injectionRate, (blackHole.mass - targetMass).absoluteValue) else injectionRate, true)
if (!matterExtracted.isPositive) return