mojira.dev
MC-123739

Recipe book entries are no longer sorted in any meaningful manner

Recipe book entries are not sorted in any meaningful manner (even changing randomly upon reloading) leading to inconsistent and confusing usage of the recipe book. This is especially interesting, considering that the recipe book used to be sorted alphabetically, and that block sets were grouped together. Here is a demonstration:

[media]

How to reproduce

  1. Give the player all vanilla recipes

    /recipe give @p *
  2. Place down a crafting table

  3. Open the recipe book

  4. Set to "Showing All" mode

Observed & Expected behavior

❌ - The item recipes will be randomly placed with no real rhyme or reason for where they are inside each category, leaving the player to search through each category randomly to find the item they want to craft.
✔ - Each recipe entry would be neatly sorted by item type, colors, category, etc. just as the creative inventory is currently.

Suggested fix:

Either sort the recipe book categories by their alphabetical order, color, id, or just as the creative inventory is done.

Code analysis:

(Mappings: MCP Reborn 1.20.2 // Class: RecipeBookComponent.java // Method: updateCollections(boolean)):

private void updateCollections(boolean p_100383_) {
      List<RecipeCollection> list = this.book.getCollection(this.selectedTab.getCategory());
      list.forEach((p_296197_) -> p_296197_.canCraft(this.stackedContents, this.menu.getGridWidth(), this.menu.getGridHeight(), this.book));
      List<RecipeCollection> list1 = Lists.newArrayList(list);
      list1.removeIf((p_100368_) -> !p_100368_.hasKnownRecipes());
      list1.removeIf((p_100360_) -> !p_100360_.hasFitting());
      String s = this.searchBox.getValue();
      if (!s.isEmpty()) {
         ObjectSet<RecipeCollection> objectset = new ObjectLinkedOpenHashSet<>(this.minecraft.getSearchTree(SearchRegistry.RECIPE_COLLECTIONS).search(s.toLowerCase(Locale.ROOT)));
         list1.removeIf((p_301525_) -> !objectset.contains(p_301525_));
      }

      if (this.book.isFiltering(this.menu)) {
         list1.removeIf((p_100331_) -> !p_100331_.hasCraftable());
      }

      this.recipeBookPage.updateCollections(list1, p_100383_);
   }

Here, the result list list1 is not sorted in any way before passing it to RecipeBookPage.updateCollections, which does pagination and layout of the recipes onto the buttons of each page.

Linked issues

Attachments

Comments 8

Can confirm for 1.16.3/1.16.4PR1

Can confirm for 21w03a, there is some order, but very little

Can confirm in 1.16.5 and 21w08b.

Still an issue on 1.18.x, would be much better if entries were to be sorted by either output item or recipe ID.

Can confirm in 1.20.1. Walls and Bamboo Mosaic are in the items tab instead of the building blocks tab. The tabs need reorganization.

This is for sorting within a tab, not for which tab a recipe is assigned. Make a seperate report for that.

RE Alex: while I agree, that leaves recipe groups. Recipe groups are a plain string and not namespaced, so how should they be sorted? Based on the first recipe ID?

Can confirm in 23w46a. I would like to request ownership of this issue to maintain it going forward seeing as the original poster is inactive since 2020.
Specifically, I would like to add actual code to the analysis, as currently it is just an explanation.

Fixed in 24w40a. The recipe book is now sorted alphabetically

24w39a:

[media]

24w40a:

[media]

williewillus

[Mod] Jingy

(Unassigned)

Confirmed

Gameplay

Normal

Crafting, UI

category, recipe-book, sorting

Minecraft 1.12.2, Minecraft 17w50a, Minecraft 1.13-pre1, Minecraft 1.13.1, 1.15.1, ..., 24w09a, 24w11a, 1.20.5 Pre-Release 1, 1.20.5, 1.21

24w40a

Retrieved