diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index bd69bd6a2..9f2ff0552 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -45,8 +45,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private var repairProgress = 0.0 private var failureChance = 0.0 private var lastItem: Item? = null + private var initialDamage = 0.0 - var canNotWork = false + var visualProgress = 0f + private set + + var isUnableToProcess = false + private set val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) @@ -142,11 +147,15 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) if (lastItem != item.item) { lastItem = item.item repairProgress = 0.0 + initialDamage = item.damageValue.toDouble() + visualProgress = 0f } if (item.isEmpty || !item.isRepairable || !item.isDamaged) { matterPerTick = Decimal.ZERO progressPerTick = 0.0 + initialDamage = 0.0 + visualProgress = 0f } else { if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { val matter = MatterManager.get(item.item) @@ -182,6 +191,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) } else { matterPerTick = Decimal.ZERO progressPerTick = 0.0 + initialDamage = 0.0 + visualProgress = 0f } } } @@ -191,7 +202,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) super.tick() if (!redstoneControl.isBlockedByRedstone) { - canNotWork = false + isUnableToProcess = false val item = repairContainer[0] @@ -205,7 +216,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble() if (progressPerTick <= 0.0) { - canNotWork = true + isUnableToProcess = true return } } @@ -222,13 +233,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val toDrain = matterPerTick * (progressPerTick / this.progressPerTick) val drain = matter.extractMatterInner(toDrain, true) if (!drain.isPositive) { - canNotWork = true + isUnableToProcess = true return } progressPerTick *= (drain / toDrain).toDouble() if (progressPerTick <= 0.0) { - canNotWork = true + isUnableToProcess = true return } @@ -242,6 +253,11 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0) repairProgress %= 1.0 } + + visualProgress = 1f - ((item.damageValue - repairProgress) / initialDamage).toFloat() + } else { + initialDamage = 0.0 + visualProgress = 0f } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 06a2bc1bb..3ca95e957 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -3,12 +3,18 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EntityRendererPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -20,9 +26,17 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - SlotPanel(this, frame, menu.slot, 80f, PROGRESS_SLOT_TOP) + SlotPanel(this, frame, menu.slot, 66f, PROGRESS_SLOT_TOP) + ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) makeDeviceControls(this, frame, redstone = menu.redstoneControl, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots) + + PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { + it.leftSided = false + it.dock = Dock.RIGHT + it.dockResize = DockResizeMode.NONE + } return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt index 08bb2fbc0..2560ad982 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt @@ -74,6 +74,16 @@ open class PlayerEquipmentPanel>( } } + var leftSided: Boolean + get() = armorSlotsStrip.dock == Dock.LEFT + set(value) { + if (value) { + armorSlotsStrip.dock = Dock.LEFT + } else { + armorSlotsStrip.dock = Dock.RIGHT + } + } + companion object { val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index fa3232943..4032c8289 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -680,7 +680,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private var curiosSlots: ImmutableList>? = null private val equipmentSlots = ArrayList() - fun makeArmorSlots(): List> { + fun makeArmorSlots(mapMoveToExternal: Boolean = false): List> { if (armorSlots != null) { return armorSlots!! } @@ -700,23 +700,45 @@ abstract class MatteryMenu @JvmOverloads protected constructor( addSlot(a) if (b != null) addSlot(b) + if (mapMoveToExternal) { + mapQuickMoveToExternal(a) + } + mapQuickMoveToInventory(a) - if (b != null) mapQuickMoveToInventory(b) + + if (b != null) { + if (mapMoveToExternal) { + mapQuickMoveToExternal(b) + } + + mapQuickMoveToInventory(b) + } } } } - fun makeEquipmentSlots(): EquipmentSlots { + fun makeEquipmentSlots(mapMoveToExternal: Boolean = false): EquipmentSlots { return EquipmentSlots( - armorSlots = makeArmorSlots(), + armorSlots = makeArmorSlots(mapMoveToExternal), curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also { for ((a, b) in it) { equipmentSlots.add(a) addSlot(a) if (b != null) addSlot(b) + if (mapMoveToExternal) { + mapQuickMoveToExternal(a) + } + mapQuickMoveToInventory(a) - if (b != null) mapQuickMoveToInventory(b) + + if (b != null) { + if (mapMoveToExternal) { + mapQuickMoveToExternal(b) + } + + mapQuickMoveToInventory(b) + } } }.also { curiosSlots = it } ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index a742e28e9..9a296b8cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterReconstructorMenu( @@ -25,6 +26,9 @@ class MatterReconstructorMenu( } } + val equipment = makeEquipmentSlots(mapMoveToExternal = true) + val progress: ProgressGaugeWidget + val redstoneControl = EnumInputWithFeedback(this) val energyConfig = EnergyPlayerInput(this) val itemConfig = ItemHandlerPlayerInput(this) @@ -38,5 +42,11 @@ class MatterReconstructorMenu( itemConfig.configure(tile.itemConfig) energyConfig.configure(tile.energyConfig) } + + if (tile == null) { + progress = ProgressGaugeWidget(this) + } else { + progress = ProgressGaugeWidget(this, tile::visualProgress, tile::isUnableToProcess) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 312d8c029..a21b60f6a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -31,7 +31,7 @@ class EnergyServoMenu @JvmOverloads constructor( } } - val equipment = makeEquipmentSlots() + val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = LevelGaugeWidget(this, tile?.energy) val itemConfig = ItemHandlerPlayerInput(this)