Don't check for null multiple times
This commit is contained in:
parent
9bebe74282
commit
61d799fb29
@ -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<Any?>
|
||||
|
||||
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<Any?>
|
||||
|
||||
if (subref.value !== new) {
|
||||
if (knownLOs.add(new)) {
|
||||
val ref = WeakReference(this)
|
||||
|
Loading…
Reference in New Issue
Block a user