4343import org .geysermc .geyser .inventory .recipe .GeyserStonecutterData ;
4444import org .geysermc .geyser .inventory .recipe .TrimRecipe ;
4545import org .geysermc .geyser .item .Items ;
46- import org .geysermc .geyser .registry .Registries ;
4746import org .geysermc .geyser .registry .type .ItemMapping ;
4847import org .geysermc .geyser .session .GeyserSession ;
4948import org .geysermc .geyser .translator .item .ItemTranslator ;
5857
5958import java .util .ArrayList ;
6059import java .util .Collections ;
61- import java .util .Comparator ;
6260import java .util .List ;
6361import java .util .Objects ;
6462import java .util .UUID ;
@@ -117,7 +115,7 @@ public void translate(GeyserSession session, ClientboundUpdateRecipesPacket pack
117115 session .getGeyser ().getLogger ().debug ("Using old smithing table workaround? " + oldSmithingTable );
118116 session .setOldSmithingTable (oldSmithingTable );
119117
120- Int2ObjectMap <List <SelectableRecipe >> unsortedStonecutterData = new Int2ObjectOpenHashMap <>();
118+ Int2ObjectMap <List <SelectableRecipe >> rawStonecutterData = new Int2ObjectOpenHashMap <>();
121119
122120 List <SelectableRecipe > stonecutterRecipes = packet .getStonecutterRecipes ();
123121 for (SelectableRecipe recipe : stonecutterRecipes ) {
@@ -131,19 +129,15 @@ public void translate(GeyserSession session, ClientboundUpdateRecipesPacket pack
131129 session .getGeyser ().getLogger ().debug ("Ignoring stonecutter recipe for weird output: " + recipe );
132130 continue ;
133131 }
134- unsortedStonecutterData .computeIfAbsent (ingredient .getHolders ()[0 ], $ -> new ArrayList <>()).add (recipe );
132+ rawStonecutterData .computeIfAbsent (ingredient .getHolders ()[0 ], $ -> new ArrayList <>()).add (recipe );
135133 }
136134
137135 Int2ObjectMap <GeyserStonecutterData > stonecutterRecipeMap = new Int2ObjectOpenHashMap <>();
138- for (Int2ObjectMap .Entry <List <SelectableRecipe >> data : unsortedStonecutterData .int2ObjectEntrySet ()) {
139- // Sort the list by each output item's Java identifier - this is how it's sorted on Java, and therefore
140- // We can get the correct order for button pressing
141- data .getValue ().sort (Comparator .comparing ((stoneCuttingRecipeData ->
142- Registries .JAVA_ITEMS .get ().get (((ItemStackSlotDisplay ) stoneCuttingRecipeData .recipe ()).itemStack ().getId ())
143- // See RecipeManager#getRecipesFor as of 1.21
144- .translationKey ())));
145-
146- // Now that it's sorted, let's translate these recipes
136+ for (Int2ObjectMap .Entry <List <SelectableRecipe >> data : rawStonecutterData .int2ObjectEntrySet ()) {
137+ // Implementation note: data used to have to be sorted according to the item translation key.
138+ // This is no longer necessary as of 1.21.2, and is instead presented in the order the server sends us.
139+ // (Recipes are ordered differently between Paper and vanilla)
140+ // See #5150.
147141 int buttonId = 0 ;
148142 for (SelectableRecipe recipe : data .getValue ()) {
149143 // As of 1.16.4, all stonecutter recipes have one ingredient option
0 commit comments