Quickcraft into hotbar

Fixes #170
This commit is contained in:
DBotThePony 2022-10-24 09:13:14 +07:00
parent 8a5727233a
commit 1e654ff079
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 11 additions and 2 deletions

View File

@ -146,11 +146,11 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
if (slotIndex == craftingResultSlot.index) {
val item = craftingResultSlot.item
val leftover = moveItemStackToSlots(item, playerInventorySlots, simulate = true)
val leftover = moveItemStackToSlots(item, playerInventorySlots2, simulate = true)
if (leftover.isEmpty) {
val copy = item.copy()
moveItemStackToSlots(item, playerInventorySlots, simulate = false)
moveItemStackToSlots(item, playerInventorySlots2, simulate = false)
item.count = 0
craftingResultSlot.onTake(ply, copy)
return copy

View File

@ -36,6 +36,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
val matteryWidgets: List<AbstractWidget> = Collections.unmodifiableList(_matteryWidgets)
private val _playerInventorySlots = ArrayList<MatterySlot>()
private val _playerInventorySlots2 = ArrayList<MatterySlot>()
private val _playerHotbarSlots = ArrayList<MatterySlot>()
private val _playerMainSlots = ArrayList<MatterySlot>()
private val _playerExoSuitSlots = ArrayList<MatterySlot>()
@ -46,6 +47,11 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
*/
val playerInventorySlots: List<MatterySlot> = Collections.unmodifiableList(_playerInventorySlots)
/**
* hotbar + inventory + exosuit (in this order)
*/
val playerInventorySlots2: List<MatterySlot> = Collections.unmodifiableList(_playerInventorySlots2)
/**
* hotbar only
*/
@ -166,6 +172,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
val slot = InventorySlot(inventory, i)
_playerInventorySlots.add(slot)
_playerInventorySlots2.add(slot)
_playerMainSlots.add(slot)
_playerCombinedInventorySlots.add(slot)
addSlot(slot)
@ -178,6 +185,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
val slot = InventorySlot(mattery.exoSuitContainer, i)
_playerInventorySlots.add(slot)
_playerInventorySlots2.add(slot)
_playerExoSuitSlots.add(slot)
_playerCombinedInventorySlots.add(slot)
addSlot(slot)
@ -188,6 +196,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
val slot = InventorySlot(inventory, i)
addSlot(slot)
_playerInventorySlots2.add(i, slot)
_playerInventorySlots.add(slot)
_playerHotbarSlots.add(slot)
}