diff options
Diffstat (limited to 'src/main/java/gregtech/api')
| -rw-r--r-- | src/main/java/gregtech/api/enums/TAE.java | 139 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/EmptyRecipeMap.java | 51 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/FishPondFakeRecipe.java | 80 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GTPP_Recipe.java | 1017 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GasSpargingRecipe.java | 99 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GasSpargingRecipeMap.java | 48 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/HotFuel.java | 28 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/SemiFluidFuelHandler.java | 117 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/ThermalFuel.java | 43 |
9 files changed, 1622 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/enums/TAE.java b/src/main/java/gregtech/api/enums/TAE.java new file mode 100644 index 0000000000..e8fd31d89e --- /dev/null +++ b/src/main/java/gregtech/api/enums/TAE.java @@ -0,0 +1,139 @@ +package gregtech.api.enums; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class TAE { + + //TAE stands for Texture Array Expansion. + + public static int gtPPLastUsedIndex = 64; + public static int secondaryIndex = 0; + + public static HashMap<Integer, GT_CopiedBlockTexture> mTAE = new HashMap<Integer, GT_CopiedBlockTexture>(); + private static final HashSet<Integer> mFreeSlots = new HashSet<Integer>(64); + + static { + for (int i=64;i<128;i++) { + mFreeSlots.add(i); + } + Logger.INFO("Initialising TAE."); + } + + /** + * + * @param aPage - The Texture page (0-3) + * @param aID - The ID on the specified page (0-15) + * @param gt_CopiedBlockTexture - The Texture to register + * @return - Did it register correctly? + */ + public static boolean registerTexture(int aPage, int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) { + int aRealID = aID + (aPage * 16); + return registerTexture(64 + aRealID, gt_CopiedBlockTexture); + } + + public static boolean registerTexture(int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) { + if (mFreeSlots.contains(aID)) { + mFreeSlots.remove(aID); + mTAE.put(aID, gt_CopiedBlockTexture); + return true; + } + else { + CORE.crash("Tried to register texture with ID "+aID+" to TAE, but it is already in use."); + return false; // Dead Code + } + } + + public static void finalizeTAE() { + String aFreeSpaces = ""; + AutoMap<Integer> aTemp = new AutoMap<Integer>(mFreeSlots); + for (int i = 0; i < mFreeSlots.size() ; i++) { + aFreeSpaces += aTemp.get(i); + if (i != (mFreeSlots.size() - 1)) { + aFreeSpaces += ", "; + } + } + Logger.INFO("Free Indexes within TAE: "+aFreeSpaces); + Logger.INFO("Filling them with ERROR textures."); + for (int aFreeSlot : aTemp.values()) { + registerTexture(aFreeSlot, new GT_CopiedBlockTexture(ModBlocks.blockCasingsTieredGTPP, 1, 15)); + } + Logger.INFO("Finalising TAE."); + for (int aKeyTae : mTAE.keySet()) { + Textures.BlockIcons.setCasingTextureForId(aKeyTae, mTAE.get(aKeyTae)); + } + Logger.INFO("Finalised TAE."); + } + + private static boolean registerTextures(GT_CopiedBlockTexture gt_CopiedBlockTexture) { + try { + //Handle page 2. + Logger.INFO("[TAE} Registering Texture, Last used casing ID is "+gtPPLastUsedIndex+"."); + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + Field x = ReflectionUtils.getField(Textures.BlockIcons.class, "casingTexturePages"); + if (x != null) { + ITexture[][] h = (ITexture[][]) x.get(null); + if (h != null) { + h[64][secondaryIndex++] = gt_CopiedBlockTexture; + x.set(null, h); + Logger.INFO("[TAE} Registered Texture with ID "+(secondaryIndex-1)+" in secondary index."); + return true; + } + } + } + } + + //set to page 1. + else { + Textures.BlockIcons.setCasingTextureForId(gtPPLastUsedIndex, gt_CopiedBlockTexture); + Logger.INFO("[TAE} Registered Texture with ID "+(gtPPLastUsedIndex)+" in main index."); + gtPPLastUsedIndex++; + return true; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + Logger.INFO("[TAE} Failed to register texture, Last used casing ID is "+gtPPLastUsedIndex+"."); + return false; + } + + public static ITexture getTexture(int index){ + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return Textures.BlockIcons.getCasingTextureForId(((64*128)+index)); + } + } + return Textures.BlockIcons.getCasingTextureForId((64+index)); + } + + public static int GTPP_INDEX(int ID){ + + if (ID >= 64) { + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return (128+ID); + } + } + } + return (64+ID); + } + + public static int getIndexFromPage(int page, int blockMeta) { + int id = 64; + id += (page == 0 ? 0 : page == 1 ? 16 : page == 2 ? 32 : page == 3 ? 48 : page == 4 ? 64 : 0); + id += blockMeta; + return id; + } +} diff --git a/src/main/java/gregtech/api/util/EmptyRecipeMap.java b/src/main/java/gregtech/api/util/EmptyRecipeMap.java new file mode 100644 index 0000000000..31e1e3db17 --- /dev/null +++ b/src/main/java/gregtech/api/util/EmptyRecipeMap.java @@ -0,0 +1,51 @@ +package gregtech.api.util; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +import net.minecraftforge.fluids.FluidStack; + +public class EmptyRecipeMap extends GT_Recipe_Map{ + + public EmptyRecipeMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { + super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, + aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, + aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + + } + + @Override + public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + return null; + + } + + @Override + public GT_Recipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + return null; + } + + @Override + public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + return null; + } + + @Override + public GT_Recipe addRecipe(GT_Recipe aRecipe) { + return null; + } + + @Override + protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { + return null; + } + + @Override + public GT_Recipe add(GT_Recipe aRecipe) { + return null; + } + +} diff --git a/src/main/java/gregtech/api/util/FishPondFakeRecipe.java b/src/main/java/gregtech/api/util/FishPondFakeRecipe.java new file mode 100644 index 0000000000..bc7cdb4701 --- /dev/null +++ b/src/main/java/gregtech/api/util/FishPondFakeRecipe.java @@ -0,0 +1,80 @@ +package gregtech.api.util; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraftforge.common.FishingHooks; +import net.minecraftforge.fluids.FluidStack; + +public class FishPondFakeRecipe { + + public static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>(); + + @SuppressWarnings("unchecked") + public static boolean generateFishPondRecipes() { + + try { + fish = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "fish").get(null); + junk = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); + treasure = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); + } + catch (IllegalArgumentException | IllegalAccessException e) { + Logger.INFO("Error generating Fish Pond Recipes. [1]"); + e.printStackTrace(); + } + + AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); + mega.put(fish); + mega.put(junk); + mega.put(treasure); + + int mType = 14; + for (ArrayList<WeightedRandomFishable> f : mega.values()) { + for (int e=0;e<f.size();e++) { + if (f.get(e) != null) { + WeightedRandomFishable u = f.get(e); + try { + ItemStack t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(u); + addNewFishPondLoot(mType, new ItemStack[]{t}, new int[] {10000}); + } + catch (IllegalArgumentException | IllegalAccessException e1) { + Logger.INFO("Error generating Fish Pond Recipes. [2]"); + e1.printStackTrace(); + } + } + } + mType++; + } + + return true; + } + + public static void addNewFishPondLoot(int circuit, ItemStack[] outputItems, int[] chances) { + GTPP_Recipe x = new GTPP_Recipe( + true, + new ItemStack[]{CI.getNumberedCircuit(circuit)}, + outputItems, + null, + chances, + new FluidStack[]{null}, + new FluidStack[]{null}, + 100, //1 Tick + 0, //No Eu produced + circuit //Magic Number + ); + if (x != null) { + Logger.INFO("Fishing ["+circuit+"]: "+ItemUtils.getArrayStackNames(outputItems)); + GTPP_Recipe.GTPP_Recipe_Map.sFishPondRecipes.addRecipe(x); + } + } + +} diff --git a/src/main/java/gregtech/api/util/GTPP_Recipe.java b/src/main/java/gregtech/api/util/GTPP_Recipe.java new file mode 100644 index 0000000000..1d04e8af6e --- /dev/null +++ b/src/main/java/gregtech/api/util/GTPP_Recipe.java @@ -0,0 +1,1017 @@ +package gregtech.api.util; + +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import static gregtech.api.enums.GT_Values.W; + +import java.util.*; + +import codechicken.nei.PositionedStack; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.objects.GT_ItemStack; +import gtPlusPlus.api.interfaces.IComparableRecipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.NoConflictGTRecipeMap; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +/** + * Custom GT Recipe Class + * @author Alkalus + * + */ +public class GTPP_Recipe extends GT_Recipe implements IComparableRecipe { + + private final String mRecipeHash; + private final AutoMap<Integer> mHashMap = new AutoMap<Integer>(); + + public GTPP_Recipe(final boolean aOptimize, final ItemStack[] aInputs, final ItemStack[] aOutputs, final Object aSpecialItems, final int[] aChances, final FluidStack[] aFluidInputs, final FluidStack[] aFluidOutputs, final int aDuration, final int aEUt, final int aSpecialValue) { + super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + //Logger.SPECIFIC_WARNING(this.getClass().getName()+" | [GregtechRecipe]", "Created new recipe instance for "+ItemUtils.getArrayStackNames(aInputs), 167); + mRecipeHash = getRecipeHash(this); + mHashMap.addAll(convertStringDataToInts(getEncodedRecipeData(this))); + } + + public GTPP_Recipe(final ItemStack aInput1, final ItemStack aOutput1, final int aFuelValue, final int aType) { + this(aInput1, aOutput1, null, null, null, aFuelValue, aType); + } + + private static AutoMap<Integer> convertStringDataToInts(AutoMap<String> aData){ + AutoMap<Integer> aMap = new AutoMap<Integer>(); + for (String string : aData) { + aMap.add(string.hashCode()); + } + return aMap; + } + + private static AutoMap<String> getEncodedRecipeData(GTPP_Recipe aRecipe){ + AutoMap<String> aData = new AutoMap<String>(); + aData.add(aRecipe.mRecipeHash); + aData.add(""+aRecipe.mCanBeBuffered); + aData.add(""+aRecipe.mHidden); + aData.add(""+aRecipe.mEnabled); + aData.add(""+aRecipe.mDuration); + aData.add(""+aRecipe.mEUt); + aData.add(""+aRecipe.mFakeRecipe); + aData.add(""+aRecipe.mSpecialItems); + aData.add(aRecipe.mChances.toString()); + aData.add(aRecipe.mInputs.toString()); + aData.add(aRecipe.mOutputs.toString()); + aData.add(aRecipe.mFluidInputs.toString()); + aData.add(aRecipe.mFluidOutputs.toString()); + return aData; + } + + public static String getRecipeHash(GT_Recipe aRecipe) { + String aEncoderString = aRecipe.toString(); + return aEncoderString; + } + + private final void checkModified() { + if (hasBeenModified()) { + CORE.crash("Someone has edited an internal GT++ recipe, which is no longer allowed. Please complain to whoever has done this, not Alkalus."); + } + } + + private final boolean hasBeenModified() { + String aEncoderString = this.toString(); + boolean aBasicHashCheck = mRecipeHash.equals(aEncoderString); + if (!aBasicHashCheck) { + Logger.INFO("This Recipe Hash: "+aEncoderString); + Logger.INFO("Expected Hash Code: "+mRecipeHash); + return true; + } + AutoMap<Integer> aData = new AutoMap<Integer>(); + aData.addAll(convertStringDataToInts(getEncodedRecipeData(this))); + long aHashTotal = 0; + long aExpectedHashTotal = 0; + for (int a : aData) { + aHashTotal += a; + } + for (int a : mHashMap) { + aExpectedHashTotal += a; + } + if (aHashTotal != aExpectedHashTotal) { + Logger.INFO("This Recipe Hash: "+aEncoderString); + Logger.INFO("Expected Hash Code: "+mRecipeHash); + Logger.INFO("This Recipe Hash: "+aHashTotal); + Logger.INFO("Expected Hash Code: "+aExpectedHashTotal); + return true; + } + return false; + } + + // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000! + public GTPP_Recipe(final ItemStack aInput1, final ItemStack aOutput1, final ItemStack aOutput2, final ItemStack aOutput3, final ItemStack aOutput4, final int aSpecialValue, final int aType) { + this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue)); + + Logger.WARNING("Switch case method for adding fuels"); + if ((this.mInputs.length > 0) && (aSpecialValue > 0)) { + switch (aType) { + // Diesel Generator + case 0: + Logger.WARNING("Added fuel "+aInput1.getDisplayName()+" is ROCKET FUEL - continuing"); + GTPP_Recipe_Map.sRocketFuels.addRecipe(this); + break; + // Gas Turbine + case 1: + GTPP_Recipe_Map.sGeoThermalFuels.addRecipe(this); + break; + // Thermal Generator + case 2: + GTPP_Recipe_Map.sRTGFuels.addRecipe(this); + break; + // Plasma Generator + case 4: + //Gregtech_Recipe_Map.sPlasmaFuels.addRecipe(this); + break; + // Magic Generator + case 5: + //Gregtech_Recipe_Map.sMagicFuels.addRecipe(this); + break; + // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator + default: + //Gregtech_Recipe_Map.sDenseLiquidFuels.addRecipe(this); + break; + } + } + } + + //Custom Recipe Handlers + public GTPP_Recipe(final ItemStack aInput, final FluidStack aFluid, final ItemStack[] aOutput, final int aDuration, final int aEUt) { + this(true, new ItemStack[]{aInput}, aOutput.clone(), null, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); + if ((this.mInputs.length > 0) && (this.mOutputs[0] != null)) { + GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(this); + } + } + + /*public GregtechRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutput, int aDuration, int aEUt) { + this(true, new ItemStack[]{aInput}, aOutput.clone(), null, null, new FluidStack[]{aFluid}, null, aDuration, aEUt, 0); + if (mInputs.length > 0 && mOutputs[0] != null) { + Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(this); + } + }*/ + + + public static void reInit() { + GT_Log.out.println("GT_Mod: Re-Unificating Recipes."); + for (final GTPP_Recipe_Map tMapEntry : GTPP_Recipe_Map.sMappings) { + //tMapEntry.reInit(); + if (tMapEntry != null && tMapEntry.mRecipeList != null && !tMapEntry.mRecipeList.isEmpty()) { + for (GT_Recipe aRecipe : tMapEntry.mRecipeList) { + checkRecipeOwnership(aRecipe); + } + } + } + for (final GTPP_Recipe_Map_Internal tMapEntry : GTPP_Recipe_Map_Internal.sMappingsEx) { + //tMapEntry.reInit(); + if (tMapEntry != null && tMapEntry.mRecipeList != null && !tMapEntry.mRecipeList.isEmpty()) { + for (GT_Recipe aRecipe : tMapEntry.mRecipeList) { + checkRecipeOwnership(aRecipe); + } + } + } + } + + private final static boolean checkRecipeOwnership(GT_Recipe aRecipe) { + if (aRecipe != null && aRecipe instanceof GTPP_Recipe) { + GTPP_Recipe nRecipe = (GTPP_Recipe) aRecipe; + GTPP_Recipe_Map_Internal.mHashedRecipes.put(nRecipe.hashCode(), nRecipe); + return true; + } + return false; + } + + public final static void checkRecipeModifications() { + for (GTPP_Recipe aRecipe : GTPP_Recipe_Map_Internal.mHashedRecipes.values()) { + Logger.INFO("Checking recipe: "+aRecipe.hashCode()); + aRecipe.checkModified(); + } + } + + @Override + public ItemStack getRepresentativeInput(final int aIndex) { + if ((aIndex < 0) || (aIndex >= this.mInputs.length)) { + return null; + } + return GT_Utility.copy(this.mInputs[aIndex]); + } + + @Override + public ItemStack getOutput(final int aIndex) { + if ((aIndex < 0) || (aIndex >= this.mOutputs.length)) { + return null; + } + return GT_Utility.copy(this.mOutputs[aIndex]); + } + + @Override + public int getOutputChance(final int aIndex) { + if ((aIndex < 0) || (aIndex >= this.mChances.length)) { + return 10000; + } + return this.mChances[aIndex]; + } + + @Override + public FluidStack getRepresentativeFluidInput(final int aIndex) { + if ((aIndex < 0) || (aIndex >= this.mFluidInputs.length) || (this.mFluidInputs[aIndex] == null)) { + return null; + } + return this.mFluidInputs[aIndex].copy(); + } + + @Override + public FluidStack getFluidOutput(final int aIndex) { + if ((aIndex < 0) || (aIndex >= this.mFluidOutputs.length) || (this.mFluidOutputs[aIndex] == null)) { + return null; + } + return this.mFluidOutputs[aIndex].copy(); + } + + @Override + public boolean isRecipeInputEqual(final boolean aDecreaseStacksizeBySuccess, final FluidStack[] aFluidInputs, final ItemStack... aInputs) { + return this.isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs); + } + + @Override + public boolean isRecipeInputEqual(final boolean aDecreaseStacksizeBySuccess, final boolean aDontCheckStackSizes, final FluidStack[] aFluidInputs, final ItemStack... aInputs) { + if ((this.mFluidInputs.length > 0) && (aFluidInputs == null)) { + return false; + } + for (final FluidStack tFluid : this.mFluidInputs) { + if (tFluid != null) { + boolean temp = true; + for (final FluidStack aFluid : aFluidInputs) { + if ((aFluid != null) && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || (aFluid.amount >= tFluid.amount))) { + temp = false; + break; + } + } + if (temp) { + return false; + } + } + } + + if ((this.mInputs.length > 0) && (aInputs == null)) { + return false; + } + + for (final ItemStack tStack : this.mInputs) { + if (tStack != null) { + boolean temp = true; + for (final ItemStack aStack : aInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || (aStack.stackSize >= tStack.stackSize))) { + temp = false; + break; + } + } + if (temp) { + return false; + } + } + } + + if (aDecreaseStacksizeBySuccess) { + if (aFluidInputs != null) { + for (final FluidStack tFluid : this.mFluidInputs) { + if (tFluid != null) { + for (final FluidStack aFluid : aFluidInputs) { + if ((aFluid != null) && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || (aFluid.amount >= tFluid.amount))) { + aFluid.amount -= tFluid.amount; + break; + } + } + } + } + } + + if (aInputs != null) { + for (final ItemStack tStack : this.mInputs) { + if (tStack != null) { + for (final ItemStack aStack : aInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || (aStack.stackSize >= tStack.stackSize))) { + aStack.stackSize -= tStack.stackSize; + break; + } + } + } + } + } + } + + return true; + } + + public static class GTPP_Recipe_Map_Internal extends GT_Recipe_Map { + + public static final Collection<GTPP_Recipe_Map_Internal> sMappingsEx = new ArrayList<>(); + private static final HashMap<Integer, GTPP_Recipe> mHashedRecipes = new HashMap<Integer, GTPP_Recipe>(); + + public GTPP_Recipe_Map_Internal(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { + super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + GT_Recipe_Map.sMappings.remove(this); + GTPP_Recipe_Map_Internal.sMappingsEx.add(this); + } + + } + + public static class GTPP_Recipe_Map { + /** + * Contains all Recipe Maps + */ + public static final Collection<GTPP_Recipe_Map> sMappings = new ArrayList<>(); + //public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gtpp.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map_Internal sCokeOvenRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(200), "gtpp.recipe.cokeoven", "Coke Oven", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 1, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map_Internal sMatterFab2Recipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(200), "gtpp.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 9, 9, 0, 0, 1, E, 1, E, true, true); + //public static final Gregtech_Recipe_Map sMatterFabRecipes = new Gregtech_Recipe_Map(new HashSet<GregtechRecipe>(200), "gtpp.recipe.matterfab", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 3, 1, 1, 1, E, 1, E, true, true); + + public static final GT_Recipe_Map_Fuel sRocketFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gtpp.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); + + public static final GTPP_Recipe_Map_Internal sGeoThermalFuels = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10), "gtpp.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GTPP_Recipe_Map_Internal sChemicalDehydratorRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(200), "gtpp.recipe.chemicaldehydrator", "Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map_Internal sVacuumFurnaceRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(500), "gtpp.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); + public static final GTPP_Recipe_Map_Internal sAlloyBlastSmelterRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(200), "gtpp.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 9, 1, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map_Internal sSteamTurbineFuels = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10), "gtpp.recipe.steamturbinefuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + + //LFTR recipes + public static final GTPP_Recipe_Map_Internal sLiquidFluorineThoriumReactorRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(50), "gtpp.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 2, 0, "Power: ", 1, " EU/t per Dynamo", true, true); + + // Ore Milling Map + public static final GTPP_Recipe_Map_Internal sOreMillRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, false); + + //Fission Fuel Plant Recipes + public static final GTPP_Recipe_Map_Internal sFissionFuelProcessing = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(50), "gtpp.recipe.fissionfuel", "Nuclear Fuel Processing", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 0, 1, E, 1, E, true, false); + + //Cold Trap + public static final GTPP_Recipe_Map_Internal sColdTrapRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.coldtrap", "Cold Trap", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + + //Reactor Processing Unit + public static final GTPP_Recipe_Map_Internal sReactorProcessingUnitRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.reactorprocessingunit", "Reactor Processing Unit", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + + //Basic Washer Map + public static final GTPP_Recipe_Map_Internal sSimpleWasherRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(3), "gtpp.recipe.simplewasher", "Simple Dust Washer", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, true); + + //public static final GT_Recipe_Map sSimpleWasherRecipes_FakeFuckBW = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gtpp.recipe.simplewasher", "Fuck you Bart", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, false); + + public static final GTPP_Recipe_Map_Internal sChemicalPlantRecipes = new GTPP_Recipe_Map_Internal( + new HashSet<GT_Recipe>(100), + "gtpp.recipe.fluidchemicaleactor", + "Chemical Plant", + null, + CORE.MODID+":textures/gui/FluidReactor", + 0, + 0, + 0, + 2, + 1, + "Tier: ", + 1, + E, + true, + false); + + + //RTG Fuel Map + public static final GT_Recipe.GT_Recipe_Map_Fuel sRTGFuels = new GTPP_Recipe.GT_Recipe_Map_Fuel( + new HashSet<GT_Recipe>(10), "gtpp.recipe.RTGgenerators", "RTG", null, + "gregtech:textures/gui/basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 365, " Minecraft Days", true, true); + + //Thermal Boiler map + public static final GT_Recipe.GT_Recipe_Map_Fuel sThermalFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gtpp.recipe.thermalgeneratorfuel", + "Thermal Generator Fuel", null, "gregtech:textures/gui/basicmachines/Default", 1, 1, 0, 0, 1, + "Fuel Value: ", 1000, " EU", true, false); + + //Cyclotron recipe map + public static final GTPP_Recipe_Map_Internal sCyclotronRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(200), "gtpp.recipe.cyclotron", "COMET - Compact Cyclotron", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 2, 16, 0, 0, 1, E, 1, E, true, true); + + //Advanced Mixer + public static final GTPP_Recipe_Map_Internal sAdvancedMixerRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(1000), "gtpp.recipe.advanced.mixer", + "Advanced Material Combiner", null, "gregtech:textures/gui/basicmachines/MixerAdvanced", 4, 4, 1, 0, 2, "", 1, "", true, true); + + + //Mini Fusion + public static final GTPP_Recipe_Map_Internal sSlowFusionRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(50), "gtpp.recipe.slowfusionreactor", + "Mimir - Slow Fusion", null, "gregtech:textures/gui/basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, + " EU", true, true); + + + //Component Assembler + public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gtpp.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); + + //Special Maps for Multis + public static final GTPP_Recipe_Map_Internal sFishPondRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(3), "gtpp.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, "Requires Circuit: ", 1, ".", true, true); + public static final GTPP_Recipe_Map_Internal sSpargeTowerRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.spargetower", "Sparging", null, RES_PATH_GUI + "basicmachines/FissionFuel", 9, 9, 0, 0, 1, E, 1, E, true, false); + + //public static final GTPP_Recipe_Map sMultiblockCentrifugeRecipes = new GT_Recipe_Map_LargeCentrifuge(); + //public static final GTPP_Recipe_Map sMultiblockElectrolyzerRecipes = new GT_Recipe_Map_LargeElectrolyzer(); + //public static final GTPP_Recipe_Map sAdvFreezerRecipes = new GT_Recipe_Map_AdvancedVacuumFreezer(); + + public static final GTPP_Recipe_Map_Internal sAdvFreezerRecipes_GT = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(2000), "gtpp.recipe.cryogenicfreezer", "Cryogenic Freezer", null, RES_PATH_GUI + "basicmachines/FissionFuel", 9, 9, 0, 0, 1, "", 0, "", false, true); + public static final GTPP_Recipe_Map_Internal sMultiblockCentrifugeRecipes_GT = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(2000), "gtpp.recipe.multicentrifuge", "Multiblock Centrifuge", null, RES_PATH_GUI + "basicmachines/FissionFuel", 9, 9, 0, 0, 1, "", 0, "", false, true); + public static final GTPP_Recipe_Map_Internal sMultiblockElectrolyzerRecipes_GT = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(2000), "gtpp.recipe.multielectro", "Multiblock Electrolyzer", null, RES_PATH_GUI + "basicmachines/FissionFuel", 9, 9, 0, 0, 1, "", 0, "", false, true); + public static final GTPP_Recipe_Map_Internal sChemicalPlant_GT = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(2000), "gtpp.recipe.temp4", "temp4", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); + public static final GTPP_Recipe_Map_Internal sMultiblockMixerRecipes_GT = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(2000), "gtpp.recipe.multimixer", "Multiblock Mixer", null, RES_PATH_GUI + "basicmachines/FissionFuel", 12, 9, 0, 0, 1, "", 0, "", false, true); + + //Semi-Fluid Fuel Map + public static final GT_Recipe_Map_Fuel sSemiFluidLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gtpp.recipe.semifluidgeneratorfuels", "Semifluid Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + + // Flotation Cell + public static final GTPP_Recipe_Map_Internal sFlotationCellRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.flotationcell", "Flotation Cell", null, RES_PATH_GUI + "basicmachines/LFTR", 6, 4, 1, 1, 1, "Ore Key: ", 1, E, true, false); + + + + + /** + * HashMap of Recipes based on their Items + */ + public final Map<GT_ItemStack, Collection<GTPP_Recipe>> mRecipeItemMap = new HashMap<>(); + /** + * HashMap of Recipes based on their Fluids + */ + public final Map<Fluid, Collection<GTPP_Recipe>> mRecipeFluidMap = new HashMap<>(); + /** + * The List of all Recipes + */ + public final Collection<GTPP_Recipe> mRecipeList; + /** + * String used as an unlocalised Name. + */ + public final String mUnlocalizedName; + /** + * String used in NEI for the Recipe Lists. If null it will use the unlocalised Name instead + */ + public final String mNEIName; + /** + * GUI used for NEI Display. Usually the GUI of the Machine itself + */ + public final String mNEIGUIPath; + public final String mNEISpecialValuePre, mNEISpecialValuePost; + public final int mUsualInputCount, mUsualOutputCount, mNEISpecialValueMultiplier, mMinimalInputItems, mMinimalInputFluids, mAmperage; + public final boolean mNEIAllowed, mShowVoltageAmperageInNEI; + + /** + * Initialises a new type of Recipe Handler. + * + * @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a pre-initialised Size. + * @param aUnlocalizedName the unlocalised Name of this Recipe Handler, used mainly for NEI. + * @param aLocalName the displayed Name inside the NEI Recipe GUI. + * @param aNEIGUIPath the displayed GUI Texture, usually just a Machine GUI. Auto-Attaches ".png" if forgotten. + * @param aUsualInputCount the usual amount of Input Slots this Recipe Class has. + * @param aUsualOutputCount the usual amount of Output Slots this Recipe Class has. + * @param aNEISpecialValuePre the String in front of the Special Value in NEI. + * @param aNEISpecialValueMultiplier the Value the Special Value is getting Multiplied with before displaying + * @param aNEISpecialValuePost the String after the Special Value. Usually for a Unit or something. + * @param aNEIAllowed if NEI is allowed to display this Recipe Handler in general. + */ + public GTPP_Recipe_Map(final Collection<GTPP_Recipe> aRecipeList, + final String aUnlocalizedName, final String aLocalName, final String aNEIName, + final String aNEIGUIPath, final int aUsualInputCount, + final int aUsualOutputCount, final int aMinimalInputItems, + final int aMinimalInputFluids, final int aAmperage, + final String aNEISpecialValuePre, final int aNEISpecialValueMultiplier, + final String aNEISpecialValuePost, final boolean aShowVoltageAmperageInNEI, + final boolean aNEIAllowed) { + sMappings.add(this); + this.mNEIAllowed = aNEIAllowed; + this.mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI; + this.mRecipeList = aRecipeList; + this.mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName; + this.mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png"; + this.mNEISpecialValuePre = aNEISpecialValuePre; + this.mNEISpecialValueMultiplier = aNEISpecialValueMultiplier; + this.mNEISpecialValuePost = aNEISpecialValuePost; + this.mAmperage = aAmperage; + this.mUsualInputCount = aUsualInputCount; + this.mUsualOutputCount = aUsualOutputCount; + this.mMinimalInputItems = aMinimalInputItems; + this.mMinimalInputFluids = aMinimalInputFluids; + GregTech_API.sFluidMappings.add(this.mRecipeFluidMap); + GregTech_API.sItemStackMappings.add(this.mRecipeItemMap); + GT_LanguageManager.addStringLocalization(this.mUnlocalizedName = aUnlocalizedName, aLocalName); + } + + public GTPP_Recipe addRecipe(final boolean aOptimize, final ItemStack[] aInputs, final ItemStack[] aOutputs, final Object aSpecial, final int[] aOutputChances, final FluidStack[] aFluidInputs, final FluidStack[] aFluidOutputs, final int aDuration, final int aEUt, final int aSpecialValue) { + return this.addRecipe(new GTPP_Recipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + } + + public GTPP_Recipe addRecipe(final int[] aOutputChances, final FluidStack[] aFluidInputs, final FluidStack[] aFluidOutputs, final int aDuration, final int aEUt, final int aSpecialValue) { + return this.addRecipe(new GTPP_Recipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false); + } + + public GTPP_Recipe addRecipe(final boolean aOptimize, final ItemStack[] aInputs, final ItemStack[] aOutputs, final Object aSpecial, final FluidStack[] aFluidInputs, final FluidStack[] aFluidOutputs, final int aDuration, final int aEUt, final int aSpecialValue) { + return this.addRecipe(new GTPP_Recipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + } + + public GTPP_Recipe addRecipe(final boolean aOptimize, final Flu |
