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 }