Add hook for hidden lexicon categories (#2867)

This commit is contained in:
Hubry authored and Vincent Lee committed 2019-06-02 12:40:11 -07:00
1 parent 4affec10a9
commit 843fa2fd06
2 files changed
+15 -5

No files matched your search

@@ -10,6 +10,7 @@
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
@@ -74,4 +75,14 @@ public class LexiconCategory implements Comparable<LexiconCategory> {
public int compareTo(@Nonnull LexiconCategory category) {
return priority == category.priority ? sortingId - category.sortingId : category.priority - priority;
}
/**
* Determines if the category shows up in the lexicon category index.
* Contained entries will still appear in the lexicon index
* and must be hidden separately if desired.
* @param stack The lexicon stack used by the player
*/
public boolean isVisible(ItemStack stack) {
return true;
}
}
@@ -111,8 +111,6 @@ public class GuiLexicon extends GuiScreen {
public String note = "";
public String categoryHighlight = "";
List<LexiconCategory> allCategories;
String title;
final int guiWidth = 146;
final int guiHeight = 180;
@@ -148,9 +146,6 @@ public class GuiLexicon extends GuiScreen {
mc.gameSettings.guiScale = guiScale;
}
allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
Collections.sort(allCategories);
lastTime = ClientTickHandler.ticksInGame;
title = ItemLexicon.getTitle(stackUsed);
@@ -168,6 +163,10 @@ public class GuiLexicon extends GuiScreen {
}
populateIndex();
} else if(isCategoryIndex()) {
List<LexiconCategory> allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
allCategories.removeIf(cat -> !cat.isVisible(stackUsed));
Collections.sort(allCategories);
int categories = allCategories.size();
for(int i = 0; i < categories + 1; i++) {
LexiconCategory category;