From 27d7a862b5ac3f4c2aebd72a184a651550874d58 Mon Sep 17 00:00:00 2001 From: Diet Cola Date: Sun, 8 Mar 2026 17:49:55 +1100 Subject: [PATCH] Truncate Factory Recipes in GUI --- .../FactoryMod/utility/FactoryModGUI.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/utility/FactoryModGUI.java b/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/utility/FactoryModGUI.java index 0e018e4792..5ca9f46c5a 100644 --- a/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/utility/FactoryModGUI.java +++ b/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/utility/FactoryModGUI.java @@ -101,13 +101,7 @@ String toText() { lore.add(ChatColor.DARK_AQUA + "Fuel: " + ChatColor.GRAY + ItemUtils.getItemName(fccEgg.getFuel().getType())); lore.add(""); lore.add(ChatColor.GOLD + String.valueOf(fccEgg.getRecipes().size() + " recipes:")); - for (IRecipe rec : fccEgg.getRecipes()) { - if (rec instanceof Upgraderecipe) { - lore.add(ChatColor.GRAY + " - " + ChatColor.GREEN + rec.getName()); - } else { - lore.add(ChatColor.GRAY + " - " + ChatColor.AQUA + rec.getName()); - } - } + lore.addAll(buildTruncatedList(fccEgg.getRecipes(), 15)); ItemUtils.addLore(is, lore); clicks.add(new LClickable(is, p -> { showForFactory(fccEgg); @@ -370,6 +364,35 @@ private FurnCraftChestEgg getParent(FurnCraftChestEgg factory) { return upgradeMapping.get(factory); } + private List buildTruncatedList(List input, int maxSize) { + int totalElements = input.size(); + List loreList = new ArrayList<>(); + + if (totalElements <= maxSize) { + for (IRecipe item : input) { + if (item instanceof Upgraderecipe) { + loreList.add(ChatColor.GRAY + " - " + ChatColor.GREEN + item.getName()); + } else { + loreList.add(ChatColor.GRAY + " - " + ChatColor.AQUA + item.getName()); + } + } + } else { + List subListForDisplay = input.subList(0, maxSize); + + for (IRecipe item : subListForDisplay) { + if (item instanceof Upgraderecipe) { + loreList.add(ChatColor.GRAY + " - " + ChatColor.GREEN + item.getName()); + } else { + loreList.add(ChatColor.GRAY + " - " + ChatColor.AQUA + item.getName()); + } + } + + int remainingCount = totalElements - maxSize; + loreList.add(ChatColor.GRAY + "... click for " + remainingCount + " other recipes"); + } + return loreList; + } + private abstract class FMCHistoryItem implements HistoryItem { abstract String toText();