feat(AutoAnvil): Auto Anvil module to automatically rename and combine items#277
feat(AutoAnvil): Auto Anvil module to automatically rename and combine items#277IceTank wants to merge 1 commit intolambda-client:1.21.11from
Conversation
beanbag44
left a comment
There was a problem hiding this comment.
the renaming functionality doesn't seem to work for me. It wouldnt take it out of the result slot and would pull already renamed items into the renaming slot. The combining feature also doesnt work for me when combing two of the same item
|
|
||
| init { | ||
| listen<TickEvent.Pre> { | ||
| val playerLevel = player.experienceLevel |
|
|
||
| val sh = player.currentScreenHandler | ||
| if (sh !is AnvilScreenHandler) return@listen | ||
| if (rename && renameName.isNotEmpty()) { |
There was a problem hiding this comment.
you can rename items with a custom name to nothing to return them back to the items default name
| val freeInvSlot = StackSelection.selectStack().filterSlots(InventoryContainer.slots).any { it.stack.isEmpty } | ||
|
|
||
| if (!output.stack.isEmpty && !freeInvSlot) return false | ||
| if (hasName(output) && output != null) { |
There was a problem hiding this comment.
if output could be null, this would have crashed before getting here. I think its safe to assume that its not null as OUTPUT_ID is a guaranteed slot in the AnvilScreenHandler
|
|
||
| private fun handleCombining(sh: AnvilScreenHandler) { | ||
| if (!delayTimer.timePassed(150.milliseconds)) return | ||
| for ((item1, item2) in combineMap) { |
There was a problem hiding this comment.
we try to use forEach instead of for loops if we can
| description = "Automatically renames or combines items", | ||
| tag = ModuleTag.PLAYER | ||
| ) { | ||
| var rename by setting("Rename", false) |
There was a problem hiding this comment.
visibility should be added to renameName, itemsToRename, etc to show and hide when these settings are toggled
| .firstOrNull { it.stack.customName == null || it.stack.customName?.equals(renameName) == false } | ||
| } | ||
|
|
||
| enum class Group(override val displayName: String) : NamedEnum { |
There was a problem hiding this comment.
just a nit pick, not important but i usually put the group enum at the top ish of the class to show what sections of the settings there are
| listen<GuiEvent.NewFrame> { | ||
| if (!combine) return@listen | ||
| if (mc.currentScreen !is AnvilScreen && mc.currentScreen !is LambdaScreen) return@listen | ||
| window("Combine Mapping", open = ImBoolean(true)) { |
There was a problem hiding this comment.
can remove the ImBoolean(true) here as that only adds a redundant close button
| /** | ||
| * A utility class to select none or one item from a collection, with a search filter and a scrollable list. | ||
| */ | ||
| class SearchBox(val name: String, val immutableCollectionProvider: () -> Collection<String>) { |
There was a problem hiding this comment.
typing in the search bar while in the anvil screen causes you to type in both the search bar and the rename section in the anvil gui
|
|
||
| if (foundItem1 != null && foundItem2 != null && input1.stack.isEmpty && input2.stack.isEmpty) { | ||
| val done = inventoryRequest { | ||
| click(foundItem1.id, 0, SlotActionType.QUICK_MOVE) |
|
|
||
| if (input1.stack.item.name.string.equals(item1) && input2.stack.item.name.string.equals(item2)) { | ||
| val done = inventoryRequest { | ||
| click(output.id, 0, SlotActionType.QUICK_MOVE) |
This module can automatically rename items and combine them