aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_Recipe.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Recipe.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java5789
1 files changed, 122 insertions, 5667 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 535da25934..a444a16ef2 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -1,148 +1,38 @@
package gregtech.api.util;
-import static gregtech.api.enums.GT_Values.D1;
import static gregtech.api.enums.GT_Values.D2;
-import static gregtech.api.enums.GT_Values.E;
-import static gregtech.api.enums.GT_Values.L;
-import static gregtech.api.enums.GT_Values.W;
-import static gregtech.api.enums.Mods.GTPlusPlus;
-import static gregtech.api.enums.Mods.GregTech;
-import static gregtech.api.enums.Mods.NEICustomDiagrams;
-import static gregtech.api.enums.Mods.Railcraft;
-import static gregtech.api.recipe.check.FindRecipeResult.EXPLODE;
-import static gregtech.api.recipe.check.FindRecipeResult.NOT_FOUND;
-import static gregtech.api.recipe.check.FindRecipeResult.ON_FIRE;
-import static gregtech.api.recipe.check.FindRecipeResult.ofSuccess;
-import static gregtech.api.util.GT_RecipeBuilder.handleRecipeCollision;
-import static gregtech.api.util.GT_RecipeConstants.ADDITIVE_AMOUNT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUIDSTACK_INPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUIDSTACK_OUTPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUID_OUTPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_INPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OR_FLUID_INPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OR_FLUID_OUTPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OUTPUT;
-import static gregtech.api.util.GT_RecipeMapUtil.GT_RecipeTemplate;
-import static gregtech.api.util.GT_RecipeMapUtil.SPECIAL_VALUE_ALIASES;
-import static gregtech.api.util.GT_RecipeMapUtil.asTemplate;
-import static gregtech.api.util.GT_RecipeMapUtil.buildOrEmpty;
-import static gregtech.api.util.GT_Utility.formatNumbers;
-import static gregtech.api.util.GT_Utility.isArrayEmptyOrNull;
-import static gregtech.api.util.GT_Utility.isArrayOfLength;
-import static net.minecraft.util.EnumChatFormatting.GRAY;
-import static net.minecraft.util.StatCollector.translateToLocal;
-import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntityFurnace;
-import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidContainerItem;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
+import org.jetbrains.annotations.Contract;
-import com.google.common.collect.Iterables;
-import com.gtnewhorizons.modularui.api.GlStateManager;
-import com.gtnewhorizons.modularui.api.ModularUITextures;
-import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture;
-import com.gtnewhorizons.modularui.api.drawable.IDrawable;
-import com.gtnewhorizons.modularui.api.drawable.UITexture;
-import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable;
-import com.gtnewhorizons.modularui.api.math.Alignment;
-import com.gtnewhorizons.modularui.api.math.Pos2d;
-import com.gtnewhorizons.modularui.api.math.Size;
-import com.gtnewhorizons.modularui.api.screen.ModularWindow;
-import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
-import com.gtnewhorizons.modularui.common.widget.ProgressBar;
-import com.gtnewhorizons.modularui.common.widget.SlotWidget;
-
-import appeng.util.ReadableNumberConverter;
-import codechicken.lib.gui.GuiDraw;
-import codechicken.nei.PositionedStack;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
-import gnu.trove.map.TByteObjectMap;
-import gnu.trove.map.hash.TByteObjectHashMap;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.ConfigCategories;
-import gregtech.api.enums.Dyes;
-import gregtech.api.enums.Element;
-import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
-import gregtech.api.enums.OrePrefixes;
-import gregtech.api.enums.SteamVariant;
-import gregtech.api.enums.SubTag;
-import gregtech.api.gui.GT_GUIColorOverride;
-import gregtech.api.gui.modularui.FallbackableSteamTexture;
-import gregtech.api.gui.modularui.GT_UITextures;
-import gregtech.api.gui.modularui.SteamTexture;
-import gregtech.api.interfaces.IGT_RecipeMap;
-import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.objects.ItemData;
-import gregtech.api.objects.MaterialStack;
-import gregtech.api.recipe.check.FindRecipeResult;
+import gregtech.api.recipe.RecipeCategory;
+import gregtech.api.recipe.RecipeMap;
+import gregtech.api.recipe.RecipeMaps;
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.recipe.metadata.EmptyRecipeMetadataStorage;
+import gregtech.api.recipe.metadata.IRecipeMetadataStorage;
import gregtech.api.util.extensions.ArrayExt;
-import gregtech.common.gui.modularui.UIHelper;
-import gregtech.common.items.GT_FluidDisplayItem;
-import gregtech.common.misc.spaceprojects.SpaceProjectManager;
-import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
-import gregtech.common.power.EUPower;
-import gregtech.common.power.Power;
-import gregtech.common.power.UnspecifiedEUPower;
-import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator;
-import gregtech.nei.FusionSpecialValueFormatter;
-import gregtech.nei.GT_NEI_DefaultHandler;
-import gregtech.nei.HeatingCoilSpecialValueFormatter;
-import gregtech.nei.INEISpecialInfoFormatter;
-import gregtech.nei.NEIRecipeInfo;
import ic2.core.Ic2Items;
-import mods.railcraft.common.blocks.aesthetics.cube.EnumCube;
-import mods.railcraft.common.items.RailcraftToolItems;
-/**
- * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
- * <p/>
- * This File contains the functions used for Recipes. Please do not include this File AT ALL in your Moddownload as it
- * ruins compatibility This is just the Core of my Recipe System, if you just want to GET the Recipes I add, then you
- * can access this File. Do NOT add Recipes using the Constructors inside this Class, The GregTech_API File calls the
- * correct Functions for these Constructors.
- * <p/>
- * I know this File causes some Errors, because of missing Main Functions, but if you just need to compile Stuff, then
- * remove said erroreous Functions.
- */
public class GT_Recipe implements Comparable<GT_Recipe> {
/**
@@ -200,13 +90,24 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
*/
private String[] neiDesc = null;
/**
+ * Holds a set of metadata for this recipe.
+ */
+ @Nonnull
+ private final IRecipeMetadataStorage metadataStorage;
+ /**
+ * Category this recipe belongs to. Recipes belonging to recipemap are forced to have non-null category when added,
+ * otherwise it can be null.
+ */
+ private RecipeCategory recipeCategory;
+ /**
* Stores which mod added this recipe
*/
public List<ModContainer> owners = new ArrayList<>();
/**
* Stores stack traces where this recipe was added
*/
- public List<List<StackTraceElement>> stackTraces = new ArrayList<>();
+ // BW wants to overwrite it, so no final
+ public List<List<String>> stackTraces = new ArrayList<>();
private GT_Recipe(GT_Recipe aRecipe, boolean shallow) {
mInputs = shallow ? aRecipe.mInputs : GT_Utility.copyItemArray(aRecipe.mInputs);
@@ -219,18 +120,23 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mSpecialValue = aRecipe.mSpecialValue;
mEUt = aRecipe.mEUt;
mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput;
+ isNBTSensitive = aRecipe.isNBTSensitive;
mCanBeBuffered = aRecipe.mCanBeBuffered;
mFakeRecipe = aRecipe.mFakeRecipe;
mEnabled = aRecipe.mEnabled;
mHidden = aRecipe.mHidden;
+ metadataStorage = EmptyRecipeMetadataStorage.INSTANCE;
owners = new ArrayList<>(aRecipe.owners);
reloadOwner();
}
- // only used for GT_RecipeBuilder. Should not be called otherwise
+ /**
+ * Only for {@link GT_RecipeBuilder}.
+ */
GT_Recipe(ItemStack[] mInputs, ItemStack[] mOutputs, FluidStack[] mFluidInputs, FluidStack[] mFluidOutputs,
int[] mChances, Object mSpecialItems, int mDuration, int mEUt, int mSpecialValue, boolean mEnabled,
- boolean mHidden, boolean mFakeRecipe, boolean mCanBeBuffered, boolean mNeedsEmptyOutput, String[] neiDesc) {
+ boolean mHidden, boolean mFakeRecipe, boolean mCanBeBuffered, boolean mNeedsEmptyOutput, boolean nbtSensitive,
+ String[] neiDesc, @Nullable IRecipeMetadataStorage metadataStorage, RecipeCategory recipeCategory) {
this.mInputs = mInputs;
this.mOutputs = mOutputs;
this.mFluidInputs = mFluidInputs;
@@ -245,7 +151,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
this.mFakeRecipe = mFakeRecipe;
this.mCanBeBuffered = mCanBeBuffered;
this.mNeedsEmptyOutput = mNeedsEmptyOutput;
+ this.isNBTSensitive = nbtSensitive;
this.neiDesc = neiDesc;
+ this.metadataStorage = metadataStorage == null ? EmptyRecipeMetadataStorage.INSTANCE : metadataStorage.copy();
+ this.recipeCategory = recipeCategory;
reloadOwner();
}
@@ -311,19 +220,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mDuration = aDuration;
mSpecialValue = aSpecialValue;
mEUt = aEUt;
+ metadataStorage = EmptyRecipeMetadataStorage.INSTANCE;
// checkCellBalance();
reloadOwner();
}
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) {
- this(aInput1, aOutput1, null, null, null, aFuelValue, aType);
- }
-
- private static FluidStack[] tryGetFluidInputsFromCells(ItemStack aInput) {
- FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true);
- return tFluid == null ? null : new FluidStack[] { tFluid };
- }
-
// aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4,
int aSpecialValue, int aType) {
@@ -343,208 +244,32 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
switch (aType) {
// Diesel Generator
case 0 -> {
- GT_Recipe_Map.sDieselFuels.addRecipe(this);
- GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this);
+ RecipeMaps.dieselFuels.addRecipe(this);
+ RecipeMaps.largeBoilerFakeFuels.getBackend()
+ .addDieselRecipe(this);
}
// Gas Turbine
- case 1 -> GT_Recipe_Map.sTurbineFuels.addRecipe(this);
+ case 1 -> RecipeMaps.gasTurbineFuels.addRecipe(this);
// Thermal Generator
- case 2 -> GT_Recipe_Map.sHotFuels.addRecipe(this);
+ case 2 -> RecipeMaps.hotFuels.addRecipe(this);
// Plasma Generator
- case 4 -> GT_Recipe_Map.sPlasmaFuels.addRecipe(this);
+ case 4 -> RecipeMaps.plasmaFuels.addRecipe(this);
// Magic Generator
- case 5 -> GT_Recipe_Map.sMagicFuels.addRecipe(this);
+ case 5 -> RecipeMaps.magicFuels.addRecipe(this);
// Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator
default -> {
- GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this);
- GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this);
+ RecipeMaps.denseLiquidFuels.addRecipe(this);
+ RecipeMaps.largeBoilerFakeFuels.getBackend()
+ .addDenseLiquidRecipe(this);
}
}
}
}
- public GT_Recipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt,
- int aSpecialValue) {
- this(
- true,
- null,
- null,
- null,
- null,
- new FluidStack[] { aInput1, aInput2 },
- new FluidStack[] { aOutput1 },
- Math.max(aDuration, 1),
- aEUt,
- Math.max(Math.min(aSpecialValue, 160000000), 0));
- if (mInputs.length > 1) {
- GT_Recipe_Map.sFusionRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt) {
- this(
- true,
- new ItemStack[] { aInput1 },
- new ItemStack[] { aOutput1, aOutput2 },
- null,
- null,
- null,
- null,
- aDuration,
- aEUt,
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sLatheRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aCellAmount, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3,
- ItemStack aOutput4, int aDuration, int aEUt) {
- this(
- true,
- new ItemStack[] { aInput1,
- aCellAmount > 0 ? ItemList.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))) : null },
- new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- Math.max(aEUt, 1),
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sDistillationRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) {
- this(
- true,
- new ItemStack[] { aInput1,
- GT_ModHandler.getIC2Item(
- "industrialTnt",
- aInput2 > 0 ? Math.min(aInput2, 64) : 1,
- new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1)) },
- new ItemStack[] { aOutput1, aOutput2 },
- null,
- null,
- null,
- null,
- 20,
- 30,
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sImplosionRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aOutput1) {
- this(
- true,
- new ItemStack[] { aInput1, ItemList.Circuit_Integrated.getWithDamage(0, aInput1.stackSize) },
- new ItemStack[] { aOutput1 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- Math.max(aEUt, 1),
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sBenderRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aInput2, int aEUt, int aDuration, ItemStack aOutput1) {
- this(
- true,
- aInput2 == null ? new ItemStack[] { aInput1 } : new ItemStack[] { aInput1, aInput2 },
- new ItemStack[] { aOutput1 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- Math.max(aEUt, 1),
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sAlloySmelterRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1,
- ItemStack aOutput2) {
- this(
- true,
- aInput2 == null ? new ItemStack[] { aInput1 } : new ItemStack[] { aInput1, aInput2 },
- new ItemStack[] { aOutput1, aOutput2 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- Math.max(aEUt, 1),
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sCannerRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration) {
- this(
- true,
- new ItemStack[] { aInput1 },
- new ItemStack[] { aOutput1 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- 120,
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt, int VACUUM) {
- this(
- true,
- new ItemStack[] { aInput1 },
- new ItemStack[] { aOutput1 },
- null,
- null,
- null,
- null,
- Math.max(aDuration, 1),
- aEUt,
- 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(FluidStack aInput1, FluidStack aOutput1, int aDuration, int aEUt) {
- this(
- false,
- null,
- null,
- null,
- null,
- new FluidStack[] { aInput1 },
- new FluidStack[] { aOutput1 },
- Math.max(aDuration, 1),
- aEUt,
- 0);
- if (mFluidInputs.length > 0 && mFluidOutputs[0] != null) {
- GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
- }
- }
-
// Dummy GT_Recipe maker...
public GT_Recipe(ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances,
FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
@@ -561,15 +286,17 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
aSpecialValue);
}
+ /**
+ * Re-unificates all the items present in recipes.
+ */
public static void reInit() {
GT_Log.out.println("GT_Mod: Re-Unificating Recipes.");
- for (GT_Recipe_Map tMapEntry : GT_Recipe_Map.sMappings) tMapEntry.reInit();
+ for (RecipeMap<?> map : RecipeMap.ALL_RECIPE_MAPS.values()) {
+ map.getBackend()
+ .reInit();
+ }
}
- // -----
- // Old Constructors, do not use!
- // -----
-
public ItemStack getRepresentativeInput(int aIndex) {
if (aIndex < 0 || aIndex >= mInputs.length) return null;
return GT_Utility.copyOrNull(mInputs[aIndex]);
@@ -580,16 +307,14 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
return GT_Utility.copyOrNull(mOutputs[aIndex]);
}
- /***
+ /**
* Dictates the ItemStacks displayed in the output slots of any NEI page handled by the default GT NEI handler.
* Override to make shown items differ from a GT_Recipe's item output array
*
* @see gregtech.nei.GT_NEI_DefaultHandler
* @param i Slot index
* @return ItemStack to be displayed in the slot
- *
*/
- //
public ItemStack getRepresentativeOutput(int i) {
return getOutput(i);
}
@@ -851,59 +576,100 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
/**
* Sets description shown on NEI. <br>
* If you have a large number of recipes for the recipemap, this is not efficient memory wise, so use
- * {@link GT_Recipe_Map#setNEISpecialInfoFormatter} instead.
+ * {@link gregtech.api.recipe.RecipeMapBuilder#neiSpecialInfoFormatter} instead.
*/
- protected void setNeiDesc(String... neiDesc) {
+ public void setNeiDesc(String... neiDesc) {
this.neiDesc = neiDesc;
}
+ // region metadata
+
+ // Don't try implementing setMetadata, as metadataStorage can be EmptyRecipeMetadataStorage
+
+ /**
+ * Gets metadata associated with this recipe. Can return null. Use
+ * {@link #getMetadataOrDefault(RecipeMetadataKey, Object)}
+ * if you want to specify default value.
+ */
+ @Nullable
+ public <T> T getMetadata(RecipeMetadataKey<T> key) {
+ return key.cast(metadataStorage.getMetadata(key));
+ }
+
/**
- * Use {@link GT_Recipe_Map#getItemInputPositions} or {@link GT_Recipe_Map#getSpecialItemPosition} or
- * {@link GT_Recipe_Map#getFluidInputPositions} instead
+ * Gets metadata associated with this recipe with default value. Does not return null unless default value is null.
*/
- @SuppressWarnings("DeprecatedIsStillUsed")
- @Deprecated
- public ArrayList<PositionedStack> getInputPositionedStacks() {
- return null;
+ @Contract("_, !null -> !null")
+ @Nullable
+ public <T> T getMetadataOrDefault(RecipeMetadataKey<T> key, @Nullable T defaultValue) {
+ return key.cast(metadataStorage.getMetadataOrDefault(key, defaultValue));
+ }
+
+ @Nonnull
+ public IRecipeMetadataStorage getMetadataStorage() {
+ return metadataStorage;
+ }
+
+ // endregion
+
+ public RecipeCategory getRecipeCategory() {
+ return recipeCategory;
}
/**
- * Use {@link GT_Recipe_Map#getItemOutputPositions} or {@link GT_Recipe_Map#getFluidOutputPositions} instead
+ * Exists only for recipe copying from external. For ordinal use case, use {@link GT_RecipeBuilder#recipeCategory}.
*/
- @SuppressWarnings("DeprecatedIsStillUsed")
- @Deprecated
- public ArrayList<PositionedStack> getOutputPositionedStacks() {
- return null;
+ public void setRecipeCategory(RecipeCategory recipeCategory) {
+ this.recipeCategory = recipeCategory;
}
+ private static final List<String> excludedStacktraces = Arrays.asList(
+ "java.lang.Thread",
+ "gregtech.api.interfaces.IRecipeMap",
+ "gregtech.api.interfaces.IRecipeMap$1",
+ "gregtech.api.recipe.RecipeMap",
+ "gregtech.api.recipe.RecipeMapBackend",
+ "gregtech.api.recipe.RecipeMapBackendPropertiesBuilder",
+ "gregtech.api.util.GT_Recipe",
+ "gregtech.api.util.GT_RecipeBuilder",
+ "gregtech.api.util.GT_RecipeConstants",
+ "gregtech.api.util.GT_RecipeMapUtil",
+ "gregtech.common.GT_RecipeAdder");
+
public void reloadOwner() {
setOwner(
Loader.instance()
.activeModContainer());
- final List<String> excludedClasses = Arrays.asList(
- "java.lang.Thread",
- "gregtech.api.util.GT_Recipe",
- "gregtech.api.util.GT_RecipeBuilder",
- "gregtech.api.util.GT_Recipe$GT_Recipe_Map",
- "gregtech.common.GT_RecipeAdder");
if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace) {
- List<StackTraceElement> toAdd = new ArrayList<>();
+ List<String> toAdd = new ArrayList<>();
for (StackTraceElement stackTrace : Thread.currentThread()
.getStackTrace()) {
- if (excludedClasses.stream()
+ if (excludedStacktraces.stream()
.noneMatch(
c -> stackTrace.getClassName()
.equals(c))) {
- toAdd.add(stackTrace);
+ toAdd.add(formatStackTrace(stackTrace));
}
}
stackTraces.add(toAdd);
}
}
+ private static String formatStackTrace(StackTraceElement stackTraceElement) {
+ String raw = stackTraceElement.toString();
+ int startParen = raw.lastIndexOf('(');
+ int colon = raw.lastIndexOf(':');
+ if (colon == -1) {
+ // native or unknown source
+ return raw;
+ }
+ // strip class name and leave line number, as class name is already shown
+ return raw.substring(0, startParen + 1) + raw.substring(colon);
+ }
+
public void setOwner(ModContainer newOwner) {
- ModContainer oldOwner = owners.size() > 0 ? this.owners.get(owners.size() - 1) : null;
+ ModContainer oldOwner = !owners.isEmpty() ? this.owners.get(owners.size() - 1) : null;
if (newOwner != null && newOwner != oldOwner) {
owners.add(newOwner);
}
@@ -1144,5146 +910,19 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
}
}
- @SuppressWarnings("StaticInitializerReferencesSubClass")
- public static class GT_Recipe_Map implements IGT_RecipeMap {
-
- /**
- * Contains all Recipe Maps
- */
- public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<>();
- /**
- * All recipe maps indexed by their {@link #mUniqueIdentifier}.
- */
- public static final Map<String, GT_Recipe_Map> sIndexedMappings = new HashMap<>();
-
- static final String TEXTURES_GUI_BASICMACHINES = "textures/gui/basicmachines";
- public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(
- new HashSet<>(500),
- "gt.recipe.orewasher",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "OreWasher"),
- 1,
- 3,
- 1,
- 1,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE)
- .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST)
- .setRecipeConfigFile("orewasher", FIRST_ITEM_INPUT)
- .setProgressBar(GT_UITextures.PROGRESSBAR_BATH, ProgressBar.Direction.CIRCULAR_CW);
- public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(
- new HashSet<>(1000),
- "gt.recipe.thermalcentrifuge",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "ThermalCentrifuge"),
- 1,
- 3,
- 1,
- 0,
- 2,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE)
- .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST)
- .setRecipeConfigFile("thermalcentrifuge", FIRST_ITEM_INPUT)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
- public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(
- new HashSet<>(750),
- "gt.recipe.compressor",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Compressor"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_COMPRESSOR)
- .setRecipeConfigFile("compressor", FIRST_ITEM_INPUT)
- .setProgressBar(GT_UITextures.PROGRESSBAR_COMPRESS, ProgressBar.Direction.RIGHT)
- .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_COMPRESSOR_STEAM)
- .setProgressBarSteam(GT_UITextures.PROGRESSBAR_COMPRESS_STEAM);
- public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(
- new HashSet<>(250),
- "gt.recipe.extractor",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Extractor"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE)
- .setRecipeConfigFile("extractor", FIRST_ITEM_INPUT)
- .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT)
- .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE_STEAM)
- .setProgressBarSteam(GT_UITextures.PROGRESSBAR_EXTRACT_STEAM);
- public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(
- new HashSet<>(0),
- "ic.recipe.recycler",
- null,
- "ic2.recycler",
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Recycler"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- false).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_RECYCLE)
- .setProgressBar(GT_UITextures.PROGRESSBAR_RECYCLE, ProgressBar.Direction.CIRCULAR_CW);
- public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(
- new HashSet<>(0),
- "mc.recipe.furnace",
- "Furnace",
- "smelting",
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "E_Furnace"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- false).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_FURNACE)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT)
- .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_FURNACE_STEAM)
- .setProgressBarSteam(GT_UITextures.PROGRESSBAR_ARROW_STEAM);
- public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(
- new HashSet<>(0),
- "gt.recipe.microwave",
- null,
- "smelting",
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "E_Furnace"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- false).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_FURNACE)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
-
- public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(
- new HashSet<>(300),
- "gt.recipe.scanner",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Scanner"),
- 1,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_MICROSCOPE)
- .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
- public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(
- new HashSet<>(200),
- "gt.recipe.rockbreaker",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "RockBreaker"),
- 2,
- 1,
- 0,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_DUST)
- .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE)
- .setProgressBar(GT_UITextures.PROGRESSBAR_MACERATE, ProgressBar.Direction.RIGHT);
- @Deprecated
- public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(
- new HashSet<>(1000),
- "gt.recipe.byproductlist",
- "Ore Byproduct List",
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Default"),
- 1,
- 6,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- false).setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
- public static final GT_Recipe_Map sReplicatorFakeRecipes = new ReplicatorFakeMap(
- new HashSet<>(100),
- "gt.recipe.replicator",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Replicator"),
- 0,
- 1,
- 0,
- 1,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CANISTER)
- .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_UUM)
- .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
- public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map_AssemblyLineFake(
- new HashSet<>(110),
- "gt.recipe.fakeAssemblylineProcess",
- "Assemblyline Process",
- null,
- GregTech.getResourcePath("textures", "gui", "FakeAssemblyline"),
- 16,
- 1,
- 1,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB)
- .setUsualFluidInputCount(4)
- .setDisableOptimize(true);
- /**
- * Usually, but not always, you should use {@link GT_RecipeConstants#UniversalArcFurnace} instead.
- */
- public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(
- new HashSet<>(20000),
- "gt.recipe.plasmaarcfurnace",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "PlasmaArcFurnace"),
- 1,
- 9,
- 1,
- 1,
- 1,
- E,
- 1,
- E,
- true,
- true).setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT)
- .setRecipeConfigFile("arcfurnace", FIRST_ITEM_INPUT);
- /**
- * Usually, but not always, you should use {@link GT_RecipeConstants#UniversalArcFurnace} instead.
- */
- public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(
- new HashSet<>(20000),
- "gt.recipe.arcfurnace",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "ArcFurnace"),
- 1,
- 9,
- 1,
- 1,
- 3,
- E,
- 1,
- E,
- true,
- true).setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT)
- .setRecipeConfigFile("arcfurnace", FIRST_ITEM_INPUT);
- public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(
- new HashSet<>(5),
- "gt.recipe.printer",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Printer"),
- 1,
- 1,
- 1,
- 1,
- 1,
- E,
- 1,
- E,
- true,
- true).setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_PAGE_BLANK)
- .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_PAGE_PRINTED)
- .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_STICK)
- .setRecipeConfigFile("printer", FIRST_ITEM_INPUT)
- .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT);
- public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(
- new HashSet<>(105),
- "gt.recipe.sifter",
- null,
- null,
- GregTech.getResourcePath(TEXTURES_GUI_BASICMACHINES, "Sifter"),
- 1,
- 9,
- 0,
- 0,
- 1,
- E,
- 1,
- E,
- true,
- true).setProgressBar(GT_UITextures.PROGRESSBAR_SIFT, ProgressBar.Direction.DOWN)
- .setRecipeConfigFile("sifter", FIRST_ITEM_INPUT);
- public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(
- new HashSet<>(300),
- "gt.recipe.press",
- null,