Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package lu.kolja.expandedgt.common.machines.input

import appeng.api.stacks.GenericStack
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler
import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour
import com.gregtechceu.gtceu.integration.ae2.machine.MEInputBusPartMachine
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEItemList
import com.lowdragmc.lowdraglib.gui.widget.LabelWidget
import com.lowdragmc.lowdraglib.gui.widget.Widget
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder
import com.lowdragmc.lowdraglib.utils.Position
import lu.kolja.expandedgt.common.machines.widgets.ae2.ExpAEItemConfigWidget
import net.minecraft.nbt.CompoundTag

open class ExpMEInputBusPartMachine(holder: IMachineBlockEntity, vararg args: Any): MEInputBusPartMachine(holder, args) {
open class ExpMEInputBusPartMachine(holder: IMachineBlockEntity, vararg args: Any) :
MEInputBusPartMachine(holder, args) {
open val managedFieldHolder = ManagedFieldHolder(ExpMEInputBusPartMachine::class.java, MANAGED_FIELD_HOLDER)

companion object {
Expand All @@ -27,59 +20,4 @@ open class ExpMEInputBusPartMachine(holder: IMachineBlockEntity, vararg args: An
this.aeItemHandler = ExportOnlyAEItemList(this, SIZE)
return this.aeItemHandler
}

override fun createUIWidget(): Widget {
val group = WidgetGroup(Position(0, 0))

group.addWidget(LabelWidget(3, 0,
if (this.isOnline) "gtceu.gui.me_network.online" else "gtceu.gui.me_network.offline"
))
val left = this.aeItemHandler.inventory.copyOfRange(0, SIZE / 2)
val right = this.aeItemHandler.inventory.copyOfRange(SIZE / 2, SIZE)
val firstWidget = ExpAEItemConfigWidget(3, 10, aeItemHandler, left)
val secondWidget = ExpAEItemConfigWidget(3, 10 + 76, aeItemHandler, right)
firstWidget.otherWidget = secondWidget
secondWidget.otherWidget = firstWidget
group.addWidget(firstWidget)
group.addWidget(secondWidget)
return group
}

override fun writeConfigToTag(): CompoundTag {
val tag = CompoundTag()
val configStacks = CompoundTag()
tag.put("ConfigStacks", configStacks)
for (i in 0..<SIZE) {
val slot = this.aeItemHandler.inventory[i]
val config = slot.config
config?.let {
val stackTag = GenericStack.writeTag(config)
configStacks.put(i.toString(), stackTag)
}
}
tag.putByte("GhostCircuit", IntCircuitBehaviour.getCircuitConfiguration(circuitInventory.getStackInSlot(0)).toByte())
tag.putBoolean("DistinctBuses", isDistinct)
return tag
}

override fun readConfigFromTag(tag: CompoundTag) {
if (tag.contains("ConfigStacks")) {
val configStacks = tag.getCompound("ConfigStacks")
for (i in 0..<SIZE) {
val key = i.toString()
if (configStacks.contains(key)) {
val configTag = configStacks.getCompound(key)
this.aeItemHandler.inventory[i].config = GenericStack.readTag(configTag)
} else {
this.aeItemHandler.inventory[i].config = null
}
}
}
if (tag.contains("GhostCircuit")) {
circuitInventory.setStackInSlot(0, IntCircuitBehaviour.stack(tag.getByte("GhostCircuit").toInt()))
}
if (tag.contains("DistinctBuses")) {
isDistinct = tag.getBoolean("DistinctBuses")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
package lu.kolja.expandedgt.common.machines.input

import appeng.api.stacks.GenericStack
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank
import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour
import com.gregtechceu.gtceu.integration.ae2.machine.MEInputHatchPartMachine
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidList
import com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup
import com.lowdragmc.lowdraglib.gui.widget.LabelWidget
import com.lowdragmc.lowdraglib.gui.widget.Widget
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder
import com.lowdragmc.lowdraglib.utils.Position
import lu.kolja.expandedgt.common.machines.widgets.ae2.ExpAEFluidConfigWidget
import net.minecraft.nbt.CompoundTag

open class ExpMEInputHatchPartMachine(holder: IMachineBlockEntity, vararg args: Any): MEInputHatchPartMachine(holder, args) {
open val managedFieldHolder = ManagedFieldHolder(ExpMEInputHatchPartMachine::class.java, MANAGED_FIELD_HOLDER)
Expand All @@ -28,58 +19,4 @@ open class ExpMEInputHatchPartMachine(holder: IMachineBlockEntity, vararg args:
this.aeFluidHandler = ExportOnlyAEFluidList(this, SIZE)
return this.aeFluidHandler
}

override fun createUIWidget(): Widget {
val group = WidgetGroup(Position(0, 0))
group.addWidget(LabelWidget(3, 0,
if (this.isOnline) "gtceu.gui.me_network.online" else "gtceu.gui.me_network.offline"
))
val left = this.aeFluidHandler.inventory.copyOfRange(0, SIZE / 2)
val right = this.aeFluidHandler.inventory.copyOfRange(SIZE / 2, SIZE)
val firstWidget = ExpAEFluidConfigWidget(3, 10, aeFluidHandler, left) {
it.selfPositionY = group.positionY - it.sizeHeight
}
val secondWidget = ExpAEFluidConfigWidget(3, 10 + 76, aeFluidHandler, right) {
it.selfPositionY = group.positionY - it.sizeHeight
}
firstWidget.otherWidget = secondWidget
secondWidget.otherWidget = firstWidget
group.addWidget(firstWidget)
group.addWidget(secondWidget)
return group
}

override fun writeConfigToTag(): CompoundTag {
val tag = CompoundTag()
val configStacks = CompoundTag()
tag.put("ConfigStacks", configStacks)
for (i in 0..<SIZE) {
val slot = this.aeFluidHandler.inventory[i]
val config = slot.config
config?.let {
val stackTag = GenericStack.writeTag(config)
configStacks.put(i.toString(), stackTag)
}
}
tag.putByte("GhostCircuit", IntCircuitBehaviour.getCircuitConfiguration(circuitInventory.getStackInSlot(0)).toByte())
return tag
}

override fun readConfigFromTag(tag: CompoundTag) {
if (tag.contains("ConfigStacks")) {
val configStacks = tag.getCompound("ConfigStacks")
for (i in 0..<SIZE) {
val key = i.toString()
if (configStacks.contains(key)) {
val configTag = configStacks.getCompound(key)
this.aeFluidHandler.inventory[i].config = GenericStack.readTag(configTag)
} else {
this.aeFluidHandler.inventory[i].config = null
}
}
}
if (tag.contains("GhostCircuit")) {
circuitInventory.setStackInSlot(0, IntCircuitBehaviour.stack(tag.getByte("GhostCircuit").toInt()))
}
}
}
Loading
Loading