Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.item.Items;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class JalistAutoPaginator {
Expand Down Expand Up @@ -57,7 +58,7 @@ public void startAutoPagination() {
logToChat("Starting JAList auto-pagination... This will read all pages automatically.");

// Start the first page click immediately
mc.execute(this::clickNextPage);
mc.execute(() -> clickNextPage(((AbstractContainerScreen<?>) mc.screen).getMenu().getItems()));
}

public void stopAutoPagination() {
Expand Down Expand Up @@ -89,7 +90,7 @@ public void stopAutoPagination() {
}
}

public void onJalistPageLoaded(int snitchCount) {
public void onJalistPageLoaded(List<ItemStack> stacks, int snitchCount) {
if (!isActive) return;

pagesProcessed++;
Expand All @@ -102,7 +103,7 @@ public void onJalistPageLoaded(int snitchCount) {
}

// Click next page instantly on page load for maximum speed
mc.execute(this::clickNextPage);
mc.execute(() -> clickNextPage(stacks));
}

public void addSnitchEntry(String group, long dormantTs, long cullTs) {
Expand All @@ -122,7 +123,7 @@ public void addSnitchEntry(String group, long dormantTs, long cullTs) {
}
}

private void clickNextPage() {
private void clickNextPage(List<ItemStack> stacks) {
if (!isActive || waitingForNextPage) {
return;
}
Expand All @@ -140,13 +141,12 @@ private void clickNextPage() {

// Get the next page button (arrow in slot 53)
var container = containerScreen.getMenu();

if (container.slots.size() <= NEXT_PAGE_SLOT) {
if (stacks.size() <= NEXT_PAGE_SLOT) {
stopAutoPagination();
return;
}
ItemStack nextPageItem = container.getSlot(NEXT_PAGE_SLOT).getItem();

ItemStack nextPageItem = stacks.get(NEXT_PAGE_SLOT);

// Check if there's a next page (should be an arrow item)
if (nextPageItem.isEmpty() || !isArrowItem(nextPageItem)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void handleWindowItems(List<ItemStack> stacks) {
if (jalistEntries.size() > 0) {
// Notify auto-paginator that this page was processed
if (JalistAutoPaginator.getInstance().isActive()) {
JalistAutoPaginator.getInstance().onJalistPageLoaded(jalistEntries.size());
JalistAutoPaginator.getInstance().onJalistPageLoaded(stacks, jalistEntries.size());
} else {
logToChat(Component.literal("Found " + jalistEntries.size() + " snitches on JAList page"));
}
Expand Down
Loading