New quickmove implementation
This commit is contained in:
parent
d151fd6727
commit
dd4be8b961
@ -18,8 +18,6 @@ import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
|
||||
class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMenu(null, CONTAINER_ID, capability.ply.inventory) {
|
||||
override val storageSlots: Collection<Slot> get() = listOf()
|
||||
|
||||
val craftingGrid: CraftingContainer
|
||||
val craftingSlots: List<MatterySlot>
|
||||
|
||||
@ -52,6 +50,19 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
|
||||
init {
|
||||
addInventorySlots(autoFrame = false)
|
||||
|
||||
for (slot in playerCombinedInventorySlots) {
|
||||
mapQuickMove(slot, playerHotbarSlots)
|
||||
}
|
||||
|
||||
for (slot in playerHotbarSlots) {
|
||||
mapQuickMove(slot, playerCombinedInventorySlots)
|
||||
}
|
||||
|
||||
for (slot in craftingSlots) {
|
||||
mapQuickMove(slot, playerInventorySlots)
|
||||
}
|
||||
|
||||
craftingSlots.forEach(this::addSlot)
|
||||
}
|
||||
|
||||
@ -65,6 +76,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
val allAccessibleSlots: List<Slot>
|
||||
|
||||
init {
|
||||
mapQuickMove(offhandSlot, playerInventorySlots)
|
||||
addSlot(offhandSlot)
|
||||
|
||||
val builder = ImmutableList.builder<Slot>()
|
||||
@ -81,11 +93,11 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
init {
|
||||
for ((a, b) in curiosSlots) {
|
||||
addSlot(a)
|
||||
storage2Inventory(a)
|
||||
mapQuickMoveToInventory(a)
|
||||
|
||||
if (b != null) {
|
||||
addSlot(b)
|
||||
storage2Inventory(b)
|
||||
mapQuickMoveToInventory(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,32 +155,6 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
if (!autoRegisteredStorageSlots) {
|
||||
autoRegisteredStorageSlots = true
|
||||
|
||||
for (slot in playerCombinedInventorySlots) {
|
||||
quickMoveMapping[slot] = ::playerHotbarSlots
|
||||
}
|
||||
|
||||
for (slot in playerHotbarSlots) {
|
||||
quickMoveMapping[slot] = ::playerCombinedInventorySlots
|
||||
}
|
||||
|
||||
for (slot in craftingSlots) {
|
||||
quickMoveMapping[slot] = ::playerInventorySlots
|
||||
}
|
||||
|
||||
for (slot in armorSlots) {
|
||||
quickMoveMapping[slot.functional] = ::playerInventorySlots
|
||||
|
||||
if (slot.cosmetic != null) {
|
||||
quickMoveMapping[slot.cosmetic] = ::playerInventorySlots
|
||||
}
|
||||
}
|
||||
|
||||
quickMoveMapping[offhandSlot] = ::playerInventorySlots
|
||||
}
|
||||
|
||||
if (slotIndex == craftingResultSlot.index) {
|
||||
val item = craftingResultSlot.item
|
||||
val leftover = moveItemStackToSlots(item, playerInventorySlots2, simulate = true)
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList
|
||||
import com.mojang.datafixers.util.Pair
|
||||
import it.unimi.dsi.fastutil.io.FastByteArrayInputStream
|
||||
import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@ -281,7 +282,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
_playerInventorySlots2.add(slot)
|
||||
_playerMainSlots.add(slot)
|
||||
_playerCombinedInventorySlots.add(slot)
|
||||
inventory2Storage(slot)
|
||||
|
||||
mapQuickMove(slot, equipmentSlots)
|
||||
mapQuickMoveToExternal(slot)
|
||||
addSlot(slot)
|
||||
}
|
||||
|
||||
@ -295,7 +298,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
_playerInventorySlots2.add(slot)
|
||||
_playerExoSuitSlots.add(slot)
|
||||
_playerCombinedInventorySlots.add(slot)
|
||||
inventory2Storage(slot)
|
||||
|
||||
mapQuickMove(slot, equipmentSlots)
|
||||
mapQuickMoveToExternal(slot)
|
||||
addSlot(slot)
|
||||
}
|
||||
}
|
||||
@ -303,11 +308,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
for (i in 0..8) {
|
||||
val slot = InventorySlot(inventory, i)
|
||||
|
||||
addSlot(slot)
|
||||
_playerInventorySlots2.add(i, slot)
|
||||
_playerInventorySlots.add(slot)
|
||||
_playerHotbarSlots.add(slot)
|
||||
inventory2Storage(slot)
|
||||
|
||||
mapQuickMove(slot, equipmentSlots)
|
||||
mapQuickMoveToExternal(slot)
|
||||
addSlot(slot)
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,50 +379,99 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
return player.distanceToSqr(pos.x.toDouble() + 0.5, pos.y.toDouble() + 0.5, pos.z.toDouble() + 0.5) <= 64.0
|
||||
}
|
||||
|
||||
abstract val storageSlots: Collection<Slot>
|
||||
protected val quickMoveMapping = Reference2ObjectOpenHashMap<Slot, () -> Collection<Slot>?>()
|
||||
private val externalSlots = ArrayList<Slot>()
|
||||
private val quickMoveMapping = Reference2ObjectOpenHashMap<Slot, ArrayList<Collection<Slot>>>()
|
||||
|
||||
override fun addSlot(pSlot: Slot): Slot {
|
||||
if (pSlot in slots) {
|
||||
return pSlot
|
||||
}
|
||||
|
||||
return super.addSlot(pSlot)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds slot to "storage slots" list (utilized by quick move) and calls [addSlot]
|
||||
*/
|
||||
protected fun <T : Slot> addStorageSlot(slot: T, addMapping: Boolean = true): T {
|
||||
if (slot !in externalSlots) {
|
||||
addSlot(slot)
|
||||
externalSlots.add(slot)
|
||||
|
||||
if (addMapping) {
|
||||
mapQuickMove(slot, equipmentSlots)
|
||||
mapQuickMoveToInventory(slot)
|
||||
}
|
||||
}
|
||||
|
||||
return slot
|
||||
}
|
||||
|
||||
protected fun addStorageSlot(slot: Iterable<Slot>, addMapping: Boolean = true) {
|
||||
for (value in slot)
|
||||
addStorageSlot(value, addMapping)
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks slot as "storage" - shift clicking it will move its contents to Player's inventory
|
||||
*/
|
||||
protected fun storage2Inventory(slot: Slot) {
|
||||
quickMoveMapping[slot] = ::playerInventorySlots
|
||||
protected fun mapQuickMoveToInventory(slot: Slot, prepend: Boolean = false) {
|
||||
mapQuickMove(slot, playerInventorySlots, prepend = prepend)
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks slot as "inventory" - shift clicking it will move its contents to menu's storage slots
|
||||
*/
|
||||
protected fun inventory2Storage(slot: Slot) {
|
||||
quickMoveMapping[slot] = ::storageSlots
|
||||
protected fun mapQuickMoveToExternal(slot: Slot, prepend: Boolean = false) {
|
||||
mapQuickMove(slot, externalSlots, prepend = prepend)
|
||||
}
|
||||
|
||||
protected var autoRegisteredStorageSlots = false
|
||||
protected fun mapQuickMove(slot: Slot, target: Collection<Slot>, prepend: Boolean = false) {
|
||||
val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ArrayList(1) })
|
||||
listing.remove(target)
|
||||
|
||||
if (prepend)
|
||||
listing.add(0, target)
|
||||
else
|
||||
listing.add(target)
|
||||
}
|
||||
|
||||
protected fun mapQuickMove(slot: Slot, vararg target: Collection<Slot>) {
|
||||
for (value in target) {
|
||||
mapQuickMove(slot, value)
|
||||
}
|
||||
}
|
||||
|
||||
// This method receive Player interactor and slot_index where Shift + Right click occurred
|
||||
// It shall return item stack that got moved
|
||||
override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack {
|
||||
if (!slots[slotIndex].hasItem() || !slots[slotIndex].mayPickup(ply)) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
if (!autoRegisteredStorageSlots) {
|
||||
autoRegisteredStorageSlots = true
|
||||
|
||||
for (slot in storageSlots) {
|
||||
storage2Inventory(slot)
|
||||
}
|
||||
}
|
||||
|
||||
val slot = slots[slotIndex]
|
||||
val target = quickMoveMapping[slot]?.invoke() ?: return ItemStack.EMPTY
|
||||
val copy = slots[slotIndex].item.copy()
|
||||
|
||||
if (moveItemStackTo(slots[slotIndex], target))
|
||||
return copy
|
||||
else
|
||||
if (!slot.hasItem() || !slot.mayPickup(ply)) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
val target = quickMoveMapping[slot] ?: return ItemStack.EMPTY
|
||||
val copy = slot.item.copy()
|
||||
var any = false
|
||||
|
||||
for (collection in target) {
|
||||
if (moveItemStackTo(slot, collection)) {
|
||||
any = true
|
||||
|
||||
if (!slot.hasItem()) {
|
||||
return copy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (any) {
|
||||
return copy
|
||||
} else {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
}
|
||||
|
||||
fun quickMoveToInventory(stack: ItemStack, simulate: Boolean): ItemStack {
|
||||
if (_playerInventorySlots.isEmpty()) {
|
||||
return stack
|
||||
@ -546,11 +602,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
return moveItemStackToSlots(item, slots, simulate)
|
||||
}
|
||||
|
||||
public override fun addDataSlots(p_38885_: ContainerData) {
|
||||
super.addDataSlots(p_38885_)
|
||||
}
|
||||
private var armorSlots: ImmutableList<PlayerSlot<EquipmentSlot, Slot>>? = null
|
||||
private var curiosSlots: ImmutableList<PlayerSlot<Slot, Slot>>? = null
|
||||
private val equipmentSlots = ArrayList<Slot>()
|
||||
|
||||
fun makeArmorSlots(): List<PlayerSlot<EquipmentSlot, Slot>> {
|
||||
if (armorSlots != null) {
|
||||
return armorSlots!!
|
||||
}
|
||||
|
||||
val cosmetic = ply.cosmeticArmorSlots
|
||||
|
||||
return ImmutableList.of(
|
||||
@ -559,9 +619,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS)),
|
||||
PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET)),
|
||||
).also {
|
||||
armorSlots = it
|
||||
|
||||
for ((a, b) in it) {
|
||||
equipmentSlots.add(a)
|
||||
addSlot(a)
|
||||
if (b != null) addSlot(b)
|
||||
|
||||
mapQuickMoveToInventory(a)
|
||||
if (b != null) mapQuickMoveToInventory(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -569,12 +635,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
fun makeEquipmentSlots(): EquipmentSlots {
|
||||
return EquipmentSlots(
|
||||
armorSlots = makeArmorSlots(),
|
||||
curiosSlots = ImmutableList.copyOf(ply.curiosSlots).also {
|
||||
curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also {
|
||||
for ((a, b) in it) {
|
||||
equipmentSlots.add(a)
|
||||
addSlot(a)
|
||||
if (b != null) addSlot(b)
|
||||
|
||||
mapQuickMoveToInventory(a)
|
||||
if (b != null) mapQuickMoveToInventory(b)
|
||||
}
|
||||
}
|
||||
}.also { curiosSlots = it }
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -28,5 +28,6 @@ abstract class MatteryPoweredMenu protected constructor(
|
||||
}
|
||||
|
||||
addSlot(batterySlot)
|
||||
mapQuickMoveToInventory(batterySlot)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class CargoCrateMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
tile: CargoCrateBlockEntity? = null
|
||||
) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory, tile) {
|
||||
override val storageSlots: List<MatterySlot>
|
||||
val storageSlots: List<MatterySlot>
|
||||
|
||||
private val trackedPlayerOpen = !inventory.player.isSpectator
|
||||
|
||||
@ -22,9 +22,7 @@ class CargoCrateMenu @JvmOverloads constructor(
|
||||
val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY)
|
||||
|
||||
storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) {
|
||||
val slot = MatterySlot(container, it)
|
||||
addSlot(slot)
|
||||
return@ImmutableList slot
|
||||
addStorageSlot(MatterySlot(container, it))
|
||||
}
|
||||
|
||||
if (trackedPlayerOpen) {
|
||||
|
@ -30,7 +30,4 @@ class HoloSignMenu @JvmOverloads constructor(
|
||||
redstone.with(tile.redstoneControl::redstoneSetting)
|
||||
}
|
||||
}
|
||||
|
||||
override val storageSlots: Collection<Slot>
|
||||
get() = listOf()
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class MinecartCargoCrateMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
val cart: MinecartCargoCrate? = null
|
||||
) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory) {
|
||||
override val storageSlots: List<MatterySlot>
|
||||
val storageSlots: List<MatterySlot>
|
||||
|
||||
private val trackedPlayerOpen = !inventory.player.isSpectator
|
||||
|
||||
@ -24,9 +24,7 @@ class MinecartCargoCrateMenu @JvmOverloads constructor(
|
||||
val container = cart as Container? ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY)
|
||||
|
||||
storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) {
|
||||
val slot = MatterySlot(container, it)
|
||||
addSlot(slot)
|
||||
return@ImmutableList slot
|
||||
addStorageSlot(MatterySlot(container, it))
|
||||
}
|
||||
|
||||
if (trackedPlayerOpen) {
|
||||
|
@ -28,7 +28,7 @@ class MatterBottlerMenu @JvmOverloads constructor(
|
||||
val progressWidget: ProgressGaugeWidget
|
||||
val matterWidget: LevelGaugeWidget
|
||||
|
||||
override val storageSlots: List<MatterySlot>
|
||||
val storageSlots: List<MatterySlot>
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(6)
|
||||
@ -57,7 +57,7 @@ class MatterBottlerMenu @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
storageSlots.forEach(this::addSlot)
|
||||
storageSlots.forEach(this::addStorageSlot)
|
||||
addInventorySlots()
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class MatterCapacitorBankMenu @JvmOverloads constructor(
|
||||
val matterGauge: LevelGaugeWidget
|
||||
val totalMatterGauge: LevelGaugeWidget
|
||||
|
||||
override val storageSlots: List<MatterContainerInputSlot>
|
||||
val storageSlots: List<MatterContainerInputSlot>
|
||||
|
||||
init {
|
||||
if (tile == null) {
|
||||
@ -38,9 +38,7 @@ class MatterCapacitorBankMenu @JvmOverloads constructor(
|
||||
val container = tile?.container ?: SimpleContainer(2 * 6)
|
||||
|
||||
storageSlots = ImmutableList(2 * 6) {
|
||||
val slot = MatterContainerInputSlot(container, it)
|
||||
addSlot(slot)
|
||||
slot
|
||||
addStorageSlot(MatterContainerInputSlot(container, it))
|
||||
}
|
||||
|
||||
addInventorySlots()
|
||||
|
@ -48,12 +48,10 @@ class MatterDecomposerMenu @JvmOverloads constructor(
|
||||
progressWidget = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess)
|
||||
}
|
||||
|
||||
addStorageSlot(outputMain)
|
||||
addStorageSlot(outputStacking)
|
||||
addStorageSlot(input)
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = ImmutableList.of(
|
||||
addSlot(outputMain),
|
||||
addSlot(outputStacking),
|
||||
addSlot(input),
|
||||
)
|
||||
}
|
||||
|
@ -294,9 +294,6 @@ class MatterPanelMenu @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override val storageSlots: Collection<Slot>
|
||||
get() = emptyList()
|
||||
|
||||
companion object {
|
||||
private val LOGGER = LogManager.getLogger()
|
||||
}
|
||||
|
@ -37,9 +37,7 @@ class MatterRecyclerMenu @JvmOverloads constructor(
|
||||
progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess)
|
||||
}
|
||||
|
||||
addSlot(input)
|
||||
addStorageSlot(input)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: Collection<Slot> = ImmutableList.of(input)
|
||||
}
|
||||
|
@ -20,15 +20,13 @@ class MatterReplicatorMenu @JvmOverloads constructor(
|
||||
) {
|
||||
val matter: LevelGaugeWidget
|
||||
val progress: ProgressGaugeWidget
|
||||
override val storageSlots: List<MachineOutputSlot>
|
||||
val storageSlots: List<MachineOutputSlot>
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(5)
|
||||
|
||||
storageSlots = ImmutableList(5) {
|
||||
val slot = MachineOutputSlot(container, it)
|
||||
addSlot(slot)
|
||||
return@ImmutableList slot
|
||||
addStorageSlot(MachineOutputSlot(container, it))
|
||||
}
|
||||
|
||||
if (tile != null) {
|
||||
|
@ -31,7 +31,7 @@ class MatterScannerMenu @JvmOverloads constructor(
|
||||
override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack)
|
||||
}
|
||||
|
||||
addSlot(input)
|
||||
addStorageSlot(input)
|
||||
|
||||
if (tile != null) {
|
||||
progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess)
|
||||
@ -45,6 +45,4 @@ class MatterScannerMenu @JvmOverloads constructor(
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: List<MatterySlot> = listOf(input)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class PatternStorageMenu @JvmOverloads constructor(
|
||||
val storedThis: LevelGaugeWidget
|
||||
val storedGrid: LevelGaugeWidget
|
||||
|
||||
override val storageSlots: List<PatternSlot>
|
||||
val storageSlots: List<PatternSlot>
|
||||
|
||||
init {
|
||||
if (tile == null) {
|
||||
@ -38,11 +38,9 @@ class PatternStorageMenu @JvmOverloads constructor(
|
||||
val patterns = tile?.container ?: SimpleContainer(2 * 4)
|
||||
|
||||
storageSlots = ImmutableList(2 * 4) {
|
||||
PatternSlot(patterns, it)
|
||||
addStorageSlot(PatternSlot(patterns, it))
|
||||
}
|
||||
|
||||
storageSlots.forEach(this::addSlot)
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,13 @@ class DriveRackMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
tile: DriveRackBlockEntity? = null
|
||||
) : MatteryPoweredMenu(MMenus.DRIVE_RACK, p_38852_, inventory, tile) {
|
||||
override val storageSlots: List<MatterySlot>
|
||||
val storageSlots: List<MatterySlot>
|
||||
|
||||
init {
|
||||
val container = tile?.container ?: SimpleContainer(4)
|
||||
|
||||
storageSlots = ImmutableList(4) {
|
||||
val slot = DriveSlot(container, it)
|
||||
addSlot(slot)
|
||||
slot
|
||||
addStorageSlot(DriveSlot(container, it))
|
||||
}
|
||||
|
||||
addInventorySlots()
|
||||
|
@ -56,12 +56,10 @@ class DriveViewerMenu @JvmOverloads constructor(
|
||||
powered = null
|
||||
}
|
||||
|
||||
addSlot(driveSlot)
|
||||
addStorageSlot(driveSlot)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = ImmutableList.of(driveSlot, batterySlot)
|
||||
|
||||
val driveFilter = ItemFilter(PortableCondensationDriveItem.MAX_FILTERS) { self, _, _, _ ->
|
||||
if (tile?.container?.get(0)?.item is PortableCondensationDriveItem) {
|
||||
tile.container[0].getOrCreateTag().put(PortableCondensationDriveItem.FILTER_PATH, self.serializeNBT())
|
||||
|
@ -130,8 +130,6 @@ class ItemMonitorMenu @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = listOf(batterySlot)
|
||||
|
||||
override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack {
|
||||
if (playerInventorySlots.any { it.index == slotIndex }) {
|
||||
if (tile == null) {
|
||||
|
@ -27,8 +27,7 @@ class StorageBusMenu @JvmOverloads constructor(
|
||||
busFilterState = BooleanInputWithFeedback(this)
|
||||
}
|
||||
|
||||
addStorageSlot(batterySlot)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: Collection<Slot> = listOf(batterySlot)
|
||||
}
|
||||
|
@ -29,6 +29,4 @@ class StorageExporterMenu @JvmOverloads constructor(
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = listOf(batterySlot)
|
||||
}
|
||||
|
@ -29,6 +29,4 @@ class StorageImporterMenu @JvmOverloads constructor(
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = listOf(batterySlot)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor(
|
||||
var activeNodes by mSynchronizer.int()
|
||||
|
||||
init {
|
||||
addStorageSlot(batterySlot)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
@ -26,6 +27,4 @@ class StoragePowerSupplierMenu @JvmOverloads constructor(
|
||||
|
||||
super.broadcastChanges()
|
||||
}
|
||||
|
||||
override val storageSlots: List<Slot> = listOf(batterySlot)
|
||||
}
|
||||
|
@ -116,11 +116,7 @@ class AndroidStationMenu @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
addInventorySlots()
|
||||
addSlot(androidBattery)
|
||||
}
|
||||
|
||||
override val storageSlots = immutableList {
|
||||
accept(androidBattery)
|
||||
addStorageSlot(androidBattery)
|
||||
}
|
||||
|
||||
override fun stillValid(player: Player): Boolean {
|
||||
|
@ -22,7 +22,7 @@ class BatteryBankMenu @JvmOverloads constructor(
|
||||
tile: BatteryBankBlockEntity? = null,
|
||||
) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) {
|
||||
val powerLevel: LevelGaugeWidget
|
||||
override val storageSlots: List<MatterySlot>
|
||||
val storageSlots: List<MatterySlot>
|
||||
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
|
||||
|
||||
init {
|
||||
@ -34,9 +34,7 @@ class BatteryBankMenu @JvmOverloads constructor(
|
||||
powerLevel = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.ENERGY)?.orNull())
|
||||
|
||||
storageSlots = ImmutableList(BatteryBankBlockEntity.CAPACITY) {
|
||||
val slot = BatterySlot(container, it)
|
||||
addSlot(slot)
|
||||
return@ImmutableList slot
|
||||
addStorageSlot(BatterySlot(container, it))
|
||||
}
|
||||
|
||||
addInventorySlots()
|
||||
|
@ -58,11 +58,11 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t
|
||||
val energy = LevelGaugeWidget(this, tile?.energy)
|
||||
var burnTime by mSynchronizer.int()
|
||||
|
||||
override val storageSlots = listOf(
|
||||
addSlot(fuelSlot),
|
||||
addSlot(batterySlot),
|
||||
addSlot(residueSlot),
|
||||
)
|
||||
init {
|
||||
addStorageSlot(fuelSlot)
|
||||
addStorageSlot(batterySlot)
|
||||
addStorageSlot(residueSlot)
|
||||
}
|
||||
|
||||
init {
|
||||
addInventorySlots()
|
||||
|
@ -17,7 +17,7 @@ class CobblerMenu @JvmOverloads constructor(
|
||||
inventory: Inventory,
|
||||
tile: CobblerBlockEntity? = null
|
||||
) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) {
|
||||
override val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } }
|
||||
val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } }
|
||||
val redstone = EnumInputWithFeedback<RedstoneSetting>(this)
|
||||
val itemConfig = ItemHandlerPlayerInput(this, false, false)
|
||||
|
||||
|
@ -72,9 +72,6 @@ class EnergyCounterMenu @JvmOverloads constructor(
|
||||
super.broadcastChanges()
|
||||
}
|
||||
|
||||
|
||||
override val storageSlots: Collection<Slot> get() = emptySet()
|
||||
|
||||
companion object {
|
||||
private val MINUS_ONE = -BigDecimal.ONE
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.menu.tech
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
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.block.entity.tech.EnergyServoBlockEntity
|
||||
@ -49,10 +47,10 @@ class EnergyServoMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
addSlot(dischargeSlot)
|
||||
addSlot(chargeSlot)
|
||||
// charge then discharge for charging to take priority over discharging
|
||||
addStorageSlot(chargeSlot)
|
||||
addStorageSlot(dischargeSlot)
|
||||
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val storageSlots: Collection<Slot> = ImmutableList.of(dischargeSlot, chargeSlot)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.menu.tech
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
@ -21,16 +20,14 @@ 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) }
|
||||
|
||||
override val storageSlots: List<MatterySlot> = ImmutableList.of(inputSlot, outputSlot)
|
||||
|
||||
val progressGauge = if (tile != null) ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) else ProgressGaugeWidget(this)
|
||||
|
||||
val itemConfig = ItemHandlerPlayerInput(this, allowPush = true)
|
||||
val energyConfig = EnergyPlayerInput(this, allowPull = true)
|
||||
|
||||
init {
|
||||
addSlot(inputSlot)
|
||||
addSlot(outputSlot)
|
||||
addStorageSlot(inputSlot)
|
||||
addStorageSlot(outputSlot)
|
||||
addInventorySlots()
|
||||
|
||||
if (tile != null) {
|
||||
|
@ -7,8 +7,4 @@ abstract class AbstractWidget(val menu: MatteryMenu,) {
|
||||
val slotID: Int = menu.addWidget(this)
|
||||
|
||||
abstract fun updateServer()
|
||||
|
||||
protected fun addDataSlots(slots: ContainerData) {
|
||||
menu.addDataSlots(slots)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user