Skip to content

Commit c5a75cf

Browse files
authored
Merge pull request #2 from DianeXD/master
Adapt to gtnh version and add gtpp support
2 parents 7c929f9 + f08a6ca commit c5a75cf

File tree

8 files changed

+86
-88
lines changed

8 files changed

+86
-88
lines changed

dependencies.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies {
55
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev')
66
compile('curse.maven:cofh-core-69162:2388751')
77
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
8-
compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
8+
compile("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
99

1010
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
1111
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
@@ -15,4 +15,5 @@ dependencies {
1515
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
1616
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
1717
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
18+
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
1819
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.glodblock.github.util.ModAndClassUtil;
55
import forestry.factory.recipes.nei.*;
66
import gregapi.recipes.Recipe;
7+
import gregtech.api.util.GTPP_Recipe;
78
import gregtech.api.util.GT_Recipe;
89

910
public class DefaultExtractorLoader implements Runnable {
@@ -27,6 +28,14 @@ public void run() {
2728
}
2829
}
2930

31+
if (ModAndClassUtil.GTPP) {
32+
for (GTPP_Recipe.GTPP_Recipe_Map_Internal gtppMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) {
33+
if (gtppMap.mNEIAllowed) {
34+
FluidRecipe.addRecipeMap(gtppMap.mNEIName, new GTPPRecipeExtractor());
35+
}
36+
}
37+
}
38+
3039
if (ModAndClassUtil.EIO) {
3140
FluidRecipe.addRecipeMap("EIOEnchanter", new EnderIORecipeExtractor());
3241
FluidRecipe.addRecipeMap("EnderIOAlloySmelter", new EnderIORecipeExtractor());
@@ -37,6 +46,17 @@ public void run() {
3746
}
3847

3948
if (ModAndClassUtil.FTR) {
49+
// GTNH
50+
FluidRecipe.addRecipeMap("forestry.bottler", new ForestryRecipeExtractor(new NEIHandlerBottler()));
51+
FluidRecipe.addRecipeMap("forestry.carpenter", new ForestryRecipeExtractor(new NEIHandlerCarpenter()));
52+
FluidRecipe.addRecipeMap("forestry.centrifuge", new ForestryRecipeExtractor(new NEIHandlerCentrifuge()));
53+
FluidRecipe.addRecipeMap("forestry.fabricator", new ForestryRecipeExtractor(new NEIHandlerFabricator()));
54+
FluidRecipe.addRecipeMap("forestry.fermenter", new ForestryRecipeExtractor(new NEIHandlerFermenter()));
55+
FluidRecipe.addRecipeMap("forestry.moistener", new ForestryRecipeExtractor(new NEIHandlerMoistener()));
56+
FluidRecipe.addRecipeMap("forestry.squeezer", new ForestryRecipeExtractor(new NEIHandlerSqueezer()));
57+
FluidRecipe.addRecipeMap("forestry.still", new ForestryRecipeExtractor(new NEIHandlerStill()));
58+
59+
// LEGACY
4060
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerBottler()));
4161
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCarpenter()));
4262
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCentrifuge()));

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

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
import codechicken.nei.recipe.TemplateRecipeHandler;
66
import com.glodblock.github.nei.object.IRecipeExtractorLegacy;
77
import com.glodblock.github.nei.object.OrderStack;
8-
import crazypants.enderio.nei.VatRecipeHandler;
8+
import com.glodblock.github.util.NEIUtil;
99
import forestry.core.recipes.nei.PositionedFluidTank;
1010
import forestry.core.recipes.nei.RecipeHandlerBase;
1111
import forestry.factory.recipes.nei.NEIHandlerFabricator;
1212
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
13-
import net.minecraft.item.ItemStack;
1413
import net.minecraftforge.fluids.FluidStack;
1514

1615
import java.util.ArrayList;
1716
import java.util.LinkedList;
1817
import java.util.List;
19-
import java.util.Objects;
20-
import java.util.stream.Collectors;
2118

2219
public class ForestryRecipeExtractor implements IRecipeExtractorLegacy {
2320

@@ -58,7 +55,7 @@ public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs
5855
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
5956
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
6057
List<OrderStack<?>> tmp = new ArrayList<>();
61-
List<PositionedStack> compressed = compress(rawInputs);
58+
List<PositionedStack> compressed = NEIUtil.compress(rawInputs);
6259
if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) {
6360
tmp = getInputIngredients(compressed);
6461
List<PositionedFluidTank> tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks();
@@ -77,7 +74,7 @@ public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs
7774
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
7875
removeGlass(rawOutputs);
7976
List<OrderStack<?>> tmp = new ArrayList<>();
80-
List<PositionedStack> compressed = compress(rawOutputs);
77+
List<PositionedStack> compressed = NEIUtil.compress(rawOutputs);
8178
if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) {
8279
tmp = getOutputIngredients(compressed);
8380
List<PositionedFluidTank> tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks();
@@ -97,29 +94,6 @@ else if (tanks.size() > 1) {
9794
return tmp;
9895
}
9996

100-
private List<PositionedStack> compress(List<PositionedStack> list) {
101-
List<PositionedStack> comp = new LinkedList<>();
102-
for (PositionedStack positionedStack : list) {
103-
if (positionedStack == null) continue;
104-
ItemStack currentStack = positionedStack.items[0].copy();
105-
if (currentStack.stackSize == 0) continue;
106-
boolean find = false;
107-
for (PositionedStack storedStack : comp) {
108-
if (storedStack == null) continue;
109-
ItemStack firstStack = storedStack.items[0].copy();
110-
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
111-
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
112-
find = true;
113-
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
114-
}
115-
}
116-
if (!find) {
117-
comp.add(positionedStack.copy());
118-
}
119-
}
120-
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
121-
}
122-
12397
private void removeGlass(List<PositionedStack> list) {
12498
if (handler instanceof NEIHandlerFabricator) {
12599
list.remove(list.size() - 1);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.glodblock.github.nei.recipes.extractor;
2+
3+
public class GTPPRecipeExtractor extends GregTech5RecipeExtractor {
4+
5+
public GTPPRecipeExtractor() {
6+
super(false);
7+
}
8+
9+
public GTPPRecipeExtractor(boolean removeSpecial) {
10+
super(removeSpecial);
11+
}
12+
13+
}

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

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import codechicken.nei.PositionedStack;
44
import com.glodblock.github.nei.object.IRecipeExtractor;
55
import com.glodblock.github.nei.object.OrderStack;
6+
import com.glodblock.github.util.NEIUtil;
67
import gregtech.api.enums.ItemList;
78
import gregtech.common.items.GT_FluidDisplayItem;
89
import net.minecraft.item.ItemStack;
@@ -12,21 +13,19 @@
1213

1314
import java.util.LinkedList;
1415
import java.util.List;
15-
import java.util.Objects;
16-
import java.util.stream.Collectors;
1716

1817
public class GregTech5RecipeExtractor implements IRecipeExtractor {
1918

20-
boolean r;
19+
boolean removeSpecial;
2120

2221
public GregTech5RecipeExtractor(boolean removeSpecial) {
23-
r = removeSpecial;
22+
this.removeSpecial = removeSpecial;
2423
}
2524

2625
@Override
2726
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
28-
if (r) removeSpecial(rawInputs);
29-
List<PositionedStack> compressed = compress(rawInputs);
27+
if (removeSpecial) removeSpecial(rawInputs);
28+
List<PositionedStack> compressed = NEIUtil.compress(rawInputs);
3029
List<OrderStack<?>> tmp = new LinkedList<>();
3130
for (int i = 0; i < compressed.size(); i ++) {
3231
if (compressed.get(i) == null) continue;
@@ -48,7 +47,7 @@ public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs)
4847

4948
@Override
5049
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
51-
List<PositionedStack> compressed = compress(rawOutputs);
50+
List<PositionedStack> compressed = NEIUtil.compress(rawOutputs);
5251
List<OrderStack<?>> tmp = new LinkedList<>();
5352
for (int i = 0; i < compressed.size(); i ++) {
5453
if (compressed.get(i) == null) continue;
@@ -79,27 +78,4 @@ private void removeSpecial(List<PositionedStack> list) {
7978
}
8079
}
8180

82-
private List<PositionedStack> compress(List<PositionedStack> list) {
83-
List<PositionedStack> comp = new LinkedList<>();
84-
for (PositionedStack positionedStack : list) {
85-
if (positionedStack == null) continue;
86-
ItemStack currentStack = positionedStack.items[0].copy();
87-
if (currentStack.stackSize == 0) continue;
88-
boolean find = false;
89-
for (PositionedStack storedStack : comp) {
90-
if (storedStack == null) continue;
91-
ItemStack firstStack = storedStack.items[0].copy();
92-
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
93-
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
94-
find = true;
95-
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
96-
}
97-
}
98-
if (!find) {
99-
comp.add(positionedStack.copy());
100-
}
101-
}
102-
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
103-
}
104-
10581
}

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

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import codechicken.nei.PositionedStack;
44
import com.glodblock.github.nei.object.IRecipeExtractor;
55
import com.glodblock.github.nei.object.OrderStack;
6+
import com.glodblock.github.util.NEIUtil;
67
import gregapi.item.ItemFluidDisplay;
78
import gregapi.recipes.Recipe;
89
import net.minecraft.item.ItemStack;
910
import net.minecraftforge.fluids.FluidStack;
1011

1112
import java.util.LinkedList;
1213
import java.util.List;
13-
import java.util.Objects;
14-
import java.util.stream.Collectors;
1514

1615
public class GregTech6RecipeExtractor implements IRecipeExtractor {
1716

@@ -24,7 +23,7 @@ public GregTech6RecipeExtractor(Recipe.RecipeMap aMap) {
2423
@Override
2524
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
2625
this.removeMachine(rawInputs);
27-
List<PositionedStack> compressed = compress(rawInputs);
26+
List<PositionedStack> compressed = NEIUtil.compress(rawInputs);
2827
List<OrderStack<?>> tmp = new LinkedList<>();
2928
for (int i = 0; i < compressed.size(); i ++) {
3029
if (compressed.get(i) == null) continue;
@@ -45,7 +44,7 @@ public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs)
4544

4645
@Override
4746
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
48-
List<PositionedStack> compressed = compress(rawOutputs);
47+
List<PositionedStack> compressed = NEIUtil.compress(rawOutputs);
4948
List<OrderStack<?>> tmp = new LinkedList<>();
5049
for (int i = 0; i < compressed.size(); i ++) {
5150
if (compressed.get(i) == null) continue;
@@ -78,27 +77,4 @@ private void removeMachine(List<PositionedStack> list) {
7877
}
7978
}
8079

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-
10480
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public final class ModAndClassUtil {
1717
public static boolean EC2 = false;
1818
public static boolean EIO = false;
1919
public static boolean FTR = false;
20+
public static boolean GTPP = false;
2021

2122
public static boolean isDoubleButton;
2223
public static boolean isSaveText;
@@ -95,7 +96,8 @@ public static void init() {
9596
EIO = true;
9697
if (Loader.isModLoaded("Forestry"))
9798
FTR = true;
98-
99+
if (Loader.isModLoaded("miscutils"))
100+
GTPP = true;
99101
}
100102

101103

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.glodblock.github.util;
2+
3+
import codechicken.nei.PositionedStack;
4+
import net.minecraft.item.ItemStack;
5+
6+
import java.util.LinkedList;
7+
import java.util.List;
8+
import java.util.Objects;
9+
import java.util.stream.Collectors;
10+
11+
public class NEIUtil {
12+
13+
public static List<PositionedStack> compress(List<PositionedStack> list) {
14+
List<PositionedStack> comp = new LinkedList<>();
15+
for (PositionedStack positionedStack : list) {
16+
if (positionedStack == null) continue;
17+
ItemStack currentStack = positionedStack.items[0].copy();
18+
if (currentStack.stackSize == 0) continue;
19+
boolean find = false;
20+
for (PositionedStack storedStack : comp) {
21+
if (storedStack == null) continue;
22+
ItemStack firstStack = storedStack.items[0].copy();
23+
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
24+
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
25+
find = true;
26+
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
27+
}
28+
}
29+
if (!find) {
30+
comp.add(positionedStack.copy());
31+
}
32+
}
33+
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
34+
}
35+
36+
}

0 commit comments

Comments
 (0)