From cf3dd0719c25f997966f21f7028e39160663b3ed Mon Sep 17 00:00:00 2001 From: Captain_D1 <8715584+CaptainD1@users.noreply.github.com> Date: Mon, 20 May 2024 19:30:55 -0400 Subject: [PATCH] Workbench recipes are now sorted alphabetically by ID --- .../guns/client/screen/WorkbenchScreen.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/mrcrayfish/guns/client/screen/WorkbenchScreen.java b/src/main/java/com/mrcrayfish/guns/client/screen/WorkbenchScreen.java index e5034e3bd..2c3728a68 100644 --- a/src/main/java/com/mrcrayfish/guns/client/screen/WorkbenchScreen.java +++ b/src/main/java/com/mrcrayfish/guns/client/screen/WorkbenchScreen.java @@ -44,6 +44,7 @@ import java.awt.*; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -112,6 +113,7 @@ else if(this.isAmmo(output)) if(!weapons.isEmpty()) { + this.sortRecipes(weapons); ItemStack icon = new ItemStack(ModItems.ASSAULT_RIFLE.get()); icon.getOrCreateTag().putInt("AmmoCount", ModItems.ASSAULT_RIFLE.get().getGun().getGeneral().getMaxAmmo()); this.tabs.add(new Tab(icon, "weapons", weapons)); @@ -119,16 +121,19 @@ else if(this.isAmmo(output)) if(!attachments.isEmpty()) { + this.sortRecipes(attachments); this.tabs.add(new Tab(new ItemStack(ModItems.LONG_SCOPE.get()), "attachments", attachments)); } if(!ammo.isEmpty()) { + this.sortRecipes(ammo); this.tabs.add(new Tab(new ItemStack(ModItems.SHELL.get()), "ammo", ammo)); } if(!misc.isEmpty()) { + this.sortRecipes(misc); this.tabs.add(new Tab(new ItemStack(Items.BARRIER), "misc", misc)); } @@ -156,6 +161,15 @@ private boolean isAmmo(ItemStack stack) return false; } + private void sortRecipes(List recipes) { + Collections.sort( + recipes, + (recipe1, recipe2) -> + recipe1.getItem().getDescriptionId().compareTo( + recipe2.getItem().getDescriptionId()) + ); + } + @Override public void init() {