Add item, energy and redstone configs to rest of machines
This commit is contained in:
parent
2da70e777f
commit
ed04506507
@ -221,25 +221,35 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo
|
||||
}
|
||||
|
||||
inner class ConfigurableItemHandler(
|
||||
val input: IItemHandler? = null,
|
||||
val output: IItemHandler? = null,
|
||||
input: IItemHandler? = null,
|
||||
output: IItemHandler? = null,
|
||||
inputOutput: IItemHandler? = null,
|
||||
val battery: IItemHandler? = null,
|
||||
val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT),
|
||||
val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK),
|
||||
val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.LEFT),
|
||||
val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.RIGHT),
|
||||
val topDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.TOP),
|
||||
val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BOTTOM),
|
||||
val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.FRONT),
|
||||
val backDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BACK),
|
||||
val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.LEFT),
|
||||
val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.RIGHT),
|
||||
val topDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.TOP),
|
||||
val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BOTTOM),
|
||||
) {
|
||||
val sideless: IItemHandler
|
||||
val possibleViews: ImmutableSet<ItemHandlerMode>
|
||||
val inputOutput: IItemHandler?
|
||||
val input: IItemHandler?
|
||||
val output: IItemHandler?
|
||||
|
||||
init {
|
||||
if ((input != null || output != null) && inputOutput != null)
|
||||
throw IllegalArgumentException("Either specify input or/and output separately, or specify inputOutput")
|
||||
|
||||
if (inputOutput != null) {
|
||||
this.input = inputOutput
|
||||
this.output = inputOutput
|
||||
} else {
|
||||
this.input = input
|
||||
this.output = output
|
||||
}
|
||||
|
||||
val builder = ImmutableSet.Builder<ItemHandlerMode>()
|
||||
|
||||
builder.add(ItemHandlerMode.DISABLED)
|
||||
@ -430,14 +440,14 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode {
|
||||
private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, inputOutput: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode {
|
||||
if (side == RelativeSide.BACK && battery != null) {
|
||||
return ItemHandlerMode.BATTERY
|
||||
}
|
||||
|
||||
if (input == null && output == null) {
|
||||
if (input == null && output == null && inputOutput == null) {
|
||||
return ItemHandlerMode.DISABLED
|
||||
} else if (input != null && output != null) {
|
||||
} else if (input != null && output != null || inputOutput != null) {
|
||||
return when (side) {
|
||||
RelativeSide.FRONT, RelativeSide.BACK -> ItemHandlerMode.DISABLED
|
||||
RelativeSide.RIGHT, RelativeSide.TOP -> ItemHandlerMode.INPUT
|
||||
|
@ -118,10 +118,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
}
|
||||
|
||||
val energy = WorkerEnergyStorage(this, ENERGY_VALUES)
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
|
||||
init {
|
||||
exposeEnergyGlobally(energy)
|
||||
savetable(::energy, ENERGY_KEY)
|
||||
savetables.stateful(::energy, ENERGY_KEY)
|
||||
}
|
||||
|
||||
val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY)
|
||||
@ -130,25 +130,30 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
init {
|
||||
exposeGlobally(MatteryCapability.MATTER, matter)
|
||||
exposeGlobally(MatteryCapability.MATTER_NODE, matterNode)
|
||||
savetable(::matter, MATTER_STORAGE_KEY)
|
||||
savetables.stateful(::matter, MATTER_STORAGE_KEY)
|
||||
}
|
||||
|
||||
// вход, выход
|
||||
val container = MatteryContainer(this::setChangedLight, 3).also(::addDroppableContainer)
|
||||
val inputContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer)
|
||||
val outputContainer = MatteryContainer(::setChangedLight, 2).also(::addDroppableContainer)
|
||||
|
||||
val itemHandler = container.handler(object : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return slot == INPUT_SLOT && MatterManager.canDecompose(stack)
|
||||
}
|
||||
val itemConfig = ConfigurableItemHandler(
|
||||
input = inputContainer.handler(object : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return MatterManager.canDecompose(stack)
|
||||
}
|
||||
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return slot != INPUT_SLOT
|
||||
}
|
||||
})
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return false
|
||||
}
|
||||
}),
|
||||
|
||||
output = outputContainer.handler(HandlerFilter.OnlyOut)
|
||||
)
|
||||
|
||||
init {
|
||||
exposeItemsGlobally(itemHandler)
|
||||
savetable(::container, INVENTORY_KEY)
|
||||
savetables.stateful(::inputContainer)
|
||||
savetables.stateful(::outputContainer)
|
||||
}
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
@ -157,7 +162,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
|
||||
override fun onJobFinish(job: DecomposerJob): Status {
|
||||
if (job.toDust) {
|
||||
job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING)
|
||||
job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1)
|
||||
|
||||
if (!job.matterValue.isZero) {
|
||||
return Status.FAILURE_WAIT_FAST
|
||||
@ -176,7 +181,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
}
|
||||
|
||||
override fun computeNextJob(): Pair<DecomposerJob?, IdleReason?> {
|
||||
val stack = container[INPUT_SLOT]
|
||||
val stack = inputContainer[0]
|
||||
|
||||
if (!stack.isEmpty) {
|
||||
val copy = stack.copy()
|
||||
@ -218,10 +223,6 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val INPUT_SLOT = 0
|
||||
const val OUTPUT_DUST_MAIN = 1
|
||||
const val OUTPUT_DUST_STACKING = 2
|
||||
|
||||
val CAPACITY get() = _CAPACITY.get()
|
||||
val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get()
|
||||
|
||||
|
@ -64,18 +64,13 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
||||
}
|
||||
}
|
||||
|
||||
val matter = MatterStorageImpl(
|
||||
this::matterLevelUpdated,
|
||||
FlowDirection.OUTPUT,
|
||||
::CAPACITY
|
||||
)
|
||||
|
||||
val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer)
|
||||
val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY)
|
||||
val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer)
|
||||
|
||||
val matterNode = SimpleMatterNode(matter = matter)
|
||||
val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG)
|
||||
val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG)
|
||||
|
||||
private val itemHandler = container.handler(object : HandlerFilter {
|
||||
val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return stack.item is MatterDustItem
|
||||
}
|
||||
@ -83,16 +78,17 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
|
||||
init {
|
||||
exposeItemsGlobally(itemHandler)
|
||||
exposeEnergyGlobally(energy)
|
||||
exposeGlobally(MatteryCapability.MATTER, matter)
|
||||
exposeGlobally(MatteryCapability.MATTER_NODE, matterNode)
|
||||
savetable(::energy, ENERGY_KEY)
|
||||
savetable(::container, INVENTORY_KEY)
|
||||
savetable(::matter, MATTER_STORAGE_KEY)
|
||||
|
||||
savetables.stateful(::energy, ENERGY_KEY)
|
||||
savetables.stateful(::container, INVENTORY_KEY)
|
||||
savetables.stateful(::matter, MATTER_STORAGE_KEY)
|
||||
}
|
||||
|
||||
override fun setRemoved() {
|
||||
|
@ -99,10 +99,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
}
|
||||
|
||||
val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES)
|
||||
val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY)
|
||||
val container = MatteryContainer(this::itemContainerUpdated, 5).also(::addDroppableContainer)
|
||||
val itemHandler = container.handler(HandlerFilter.OnlyOut)
|
||||
val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)
|
||||
val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY)
|
||||
val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer)
|
||||
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut))
|
||||
|
||||
val matterNode = object : MatterNode() {
|
||||
override fun getMatterHandler(): IMatterStorage {
|
||||
@ -129,14 +131,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
init {
|
||||
exposeEnergyGlobally(energy)
|
||||
exposeItemsGlobally(itemHandler)
|
||||
exposeGlobally(MatteryCapability.MATTER, matter)
|
||||
exposeGlobally(MatteryCapability.MATTER_NODE, matterNode)
|
||||
|
||||
savetable(::energy, ENERGY_KEY)
|
||||
savetable(::matter, MATTER_STORAGE_KEY)
|
||||
savetable(::container, INVENTORY_KEY)
|
||||
savetables.stateful(::energy, ENERGY_KEY)
|
||||
savetables.stateful(::matter, MATTER_STORAGE_KEY)
|
||||
savetables.stateful(::container, INVENTORY_KEY)
|
||||
}
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
|
@ -35,9 +35,10 @@ import kotlin.math.pow
|
||||
class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
MatteryWorkerBlockEntity<MatteryWorkerBlockEntity.ItemJob>(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) {
|
||||
|
||||
val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer)
|
||||
val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES)
|
||||
val itemHandler = container.handler(object : HandlerFilter {
|
||||
val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer)
|
||||
val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)
|
||||
|
||||
val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return MatterManager.canDecompose(stack)
|
||||
}
|
||||
@ -45,7 +46,9 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return isIdling
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
|
||||
val matterNode = object : MatterNode() {
|
||||
override fun onPatternAdded(state: IPatternState) {
|
||||
@ -68,12 +71,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
init {
|
||||
exposeItemsGlobally(itemHandler)
|
||||
exposeEnergyGlobally(energy)
|
||||
exposeGlobally(MatteryCapability.MATTER_NODE, matterNode)
|
||||
|
||||
savetable(::container, INVENTORY_KEY)
|
||||
savetable(::energy, ENERGY_KEY)
|
||||
savetables.stateful(::container, INVENTORY_KEY)
|
||||
savetables.stateful(::energy, ENERGY_KEY)
|
||||
}
|
||||
|
||||
override fun invalidateCaps() {
|
||||
|
@ -76,7 +76,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
}
|
||||
|
||||
private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent }
|
||||
val itemConfig = ConfigurableItemHandler(inputOutput = container.handler { _: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent })
|
||||
|
||||
override fun setLevel(level: Level) {
|
||||
super.setLevel(level)
|
||||
@ -91,9 +91,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
init {
|
||||
exposeGlobally(MatteryCapability.PATTERN, this)
|
||||
exposeGlobally(MatteryCapability.MATTER_NODE, matterNode)
|
||||
exposeItemsGlobally(itemHandler)
|
||||
|
||||
savetable(::container, INVENTORY_KEY)
|
||||
savetables.stateful(::container, INVENTORY_KEY)
|
||||
}
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
|
@ -32,9 +32,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
return AndroidStationMenu(containerID, inventory, this)
|
||||
}
|
||||
|
||||
val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight,
|
||||
AndroidStationBlockEntity.Companion::CAPACITY,
|
||||
AndroidStationBlockEntity.Companion::MAX_IO, { null }) {
|
||||
val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) {
|
||||
override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
|
||||
return super.extractEnergy(howMuch, simulate).also {
|
||||
if (!simulate && this.batteryLevel.isZero) {
|
||||
@ -59,9 +57,10 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
}
|
||||
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
|
||||
init {
|
||||
exposeEnergyGlobally(energy)
|
||||
savetable(::energy, ENERGY_KEY)
|
||||
savetables.stateful(::energy, ENERGY_KEY)
|
||||
}
|
||||
|
||||
private var tickedOnce = false
|
||||
|
@ -46,11 +46,13 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
val capsule = capsuleContainer[0]
|
||||
if (!redstoneControl.isBlockedByRedstone) {
|
||||
val capsule = capsuleContainer[0]
|
||||
|
||||
if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) {
|
||||
experienceStored += EssenceCapsuleItem.experienceStored(capsule)
|
||||
capsuleContainer.clearContent()
|
||||
if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) {
|
||||
experienceStored += EssenceCapsuleItem.experienceStored(capsule)
|
||||
capsuleContainer.clearContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component)
|
||||
lock.dockMargin = DockProperty(2f, 2f, 2f, 2f)
|
||||
lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip")
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title:
|
||||
ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue)
|
||||
}
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory
|
||||
SlotPanel(this, frame, menu.outputMain, 74f, PROGRESS_SLOT_TOP)
|
||||
SlotPanel(this, frame, menu.outputStacking, 56f, PROGRESS_SLOT_TOP)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ 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
|
||||
@ -29,7 +28,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent
|
||||
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, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
makeCuriosPanel(this, frame, menu.equipment.curiosSlots)
|
||||
|
||||
PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also {
|
||||
|
@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu
|
||||
|
||||
class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterRecyclerMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
@ -24,7 +24,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title
|
||||
ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true
|
||||
SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu
|
||||
|
||||
class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<MatterReplicatorMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
@ -30,7 +30,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory
|
||||
SlotPanel(this, frame, menu.storageSlots[3], 80f, PROGRESS_SLOT_TOP + 22f)
|
||||
SlotPanel(this, frame, menu.storageSlots[4], 80f + 18f, PROGRESS_SLOT_TOP + 22f)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97
|
||||
ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true
|
||||
SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.PatternSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel
|
||||
|
||||
class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<PatternStorageMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PatternGaugePanel(this, frame, menu.storedThis, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT)
|
||||
@ -22,6 +23,8 @@ class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_
|
||||
for (i in 4 until 8)
|
||||
PatternSlotPanel(this, frame, menu.storageSlots[i], 62f + (i - 4) * 18, 32f + 18f)
|
||||
|
||||
makeDeviceControls(this, frame, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
}
|
||||
|
@ -275,9 +275,9 @@ fun <S : MatteryScreen<*>> makeDeviceControls(
|
||||
screen: S,
|
||||
parent: FramePanel<S>,
|
||||
extra: Iterable<EditablePanel<S>> = listOf(),
|
||||
redstone: IPlayerInputWithFeedback<RedstoneSetting>? = null,
|
||||
redstoneConfig: IPlayerInputWithFeedback<RedstoneSetting>? = null,
|
||||
itemConfig: ItemHandlerPlayerInput? = null,
|
||||
energyConfig: EnergyPlayerInput? = null,
|
||||
): DeviceControls<S> {
|
||||
return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstone, itemConfig = itemConfig, energyConfig = energyConfig)
|
||||
return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon
|
||||
|
||||
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit
|
||||
|
||||
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit
|
||||
|
||||
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
|
||||
}
|
||||
}
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
|
||||
this.playerStrip = playerStrip
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co
|
||||
for (i in 6 .. 11)
|
||||
BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory,
|
||||
SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP)
|
||||
SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) :
|
||||
for (column in 0 .. 2)
|
||||
SlotPanel(this, frame, menu.storageSlots[row * 3 + column], 80f + column * AbstractSlotPanel.SIZE, 26f + row * AbstractSlotPanel.SIZE)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
|
||||
|
||||
limitsTab.onClose!!.run()
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp
|
||||
it.dockRight
|
||||
}
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.Label
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.HorizontalStripPanel
|
||||
@ -246,6 +247,8 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon
|
||||
ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP)
|
||||
SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP)
|
||||
|
||||
makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.*
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.InventoryMenu
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse
|
||||
@ -36,8 +39,6 @@ import ru.dbotthepony.mc.otm.core.util.IStreamCodec
|
||||
import ru.dbotthepony.mc.otm.core.util.ItemValueCodec
|
||||
import ru.dbotthepony.mc.otm.core.util.NullValueCodec
|
||||
import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec
|
||||
import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer
|
||||
import ru.dbotthepony.mc.otm.network.synchronizer.IField
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPacket
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
import ru.dbotthepony.mc.otm.network.MenuFieldPacket
|
||||
@ -46,13 +47,14 @@ import ru.dbotthepony.mc.otm.network.SetInventoryFilterPacket
|
||||
import ru.dbotthepony.mc.otm.network.enqueueWork
|
||||
import ru.dbotthepony.mc.otm.network.packetHandled
|
||||
import ru.dbotthepony.mc.otm.network.sender
|
||||
import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer
|
||||
import ru.dbotthepony.mc.otm.network.synchronizer.IField
|
||||
import java.io.DataInputStream
|
||||
import java.io.DataOutputStream
|
||||
import java.math.BigDecimal
|
||||
import java.util.*
|
||||
import java.util.function.Predicate
|
||||
import java.util.function.Supplier
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
data class PlayerSlot<A : Slot, B : Slot>(val functional: A, val cosmetic: B? = null)
|
||||
|
||||
|
@ -6,7 +6,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
|
||||
import ru.dbotthepony.mc.otm.capability.matter.matter
|
||||
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
|
||||
|
||||
@ -18,11 +17,11 @@ abstract class MatteryPoweredMenu protected constructor(
|
||||
) : MatteryMenu(menuType, containerID, inventory, tile) {
|
||||
val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy)
|
||||
val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0)
|
||||
val redstone = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
redstone.with(tile.redstoneControl::redstoneSetting)
|
||||
redstoneConfig.with(tile.redstoneControl::redstoneSetting)
|
||||
}
|
||||
|
||||
addSlot(batterySlot)
|
||||
|
@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
/**
|
||||
* [allowPull] and [allowPush] controls whenever player is allowed to change these options
|
||||
*/
|
||||
class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) {
|
||||
class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) {
|
||||
var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java)
|
||||
private set
|
||||
|
||||
@ -59,4 +59,10 @@ class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, v
|
||||
pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } }
|
||||
push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } }
|
||||
}
|
||||
|
||||
init {
|
||||
if (config != null) {
|
||||
configure(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
/**
|
||||
* [allowPull] and [allowPush] controls whenever player is allowed to change these options
|
||||
*/
|
||||
class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) {
|
||||
class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) {
|
||||
private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it }
|
||||
fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean
|
||||
|
||||
@ -48,7 +48,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal
|
||||
|
||||
fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) {
|
||||
for ((f, v) in allowedFlags) {
|
||||
f.value = v in config.possibleViews
|
||||
f.boolean = v in config.possibleViews
|
||||
}
|
||||
|
||||
for ((side, v) in config.pieces) {
|
||||
@ -62,4 +62,10 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal
|
||||
pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } }
|
||||
push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } }
|
||||
}
|
||||
|
||||
init {
|
||||
if (config != null) {
|
||||
configure(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,16 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.core.orNull
|
||||
import ru.dbotthepony.mc.otm.matter.MatterManager
|
||||
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
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.registry.MMenus
|
||||
|
||||
class MatterDecomposerMenu @JvmOverloads constructor(
|
||||
@ -22,27 +26,23 @@ class MatterDecomposerMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
tile: MatterDecomposerBlockEntity? = null
|
||||
) : MatteryPoweredMenu(MMenus.MATTER_DECOMPOSER, containerID, inventory, tile) {
|
||||
val input: MatterySlot
|
||||
val input = object : MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) {
|
||||
override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack)
|
||||
}
|
||||
|
||||
val outputMain: MachineOutputSlot
|
||||
val outputStacking: MachineOutputSlot
|
||||
val progressWidget = ProgressGaugeWidget(this)
|
||||
val progressWidget = ProgressGaugeWidget(this, tile)
|
||||
val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull())
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(3)
|
||||
|
||||
// Вход
|
||||
input = object : MatterySlot(container, 0) {
|
||||
override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack)
|
||||
}
|
||||
val container = tile?.outputContainer ?: SimpleContainer(2)
|
||||
|
||||
// Выход
|
||||
outputMain = MachineOutputSlot(container, 1)
|
||||
outputStacking = MachineOutputSlot(container, 2)
|
||||
|
||||
if (tile != null) {
|
||||
progressWidget.with(tile::workProgress, tile::isUnableToProcess)
|
||||
}
|
||||
outputMain = MachineOutputSlot(container, 0)
|
||||
outputStacking = MachineOutputSlot(container, 1)
|
||||
|
||||
addStorageSlot(outputMain)
|
||||
addStorageSlot(outputStacking)
|
||||
|
@ -29,20 +29,13 @@ class MatterReconstructorMenu(
|
||||
val equipment = makeEquipmentSlots(mapMoveToExternal = true)
|
||||
val progress = ProgressGaugeWidget(this)
|
||||
|
||||
val redstoneControl = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
val energyConfig = EnergyPlayerInput(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
|
||||
init {
|
||||
addStorageSlot(slot)
|
||||
addInventorySlots()
|
||||
|
||||
if (tile != null) {
|
||||
redstoneControl.with(tile.redstoneControl::redstoneSetting)
|
||||
itemConfig.configure(tile.itemConfig)
|
||||
energyConfig.configure(tile.energyConfig)
|
||||
}
|
||||
|
||||
if (tile != null) {
|
||||
progress.with(tile::visualProgress, tile::isUnableToProcess)
|
||||
}
|
||||
|
@ -3,10 +3,14 @@ package ru.dbotthepony.mc.otm.menu.matter
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.item.MatterDustItem
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
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
|
||||
@ -22,14 +26,12 @@ class MatterRecyclerMenu @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val progress = ProgressGaugeWidget(this)
|
||||
val progress = ProgressGaugeWidget(this, tile)
|
||||
val matter = LevelGaugeWidget(this, tile?.matter)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
progress.with(tile::workProgress, tile::isUnableToProcess)
|
||||
}
|
||||
|
||||
addStorageSlot(input)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
@ -6,21 +6,25 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
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.registry.MMenus
|
||||
|
||||
class MatterReplicatorMenu @JvmOverloads constructor(
|
||||
p_38852_: Int,
|
||||
inventory: Inventory,
|
||||
tile: MatterReplicatorBlockEntity? = null
|
||||
) : MatteryPoweredMenu(
|
||||
MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile
|
||||
) {
|
||||
) : MatteryPoweredMenu(MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile) {
|
||||
val matter = LevelGaugeWidget(this, tile?.matter)
|
||||
val progress = ProgressGaugeWidget(this)
|
||||
val progress = ProgressGaugeWidget(this, tile)
|
||||
val storageSlots: List<MachineOutputSlot>
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(5)
|
||||
@ -29,10 +33,6 @@ class MatterReplicatorMenu @JvmOverloads constructor(
|
||||
addStorageSlot(MachineOutputSlot(container, it))
|
||||
}
|
||||
|
||||
if (tile != null) {
|
||||
progress.with(tile::workProgress, tile::isUnableToProcess)
|
||||
}
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
}
|
||||
|
@ -11,18 +11,20 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.matter.MatterManager
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput
|
||||
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
class MatterScannerMenu @JvmOverloads constructor(
|
||||
p_38852_: Int,
|
||||
inventory: Inventory,
|
||||
tile: MatterScannerBlockEntity? = null
|
||||
) : MatteryPoweredMenu(
|
||||
MMenus.MATTER_SCANNER, p_38852_, inventory, tile
|
||||
) {
|
||||
) : MatteryPoweredMenu(MMenus.MATTER_SCANNER, p_38852_, inventory, tile) {
|
||||
val input: MatterySlot
|
||||
val progress = ProgressGaugeWidget(this)
|
||||
val progress = ProgressGaugeWidget(this, tile)
|
||||
val patterns = LevelGaugeWidget(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(1)
|
||||
@ -34,7 +36,6 @@ class MatterScannerMenu @JvmOverloads constructor(
|
||||
addStorageSlot(input)
|
||||
|
||||
if (tile != null) {
|
||||
progress.with(tile::workProgress, tile::isUnableToProcess)
|
||||
patterns.with(
|
||||
{ Decimal(tile.matterNode.graph.patternCount) },
|
||||
{ Decimal(tile.matterNode.graph.patternCapacity) })
|
||||
|
@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import ru.dbotthepony.mc.otm.menu.PatternSlot
|
||||
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
@ -14,17 +15,15 @@ class PatternStorageMenu @JvmOverloads constructor(
|
||||
p_38852_: Int,
|
||||
inventory: Inventory,
|
||||
tile: PatternStorageBlockEntity? = null
|
||||
) : MatteryMenu(
|
||||
MMenus.PATTERN_STORAGE, p_38852_, inventory, tile
|
||||
) {
|
||||
val storedThis = LevelGaugeWidget(this)
|
||||
) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) {
|
||||
val storedThis = LevelGaugeWidget(this, tile)
|
||||
val storedGrid = LevelGaugeWidget(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
|
||||
val storageSlots: List<PatternSlot>
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
storedThis.with(tile)
|
||||
storedGrid.with({
|
||||
Decimal(tile.matterNode.graph.patternCount)
|
||||
}, {
|
||||
|
@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
@ -113,6 +114,7 @@ class AndroidStationMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
val equipment = makeEquipmentSlots()
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig)
|
||||
|
||||
init {
|
||||
addInventorySlots()
|
||||
|
@ -20,15 +20,13 @@ import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, tile: ChemicalGeneratorBlockEntity? = null)
|
||||
: MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) {
|
||||
|
||||
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = true)
|
||||
val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true)
|
||||
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPush = true)
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
redstone.with(tile.redstoneControl::redstoneSetting)
|
||||
itemConfig.configure(tile.itemConfig)
|
||||
energyConfig.configure(tile.energyConfig)
|
||||
redstoneConfig.with(tile.redstoneControl::redstoneSetting)
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +62,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t
|
||||
addStorageSlot(residueSlot)
|
||||
|
||||
if (tile != null) {
|
||||
progress.with { 1f - tile.workTicks.toFloat() / tile.workTicksTotal }
|
||||
progress.with { if (tile.workTicksTotal == 0) 0f else 1f - tile.workTicks.toFloat() / tile.workTicksTotal }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,15 +34,13 @@ class EnergyServoMenu @JvmOverloads constructor(
|
||||
val equipment = makeEquipmentSlots(mapMoveToExternal = true)
|
||||
|
||||
val powerGauge = LevelGaugeWidget(this, tile?.energy)
|
||||
val itemConfig = ItemHandlerPlayerInput(this)
|
||||
val energyConfig = EnergyPlayerInput(this, true, true)
|
||||
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true)
|
||||
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
|
||||
init {
|
||||
if (tile != null) {
|
||||
redstone.with(tile.redstoneControl::redstoneSetting)
|
||||
itemConfig.configure(tile.itemConfig)
|
||||
energyConfig.configure(tile.energyConfig)
|
||||
redstoneConfig.with(tile.redstoneControl::redstoneSetting)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.itemsStream
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
@ -13,6 +14,8 @@ import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem
|
||||
import ru.dbotthepony.mc.otm.item.EssenceServoItem
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
|
||||
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
@ -21,7 +24,9 @@ class EssenceStorageMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
tile: EssenceStorageBlockEntity? = null
|
||||
) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) {
|
||||
val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L })
|
||||
val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property
|
||||
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig)
|
||||
|
||||
val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) {
|
||||
override fun mayPlace(itemStack: ItemStack): Boolean {
|
||||
@ -90,6 +95,10 @@ class EssenceStorageMenu @JvmOverloads constructor(
|
||||
|
||||
dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L }
|
||||
|
||||
if (tile != null) {
|
||||
redstoneConfig.with(tile.redstoneControl::redstoneSetting)
|
||||
}
|
||||
|
||||
addStorageSlot(capsuleSlot)
|
||||
addStorageSlot(servoSlot)
|
||||
addInventorySlots()
|
||||
|
@ -20,20 +20,13 @@ class PlatePressMenu @JvmOverloads constructor(
|
||||
val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0)
|
||||
val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) }
|
||||
|
||||
val progressGauge = ProgressGaugeWidget(this)
|
||||
|
||||
val itemConfig = ItemHandlerPlayerInput(this, allowPush = true)
|
||||
val energyConfig = EnergyPlayerInput(this, allowPull = true)
|
||||
val progressGauge = ProgressGaugeWidget(this, tile)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true)
|
||||
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true)
|
||||
|
||||
init {
|
||||
addStorageSlot(inputSlot)
|
||||
addStorageSlot(outputSlot)
|
||||
addInventorySlots()
|
||||
|
||||
if (tile != null) {
|
||||
progressGauge.with(tile::workProgress, tile::isUnableToProcess)
|
||||
itemConfig.configure(tile.itemConfig)
|
||||
energyConfig.configure(tile.energyConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.menu.widget
|
||||
|
||||
import mekanism.api.functions.FloatSupplier
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.FloatSupplier
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import java.util.function.BooleanSupplier
|
||||
|
||||
@ -9,7 +10,7 @@ class ProgressGaugeWidget(menu: MatteryMenu) {
|
||||
var progressSupplier: FloatSupplier = FloatSupplier { 0f }
|
||||
var stuckSupplier: BooleanSupplier = BooleanSupplier { false }
|
||||
|
||||
val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.asFloat })
|
||||
val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() })
|
||||
val isStuck by menu.mSynchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean })
|
||||
|
||||
constructor(
|
||||
@ -19,6 +20,15 @@ class ProgressGaugeWidget(menu: MatteryMenu) {
|
||||
this.progressSupplier = progress
|
||||
}
|
||||
|
||||
constructor(
|
||||
menu: MatteryMenu,
|
||||
blockEntity: MatteryWorkerBlockEntity<*>?
|
||||
) : this(menu) {
|
||||
if (blockEntity != null) {
|
||||
with(blockEntity)
|
||||
}
|
||||
}
|
||||
|
||||
constructor(
|
||||
menu: MatteryMenu,
|
||||
progress: FloatSupplier,
|
||||
@ -39,4 +49,9 @@ class ProgressGaugeWidget(menu: MatteryMenu) {
|
||||
this.stuckSupplier = stuck
|
||||
return this
|
||||
}
|
||||
|
||||
fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget {
|
||||
with(blockEntity::workProgress, blockEntity::isUnableToProcess)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user