New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LEGACY] Inventory Management Rework #1347
Conversation
Recoded AutoArmor, InventoryCleaner and ChestStealer using coroutines. * they are executed sequentially from a coroutine in ModuleManager * added temporary modules CoroutineStealer, CoroutineArmorer, CoroutineCleaner to category Beta * order of execution: Stealer, Armorer, Cleaner * all modules clicks are scheduled to ticks from the coroutine, this prevents flags * it is possible to send multiple clicks in a tick, therefore delays are as precise as they can be when averaged, previously these clicks were scheduled from a render loop but that was fps dependent, coroutines are fps independent and as precise as possible CoroutineStealer: * can steal to target sorting slots * compares items in chests with items in inventory and even equipped armor (no duplicates hopefully) * after stealing is finished, it checks all items in chest again and if any of actions failed, steals remaining items * proper start and close delay using coroutines CoroutineArmorer: * using CoroutineArmorComparator * first correct 1.8.9 best armor calculation (LB had 1.9 calculations before) * for these calculations to be as good as possible, it finds all armor combinations and sorts them by average defense factor of the whole set * when swapping armor pieces, it doesn't just drop the worse one and equip the better one, instead, it grabs the better one, drags and swaps it with equipped one and drops the equipped one * this way there is no time of having no armor piece equipped * proper start and close delay using coroutines * can autoclose inventory, if invopen is enabled CoroutineCleaner: * using cleaning and sorting system from my InventoryManager script * better useful block comparison, no interactable blocks, half blocks, stairs, flowers and so on * no item duplicates, items are compared with their stats, durability, enchantment count, ... if both are equally good, the one that is sorted or lower in inventory wins * sorting targets allow duplicates for blocks, pearls, etc, but not for swords, tools, ... * added sorting target to Fire (lava, flint n' steel, ...) TickScheduler: * added object TickScheduler to each module * used as a bridge to TickedActions * has features like .schedule(), .scheduleClick(), +=, in, ... * added optional allowDuplicates argument to TickedActions * replaced usage of TickedActions to TickScheduler * modified TickedActions accordingly DelayTimer: * new timer that is initialised with 2 arguments (min delay value, max delay value) * every time it gets reset a random delay gets chosen * it gets checked with .hasTimePassed() with no arguments * used in Scaffold ItemUtils: * code cleanup * ItemStack.enchantments - map of all enchantments and levels, used in ItemStack.enchantmentCount, ItemStack.enchantmentSum, ItemStack.getEnchantmentLevel() * ItemStack.totalDurability = ItemStack.durability * unbreaking level Minor improvements: * made variable in Ambience private * InventoryUtils.hasSpaceHotbar() -> hasSpaceInHotbar() * BlockUtils improvements regarding block filtering * increased maximal ClickGUI fade speed * removed unnecessary ; at line ends * added InventoryUtils.hasSpaceInInventory() * replaced some .count() with .size * Iterable.shuffled(shuffle: Boolean) - shuffling based on boolean, if false, does not shuffle, used in inventory managment rework * changed refill to onTick, made it use CLICK_TIMER * CLICK_TIMER gets reset on every window click now (but its pretty useless because of this rework) * replaced some for loops with repeat loops for better readability * run block simplification
src/main/java/net/ccbluex/liquidbounce/utils/item/CoroutineArmorComparator.kt
Outdated
Show resolved
Hide resolved
* added sorting target: "Potion" * added ItemStack.isSplashPotion(), replaced use of ItemPotion.isSplashPotion(stack.metadata) with it * removed some commented out lines * fixed stack trace printing
* fixed possible NPEs * simplified code
Also improved stealing progress bar in 698a269 |
CoroutineArmorer: * improved delayedSlotSwitch: if disabled: schedules all clicks to next tick to equip 4 items at once, bypasses everything except Vulcan, Matrix, if enabled: schedules slot change and click per tick CoroutineUtils: * added waitUntil(condition) - suspends the thread with a while loop until the condition is met, used in coroutine modules TickScheduler: * added scheduleAndSuspend(vararg actions) - for scheduling multiple actions to be executed 1 per tick TickedActions: * fixed a bug: if you had an action scheduled to an id "x", you couldn't schedule another action to id "x" from it without allowing duplicates Other: * improved comments * fixed a possible NPE * moved modules to beta category package
CoroutineArmorer: * made smart armor piece swapping stable and toggleable (https://youtu.be/5QyAOE9KY0I) CoroutineCleaner: * added MaxBlockStacks, determines how many slots can be occupied by blocks (https://youtu.be/v2VYRbvb_mA) * removed separate sorting delay, just one delay is enough * fixed possible sorting / isUseful / comparison issue * stacks that were in target sorting slots had advantage even when sorting was disabled CoroutineStealer: * refactored TakeRandomized to RandomSlot Other: * refactored ItemDelay to MinItemAge * refactored ItemStack.hasItemDelayPassed to hasItemAgePassed * included delay() straight into click() and therefore simplified code * reordered values * added more comments
Interesting videos from 828feae |
Fixed major issue of waitUntil { TickScheduler.isEmpty() } not working at all because of the way how duplicated actions got managed. * caused inventory desyncs, dropping whole armor sets and so on * had to rollback TickedActions to how they were previously CoroutineArmorer: * fixed DelayedSlotSwitch still flagging on Vulcan * made armor equipping instant again * improved compatibility with CoroutineCleaner regarding inventory / simulated inventory management and closing * improved code CoroutineCleaner: * improved compatibility with CoroutineArmorer, only executes if CoroutineArmorer finished first (if InvOpen was enabled, it would drop garbage and close the inventory, without Armorer equipping armor pieces before that) More comments
Added HighlightUseful option to CoroutineCleaner * renders green esp boxes for useful items that are dropped on ground * integrated into ItemESP, uses its settings, when ItemESP is disabled it only renders useful items, otherwise it renders useful items with green color * had to make item comparison compatible with dropped items on ground * compares dropped items with inventory items + dropped items, if 2 dropped items are equally good it compares their squared distances Fixed ItemStack.totalDurability not working correctly Improved code of ESP modules
Added MaxFoodStacks * compares food by total saturation sum of the stack Now also compares dropped blocks and food items between themselves when highlighting.
Any known bugs? |
CoroutineCleaner: * added CompactStacks option InventoryUtils: * added InventoryUtils.isFirstInventoryClick - fixed start delays in coroutine modules with it Fixed possible NPE. Fixed AutoClose possibly closing too soon, if your delay settings were in sync with tick loop.
# Conflicts: # src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Scaffold.kt
Simplified inventory, hotbar slot management in modules with these.
Added util InventoryManager: * stores shared values of Armorer, Cleaner, InventoryMove, Refill, ... (NoMoveClicks and its options, for Armorer and Cleaner also start, close delay, autoclose, ...) - these values are shared between modules * handles inventory management actions one by one * if player is violating nomove or invopen, no inventory requiring actions even start waiting for nomove, because that could block hotbar equipping from doing its stuff * properly fixed unwanted autoclosing CoroutineCleaner: * added LimitStackCounts that needs to be enabled for MaxBlockStacks and such to work * renamed CompactStacks to MergeStacks * fixed stack merging and also improved it by ignoring stack limits when checking what to merge, temporarily set max merging delay to 100 * whitelisted eggs and snowballs, added a sorting category for them called "Throwable" CoroutineStealer: * now cooperates with autoarmor to equip armor pieces even while still inside a chest * fixed incorrectly assumed item swapping logic which could have problems when inventory was full * if inventory is full, garbage items or items that occupy hotbar sorting slot are now moved to chest to free up inventory space * fixed progress bar being shown in chests that were ignored because of their title or such * fixed progress bar first appearing after start delay elapsed InventoryMove: * added value SilentlyCloseAndReopen - if player violates nomove check and inventory is open, close inventory and reopen it when still * added value reopenOnClick - only reopen inventory, before a click * renamed value Undetectable to NotInChests - if you invmove when a chest is open on Polar, the chest gets closed instantly * improved code TickedActions: * fixed scheduling - nested schedules now aren't flagged as duplicates or cleared before ever being called * added TickedActions.size(module) and TickScheduler.size Fixed InventoryUtils getting into unescaped loops and freezing game by adding backing fields. * improved server inventory closing detection by checking if server sent a packet to open a different window Sprint: * added value Inventory - stops you from sprinting when serverOpenInventory == true, needed to bypass Vulcan for example MovementUtils: * added serverOnGround, serverX, serverY, serverZ - used serverOnGround to improve NoMove checks for ground * fixed hasMotion that got broken in previous commit EventManager: * simplified code * improved performance by not sorting by priority every event call Added comments. Refactored some util packages and moved some utils around.
fd33169 |
# Conflicts: # src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/AntiFireball.kt # src/main/java/net/ccbluex/liquidbounce/utils/block/BlockUtils.kt
Equipping armor while inside a chest: |
Nextgen also has this (but not indended haha) |
+ stealer no longer randomly doesn't do anything sometimes (caused by simulated inventory getting closed even with chest open) |
Improved coroutine modules * Now they only work if gamemode is survival or adventure. * Stealer now drops garbage items that block useful items from chest from being taken, when the chest is full as well... * Stealer now checks whether armor slot isn't occupied, when equipping while stealing. * Removed forgotten debug message. Improved ItemStack?.isEmpty() * Used kotlin contract to make stack smart-cast to not null ItemStack. Improved AutoPot, AutoSoup * No longer closes visually open inventory when simulating inventory closing after each click. A bit of refactoring and other minor stuff.
01e9e3c |
This is now ready to be merged to be tested by nightly users. Modules are still in their own category "Beta", not replacing the stable ones. |
👍🏻 |
Recoded AutoArmor, InventoryCleaner and ChestStealer using coroutines.
CoroutineStealer:
CoroutineArmorer:
CoroutineCleaner:
TickScheduler:
DelayTimer:
ItemUtils:
Minor improvements: