diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
17 files changed, 558 insertions, 6069 deletions
diff --git a/src/main/java/gregtech/api/util/FieldsAreNonnullByDefault.java b/src/main/java/gregtech/api/util/FieldsAreNonnullByDefault.java new file mode 100644 index 0000000000..1f51aa39a7 --- /dev/null +++ b/src/main/java/gregtech/api/util/FieldsAreNonnullByDefault.java @@ -0,0 +1,18 @@ +package gregtech.api.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +/** + * This annotation can be applied to a package or class to indicate that + * the fields in that element are nonnull by default unless there is an explicit nullness annotation. + * </ul> + */ +@Nonnull +@TypeQualifierDefault({ ElementType.FIELD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface FieldsAreNonnullByDefault {} diff --git a/src/main/java/gregtech/api/util/GT_Config.java b/src/main/java/gregtech/api/util/GT_Config.java index 36585559c2..dc56def68f 100644 --- a/src/main/java/gregtech/api/util/GT_Config.java +++ b/src/main/java/gregtech/api/util/GT_Config.java @@ -139,6 +139,20 @@ public class GT_Config implements Runnable { return rResult; } + public String getWithValidValues(Object aCategory, String aName, String[] validValues, String aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get( + aCategory.toString() + .replaceAll("\\|", "_"), + aName.replaceAll("\\|", "_"), + aDefault, + null, + validValues); + String rResult = tProperty.getString(); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + @Override public void run() { mConfig.save(); diff --git a/src/main/java/gregtech/api/util/GT_Forestry_Compat.java b/src/main/java/gregtech/api/util/GT_Forestry_Compat.java index 933c379db1..427703e6f7 100644 --- a/src/main/java/gregtech/api/util/GT_Forestry_Compat.java +++ b/src/main/java/gregtech/api/util/GT_Forestry_Compat.java @@ -11,12 +11,13 @@ import forestry.api.recipes.RecipeManagers; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; +import gregtech.api.recipe.RecipeMaps; public class GT_Forestry_Compat { public static void populateFakeNeiRecipes() { if (ItemList.FR_Bee_Drone.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Bee_Drone.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Bee_Drone.getWithName(1L, "Scanned Drone") }, @@ -28,7 +29,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Bee_Princess.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Bee_Princess.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Bee_Princess.getWithName(1L, "Scanned Princess") }, @@ -40,7 +41,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Bee_Queen.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Bee_Queen.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Bee_Queen.getWithName(1L, "Scanned Queen") }, @@ -52,7 +53,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Tree_Sapling.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Tree_Sapling.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Tree_Sapling.getWithName(1L, "Scanned Sapling") }, @@ -64,7 +65,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Butterfly.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Butterfly.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Butterfly.getWithName(1L, "Scanned Butterfly") }, @@ -76,7 +77,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Larvae.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Larvae.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Larvae.getWithName(1L, "Scanned Larvae") }, @@ -88,7 +89,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Serum.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Serum.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Serum.getWithName(1L, "Scanned Serum") }, @@ -100,7 +101,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_Caterpillar.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_Caterpillar.getWildcard(1L) }, new ItemStack[] { ItemList.FR_Caterpillar.getWithName(1L, "Scanned Caterpillar") }, @@ -112,7 +113,7 @@ public class GT_Forestry_Compat { 0); } if (ItemList.FR_PollenFertile.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + RecipeMaps.scannerFakeRecipes.addFakeRecipe( false, new ItemStack[] { ItemList.FR_PollenFertile.getWildcard(1L) }, new ItemStack[] { ItemList.FR_PollenFertile.getWithName(1L, "Scanned Pollen") }, @@ -138,7 +139,7 @@ public class GT_Forestry_Compat { .copy(); i++; } - GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe( + RecipeMaps.centrifugeRecipes.addRecipe( true, new ItemStack[] { tRecipe.getInput() }, tOutputs, @@ -149,7 +150,7 @@ public class GT_Forestry_Compat { 128, 5, 0); - GT_Recipe.GT_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe( + RecipeMaps.centrifugeNonCellRecipes.addRecipe( true, new ItemStack[] { tRecipe.getInput() }, tOutputs, @@ -172,7 +173,7 @@ public class GT_Forestry_Compat { try { for (ISqueezerRecipe tRecipe : RecipeManagers.squeezerManager.recipes()) { if ((tRecipe.getResources().length == 1) && (tRecipe.getFluidOutput() != null)) { - GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.addRecipe( + RecipeMaps.fluidExtractionRecipes.addRecipe( true, new ItemStack[] { tRecipe.getResources()[0] }, new ItemStack[] { tRecipe.getRemnants() }, diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index 76e59eed22..ed82befbcc 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -315,7 +315,6 @@ public class GT_LanguageManager { addStringLocalization("Interaction_DESCRIPTION_Index_151.2", "Outputs 1 specific Fluid"); addStringLocalization("Interaction_DESCRIPTION_Index_151.4", "Successfully locked Fluid to %s"); addStringLocalization("Interaction_DESCRIPTION_Index_152", "Total: "); - addStringLocalization("Interaction_DESCRIPTION_Index_152.1", "Max EU: "); addStringLocalization("Interaction_DESCRIPTION_Index_153", "Usage: "); addStringLocalization("Interaction_DESCRIPTION_Index_154", "Voltage: "); addStringLocalization("Interaction_DESCRIPTION_Index_155", "Amperage: "); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index e16e559360..b83c70d7de 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -9,9 +9,9 @@ import static gregtech.api.enums.GT_Values.M; import static gregtech.api.enums.GT_Values.RA; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.W; -import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sAlloySmelterRecipes; -import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sExtractorRecipes; -import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sOreWasherRecipes; +import static gregtech.api.recipe.RecipeMaps.alloySmelterRecipes; +import static gregtech.api.recipe.RecipeMaps.extractorRecipes; +import static gregtech.api.recipe.RecipeMaps.oreWasherRecipes; import static gregtech.api.util.GT_RecipeBuilder.SECONDS; import static gregtech.api.util.GT_RecipeBuilder.TICKS; @@ -70,6 +70,8 @@ import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.recipe.RecipeMap; import ic2.api.item.IBoxable; import ic2.api.item.IC2Items; import ic2.api.item.IElectricItem; @@ -569,11 +571,12 @@ public class GT_ModHandler { } recipeBuilder.itemOutputs(aOutput) .duration(duration * TICKS) - .eut(3); + .eut(3) + .recipeCategory(RecipeCategories.alloySmelterRecycling); if (hidden) { recipeBuilder.hidden(); } - recipeBuilder.addTo(sAlloySmelterRecipes); + recipeBuilder.addTo(alloySmelterRecipes); return true; } @@ -617,7 +620,7 @@ public class GT_ModHandler { .itemOutputs(aOutput) .duration(15 * SECONDS) .eut(2) - .addTo(sExtractorRecipes); + .addTo(extractorRecipes); return true; } @@ -733,7 +736,7 @@ public class GT_ModHandler { .itemOutputs(aOutput1) .duration(aDuration) .eut(aEUt) - .addTo(sAlloySmelterRecipes); + .addTo(alloySmelterRecipes); return true; } @@ -759,9 +762,8 @@ public class GT_ModHandler { /** * Adds GT versions of the IC2 recipes from the supplied IC2RecipeList. */ - public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, - GT_Recipe.GT_Recipe_Map aGTRecipeMap, boolean aAddGTRecipe, boolean aRemoveIC2Recipe, - boolean aExcludeGTIC2Items) { + public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, RecipeMap<?> aGTRecipeMap, + boolean aAddGTRecipe, boolean aRemoveIC2Recipe, boolean aExcludeGTIC2Items) { Map<ItemStack, ItemStack> aRecipesToRemove = new HashMap<>(); for (Entry<IRecipeInput, RecipeOutput> iRecipeInputRecipeOutputEntry : aIC2RecipeList.entrySet()) { if (iRecipeInputRecipeOutputEntry.getValue().items.isEmpty()) { @@ -773,7 +775,7 @@ public class GT_ModHandler { continue; } - if (aAddGTRecipe && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) { + if (aAddGTRecipe) { try { if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName() .contains("gt.metaitem.01") @@ -784,7 +786,7 @@ public class GT_ModHandler { || tStack.getUnlocalizedName() .contains("ic2.itemPurifiedCrushed")))) continue; - switch (aGTRecipeMap.mUnlocalizedName) { + switch (aGTRecipeMap.unlocalizedName) { case "gt.recipe.macerator", "gt.recipe.extractor", "gt.recipe.compressor" -> aGTRecipeMap .addRecipe( true, @@ -928,7 +930,7 @@ public class GT_ModHandler { .fluidInputs(GT_ModHandler.getWater(aWaterAmount)) .duration(25 * SECONDS) .eut(16) - .addTo(sOreWasherRecipes); + .addTo(oreWasherRecipes); RA.stdBuilder() .itemInputs(aInput) @@ -937,7 +939,7 @@ public class GT_ModHandler { .fluidInputs(GT_ModHandler.getDistilledWater(aWaterAmount / 5)) .duration(15 * SECONDS) .eut(16) - .addTo(sOreWasherRecipes); + .addTo(oreWasherRecipes); return true; } @@ -950,7 +952,7 @@ public class GT_ModHandler { .fluidInputs(GT_ModHandler.getWater(aWaterAmount)) .duration(25 * SECONDS) .eut(16) - .addTo(sOreWasherRecipes); + .addTo(oreWasherRecipes); RA.stdBuilder() .itemInputs(aInput) @@ -958,7 +960,7 @@ public class GT_ModHandler { .fluidInputs(GT_ModHandler.getDistilledWater(aWaterAmount / 5)) .duration(15 * SECONDS) .eut(16) - .addTo(sOreWasherRecipes); + .addTo(oreWasherRecipes); return true; } diff --git a/src/main/java/gregtech/api/util/GT_OverclockCalculator.java b/src/main/java/gregtech/api/util/GT_OverclockCalculator.java index 582b65e7ec..8e896fd8de 100644 --- a/src/main/java/gregtech/api/util/GT_OverclockCalculator.java +++ b/src/main/java/gregtech/api/util/GT_OverclockCalculator.java @@ -198,14 +198,6 @@ public class GT_OverclockCalculator { } /** - * Use {@link #setHeatOC(boolean)} - */ - @Deprecated - public GT_OverclockCalculator enableHeatOC() { - return setHeatOC(true); - } - - /** * Set if we should be calculating overclocking using EBF's perfectOC */ public GT_OverclockCalculator setHeatOC(boolean heatOC) { @@ -214,14 +206,6 @@ public class GT_OverclockCalculator { } /** - * Use {@link #setHeatDiscount(boolean)} - */ - @Deprecated - public GT_OverclockCalculator enableHeatDiscount() { - return setHeatDiscount(true); - } - - /** * Sets if we should add a heat discount at the end of calculating an overclock, just like the EBF */ public GT_OverclockCalculator setHeatDiscount(boolean heatDiscount) { @@ -238,14 +222,6 @@ public class GT_OverclockCalculator { } /** - * Use {@link #setMachineHeat(int)} - */ - @Deprecated - public GT_OverclockCalculator setMultiHeat(int machineHeat) { - return setMachineHeat(machineHeat); - } - - /** * Sets the heat of the coils on the machine */ public GT_OverclockCalculator setMachineHeat(int machineHeat) { @@ -313,14 +289,6 @@ public class GT_OverclockCalculator { } /** - * Use {@link #setOneTickDiscount(boolean)} - */ - @Deprecated - public GT_OverclockCalculator enableOneTickDiscount() { - return setOneTickDiscount(true); - } - - /** * Set One Tick Discount on EUt based on Duration Decrease Per Overclock. This functions the same as single * blocks. */ @@ -556,7 +524,7 @@ public class GT_OverclockCalculator { /** * Returns the EUt consumption one would get from overclocking under 1 tick * This Doesn't count as calculating - * + * * @param originalMaxParallel Parallels which are of the actual machine before the overclocking extra ones */ public long calculateEUtConsumptionUnderOneTick(int originalMaxParallel, int currentParallel) { diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java index d3921b613d..8a5cd0b9f8 100644 --- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java +++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java @@ -10,8 +10,8 @@ import net.minecraftforge.fluids.FluidStack; import gregtech.api.interfaces.tileentity.IRecipeLockable; import gregtech.api.interfaces.tileentity.IVoidable; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.XSTR; +import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.recipe.check.SingleRecipeCheck; @@ -124,27 +124,6 @@ public class GT_ParallelHelper { public GT_ParallelHelper() {} /** - * Sets MetaTE controller, with current configuration for void protection mode. - * - * @deprecated Use {@link #setMachine(IVoidable)} - */ - @Deprecated - public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta) { - return setMachine(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid()); - } - - /** - * Sets MetaTE controller, with void protection mode forcibly. - * - * @deprecated Use {@link #setMachine(IVoidable, boolean, boolean)} - */ - @Deprecated - public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta, boolean protectExcessItem, - boolean protectExcessFluid) { - return setMachine(machineMeta, protectExcessItem, protectExcessFluid); - } - - /** * Sets machine, with current configuration for void protection mode. */ public GT_ParallelHelper setMachine(IVoidable machine) { @@ -213,14 +192,6 @@ public class GT_ParallelHelper { } /** - * Use {@link #setConsumption(boolean)} - */ - @Deprecated - public GT_ParallelHelper enableConsumption() { - return setConsumption(true); - } - - /** * Set if we should consume inputs or not when trying for parallels * * @param consume Should we consume inputs @@ -249,14 +220,6 @@ public class GT_ParallelHelper { } /** - * Use {@link #setOutputCalculation(boolean)} - */ - @Deprecated - public GT_ParallelHelper enableOutputCalculation() { - return setOutputCalculation(true); - } - - /** * Sets if we should calculate outputs with the parallels we found or not * * @param calculateOutputs Should we calculate outputs with the helper or not @@ -339,14 +302,6 @@ public class GT_ParallelHelper { } /** - * @deprecated Use {@link #getDurationMultiplierDouble()} - */ - @Deprecated - public float getDurationMultiplier() { - return (float) getDurationMultiplierDouble(); - } - - /** * @return The ItemOutputs from the recipe */ @Nonnull @@ -382,23 +337,6 @@ public class GT_ParallelHelper { } /** - * @deprecated Use {@link #setMaxParallelCalculator} and {@link #setInputConsumer} - */ - @Deprecated - protected boolean tryConsumeRecipeInputs(GT_Recipe recipe, FluidStack[] fluids, ItemStack[] items) { - return false; - } - - /** - * @deprecated Use {@link #setMaxParallelCalculator} and {@link #setInputConsumer} - */ - @Deprecated - protected boolean tryConsumeRecipeInputs(GT_Recipe recipe, FluidStack[] fluids, ItemStack[] items, - int minParallel) { - return false; - } - - /** * Called by build(). Determines the parallels and everything else that needs to be done at build time */ protected void determineParallel() { @@ -446,7 +384,7 @@ public class GT_ParallelHelper { if (recipeCheck == null) { // Machine is configured to lock to a single recipe, but haven't built the recipe checker yet. // Build the checker on next successful recipe. - GT_Recipe.GT_Recipe_Map recipeMap = singleRecipeMachine.getRecipeMap(); + RecipeMap<?> recipeMap = singleRecipeMachine.getRecipeMap(); if (recipeMap != null) { tSingleRecipeCheckBuilder = SingleRecipeCheck.builder(recipeMap) .setBefore(itemInputs, fluidInputs); diff --git a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java index 7ff37a927c..ead9393d0e 100644 --- a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java +++ b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java @@ -5,24 +5,24 @@ import java.util.HashMap; import net.minecraft.item.ItemStack; import gregtech.api.enums.SoundResource; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.recipe.RecipeMap; @Deprecated public class GT_ProcessingArray_Manager { - private static final HashMap<String, GT_Recipe_Map> mRecipeSaves = new HashMap<>(); + private static final HashMap<String, RecipeMap<?>> mRecipeSaves = new HashMap<>(); private static final HashMap<String, SoundResource> machineSounds = new HashMap<>(); // Adds recipe Maps to the PA using the machines unlocalized name. // Example: basicmachine.electrolyzer, with its recipe map will add the electrolyzer's recipe map to the PA - public static void addRecipeMapToPA(String aMachineName, GT_Recipe_Map aMap) { + public static void addRecipeMapToPA(String aMachineName, RecipeMap<?> aMap) { if (aMachineName != null) { mRecipeSaves.put(aMachineName, aMap); } } // Allows the PA to extract the recipe map for the machine inside it. - public static GT_Recipe_Map giveRecipeMap(String aMachineName) { + public static RecipeMap<?> giveRecipeMap(String aMachineName) { if (aMachineName != null) { return mRecipeSaves.get(aMachineName); } 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 cl |
