Matter reconstructor proper GUI
This commit is contained in:
parent
9adf18cd76
commit
d21a4653e1
@ -45,8 +45,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
private var repairProgress = 0.0
|
private var repairProgress = 0.0
|
||||||
private var failureChance = 0.0
|
private var failureChance = 0.0
|
||||||
private var lastItem: Item? = null
|
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 matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY)
|
||||||
val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES)
|
val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES)
|
||||||
@ -142,11 +147,15 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
if (lastItem != item.item) {
|
if (lastItem != item.item) {
|
||||||
lastItem = item.item
|
lastItem = item.item
|
||||||
repairProgress = 0.0
|
repairProgress = 0.0
|
||||||
|
initialDamage = item.damageValue.toDouble()
|
||||||
|
visualProgress = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isEmpty || !item.isRepairable || !item.isDamaged) {
|
if (item.isEmpty || !item.isRepairable || !item.isDamaged) {
|
||||||
matterPerTick = Decimal.ZERO
|
matterPerTick = Decimal.ZERO
|
||||||
progressPerTick = 0.0
|
progressPerTick = 0.0
|
||||||
|
initialDamage = 0.0
|
||||||
|
visualProgress = 0f
|
||||||
} else {
|
} else {
|
||||||
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
|
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
|
||||||
val matter = MatterManager.get(item.item)
|
val matter = MatterManager.get(item.item)
|
||||||
@ -182,6 +191,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
} else {
|
} else {
|
||||||
matterPerTick = Decimal.ZERO
|
matterPerTick = Decimal.ZERO
|
||||||
progressPerTick = 0.0
|
progressPerTick = 0.0
|
||||||
|
initialDamage = 0.0
|
||||||
|
visualProgress = 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +202,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
super.tick()
|
super.tick()
|
||||||
|
|
||||||
if (!redstoneControl.isBlockedByRedstone) {
|
if (!redstoneControl.isBlockedByRedstone) {
|
||||||
canNotWork = false
|
isUnableToProcess = false
|
||||||
|
|
||||||
val item = repairContainer[0]
|
val item = repairContainer[0]
|
||||||
|
|
||||||
@ -205,7 +216,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble()
|
progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble()
|
||||||
|
|
||||||
if (progressPerTick <= 0.0) {
|
if (progressPerTick <= 0.0) {
|
||||||
canNotWork = true
|
isUnableToProcess = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,13 +233,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
val toDrain = matterPerTick * (progressPerTick / this.progressPerTick)
|
val toDrain = matterPerTick * (progressPerTick / this.progressPerTick)
|
||||||
val drain = matter.extractMatterInner(toDrain, true)
|
val drain = matter.extractMatterInner(toDrain, true)
|
||||||
if (!drain.isPositive) {
|
if (!drain.isPositive) {
|
||||||
canNotWork = true
|
isUnableToProcess = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
progressPerTick *= (drain / toDrain).toDouble()
|
progressPerTick *= (drain / toDrain).toDouble()
|
||||||
if (progressPerTick <= 0.0) {
|
if (progressPerTick <= 0.0) {
|
||||||
canNotWork = true
|
isUnableToProcess = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +253,11 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0)
|
item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0)
|
||||||
repairProgress %= 1.0
|
repairProgress %= 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visualProgress = 1f - ((item.damageValue - repairProgress) / initialDamage).toFloat()
|
||||||
|
} else {
|
||||||
|
initialDamage = 0.0
|
||||||
|
visualProgress = 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,18 @@ package ru.dbotthepony.mc.otm.client.screen.matter
|
|||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.entity.player.Inventory
|
import net.minecraft.world.entity.player.Inventory
|
||||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
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.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.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.BatterySlotPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
|
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.MatterGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
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
|
import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu
|
||||||
|
|
||||||
class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterReconstructorMenu>(menu, inventory, title) {
|
class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterReconstructorMenu>(menu, inventory, title) {
|
||||||
@ -20,9 +26,17 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent
|
|||||||
|
|
||||||
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
|
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)
|
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
|
return frame
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,16 @@ open class PlayerEquipmentPanel<S : MatteryScreen<*>>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var leftSided: Boolean
|
||||||
|
get() = armorSlotsStrip.dock == Dock.LEFT
|
||||||
|
set(value) {
|
||||||
|
if (value) {
|
||||||
|
armorSlotsStrip.dock = Dock.LEFT
|
||||||
|
} else {
|
||||||
|
armorSlotsStrip.dock = Dock.RIGHT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height
|
val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height
|
||||||
val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width
|
val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width
|
||||||
|
@ -680,7 +680,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
|||||||
private var curiosSlots: ImmutableList<PlayerSlot<Slot, Slot>>? = null
|
private var curiosSlots: ImmutableList<PlayerSlot<Slot, Slot>>? = null
|
||||||
private val equipmentSlots = ArrayList<Slot>()
|
private val equipmentSlots = ArrayList<Slot>()
|
||||||
|
|
||||||
fun makeArmorSlots(): List<PlayerSlot<EquipmentSlot, Slot>> {
|
fun makeArmorSlots(mapMoveToExternal: Boolean = false): List<PlayerSlot<EquipmentSlot, Slot>> {
|
||||||
if (armorSlots != null) {
|
if (armorSlots != null) {
|
||||||
return armorSlots!!
|
return armorSlots!!
|
||||||
}
|
}
|
||||||
@ -700,23 +700,45 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
|||||||
addSlot(a)
|
addSlot(a)
|
||||||
if (b != null) addSlot(b)
|
if (b != null) addSlot(b)
|
||||||
|
|
||||||
|
if (mapMoveToExternal) {
|
||||||
|
mapQuickMoveToExternal(a)
|
||||||
|
}
|
||||||
|
|
||||||
mapQuickMoveToInventory(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(
|
return EquipmentSlots(
|
||||||
armorSlots = makeArmorSlots(),
|
armorSlots = makeArmorSlots(mapMoveToExternal),
|
||||||
curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also {
|
curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also {
|
||||||
for ((a, b) in it) {
|
for ((a, b) in it) {
|
||||||
equipmentSlots.add(a)
|
equipmentSlots.add(a)
|
||||||
addSlot(a)
|
addSlot(a)
|
||||||
if (b != null) addSlot(b)
|
if (b != null) addSlot(b)
|
||||||
|
|
||||||
|
if (mapMoveToExternal) {
|
||||||
|
mapQuickMoveToExternal(a)
|
||||||
|
}
|
||||||
|
|
||||||
mapQuickMoveToInventory(a)
|
mapQuickMoveToInventory(a)
|
||||||
if (b != null) mapQuickMoveToInventory(b)
|
|
||||||
|
if (b != null) {
|
||||||
|
if (mapMoveToExternal) {
|
||||||
|
mapQuickMoveToExternal(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
mapQuickMoveToInventory(b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.also { curiosSlots = it }
|
}.also { curiosSlots = it }
|
||||||
)
|
)
|
||||||
|
@ -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.EnumInputWithFeedback
|
||||||
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
|
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
|
||||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||||
|
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||||
|
|
||||||
class MatterReconstructorMenu(
|
class MatterReconstructorMenu(
|
||||||
@ -25,6 +26,9 @@ class MatterReconstructorMenu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val equipment = makeEquipmentSlots(mapMoveToExternal = true)
|
||||||
|
val progress: ProgressGaugeWidget
|
||||||
|
|
||||||
val redstoneControl = EnumInputWithFeedback<RedstoneSetting>(this)
|
val redstoneControl = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||||
val energyConfig = EnergyPlayerInput(this)
|
val energyConfig = EnergyPlayerInput(this)
|
||||||
val itemConfig = ItemHandlerPlayerInput(this)
|
val itemConfig = ItemHandlerPlayerInput(this)
|
||||||
@ -38,5 +42,11 @@ class MatterReconstructorMenu(
|
|||||||
itemConfig.configure(tile.itemConfig)
|
itemConfig.configure(tile.itemConfig)
|
||||||
energyConfig.configure(tile.energyConfig)
|
energyConfig.configure(tile.energyConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tile == null) {
|
||||||
|
progress = ProgressGaugeWidget(this)
|
||||||
|
} else {
|
||||||
|
progress = ProgressGaugeWidget(this, tile::visualProgress, tile::isUnableToProcess)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class EnergyServoMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val equipment = makeEquipmentSlots()
|
val equipment = makeEquipmentSlots(mapMoveToExternal = true)
|
||||||
|
|
||||||
val powerGauge = LevelGaugeWidget(this, tile?.energy)
|
val powerGauge = LevelGaugeWidget(this, tile?.energy)
|
||||||
val itemConfig = ItemHandlerPlayerInput(this)
|
val itemConfig = ItemHandlerPlayerInput(this)
|
||||||
|
Loading…
Reference in New Issue
Block a user