Ignore slot filters when taking from chests
This commit is contained in:
parent
36f6a12395
commit
bd4622fc0d
@ -24,7 +24,7 @@ class MatteryChestMenu(
|
||||
}
|
||||
|
||||
override val quickMoveToStorage = QuickMoveInput.create(this, playerCombinedInventorySlots, containerSlots)
|
||||
override val quickMoveFromStorage = QuickMoveInput.create(this, containerSlots, playerInventorySlots)
|
||||
override val quickMoveFromStorage = QuickMoveInput.create(this, containerSlots, playerInventorySlots, false)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@ -26,7 +26,7 @@ class MatteryShulkerBoxMenu(
|
||||
}
|
||||
|
||||
override val quickMoveToStorage = QuickMoveInput.create(this, playerCombinedInventorySlots, containerSlots)
|
||||
override val quickMoveFromStorage = QuickMoveInput.create(this, containerSlots, playerInventorySlots)
|
||||
override val quickMoveFromStorage = QuickMoveInput.create(this, containerSlots, playerInventorySlots, false)
|
||||
|
||||
class Slot(container: Container, slot: Int) : MatteryMenuSlot(container, slot) {
|
||||
override fun mayPlace(stack: ItemStack): Boolean {
|
||||
|
@ -15,15 +15,15 @@ import ru.dbotthepony.mc.otm.core.util.ItemStackKey
|
||||
import ru.dbotthepony.mc.otm.core.util.asKey
|
||||
import ru.dbotthepony.mc.otm.core.util.asKeyOrNull
|
||||
|
||||
class QuickMoveInput(private val menu: MatteryMenu, val from: Collection<Slot>, val to: Collection<Slot>, val mode: Mode) {
|
||||
class QuickMoveInput(private val menu: MatteryMenu, val from: Collection<Slot>, val to: Collection<Slot>, val mode: Mode, val dontTouchFilteredSlots: Boolean = true) {
|
||||
enum class Mode(val iconFromStorage: AbstractMatterySprite, val iconToStorage: AbstractMatterySprite) {
|
||||
RESTOCK(
|
||||
Widgets18.RESTOCK_FROM_STORAGE,
|
||||
Widgets18.RESTOCK_TO_STORAGE
|
||||
) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player, dontTouchFilteredSlots: Boolean) {
|
||||
if (from.isEmpty() || to.isEmpty()) return
|
||||
val (_, itemsFrom) = computeSlotLists(from, true)
|
||||
val (_, itemsFrom) = computeSlotLists(from, dontTouchFilteredSlots)
|
||||
val (_, itemsTo) = computeSlotLists(to, false)
|
||||
|
||||
val intersect = if (itemsFrom.size < itemsTo.size) itemsFrom.keys.filter { it in itemsTo.keys } else itemsTo.keys.filter { it in itemsFrom.keys }
|
||||
@ -39,9 +39,9 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection<Slot>,
|
||||
Widgets18.RESTOCK_WITH_MOVE_FROM_STORAGE,
|
||||
Widgets18.RESTOCK_WITH_MOVE_TO_STORAGE
|
||||
) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player, dontTouchFilteredSlots: Boolean) {
|
||||
if (from.isEmpty() || to.isEmpty()) return
|
||||
val (_, itemsFrom) = computeSlotLists(from, true)
|
||||
val (_, itemsFrom) = computeSlotLists(from, dontTouchFilteredSlots)
|
||||
val (emptyTo, itemsTo) = computeSlotLists(to, false)
|
||||
|
||||
val intersect = if (itemsFrom.size < itemsTo.size) itemsFrom.keys.filter { it in itemsTo.keys } else itemsTo.keys.filter { it in itemsFrom.keys }
|
||||
@ -61,20 +61,20 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection<Slot>,
|
||||
Widgets18.MOVE_EVERYTHING_FROM_STORAGE,
|
||||
Widgets18.MOVE_EVERYTHING_TO_STORAGE
|
||||
) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player) {
|
||||
override fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player, dontTouchFilteredSlots: Boolean) {
|
||||
if (from.isEmpty() || to.isEmpty()) return
|
||||
val toSorted = prioritySortSlots(to)
|
||||
|
||||
from.forEach {
|
||||
val slot = it.containerSlotOrNull()
|
||||
|
||||
if (slot !is IFilteredContainerSlot || !slot.hasFilter)
|
||||
if (!dontTouchFilteredSlots || slot !is IFilteredContainerSlot || !slot.hasFilter)
|
||||
moveItemStackTo(player, it, toSorted, sort = false)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player)
|
||||
abstract fun move(from: Collection<Slot>, to: Collection<Slot>, player: Player, dontTouchFilteredSlots: Boolean = true)
|
||||
|
||||
val textFromStorage: Component get() {
|
||||
return TranslatableComponent("otm.gui.quickmove_from.${name.lowercase()}")
|
||||
@ -92,12 +92,12 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection<Slot>,
|
||||
}
|
||||
|
||||
private fun handle() {
|
||||
mode.move(from, to, menu.player)
|
||||
mode.move(from, to, menu.player, dontTouchFilteredSlots)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun create(menu: MatteryMenu, from: Collection<Slot>, to: Collection<Slot>): Map<Mode, QuickMoveInput> {
|
||||
return Mode.entries.associateWith { QuickMoveInput(menu, from, to, it) }
|
||||
fun create(menu: MatteryMenu, from: Collection<Slot>, to: Collection<Slot>, dontTouchFilteredSlots: Boolean = true): Map<Mode, QuickMoveInput> {
|
||||
return Mode.entries.associateWith { QuickMoveInput(menu, from, to, it, dontTouchFilteredSlots) }
|
||||
}
|
||||
|
||||
private fun computeSlotLists(slots: Collection<Slot>, skipFilteredSlots: Boolean): Pair<MutableList<Slot>, MutableMap<ItemStackKey, MutableList<Slot>>> {
|
||||
|
@ -22,7 +22,7 @@ class CargoCrateMenu(
|
||||
|
||||
val sort = SortInput(this, actualContainer, playerSortSettings)
|
||||
val quickMoveToStorage = QuickMoveInput.create(this, playerCombinedInventorySlots, storageSlots)
|
||||
val quickMoveFromStorage = QuickMoveInput.create(this, storageSlots, playerInventorySlots)
|
||||
val quickMoveFromStorage = QuickMoveInput.create(this, storageSlots, playerInventorySlots, false)
|
||||
|
||||
init {
|
||||
if (trackedPlayerOpen) {
|
||||
|
@ -480,7 +480,7 @@ class QuickStackPacket(
|
||||
if (fromExopack)
|
||||
mode.move(player.matteryPlayer.exoPackMenu.playerCombinedInventorySlots, cap.getSlotsFor(player), player)
|
||||
else
|
||||
mode.move(cap.getSlotsFor(player), player.matteryPlayer.exoPackMenu.playerInventorySlots, player)
|
||||
mode.move(cap.getSlotsFor(player), player.matteryPlayer.exoPackMenu.playerInventorySlots, player, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user