generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add JEI Category Sorting functionality (#257)
* add ability to sort categories * add tip for using the command to get category uids * rename mixin class * use indexOf once instead of contains
- Loading branch information
1 parent
c3d8582
commit aef4323
Showing
6 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/ModRegistryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.cleanroommc.groovyscript.core.mixin.jei; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.jei.JeiPlugin; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import mezz.jei.recipes.RecipeRegistry; | ||
import mezz.jei.startup.ModRegistry; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(value = ModRegistry.class, remap = false) | ||
public abstract class ModRegistryMixin { | ||
|
||
@Shadow | ||
@Final | ||
private List<IRecipeCategory<?>> recipeCategories; | ||
|
||
/** | ||
* @reason Sort recipe categories according to a list created and managed by GroovyScript | ||
* to allow a custom order for JEI category tabs. | ||
* @see JeiPlugin#getCategoryComparator() | ||
*/ | ||
@Inject(method = "createRecipeRegistry", at = @At("HEAD")) | ||
private void grs$sortRecipeCategories(CallbackInfoReturnable<RecipeRegistry> ci) { | ||
recipeCategories.sort(JeiPlugin.getCategoryComparator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters