Skip to content

Commit d977fc7

Browse files
committed
support for eio and gt6
1 parent 3e76b36 commit d977fc7

File tree

10 files changed

+271
-7
lines changed

10 files changed

+271
-7
lines changed

dependencies.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
// Add your dependencies here
22

33
dependencies {
4-
compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
5-
compile('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
4+
65
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev')
7-
compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
86
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
97
compile('curse.maven:cofh-core-69162:2388751')
108
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
9+
compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
1110

11+
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
12+
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
13+
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
14+
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
15+
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
1216
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
1317
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
18+
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
1419
}

src/main/java/com/glodblock/github/inventory/gui/GuiType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.glodblock.github.client.gui.*;
77
import com.glodblock.github.client.gui.container.*;
88
import com.glodblock.github.common.parts.FCBasePart;
9-
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
109
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
1110
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
1211
import com.google.common.collect.ImmutableList;

src/main/java/com/glodblock/github/loader/RecipeLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void run() {
3737
GameRegistry.addRecipe(new ShapedOreRecipe(DECODER.stack(), "IHI", "CFC", "IPI", 'I', "ingotIron", 'H', Blocks.hopper, 'C', AE2_GLASS_CABLE, 'F', INTERFACE, 'P', AE2_PROCESS_CAL));
3838
GameRegistry.addRecipe(new ShapedOreRecipe(ENCODER.stack(), "LPL", "IWI", "III", 'I', "ingotIron", 'L', "blockLapis", 'P', AE2_PROCESS_ENG, 'W', AE2_WORK_BENCH));
3939
GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER);
40+
GameRegistry.addShapelessRecipe(FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG);
4041

4142
if (Config.fluidCells) {
4243
OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS);

src/main/java/com/glodblock/github/nei/object/IRecipeExtractor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.glodblock.github.nei.object;
22

33
import codechicken.nei.PositionedStack;
4+
import codechicken.nei.recipe.IRecipeHandler;
45

56
import java.util.List;
67

@@ -10,4 +11,12 @@ public interface IRecipeExtractor {
1011

1112
List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs);
1213

14+
default List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
15+
return getInputIngredients(rawInputs);
16+
}
17+
18+
default List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe, int index) {
19+
return getOutputIngredients(rawOutputs);
20+
}
21+
1322
}

src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.glodblock.github.nei.recipes;
22

3+
import com.glodblock.github.nei.recipes.extractor.EnderIORecipeExtractor;
34
import com.glodblock.github.nei.recipes.extractor.GregTech5RecipeExtractor;
5+
import com.glodblock.github.nei.recipes.extractor.GregTech6RecipeExtractor;
46
import com.glodblock.github.nei.recipes.extractor.VanillaRecipeExtractor;
57
import com.glodblock.github.util.ModAndClassUtil;
8+
import gregapi.recipes.Recipe;
69
import gregtech.api.util.GT_Recipe;
710

811
public class DefaultExtractorLoader implements Runnable {
@@ -19,6 +22,22 @@ public void run() {
1922
FluidRecipe.addRecipeMap(tMap.mNEIName, new GregTech5RecipeExtractor(tMap.mNEIName.equals("gt.recipe.scanner") || tMap.mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
2023
}
2124
}
25+
26+
if (ModAndClassUtil.GT6) {
27+
for (Recipe.RecipeMap tMap : Recipe.RecipeMap.RECIPE_MAPS.values()) {
28+
FluidRecipe.addRecipeMap(tMap.mNameNEI, new GregTech6RecipeExtractor(tMap));
29+
}
30+
}
31+
32+
if (ModAndClassUtil.EIO) {
33+
FluidRecipe.addRecipeMap("EIOEnchanter", new EnderIORecipeExtractor());
34+
FluidRecipe.addRecipeMap("EnderIOAlloySmelter", new EnderIORecipeExtractor());
35+
FluidRecipe.addRecipeMap("EnderIOSagMill", new EnderIORecipeExtractor());
36+
FluidRecipe.addRecipeMap("EnderIOSliceAndSplice", new EnderIORecipeExtractor());
37+
FluidRecipe.addRecipeMap("EnderIOSoulBinder", new EnderIORecipeExtractor());
38+
FluidRecipe.addRecipeMap("EnderIOVat", new EnderIORecipeExtractor());
39+
}
40+
2241
}
2342

2443
}

src/main/java/com/glodblock/github/nei/recipes/FluidRecipe.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static List<OrderStack<?>> getPackageInputs(IRecipeHandler recipe, int in
2525
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
2626
if (extractor == null) return new ArrayList<>();
2727
List<PositionedStack> tmp = new ArrayList<>(tRecipe.getIngredientStacks(index));
28-
return extractor.getInputIngredients(tmp);
28+
return extractor.getInputIngredients(tmp, recipe, index);
2929
}
3030

3131
public static List<OrderStack<?>> getPackageOutputs(IRecipeHandler recipe, int index, boolean useOther) {
@@ -35,7 +35,7 @@ public static List<OrderStack<?>> getPackageOutputs(IRecipeHandler recipe, int i
3535
if (extractor == null) return new ArrayList<>();
3636
List<PositionedStack> tmp = new ArrayList<>(Collections.singleton(tRecipe.getResultStack(index)));
3737
if (useOther) tmp.addAll(tRecipe.getOtherStacks(index));
38-
return extractor.getOutputIngredients(tmp);
38+
return extractor.getOutputIngredients(tmp, recipe, index);
3939
}
4040

4141
public static List<String> getSupportRecipes() {
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.glodblock.github.nei.recipes.extractor;
2+
3+
import codechicken.nei.PositionedStack;
4+
import codechicken.nei.recipe.IRecipeHandler;
5+
import codechicken.nei.recipe.TemplateRecipeHandler;
6+
import com.glodblock.github.nei.object.IRecipeExtractor;
7+
import com.glodblock.github.nei.object.OrderStack;
8+
import com.glodblock.github.util.Ae2Reflect;
9+
import crazypants.enderio.machine.crusher.CrusherRecipeManager;
10+
import crazypants.enderio.nei.VatRecipeHandler;
11+
import net.minecraftforge.fluids.FluidStack;
12+
13+
import java.lang.reflect.Field;
14+
import java.util.ArrayList;
15+
import java.util.LinkedList;
16+
import java.util.List;
17+
18+
public class EnderIORecipeExtractor implements IRecipeExtractor {
19+
20+
public EnderIORecipeExtractor() {
21+
}
22+
23+
@Override
24+
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
25+
List<OrderStack<?>> tmp = new LinkedList<>();
26+
for (int i = 0; i < rawInputs.size(); i ++) {
27+
if (rawInputs.get(i) == null) continue;
28+
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), i);
29+
if (stack != null) tmp.add(stack);
30+
}
31+
return tmp;
32+
}
33+
34+
@Override
35+
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
36+
List<OrderStack<?>> tmp = new LinkedList<>();
37+
for (int i = 0; i < rawOutputs.size(); i ++) {
38+
if (rawOutputs.get(i) == null) continue;
39+
OrderStack<?> stack = OrderStack.pack(rawOutputs.get(i), i);
40+
if (stack != null) tmp.add(stack);
41+
}
42+
return tmp;
43+
}
44+
45+
@Override
46+
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
47+
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
48+
List<OrderStack<?>> tmp = new LinkedList<>();
49+
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
50+
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
51+
ArrayList<PositionedStack> inputs = ReflectEIO.getInputs(vatRecipe);
52+
for (int i = 0; i < inputs.size(); i ++) {
53+
if (inputs.get(i) == null) continue;
54+
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), i);
55+
if (stack != null) tmp.add(stack);
56+
}
57+
FluidStack in = ReflectEIO.getInputFluid(vatRecipe);
58+
if (in != null) {
59+
tmp.add(new OrderStack<>(in, inputs.size()));
60+
}
61+
return tmp;
62+
} else if (tRecipe.getOverlayIdentifier().equals("EnderIOSagMill")) {
63+
for (int i = rawInputs.size() - 1; i >= 0; i --) {
64+
PositionedStack stack = rawInputs.get(i);
65+
if (stack != null && CrusherRecipeManager.getInstance().isValidSagBall(stack.items[0])) {
66+
rawInputs.remove(i);
67+
break;
68+
}
69+
}
70+
return getInputIngredients(rawInputs);
71+
}
72+
else {
73+
return getInputIngredients(rawInputs);
74+
}
75+
}
76+
77+
@Override
78+
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe, int index) {
79+
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
80+
List<OrderStack<?>> tmp = new LinkedList<>();
81+
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
82+
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
83+
FluidStack result = ReflectEIO.getResult(vatRecipe);
84+
if (result != null) {
85+
tmp.add(new OrderStack<>(result, 0));
86+
}
87+
return tmp;
88+
}
89+
else {
90+
return getOutputIngredients(rawOutputs);
91+
}
92+
}
93+
94+
private static class ReflectEIO {
95+
96+
private final static Field inputsF;
97+
private final static Field resultF;
98+
private final static Field inFluidF;
99+
100+
static {
101+
try {
102+
inputsF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "inputs");
103+
resultF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "result");
104+
inFluidF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "inFluid");
105+
} catch (NoSuchFieldException e) {
106+
throw new IllegalStateException("Failed to initialize EIO reflection hacks!", e);
107+
}
108+
}
109+
110+
private static ArrayList<PositionedStack> getInputs(VatRecipeHandler.InnerVatRecipe vat) {
111+
return Ae2Reflect.readField(vat, inputsF);
112+
}
113+
114+
private static FluidStack getResult(VatRecipeHandler.InnerVatRecipe vat) {
115+
return Ae2Reflect.readField(vat, resultF);
116+
}
117+
118+
private static FluidStack getInputFluid(VatRecipeHandler.InnerVatRecipe vat) {
119+
return Ae2Reflect.readField(vat, inFluidF);
120+
}
121+
122+
}
123+
124+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.glodblock.github.nei.recipes.extractor;
2+
3+
import codechicken.nei.PositionedStack;
4+
import com.glodblock.github.nei.object.IRecipeExtractor;
5+
import com.glodblock.github.nei.object.OrderStack;
6+
import gregapi.item.ItemFluidDisplay;
7+
import gregapi.recipes.Recipe;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraftforge.fluids.FluidStack;
10+
11+
import java.util.LinkedList;
12+
import java.util.List;
13+
import java.util.Objects;
14+
import java.util.stream.Collectors;
15+
16+
public class GregTech6RecipeExtractor implements IRecipeExtractor {
17+
18+
private final Recipe.RecipeMap Recipes;
19+
20+
public GregTech6RecipeExtractor(Recipe.RecipeMap aMap) {
21+
Recipes = aMap;
22+
}
23+
24+
@Override
25+
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
26+
this.removeMachine(rawInputs);
27+
List<PositionedStack> compressed = compress(rawInputs);
28+
List<OrderStack<?>> tmp = new LinkedList<>();
29+
for (int i = 0; i < compressed.size(); i ++) {
30+
if (compressed.get(i) == null) continue;
31+
ItemStack item = compressed.get(i).items[0];
32+
OrderStack<?> stack;
33+
if (item.getItem() instanceof ItemFluidDisplay) {
34+
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
35+
if (fluid == null || fluid.amount <= 0) continue;
36+
stack = new OrderStack<>(fluid, i);
37+
tmp.add(stack);
38+
} else {
39+
stack = OrderStack.pack(compressed.get(i), i);
40+
if (stack != null) tmp.add(stack);
41+
}
42+
}
43+
return tmp;
44+
}
45+
46+
@Override
47+
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
48+
List<PositionedStack> compressed = compress(rawOutputs);
49+
List<OrderStack<?>> tmp = new LinkedList<>();
50+
for (int i = 0; i < compressed.size(); i ++) {
51+
if (compressed.get(i) == null) continue;
52+
ItemStack item = compressed.get(i).items[0];
53+
OrderStack<?> stack;
54+
if (item.getItem() instanceof ItemFluidDisplay) {
55+
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
56+
if (fluid == null || fluid.amount <= 0) continue;
57+
stack = new OrderStack<>(fluid, i);
58+
tmp.add(stack);
59+
} else {
60+
stack = OrderStack.pack(compressed.get(i), i);
61+
if (stack != null) tmp.add(stack);
62+
}
63+
}
64+
return tmp;
65+
}
66+
67+
private void removeMachine(List<PositionedStack> list) {
68+
for (int i = list.size() - 1; i >= 0; i --) {
69+
PositionedStack positionedStack = list.get(i);
70+
if (positionedStack != null) {
71+
for (ItemStack machine : this.Recipes.mRecipeMachineList) {
72+
if (positionedStack.items[0].isItemEqual(machine)) {
73+
list.remove(i);
74+
break;
75+
}
76+
}
77+
}
78+
}
79+
}
80+
81+
private List<PositionedStack> compress(List<PositionedStack> list) {
82+
List<PositionedStack> comp = new LinkedList<>();
83+
for (PositionedStack positionedStack : list) {
84+
if (positionedStack == null) continue;
85+
ItemStack currentStack = positionedStack.items[0].copy();
86+
if (currentStack.stackSize == 0) continue;
87+
boolean find = false;
88+
for (PositionedStack storedStack : comp) {
89+
if (storedStack == null) continue;
90+
ItemStack firstStack = storedStack.items[0].copy();
91+
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
92+
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
93+
find = true;
94+
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
95+
}
96+
}
97+
if (!find) {
98+
comp.add(positionedStack.copy());
99+
}
100+
}
101+
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
102+
}
103+
104+
}

src/main/java/com/glodblock/github/nei/recipes/extractor/VanillaRecipeExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class VanillaRecipeExtractor implements IRecipeExtractor {
1111

12-
private boolean c;
12+
private final boolean c;
1313

1414
public VanillaRecipeExtractor(boolean isCraft) {
1515
c = isCraft;

src/main/java/com/glodblock/github/util/ModAndClassUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public final class ModAndClassUtil {
1313
public static boolean GT5 = false;
1414
public static boolean GT6 = false;
1515
public static boolean EC2 = false;
16+
public static boolean EIO = false;
1617

1718
public static boolean isDoubleButton;
1819
public static boolean isSaveText;
@@ -68,6 +69,8 @@ public static void init() {
6869
GT6 = true;
6970
if (Loader.isModLoaded("extracells"))
7071
EC2 = true;
72+
if (Loader.isModLoaded("EnderIO"))
73+
EIO = true;
7174

7275
}
7376

0 commit comments

Comments
 (0)