Skip to content

Commit

Permalink
Resolve InvUI-related deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Dec 18, 2024
1 parent afd5d22 commit 27ed9a7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ItemCableConfigMenu(
updateValues()

insertFilterInventory = VirtualInventory(null, 1, arrayOf(insertFilter), intArrayOf(1))
insertFilterInventory.setPreUpdateHandler(::validateIsItemFilter)
insertFilterInventory.addPreUpdateHandler(::validateIsItemFilter)
extractFilterInventory = VirtualInventory(null, 1, arrayOf(extractFilter), intArrayOf(1))
extractFilterInventory.setPreUpdateHandler(::validateIsItemFilter)
extractFilterInventory.addPreUpdateHandler(::validateIsItemFilter)

gui = Gui.normal()
.setStructure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class ItemFilterMenu(
) {

private val filterInventory = VirtualInventory(null, items.size, items, IntArray(items.size) {1}).apply {
setPreUpdateHandler { event ->
addPreUpdateHandler { event ->
event.isCancelled = true

// disallow item filters in item filters
if (event.newItem?.isItemFilter() == true)
return@setPreUpdateHandler
return@addPreUpdateHandler

if (event.isAdd || event.isSwap) {
putItem(UpdateReason.SUPPRESSED, event.slot, event.newItem!!.clone().apply { amount = 1} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private val MAX_ITEMS by STORAGE_UNIT.config.entry<Int>("max_items")
class StorageUnit(pos: BlockPos, state: NovaBlockState, data: Compound) : NetworkedTileEntity(pos, state, data) {

private val inventory = StorageUnitInventory(storedValue("type", true, ItemStack::empty), storedValue("amount", true) { 0 })
private val inputInventory = VirtualInventory(null, 1).apply { setPreUpdateHandler(::handleInputInventoryUpdate) }
private val outputInventory = VirtualInventory(null, 1).apply { setPreUpdateHandler(::handlePreOutputInventoryUpdate); setPostUpdateHandler(::handlePostOutputInventoryUpdate) }
private val inputInventory = VirtualInventory(null, 1).apply { addPreUpdateHandler(::handleInputInventoryUpdate) }
private val outputInventory = VirtualInventory(null, 1).apply { addPreUpdateHandler(::handlePreOutputInventoryUpdate); addPostUpdateHandler(::handlePostOutputInventoryUpdate) }

init {
storedItemHolder(inventory to NetworkConnectionType.BUFFER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.util.*

class TrashCan(pos: BlockPos, state: NovaBlockState, data: Compound) : NetworkedTileEntity(pos, state, data) {

private val inventory = VirtualInventory(1).apply { setPostUpdateHandler { setItem(UpdateReason.SUPPRESSED, 0, null) } }
private val inventory = VirtualInventory(1).apply { addPostUpdateHandler { setItem(UpdateReason.SUPPRESSED, 0, null) } }
private val itemHolder = storedItemHolder(inventory to NetworkConnectionType.INSERT)
private val fluidHolder = storedFluidHolder(VoidingFluidContainer to NetworkConnectionType.INSERT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class VacuumChest(pos: BlockPos, state: NovaBlockState, data: Compound) : Networ
if (filter != null)
filterInventory.setItem(SELF_UPDATE_REASON, 0, filter!!.toItemStack())

filterInventory.setPreUpdateHandler(::handleFilterInventoryUpdate)
filterInventory.addPreUpdateHandler(::handleFilterInventoryUpdate)
filterInventory.guiPriority = 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private fun ItemStack.getUpgradeType(): UpgradeType<*>? =

internal class UpgradesGui(val upgradeHolder: UpgradeHolder, openPrevious: (Player) -> Unit) {

private val input = VirtualInventory(null, 1).apply { setPreUpdateHandler(::handlePreInvUpdate); setPostUpdateHandler(::handlePostInvUpdate) }
private val input = VirtualInventory(null, 1).apply { addPreUpdateHandler(::handlePreInvUpdate); addPostUpdateHandler(::handlePostInvUpdate) }

private val upgradeItems = ArrayList<Item>()

Expand Down

0 comments on commit 27ed9a7

Please sign in to comment.