feature(AutoTool): Delay switch Item - #8542
Conversation
|
Thanks for working on this! I noticed a few issues with the current approach and wanted to suggest an alternative: Issues
Suggested approachInstead of a private val switchDelay by int("SwitchDelay", 0, 0..20, "ticks")
private var breakingPos: BlockPos? = null
private var breakingTicks = 0
@Suppress("unused")
private val handleBlockBreakingProgress = handler<BlockBreakingProgressEvent> { event ->
if (event.pos == breakingPos) {
breakingTicks++
} else {
breakingPos = event.pos
breakingTicks = 0
}
if (breakingTicks >= switchDelay) {
switchToBreakBlock(event.pos)
}
}
@Suppress("unused")
private val handleCancelBlockBreaking = handler<CancelBlockBreakingEvent> {
breakingPos = null
breakingTicks = 0
if (isInventoryConsidered) {
DynamicSelectMode.ConsiderInventory.onNoTool()
}
}Key differences:
Also consider renaming to Happy to help if you'd like — I can push a commit to your branch or open an alternative PR. Let me know! |
|
Regarding the item exclusion feature you mentioned — here's how to implement it using the existing // Add these fields after the existing settings (e.g. after notDuringCombat):
private val heldItemFilter by enumChoice("HeldItemFilter", Filter.BLACKLIST)
private val heldItems by items("HeldItems", mutableListOf())Then add a check at the top of fun switchToBreakBlock(pos: BlockPos) {
// Don't swap away from excluded items (e.g. sword during combat, totem, etc.)
val currentItem = player.mainHandItem.item
if (!heldItemFilter(currentItem, heldItems)) {
return
}
val cancelDueToCombat = notDuringCombat && CombatManager.isInCombat
// ... rest of existing logic
}That's it — the What this does:
The import you need is already there: Combined with the delay approach from my previous comment, the full feature becomes:
Let me know if you want me to push this to your branch directly! |
|
For the suggested approach, I still prefer using waitTicks() i dont want a custom one sorry. But i did consider that option but chose not to use it. |
|
I think i fixed the issue on CivMineMode and SwitchMethod? But i did added the Exclusion. Sorry don't have the time to test right now. |
Yes, this should be fixed! |
|
Please split 2 features into independent PRs |
|
ok 👍 |
|
i'll do exclusion some time later |
|
messed this up, oops. |
Meant for this Feature Request
Adds delay/activation time to swapping items, Also adds a filter list.
Whitelist: Skips delay everything else gets delay
Blacklist: The items ticked is delayed, everything else has no delay
Not sure if thats what they wanted might have misunderstood.