From 5e1ae7e77d60c553bcccac03ab0603b40b45e23f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 10 Mar 2025 15:30:50 +0700 Subject: [PATCH] Handle negative experience stored in essence capsules --- .../mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 22db89523..5f21b8da5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -40,6 +40,7 @@ import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities import ru.dbotthepony.mc.otm.registry.game.MDataComponentTypes import ru.dbotthepony.mc.otm.registry.game.MFluids +import kotlin.math.max class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ESSENCE_STORAGE, blockPos, blockState), IFluidHandler { var experienceStored = 0L @@ -169,7 +170,7 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma val capsule = capsuleContainer[0] if (!capsule.isEmpty && capsule.has(MDataComponentTypes.EXPERIENCE)) { - experienceStored += capsule.get(MDataComponentTypes.EXPERIENCE)!! * capsule.count + experienceStored += max(capsule.get(MDataComponentTypes.EXPERIENCE)!! * capsule.count, 0L) capsuleContainer.clearContent() }