diff options
| author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
| commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
| tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gregtech/api | |
| parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
| download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip | |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gregtech/api')
| -rw-r--r-- | src/main/java/gregtech/api/enums/TAE.java | 275 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/EmptyRecipeMap.java | 132 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/FishPondFakeRecipe.java | 122 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GTPP_Recipe.java | 1944 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GasSpargingRecipe.java | 171 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/GasSpargingRecipeMap.java | 81 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/HotFuel.java | 62 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/SemiFluidFuelHandler.java | 205 | ||||
| -rw-r--r-- | src/main/java/gregtech/api/util/ThermalFuel.java | 67 |
9 files changed, 1986 insertions, 1073 deletions
diff --git a/src/main/java/gregtech/api/enums/TAE.java b/src/main/java/gregtech/api/enums/TAE.java index 274a29065b..e45e9e4e58 100644 --- a/src/main/java/gregtech/api/enums/TAE.java +++ b/src/main/java/gregtech/api/enums/TAE.java @@ -1,9 +1,5 @@ package gregtech.api.enums; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.HashSet; - import gregtech.api.interfaces.ITexture; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -12,141 +8,144 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; public class TAE { - //TAE stands for Texture Array Expansion. - - public static int gtPPLastUsedIndex = 64; - public static int secondaryIndex = 0; - - public static HashMap<Integer, GTPP_CopiedBlockTexture> mTAE = new HashMap<Integer, GTPP_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 GTPP_CopiedBlockTexture - The Texture to register - * @return - Did it register correctly? - */ - public static boolean registerTexture(int aPage, int aID, GTPP_CopiedBlockTexture GTPP_CopiedBlockTexture) { - int aRealID = aID + (aPage * 16); - return registerTexture(64 + aRealID, GTPP_CopiedBlockTexture); - } - - public static boolean registerTexture(int aID, GTPP_CopiedBlockTexture GTPP_CopiedBlockTexture) { - if (mFreeSlots.contains(aID)) { - mFreeSlots.remove(aID); - mTAE.put(aID, GTPP_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 = ""; - String aPageAndSlotFree = ""; - AutoMap<Integer> aTemp = new AutoMap<Integer>(mFreeSlots); - for (int i = 0; i < mFreeSlots.size() ; i++) { - int j = aTemp.get(i); - aFreeSpaces += j; - aPageAndSlotFree += getPageFromIndex(j); - if (i != (mFreeSlots.size() - 1)) { - aFreeSpaces += ", "; - aPageAndSlotFree += ", "; - } - } - Logger.INFO("Free Indexes within TAE: "+aFreeSpaces); - Logger.INFO("Free Page slots within TAE: "+aPageAndSlotFree); - Logger.INFO("Filling them with ERROR textures."); - for (int aFreeSlot : aTemp.values()) { - registerTexture(aFreeSlot, new GTPP_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(GTPP_CopiedBlockTexture GTPP_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++] = GTPP_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, GTPP_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; - } - public static String getPageFromIndex(int aIndex) { - int aPage = 0; - int aSlot = 0; - int aAdjustedIndex = aIndex > 64 ? (aIndex - 64) : aIndex; - aPage = aAdjustedIndex / 16; - aSlot = aAdjustedIndex - (16 * aPage); - return "["+aIndex+" | "+aPage+", "+aSlot+"]"; - } + // TAE stands for Texture Array Expansion. + + public static int gtPPLastUsedIndex = 64; + public static int secondaryIndex = 0; + + public static HashMap<Integer, GTPP_CopiedBlockTexture> mTAE = new HashMap<Integer, GTPP_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 GTPP_CopiedBlockTexture - The Texture to register + * @return - Did it register correctly? + */ + public static boolean registerTexture(int aPage, int aID, GTPP_CopiedBlockTexture GTPP_CopiedBlockTexture) { + int aRealID = aID + (aPage * 16); + return registerTexture(64 + aRealID, GTPP_CopiedBlockTexture); + } + + public static boolean registerTexture(int aID, GTPP_CopiedBlockTexture GTPP_CopiedBlockTexture) { + if (mFreeSlots.contains(aID)) { + mFreeSlots.remove(aID); + mTAE.put(aID, GTPP_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 = ""; + String aPageAndSlotFree = ""; + AutoMap<Integer> aTemp = new AutoMap<Integer>(mFreeSlots); + for (int i = 0; i < mFreeSlots.size(); i++) { + int j = aTemp.get(i); + aFreeSpaces += j; + aPageAndSlotFree += getPageFromIndex(j); + if (i != (mFreeSlots.size() - 1)) { + aFreeSpaces += ", "; + aPageAndSlotFree += ", "; + } + } + Logger.INFO("Free Indexes within TAE: " + aFreeSpaces); + Logger.INFO("Free Page slots within TAE: " + aPageAndSlotFree); + Logger.INFO("Filling them with ERROR textures."); + for (int aFreeSlot : aTemp.values()) { + registerTexture(aFreeSlot, new GTPP_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(GTPP_CopiedBlockTexture GTPP_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++] = GTPP_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, GTPP_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; + } + + public static String getPageFromIndex(int aIndex) { + int aPage = 0; + int aSlot = 0; + int aAdjustedIndex = aIndex > 64 ? (aIndex - 64) : aIndex; + aPage = aAdjustedIndex / 16; + aSlot = aAdjustedIndex - (16 * aPage); + return "[" + aIndex + " | " + aPage + ", " + aSlot + "]"; + } } diff --git a/src/main/java/gregtech/api/util/EmptyRecipeMap.java b/src/main/java/gregtech/api/util/EmptyRecipeMap.java index 31e1e3db17..45a31b7c1d 100644 --- a/src/main/java/gregtech/api/util/EmptyRecipeMap.java +++ b/src/main/java/gregtech/api/util/EmptyRecipeMap.java @@ -1,51 +1,99 @@ package gregtech.api.util; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import java.util.Collection; - import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +public class EmptyRecipeMap extends GT_Recipe_Map { -import net.minecraftforge.fluids.FluidStack; + 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; + } -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; - } + @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 index bc7cdb4701..14cd00d134 100644 --- a/src/main/java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/main/java/gregtech/api/util/FishPondFakeRecipe.java @@ -1,80 +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 java.util.ArrayList; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; 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() { + public static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>(); - 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(); - } + @SuppressWarnings("unchecked") + public static boolean generateFishPondRecipes() { - AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); - mega.put(fish); - mega.put(junk); - mega.put(treasure); + 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(); + } - 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++; - } + AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); + mega.put(fish); + mega.put(junk); + mega.put(treasure); - return true; - } + 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++; + } - 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); - } - } + 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 index 323977a348..891b5ba0a8 100644 --- a/src/main/java/gregtech/api/util/GTPP_Recipe.java +++ b/src/main/java/gregtech/api/util/GTPP_Recipe.java @@ -2,12 +2,8 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.*; -import java.util.*; - import codechicken.nei.PositionedStack; -import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.*; -import gregtech.api.objects.GT_ItemStack; import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack; import gtPlusPlus.api.interfaces.IComparableRecipe; import gtPlusPlus.api.objects.Logger; @@ -15,6 +11,7 @@ import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import java.util.*; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.*; @@ -25,542 +22,1405 @@ import net.minecraftforge.fluids.*; */ 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); - this.mRecipeHash = getRecipeHash(this); - 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()) { - String[] aInfo = RecipeUtils.getRecipeInfo(this); - for (String s : aInfo) { - Logger.INFO(s); - } - 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 = this.mRecipeHash.equals(aEncoderString); - if (!aBasicHashCheck) { - Logger.INFO("This Recipe Hash: "+aEncoderString); - Logger.INFO("Expected Hash Code: "+this.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 : this.mHashMap) { - aExpectedHashTotal += a; - } - if (aHashTotal != aExpectedHashTotal) { - Logger.INFO("This Recipe Hash: "+aEncoderString); - Logger.INFO("Expected Hash Code: "+this.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; - } - } - } - - public static void reInit() { - GT_Log.out.println("GT_Mod: Re-Unificating Recipes."); - 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(); - } - } - - 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 { - //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", 6, 6, 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_MultiNoCell(new HashSet<GT_Recipe>(500), "gtpp.recipe.vacfurnace", "Vacuum Furnace", null, RES_PATH_GUI + "basicmachines/FissionFuel", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); - public static final GTPP_Recipe_Map_Internal sAlloyBlastSmelterRecipes = new GTPP_Recipe_Map_MultiNoCell(new HashSet<GT_Recipe>(200), "gtpp.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/FissionFuel", 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, false); - - //LFTR recipes - public static final GTPP_Recipe_Map_Internal sLiquidFluorineThoriumReactorRecipes = new GTPP_Recipe_Map_MultiNoCell(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, true); - - //Fission Fuel Plant Recipes - public static final GTPP_Recipe_Map_Internal sFissionFuelProcessing = new GTPP_Recipe_Map_MultiNoCell(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, true); - - //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); - - //Molecular Transformer Map - public static final GTPP_Recipe_Map_Internal sMolecularTransformerRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(3), "gtpp.recipe.moleculartransformer", "Molecular Transformer", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 0, 0, 1, E, 1, E, true, true); - - //Elemental Duplicator Map - public static final GTPP_Recipe_Map_Internal sElementalDuplicatorRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(3), "gtpp.recipe.elementaldupe", "Elemental Du |
