From fda82f335702939953f9fe3976d9b7d7990ff0db Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 19:35:36 +0700 Subject: [PATCH] Fix creative matter capacitor not exposing Long.MAX_VALUE stored matter --- .../dbotthepony/mc/otm/item/MatterCapacitorItem.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index b58b41715..465ee309a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.tagNotNull import javax.annotation.ParametersAreNonnullByDefault @@ -36,22 +37,18 @@ class MatterCapacitorItem : Item { override var storedMatter: Decimal get() { - val tag = stack.orCreateTag - return if (tag.contains("matter")) { - Decimal.deserializeNBT(tag["matter"]) - } else Decimal.ZERO + if (isCreative) return Decimal.LONG_MAX_VALUE + return stack.tag?.map("matter", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO } set(value) { stack.tagNotNull.put("matter", value.serializeNBT()) } - override val maxStoredMatter: Decimal - get() { + override val maxStoredMatter: Decimal get() { return capacity } - override val missingMatter: Decimal - get() { + override val missingMatter: Decimal get() { return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingMatter }