Skip to content

Commit

Permalink
Automatically remove empty research categories (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodex6824 committed Sep 11, 2024
1 parent b5fdaae commit 79e5159
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/thecodex6824/thaumcraftfix/ThaumcraftFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package thecodex6824.thaumcraftfix;

import java.nio.file.Paths;
import java.util.ArrayList;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -268,7 +269,12 @@ public void loadComplete(FMLLoadCompleteEvent event) {
ThaumcraftFixApiBridge.InternalImplementation impl = ThaumcraftFixApiBridge.implementation();
if (impl instanceof DefaultApiImplementation) {
ImmutableSet.Builder<ResearchCategory> allowed = ImmutableSet.builder();
ArrayList<ResearchCategory> empty = new ArrayList<>();
for (ResearchCategory category : ResearchCategories.researchCategories.values()) {
if (category.research.isEmpty()) {
empty.add(category);
}

for (ResearchEntry entry : category.research.values()) {
if (entry.getStages() != null) {
for (ResearchStage stage : entry.getStages()) {
Expand All @@ -289,6 +295,14 @@ public void loadComplete(FMLLoadCompleteEvent event) {
for (ResearchCategory c : ResearchCategoryTheorycraftFilter.getAllowedTheorycraftCategories()) {
logger.debug("{}", c.key);
}

if (!empty.isEmpty()) {
logger.debug("The following research categories will be removed from the game (including their Thaumonomicon tab):");
for (ResearchCategory c : empty) {
logger.debug("{}", c.key);
ResearchCategories.researchCategories.remove(c.key);
}
}
}
}

Expand Down

0 comments on commit 79e5159

Please sign in to comment.