From b2e50a6c1b878f14d70840f8bafd0e0e82cc0b33 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Jul 2023 21:40:15 +0700 Subject: [PATCH] Fix mekanism energy getting above potential IMatteryEnergyStorage --- .../ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 f3fb2360e..b7a3bcc7b 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 @@ -49,6 +49,7 @@ import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide @@ -273,7 +274,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } override fun get(): LazyOptional { - return actualMekanism ?: regular.get() + val get = regular.get() + get.ifPresentK { if (it is IMatteryEnergyStorage) return get } + return actualMekanism ?: get } } }