Inventory Profiles Next

Inventory Profiles Next

24M Downloads

Inverse of "Items Allowed in Hotbar": "Items Not Allowed in Hotbar"

Xetaxheb opened this issue ยท 1 comments

commented

Have you asked for help in discord?

YES

Describe your desired feature.

As discussed here: https://discord.com/channels/861171785897738240/861178789921030144/1271198691134279802

Basically a text box after LOCKED_SLOTS_EMPTY_HOTBAR_BLACKLIST (items allowed in hotbar: default: "carryon") that allows for blacklisting matched items from going into the hotbar when LOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED==false (pick items directly into inventory: false)

If I put say, "minecraft:cobblestone", then any cobblestone would go into my inventory instead of my hotbar when picked up under the same circumstances (aka normally walking over the item) as "Pick items directly into inventory" would trigger.

commented

A rough draft for edits I cannot test right now; I'm unsure what a lot of the existing code does so I don't know if there's more that needs adding/changing or if there's unnecessary parts (or even just a better place to put the check):

Configs.kt addition

    val LOCKED_SLOTS_BLOCK_HOTBAR_BLACKLIST             /**/ by handledString("botania:pebble", LockedSlotKeeper::updateBlocked)



LockedSlotKeeper.kt addition

    private val blockHotbarBlackList: MutableSet<String> = mutableSetOf()

    fun isBlocked(stack: ItemStack?): Boolean = stack != null && blockHotbarBlackList.find { s ->
                s == stack.`(itemType)`.namespace || s == stack.`(itemType)`.itemId ||
                        s.isWildCard() && JWildcard.matches(s, stack.`(itemType)`.itemId)
            } != null

    fun updateBlocked() {
        blockHotbarBlackList.clear()
        LockedSlotsSettings.LOCKED_SLOTS_BLOCK_HOTBAR_BLACKLIST.value.split(",").forEach {
            blockHotbarBlackList.add(it.trim())
        }
    }

LockedSlotKeeper.kt
L245 (adding another else if to L182's closing bracket)

-- }
++

            } else if (this.emptyNonLockedSlots.isNotEmpty()
            && emptyNonLockedHotbarSlots.isNotEmpty()) {

            fun checkHotbar(second: Boolean = false) {
                val localSkipRemoveEmptyFor: MutableSet<Int> = skipRemoveEmptyFor.toMutableSet()
                val secondString  = if (second) {
                    "Second run: "
                } else {
                    ""
                }

                newlyFilled.clear()
                (localEmptyNonLockedSlots - emptyNonLockedHotbarSlots).isEmpty().ifTrue {
                    return
                }
                emptyNonLockedHotbarSlots.forEach { slotId ->
                    if (Vanilla.container() !is PlayerContainer) {
                        Log.trace("Current container is: ${Vanilla.container().javaClass.name}" )
                    }
                    val stack = Vanilla.container().`(slots)`[slotId].`(vanillaStack)`
                    if (!stack.isEmpty) {
                        someThingChanged = true
                        if (!isBlocked(stack)) {
                            newlyFilled.add(slotId)
                            AutoRefillHandler.skipTick = true
                            Log.trace("${secondString}Item type: ${stack.`(itemType)`.itemId} is allowed in slot id $slotId")
                        } else if (!ignoredHotbarSlots.contains(slotId)) {
                            if (localEmptyNonLockedSlots.size > 0) {
                                AutoRefillHandler.skipTick = true
                                val targetSlot = localEmptyNonLockedSlots[0]
                                val hotBarSlot = slotId - 36
                                Log.trace("${secondString}Fast Swapping $slotId to $targetSlot")
                                ContainerClicker.swap(targetSlot,
                                                      hotBarSlot)
                                localEmptyNonLockedSlots.removeAt(0)
                            }
                        } else {
                            AutoRefillHandler.skipTick = true
                            Log.trace("${secondString}Removing $slotId from blocked")
                            ignoredHotbarSlots.remove(slotId)
                            newlyFilled.add(slotId)
                        }
                    }
                }
                if (newlyFilled.isNotEmpty()) {
                    Log.trace("Skip remove from empty is: $localSkipRemoveEmptyFor")
                    newlyFilled.removeAll(localSkipRemoveEmptyFor)
                    emptyNonLockedHotbarSlots.removeAll(newlyFilled)
                }
            }
            skipRemoveEmptyFor.isNotEmpty().ifTrue {
                emptyNonLockedHotbarSlots.addAll(skipRemoveEmptyFor)
            }
            checkHotbar()
            ignoredHotbarSlots.addAll(skipRemoveEmptyFor)
            //Yes doing the same thing twice...
            //sometimes an item is picked up in the just freed slot and it remains in the hotbar.
            //so we check twice to be sure
            if (localEmptyNonLockedSlots.isNotEmpty()) {
                checkHotbar(true)
            }
            skipRemoveEmptyFor.clear()
        }