mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Add hook for hidden lexicon categories (#2867)
This commit is contained in:
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;
|
||||
|
||||
Reference in new issue
Block a user