mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-19 11:49:06 +00:00
feat: add gt++ support
This commit is contained in:
1 parent
a93fce9feb
commit
e6abec978a
9 files changed
+73
-39
No files matched your search
@@ -13,6 +13,7 @@ public class Adapter {
|
||||
public static List<IAdapter> adapters = new ArrayList<>();
|
||||
|
||||
public static void init() {
|
||||
JustEnoughCalculation.logger.info("=====Just Enough Calculation Init Start=====");
|
||||
if (Loader.isModLoaded("Forestry")) {
|
||||
JustEnoughCalculation.logger.info("Forestry installed");
|
||||
adapters.add(new Forestry());
|
||||
@@ -25,14 +26,20 @@ public class Adapter {
|
||||
JustEnoughCalculation.logger.info("gregtech installed");
|
||||
adapters.add(new GregTech());
|
||||
}
|
||||
// if (Loader.isModLoaded("miscutils")) {
|
||||
// JustEnoughCalculation.logger.info("gt++ not supported");
|
||||
// adapters.add(new GTPP());
|
||||
// }
|
||||
try {
|
||||
if (Loader.isModLoaded("miscutils")) {
|
||||
adapters.add(new GTPP());
|
||||
JustEnoughCalculation.logger.info("gt++ installed");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
JustEnoughCalculation.logger.info("exception when installing gt++");
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Loader.isModLoaded("Avaritia")) {
|
||||
JustEnoughCalculation.logger.info("Avaritia installed");
|
||||
adapters.add(new Avaritia());
|
||||
}
|
||||
JustEnoughCalculation.logger.info("=====Just Enough Calculation Init Finish=====");
|
||||
}
|
||||
|
||||
public static void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
|
||||
@@ -17,6 +17,7 @@ public class NEICalculatorConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
Adapter.init();
|
||||
/* null For the recipeHandlers which extend `TemplateRecipeHandler` without override the `getOverlayIdentifier` function */
|
||||
Set<String> baseOverlayIdentifiers = new HashSet<>(
|
||||
Arrays.asList("crafting", "crafting2x2", "smelting", "fuel", "brewing", null));
|
||||
|
||||
@@ -18,7 +18,6 @@ public class NEIPlugin {
|
||||
|
||||
public static void init() {
|
||||
GuiContainerManager.addTooltipHandler(new JecaTooltipHandler());
|
||||
Adapter.init();
|
||||
// nei version check
|
||||
String neiVersion = Loader.instance().getIndexedModList().get("NotEnoughItems").getVersion();
|
||||
JustEnoughCalculation.logger.info("NEI version: " + neiVersion);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import gregtech.api.util.GTPP_Recipe;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -15,30 +15,54 @@ import java.util.stream.Stream;
|
||||
* don't work, why?
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public class GTPP /* extends GregTech */ {
|
||||
//
|
||||
// private final static Set<Class<? extends TemplateRecipeHandler>> defaultHandlers = Stream.of(
|
||||
// GTPP_NEI_DefaultHandler.class, GT_NEI_VacFurnace.class, GT_NEI_RFPP.class,
|
||||
// GT_NEI_multiCentriElectroFreezer.class, GT_NEI_MillingMachine.class, GT_NEI_FluidReactor.class,
|
||||
// GT_NEI_FlotationCell.class, DecayableRecipeHandler.class).collect(Collectors.toSet());
|
||||
//
|
||||
// @Override
|
||||
// public Set<String> getAllOverlayIdentifier() {
|
||||
// Set<String> recipeNames = GTPP_Recipe.GT_Recipe_Map.sMappings.stream()
|
||||
// .map(gt_recipe_map -> gt_recipe_map.mNEIName)
|
||||
// .collect(Collectors.toSet());
|
||||
// recipeNames.add("GTPP_Decayables");
|
||||
// JustEnoughCalculation.logger.info("GTPP recipe handlers cecipe name");
|
||||
// for (String recipeName : recipeNames) {
|
||||
// JustEnoughCalculation.logger.info(" " + recipeName);
|
||||
// }
|
||||
// return recipeNames;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
// if (defaultHandlers.stream().anyMatch(aClass -> aClass.isInstance(recipe))) {
|
||||
// handleDefault(recipe, index, inputs, outputs);
|
||||
// }
|
||||
// }
|
||||
public class GTPP extends GregTech {
|
||||
|
||||
private final static Set<Class<?>> defaultHandlers;
|
||||
|
||||
static {
|
||||
List<String> handlers = Stream.of(
|
||||
// gtpp after 2020/5/30
|
||||
"GTPP_NEI_DefaultHandler", "GT_NEI_VacFurnace", "GT_NEI_RFPP", "GT_NEI_multiCentriElectroFreezer",
|
||||
"GT_NEI_MillingMachine", "GT_NEI_FluidReactor", "GT_NEI_FlotationCell", "DecayableRecipeHandler",
|
||||
// gtpp before 2020/5/30
|
||||
"GT_NEI_DefaultHandler", "GT_NEI_Dehydrator", "GT_NEI_MultiBlockHandler", "GTPP_NEI_CustomMapHandler",
|
||||
"GTPP_NEI_DefaultHandlerEx"
|
||||
|
||||
).map(name -> "gtPlusPlus.nei." + name).collect(Collectors.toList()); defaultHandlers = new HashSet<>();
|
||||
for (String handler : handlers) {
|
||||
try {
|
||||
defaultHandlers.add(Class.forName(handler));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
Set<String> recipeNames = new HashSet<>();
|
||||
try {
|
||||
// add as many recipe as possible
|
||||
recipeNames.addAll(
|
||||
GTPP_Recipe.GT_Recipe_Map.sMappings.stream().map(rm -> rm.mNEIName).collect(Collectors.toSet()));
|
||||
recipeNames.addAll(
|
||||
GTPP_Recipe.GTPP_Recipe_Map.sMappings.stream().map(rm -> rm.mNEIName).collect(Collectors.toSet()));
|
||||
recipeNames.addAll(GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx.stream()
|
||||
.map(rm -> rm.mNEIName)
|
||||
.collect(Collectors.toSet()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// which one?
|
||||
recipeNames.add("GTPP_Decayables");
|
||||
recipeNames.add("Decayables");
|
||||
return recipeNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
if (defaultHandlers.stream().anyMatch(aClass -> aClass.isInstance(recipe))) {
|
||||
handleDefault(recipe, index, inputs, outputs);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user