Update matter scanner interface

This commit is contained in:
DBotThePony 2021-12-29 14:25:29 +07:00
parent 4d4caed30d
commit 328bca5982
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 50 additions and 46 deletions

View File

@ -18,11 +18,11 @@ 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

View File

@ -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
}
}