Skip to content

Commit

Permalink
Compat with GT change
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune committed Dec 1, 2023
1 parent 3077326 commit c1c30cf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1699290261
//version: 1700844281
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -302,7 +302,7 @@ if (apiPackage) {
}

if (accessTransformersFile) {
for (atFile in accessTransformersFile.split(",")) {
for (atFile in accessTransformersFile.split(" ")) {
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
Expand Down
1 change: 0 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ dependencies {
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.19-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.5.0-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.30:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.31:dev") { transitive = false }

runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,8 +21,6 @@
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 {

Expand All @@ -32,12 +32,19 @@ public void run() {
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);
}
}

Expand All @@ -47,11 +54,21 @@ public void run() {
}
}

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);
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/glodblock/github/util/ModAndClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

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;
Expand Down Expand Up @@ -119,7 +126,14 @@ public static void init() {
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;
Expand Down

0 comments on commit c1c30cf

Please sign in to comment.