mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-20 12:09:48 +00:00
Add ThermalExpansion support
This commit is contained in:
1 parent
a66fed83ed
commit
571204f2d2
7 files changed
+97
-4
No files matched your search
@@ -75,7 +75,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
}
|
||||
|
||||
for (PositionedStack positionedStack : tInputs) {
|
||||
ItemStack currentStack = positionedStack.items[0];
|
||||
ItemStack currentStack = positionedStack.item;
|
||||
for (ItemStack stack : positionedStack.items) {
|
||||
if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) {
|
||||
currentStack = stack.copy();
|
||||
|
||||
@@ -42,6 +42,10 @@ public class RecipeProcessor {
|
||||
NotEnoughEnergistics.logger.info("Found TCNEIPlugin, install TCNEIPlugin support");
|
||||
recipeProcessors.add(new TCNEIPluginRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("ThermalExpansion")) {
|
||||
NotEnoughEnergistics.logger.info("Found ThermalExpansion, install ThermalExpansion support");
|
||||
recipeProcessors.add(new ThermalExpansionRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("appliedenergistics2")) {
|
||||
NotEnoughEnergistics.logger.info("Applied Energistics 2 will not be supported");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"thermalexpansion.charger", "thermalexpansion.crucible", "thermalexpansion.furnace", "thermalexpansion.insolator",
|
||||
"thermalexpansion.pulverizer", "thermalexpansion.sawmill", "thermalexpansion.smelter", "thermalexpansion.transposer"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "ThermalExpansion";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
if (recipe instanceof RecipeHandlerBase) {
|
||||
Class<?> NEIRecipeBase = null;
|
||||
try {
|
||||
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (NEIRecipeBase != null) {
|
||||
Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput");
|
||||
PositionedStack secondaryInput = null;
|
||||
try {
|
||||
secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (secondaryInput != null) {
|
||||
recipeInputs.add(secondaryInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
if (recipe instanceof RecipeHandlerBase) {
|
||||
Class<?> NEIRecipeBase = null;
|
||||
try {
|
||||
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (NEIRecipeBase != null) {
|
||||
Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput");
|
||||
PositionedStack secondaryOutput = null;
|
||||
try {
|
||||
secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (secondaryOutput != null) {
|
||||
recipeOutputs.add(secondaryOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user