diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index 96a392e974e..3a106ed928a 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -523,7 +523,7 @@ protected ModularUI.Builder addSpecialTexture(ModularUI.Builder builder) { } - public List getRecipeList() { + public Collection getRecipeList() { return Collections.unmodifiableList(new ArrayList<>(recipeSet)); } diff --git a/src/main/java/gregtech/common/items/armor/PowerlessJetpack.java b/src/main/java/gregtech/common/items/armor/PowerlessJetpack.java index 401031f56e1..f0ed264c2fc 100644 --- a/src/main/java/gregtech/common/items/armor/PowerlessJetpack.java +++ b/src/main/java/gregtech/common/items/armor/PowerlessJetpack.java @@ -38,11 +38,12 @@ import javax.annotation.Nonnull; import java.util.Arrays; +import java.util.Collection; import java.util.List; public class PowerlessJetpack implements ISpecialArmorLogic, IArmorLogic, IJetpack { - private static final List FUELS = RecipeMaps.COMBUSTION_GENERATOR_FUELS.getRecipeList(); + private static final Collection FUELS = RecipeMaps.COMBUSTION_GENERATOR_FUELS.getRecipeList(); public static final List FUELS_FORBIDDEN = Arrays.asList(Materials.Oil.getFluid(), Materials.SulfuricLightFuel.getFluid()); diff --git a/src/main/java/gregtech/core/GregTechTransformer.java b/src/main/java/gregtech/core/GregTechTransformer.java index 0da41d38d9d..c4b2e3188dd 100644 --- a/src/main/java/gregtech/core/GregTechTransformer.java +++ b/src/main/java/gregtech/core/GregTechTransformer.java @@ -5,6 +5,8 @@ import gregtech.core.util.TargetClassVisitor; import gregtech.core.visitors.*; import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; @@ -108,6 +110,18 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) classReader.accept(new TargetClassVisitor(classWriter, CCLVisitor.TARGET_METHOD, CCLVisitor::new), 0); return classWriter.toByteArray(); } + case NuclearCraftRecipeHelperVisitor.TARGET_CLASS_NAME: { + ClassReader classReader = new ClassReader(basicClass); + ClassWriter classWriter = new ClassWriter(0); + + ModContainer container = Loader.instance().getIndexedModList().get("nuclearcraft"); + if (container.getVersion().contains("2o")) { // overhauled + classReader.accept(new TargetClassVisitor(classWriter, NuclearCraftRecipeHelperVisitor.TARGET_METHOD_NCO, NuclearCraftRecipeHelperVisitor::new), 0); + } else { + classReader.accept(new TargetClassVisitor(classWriter, NuclearCraftRecipeHelperVisitor.TARGET_METHOD_NC, NuclearCraftRecipeHelperVisitor::new), 0); + } + return classWriter.toByteArray(); + } } return basicClass; } diff --git a/src/main/java/gregtech/core/visitors/NuclearCraftRecipeHelperVisitor.java b/src/main/java/gregtech/core/visitors/NuclearCraftRecipeHelperVisitor.java new file mode 100644 index 00000000000..6c3c5a71ac3 --- /dev/null +++ b/src/main/java/gregtech/core/visitors/NuclearCraftRecipeHelperVisitor.java @@ -0,0 +1,24 @@ +package gregtech.core.visitors; + +import gregtech.core.util.ObfMapping; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class NuclearCraftRecipeHelperVisitor extends MethodVisitor implements Opcodes { + public static final String TARGET_CLASS_NAME = "nc/integration/gtce/GTCERecipeHelper"; + + public static final ObfMapping TARGET_METHOD_NC = new ObfMapping(TARGET_CLASS_NAME, "addGTCERecipe", "(Ljava/lang/String;Lnc/recipe/ProcessorRecipe;)V"); + public static final ObfMapping TARGET_METHOD_NCO = new ObfMapping(TARGET_CLASS_NAME, "addGTCERecipe", "(Ljava/lang/String;Lnc/recipe/BasicRecipe;)V"); + + public NuclearCraftRecipeHelperVisitor(MethodVisitor mv) { + super(ASM5, mv); + } + + @Override + public void visitFieldInsn(int opcode, String owner, String name, String desc) { + if (opcode == GETSTATIC && name.equals("FLUID_EXTRACTION_RECIPES")) { // FLUID_EXTRACTION_RECIPES -> EXTRACTOR_RECIPES + name = "EXTRACTOR_RECIPES"; + } + super.visitFieldInsn(opcode, owner, name, desc); + } +} diff --git a/src/main/java/gregtech/integration/jei/GTJeiPlugin.java b/src/main/java/gregtech/integration/jei/GTJeiPlugin.java index 66e9a008a63..9ef49750d01 100644 --- a/src/main/java/gregtech/integration/jei/GTJeiPlugin.java +++ b/src/main/java/gregtech/integration/jei/GTJeiPlugin.java @@ -48,10 +48,7 @@ import javax.annotation.Nonnull; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -110,7 +107,7 @@ public void register(IModRegistry registry) { .filter(recipe -> !recipe.isHidden() && recipe.hasValidInputsForDisplay()); if (recipeMap.getSmallRecipeMap() != null) { - List smallRecipes = recipeMap.getSmallRecipeMap().getRecipeList(); + Collection smallRecipes = recipeMap.getSmallRecipeMap().getRecipeList(); recipeStream = recipeStream.filter(recipe -> !smallRecipes.contains(recipe)); }