From 328bca5982017d05a72a9afee21b9a03361cca92 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 29 Dec 2021 14:25:29 +0700 Subject: [PATCH] Update matter scanner interface --- .../otm/client/screen/MatterScannerScreen.kt | 6 +- .../mc/otm/menu/MatterScannerMenu.kt | 90 ++++++++++--------- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt index 5c848722f..785cc6f9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt @@ -18,13 +18,13 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97 val m = PowerGaugePanel(this, frame, menu.battery_widget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - // PatternGaugePanel(this, frame, menu.patterns, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) + PatternGaugePanel(this, frame, menu.patterns, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.battery_slot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP) + ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) return frame } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt index 9fe0acbea..bf4695019 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt @@ -1,55 +1,59 @@ -package ru.dbotthepony.mc.otm.menu; +package ru.dbotthepony.mc.otm.menu -import net.minecraft.world.Container; -import net.minecraft.world.SimpleContainer; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.item.ItemStack; -import ru.dbotthepony.mc.otm.matter.MatterRegistry; -import ru.dbotthepony.mc.otm.Registry; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterScanner; -import ru.dbotthepony.mc.otm.menu.slot.MatterySlot; -import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget; +import kotlin.jvm.JvmOverloads +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterScanner +import ru.dbotthepony.mc.otm.menu.PoweredMatteryMenu +import ru.dbotthepony.mc.otm.menu.slot.MatterySlot +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import net.minecraft.world.SimpleContainer +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.Registry +import ru.dbotthepony.mc.otm.core.Fraction +import ru.dbotthepony.mc.otm.matter.MatterRegistry +import java.math.BigInteger -public class MatterScannerMenu extends PoweredMatteryMenu { - public MatterScannerMenu(int p_38852_, Inventory inventory) { - this(p_38852_, inventory, null); - } +class MatterScannerMenu @JvmOverloads constructor( + p_38852_: Int, + inventory: Inventory, + tile: BlockEntityMatterScanner? = null +) : PoweredMatteryMenu( + Registry.Menus.MATTER_SCANNER, p_38852_, inventory, tile +) { + val input: MatterySlot + val progress: ProgressGaugeWidget + val patterns: LevelGaugeWidget - public MatterySlot input; - public ProgressGaugeWidget progress; - - public MatterScannerMenu(int p_38852_, Inventory inventory, BlockEntityMatterScanner tile) { - super(Registry.Menus.MATTER_SCANNER, p_38852_, inventory, tile); - - Container container = tile != null ? tile.input_slot : new SimpleContainer(1); - - input = new MatterySlot(container, 0, 64, 38) { - @Override - public boolean mayPlace(ItemStack p_40231_) { - return MatterRegistry.canDecompose(p_40231_); + init { + val container = if (tile != null) tile.input_slot else SimpleContainer(1) + input = object : MatterySlot(container, 0, 64, 38) { + override fun mayPlace(p_40231_: ItemStack): Boolean { + return MatterRegistry.canDecompose(p_40231_) } - }; - - addSlot(input); - - if (tile != null) { - progress = new ProgressGaugeWidget(this, () -> (float) tile.getWorkProgress(), tile::cantProcessJob); - } else { - progress = new ProgressGaugeWidget(this); } - addBatterySlot(); + addSlot(input) - addInventorySlots(); + if (tile != null) { + progress = ProgressGaugeWidget(this, { tile.workProgress.toFloat() }) { tile.cantProcessJob() } + patterns = LevelGaugeWidget(this, + { Fraction(tile.matterGrid?.storedPatternCount?.toBigInteger() ?: BigInteger.ZERO) }, + { Fraction(tile.matterGrid?.patternCapacity?.toBigInteger() ?: BigInteger.ZERO) }) + } else { + progress = ProgressGaugeWidget(this) + patterns = LevelGaugeWidget(this) + } + + addBatterySlot() + addInventorySlots() } - @Override - protected int getWorkingSlotStart() { - return 0; + override fun getWorkingSlotStart(): Int { + return 0 } - @Override - protected int getWorkingSlotEnd() { - return 1; + override fun getWorkingSlotEnd(): Int { + return 1 } -} +} \ No newline at end of file