Compat with GT change (#175)

* Compat with GT change

* update gradle+bs+deps

---------

Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
miozuneandMartin Robertz authored and GitHub committed 2023-12-04 00:09:20 +01:00
1 parent 3b1b1af852
commit d790afc047
7 files changed
+61 -42

No files matched your search

@@ -1,5 +1,7 @@
package com.glodblock.github.nei.recipes;
import java.util.Collection;
import com.glodblock.github.nei.recipes.extractor.AvaritiaRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.EnderIORecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.ForestryRecipeExtractor;
@@ -19,8 +21,6 @@ import forestry.factory.recipes.nei.NEIHandlerMoistener;
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
import forestry.factory.recipes.nei.NEIHandlerStill;
import gregapi.recipes.Recipe;
import gregtech.api.util.GTPP_Recipe;
import gregtech.api.util.GT_Recipe;
public class DefaultExtractorLoader implements Runnable {
@@ -32,12 +32,19 @@ public class DefaultExtractorLoader implements Runnable {
FluidRecipe.addRecipeMap("crafting2x2", new VanillaRecipeExtractor(true));
if (ModAndClassUtil.GT5) {
for (GT_Recipe.GT_Recipe_Map tMap : GT_Recipe.GT_Recipe_Map.sMappings) {
FluidRecipe.addRecipeMap(
tMap.mNEIName,
new GregTech5RecipeExtractor(
tMap.mNEIName.equals("gt.recipe.scanner")
|| tMap.mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
try {
Class<?> recipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
Collection<?> sMappings = (Collection<?>) recipeMapClazz.getDeclaredField("sMappings").get(null);
for (Object tMap : sMappings) {
String mNEIName = (String) recipeMapClazz.getDeclaredField("mNEIName").get(tMap);
FluidRecipe.addRecipeMap(
mNEIName,
new GregTech5RecipeExtractor(
mNEIName.equals("gt.recipe.scanner")
|| mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -47,11 +54,21 @@ public class DefaultExtractorLoader implements Runnable {
}
}
if (ModAndClassUtil.GTPP) {
for (GTPP_Recipe.GTPP_Recipe_Map_Internal gtppMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) {
if (gtppMap.mNEIAllowed) {
FluidRecipe.addRecipeMap(gtppMap.mNEIName, new GTPPRecipeExtractor());
if (ModAndClassUtil.GTPP && !ModAndClassUtil.GT5NH) {
try {
Class<?> gtRecipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
Class<?> gtppRecipeMapClazz = Class.forName("gregtech.api.util.GTPP_Recipe$GTPP_Recipe_Map_Internal");
Collection<?> sMappingsEx = (Collection<?>) gtppRecipeMapClazz.getDeclaredField("sMappingsEx")
.get(null);
for (Object gtppMap : sMappingsEx) {
boolean mNEIAllowed = gtRecipeMapClazz.getDeclaredField("mNEIAllowed").getBoolean(gtppMap);
if (mNEIAllowed) {
String mNEIName = (String) gtRecipeMapClazz.getDeclaredField("mNEIName").get(gtppMap);
FluidRecipe.addRecipeMap(mNEIName, new GTPPRecipeExtractor());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -12,6 +12,13 @@ import cpw.mods.fml.common.Loader;
public final class ModAndClassUtil {
/**
* GTNH fork of GregTech5 Unofficial
*/
public static boolean GT5NH = false;
/**
* GregTech5 / GregTech5 Unofficial (Blood-Asp's "official" GT5u)
*/
public static boolean GT5 = false;
public static boolean GT6 = false;
public static boolean EC2 = false;
@@ -119,7 +126,14 @@ public final class ModAndClassUtil {
isTypeFilter = false;
}
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) GT5 = true;
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) {
try {
Class.forName("gregtech.api.recipe.RecipeMap");
GT5NH = true;
} catch (ClassNotFoundException e) {
GT5 = true;
}
}
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) GT6 = true;
if (Loader.isModLoaded("extracells")) EC2 = true;
if (Loader.isModLoaded("EnderIO")) EIO = true;