diff --git a/MODSRC/vazkii/botania/api/LexiconEntry.java b/MODSRC/vazkii/botania/api/LexiconEntry.java index 9803c3d67..c1db19a77 100644 --- a/MODSRC/vazkii/botania/api/LexiconEntry.java +++ b/MODSRC/vazkii/botania/api/LexiconEntry.java @@ -15,21 +15,28 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.StatCollector; import vazkii.botania.api.page.LexiconPage; -public class LexiconEntry { +public class LexiconEntry implements Comparable{ public final String unlocalizedName; public List pages = new ArrayList(); - + private boolean priority = false; + /** * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. */ public LexiconEntry(String unlocalizedName) { this.unlocalizedName = unlocalizedName; } + + /** + * Sets this page as prioritized, as in, will appear before others in the lexicon. + */ + public void setPriority() { + priority = true; + } public String getUnlocalizedName() { return unlocalizedName; @@ -48,4 +55,13 @@ public class LexiconEntry { public void addPage(LexiconPage page) { pages.add(page); } -} + + public final String getNameForSorting() { + return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); + } + + @Override + public int compareTo(LexiconEntry o) { + return getNameForSorting().compareTo(o.getNameForSorting()); + } +} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/client/gui/GuiLexiconIndex.java b/MODSRC/vazkii/botania/client/gui/GuiLexiconIndex.java index ae5c81f38..952f7c2f9 100644 --- a/MODSRC/vazkii/botania/client/gui/GuiLexiconIndex.java +++ b/MODSRC/vazkii/botania/client/gui/GuiLexiconIndex.java @@ -58,14 +58,7 @@ public class GuiLexiconIndex extends GuiLexicon { entriesToDisplay.clear(); entriesToDisplay.addAll(category.entries); - Collections.sort(entriesToDisplay, new Comparator() { - - @Override - public int compare(LexiconEntry arg0, LexiconEntry arg1) { - return StatCollector.translateToLocal(arg0.getUnlocalizedName()).compareTo(StatCollector.translateToLocal(arg1.getUnlocalizedName())); - } - - }); + Collections.sort(entriesToDisplay); updatePageButtons(); populateIndex();