aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2023-04-02 00:02:47 +0800
committerGitHub <noreply@github.com>2023-04-01 18:02:47 +0200
commit6b77557e0e87cf5afd9ebd3985323ff1249e615c (patch)
tree36474042ef39f863aedc007eab81a9b09cc7aa78 /src/main/java/gregtech/api/interfaces
parent655cc902d3df19a1ac2bfaa38cc928ed629d0171 (diff)
downloadGT5-Unofficial-6b77557e0e87cf5afd9ebd3985323ff1249e615c.tar.gz
GT5-Unofficial-6b77557e0e87cf5afd9ebd3985323ff1249e615c.tar.bz2
GT5-Unofficial-6b77557e0e87cf5afd9ebd3985323ff1249e615c.zip
Recipe Adder v2 (#1770)
* add everything * fixes * migrate plasma forge recipes * syntax update * make chances array length differ a fatal error * time constants + long eut overload * migrate extruder recipes * migrate electromagnetic separator recipes * migrate wiremill recipes * migrate forming press recipes * migrate bender recipes * add doc to clarify the three itemInputs * migrate alloy smelter recipes * migrate arc furnace recipes * added ModIDs enum * sort ModIDs * migrate autoclave recipes * migrated some assembler recipes * split a bit more assembler recipes * migrate canner recipes * migrate brewing recipes * ic2 mod check in canner recipes * use some loops to reduce the amount of recipes to migrate * add requested helper methods * migrate vacuum freezer recipes * migrate thermal centrifuge recipes * format smelter recipes only, doesn't go through normal GT recipe * migrated slicer recipes * migrated sifter recipes * Use proper enum now * remove more constants * cleaning cutting recipes before migration * remove tons of dead commented recipes * migrate pyrolyse recipes * use ModIDs enum more * migrate printer recipes * add a less confusing way to specify value of specialItem * migrate pulverizer recipes * less confusing special item specification * even more ModIDs enum usage * fix auto * import confusing Minecraft enum value with Minecraft client object * migrated blast furnace recipes * migrated Centrifuge recipes * migrated assembler recipes * migrated implosion compressor recipes * migrated extractor recipes * migrated mixer recipes * remove useless code * mgrate universal chemical recipes * refactor chemical recipes * migrate single block only chem reactor recipes * migrate chem reactor recipes * reworked circuit assembler recipes before migrating them * migrated circuit assembler recipes * fix merge conflict for assembler recipes * remove leftover of the merge conflicts * fix weird translation glitch * example of assembly line recipe using RA2 * bugfixes for assline * remove specialValue usage in blast furnace recipes * fix more bugs * add nooptimize to where it make sense * add recipe descriptions * Materials.Superconductor -> Materials.SuperconductorUHV * remove useless Object creations * remove explicit long casts * migrate assemblyline recipes * migrate chemical bath recipes * migrate compressor recipes * move smelting recipe where it belongs * migrated cutting machine recipes * migrated fermenter recipes (unhide alcohol) * remove explicit long casts * migrate fluid canner recipes * migrate fluid heater recipes * migrated fusion recipes * migrated lathe recipes * migrated laser engraver recipes * migrated packager recipes * migrated forge hammer recipes * migrated TPM recipes * exit early and reduced indents * migrated fluid extractor recipes * migrated fluid solidifier recipes * migrated electrolyzer recipes * migrated crop processing recipes * migrated default polymerization recipes * migrate distillery recipes * migrate matter amplifier recipes * add metadata identifier for fusion ignition threshold * migrate fuel recipes * update bs (cherry picked from commit c2d931c9b6caa0376e9d50591894cd849021104d) * spotless (cherry picked from commit 1060f5357fb95e28bfae1f052025f55dabc21a0f) * guard against null itemstacks * wrong translation * fix empty arrays being accessed * add 0 duration and 0 EU/t for fuel recipes * fix typo in matter amplifier recipes * spotless apply --------- Co-authored-by: boubou19 <miisterunknown@gmail.com> Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/api/interfaces')
-rw-r--r--src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java64
-rw-r--r--src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java3
2 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java b/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java
new file mode 100644
index 0000000000..69f87161d1
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java
@@ -0,0 +1,64 @@
+package gregtech.api.interfaces;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_RecipeBuilder;
+import gregtech.api.util.GT_Utility;
+
+/**
+ * Represents the target of a recipe adding action, usually, but not necessarily, is a recipe map itself.
+ */
+public interface IGT_RecipeMap {
+
+ /**
+ * Add a downstream recipe map that will get to handle the original builder.
+ *
+ * @param downstream
+ */
+ void addDownstream(IGT_RecipeMap downstream);
+
+ /**
+ * Actually add the recipe represented by the builder. CAN modify the builder's internal states!!!
+ */
+ @Nonnull
+ Collection<GT_Recipe> doAdd(GT_RecipeBuilder builder);
+
+ /**
+ * Return a variant of this recipe map that will perform a deep copy on input recipe builder before doing anything
+ * to it.
+ *
+ * The returned recipe map will not have any downstreams, but can accept new downstreams.
+ */
+ default IGT_RecipeMap deepCopyInput() {
+ return newRecipeMap(b -> doAdd(b.copy()));
+ }
+
+ static IGT_RecipeMap newRecipeMap(Function<? super GT_RecipeBuilder, Collection<GT_Recipe>> func) {
+ return new IGT_RecipeMap() {
+
+ private final Collection<IGT_RecipeMap> downstreams = new ArrayList<>();
+
+ @Override
+ public void addDownstream(IGT_RecipeMap downstream) {
+ downstreams.add(downstream);
+ }
+
+ @Nonnull
+ @Override
+ public Collection<GT_Recipe> doAdd(GT_RecipeBuilder builder) {
+ List<Collection<GT_Recipe>> ret = new ArrayList<>();
+ ret.add(func.apply(builder));
+ for (IGT_RecipeMap downstream : downstreams) {
+ ret.add(downstream.doAdd(builder));
+ }
+ return GT_Utility.concat(ret);
+ }
+ };
+ }
+}
diff --git a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
index bda2523811..149600b426 100644
--- a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
+++ b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java
@@ -5,6 +5,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_RecipeBuilder;
public interface IGT_RecipeAdder {
@@ -960,4 +961,6 @@ public interface IGT_RecipeAdder {
*/
GT_Recipe addIC2ReactorFuelCell(ItemStack input, ItemStack output, boolean aMox, float aHeat, float aEnergy,
int aCells);
+
+ GT_RecipeBuilder stdBuilder();
}