From 61d799fb2916b03a72bf617aeaacabf6d071f54f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 13:13:16 +0700 Subject: [PATCH] Don't check for null multiple times --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 1714205fe..3bbc3582d 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 @@ -287,8 +287,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc ?.chunkSource ?.getChunkNow(SectionPos.blockToSectionCoord(targetPos.x), SectionPos.blockToSectionCoord(targetPos.z)) + val subref = subscriptions[capability] as SubRef + if (chunk == null) { - subscriptions[capability]!!.unset() + subref.unset() level?.once { updateTracked(capability) } return } @@ -296,19 +298,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val entity = chunk.getBlockEntity(targetPos) if (entity == null) { - subscriptions[capability]!!.unset() + subref.unset() return } val new = entity.getCapability(capability, dir.opposite) if (!new.isPresent) { - subscriptions[capability]!!.unset() + subref.unset() return } - val subref = subscriptions[capability] as SubRef - if (subref.value !== new) { if (knownLOs.add(new)) { val ref = WeakReference(this)