diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index a2c2ef7b1f4..9b920a7239f 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -106,6 +106,8 @@ public class RecipeMap> { private int maxFluidInputs; private int maxFluidOutputs; + private final GTRecipeCategory primaryRecipeCategory; + /** * @deprecated {@link RecipeMapUI#isJEIVisible()} */ @@ -128,80 +130,6 @@ public class RecipeMap> { protected @Nullable SoundEvent sound; private @Nullable RecipeMap smallRecipeMap; - /** - * Create and register new instance of RecipeMap with specified properties. All - * maximum I/O size for item and fluids will be able to be modified. - * - * @param unlocalizedName the unlocalized name for the RecipeMap - * @param maxInputs the maximum item inputs - * @param maxOutputs the maximum item outputs - * @param maxFluidInputs the maximum fluid inputs - * @param maxFluidOutputs the maximum fluid outputs - * @param defaultRecipeBuilder the default RecipeBuilder for the RecipeMap - * @param isHidden if the RecipeMap should have a category in JEI - * - * @deprecated {@link RecipeMap#RecipeMap(String, R, RecipeMapUIFunction, int, int, int, int)} - */ - @ApiStatus.ScheduledForRemoval(inVersion = "2.9") - @Deprecated - public RecipeMap(@NotNull String unlocalizedName, - int maxInputs, int maxOutputs, int maxFluidInputs, int maxFluidOutputs, - @NotNull R defaultRecipeBuilder, - boolean isHidden) { - this(unlocalizedName, - maxInputs, true, maxOutputs, true, - maxFluidInputs, true, maxFluidOutputs, true, - defaultRecipeBuilder, isHidden); - } - - /** - * Create and register new instance of RecipeMap with specified properties. - * - * @param unlocalizedName the unlocalized name for the RecipeMap - * @param maxInputs the maximum item inputs - * @param modifyItemInputs if modification of the maximum item input is permitted - * @param maxOutputs the maximum item outputs - * @param modifyItemOutputs if modification of the maximum item output is permitted - * @param maxFluidInputs the maximum fluid inputs - * @param modifyFluidInputs if modification of the maximum fluid input is permitted - * @param maxFluidOutputs the maximum fluid outputs - * @param modifyFluidOutputs if modification of the maximum fluid output is permitted - * @param defaultRecipeBuilder the default RecipeBuilder for the RecipeMap - * @param isHidden if the RecipeMap should have a category in JEI - * - * @deprecated {@link RecipeMap#RecipeMap(String, R, RecipeMapUIFunction, int, int, int, int)} - */ - @ApiStatus.ScheduledForRemoval(inVersion = "2.9") - @Deprecated - public RecipeMap(@NotNull String unlocalizedName, - int maxInputs, boolean modifyItemInputs, - int maxOutputs, boolean modifyItemOutputs, - int maxFluidInputs, boolean modifyFluidInputs, - int maxFluidOutputs, boolean modifyFluidOutputs, - @NotNull R defaultRecipeBuilder, - boolean isHidden) { - this.unlocalizedName = unlocalizedName; - - this.maxInputs = maxInputs; - this.maxFluidInputs = maxFluidInputs; - this.maxOutputs = maxOutputs; - this.maxFluidOutputs = maxFluidOutputs; - - defaultRecipeBuilder.setRecipeMap(this); - defaultRecipeBuilder - .category(GTRecipeCategory.create(GTValues.MODID, unlocalizedName, getTranslationKey(), this)); - this.recipeBuilderSample = defaultRecipeBuilder; - - this.recipeMapUI = new RecipeMapUI<>(this, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, - modifyFluidOutputs, false); - this.recipeMapUI.setJEIVisible(!isHidden); - - RECIPE_MAP_REGISTRY.put(unlocalizedName, this); - - this.grsVirtualizedRecipeMap = GregTechAPI.moduleManager.isModuleEnabled(GregTechModules.MODULE_GRS) ? - new VirtualizedRecipeMap(this) : null; - } - /** * Create and register new instance of RecipeMap with specified properties. * @@ -223,10 +151,11 @@ public RecipeMap(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilde this.maxFluidInputs = maxFluidInputs; this.maxOutputs = maxOutputs; this.maxFluidOutputs = maxFluidOutputs; + this.primaryRecipeCategory = GTRecipeCategory.create(GTValues.MODID, unlocalizedName, getTranslationKey(), + this); defaultRecipeBuilder.setRecipeMap(this); - defaultRecipeBuilder - .category(GTRecipeCategory.create(GTValues.MODID, unlocalizedName, getTranslationKey(), this)); + defaultRecipeBuilder.category(primaryRecipeCategory); this.recipeBuilderSample = defaultRecipeBuilder; RECIPE_MAP_REGISTRY.put(unlocalizedName, this); @@ -1514,6 +1443,10 @@ public void setRecipeMapUI(@NotNull RecipeMapUI recipeMapUI) { this.recipeMapUI = recipeMapUI; } + public @NotNull GTRecipeCategory getPrimaryRecipeCategory() { + return primaryRecipeCategory; + } + @Override @ZenMethod public String toString() { diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 24e52ad07ce..2aa466d5f67 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -49,6 +49,8 @@ public class RecipeMapBuilder> { private @Nullable Map> buildActions; + private boolean sortToBack; + /** * @param unlocalizedName the name of the recipemap * @param defaultRecipeBuilder the default recipe builder of the recipemap @@ -282,6 +284,18 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } + /** + * Have the primary {@link gregtech.api.recipes.category.GTRecipeCategory} for the RecipeMap be sorted to the end + * of the JEI recipe category list. + * + * @param sortToBack if it should be sorted to the back + * @return this + */ + public @NotNull RecipeMapBuilder jeiSortToBack(boolean sortToBack) { + this.sortToBack = sortToBack; + return this; + } + /** * Do not call this twice. RecipeMapBuilders are not re-usable. * @@ -297,6 +311,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip if (buildActions != null) { recipeMap.onRecipeBuild(buildActions); } + recipeMap.getPrimaryRecipeCategory().jeiSortToBack(sortToBack); return recipeMap; } } diff --git a/src/main/java/gregtech/api/recipes/category/GTRecipeCategory.java b/src/main/java/gregtech/api/recipes/category/GTRecipeCategory.java index d6da4e55aef..d92c96899d3 100644 --- a/src/main/java/gregtech/api/recipes/category/GTRecipeCategory.java +++ b/src/main/java/gregtech/api/recipes/category/GTRecipeCategory.java @@ -5,7 +5,10 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; +import java.util.Collection; +import java.util.Collections; import java.util.Map; public final class GTRecipeCategory { @@ -18,6 +21,7 @@ public final class GTRecipeCategory { private final String translationKey; private final RecipeMap recipeMap; private Object icon; + private boolean sortToBack; /** * Create a GTRecipeCategory @@ -44,11 +48,18 @@ public static GTRecipeCategory getByName(@NotNull String categoryName) { return categories.get(categoryName); } + /** + * @return all of the GTRecipeCategory instances + */ + public static @NotNull @UnmodifiableView Collection getCategories() { + return Collections.unmodifiableCollection(categories.values()); + } + private GTRecipeCategory(@NotNull String modid, @NotNull String name, @NotNull String translationKey, @NotNull RecipeMap recipeMap) { this.modid = modid; this.name = name; - this.uniqueID = modid + ':' + this.name; + this.uniqueID = modid + '.' + this.name; this.translationKey = translationKey; this.recipeMap = recipeMap; } @@ -85,7 +96,7 @@ public RecipeMap getRecipeMap() { * @param icon the icon to use as a JEI category * @return this */ - public GTRecipeCategory jeiIcon(@Nullable Object icon) { + public @NotNull GTRecipeCategory jeiIcon(@Nullable Object icon) { this.icon = icon; return this; } @@ -95,6 +106,19 @@ public Object getJEIIcon() { return this.icon; } + /** + * @param sortToBack if the category should be at the end of the JEI category list + * @return this + */ + public @NotNull GTRecipeCategory jeiSortToBack(boolean sortToBack) { + this.sortToBack = sortToBack; + return this; + } + + public boolean shouldSortToBackJEI() { + return sortToBack; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/gregtech/api/recipes/category/RecipeCategories.java b/src/main/java/gregtech/api/recipes/category/RecipeCategories.java index 1eee70a5607..703beac5443 100644 --- a/src/main/java/gregtech/api/recipes/category/RecipeCategories.java +++ b/src/main/java/gregtech/api/recipes/category/RecipeCategories.java @@ -10,19 +10,22 @@ public final class RecipeCategories { "arc_furnace_recycling", "gregtech.recipe.category.arc_furnace_recycling", RecipeMaps.ARC_FURNACE_RECIPES) - .jeiIcon(GuiTextures.ARC_FURNACE_RECYLCING_CATEGORY); + .jeiIcon(GuiTextures.ARC_FURNACE_RECYLCING_CATEGORY) + .jeiSortToBack(true); public static final GTRecipeCategory MACERATOR_RECYCLING = GTRecipeCategory.create(GTValues.MODID, "macerator_recycling", "gregtech.recipe.category.macerator_recycling", RecipeMaps.MACERATOR_RECIPES) - .jeiIcon(GuiTextures.MACERATOR_RECYLCING_CATEGORY); + .jeiIcon(GuiTextures.MACERATOR_RECYLCING_CATEGORY) + .jeiSortToBack(true); public static final GTRecipeCategory EXTRACTOR_RECYCLING = GTRecipeCategory.create(GTValues.MODID, "extractor_recycling", "gregtech.recipe.category.extractor_recycling", RecipeMaps.EXTRACTOR_RECIPES) - .jeiIcon(GuiTextures.EXTRACTOR_RECYLCING_CATEGORY); + .jeiIcon(GuiTextures.EXTRACTOR_RECYLCING_CATEGORY) + .jeiSortToBack(true); private RecipeCategories() {} } diff --git a/src/main/java/gregtech/api/recipes/machines/RecipeMapResearchStation.java b/src/main/java/gregtech/api/recipes/machines/RecipeMapResearchStation.java index de0295359cc..0df34aeb61b 100644 --- a/src/main/java/gregtech/api/recipes/machines/RecipeMapResearchStation.java +++ b/src/main/java/gregtech/api/recipes/machines/RecipeMapResearchStation.java @@ -16,5 +16,6 @@ public RecipeMapResearchStation(@NotNull String unlocalizedName, @NotNull R defa @NotNull RecipeMapUIFunction recipeMapUI) { super(unlocalizedName, defaultRecipeBuilder, recipeMapUI, 2, 1, 0, 0); setSound(GTValues.FOOLS.get() ? GTSoundEvents.SCIENCE : GTSoundEvents.COMPUTATION); + getPrimaryRecipeCategory().jeiSortToBack(true); } } diff --git a/src/main/java/gregtech/api/recipes/machines/RecipeMapScanner.java b/src/main/java/gregtech/api/recipes/machines/RecipeMapScanner.java index f76c7b10814..4e3a774536b 100644 --- a/src/main/java/gregtech/api/recipes/machines/RecipeMapScanner.java +++ b/src/main/java/gregtech/api/recipes/machines/RecipeMapScanner.java @@ -25,6 +25,7 @@ public RecipeMapScanner(@NotNull String unlocalizedName, @NotNull SimpleRecipeBu @NotNull RecipeMapUIFunction recipeMapUI) { super(unlocalizedName, defaultRecipeBuilder, recipeMapUI, 2, 1, 1, 0); setSound(GTSoundEvents.ELECTROLYZER); + getPrimaryRecipeCategory().jeiSortToBack(true); } @Override diff --git a/src/main/java/gregtech/common/ConfigHolder.java b/src/main/java/gregtech/common/ConfigHolder.java index 7976970c6bb..93cbb1dbdcf 100644 --- a/src/main/java/gregtech/common/ConfigHolder.java +++ b/src/main/java/gregtech/common/ConfigHolder.java @@ -465,6 +465,9 @@ public static class ClientOptions { "Default: true" }) public boolean enableFancyChestRender = true; + @Config.Comment({ "Whether to prefer the Material Tree over other categories in JEI", "Default: false" }) + public boolean preferMaterialTreeInJEI = false; + public static class GuiConfig { @Config.Comment({ "The scrolling speed of widgets", "Default: 13" }) diff --git a/src/main/java/gregtech/integration/jei/JustEnoughItemsModule.java b/src/main/java/gregtech/integration/jei/JustEnoughItemsModule.java index 1dd161878ed..c0a70ea2be6 100644 --- a/src/main/java/gregtech/integration/jei/JustEnoughItemsModule.java +++ b/src/main/java/gregtech/integration/jei/JustEnoughItemsModule.java @@ -27,6 +27,7 @@ import gregtech.api.worldgen.config.BedrockFluidDepositDefinition; import gregtech.api.worldgen.config.OreDepositDefinition; import gregtech.api.worldgen.config.WorldGenRegistry; +import gregtech.common.ConfigHolder; import gregtech.common.blocks.MetaBlocks; import gregtech.common.items.MetaItems; import gregtech.common.items.ToolItems; @@ -70,16 +71,20 @@ import mezz.jei.api.JEIPlugin; import mezz.jei.api.ingredients.IIngredientRegistry; import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeCategoryRegistration; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.config.Constants; import mezz.jei.input.IShowsRecipeFocuses; import mezz.jei.input.InputHandler; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -156,7 +161,7 @@ public void register(IModRegistry registry) { ModularUIGuiHandler modularUIGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper()); modularUIGuiHandler.blacklistCategory( IntCircuitCategory.UID, - GTValues.MODID + ":material_tree", + MaterialTreeCategory.UID, VanillaRecipeCategoryUid.INFORMATION, VanillaRecipeCategoryUid.FUEL); registry.getRecipeTransferRegistry().addRecipeTransferHandler(modularUIGuiHandler, @@ -255,8 +260,7 @@ public void register(IModRegistry registry) { } } - String oreByProductId = GTValues.MODID + ":" + "ore_by_product"; - registry.addRecipes(oreByproductList, oreByProductId); + registry.addRecipes(oreByproductList, OreByProductCategory.UID); MetaTileEntity[][] machineLists = { MetaTileEntities.MACERATOR, MetaTileEntities.ORE_WASHER, @@ -268,11 +272,11 @@ public void register(IModRegistry registry) { }; for (MetaTileEntity[] machine : machineLists) { if (machine.length < GTValues.LV + 1 || machine[GTValues.LV] == null) continue; - registry.addRecipeCatalyst(machine[GTValues.LV].getStackForm(), oreByProductId); + registry.addRecipeCatalyst(machine[GTValues.LV].getStackForm(), OreByProductCategory.UID); } // Material Tree - registry.addRecipes(materialTreeList, GTValues.MODID + ":" + "material_tree"); + registry.addRecipes(materialTreeList, MaterialTreeCategory.UID); // Ore Veins List oreVeins = WorldGenRegistry.getOreDeposits(); @@ -281,7 +285,7 @@ public void register(IModRegistry registry) { oreInfoList.add(new GTOreInfo(vein)); } - String oreSpawnID = GTValues.MODID + ":" + "ore_spawn_location"; + String oreSpawnID = GTOreCategory.UID; registry.addRecipes(oreInfoList, oreSpawnID); registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LV.getStackForm(), oreSpawnID); registry.addRecipeCatalyst(MetaItems.PROSPECTOR_HV.getStackForm(), oreSpawnID); @@ -295,7 +299,7 @@ public void register(IModRegistry registry) { fluidVeinInfos.add(new GTFluidVeinInfo(fluidVein)); } - String fluidVeinSpawnID = GTValues.MODID + ":" + "fluid_spawn_location"; + String fluidVeinSpawnID = GTFluidVeinCategory.UID; registry.addRecipes(fluidVeinInfos, fluidVeinSpawnID); registry.addRecipeCatalyst(MetaItems.PROSPECTOR_HV.getStackForm(), fluidVeinSpawnID); registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LUV.getStackForm(), fluidVeinSpawnID); @@ -379,4 +383,42 @@ private void registerRecipeMapCatalyst(IModRegistry registry, RecipeMap recip } } } + + /** + * Comparator to sort certain GT categories to the front or back of the JEI category list. + * + * @return the comparator + */ + @ApiStatus.Internal + public static @NotNull Comparator> getRecipeCategoryComparator() { + List backIds = GTRecipeCategory.getCategories().stream() + .filter(GTRecipeCategory::shouldSortToBackJEI) + .map(GTRecipeCategory::getUniqueID) + .collect(Collectors.toCollection(ArrayList::new)); + backIds.add(IntCircuitCategory.UID); + backIds.add(MultiblockInfoCategory.UID); + backIds.add(OreByProductCategory.UID); + backIds.add(GTOreCategory.UID); + backIds.add(GTFluidVeinCategory.UID); + List frontIds; + if (ConfigHolder.client.preferMaterialTreeInJEI) { + frontIds = Collections.singletonList(MaterialTreeCategory.UID); + } else { + frontIds = Collections.emptyList(); + } + + return Comparator.>comparingInt(category -> { + int index = backIds.indexOf(category.getUid()); + if (index >= 0) { + return index; + } + return Integer.MIN_VALUE; + }).thenComparingInt(category -> { + int index = frontIds.indexOf(category.getUid()); + if (index >= 0) { + return index; + } + return Integer.MAX_VALUE; + }); + } } diff --git a/src/main/java/gregtech/integration/jei/basic/BasicRecipeCategory.java b/src/main/java/gregtech/integration/jei/basic/BasicRecipeCategory.java index 9017c0936e1..fafd774290b 100644 --- a/src/main/java/gregtech/integration/jei/basic/BasicRecipeCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/BasicRecipeCategory.java @@ -39,7 +39,7 @@ public IDrawable getIcon() { @NotNull @Override public String getUid() { - return getModName() + ":" + uniqueName; + return getModName() + "." + uniqueName; } @NotNull diff --git a/src/main/java/gregtech/integration/jei/basic/GTFluidVeinCategory.java b/src/main/java/gregtech/integration/jei/basic/GTFluidVeinCategory.java index 18d53c28986..a866e58b53e 100644 --- a/src/main/java/gregtech/integration/jei/basic/GTFluidVeinCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/GTFluidVeinCategory.java @@ -1,5 +1,6 @@ package gregtech.integration.jei.basic; +import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; import gregtech.api.util.GTStringUtils; import gregtech.api.worldgen.config.WorldGenRegistry; @@ -21,6 +22,8 @@ public class GTFluidVeinCategory extends BasicRecipeCategory { + public static final String UID = String.format("%s.fluid_spawn_location", GTValues.MODID); + private static final int SLOT_CENTER = 79; private static final int TEXT_START_X = 5; private static final int START_POS_Y = 40; diff --git a/src/main/java/gregtech/integration/jei/basic/GTOreCategory.java b/src/main/java/gregtech/integration/jei/basic/GTOreCategory.java index 5427259ee8e..1380e054513 100644 --- a/src/main/java/gregtech/integration/jei/basic/GTOreCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/GTOreCategory.java @@ -1,5 +1,6 @@ package gregtech.integration.jei.basic; +import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; import gregtech.api.util.GTStringUtils; import gregtech.api.worldgen.config.OreDepositDefinition; @@ -20,6 +21,8 @@ public class GTOreCategory extends BasicRecipeCategory { + public static final String UID = String.format("%s.ore_spawn_location", GTValues.MODID); + private static final int NUM_OF_SLOTS = 5; private static final int SLOT_WIDTH = 18; private static final int SLOT_HEIGHT = 18; diff --git a/src/main/java/gregtech/integration/jei/basic/MaterialTreeCategory.java b/src/main/java/gregtech/integration/jei/basic/MaterialTreeCategory.java index b3c8b6e10b2..a88073aa69c 100644 --- a/src/main/java/gregtech/integration/jei/basic/MaterialTreeCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/MaterialTreeCategory.java @@ -30,6 +30,8 @@ public class MaterialTreeCategory extends BasicRecipeCategory { + public static final String UID = String.format("%s.material_tree", GTValues.MODID); + protected String materialName; protected String materialFormula; protected int materialBFTemp; diff --git a/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java b/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java index db4f2bc6345..a347797fe90 100644 --- a/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java +++ b/src/main/java/gregtech/integration/jei/basic/OreByProductCategory.java @@ -31,6 +31,8 @@ public class OreByProductCategory extends BasicRecipeCategory { + public static final String UID = String.format("%s.ore_by_product", GTValues.MODID); + protected final IDrawable slot; protected final IDrawable fluidSlot; protected final IDrawable arrowsBase; diff --git a/src/main/java/gregtech/integration/jei/multiblock/MultiblockInfoCategory.java b/src/main/java/gregtech/integration/jei/multiblock/MultiblockInfoCategory.java index f0325a4c488..28c65478852 100644 --- a/src/main/java/gregtech/integration/jei/multiblock/MultiblockInfoCategory.java +++ b/src/main/java/gregtech/integration/jei/multiblock/MultiblockInfoCategory.java @@ -22,6 +22,8 @@ public class MultiblockInfoCategory implements IRecipeCategory { + public static final String UID = String.format("%s.multiblock_info", GTValues.MODID); + private final IDrawable background; private final IDrawable icon; private final IGuiHelper guiHelper; @@ -40,14 +42,13 @@ public static void registerMultiblock(MultiblockControllerBase controllerBase) { } public static void registerRecipes(IModRegistry registry) { - registry.addRecipes(REGISTER.stream().map(MultiblockInfoRecipeWrapper::new).collect(Collectors.toList()), - "gregtech:multiblock_info"); + registry.addRecipes(REGISTER.stream().map(MultiblockInfoRecipeWrapper::new).collect(Collectors.toList()), UID); } @NotNull @Override public String getUid() { - return "gregtech:multiblock_info"; + return UID; } @NotNull diff --git a/src/main/java/gregtech/integration/jei/recipe/IntCircuitCategory.java b/src/main/java/gregtech/integration/jei/recipe/IntCircuitCategory.java index 82e2fa39fb5..76e28f89d6d 100644 --- a/src/main/java/gregtech/integration/jei/recipe/IntCircuitCategory.java +++ b/src/main/java/gregtech/integration/jei/recipe/IntCircuitCategory.java @@ -41,7 +41,7 @@ @MethodsReturnNonnullByDefault public class IntCircuitCategory implements IRecipeCategory { - public static final String UID = GTValues.MODID + ":" + MetaItems.INTEGRATED_CIRCUIT.unlocalizedName; + public static final String UID = GTValues.MODID + "." + MetaItems.INTEGRATED_CIRCUIT.unlocalizedName; private static final int SLOT_SIZE = 18; private static final int ROW_LENGTH = 6; private static final int FIRST_SLOT_SCALE = 2; diff --git a/src/main/java/gregtech/mixins/jei/ModRegistryMixin.java b/src/main/java/gregtech/mixins/jei/ModRegistryMixin.java new file mode 100644 index 00000000000..36667ff929d --- /dev/null +++ b/src/main/java/gregtech/mixins/jei/ModRegistryMixin.java @@ -0,0 +1,33 @@ +package gregtech.mixins.jei; + +import gregtech.integration.jei.JustEnoughItemsModule; + +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> recipeCategories; + + /** + * @reason Sort recipe categories according to rules defined by GTCEu to allow a custom order for its JEI category + * tabs. + * @see JustEnoughItemsModule#getRecipeCategoryComparator() + */ + @Inject(method = "createRecipeRegistry", at = @At("HEAD"), order = 100) + private void gregtech$sortRecipeCategories(CallbackInfoReturnable ci) { + recipeCategories.sort(JustEnoughItemsModule.getRecipeCategoryComparator()); + } +} diff --git a/src/main/resources/mixins.gregtech.jei.json b/src/main/resources/mixins.gregtech.jei.json index 3df5ef9885e..75728d0aeb9 100644 --- a/src/main/resources/mixins.gregtech.jei.json +++ b/src/main/resources/mixins.gregtech.jei.json @@ -10,6 +10,7 @@ "GhostDragAccessor", "IngredientGridMixin", "JEITooltipMixin", + "ModRegistryMixin", "StackHelperMixin" ], "client": [],