Skip to content

feat(AutoAnvil): Auto Anvil module to automatically rename and combine items#277

Open
IceTank wants to merge 1 commit intolambda-client:1.21.11from
IceTank:feature/auto-anvil
Open

feat(AutoAnvil): Auto Anvil module to automatically rename and combine items#277
IceTank wants to merge 1 commit intolambda-client:1.21.11from
IceTank:feature/auto-anvil

Conversation

@IceTank
Copy link
Copy Markdown
Contributor

@IceTank IceTank commented Mar 22, 2026

This module can automatically rename items and combine them

@github-project-automation github-project-automation bot moved this to Backlog in Kanban Mar 22, 2026
@beanbag44 beanbag44 self-requested a review March 25, 2026 16:31
Copy link
Copy Markdown
Member

@beanbag44 beanbag44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can inline this value


val sh = player.currentScreenHandler
if (sh !is AnvilScreenHandler) return@listen
if (rename && renameName.isNotEmpty()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quickMove()


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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quickMove()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants