aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_BartWorks_Compat.java48
-rw-r--r--src/main/java/gregtech/api/util/GT_CLS_Compat.java145
-rw-r--r--src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java31
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java3686
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java4801
5 files changed, 4515 insertions, 4196 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BartWorks_Compat.java b/src/main/java/gregtech/api/util/GT_BartWorks_Compat.java
new file mode 100644
index 0000000000..eedae52716
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_BartWorks_Compat.java
@@ -0,0 +1,48 @@
+package gregtech.api.util;
+
+import com.github.bartimaeusnek.bartworks.API.VoidMinerDropAdder;
+import com.github.bartimaeusnek.bartworks.API.WerkstoffAPI;
+import com.github.bartimaeusnek.bartworks.system.material.Werkstoff;
+import gregtech.api.enums.Materials;
+import gregtech.api.interfaces.ISubTagContainer;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Optional;
+
+public class GT_BartWorks_Compat {
+
+ public static Materials getBartWorksMaterialByVarName(String name) {
+ Materials materials = Materials._NULL;
+ try {
+ materials = WerkstoffAPI.getWerkstoff(name).getBridgeMaterial();
+ } catch (NoSuchFieldException | IllegalAccessException exception) {
+ exception.printStackTrace();
+ }
+ return materials;
+ }
+
+ public static Materials getBartWorksMaterialByODName(String name) {
+ Optional<Werkstoff> material = Werkstoff.werkstoffHashSet.stream().filter(e -> e.getVarName().equals(name)).findFirst();
+ if (material.isPresent()) {
+ return material.get().getBridgeMaterial();
+ }
+ return Materials._NULL;
+ }
+
+ public static Materials getBartWorksMaterialByIGNName(String name) {
+ return Optional.ofNullable(Optional.ofNullable(Werkstoff.werkstoffNameHashMap.get(name)).orElse(Werkstoff.default_null_Werkstoff).getBridgeMaterial()).orElse(Materials._NULL);
+ }
+
+ public static Materials getBartWorksMaterialByID(int id) {
+ return Optional.ofNullable(Optional.ofNullable(Werkstoff.werkstoffHashMap.get((short) id)).orElse(Werkstoff.default_null_Werkstoff).getBridgeMaterial()).orElse(Materials._NULL);
+ }
+
+ public static void addVoidMinerDropsToDimension(int dimID, ISubTagContainer material, float chance){
+ try {
+ VoidMinerDropAdder.addDropsToDim(dimID, material, chance);
+ } catch (InvocationTargetException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_CLS_Compat.java b/src/main/java/gregtech/api/util/GT_CLS_Compat.java
new file mode 100644
index 0000000000..738b04a3b3
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_CLS_Compat.java
@@ -0,0 +1,145 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.ProgressManager;
+import gregtech.GT_Mod;
+import gregtech.api.enums.Materials;
+import gregtech.common.GT_Proxy;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.Set;
+
+@SuppressWarnings("rawtypes, unchecked, deprecation")
+public class GT_CLS_Compat {
+
+ private static Class alexiilMinecraftDisplayer;
+ private static Class alexiilProgressDisplayer;
+
+ private static Method getLastPercent;
+ private static Method displayProgress;
+
+ private static Field isReplacingVanillaMaterials;
+ private static Field isRegisteringGTmaterials;
+
+ static {
+ //CLS
+ try {
+ alexiilMinecraftDisplayer = Class.forName("alexiil.mods.load.MinecraftDisplayer");
+ alexiilProgressDisplayer = Class.forName("alexiil.mods.load.ProgressDisplayer");
+ } catch (ClassNotFoundException ex) {
+ GT_Mod.GT_FML_LOGGER.catching(ex);
+ }
+
+ Optional.ofNullable(alexiilMinecraftDisplayer).ifPresent(e -> {
+ try {
+ getLastPercent = e.getMethod("getLastPercent");
+ isReplacingVanillaMaterials = e.getField("isReplacingVanillaMaterials");
+ isRegisteringGTmaterials = e.getField("isRegisteringGTmaterials");
+ } catch (NoSuchMethodException | NoSuchFieldException ex) {
+ GT_Mod.GT_FML_LOGGER.catching(ex);
+ }
+
+ });
+
+ Optional.ofNullable(alexiilProgressDisplayer).ifPresent(e -> {
+ try {
+ displayProgress = e.getMethod("displayProgress", String.class, float.class);
+ } catch (NoSuchMethodException ex) {
+ GT_Mod.GT_FML_LOGGER.catching(ex);
+ }
+ });
+ }
+
+ public static void stepMaterialsCLS(Collection<GT_Proxy.OreDictEventContainer> mEvents, ProgressManager.ProgressBar progressBar) throws IllegalAccessException, InvocationTargetException {
+ int sizeStep = GT_CLS_Compat.setStepSize(mEvents);
+ int size = 0;
+ for (GT_Proxy.OreDictEventContainer tEvent : mEvents) {
+ sizeStep--;
+
+ String materialName = tEvent.mMaterial == null ? "" : tEvent.mMaterial.toString();
+
+ displayProgress.invoke(null, materialName, ((float) size) / 100);
+
+ if (sizeStep == 0) {
+ if (size % 5 == 0)
+ GT_Mod.GT_FML_LOGGER.info("Baking: " + size + "%");
+ sizeStep = mEvents.size() / 100 - 1;
+ size++;
+ }
+
+ progressBar.step(materialName);
+ GT_Proxy.registerRecipes(tEvent);
+ }
+ ProgressManager.pop(progressBar);
+ isRegisteringGTmaterials.set(null, false);
+ }
+
+
+ public static int setStepSize(Collection mEvents) {
+ try {
+ isRegisteringGTmaterials.set(null, true);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ GT_Mod.GT_FML_LOGGER.catching(e);
+ }
+
+ return mEvents.size() / 100 - 1;
+ }
+
+ private GT_CLS_Compat() {
+ }
+
+ private static int[] setSizeSteps(Set<Materials> replaceVanillaItemsSet){
+ int sizeStep;
+ int sizeStep2;
+ if (replaceVanillaItemsSet.size() >= 100) {
+ sizeStep = replaceVanillaItemsSet.size() / 100 - 1;
+ sizeStep2 = 1;
+ } else {
+ sizeStep = 100 / replaceVanillaItemsSet.size();
+ sizeStep2 = sizeStep;
+ }
+ return new int[]{sizeStep, sizeStep2};
+ }
+
+ private static void displayMethodAdapter(int counter, String mDefaultLocalName, int size) throws InvocationTargetException, IllegalAccessException {
+ if (counter == 1) {
+ displayProgress.invoke(null, mDefaultLocalName, ((float) 95) / 100);
+ } else if (counter == 0) {
+ displayProgress.invoke(null, mDefaultLocalName, (float) 1);
+ } else {
+ displayProgress.invoke(null, mDefaultLocalName, ((float) size) / 100);
+ }
+ }
+
+ public static void doActualRegistrationCLS(ProgressManager.ProgressBar progressBar, Set<Materials> replaceVanillaItemsSet) throws InvocationTargetException, IllegalAccessException {
+ int size = 0;
+ int counter = replaceVanillaItemsSet.size();
+ try {
+ isReplacingVanillaMaterials.set(null, true);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ GT_Mod.GT_FML_LOGGER.catching(e);
+ }
+
+ int[] sizeSteps = setSizeSteps(replaceVanillaItemsSet);
+
+ for (Materials m : replaceVanillaItemsSet) {
+ counter--;
+ sizeSteps[0]--;
+
+ displayMethodAdapter(counter,m.mDefaultLocalName,size);
+ GT_Mod.doActualRegistration(m);
+
+ size += sizeSteps[1];
+ progressBar.step(m.mDefaultLocalName);
+ }
+ }
+
+ public static void pushToDisplayProgress() throws InvocationTargetException, IllegalAccessException {
+ isReplacingVanillaMaterials.set(null, false);
+ displayProgress.invoke(null, "Post Initialization: loading GregTech", getLastPercent.invoke(null));
+ }
+
+}
diff --git a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java
new file mode 100644
index 0000000000..e25a0209d9
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java
@@ -0,0 +1,31 @@
+package gregtech.api.util;
+
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+
+import java.util.HashMap;
+
+public class GT_ProcessingArray_Manager {
+
+ private static final HashMap<Integer, String> mMetaKeyMap = new HashMap<Integer, String>();
+ private static final HashMap<String, GT_Recipe_Map> mRecipeCache = new HashMap<String, GT_Recipe_Map>();
+
+ public static boolean registerRecipeMapForMeta(int aMeta, GT_Recipe_Map aMap) {
+ if (aMeta < 0 || aMeta > Short.MAX_VALUE || aMap == null) {
+ return false;
+ }
+ if (mMetaKeyMap.containsKey(aMeta)) {
+ return false;
+ }
+ String aMapNameKey = aMap.mUnlocalizedName;
+ mMetaKeyMap.put(aMeta, aMapNameKey);
+ if (!mRecipeCache.containsKey(aMapNameKey)) {
+ mRecipeCache.put(aMapNameKey, aMap);
+ }
+ return true;
+ }
+
+ public static GT_Recipe_Map getRecipeMapForMeta(int aMeta) {
+ return mRecipeCache.get(mMetaKeyMap.get(aMeta));
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 75b682e825..3cf1dd3d15 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -1,1832 +1,1854 @@
-package gregtech.api.util;
-
-import codechicken.nei.PositionedStack;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
-import gregtech.api.objects.GT_FluidStack;
-import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.objects.ItemData;
-import gregtech.api.objects.MaterialStack;
-import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
-import ic2.core.Ic2Items;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntityFurnace;
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidContainerRegistry;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidContainerItem;
-
-import java.util.*;
-
-import static gregtech.api.enums.GT_Values.*;
-
-/**
- * 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> {
- public static volatile int VERSION = 509;
- /**
- * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
- */
- public ItemStack[] mInputs, mOutputs;
- /**
- * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
- */
- public FluidStack[] mFluidInputs, mFluidOutputs;
- /**
- * If you changed the amount of Array-Items inside the Output Array then the length of this Array must be larger or equal to the Output Array. A chance of 10000 equals 100%
- */
- public int[] mChances;
- /**
- * An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible.
- */
- public Object mSpecialItems;
- public int mDuration, mEUt, mSpecialValue;
- /**
- * Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe.
- */
- public boolean mEnabled = true;
- /**
- * If this Recipe is hidden from NEI
- */
- public boolean mHidden = false;
- /**
- * If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps, so that containsInput does return T on those fake Inputs)
- */
- public boolean mFakeRecipe = false;
- /**
- * If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes, you have to set this to F.
- */
- public boolean mCanBeBuffered = true;
- /**
- * If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs
- */
- public boolean mNeedsEmptyOutput = false;
- /**
- * Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels)
- */
- private String[] neiDesc = null;
-
- private GT_Recipe(GT_Recipe aRecipe) {
- mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs);
- mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs);
- mSpecialItems = aRecipe.mSpecialItems;
- mChances = aRecipe.mChances;
- mFluidInputs = GT_Utility.copyFluidArray(aRecipe.mFluidInputs);
- mFluidOutputs = GT_Utility.copyFluidArray(aRecipe.mFluidOutputs);
- mDuration = aRecipe.mDuration;
- mSpecialValue = aRecipe.mSpecialValue;
- mEUt = aRecipe.mEUt;
- mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput;
- mCanBeBuffered = aRecipe.mCanBeBuffered;
- mFakeRecipe = aRecipe.mFakeRecipe;
- mEnabled = aRecipe.mEnabled;
- mHidden = aRecipe.mHidden;
- }
- protected GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- if (aInputs == null)
- aInputs = new ItemStack[0];
- if (aOutputs == null)
- aOutputs = new ItemStack[0];
- if (aFluidInputs == null)
- aFluidInputs = new FluidStack[0];
- if (aFluidOutputs == null)
- aFluidOutputs = new FluidStack[0];
- if (aChances == null)
- aChances = new int[aOutputs.length];
- if (aChances.length < aOutputs.length)
- aChances = Arrays.copyOf(aChances, aOutputs.length);
-
- aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
- aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
- aFluidInputs = GT_Utility.getArrayListWithoutNulls(aFluidInputs).toArray(new FluidStack[0]);
- aFluidOutputs = GT_Utility.getArrayListWithoutNulls(aFluidOutputs).toArray(new FluidStack[0]);
-
- GT_OreDictUnificator.setStackArray(true, aInputs);
- GT_OreDictUnificator.setStackArray(true, aOutputs);
-
- for (ItemStack tStack : aOutputs)
- GT_Utility.updateItemStack(tStack);
-
- for (int i = 0; i < aChances.length; i++)
- if (aChances[i] <= 0)
- aChances[i] = 10000;
- for (int i = 0; i < aFluidInputs.length; i++)
- aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]);
- for (int i = 0; i < aFluidOutputs.length; i++)
- aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]);
-
- for (ItemStack aInput : aInputs)
- if (aInput != null && Items.feather.getDamage(aInput) != W)
- for (int j = 0; j < aOutputs.length; j++) {
- if (GT_Utility.areStacksEqual(aInput, aOutputs[j])) {
- if (aInput.stackSize >= aOutputs[j].stackSize) {
- aInput.stackSize -= aOutputs[j].stackSize;
- aOutputs[j] = null;
- } else {
- aOutputs[j].stackSize -= aInput.stackSize;
- }
- }
- }
-
- if (aOptimize && aDuration >= 32) {
- ArrayList<ItemStack> tList = new ArrayList<>();
- tList.addAll(Arrays.asList(aInputs));
- tList.addAll(Arrays.asList(aOutputs));
- for (int i = 0; i < tList.size(); i++) if (tList.get(i) == null) tList.remove(i--);
-
- for (byte i = (byte) Math.min(64, aDuration / 16); i > 1; i--)
- if (aDuration / i >= 16) {
- boolean temp = true;
- for (ItemStack stack : tList)
- if (stack.stackSize % i != 0) {
- temp = false;
- break;
- }
- if (temp)
- for (FluidStack aFluidInput : aFluidInputs)
- if (aFluidInput.amount % i != 0) {
- temp = false;
- break;
- }
- if (temp)
- for (FluidStack aFluidOutput : aFluidOutputs)
- if (aFluidOutput.amount % i != 0) {
- temp = false;
- break;
- }
- if (temp) {
- for (ItemStack itemStack : tList)
- itemStack.stackSize /= i;
- for (FluidStack aFluidInput : aFluidInputs)
- aFluidInput.amount /= i;
- for (FluidStack aFluidOutput : aFluidOutputs)
- aFluidOutput.amount /= i;
- aDuration /= i;
- }
- }
- }
-
- mInputs = aInputs;
- mOutputs = aOutputs;
- mSpecialItems = aSpecialItems;
- mChances = aChances;
- mFluidInputs = aFluidInputs;
- mFluidOutputs = aFluidOutputs;
- mDuration = aDuration;
- mSpecialValue = aSpecialValue;
- mEUt = aEUt;
-// checkCellBalance();
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) {
- this(aInput1, aOutput1, null, null, null, aFuelValue, aType);
- }
-
- // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) {
- this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue));
-
- if (mInputs.length > 0 && aSpecialValue > 0) {
- switch (aType) {
- // Diesel Generator
- case 0:
- GT_Recipe_Map.sDieselFuels.addRecipe(this);
- GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this);
- break;
- // Gas Turbine
- case 1:
- GT_Recipe_Map.sTurbineFuels.addRecipe(this);
- break;
- // Thermal Generator
- case 2:
- GT_Recipe_Map.sHotFuels.addRecipe(this);
- break;
- // Plasma Generator
- case 4:
- GT_Recipe_Map.sPlasmaFuels.addRecipe(this);
- break;
- // Magic Generator
- case 5:
- GT_Recipe_Map.sMagicFuels.addRecipe(this);
- break;
- // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator
- default:
- GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this);
- GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this);
- break;
- }
- }
- }
-
- public GT_Recipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt, int aSpecialValue) {
- this(true, null, null, null, null, new FluidStack[]{aInput1, aInput2}, new FluidStack[]{aOutput1}, Math.max(aDuration, 1), aEUt, Math.max(Math.min(aSpecialValue, 160000000), 0));
- if (mInputs.length > 1) {
- GT_Recipe_Map.sFusionRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt) {
- this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, aDuration, aEUt, 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sLatheRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aCellAmount, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) {
- this(true, new ItemStack[]{aInput1, aCellAmount > 0 ? ItemList.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))) : null}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sDistillationRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) {
- this(true, new ItemStack[]{aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2 > 0 ? Math.min(aInput2, 64) : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1))}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, 20, 30, 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sImplosionRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aOutput1) {
- this(true, new ItemStack[]{aInput1, ItemList.Circuit_Integrated.getWithDamage(0, aInput1.stackSize)}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sBenderRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aInput2, int aEUt, int aDuration, ItemStack aOutput1) {
- this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sAlloySmelterRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1, ItemStack aOutput2) {
- this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sCannerRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration) {
- this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), 120, 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
- }
- }
-
- public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt, int VACUUM) {
- this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), aEUt, 0);
- if (mInputs.length > 0 && mOutputs[0] != null) {
- GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
- }
- }
-
- //Dummy GT_Recipe maker...
- public GT_Recipe(ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){
- this(true, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
- }
-
- public static void reInit() {
- GT_Log.out.println("GT_Mod: Re-Unificating Recipes.");
- for (GT_Recipe_Map tMapEntry : GT_Recipe_Map.sMappings)
- tMapEntry.reInit();
- }
-
- // -----
- // Old Constructors, do not use!
- // -----
-
- public ItemStack getRepresentativeInput(int aIndex) {
- if (aIndex < 0 || aIndex >= mInputs.length) return null;
- return GT_Utility.copy(mInputs[aIndex]);
- }
-
- public ItemStack getOutput(int aIndex) {
- if (aIndex < 0 || aIndex >= mOutputs.length) return null;
- return GT_Utility.copy(mOutputs[aIndex]);
- }
-
- public int getOutputChance(int aIndex) {
- if (aIndex < 0 || aIndex >= mChances.length) return 10000;
- return mChances[aIndex];
- }
-
- public FluidStack getRepresentativeFluidInput(int aIndex) {
- if (aIndex < 0 || aIndex >= mFluidInputs.length || mFluidInputs[aIndex] == null) return null;
- return mFluidInputs[aIndex].copy();
- }
-
- public FluidStack getFluidOutput(int aIndex) {
- if (aIndex < 0 || aIndex >= mFluidOutputs.length || mFluidOutputs[aIndex] == null) return null;
- return mFluidOutputs[aIndex].copy();
- }
-
- public void checkCellBalance() {
- if (!D2 || mInputs.length < 1) return;
-
- int tInputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(mInputs);
- int tOutputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(mOutputs);
-
- if (tInputAmount < tOutputAmount) {
- if (!Materials.Tin.contains(mInputs)) {
- GT_Log.err.println("You get more Cells, than you put in? There must be something wrong.");
- new Exception().printStackTrace(GT_Log.err);
- }
- } else if (tInputAmount > tOutputAmount) {
- if (!Materials.Tin.contains(mOutputs)) {
- GT_Log.err.println("You get less Cells, than you put in? GT Machines usually don't destroy Cells.");
- new Exception().printStackTrace(GT_Log.err);
- }
- }
- }
-
- public GT_Recipe copy() {
- return new GT_Recipe(this);
- }
-
- public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) {
- return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs);
- }
-
- public static boolean GTppRecipeHelper;
-
- public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
- if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
- int amt;
- for (FluidStack tFluid : mFluidInputs)
- if (tFluid != null) {
- boolean temp = true;
- amt = tFluid.amount;
- for (FluidStack aFluid : aFluidInputs)
- if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
- if (aDontCheckStackSizes) {
- temp = false;
- break;
- }
- amt -= aFluid.amount;
- if (amt < 1) {
- temp = false;
- break;
- }
- }
- if (temp) return false;
- }
-
- if (mInputs.length > 0 && aInputs == null) return false;
-
- for (ItemStack tStack : mInputs) {
- if (tStack != null) {
- amt = tStack.stackSize;
- boolean temp = true;
- for (ItemStack aStack : aInputs) {
- if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
- if (GTppRecipeHelper) {//remove once the fix is out
- if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
- if (!GT_Utility.areStacksEqual(aStack, tStack, false))
- continue;
- }
- }
- if (aDontCheckStackSizes) {
- temp = false;
- break;
- }
- amt -= aStack.stackSize;
- if (amt < 1) {
- temp = false;
- break;
- }
- }
- }
- if (temp) return false;
- }
- }
- if (aDecreaseStacksizeBySuccess) {
- if (aFluidInputs != null) {
- for (FluidStack tFluid : mFluidInputs) {
- if (tFluid != null) {
- amt = tFluid.amount;
- for (FluidStack aFluid : aFluidInputs) {
- if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
- if (aDontCheckStackSizes) {
- aFluid.amount -= amt;
- break;
- }
- if (aFluid.amount < amt) {
- amt -= aFluid.amount;
- aFluid.amount = 0;
- } else {
- aFluid.amount -= amt;
- amt = 0;
- break;
- }
- }
- }
- }
- }
- }
-
- if (aInputs != null) {
- for (ItemStack tStack : mInputs) {
- if (tStack != null) {
- amt = tStack.stackSize;
- for (ItemStack aStack : aInputs) {
- if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
- if (GTppRecipeHelper) {
- if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
- if (!GT_Utility.areStacksEqual(aStack, tStack, false))
- continue;
- }
- }
- if (aDontCheckStackSizes){
- aStack.stackSize -= amt;
- break;
- }
- if (aStack.stackSize < amt){
- amt -= aStack.stackSize;
- aStack.stackSize = 0;
- }else{
- aStack.stackSize -= amt;
- amt = 0;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- return true;
- }
-
- @Override
- public int compareTo(GT_Recipe recipe) {
- // first lowest tier recipes
- // then fastest
- // then with lowest special value
- // then dry recipes
- // then with fewer inputs
- if (this.mEUt != recipe.mEUt) {
- return this.mEUt - recipe.mEUt;
- } else if (this.mDuration != recipe.mDuration) {
- return this.mDuration - recipe.mDuration;
- } else if (this.mSpecialValue != recipe.mSpecialValue) {
- return this.mSpecialValue - recipe.mSpecialValue;
- } else if (this.mFluidInputs.length != recipe.mFluidInputs.length) {
- return this.mFluidInputs.length - recipe.mFluidInputs.length;
- } else if (this.mInputs.length != recipe.mInputs.length) {
- return this.mInputs.length - recipe.mInputs.length;
- }
- return 0;
- }
-
- public String[] getNeiDesc() {
- return neiDesc;
- }
-
- protected void setNeiDesc(String... neiDesc) {
- this.neiDesc = neiDesc;
- }
-
- /**
- * Overriding this method and getOutputPositionedStacks allows for custom NEI stack placement
- * @return A list of input stacks
- */
- public ArrayList<PositionedStack> getInputPositionedStacks(){
- return null;
- }
-
- /**
- * Overriding this method and getInputPositionedStacks allows for custom NEI stack placement
- * @return A list of output stacks
- */
- public ArrayList<PositionedStack> getOutputPositionedStacks(){
- return null;
- }
-
- public static class GT_Recipe_AssemblyLine{
- public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>();
-
- public ItemStack mResearchItem;
- public int mResearchTime;
- public ItemStack[] mInputs;
- public FluidStack[] mFluidInputs;
- public ItemStack mOutput;
- public int mDuration;
- public int mEUt;
- public ItemStack[][] mOreDictAlt;
-
- public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) {
- this(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt, new ItemStack[aInputs.length][]);
- }
-
- public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt, ItemStack[][] aAlt) {
- mResearchItem = aResearchItem;
- mResearchTime = aResearchTime;
- mInputs = aInputs;
- mFluidInputs = aFluidInputs;
- mOutput = aOutput;
- mDuration = aDuration;
- mEUt = aEUt;
- mOreDictAlt = aAlt;
- }
-
- }
-
- public static class GT_Recipe_Map {
- /**
- * Contains all Recipe Maps
- */
- public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<>();
-
- public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<>(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true);
- public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet<>(750), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false);
- public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
- public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
-
- public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sReplicatorFakeRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true);
- //public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map(new HashSet<>(110), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false);
- public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true);
- public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<>(5), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet<>(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet<>(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet<>(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraver", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer2", 9, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave", 1, 1, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<>(16600), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<>(2550), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<>(2100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet<>(10), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet<>(400), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 1, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map(new HashSet<>(35000), "gt.recipe.fluidsolidifier", "Fluid Solidifier", null, RES_PATH_GUI + "basicmachines/FluidSolidifier", 1, 1, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map(new HashSet<>(15000), "gt.recipe.fluidextractor", "Fluid Extractor", null, RES_PATH_GUI + "basicmachines/FluidExtractor", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map(new HashSet<>(2500), "gt.recipe.packager", "Packager", null, RES_PATH_GUI + "basicmachines/Packager", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator(new HashSet<>(2500), "gt.recipe.unpackager", "Unpackager", null, RES_PATH_GUI + "basicmachines/Unpackager", 1, 2, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/FusionReactor", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true);
- public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1200), "gt.recipe.centrifuge", "Centrifuge", null, RES_PATH_GUI + "basicmachines/Centrifuge", 2, 6, 0, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.electrolyzer", "Electrolyzer", null, RES_PATH_GUI + "basicmachines/Electrolyzer", 2, 6, 0, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map(new HashSet<>(800), "gt.recipe.blastfurnace", "Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true);
- public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.primitiveblastfurnace", "Primitive Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 3, 3, 1, 0, 1, E, 1, E, false, true);
- public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.implosioncompressor", "Implosion Compressor", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet<>(305), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, false, true);
- public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<>(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor();
- public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower();
- public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<>(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<>(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet<>(12000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(8200), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler2", 9, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(605), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet<>(1150), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<>(5125), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter2", 2, 2, 1, 1, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<>(20), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet<>(13000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true);
- public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true);
- public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false);
- public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
- public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = new GT_Recipe_Map_LargeBoilerFakeFuels();
-
- /**
- * HashMap of Recipes based on their Items
- */
- public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/HashMap<>();
- /**
- * HashMap of Recipes based on their Fluids
- */
- public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/HashMap<>();
- public final HashSet<String> mRecipeFluidNameMap = new HashSet<>();
- /**
- * The List of all Recipes
- */
- public final Collection<GT_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 GT_Recipe_Map(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) {
- sMappings.add(this);
- mNEIAllowed = aNEIAllowed;
- mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI;
- mRecipeList = aRecipeList;
- mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName;
- mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png";
- mNEISpecialValuePre = aNEISpecialValuePre;
- mNEISpecialValueMultiplier = aNEISpecialValueMultiplier;
- mNEISpecialValuePost = aNEISpecialValuePost;
- mAmperage = aAmperage;
- mUsualInputCount = aUsualInputCount;
- mUsualOutputCount = aUsualOutputCount;
- mMinimalInputItems = aMinimalInputItems;
- mMinimalInputFluids = aMinimalInputFluids;
- GregTech_API.sFluidMappings.add(mRecipeFluidMap);
- GregTech_API.sItemStackMappings.add(mRecipeItemMap);
- GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName);
- }
-
- 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 addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
-
- public GT_Recipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return addRecipe(new GT_Recipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false);
- }
-
- public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
-
- public GT_Recipe addRecipe(GT_Recipe aRecipe) {
- return addRecipe(aRecipe, true, false, false);
- }
-
- protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) {
- aRecipe.mHidden = aHidden;
- aRecipe.mFakeRecipe = aFakeRecipe;
- if (aRecipe.mFluidInputs.length < mMinimalInputFluids && aRecipe.mInputs.length < mMinimalInputItems)
- return null;
- if (aCheckForCollisions && findRecipe(null, false, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null)
- return null;
- return add(aRecipe);
- }
-
- /**
- * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
- */
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
-
- /**
- * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
- */
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) {
- return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue),hidden);
- }
-
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt ,boolean hidden) {
- return addFakeRecipe(aCheckForCollisions, new GT_Recipe_WithAlt(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue, aAlt),hidden);
- }
-
- /**
- * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
- */
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) {
- return addRecipe(aRecipe, aCheckForCollisions, true, false);
- }
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe,boolean hidden) {
- return addRecipe(aRecipe, aCheckForCollisions, true, hidden);
- }
-
- public GT_Recipe add(GT_Recipe aRecipe) {
- mRecipeList.add(aRecipe);
- for (FluidStack aFluid : aRecipe.mFluidInputs)
- if (aFluid != null) {
- Collection<GT_Recipe> tList = mRecipeFluidMap.computeIfAbsent(aFluid.getFluid(), k -> new HashSet<>(1));
- tList.add(aRecipe);
- mRecipeFluidNameMap.add(aFluid.getFluid().getName());
- }
- return addToItemMap(aRecipe);
- }
-
- public void reInit() {
- mRecipeItemMap.clear();
- for (GT_Recipe tRecipe : mRecipeList) {
- GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs);
- GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs);
- addToItemMap(tRecipe);
- }
- }
-
- /**
- * @return if this Item is a valid Input for any for the Recipes
- */
- public boolean containsInput(ItemStack aStack) {
- return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))));
- }
-
- /**
- * @return if this Fluid is a valid Input for any for the Recipes
- */
- public boolean containsInput(FluidStack aFluid) {
- return aFluid != null && containsInput(aFluid.getFluid());
- }
-
- /**
- * @return if this Fluid is a valid Input for any for the Recipes
- */
- public boolean containsInput(Fluid aFluid) {
- return aFluid != null && mRecipeFluidNameMap.contains(aFluid.getName());
- }
-
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
- return findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, null, aInputs);
- }
-
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
- return findRecipe(aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs);
- }
-
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
- return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, aInputs);
- }
-
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
- return findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs);
- }
-
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- return findRecipe(aTileEntity, aRecipe, aNotUnificated, true, aVoltage, aFluids, aSpecialSlot, aInputs);
- }
- /**
- * finds a Recipe matching the aFluid and ItemStack Inputs.
- *
- * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup.
- * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up.
- * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs
- * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input
- * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage
- * @param aFluids the Fluid Inputs
- * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do.
- * @param aInputs the Item Inputs
- * @return the Recipe it has found or null for no matching Recipe
- */
- public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- // No Recipes? Well, nothing to be found then.
- if (mRecipeList.isEmpty()) return null;
-
- // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes.
- // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes.
- if (GregTech_API.sPostloadFinished) {
- if (mMinimalInputFluids > 0) {
- if (aFluids == null) return null;
- int tAmount = 0;
- for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++;
- if (tAmount < mMinimalInputFluids) return null;
- }
- if (mMinimalInputItems > 0) {
- if (aInputs == null) return null;
- int tAmount = 0;
- for (ItemStack aInput : aInputs) if (aInput != null) tAmount++;
- if (tAmount < mMinimalInputItems) return null;
- }
- }
-
- // Unification happens here in case the Input isn't already unificated.
- if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, aInputs);
-
- // Check the Recipe which has been used last time in order to not have to search for it again, if possible.
- if (aRecipe != null)
- if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
- return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null;
-
- // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items.
- if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs)
- if (tStack != null) {
- Collection<GT_Recipe>
- tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack));
- if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
- if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
- return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
- tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack)));
- if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
- if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
- return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
- }
-
- // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too.
- if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids)
- if (aFluid != null) {
- Collection<GT_Recipe>
- tRecipes = mRecipeFluidMap.get(aFluid.getFluid());
- if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
- if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
- return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
- }
-
- // And nothing has been found.
- return null;
- }
-
- protected GT_Recipe addToItemMap(GT_Recipe aRecipe) {
- for (ItemStack aStack : aRecipe.mInputs)
- if (aStack != null) {
- GT_ItemStack tStack = new GT_ItemStack(aStack);
- Collection<GT_Recipe> tList = mRecipeItemMap.computeIfAbsent(tStack, k -> new HashSet<>(1));
- tList.add(aRecipe);
- }
- return aRecipe;
- }
- }
-
- // -----------------------------------------------------------------------------------------------------------------
- // Here are a few Classes I use for Special Cases in some Machines without having to write a separate Machine Class.
- // -----------------------------------------------------------------------------------------------------------------
-
- /**
- * Abstract Class for general Recipe Handling of non GT Recipes
- */
- public static abstract class GT_Recipe_Map_NonGTRecipes extends GT_Recipe_Map {
- public GT_Recipe_Map_NonGTRecipes(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 boolean containsInput(ItemStack aStack) {
- return false;
- }
-
- @Override
- public boolean containsInput(FluidStack aFluid) {
- return false;
- }
-
- @Override
- public boolean containsInput(Fluid aFluid) {
- return false;
- }
-
- @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(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
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return null;
- }
-
- @Override
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return null;
- }
-
- @Override
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) {
- return null;
- }
-
- @Override
- public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) {
- return null;
- }
-
- @Override
- public GT_Recipe add(GT_Recipe aRecipe) {
- return null;
- }
-
- @Override
- public void reInit() {/**/}
-
- @Override
- protected GT_Recipe addToItemMap(GT_Recipe aRecipe) {
- return null;
- }
- }
-
- /**
- * Just a Recipe Map with Utility specifically for Fuels.
- */
- public static class GT_Recipe_Map_Fuel extends GT_Recipe_Map {
- public GT_Recipe_Map_Fuel(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);
- }
-
- public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, int aFuelValueInEU) {
- return addFuel(aInput, aOutput, null, null, 10000, aFuelValueInEU);
- }
-
- public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, int aChance, int aFuelValueInEU) {
- return addFuel(aInput, aOutput, null, null, aChance, aFuelValueInEU);
- }
-
- public GT_Recipe addFuel(FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
- return addFuel(null, null, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
- }
-
- public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
- return addFuel(aInput, aOutput, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
- }
-
- public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) {
- return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU);
- }
- }
-
- /**
- * Special Class for Furnace Recipe handling.
- */
- public static class GT_Recipe_Map_Furnace extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_Furnace(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null);
- return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 4, 0);
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_ModHandler.getSmeltingOutput(aStack, false, null) != null;
- }
- }
-
- /**
- * Special Class for Microwave Recipe handling.
- */
- public static class GT_Recipe_Map_Microwave extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_Microwave(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null);
-
- if (GT_Utility.areStacksEqual(aInputs[0], new ItemStack(Items.book, 1, W))) {
- return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getWrittenBook("Manual_Microwave", ItemList.Book_Written_03.get(1))}, null, null, null, null, 32, 4, 0);
- }
-
- // Check Container Item of Input since it is around the Input, then the Input itself, then Container Item of Output and last check the Output itself
- for (ItemStack tStack : new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true), aInputs[0], GT_Utility.getContainerItem(tOutput, true), tOutput})
- if (tStack != null) {
- if (GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.netherrack, 1, W), true)
- || GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.tnt, 1, W), true)
- || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.egg, 1, W), true)
- || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.firework_charge, 1, W), true)
- || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fireworks, 1, W), true)
- || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fire_charge, 1, W), true)
- ) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- GT_Log.exp.println("Microwave Explosion due to TNT || EGG || FIREWORKCHARGE || FIREWORK || FIRE CHARGE");
- ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
- }
- return null;
- }
- ItemData tData = GT_OreDictUnificator.getItemData(tStack);
-
-
- if (tData != null) {
- if (tData.mMaterial != null && tData.mMaterial.mMaterial != null) {
- if (tData.mMaterial.mMaterial.contains(SubTag.METAL) || tData.mMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- GT_Log.exp.println("Microwave Explosion due to METAL insertion");
- ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
- }
- return null;
- }
- if (tData.mMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- GT_Log.exp.println("Microwave INFLAMMATION due to FLAMMABLE insertion");
- ((IGregTechTileEntity) aTileEntity).setOnFire();
- }
- return null;
- }
- }
- for (MaterialStack tMaterial : tData.mByProducts)
- if (tMaterial != null) {
- if (tMaterial.mMaterial.contains(SubTag.METAL) || tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- GT_Log.exp.println("Microwave Explosion due to METAL insertion");
- ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
- }
- return null;
- }
- if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- ((IGregTechTileEntity) aTileEntity).setOnFire();
- GT_Log.exp.println("Microwave INFLAMMATION due to FLAMMABLE insertion");
- }
- return null;
- }
- }
- }
- if (TileEntityFurnace.getItemBurnTime(tStack) > 0) {
- if (aTileEntity instanceof IGregTechTileEntity) {
- ((IGregTechTileEntity) aTileEntity).setOnFire();
- GT_Log.exp.println("Microwave INFLAMMATION due to BURNABLE insertion");
- }
- return null;
- }
-
- }
-
- return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 32, 4, 0);
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_ModHandler.getSmeltingOutput(aStack, false, null) != null;
- }
- }
-
- /**
- * Special Class for Unboxinator handling.
- */
- public static class GT_Recipe_Map_Unboxinator extends GT_Recipe_Map {
- public GT_Recipe_Map_Unboxinator(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || !ItemList.IC2_Scrapbox.isStackEqual(aInputs[0], false, true))
- return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- ItemStack tOutput = GT_ModHandler.getRandomScrapboxDrop();
- if (tOutput == null)
- return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- GT_Recipe rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.IC2_Scrapbox.get(1)}, new ItemStack[]{tOutput}, null, null, null, null, 16, 1, 0);
- // It is not allowed to be buffered due to the random Output
- rRecipe.mCanBeBuffered = false;
- // Due to its randomness it is not good if there are Items in the Output Slot, because those Items could manipulate the outcome.
- rRecipe.mNeedsEmptyOutput = true;
- return rRecipe;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return ItemList.IC2_Scrapbox.isStackEqual(aStack, false, true) || super.containsInput(aStack);
- }
- }
-
- /**
- * Special Class for Fluid Canner handling.
- */
- public static class GT_Recipe_Map_FluidCanner extends GT_Recipe_Map {
- public GT_Recipe_Map_FluidCanner(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe != null || !GregTech_API.sPostloadFinished)
- return rRecipe;
- if (aFluids != null && aFluids.length > 0 && aFluids[0] != null) {
- ItemStack tOutput = GT_Utility.fillFluidContainer(aFluids[0], aInputs[0], false, true);
- FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true);
- if (tFluid != null)
- rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{tFluid}, null, Math.max(tFluid.amount / 64, 16), 1, 0);
- }
- if (rRecipe == null) {
- FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInputs[0], true);
- if (tFluid != null)
- rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true)}, null, null, null, new FluidStack[]{tFluid}, Math.max(tFluid.amount / 64, 16), 1, 0);
- }
- if (rRecipe != null) rRecipe.mCanBeBuffered = false;
- return rRecipe;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return aStack != null && (super.containsInput(aStack) || (aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0));
- }
-
- @Override
- public boolean containsInput(FluidStack aFluid) {
- return true;
- }
-
- @Override
- public boolean containsInput(Fluid aFluid) {
- return true;
- }
- }
-
- /**
- * Special Class for Recycler Recipe handling.
- */
- public static class GT_Recipe_Map_Recycler extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_Recycler(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aInputs[0]), 0) == null ? null : new ItemStack[]{ItemList.IC2_Scrap.get(1)}, null, new int[]{1250}, null, null, 45, 1, 0);
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aStack), 0) != null;
- }
- }
-
- /**
- * Special Class for Compressor Recipe handling.
- */
- public static class GT_Recipe_Map_Compressor extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_Compressor(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
- ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.compressor.getRecipes(), true, new NBTTagCompound(), null, null, null);
- return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.compressor.getRecipes(), false, new NBTTagCompound(), null, null, null));
- }
- }
-
- /**
- * Special Class for Extractor Recipe handling.
- */
- public static class GT_Recipe_Map_Extractor extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_Extractor(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
- ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.extractor.getRecipes(), true, new NBTTagCompound(), null, null, null);
- return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.extractor.getRecipes(), false, new NBTTagCompound(), null, null, null));
- }
- }
-
- /**
- * Special Class for Thermal Centrifuge Recipe handling.
- */
- public static class GT_Recipe_Map_ThermalCentrifuge extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_ThermalCentrifuge(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
- ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.centrifuge.getRecipes(), true, new NBTTagCompound(), null, null, null);
- return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 48, 0) : null;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.centrifuge.getRecipes(), false, new NBTTagCompound(), null, null, null));
- }
- }
-
- /**
- * Special Class for Ore Washer Recipe handling.
- */
- public static class GT_Recipe_Map_OreWasher extends GT_Recipe_Map_NonGTRecipes {
- public GT_Recipe_Map_OreWasher(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 || !GT_ModHandler.isWater(aFluids[0]))
- return null;
- if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
- ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
- NBTTagCompound aRecipeMetaData = new NBTTagCompound();
- ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.oreWashing.getRecipes(), true, aRecipeMetaData, null, null, null);
- return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount"))}, null, 400, 16, 0) : null;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.oreWashing.getRecipes(), false, new NBTTagCompound(), null, null, null));
- }
-
- @Override
- public boolean containsInput(FluidStack aFluid) {
- return GT_ModHandler.isWater(aFluid);
- }
-
- @Override
- public boolean containsInput(Fluid aFluid) {
- return GT_ModHandler.isWater(new FluidStack(aFluid, 0));
- }
- }
-
- /**
- * Special Class for Macerator/RockCrusher Recipe handling.
- */
- public static class GT_Recipe_Map_Macerator extends GT_Recipe_Map {
- public GT_Recipe_Map_Macerator(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || !GregTech_API.sPostloadFinished)
- return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- aRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- if (aRecipe != null) return aRecipe;
-
- try {
- List<ItemStack> tRecipeOutputs = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.getRecipe(GT_Utility.copyAmount(1, aInputs[0])).getRandomizedOuputs();
- if (tRecipeOutputs != null) {
- aRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, tRecipeOutputs.toArray(new ItemStack[0]), null, null, null, null, 800, 2, 0);
- aRecipe.mCanBeBuffered = false;
- aRecipe.mNeedsEmptyOutput = true;
- return aRecipe;
- }
- } catch (NoClassDefFoundError e) {
- if (D1) GT_Log.err.println("Railcraft Not loaded");
- } catch (NullPointerException e) {/**/}
-
- ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
- ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.macerator.getRecipes(), true, new NBTTagCompound(), null, null, null);
- return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return super.containsInput(aStack) || GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.macerator.getRecipes(), false, new NBTTagCompound(), null, null, null));
- }
- }
-
- /**
- * Special Class for Assembler handling.
- */
- public static class GT_Recipe_Map_Assembler extends GT_Recipe_Map {
-
- public GT_Recipe_Map_Assembler(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
-
- GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, true, aVoltage, aFluids, aSpecialSlot, aInputs);
-/*
-
-
- Doesnt work, keep it as a reminder tho
-
- if (rRecipe == null){
- Set<ItemStack> aInputs2 = new TreeSet<ItemStack>();
- for (ItemStack aInput : aInputs) {
- aInputs2.add(aInput);
- }
-
- for (ItemStack aInput : aInputs) {
- aInputs2.remove(aInput);
- int[] oredictIDs = OreDictionary.getOreIDs(aInput);
- if ( oredictIDs.length > 1){
- for (final int i : oredictIDs){
- final ItemStack[] oredictIS = (ItemStack[]) OreDictionary.getOres(OreDictionary.getOreName(i)).toArray();
- if (oredictIS != null && oredictIS.length > 1){
- for (final ItemStack IS : oredictIS){
- aInputs2.add(IS);
- ItemStack[] temp = (ItemStack[]) aInputs2.toArray();
- rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot,temp);
- if(rRecipe!= null){
- break;
- }
- else {
- aInputs2.remove(IS);
- }
- }
- if(rRecipe!= null)
- break;
- }
- }
- if(rRecipe!= null)
- break;
- }else
- aInputs2.add(aInput);
- if(rRecipe!= null)
- break;
- }
- }
-*/
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe == null || !GregTech_API.sPostloadFinished)
- return rRecipe;
-
- for (ItemStack aInput : aInputs) {
- if (ItemList.Paper_Printed_Pages.isStackEqual(aInput, false, true)) {
- rRecipe = rRecipe.copy();
- rRecipe.mCanBeBuffered = false;
- rRecipe.mOutputs[0].setTagCompound(aInput.getTagCompound());
- }
-
- }
- return rRecipe;
- }
-
- }
-
- /**
- * Special Class for Forming Press handling.
- */
- public static class GT_Recipe_Map_FormingPress extends GT_Recipe_Map {
- public GT_Recipe_Map_FormingPress(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- if (aInputs == null || aInputs.length < 2 || aInputs[0] == null || aInputs[1] == null || !GregTech_API.sPostloadFinished)
- return rRecipe;
- if (rRecipe == null) {
- if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[0], false, true)) {
- ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[1]);
- tOutput.setStackDisplayName(aInputs[0].getDisplayName());
- rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[1])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
- rRecipe.mCanBeBuffered = false;
- return rRecipe;
- }
- if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[1], false, true)) {
- ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[0]);
- tOutput.setStackDisplayName(aInputs[1].getDisplayName());
- rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
- rRecipe.mCanBeBuffered = false;
- return rRecipe;
- }
- return null;
- }
- for (ItemStack aMold : aInputs) {
- if (ItemList.Shape_Mold_Credit.isStackEqual(aMold, false, true)) {
- NBTTagCompound tNBT = aMold.getTagCompound();
- if (tNBT == null) tNBT = new NBTTagCompound();
- if (!tNBT.hasKey("credit_security_id")) tNBT.setLong("credit_security_id", System.nanoTime());
- aMold.setTagCompound(tNBT);
-
- rRecipe = rRecipe.copy();
- rRecipe.mCanBeBuffered = false;
- rRecipe.mOutputs[0].setTagCompound(tNBT);
- return rRecipe;
- }
- }
- return rRecipe;
- }
- }
-
- /**
- * Special Class for Printer handling.
- */
- public static class GT_Recipe_Map_Printer extends GT_Recipe_Map {
- public GT_Recipe_Map_Printer(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
- GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
- if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length <= 0 || aFluids[0] == null || !GregTech_API.sPostloadFinished)
- return rRecipe;
-
- Dyes aDye = null;
- for (Dyes tDye : Dyes.VALUES)
- if (tDye.isFluidDye(aFluids[0])) {
- aDye = tDye;
- break;
- }
-
- if (aDye == null) return rRecipe;
-
- if (rRecipe == null) {
- ItemStack
- tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], aInputs[0], aInputs[0], aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1), aInputs[0], aInputs[0], aInputs[0], aInputs[0]);
- if (tOutput != null)
- return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(8, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 256, 2, 0), false, false, true);
-
- tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1));
- if (tOutput != null)
- return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 32, 2, 0), false, false, true);
- } else {
- if (aInputs[0].getItem() == Items.paper) {
- if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
- NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
- if (tNBT == null || GT_Utility.isStringInvalid(tNBT.getString("title")) || GT_Utility.isStringInvalid(tNBT.getString("author")))
- return null;
-
- rRecipe = rRecipe.copy();
- rRecipe.mCanBeBuffered = false;
- rRecipe.mOutputs[0].setTagCompound(tNBT);
- return rRecipe;
- }
- if (aInputs[0].getItem() == Items.map) {
- if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
- NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
- if (tNBT == null || !tNBT.hasKey("map_id")) return null;
-
- rRecipe = rRecipe.copy();
- rRecipe.mCanBeBuffered = false;
- rRecipe.mOutputs[0].setItemDamage(tNBT.getShort("map_id"));
- return rRecipe;
- }
- if (ItemList.Paper_Punch_Card_Empty.isStackEqual(aInputs[0], false, true)) {
- if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
- NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
- if (tNBT == null || !tNBT.hasKey("GT.PunchCardData")) return null;
-
- rRecipe = rRecipe.copy();
- rRecipe.mCanBeBuffered = false;
- rRecipe.mOutputs[0].setTagCompound(GT_Utility.getNBTContainingString(new NBTTagCompound(), "GT.PunchCardData", tNBT.getString("GT.PunchCardData")));
- return rRecipe;
- }
- }
- return rRecipe;
- }
-
- @Override
- public boolean containsInput(ItemStack aStack) {
- return true;
- }
-
- @Override
- public boolean containsInput(FluidStack aFluid) {
- return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
- }
-
- @Override
- public boolean containsInput(Fluid aFluid) {
- return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
- }
- }
-
- public static class GT_Recipe_Map_LargeBoilerFakeFuels extends GT_Recipe_Map {
-
- public GT_Recipe_Map_LargeBoilerFakeFuels() {
- super(new HashSet<>(55), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true);
- GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1);
- explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler.");
- addRecipe(explanatoryRecipe);
- }
-
- public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) {
- return addRecipe(recipe, ((double) recipe.mSpecialValue) / 10);
- }
-
- public GT_Recipe addDieselRecipe(GT_Recipe recipe) {
- return addRecipe(recipe, ((double) recipe.mSpecialValue) / 40);
- }
-
- public void addSolidRecipes(ItemStack... itemStacks) {
- for (ItemStack itemStack : itemStacks) {
- addSolidRecipe(itemStack);
- }
- }
-
- public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) {
- return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600);
- }
-
- private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) {
- recipe = new GT_Recipe(recipe);
- //Some recipes will have a burn time like 15.9999999 and % always rounds down
- double floatErrorCorrection = 0.0001;
-
- double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection;
- bronzeBurnTime -= bronzeBurnTime % 0.05;
- double steelBurnTime = baseBurnTime * 1.5 + floatErrorCorrection;
- steelBurnTime -= steelBurnTime % 0.05;
- double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection;
- titaniumBurnTime -= titaniumBurnTime % 0.05;
- double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection;
- tungstensteelBurnTime -= tungstensteelBurnTime % 0.05;
-
- recipe.setNeiDesc("Burn time in seconds:",
- String.format("Bronze Boiler: %.4f", bronzeBurnTime),
- String.format("Steel Boiler: %.4f", steelBurnTime),
- String.format("Titanium Boiler: %.4f", titaniumBurnTime),
- String.format("Tungstensteel Boiler: %.4f", tungstensteelBurnTime));
- return super.addRecipe(recipe);
- }
-
- }
-
- public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map{
- private static int TOTAL_INPUT_COUNT = 6;
- private static int OUTPUT_COUNT = 2;
- private static int FLUID_OUTPUT_COUNT = 4;
-
- public GT_Recipe_Map_LargeChemicalReactor() {
- super(new HashSet<>(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true);
- }
-
- @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) {
- aOptimize = false;
- ArrayList<ItemStack> adjustedInputs = new ArrayList<>();
- ArrayList<ItemStack> adjustedOutputs = new ArrayList<>();
- ArrayList<FluidStack> adjustedFluidInputs = new ArrayList<>();
- ArrayList<FluidStack> adjustedFluidOutputs = new ArrayList<>();
-
- if (aInputs == null) {
- aInputs = new ItemStack[0];
- } else {
- aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
- }
-
- for (ItemStack input : aInputs) {
- FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input);
- if (inputFluidContent != null) {
- inputFluidContent.amount *= input.stackSize;
- if (inputFluidContent.getFluid().getName().equals("ic2steam")) {
- inputFluidContent = GT_ModHandler.getSteam(inputFluidContent.amount);
- }
- adjustedFluidInputs.add(inputFluidContent);
- } else {
- ItemData itemData = GT_OreDictUnificator.getItemData(input);
- if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty) {
- continue;
- } else {
- if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mPrefix == OrePrefixes.cell) {
- ItemStack dustStack = itemData.mMaterial.mMaterial.getDust(input.stackSize);
- if (dustStack != null) {
- adjustedInputs.add(dustStack);
- } else {
- adjustedInputs.add(input);
- }
- } else {
- adjustedInputs.add(input);
- }
- }
- }
-
- if (aFluidInputs == null) {
- aFluidInputs = new FluidStack[0];
- }
- }
- Collections.addAll(adjustedFluidInputs, aFluidInputs);
- aInputs = adjustedInputs.toArray(new ItemStack[0]);
- aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[0]);
-
- if (aOutputs == null) {
- aOutputs = new ItemStack[0];
- } else {
- aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
- }
-
- for (ItemStack output : aOutputs) {
- FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output);
- if (outputFluidContent != null) {
- outputFluidContent.amount *= output.stackSize;
- if (outputFluidContent.getFluid().getName().equals("ic2steam")) {
- outputFluidContent = GT_ModHandler.getSteam(outputFluidContent.amount);
- }
- adjustedFluidOutputs.add(outputFluidContent);
- } else {
- ItemData itemData = GT_OreDictUnificator.getItemData(output);
- if (!(itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty)) {
- adjustedOutputs.add(output);
- }
- }
- }
- if (aFluidOutputs == null) {
- aFluidOutputs = new FluidStack[0];
- }
- Collections.addAll(adjustedFluidOutputs, aFluidOutputs);
- aOutputs = adjustedOutputs.toArray(new ItemStack[0]);
- aFluidOutputs = adjustedFluidOutputs.toArray(new FluidStack[0]);
-
- return addRecipe(new GT_Recipe_LargeChemicalReactor(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
-
- private static class GT_Recipe_LargeChemicalReactor extends GT_Recipe{
-
- protected GT_Recipe_LargeChemicalReactor(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
- }
-
- @Override
- public ArrayList<PositionedStack> getInputPositionedStacks() {
- int itemLimit = Math.min(mInputs.length, TOTAL_INPUT_COUNT);
- int fluidLimit = Math.min(mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit);
- int inputlimit = itemLimit + fluidLimit;
- int j = 0;
-
- ArrayList<PositionedStack> inputStacks = new ArrayList<>(inputlimit);
-
- for (int i = 0; i < itemLimit; i++, j++) {
- if (this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1))) {
- if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
- GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
- else
- GT_Log.out.println("recipe " + this.toString() + " has errored!");
-
- new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
- }
-
-
- if ((this.mInputs != null && this.mInputs[i] != null) || !GT_Values.allow_broken_recipemap)
- inputStacks.add(new FixedPositionedStack(this.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- else
- inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- }
-
- for (int i = 0; i < fluidLimit; i++, j++) {
- if (this.mFluidInputs == null || this.mFluidInputs[i] == null) {
- if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
- GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
- else
- GT_Log.out.println("recipe " + this.toString() + " has errored!");
-
- new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
- }
-
- if ((this.mFluidInputs != null && this.mFluidInputs[i] != null) || !GT_Values.allow_broken_recipemap)
- inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- }
-
- return inputStacks;
- }
-
- @Override
- public ArrayList<PositionedStack> getOutputPositionedStacks() {
- int itemLimit = Math.min(mOutputs.length, OUTPUT_COUNT);
- int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT);
- ArrayList<PositionedStack> outputStacks = new ArrayList<>(itemLimit + fluidLimit);
-
- for (int i = 0; i < itemLimit; i++) {
- outputStacks.add(new FixedPositionedStack(this.mOutputs[i].copy(), 102 + i * 18, 5));
- }
-
- for (int i = 0; i < fluidLimit; i++) {
- outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), 102 + i * 18, 23));
- }
-
- return outputStacks;
- }
-
-
- }
- }
- public static class GT_Recipe_Map_DistillationTower extends GT_Recipe_Map {
- private static final int FLUID_OUTPUT_COUNT = 11;
- private static final int ROW_SIZE = 3;
-
- public GT_Recipe_Map_DistillationTower() {
- super(new HashSet<>(110), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, 4, 0, 0, 1, E, 1, E, true, true);
- }
-
- @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 addRecipe(new GT_Recipe_DistillationTower(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
- }
-
- @Override
- public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- return addRecipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
- }
-
- private static class GT_Recipe_DistillationTower extends GT_Recipe{
- protected GT_Recipe_DistillationTower(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
- super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
- }
-
- @Override
- public ArrayList<PositionedStack> getInputPositionedStacks() {
- ArrayList<PositionedStack> inputStacks = new ArrayList<>(1);
-
- if (this.mFluidInputs.length > 0 && this.mFluidInputs[0] != null) {
- inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[0], true), 48, 52));
- }
- return inputStacks;
- }
- @Override
- public ArrayList<PositionedStack> getOutputPositionedStacks() {
- int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT);
- ArrayList<PositionedStack> outputStacks = new ArrayList<>(1 + fluidLimit);
-
- if (this.mOutputs.length > 0 && this.mOutputs[0] != null) {
- outputStacks.add(new FixedPositionedStack(this.getOutput(0), 102, 52));
- }
-
- for (int i = 0; i < fluidLimit; i++) {
- int x = 102 + ((i + 1) % ROW_SIZE) * 18;
- int y = 52 - ((i + 1) / ROW_SIZE) * 18;
- outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), x, y));
- }
- return outputStacks;
- }
-
- }
- }
-
- public static class GT_Recipe_WithAlt extends GT_Recipe {
-
- ItemStack[][] mOreDictAlt;
-
- public GT_Recipe_WithAlt(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt) {
- super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
- mOreDictAlt = aAlt;
- }
-
-
- public Object getAltRepresentativeInput(int aIndex) {
- if (aIndex < 0) return null;
- if (aIndex < mOreDictAlt.length) {
- if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) {
- ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length];
- for (int i = 0; i < mOreDictAlt[aIndex].length; i++) {
- rStacks[i] = GT_Utility.copy(mOreDictAlt[aIndex][i]);
- }
- return rStacks;
- }
- }
- if (aIndex >= mInputs.length) return null;
- return GT_Utility.copy(mInputs[aIndex]);
- }
-
- }
-}
+package gregtech.api.util;
+
+import codechicken.nei.PositionedStack;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.*;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
+import gregtech.api.objects.GT_FluidStack;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.ItemData;
+import gregtech.api.objects.MaterialStack;
+import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator;
+import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
+import ic2.core.Ic2Items;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+import java.util.*;
+
+import static gregtech.api.enums.GT_Values.*;
+
+/**
+ * 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> {
+ public static volatile int VERSION = 509;
+ /**
+ * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
+ */
+ public ItemStack[] mInputs, mOutputs;
+ /**
+ * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
+ */
+ public FluidStack[] mFluidInputs, mFluidOutputs;
+ /**
+ * If you changed the amount of Array-Items inside the Output Array then the length of this Array must be larger or equal to the Output Array. A chance of 10000 equals 100%
+ */
+ public int[] mChances;
+ /**
+ * An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible.
+ */
+ public Object mSpecialItems;
+ public int mDuration, mEUt, mSpecialValue;
+ /**
+ * Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe.
+ */
+ public boolean mEnabled = true;
+ /**
+ * If this Recipe is hidden from NEI
+ */
+ public boolean mHidden = false;
+ /**
+ * If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps, so that containsInput does return T on those fake Inputs)
+ */
+ public boolean mFakeRecipe = false;
+ /**
+ * If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes, you have to set this to F.
+ */
+ public boolean mCanBeBuffered = true;
+ /**
+ * If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs
+ */
+ public boolean mNeedsEmptyOutput = false;
+ /**
+ * Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels)
+ */
+ private String[] neiDesc = null;
+
+ private GT_Recipe(GT_Recipe aRecipe) {
+ mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs);
+ mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs);
+ mSpecialItems = aRecipe.mSpecialItems;
+ mChances = aRecipe.mChances;
+ mFluidInputs = GT_Utility.copyFluidArray(aRecipe.mFluidInputs);
+ mFluidOutputs = GT_Utility.copyFluidArray(aRecipe.mFluidOutputs);
+ mDuration = aRecipe.mDuration;
+ mSpecialValue = aRecipe.mSpecialValue;
+ mEUt = aRecipe.mEUt;
+ mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput;
+ mCanBeBuffered = aRecipe.mCanBeBuffered;
+ mFakeRecipe = aRecipe.mFakeRecipe;
+ mEnabled = aRecipe.mEnabled;
+ mHidden = aRecipe.mHidden;
+ }
+ protected GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ if (aInputs == null)
+ aInputs = new ItemStack[0];
+ if (aOutputs == null)
+ aOutputs = new ItemStack[0];
+ if (aFluidInputs == null)
+ aFluidInputs = new FluidStack[0];
+ if (aFluidOutputs == null)
+ aFluidOutputs = new FluidStack[0];
+ if (aChances == null)
+ aChances = new int[aOutputs.length];
+ if (aChances.length < aOutputs.length)
+ aChances = Arrays.copyOf(aChances, aOutputs.length);
+
+ aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
+ aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
+ aFluidInputs = GT_Utility.getArrayListWithoutNulls(aFluidInputs).toArray(new FluidStack[0]);
+ aFluidOutputs = GT_Utility.getArrayListWithoutNulls(aFluidOutputs).toArray(new FluidStack[0]);
+
+ GT_OreDictUnificator.setStackArray(true, aInputs);
+ GT_OreDictUnificator.setStackArray(true, aOutputs);
+
+ for (ItemStack tStack : aOutputs)
+ GT_Utility.updateItemStack(tStack);
+
+ for (int i = 0; i < aChances.length; i++)
+ if (aChances[i] <= 0)
+ aChances[i] = 10000;
+ for (int i = 0; i < aFluidInputs.length; i++)
+ aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]);
+ for (int i = 0; i < aFluidOutputs.length; i++)
+ aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]);
+
+ for (ItemStack aInput : aInputs)
+ if (aInput != null && Items.feather.getDamage(aInput) != W)
+ for (int j = 0; j < aOutputs.length; j++) {
+ if (GT_Utility.areStacksEqual(aInput, aOutputs[j])) {
+ if (aInput.stackSize >= aOutputs[j].stackSize) {
+ aInput.stackSize -= aOutputs[j].stackSize;
+ aOutputs[j] = null;
+ } else {
+ aOutputs[j].stackSize -= aInput.stackSize;
+ }
+ }
+ }
+
+ if (aOptimize && aDuration >= 32) {
+ ArrayList<ItemStack> tList = new ArrayList<>();
+ tList.addAll(Arrays.asList(aInputs));
+ tList.addAll(Arrays.asList(aOutputs));
+ for (int i = 0; i < tList.size(); i++) if (tList.get(i) == null) tList.remove(i--);
+
+ for (byte i = (byte) Math.min(64, aDuration / 16); i > 1; i--)
+ if (aDuration / i >= 16) {
+ boolean temp = true;
+ for (ItemStack stack : tList)
+ if (stack.stackSize % i != 0) {
+ temp = false;
+ break;
+ }
+ if (temp)
+ for (FluidStack aFluidInput : aFluidInputs)
+ if (aFluidInput.amount % i != 0) {
+ temp = false;
+ break;
+ }
+ if (temp)
+ for (FluidStack aFluidOutput : aFluidOutputs)
+ if (aFluidOutput.amount % i != 0) {
+ temp = false;
+ break;
+ }
+ if (temp) {
+ for (ItemStack itemStack : tList)
+ itemStack.stackSize /= i;
+ for (FluidStack aFluidInput : aFluidInputs)
+ aFluidInput.amount /= i;
+ for (FluidStack aFluidOutput : aFluidOutputs)
+ aFluidOutput.amount /= i;
+ aDuration /= i;
+ }
+ }
+ }
+
+ mInputs = aInputs;
+ mOutputs = aOutputs;
+ mSpecialItems = aSpecialItems;
+ mChances = aChances;
+ mFluidInputs = aFluidInputs;
+ mFluidOutputs = aFluidOutputs;
+ mDuration = aDuration;
+ mSpecialValue = aSpecialValue;
+ mEUt = aEUt;
+// checkCellBalance();
+ }
+
+ public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) {
+ this(aInput1, aOutput1, null, null, null, aFuelValue, aType);
+ }
+
+ // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
+ public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) {
+ this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue));
+
+ if (mInputs.length > 0 && aSpecialValue > 0) {
+ switch (aType) {
+ // Diesel Generator
+ case 0:
+ GT_Recipe_Map.sDieselFuels.addRecipe(this);
+ GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this);
+ break;
+ // Gas Turbine
+ case 1:
+ GT_Recipe_Map.sTurbineFuels.addRecipe(this);
+ break;
+ // Thermal Generator
+ case 2:
+ GT_Recipe_Map.sHotFuels.addRecipe(this);
+ break;
+ // Plasma Generator
+ case 4:
+ GT_Recipe_Map.sPlasmaFuels.addRecipe(this);
+ break;
+ // Magic Generator
+ case 5:
+ GT_Recipe_Map.sMagicFuels.addRecipe(this);
+ break;
+ // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator
+ default:
+ GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this);
+ GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this);
+ break;
+ }
+ }
+ }
+
+ public GT_Recipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt, int aSpecialValue) {
+ this(true, null, null, null, null, new FluidStack[]{aInput1, aInput2}, new FluidStack[]{aOutput1}, Math.max(aDuration, 1), aEUt, Math.max(Math.min(aSpecialValue, 160000000), 0));
+ if (mInputs.length > 1) {
+ GT_Recipe_Map.sFusionRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt) {
+ this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, aDuration, aEUt, 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sLatheRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, int aCellAmount, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) {
+ this(true, new ItemStack[]{aInput1, aCellAmount > 0 ? ItemList.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))) : null}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sDistillationRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) {
+ this(true, new ItemStack[]{aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2 > 0 ? Math.min(aInput2, 64) : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1))}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, 20, 30, 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sImplosionRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aOutput1) {
+ this(true, new ItemStack[]{aInput1, ItemList.Circuit_Integrated.getWithDamage(0, aInput1.stackSize)}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sBenderRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, ItemStack aInput2, int aEUt, int aDuration, ItemStack aOutput1) {
+ this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sAlloySmelterRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1, ItemStack aOutput2) {
+ this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sCannerRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration) {
+ this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), 120, 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
+ }
+ }
+
+ public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt, int VACUUM) {
+ this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), aEUt, 0);
+ if (mInputs.length > 0 && mOutputs[0] != null) {
+ GT_Recipe_Map.sVacuumRecipes.addRecipe(this);
+ }
+ }
+
+ //Dummy GT_Recipe maker...
+ public GT_Recipe(ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){
+ this(true, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
+ }
+
+ public static void reInit() {
+ GT_Log.out.println("GT_Mod: Re-Unificating Recipes.");
+ for (GT_Recipe_Map tMapEntry : GT_Recipe_Map.sMappings)
+ tMapEntry.reInit();
+ }
+
+ // -----
+ // Old Constructors, do not use!
+ // -----
+
+ public ItemStack getRepresentativeInput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mInputs.length) return null;
+ return GT_Utility.copy(mInputs[aIndex]);
+ }
+
+ public ItemStack getOutput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mOutputs.length) return null;
+ return GT_Utility.copy(mOutputs[aIndex]);
+ }
+
+ public int getOutputChance(int aIndex) {
+ if (aIndex < 0 || aIndex >= mChances.length) return 10000;
+ return mChances[aIndex];
+ }
+
+ public FluidStack getRepresentativeFluidInput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mFluidInputs.length || mFluidInputs[aIndex] == null) return null;
+ return mFluidInputs[aIndex].copy();
+ }
+
+ public FluidStack getFluidOutput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mFluidOutputs.length || mFluidOutputs[aIndex] == null) return null;
+ return mFluidOutputs[aIndex].copy();
+ }
+
+ public void checkCellBalance() {
+ if (!D2 || mInputs.length < 1) return;
+
+ int tInputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(mInputs);
+ int tOutputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(mOutputs);
+
+ if (tInputAmount < tOutputAmount) {
+ if (!Materials.Tin.contains(mInputs)) {
+ GT_Log.err.println("You get more Cells, than you put in? There must be something wrong.");
+ new Exception().printStackTrace(GT_Log.err);
+ }
+ } else if (tInputAmount > tOutputAmount) {
+ if (!Materials.Tin.contains(mOutputs)) {
+ GT_Log.err.println("You get less Cells, than you put in? GT Machines usually don't destroy Cells.");
+ new Exception().printStackTrace(GT_Log.err);
+ }
+ }
+ }
+
+ public GT_Recipe copy() {
+ return new GT_Recipe(this);
+ }
+
+ public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) {
+ return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs);
+ }
+
+ public static boolean GTppRecipeHelper;
+
+ public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
+ if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
+ int amt;
+ for (FluidStack tFluid : mFluidInputs)
+ if (tFluid != null) {
+ boolean temp = true;
+ amt = tFluid.amount;
+ for (FluidStack aFluid : aFluidInputs)
+ if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
+ if (aDontCheckStackSizes) {
+ temp = false;
+ break;
+ }
+ amt -= aFluid.amount;
+ if (amt < 1) {
+ temp = false;
+ break;
+ }
+ }
+ if (temp) return false;
+ }
+
+ if (mInputs.length > 0 && aInputs == null) return false;
+
+ for (ItemStack tStack : mInputs) {
+ if (tStack != null) {
+ amt = tStack.stackSize;
+ boolean temp = true;
+ for (ItemStack aStack : aInputs) {
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
+ if (GTppRecipeHelper) {//remove once the fix is out
+ if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
+ if (!GT_Utility.areStacksEqual(aStack, tStack, false))
+ continue;
+ }
+ }
+ if (aDontCheckStackSizes) {
+ temp = false;
+ break;
+ }
+ amt -= aStack.stackSize;
+ if (amt < 1) {
+ temp = false;
+ break;
+ }
+ }
+ }
+ if (temp) return false;
+ }
+ }
+ if (aDecreaseStacksizeBySuccess) {
+ if (aFluidInputs != null) {
+ for (FluidStack tFluid : mFluidInputs) {
+ if (tFluid != null) {
+ amt = tFluid.amount;
+ for (FluidStack aFluid : aFluidInputs) {
+ if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
+ if (aDontCheckStackSizes) {
+ aFluid.amount -= amt;
+ break;
+ }
+ if (aFluid.amount < amt) {
+ amt -= aFluid.amount;
+ aFluid.amount = 0;
+ } else {
+ aFluid.amount -= amt;
+ amt = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (aInputs != null) {
+ for (ItemStack tStack : mInputs) {
+ if (tStack != null) {
+ amt = tStack.stackSize;
+ for (ItemStack aStack : aInputs) {
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
+ if (GTppRecipeHelper) {
+ if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) {
+ if (!GT_Utility.areStacksEqual(aStack, tStack, false))
+ continue;
+ }
+ }
+ if (aDontCheckStackSizes){
+ aStack.stackSize -= amt;
+ break;
+ }
+ if (aStack.stackSize < amt){
+ amt -= aStack.stackSize;
+ aStack.stackSize = 0;
+ }else{
+ aStack.stackSize -= amt;
+ amt = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public int compareTo(GT_Recipe recipe) {
+ // first lowest tier recipes
+ // then fastest
+ // then with lowest special value
+ // then dry recipes
+ // then with fewer inputs
+ if (this.mEUt != recipe.mEUt) {
+ return this.mEUt - recipe.mEUt;
+ } else if (this.mDuration != recipe.mDuration) {
+ return this.mDuration - recipe.mDuration;
+ } else if (this.mSpecialValue != recipe.mSpecialValue) {
+ return this.mSpecialValue - recipe.mSpecialValue;
+ } else if (this.mFluidInputs.length != recipe.mFluidInputs.length) {
+ return this.mFluidInputs.length - recipe.mFluidInputs.length;
+ } else if (this.mInputs.length != recipe.mInputs.length) {
+ return this.mInputs.length - recipe.mInputs.length;
+ }
+ return 0;
+ }
+
+ public String[] getNeiDesc() {
+ return neiDesc;
+ }
+
+ protected void setNeiDesc(String... neiDesc) {
+ this.neiDesc = neiDesc;
+ }
+
+ /**
+ * Overriding this method and getOutputPositionedStacks allows for custom NEI stack placement
+ * @return A list of input stacks
+ */
+ public ArrayList<PositionedStack> getInputPositionedStacks(){
+ return null;
+ }
+
+ /**
+ * Overriding this method and getInputPositionedStacks allows for custom NEI stack placement
+ * @return A list of output stacks
+ */
+ public ArrayList<PositionedStack> getOutputPositionedStacks(){
+ return null;
+ }
+
+ public static class GT_Recipe_AssemblyLine{
+ public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>();
+
+ public ItemStack mResearchItem;
+ public int mResearchTime;
+ public ItemStack[] mInputs;
+ public FluidStack[] mFluidInputs;
+ public ItemStack mOutput;
+ public int mDuration;
+ public int mEUt;
+ public ItemStack[][] mOreDictAlt;
+
+ public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) {
+ this(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt, new ItemStack[aInputs.length][]);
+ }
+
+ public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt, ItemStack[][] aAlt) {
+ mResearchItem = aResearchItem;
+ mResearchTime = aResearchTime;
+ mInputs = aInputs;
+ mFluidInputs = aFluidInputs;
+ mOutput = aOutput;
+ mDuration = aDuration;
+ mEUt = aEUt;
+ mOreDictAlt = aAlt;
+ }
+
+ }
+
+ public static class GT_Recipe_Map {
+ /**
+ * Contains all Recipe Maps
+ */
+ public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<>();
+
+ public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<>(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet<>(750), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false);
+
+ public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sReplicatorFakeRecipes = new ReplicatorFakeMap(new HashSet<>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true);
+ //public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map(new HashSet<>(110), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true);
+ public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<>(5), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet<>(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet<>(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet<>(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraver", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer2", 9, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave", 1, 1, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<>(16600), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<>(2550), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<>(2100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet<>(10), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet<>(400), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 1, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map(new HashSet<>(35000), "gt.recipe.fluidsolidifier", "Fluid Solidifier", null, RES_PATH_GUI + "basicmachines/FluidSolidifier", 1, 1, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map(new HashSet<>(15000), "gt.recipe.fluidextractor", "Fluid Extractor", null, RES_PATH_GUI + "basicmachines/FluidExtractor", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map(new HashSet<>(2500), "gt.recipe.packager", "Packager", null, RES_PATH_GUI + "basicmachines/Packager", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator(new HashSet<>(2500), "gt.recipe.unpackager", "Unpackager", null, RES_PATH_GUI + "basicmachines/Unpackager", 1, 2, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/FusionReactor", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true);
+ public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1200), "gt.recipe.centrifuge", "Centrifuge", null, RES_PATH_GUI + "basicmachines/Centrifuge", 2, 6, 0, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.electrolyzer", "Electrolyzer", null, RES_PATH_GUI + "basicmachines/Electrolyzer", 2, 6, 0, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map(new HashSet<>(800), "gt.recipe.blastfurnace", "Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true);
+ public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.primitiveblastfurnace", "Primitive Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 3, 3, 1, 0, 1, E, 1, E, false, true);
+ public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.implosioncompressor", "Implosion Compressor", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet<>(305), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, false, true);
+ public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<>(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor();
+ public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower();
+ public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<>(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<>(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet<>(12000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(8200), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler2", 9, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(605), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet<>(1150), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<>(5125), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter2", 2, 2, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<>(20), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet<>(13000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true);
+ public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false);
+ public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+ public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = new GT_Recipe_Map_LargeBoilerFakeFuels();
+
+ /**
+ * HashMap of Recipes based on their Items
+ */
+ public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/HashMap<>();
+ /**
+ * HashMap of Recipes based on their Fluids
+ */
+ public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/HashMap<>();
+ public final HashSet<String> mRecipeFluidNameMap = new HashSet<>();
+ /**
+ * The List of all Recipes
+ */
+ public final Collection<GT_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 GT_Recipe_Map(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) {
+ sMappings.add(this);
+ mNEIAllowed = aNEIAllowed;
+ mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI;
+ mRecipeList = aRecipeList;
+ mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName;
+ mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png";
+ mNEISpecialValuePre = aNEISpecialValuePre;
+ mNEISpecialValueMultiplier = aNEISpecialValueMultiplier;
+ mNEISpecialValuePost = aNEISpecialValuePost;
+ mAmperage = aAmperage;
+ mUsualInputCount = aUsualInputCount;
+ mUsualOutputCount = aUsualOutputCount;
+ mMinimalInputItems = aMinimalInputItems;
+ mMinimalInputFluids = aMinimalInputFluids;
+ GregTech_API.sFluidMappings.add(mRecipeFluidMap);
+ GregTech_API.sItemStackMappings.add(mRecipeItemMap);
+ GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName);
+ }
+
+ 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 addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ public GT_Recipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GT_Recipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false);
+ }
+
+ public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ public GT_Recipe addRecipe(GT_Recipe aRecipe) {
+ return addRecipe(aRecipe, true, false, false);
+ }
+
+ protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) {
+ aRecipe.mHidden = aHidden;
+ aRecipe.mFakeRecipe = aFakeRecipe;
+ if (aRecipe.mFluidInputs.length < mMinimalInputFluids && aRecipe.mInputs.length < mMinimalInputItems)
+ return null;
+ if (aCheckForCollisions && findRecipe(null, false, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null)
+ return null;
+ return add(aRecipe);
+ }
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) {
+ return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue),hidden);
+ }
+
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt ,boolean hidden) {
+ return addFakeRecipe(aCheckForCollisions, new GT_Recipe_WithAlt(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue, aAlt),hidden);
+ }
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) {
+ return addRecipe(aRecipe, aCheckForCollisions, true, false);
+ }
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe,boolean hidden) {
+ return addRecipe(aRecipe, aCheckForCollisions, true, hidden);
+ }
+
+ public GT_Recipe add(GT_Recipe aRecipe) {
+ mRecipeList.add(aRecipe);
+ for (FluidStack aFluid : aRecipe.mFluidInputs)
+ if (aFluid != null) {
+ Collection<GT_Recipe> tList = mRecipeFluidMap.computeIfAbsent(aFluid.getFluid(), k -> new HashSet<>(1));
+ tList.add(aRecipe);
+ mRecipeFluidNameMap.add(aFluid.getFluid().getName());
+ }
+ return addToItemMap(aRecipe);
+ }
+
+ public void reInit() {
+ mRecipeItemMap.clear();
+ for (GT_Recipe tRecipe : mRecipeList) {
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs);
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs);
+ addToItemMap(tRecipe);
+ }
+ }
+
+ /**
+ * @return if this Item is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(ItemStack aStack) {
+ return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))));
+ }
+
+ /**
+ * @return if this Fluid is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(FluidStack aFluid) {
+ return aFluid != null && containsInput(aFluid.getFluid());
+ }
+
+ /**
+ * @return if this Fluid is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(Fluid aFluid) {
+ return aFluid != null && mRecipeFluidNameMap.contains(aFluid.getName());
+ }
+
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, null, aInputs);
+ }
+
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs);
+ }
+
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, aInputs);
+ }
+
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs);
+ }
+
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, aRecipe, aNotUnificated, true, aVoltage, aFluids, aSpecialSlot, aInputs);
+ }
+ /**
+ * finds a Recipe matching the aFluid and ItemStack Inputs.
+ *
+ * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup.
+ * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up.
+ * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs
+ * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input
+ * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage
+ * @param aFluids the Fluid Inputs
+ * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do.
+ * @param aInputs the Item Inputs
+ * @return the Recipe it has found or null for no matching Recipe
+ */
+ public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ // No Recipes? Well, nothing to be found then.
+ if (mRecipeList.isEmpty()) return null;
+
+ // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes.
+ // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes.
+ if (GregTech_API.sPostloadFinished) {
+ if (mMinimalInputFluids > 0) {
+ if (aFluids == null) return null;
+ int tAmount = 0;
+ for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++;
+ if (tAmount < mMinimalInputFluids) return null;
+ }
+ if (mMinimalInputItems > 0) {
+ if (aInputs == null) return null;
+ int tAmount = 0;
+ for (ItemStack aInput : aInputs) if (aInput != null) tAmount++;
+ if (tAmount < mMinimalInputItems) return null;
+ }
+ }
+
+ // Unification happens here in case the Input isn't already unificated.
+ if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs);
+
+ // Check the Recipe which has been used last time in order to not have to search for it again, if possible.
+ if (aRecipe != null)
+ if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
+ return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null;
+
+ // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items.
+ if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs)
+ if (tStack != null) {
+ Collection<GT_Recipe>
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack));
+ if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack)));
+ if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too.
+ if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids)
+ if (aFluid != null) {
+ Collection<GT_Recipe>
+ tRecipes = mRecipeFluidMap.get(aFluid.getFluid());
+ if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // And nothing has been found.
+ return null;
+ }
+
+ protected GT_Recipe addToItemMap(GT_Recipe aRecipe) {
+ for (ItemStack aStack : aRecipe.mInputs)
+ if (aStack != null) {
+ GT_ItemStack tStack = new GT_ItemStack(aStack);
+ Collection<GT_Recipe> tList = mRecipeItemMap.computeIfAbsent(tStack, k -> new HashSet<>(1));
+ tList.add(aRecipe);
+ }
+ return aRecipe;
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ // Here are a few Classes I use for Special Cases in some Machines without having to write a separate Machine Class.
+ // -----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Abstract Class for general Recipe Handling of non GT Recipes
+ */
+ public static abstract class GT_Recipe_Map_NonGTRecipes extends GT_Recipe_Map {
+ public GT_Recipe_Map_NonGTRecipes(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 boolean containsInput(ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean containsInput(FluidStack aFluid) {
+ return false;
+ }
+
+ @Override
+ public boolean containsInput(Fluid aFluid) {
+ return false;
+ }
+
+ @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(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
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) {
+ return null;
+ }
+
+ @Override
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) {
+ return null;
+ }
+
+ @Override
+ public GT_Recipe add(GT_Recipe aRecipe) {
+ return null;
+ }
+
+ @Override
+ public void reInit() {/**/}
+
+ @Override
+ protected GT_Recipe addToItemMap(GT_Recipe aRecipe) {
+ return null;
+ }
+ }
+
+ /**
+ * Just a Recipe Map with Utility specifically for Fuels.
+ */
+ public static class GT_Recipe_Map_Fuel extends GT_Recipe_Map {
+ public GT_Recipe_Map_Fuel(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);
+ }
+
+ public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, int aFuelValueInEU) {
+ return addFuel(aInput, aOutput, null, null, 10000, aFuelValueInEU);
+ }
+
+ public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, int aChance, int aFuelValueInEU) {
+ return addFuel(aInput, aOutput, null, null, aChance, aFuelValueInEU);
+ }
+
+ public GT_Recipe addFuel(FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
+ return addFuel(null, null, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
+ }
+
+ public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
+ return addFuel(aInput, aOutput, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
+ }
+
+ public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) {
+ return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU);
+ }
+ }
+
+ /**
+ * Special Class for Furnace Recipe handling.
+ */
+ public static class GT_Recipe_Map_Furnace extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_Furnace(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null);
+ return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 4, 0);
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_ModHandler.getSmeltingOutput(aStack, false, null) != null;
+ }
+ }
+
+ /**
+ * Special Class for Microwave Recipe handling.
+ */
+ public static class GT_Recipe_Map_Microwave extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_Microwave(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null);
+
+ if (GT_Utility.areStacksEqual(aInputs[0], new ItemStack(Items.book, 1, W))) {
+ return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getWrittenBook("Manual_Microwave", ItemList.Book_Written_03.get(1))}, null, null, null, null, 32, 4, 0);
+ }
+
+ // Check Container Item of Input since it is around the Input, then the Input itself, then Container Item of Output and last check the Output itself
+ for (ItemStack tStack : new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true), aInputs[0], GT_Utility.getContainerItem(tOutput, true), tOutput})
+ if (tStack != null) {
+ if (GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.netherrack, 1, W), true)
+ || GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.tnt, 1, W), true)
+ || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.egg, 1, W), true)
+ || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.firework_charge, 1, W), true)
+ || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fireworks, 1, W), true)
+ || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fire_charge, 1, W), true)
+ ) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ GT_Log.exp.println("Microwave Explosion due to TNT || EGG || FIREWORKCHARGE || FIREWORK || FIRE CHARGE");
+ ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
+ }
+ return null;
+ }
+ ItemData tData = GT_OreDictUnificator.getItemData(tStack);
+
+
+ if (tData != null) {
+ if (tData.mMaterial != null && tData.mMaterial.mMaterial != null) {
+ if (tData.mMaterial.mMaterial.contains(SubTag.METAL) || tData.mMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ GT_Log.exp.println("Microwave Explosion due to METAL insertion");
+ ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
+ }
+ return null;
+ }
+ if (tData.mMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ GT_Log.exp.println("Microwave INFLAMMATION due to FLAMMABLE insertion");
+ ((IGregTechTileEntity) aTileEntity).setOnFire();
+ }
+ return null;
+ }
+ }
+ for (MaterialStack tMaterial : tData.mByProducts)
+ if (tMaterial != null) {
+ if (tMaterial.mMaterial.contains(SubTag.METAL) || tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ GT_Log.exp.println("Microwave Explosion due to METAL insertion");
+ ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
+ }
+ return null;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ ((IGregTechTileEntity) aTileEntity).setOnFire();
+ GT_Log.exp.println("Microwave INFLAMMATION due to FLAMMABLE insertion");
+ }
+ return null;
+ }
+ }
+ }
+ if (TileEntityFurnace.getItemBurnTime(tStack) > 0) {
+ if (aTileEntity instanceof IGregTechTileEntity) {
+ ((IGregTechTileEntity) aTileEntity).setOnFire();
+ GT_Log.exp.println("Microwave INFLAMMATION due to BURNABLE insertion");
+ }
+ return null;
+ }
+
+ }
+
+ return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 32, 4, 0);
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_ModHandler.getSmeltingOutput(aStack, false, null) != null;
+ }
+ }
+
+ /**
+ * Special Class for Unboxinator handling.
+ */
+ public static class GT_Recipe_Map_Unboxinator extends GT_Recipe_Map {
+ public GT_Recipe_Map_Unboxinator(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || !ItemList.IC2_Scrapbox.isStackEqual(aInputs[0], false, true))
+ return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ ItemStack tOutput = GT_ModHandler.getRandomScrapboxDrop();
+ if (tOutput == null)
+ return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ GT_Recipe rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.IC2_Scrapbox.get(1)}, new ItemStack[]{tOutput}, null, null, null, null, 16, 1, 0);
+ // It is not allowed to be buffered due to the random Output
+ rRecipe.mCanBeBuffered = false;
+ // Due to its randomness it is not good if there are Items in the Output Slot, because those Items could manipulate the outcome.
+ rRecipe.mNeedsEmptyOutput = true;
+ return rRecipe;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return ItemList.IC2_Scrapbox.isStackEqual(aStack, false, true) || super.containsInput(aStack);
+ }
+ }
+
+ /**
+ * Special Class for Fluid Canner handling.
+ */
+ public static class GT_Recipe_Map_FluidCanner extends GT_Recipe_Map {
+ public GT_Recipe_Map_FluidCanner(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe != null || !GregTech_API.sPostloadFinished)
+ return rRecipe;
+ if (aFluids != null && aFluids.length > 0 && aFluids[0] != null) {
+ ItemStack tOutput = GT_Utility.fillFluidContainer(aFluids[0], aInputs[0], false, true);
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true);
+ if (tFluid != null)
+ rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{tFluid}, null, Math.max(tFluid.amount / 64, 16), 1, 0);
+ }
+ if (rRecipe == null) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInputs[0], true);
+ if (tFluid != null)
+ rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true)}, null, null, null, new FluidStack[]{tFluid}, Math.max(tFluid.amount / 64, 16), 1, 0);
+ }
+ if (rRecipe != null) rRecipe.mCanBeBuffered = false;
+ return rRecipe;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return aStack != null && (super.containsInput(aStack) || (aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0));
+ }
+
+ @Override
+ public boolean containsInput(FluidStack aFluid) {
+ return true;
+ }
+
+ @Override
+ public boolean containsInput(Fluid aFluid) {
+ return true;
+ }
+ }
+
+ /**
+ * Special Class for Recycler Recipe handling.
+ */
+ public static class GT_Recipe_Map_Recycler extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_Recycler(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aInputs[0]), 0) == null ? null : new ItemStack[]{ItemList.IC2_Scrap.get(1)}, null, new int[]{1250}, null, null, 45, 1, 0);
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aStack), 0) != null;
+ }
+ }
+
+ /**
+ * Special Class for Compressor Recipe handling.
+ */
+ public static class GT_Recipe_Map_Compressor extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_Compressor(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
+ ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.compressor.getRecipes(), true, new NBTTagCompound(), null, null, null);
+ return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.compressor.getRecipes(), false, new NBTTagCompound(), null, null, null));
+ }
+ }
+
+ /**
+ * Special Class for Extractor Recipe handling.
+ */
+ public static class GT_Recipe_Map_Extractor extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_Extractor(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
+ ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.extractor.getRecipes(), true, new NBTTagCompound(), null, null, null);
+ return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.extractor.getRecipes(), false, new NBTTagCompound(), null, null, null));
+ }
+ }
+
+ /**
+ * Special Class for Thermal Centrifuge Recipe handling.
+ */
+ public static class GT_Recipe_Map_ThermalCentrifuge extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_ThermalCentrifuge(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
+ ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.centrifuge.getRecipes(), true, new NBTTagCompound(), null, null, null);
+ return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 48, 0) : null;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.centrifuge.getRecipes(), false, new NBTTagCompound(), null, null, null));
+ }
+ }
+
+ /**
+ * Special Class for Ore Washer Recipe handling.
+ */
+ public static class GT_Recipe_Map_OreWasher extends GT_Recipe_Map_NonGTRecipes {
+ public GT_Recipe_Map_OreWasher(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 || !GT_ModHandler.isWater(aFluids[0]))
+ return null;
+ if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe;
+ ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
+ NBTTagCompound aRecipeMetaData = new NBTTagCompound();
+ ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.oreWashing.getRecipes(), true, aRecipeMetaData, null, null, null);
+ return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount"))}, null, 400, 16, 0) : null;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.oreWashing.getRecipes(), false, new NBTTagCompound(), null, null, null));
+ }
+
+ @Override
+ public boolean containsInput(FluidStack aFluid) {
+ return GT_ModHandler.isWater(aFluid);
+ }
+
+ @Override
+ public boolean containsInput(Fluid aFluid) {
+ return GT_ModHandler.isWater(new FluidStack(aFluid, 0));
+ }
+ }
+
+ /**
+ * Special Class for Macerator/RockCrusher Recipe handling.
+ */
+ public static class GT_Recipe_Map_Macerator extends GT_Recipe_Map {
+ public GT_Recipe_Map_Macerator(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || !GregTech_API.sPostloadFinished)
+ return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ aRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ if (aRecipe != null) return aRecipe;
+
+ try {
+ List<ItemStack> tRecipeOutputs = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.getRecipe(GT_Utility.copyAmount(1, aInputs[0])).getRandomizedOuputs();
+ if (tRecipeOutputs != null) {
+ aRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, tRecipeOutputs.toArray(new ItemStack[0]), null, null, null, null, 800, 2, 0);
+ aRecipe.mCanBeBuffered = false;
+ aRecipe.mNeedsEmptyOutput = true;
+ return aRecipe;
+ }
+ } catch (NoClassDefFoundError e) {
+ if (D1) GT_Log.err.println("Railcraft Not loaded");
+ } catch (NullPointerException e) {/**/}
+
+ ItemStack tComparedInput = GT_Utility.copy(aInputs[0]);
+ ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.macerator.getRecipes(), true, new NBTTagCompound(), null, null, null);
+ return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return super.containsInput(aStack) || GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.macerator.getRecipes(), false, new NBTTagCompound(), null, null, null));
+ }
+ }
+
+ /**
+ * Special Class for Assembler handling.
+ */
+ public static class GT_Recipe_Map_Assembler extends GT_Recipe_Map {
+
+ public GT_Recipe_Map_Assembler(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+
+ GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, true, aVoltage, aFluids, aSpecialSlot, aInputs);
+/*
+
+
+ Doesnt work, keep it as a reminder tho
+
+ if (rRecipe == null){
+ Set<ItemStack> aInputs2 = new TreeSet<ItemStack>();
+ for (ItemStack aInput : aInputs) {
+ aInputs2.add(aInput);
+ }
+
+ for (ItemStack aInput : aInputs) {
+ aInputs2.remove(aInput);
+ int[] oredictIDs = OreDictionary.getOreIDs(aInput);
+ if ( oredictIDs.length > 1){
+ for (final int i : oredictIDs){
+ final ItemStack[] oredictIS = (ItemStack[]) OreDictionary.getOres(OreDictionary.getOreName(i)).toArray();
+ if (oredictIS != null && oredictIS.length > 1){
+ for (final ItemStack IS : oredictIS){
+ aInputs2.add(IS);
+ ItemStack[] temp = (ItemStack[]) aInputs2.toArray();
+ rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot,temp);
+ if(rRecipe!= null){
+ break;
+ }
+ else {
+ aInputs2.remove(IS);
+ }
+ }
+ if(rRecipe!= null)
+ break;
+ }
+ }
+ if(rRecipe!= null)
+ break;
+ }else
+ aInputs2.add(aInput);
+ if(rRecipe!= null)
+ break;
+ }
+ }
+*/
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe == null || !GregTech_API.sPostloadFinished)
+ return rRecipe;
+
+ for (ItemStack aInput : aInputs) {
+ if (ItemList.Paper_Printed_Pages.isStackEqual(aInput, false, true)) {
+ rRecipe = rRecipe.copy();
+ rRecipe.mCanBeBuffered = false;
+ rRecipe.mOutputs[0].setTagCompound(aInput.getTagCompound());
+ }
+
+ }
+ return rRecipe;
+ }
+
+ }
+
+ /**
+ * Special Class for Forming Press handling.
+ */
+ public static class GT_Recipe_Map_FormingPress extends GT_Recipe_Map {
+ public GT_Recipe_Map_FormingPress(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ if (aInputs == null || aInputs.length < 2 || aInputs[0] == null || aInputs[1] == null || !GregTech_API.sPostloadFinished)
+ return rRecipe;
+ if (rRecipe == null) {
+ if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[0], false, true)) {
+ ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[1]);
+ tOutput.setStackDisplayName(aInputs[0].getDisplayName());
+ rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[1])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
+ rRecipe.mCanBeBuffered = false;
+ return rRecipe;
+ }
+ if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[1], false, true)) {
+ ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[0]);
+ tOutput.setStackDisplayName(aInputs[1].getDisplayName());
+ rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
+ rRecipe.mCanBeBuffered = false;
+ return rRecipe;
+ }
+ return null;
+ }
+ for (ItemStack aMold : aInputs) {
+ if (ItemList.Shape_Mold_Credit.isStackEqual(aMold, false, true)) {
+ NBTTagCompound tNBT = aMold.getTagCompound();
+ if (tNBT == null) tNBT = new NBTTagCompound();
+ if (!tNBT.hasKey("credit_security_id")) tNBT.setLong("credit_security_id", System.nanoTime());
+ aMold.setTagCompound(tNBT);
+
+ rRecipe = rRecipe.copy();
+ rRecipe.mCanBeBuffered = false;
+ rRecipe.mOutputs[0].setTagCompound(tNBT);
+ return rRecipe;
+ }
+ }
+ return rRecipe;
+ }
+ }
+
+ /**
+ * Special Class for Printer handling.
+ */
+ public static class GT_Recipe_Map_Printer extends GT_Recipe_Map {
+ public GT_Recipe_Map_Printer(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 findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length <= 0 || aFluids[0] == null || !GregTech_API.sPostloadFinished)
+ return rRecipe;
+
+ Dyes aDye = null;
+ for (Dyes tDye : Dyes.VALUES)
+ if (tDye.isFluidDye(aFluids[0])) {
+ aDye = tDye;
+ break;
+ }
+
+ if (aDye == null) return rRecipe;
+
+ if (rRecipe == null) {
+ ItemStack
+ tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], aInputs[0], aInputs[0], aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1), aInputs[0], aInputs[0], aInputs[0], aInputs[0]);
+ if (tOutput != null)
+ return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(8, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 256, 2, 0), false, false, true);
+
+ tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1));
+ if (tOutput != null)
+ return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 32, 2, 0), false, false, true);
+ } else {
+ if (aInputs[0].getItem() == Items.paper) {
+ if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
+ NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
+ if (tNBT == null || GT_Utility.isStringInvalid(tNBT.getString("title")) || GT_Utility.isStringInvalid(tNBT.getString("author")))
+ return null;
+
+ rRecipe = rRecipe.copy();
+ rRecipe.mCanBeBuffered = false;
+ rRecipe.mOutputs[0].setTagCompound(tNBT);
+ return rRecipe;
+ }
+ if (aInputs[0].getItem() == Items.map) {
+ if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
+ NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
+ if (tNBT == null || !tNBT.hasKey("map_id")) return null;
+
+ rRecipe = rRecipe.copy();
+ rRecipe.mCanBeBuffered = false;
+ rRecipe.mOutputs[0].setItemDamage(tNBT.getShort("map_id"));
+ return rRecipe;
+ }
+ if (ItemList.Paper_Punch_Card_Empty.isStackEqual(aInputs[0], false, true)) {
+ if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null;
+ NBTTagCompound tNBT = aSpecialSlot.getTagCompound();
+ if (tNBT == null || !tNBT.hasKey("GT.PunchCardData")) return null;
+
+ rRecipe = rRecipe.copy();
+ rRecipe.mCanBeBuffered = false;
+ rRecipe.mOutputs[0].setTagCompound(GT_Utility.getNBTContainingString(new NBTTagCompound(), "GT.PunchCardData", tNBT.getString("GT.PunchCardData")));
+ return rRecipe;
+ }
+ }
+ return rRecipe;
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public boolean containsInput(FluidStack aFluid) {
+ return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
+ }
+
+ @Override
+ public boolean containsInput(Fluid aFluid) {
+ return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
+ }
+ }
+
+ public static class GT_Recipe_Map_LargeBoilerFakeFuels extends GT_Recipe_Map {
+
+ public GT_Recipe_Map_LargeBoilerFakeFuels() {
+ super(new HashSet<>(55), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true);
+ GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1);
+ explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler.");
+ addRecipe(explanatoryRecipe);
+ }
+
+ public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) {
+ return addRecipe(recipe, ((double) recipe.mSpecialValue) / 10);
+ }
+
+ public GT_Recipe addDieselRecipe(GT_Recipe recipe) {
+ return addRecipe(recipe, ((double) recipe.mSpecialValue) / 40);
+ }
+
+ public void addSolidRecipes(ItemStack... itemStacks) {
+ for (ItemStack itemStack : itemStacks) {
+ addSolidRecipe(itemStack);
+ }
+ }
+
+ public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) {
+ return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600);
+ }
+
+ private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) {
+ recipe = new GT_Recipe(recipe);
+ //Some recipes will have a burn time like 15.9999999 and % always rounds down
+ double floatErrorCorrection = 0.0001;
+
+ double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection;
+ bronzeBurnTime -= bronzeBurnTime % 0.05;
+ double steelBurnTime = baseBurnTime * 1.5 + floatErrorCorrection;
+ steelBurnTime -= steelBurnTime % 0.05;
+ double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection;
+ titaniumBurnTime -= titaniumBurnTime % 0.05;
+ double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection;
+ tungstensteelBurnTime -= tungstensteelBurnTime % 0.05;
+
+ recipe.setNeiDesc("Burn time in seconds:",
+ String.format("Bronze Boiler: %.4f", bronzeBurnTime),
+ String.format("Steel Boiler: %.4f", steelBurnTime),
+ String.format("Titanium Boiler: %.4f", titaniumBurnTime),
+ String.format("Tungstensteel Boiler: %.4f", tungstensteelBurnTime));
+ return super.addRecipe(recipe);
+ }
+
+ }
+
+ public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map{
+ private static int TOTAL_INPUT_COUNT = 6;
+ private static int OUTPUT_COUNT = 2;
+ private static int FLUID_OUTPUT_COUNT = 4;
+
+ public GT_Recipe_Map_LargeChemicalReactor() {
+ super(new HashSet<>(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true);
+ }
+
+ @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) {
+ aOptimize = false;
+ ArrayList<ItemStack> adjustedInputs = new ArrayList<>();
+ ArrayList<ItemStack> adjustedOutputs = new ArrayList<>();
+ ArrayList<FluidStack> adjustedFluidInputs = new ArrayList<>();
+ ArrayList<FluidStack> adjustedFluidOutputs = new ArrayList<>();
+
+ if (aInputs == null) {
+ aInputs = new ItemStack[0];
+ } else {
+ aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
+ }
+
+ for (ItemStack input : aInputs) {
+ FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input);
+ if (inputFluidContent != null) {
+ inputFluidContent.amount *= input.stackSize;
+ if (inputFluidContent.getFluid().getName().equals("ic2steam")) {
+ inputFluidContent = GT_ModHandler.getSteam(inputFluidContent.amount);
+ }
+ adjustedFluidInputs.add(inputFluidContent);
+ } else {
+ ItemData itemData = GT_OreDictUnificator.getItemData(input);
+ if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty) {
+ continue;
+ } else {
+ if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mPrefix == OrePrefixes.cell) {
+ ItemStack dustStack = itemData.mMaterial.mMaterial.getDust(input.stackSize);
+ if (dustStack != null) {
+ adjustedInputs.add(dustStack);
+ } else {
+ adjustedInputs.add(input);
+ }
+ } else {
+ adjustedInputs.add(input);
+ }
+ }
+ }
+
+ if (aFluidInputs == null) {
+ aFluidInputs = new FluidStack[0];
+ }
+ }
+ Collections.addAll(adjustedFluidInputs, aFluidInputs);
+ aInputs = adjustedInputs.toArray(new ItemStack[0]);
+ aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[0]);
+
+ if (aOutputs == null) {
+ aOutputs = new ItemStack[0];
+ } else {
+ aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
+ }
+
+ for (ItemStack output : aOutputs) {
+ FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output);
+ if (outputFluidContent != null) {
+ outputFluidContent.amount *= output.stackSize;
+ if (outputFluidContent.getFluid().getName().equals("ic2steam")) {
+ outputFluidContent = GT_ModHandler.getSteam(outputFluidContent.amount);
+ }
+ adjustedFluidOutputs.add(outputFluidContent);
+ } else {
+ ItemData itemData = GT_OreDictUnificator.getItemData(output);
+ if (!(itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty)) {
+ adjustedOutputs.add(output);
+ }
+ }
+ }
+ if (aFluidOutputs == null) {
+ aFluidOutputs = new FluidStack[0];
+ }
+ Collections.addAll(adjustedFluidOutputs, aFluidOutputs);
+ aOutputs = adjustedOutputs.toArray(new ItemStack[0]);
+ aFluidOutputs = adjustedFluidOutputs.toArray(new FluidStack[0]);
+
+ return addRecipe(new GT_Recipe_LargeChemicalReactor(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ private static class GT_Recipe_LargeChemicalReactor extends GT_Recipe{
+
+ protected GT_Recipe_LargeChemicalReactor(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
+ }
+
+ @Override
+ public ArrayList<PositionedStack> getInputPositionedStacks() {
+ int itemLimit = Math.min(mInputs.length, TOTAL_INPUT_COUNT);
+ int fluidLimit = Math.min(mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit);
+ int inputlimit = itemLimit + fluidLimit;
+ int j = 0;
+
+ ArrayList<PositionedStack> inputStacks = new ArrayList<>(inputlimit);
+
+ for (int i = 0; i < itemLimit; i++, j++) {
+ if (this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1))) {
+ if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
+ GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
+ else
+ GT_Log.out.println("recipe " + this.toString() + " has errored!");
+
+ new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
+ }
+
+
+ if ((this.mInputs != null && this.mInputs[i] != null) || !GT_Values.allow_broken_recipemap)
+ inputStacks.add(new FixedPositionedStack(this.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
+ else
+ inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
+ }
+
+ for (int i = 0; i < fluidLimit; i++, j++) {
+ if (this.mFluidInputs == null || this.mFluidInputs[i] == null) {
+ if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
+ GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
+ else
+ GT_Log.out.println("recipe " + this.toString() + " has errored!");
+
+ new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
+ }
+
+ if ((this.mFluidInputs != null && this.mFluidInputs[i] != null) || !GT_Values.allow_broken_recipemap)
+ inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
+ }
+
+ return inputStacks;
+ }
+
+ @Override
+ public ArrayList<PositionedStack> getOutputPositionedStacks() {
+ int itemLimit = Math.min(mOutputs.length, OUTPUT_COUNT);
+ int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT);
+ ArrayList<PositionedStack> outputStacks = new ArrayList<>(itemLimit + fluidLimit);
+
+ for (int i = 0; i < itemLimit; i++) {
+ outputStacks.add(new FixedPositionedStack(this.mOutputs[i].copy(), 102 + i * 18, 5));
+ }
+
+ for (int i = 0; i < fluidLimit; i++) {
+ outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), 102 + i * 18, 23));
+ }
+
+ return outputStacks;
+ }
+
+
+ }
+ }
+ public static class GT_Recipe_Map_DistillationTower extends GT_Recipe_Map {
+ private static final int FLUID_OUTPUT_COUNT = 11;
+ private static final int ROW_SIZE = 3;
+
+ public GT_Recipe_Map_DistillationTower() {
+ super(new HashSet<>(110), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, 4, 0, 0, 1, E, 1, E, true, true);
+ }
+
+ @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 addRecipe(new GT_Recipe_DistillationTower(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ @Override
+ public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
+ }
+
+ private static class GT_Recipe_DistillationTower extends GT_Recipe{
+ protected GT_Recipe_DistillationTower(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
+ }
+
+ @Override
+ public ArrayList<PositionedStack> getInputPositionedStacks() {
+ ArrayList<PositionedStack> inputStacks = new ArrayList<>(1);
+
+ if (this.mFluidInputs.length > 0 && this.mFluidInputs[0] != null) {
+ inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[0], true), 48, 52));
+ }
+ return inputStacks;
+ }
+ @Override
+ public ArrayList<PositionedStack> getOutputPositionedStacks() {
+ int fluidLimit = Math.min(mFluidOutputs.length, FLUID_OUTPUT_COUNT);
+ ArrayList<PositionedStack> outputStacks = new ArrayList<>(1 + fluidLimit);
+
+ if (this.mOutputs.length > 0 && this.mOutputs[0] != null) {
+ outputStacks.add(new FixedPositionedStack(this.getOutput(0), 102, 52));
+ }
+
+ for (int i = 0; i < fluidLimit; i++) {
+ int x = 102 + ((i + 1) % ROW_SIZE) * 18;
+ int y = 52 - ((i + 1) / ROW_SIZE) * 18;
+ outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidOutputs[i], true), x, y));
+ }
+ return outputStacks;
+ }
+
+ }
+ }
+
+ public static class GT_Recipe_WithAlt extends GT_Recipe {
+
+ ItemStack[][] mOreDictAlt;
+
+ public GT_Recipe_WithAlt(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt) {
+ super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
+ mOreDictAlt = aAlt;
+ }
+
+
+ public Object getAltRepresentativeInput(int aIndex) {
+ if (aIndex < 0) return null;
+ if (aIndex < mOreDictAlt.length) {
+ if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) {
+ ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length];
+ for (int i = 0; i < mOreDictAlt[aIndex].length; i++) {
+ rStacks[i] = GT_Utility.copy(mOreDictAlt[aIndex][i]);
+ }
+ return rStacks;
+ }
+ }
+ if (aIndex >= mInputs.length) return null;
+ return GT_Utility.copy(mInputs[aIndex]);
+ }
+
+ }
+
+ private static class ReplicatorFakeMap extends GT_Recipe_Map {
+
+ public ReplicatorFakeMap(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);
+ }
+
+ public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ Optional.ofNullable(GT_OreDictUnificator.getAssociation(aOutputs[0]))
+ .map(itemData -> itemData.mMaterial)
+ .map(materialsStack -> materialsStack.mMaterial)
+ .map(materials -> materials.mElement)
+ .map(Element::getMass)
+ .ifPresent(e ->
+ aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e)
+ );
+ return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ }
+
+}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 9e0589c2cb..3b08a1e81f 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -1,2364 +1,2437 @@
-package gregtech.api.util;
-
-import cofh.api.transport.IItemDuct;
-import com.mojang.authlib.GameProfile;
-import cpw.mods.fml.common.FMLCommonHandler;
-import gregtech.api.GregTech_API;
-import gregtech.api.damagesources.GT_DamageSources;
-import gregtech.api.enchants.Enchantment_Radioactivity;
-import gregtech.api.enums.*;
-import gregtech.api.events.BlockScanningEvent;
-import gregtech.api.interfaces.IDebugableBlock;
-import gregtech.api.interfaces.IProjectileItem;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.tileentity.*;
-import gregtech.api.items.GT_EnergyArmor_Item;
-import gregtech.api.items.GT_Generic_Item;
-import gregtech.api.net.GT_Packet_Sound;
-import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.objects.ItemData;
-import gregtech.api.threads.GT_Runnable_Sound;
-import gregtech.common.GT_Proxy;
-import ic2.api.recipe.IRecipeInput;
-import ic2.api.recipe.RecipeInputItemStack;
-import ic2.api.recipe.RecipeInputOreDict;
-import ic2.api.recipe.RecipeOutput;
-import net.minecraft.block.Block;
-import net.minecraft.enchantment.Enchantment;
-import net.minecraft.enchantment.EnchantmentHelper;
-import net.minecraft.entity.*;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.ISidedInventory;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTBase;
-import net.minecraft.nbt.NBTBase.NBTPrimitive;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.nbt.NBTTagString;
-import net.minecraft.network.play.server.S07PacketRespawn;
-import net.minecraft.network.play.server.S1DPacketEntityEffect;
-import net.minecraft.network.play.server.S1FPacketSetExperience;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionEffect;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.tileentity.TileEntityChest;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.MathHelper;
-import net.minecraft.world.World;
-import net.minecraft.world.WorldServer;
-import net.minecraftforge.common.DimensionManager;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.util.BlockSnapshot;
-import net.minecraftforge.common.util.FakePlayer;
-import net.minecraftforge.common.util.FakePlayerFactory;
-import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.event.ForgeEventFactory;
-import net.minecraftforge.event.world.BlockEvent;
-import net.minecraftforge.fluids.*;
-import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
-import java.util.*;
-import java.util.Map.Entry;
-
-import static gregtech.GT_Mod.GT_FML_LOGGER;
-import static gregtech.api.enums.GT_Values.*;
-import static gregtech.common.GT_Proxy.GTPOLLUTION;
-import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
-
-/**
- * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
- * <p/>
- * Just a few Utility Functions I use.
- */
-public class GT_Utility {
- /**
- * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there.
- */
- private static final List<FluidContainerData> sFluidContainerList = new ArrayList<FluidContainerData>();
- private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<GT_ItemStack, FluidContainerData>();
- private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>();
- public static volatile int VERSION = 509;
- public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
- public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>();
- private static int sBookCount = 0;
- public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000");
-
- static {
- GregTech_API.sItemStackMappings.add(sFilledContainerToData);
- GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
- }
-
- public static int safeInt(long number, int margin){
- return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number;
- }
-
- public static int safeInt(long number){
- return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number;
- }
-
- public static Field getPublicField(Object aObject, String aField) {
- Field rField = null;
- try {
- rField = aObject.getClass().getDeclaredField(aField);
- } catch (Throwable e) {/*Do nothing*/}
- return rField;
- }
-
- public static Field getField(Object aObject, String aField) {
- Field rField = null;
- try {
- rField = aObject.getClass().getDeclaredField(aField);
- rField.setAccessible(true);
- } catch (Throwable e) {/*Do nothing*/}
- return rField;
- }
-
- public static Field getField(Class aObject, String aField) {
- Field rField = null;
- try {
- rField = aObject.getDeclaredField(aField);
- rField.setAccessible(true);
- } catch (Throwable e) {/*Do nothing*/}
- return rField;
- }
-
- public static Method getMethod(Class aObject, String aMethod, Class<?>... aParameterTypes) {
- Method rMethod = null;
- try {
- rMethod = aObject.getMethod(aMethod, aParameterTypes);
- rMethod.setAccessible(true);
- } catch (Throwable e) {/*Do nothing*/}
- return rMethod;
- }
-
- public static Method getMethod(Object aObject, String aMethod, Class<?>... aParameterTypes) {
- Method rMethod = null;
- try {
- rMethod = aObject.getClass().getMethod(aMethod, aParameterTypes);
- rMethod.setAccessible(true);
- } catch (Throwable e) {/*Do nothing*/}
- return rMethod;
- }
-
- public static Field getField(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) {
- try {
- Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField);
- if (aPrivate) tField.setAccessible(true);
- return tField;
- } catch (Throwable e) {
- if (aLogErrors) e.printStackTrace(GT_Log.err);
- }
- return null;
- }
-
- public static Object getFieldContent(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) {
- try {
- Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField);
- if (aPrivate) tField.setAccessible(true);
- return tField.get(aObject instanceof Class || aObject instanceof String ? null : aObject);
- } catch (Throwable e) {
- if (aLogErrors) e.printStackTrace(GT_Log.err);
- }
- return null;
- }
-
- public static Object callPublicMethod(Object aObject, String aMethod, Object... aParameters) {
- return callMethod(aObject, aMethod, false, false, true, aParameters);
- }
-
- public static Object callPrivateMethod(Object aObject, String aMethod, Object... aParameters) {
- return callMethod(aObject, aMethod, true, false, true, aParameters);
- }
-
- public static Object callMethod(Object aObject, String aMethod, boolean aPrivate, boolean aUseUpperCasedDataTypes, boolean aLogErrors, Object... aParameters) {
- try {
- Class<?>[] tParameterTypes = new Class<?>[aParameters.length];
- for (byte i = 0; i < aParameters.length; i++) {
- if (aParameters[i] instanceof Class) {
- tParameterTypes[i] = (Class) aParameters[i];
- aParameters[i] = null;
- } else {
- tParameterTypes[i] = aParameters[i].getClass();
- }
- if (!aUseUpperCasedDataTypes) {
- if (tParameterTypes[i] == Boolean.class) tParameterTypes[i] = boolean.class;
- else if (tParameterTypes[i] == Byte.class) tParameterTypes[i] = byte.class;
- else if (tParameterTypes[i] == Short.class) tParameterTypes[i] = short.class;
- else if (tParameterTypes[i] == Integer.class) tParameterTypes[i] = int.class;
- else if (tParameterTypes[i] == Long.class) tParameterTypes[i] = long.class;
- else if (tParameterTypes[i] == Float.class) tParameterTypes[i] = float.class;
- else if (tParameterTypes[i] == Double.class) tParameterTypes[i] = double.class;
- }
- }
-
- Method tMethod = (aObject instanceof Class) ? ((Class) aObject).getMethod(aMethod, tParameterTypes) : aObject.getClass().getMethod(aMethod, tParameterTypes);
- if (aPrivate) tMethod.setAccessible(true);
- return tMethod.invoke(aObject, aParameters);
- } catch (Throwable e) {
- if (aLogErrors) e.printStackTrace(GT_Log.err);
- }
- return null;
- }
-
- public static Object callConstructor(String aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) {
- if (aConstructorIndex < 0) {
- try {
- for (Constructor tConstructor : Class.forName(aClass).getConstructors()) {
- try {
- return tConstructor.newInstance(aParameters);
- } catch (Throwable e) {/*Do nothing*/}
- }
- } catch (Throwable e) {
- if (aLogErrors) e.printStackTrace(GT_Log.err);
- }
- } else {
- try {
- return Class.forName(aClass).getConstructors()[aConstructorIndex].newInstance(aParameters);
- } catch (Throwable e) {
- if (aLogErrors) e.printStackTrace(GT_Log.err);
- }
- }
- return aReplacementObject;
- }
-
- public static String capitalizeString(String aString) {
- if (aString != null && aString.length() > 0)
- return aString.substring(0, 1).toUpperCase() + aString.substring(1);
- return E;
- }
-
- public static boolean getPotion(EntityLivingBase aPlayer, int aPotionIndex) {
- try {
- Field tPotionHashmap = null;
-
- Field[] var3 = EntityLiving.class.getDeclaredFields();
- int var4 = var3.length;
-
- for (int var5 = 0; var5 < var4; ++var5) {
- Field var6 = var3[var5];
- if (var6.getType() == HashMap.class) {
- tPotionHashmap = var6;
- tPotionHashmap.setAccessible(true);
- break;
- }
- }
-
- if (tPotionHashmap != null)
- return ((HashMap) tPotionHashmap.get(aPlayer)).get(Integer.valueOf(aPotionIndex)) != null;
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- return false;
- }
-
- public static String getClassName(Object aObject) {
- if (aObject == null) return "null";
- return aObject.getClass().getName().substring(aObject.getClass().getName().lastIndexOf(".") + 1);
- }
-
- public static void removePotion(EntityLivingBase aPlayer, int aPotionIndex) {
- try {
- Field tPotionHashmap = null;
-
- Field[] var3 = EntityLiving.class.getDeclaredFields();
- int var4 = var3.length;
-
- for (int var5 = 0; var5 < var4; ++var5) {
- Field var6 = var3[var5];
- if (var6.getType() == HashMap.class) {
- tPotionHashmap = var6;
- tPotionHashmap.setAccessible(true);
- break;
- }
- }
-
- if (tPotionHashmap != null) ((HashMap) tPotionHashmap.get(aPlayer)).remove(Integer.valueOf(aPotionIndex));
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- }
-
- public static boolean getFullInvisibility(EntityPlayer aPlayer) {
- try {
- if (aPlayer.isInvisible()) {
- for (int i = 0; i < 4; i++) {
- if (aPlayer.inventory.armorInventory[i] != null) {
- if (aPlayer.inventory.armorInventory[i].getItem() instanceof GT_EnergyArmor_Item) {
- if ((((GT_EnergyArmor_Item) aPlayer.inventory.armorInventory[i].getItem()).mSpecials & 512) != 0) {
- if (GT_ModHandler.canUseElectricItem(aPlayer.inventory.armorInventory[i], 10000)) {
- return true;
- }
- }
- }
- }
- }
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- return false;
- }
-
- public static ItemStack suckOneItemStackAt(World aWorld, double aX, double aY, double aZ, double aL, double aH, double aW) {
- for (EntityItem tItem : (ArrayList<EntityItem>) aWorld.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + aL, aY + aH, aZ + aW))) {
- if (!tItem.isDead) {
- aWorld.removeEntity(tItem);
- tItem.setDead();
- return tItem.getEntityItem();
- }
- }
- return null;
- }
-
- public static byte getOppositeSide(int aSide) {
- return (byte) ForgeDirection.getOrientation(aSide).getOpposite().ordinal();
- }
-
- public static byte getTier(long l) {
- byte i = -1;
- while (++i < V.length) if (l <= V[i]) return i;
- return i;
- }
-
- public static void sendChatToPlayer(EntityPlayer aPlayer, String aChatMessage) {
- if (aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
- aPlayer.addChatComponentMessage(new ChatComponentText(aChatMessage));
- }
- }
-
- public static void checkAvailabilities() {
- if (CHECK_ALL) {
- try {
- Class tClass = IItemDuct.class;
- tClass.getCanonicalName();
- TE_CHECK = true;
- } catch (Throwable e) {/**/}
- try {
- Class tClass = buildcraft.api.transport.IPipeTile.class;
- tClass.getCanonicalName();
- BC_CHECK = true;
- } catch (Throwable e) {/**/}
- try {
- Class tClass = cofh.api.energy.IEnergyReceiver.class;
- tClass.getCanonicalName();
- RF_CHECK = true;
- } catch (Throwable e) {/**/}
- CHECK_ALL = false;
- }
- }
-
- public static boolean isConnectableNonInventoryPipe(Object aTileEntity, int aSide) {
- if (aTileEntity == null) return false;
- checkAvailabilities();
- if (TE_CHECK && aTileEntity instanceof IItemDuct) return true;
- if (BC_CHECK && aTileEntity instanceof buildcraft.api.transport.IPipeTile)
- return ((buildcraft.api.transport.IPipeTile) aTileEntity).isPipeConnected(ForgeDirection.getOrientation(aSide));
- if (GregTech_API.mTranslocator && aTileEntity instanceof codechicken.translocator.TileItemTranslocator) return true;
-
- return false;
- }
- /**
- * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed.
- *
- * @return the Amount of moved Items
- */
- public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
- return moveStackIntoPipe(aTileEntity1, aTileEntity2, aGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
- }
-
- /**
- * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed.
- *
- * @return the Amount of moved Items
- */
- public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean dropItem) {
- if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce)
- return 0;
- if (aTileEntity2 != null) {
- checkAvailabilities();
- if (TE_CHECK && aTileEntity2 instanceof IItemDuct) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
- ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
- byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize));
- if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) {
- //((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F);
- aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
- aTileEntity1.markDirty();
- return tMovedItemCount;
- }
- }
- }
- }
- }
- return 0;
- }
- if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
- byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copy(tStack), false, ForgeDirection.getOrientation(aPutTo));
- if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) {
- tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo)));
- aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
- aTileEntity1.markDirty();
- return tMovedItemCount;
- }
- }
- }
- }
- }
- return 0;
- }
- }
-
- ForgeDirection tDirection = ForgeDirection.getOrientation(aGrabFrom);
- if (aTileEntity1 instanceof TileEntity && tDirection != ForgeDirection.UNKNOWN && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) {
- int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ;
- if (!hasBlockHitBox(((TileEntity) aTileEntity1).getWorldObj(), tX, tY, tZ) && dropItem) {
- for (int i = 0; i < aGrabSlots.length; i++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
- if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
- ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
- EntityItem tEntity = new EntityItem(((TileEntity) aTileEntity1).getWorldObj(), tX + 0.5, tY + 0.5, tZ + 0.5, tStack);
- tEntity.motionX = tEntity.motionY = tEntity.motionZ = 0;
- ((TileEntity) aTileEntity1).getWorldObj().spawnEntityInWorld(tEntity);
- aTileEntity1.decrStackSize(aGrabSlots[i], tStack.stackSize);
- aTileEntity1.markDirty();
- return (byte) tStack.stackSize;
- }
- }
- }
- }
- }
- }
- return 0;
- }
-
- /**
- * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed. (useful for internal Inventory Operations)
- *
- * @return the Amount of moved Items
- */
- public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
- if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce)
- return 0;
-
- ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), tStack3 = null;
- if (tStack1 != null) {
- if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0;
- tStack3 = copy(tStack1);
- aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, Math.min(tStack3.getMaxStackSize(), Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), aTileEntity2.getInventoryStackLimit())));
- tStack3.stackSize = Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize));
- if (tStack3.stackSize > aMaxMoveAtOnce) tStack3.stackSize = aMaxMoveAtOnce;
- if (tStack3.stackSize + (tStack2 == null ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(), aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) {
- tStack3 = aTileEntity1.decrStackSize(aGrabFrom, tStack3.stackSize);
- aTileEntity1.markDirty();
- if (tStack3 != null) {
- if (tStack2 == null) {
- aTileEntity2.setInventorySlotContents(aPutTo, copy(tStack3));
- aTileEntity2.markDirty();
- } else {
- tStack2.stackSize += tStack3.stackSize;
- aTileEntity2.markDirty();
- }
- return (byte) tStack3.stackSize;
- }
- }
- }
- return 0;
- }
-
- public static boolean isAllowedToTakeFromSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack) {
- if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) {
- return isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 0, aStack)
- || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 1, aStack)
- || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 2, aStack)
- || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 3, aStack)
- || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 4, aStack)
- || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 5, aStack);
- }
- if (aTileEntity instanceof ISidedInventory)
- return ((ISidedInventory) aTileEntity).canExtractItem(aSlot, aStack, aSide);
- return true;
- }
-
- public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack, byte aMaxStackSize) {
- ItemStack tStack = aTileEntity.getStackInSlot(aSlot);
- if (tStack != null && (!areStacksEqual(tStack, aStack) || tStack.stackSize >= tStack.getMaxStackSize()))
- return false;
- if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) {
- return isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 0, aStack, aMaxStackSize)
- || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 1, aStack, aMaxStackSize)
- || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 2, aStack, aMaxStackSize)
- || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 3, aStack, aMaxStackSize)
- || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 4, aStack, aMaxStackSize)
- || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 5, aStack, aMaxStackSize);
- }
- if (aTileEntity instanceof ISidedInventory && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, aSide))
- return false;
- return aSlot < aTileEntity.getSizeInventory() && aTileEntity.isItemValidForSlot(aSlot, aStack);
- }
-
- /**
- * Moves Stack from Inv-Side to Inv-Side.
- *
- * @return the Amount of moved Items
- */
- public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
- if (aTileEntity1 instanceof IInventory)
- return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
- return 0;
- }
-
- /**
- * This is only because I needed an additional Parameter for the Double Chest Check.
- */
- private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) {
- if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
- return 0;
-
- int[] tGrabSlots = null;
- if (aTileEntity1 instanceof ISidedInventory)
- tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);
- if (tGrabSlots == null) {
- tGrabSlots = new int[aTileEntity1.getSizeInventory()];
- for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
- }
-
- if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) {
- int[] tPutSlots = null;
- if (aTileEntity2 instanceof ISidedInventory)
- tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo);
-
- if (tPutSlots == null) {
- tPutSlots = new int[((IInventory) aTileEntity2).getSizeInventory()];
- for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i;
- }
-
- for (int i = 0; i < tGrabSlots.length; i++) {
- byte tMovedItemCount = 0;
- for (int j = 0; j < tPutSlots.length; j++) {
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) {
- if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
- tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
- if (tMovedItemCount >= aMaxMoveAtOnce) {
- return tMovedItemCount;
-
- }
- }
- }
- }
- }
- if (tMovedItemCount > 0) return tMovedItemCount;
- }
-
- if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) {
- TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1;
- if (tTileEntity1.adjacentChestChecked) {
- byte tAmount = 0;
- if (tTileEntity1.adjacentChestXNeg != null) {
- tAmount = moveOneItemStack(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity1.adjacentChestZNeg != null) {
- tAmount = moveOneItemStack(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity1.adjacentChestXPos != null) {
- tAmount = moveOneItemStack(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity1.adjacentChestZPos != null) {
- tAmount = moveOneItemStack(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- }
- if (tAmount != 0) return tAmount;
- }
- }
- if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) {
- TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2;
- if (tTileEntity2.adjacentChestChecked) {
- byte tAmount = 0;
- if (tTileEntity2.adjacentChestXNeg != null) {
- tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity2.adjacentChestZNeg != null) {
- tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity2.adjacentChestXPos != null) {
- tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- } else if (tTileEntity2.adjacentChestZPos != null) {
- tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
- }
- if (tAmount != 0) return tAmount;
- }
- }
- }
-
- return moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests);
- }
-
- /**
- * Moves Stack from Inv-Side to Inv-Slot.
- *
- * @return the Amount of moved Items
- */
- public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
- if (aTileEntity1 == null || !(aTileEntity1 instanceof IInventory) || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
- return 0;
-
- int[] tGrabSlots = null;
- if (aTileEntity1 instanceof ISidedInventory)
- tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);
- if (tGrabSlots == null) {
- tGrabSlots = new int[((IInventory) aTileEntity1).getSizeInventory()];
- for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
- }
-
- if (aTileEntity2 instanceof IInventory) {
- for (int i = 0; i < tGrabSlots.length; i++) {
- if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) {
- if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, aPutTo, (byte) 6, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
- byte tMovedItemCount = moveStackFromSlotAToSlotB((IInventory) aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
- if (tMovedItemCount > 0) return tMovedItemCount;
- }
- }
- }
- }
- }
-
- moveStackIntoPipe(((IInventory) aTileEntity1), aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
- return 0;
- }
-
- /**
- * Moves Stack from Inv-Slot to Inv-Slot.
- *
- * @return the Amount of moved Items
- */
- public static byte moveFromSlotToSlot(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
- if (aTileEntity1 == null || aTileEntity2 == null || aGrabFrom < 0 || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
- return 0;
- if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabFrom), true, aInvertFilter)) {
- if (isAllowedToTakeFromSlot(aTileEntity1, aGrabFrom, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom))) {
- if (isAllowedToPutIntoSlot(aTileEntity2, aPutTo, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) {
- byte tMovedItemCount = moveStackFromSlotAToSlotB(aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
- if (tMovedItemCount > 0) return tMovedItemCount;
- }
- }
- }
- return 0;
- }
-
- public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) {
- if (aStack == null || aStack.stackSize < 1) return false;
- if (aList == null) return aTIfListEmpty;
- while (aList.contains(null)) aList.remove(null);
- if (aList.size() < 1) return aTIfListEmpty;
- Iterator<ItemStack> tIterator = aList.iterator();
- ItemStack tStack = null;
- while (tIterator.hasNext())
- if ((tStack = tIterator.next()) != null && areStacksEqual(aStack, tStack)) return !aInvertFilter;
- return aInvertFilter;
- }
-
- public static boolean areStacksOrToolsEqual(ItemStack aStack1, ItemStack aStack2) {
- if (aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem()) {
- if (aStack1.getItem().isDamageable()) return true;
- return ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound())) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
- }
- return false;
- }
-
- public static boolean areFluidsEqual(FluidStack aFluid1, FluidStack aFluid2) {
- return areFluidsEqual(aFluid1, aFluid2, false);
- }
-
- public static boolean areFluidsEqual(FluidStack aFluid1, FluidStack aFluid2, boolean aIgnoreNBT) {
- return aFluid1 != null && aFluid2 != null && aFluid1.getFluid() == aFluid2.getFluid() && (aIgnoreNBT || ((aFluid1.tag == null) == (aFluid2.tag == null)) && (aFluid1.tag == null || aFluid1.tag.equals(aFluid2.tag)));
- }
-
- public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2) {
- return areStacksEqual(aStack1, aStack2, false);
- }
-
- public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) {
- return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem() && (aIgnoreNBT || ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound()))) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
- }
-
- public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2) {
- return areUnificationsEqual(aStack1, aStack2, false);
- }
-
- public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) {
- return areStacksEqual(GT_OreDictUnificator.get(aStack1), GT_OreDictUnificator.get(aStack2), aIgnoreNBT);
- }
-
- public static String getFluidName(Fluid aFluid, boolean aLocalized) {
- if (aFluid == null) return E;
- String rName = aLocalized ? aFluid.getLocalizedName(new FluidStack(aFluid, 0)) : aFluid.getUnlocalizedName();
- if (rName.contains("fluid.") || rName.contains("tile."))
- return capitalizeString(rName.replaceAll("fluid.", E).replaceAll("tile.", E));
- return rName;
- }
-
- public static String getFluidName(FluidStack aFluid, boolean aLocalized) {
- if (aFluid == null) return E;
- return getFluidName(aFluid.getFluid(), aLocalized);
- }
-
- public static void reInit() {
- sFilledContainerToData.clear();
- sEmptyContainerToFluidToData.clear();
- for (FluidContainerData tData : sFluidContainerList) {
- sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData);
- Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer));
- if (tFluidToContainer == null) {
- sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
- GregTech_API.sFluidMappings.add(tFluidToContainer);
- }
- tFluidToContainer.put(tData.fluid.getFluid(), tData);
- }
- }
-
- public static void addFluidContainerData(FluidContainerData aData) {
- sFluidContainerList.add(aData);
- sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData);
- Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer));
- if (tFluidToContainer == null) {
- sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
- GregTech_API.sFluidMappings.add(tFluidToContainer);
- }
- tFluidToContainer.put(aData.fluid.getFluid(), aData);
- }
-
- public static ItemStack fillFluidContainer(FluidStack aFluid, ItemStack aStack, boolean aRemoveFluidDirectly, boolean aCheckIFluidContainerItems) {
- if (isStackInvalid(aStack) || aFluid == null) return null;
- if (GT_ModHandler.isWater(aFluid) && ItemList.Bottle_Empty.isStackEqual(aStack)) {
- if (aFluid.amount >= 250) {
- if (aRemoveFluidDirectly) aFluid.amount -= 250;
- return new ItemStack(Items.potionitem, 1, 0);
- }
- return null;
- }
- if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getFluid(aStack) == null && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) <= aFluid.amount) {
- if (aRemoveFluidDirectly)
- aFluid.amount -= ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true);
- else
- ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true);
- return aStack;
- }
- Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aStack));
- if (tFluidToContainer == null) return null;
- FluidContainerData tData = tFluidToContainer.get(aFluid.getFluid());
- if (tData == null || tData.fluid.amount > aFluid.amount) return null;
- if (aRemoveFluidDirectly) aFluid.amount -= tData.fluid.amount;
- return copyAmount(1, tData.filledContainer);
- }
-
- public static ItemStack getFluidDisplayStack(Fluid aFluid) {
- return aFluid == null ? null : getFluidDisplayStack(new FluidStack(aFluid, 0), false);
- }
-
- public static ItemStack getFluidDisplayStack(FluidStack aFluid, boolean aUseStackSize) {
- if (aFluid == null || aFluid.getFluid() == null) return null;
- int tmp = 0;
- try {
- tmp = aFluid.getFluid().getID();
- } catch (Exception e) {
- System.err.println(e);
- }
- ItemStack rStack = ItemList.Display_Fluid.getWithDamage(aUseStackSize ? aFluid.amount / 1000 : 1, tmp);
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setLong("mFluidDisplayAmount", aFluid.amount);
- tNBT.setLong("mFluidDisplayHeat", aFluid.getFluid().getTemperature(aFluid));
- tNBT.setBoolean("mFluidState", aFluid.getFluid().isGaseous(aFluid));
- rStack.setTagCompound(tNBT);
- return rStack;
- }
-
- public static boolean containsFluid(ItemStack aStack, FluidStack aFluid, boolean aCheckIFluidContainerItems) {
- if (isStackInvalid(aStack) || aFluid == null) return false;
- if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)
- return aFluid.isFluidEqual(((IFluidContainerItem) aStack.getItem()).getFluid(aStack = copyAmount(1, aStack)));
- FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
- return tData == null ? false : tData.fluid.isFluidEqual(aFluid);
- }
-
- public static FluidStack getFluidForFilledItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
- if (isStackInvalid(aStack)) return null;
- if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)
- return ((IFluidContainerItem) aStack.getItem()).drain(copyAmount(1, aStack), Integer.MAX_VALUE, true);
- FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
- return tData == null ? null : tData.fluid.copy();
- }
-
- public static ItemStack getContainerForFilledItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
- if (isStackInvalid(aStack)) return null;
- FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
- if (tData != null) return copyAmount(1, tData.emptyContainer);
- if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) {
- ((IFluidContainerItem) aStack.getItem()).drain(aStack = copyAmount(1, aStack), Integer.MAX_VALUE, true);
- return aStack;
- }
- return null;
- }
-
- public static ItemStack getContainerItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
- if (isStackInvalid(aStack)) return null;
- if (aStack.getItem().hasContainerItem(aStack)) return aStack.getItem().getContainerItem(aStack);
- /** These are all special Cases, in which it is intended to have only GT Blocks outputting those Container Items */
- if (ItemList.Cell_Empty.isStackEqual(aStack, false, true)) return null;
- if (ItemList.IC2_Fuel_Can_Filled.isStackEqual(aStack, false, true)) return ItemList.IC2_Fuel_Can_Empty.get(1);
- if (aStack.getItem() == Items.potionitem || aStack.getItem() == Items.experience_bottle || ItemList.TF_Vial_FieryBlood.isStackEqual(aStack) || ItemList.TF_Vial_FieryTears.isStackEqual(aStack))
- return ItemList.Bottle_Empty.get(1);
-
- if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) {
- ItemStack tStack = copyAmount(1, aStack);
- ((IFluidContainerItem) aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true);
- if (!areStacksEqual(aStack, tStack)) return tStack;
- return null;
- }
-
- int tCapsuleCount = GT_ModHandler.getCapsuleCellContainerCount(aStack);
- if (tCapsuleCount > 0) return ItemList.Cell_Empty.get(tCapsuleCount);
-
- if (ItemList.IC2_ForgeHammer.isStackEqual(aStack) || ItemList.IC2_WireCutter.isStackEqual(aStack))
- return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack);
- return null;
- }
-
- public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){
- if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false;
- boolean rReturn = false;
- Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator();
- aOutput = GT_OreDictUnificator.get(aOutput);
- while (tIterator.hasNext()) {
- Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> tEntry = tIterator.next();
- if (aInput == null || tEntry.getKey().matches(aContainer, aInput)) {
- List<ItemStack> tList = tEntry.getValue().items;
- if (tList != null) for (ItemStack tOutput : tList)
- if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) {
- tIterator.remove();
- rReturn = true;
- break;
- }
- }
- }
- return rReturn;
- }
-
- public static synchronized boolean removeSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, ItemStack aOutput) {
- if ((isStackInvalid(aInput) && isStackInvalid(aOutput)) || aRecipeList == null) return false;
- boolean rReturn = false;
- Iterator<Map.Entry<IRecipeInput, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator();
- aOutput = GT_OreDictUnificator.get(aOutput);
- while (tIterator.hasNext()) {
- Map.Entry<IRecipeInput, RecipeOutput> tEntry = tIterator.next();
- if (aInput == null || tEntry.getKey().matches(aInput)) {
- List<ItemStack> tList = tEntry.getValue().items;
- if (tList != null) for (ItemStack tOutput : tList)
- if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) {
- tIterator.remove();
- rReturn = true;
- break;
- }
- }
- }
- return rReturn;
- }
-
- public static boolean addSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, NBTTagCompound aNBT, Object... aOutput) {
- if (isStackInvalid(aInput) || aOutput.length == 0 || aRecipeList == null) return false;
- ItemData tOreName = GT_OreDictUnificator.getAssociation(aInput);
- for (int i = 0; i < aOutput.length; i++) {
- if (aOutput[i] == null) {
- GT_FML_LOGGER.info("EmptyIC2Output!" + aInput.getUnlocalizedName());
- return false;
- }
- }
- ItemStack[] tStack = GT_OreDictUnificator.getStackArray(true, aOutput);
- if(tStack==null||(tStack.length>0&&GT_Utility.areStacksEqual(aInput, tStack[0])))return false;
- if (tOreName != null) {
- if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false;
- aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack));
- } else {
- aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack));
- }
- return true;
- }
-
- public static ItemStack getWrittenBook(String aMapping, ItemStack aStackToPutNBT) {
- if (isStringInvalid(aMapping)) return null;
- ItemStack rStack = GregTech_API.sBookList.get(aMapping);
- if (rStack == null) return aStackToPutNBT;
- if (aStackToPutNBT != null) {
- aStackToPutNBT.setTagCompound(rStack.getTagCompound());
- return aStackToPutNBT;
- }
- return copyAmount(1, rStack);
- }
-
- public static ItemStack getWrittenBook(String aMapping, String aTitle, String aAuthor, String... aPages) {
- if (isStringInvalid(aMapping)) return null;
- ItemStack rStack = GregTech_API.sBookList.get(aMapping);
- if (rStack != null) return copyAmount(1, rStack);
- if (isStringInvalid(aTitle) || isStringInvalid(aAuthor) || aPages.length <= 0) return null;
- sBookCount++;
- rStack = new ItemStack(Items.written_book, 1);
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setString("title", GT_LanguageManager.addStringLocalization("Book." + aTitle + ".Name", aTitle));
- tNBT.setString("author", aAuthor);
- NBTTagList tNBTList = new NBTTagList();
- for (byte i = 0; i < aPages.length; i++) {
- aPages[i] = GT_LanguageManager.addStringLocalization("Book." + aTitle + ".Page" + ((i < 10) ? "0" + i : i), aPages[i]);
- if (i < 48) {
- if (aPages[i].length() < 256)
- tNBTList.appendTag(new NBTTagString(aPages[i]));
- else
- GT_Log.err.println("WARNING: String for written Book too long! -> " + aPages[i]);
- } else {
- GT_Log.err.println("WARNING: Too much Pages for written Book! -> " + aTitle);
- break;
- }
- }
- tNBTList.appendTag(new NBTTagString("Credits to " + aAuthor + " for writing this Book. This was Book Nr. " + sBookCount + " at its creation. Gotta get 'em all!"));
- tNBT.setTag("pages", tNBTList);
- rStack.setTagCompound(tNBT);
- GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + "' - Author: '" + aAuthor + "'");
- GregTech_API.sBookList.put(aMapping, rStack);
- return copy(rStack);
- }
-
- public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength) {
- return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer());
- }
-
- public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) {
- if (aEntity == null) return false;
- return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ);
- }
-
- public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) {
- return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ);
- }
-
- public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) {
- if (isStringInvalid(aSoundName) || !FMLCommonHandler.instance().getEffectiveSide().isClient() || GT.getThePlayer() == null || !GT.getThePlayer().worldObj.isRemote)
- return false;
- if (GregTech_API.sMultiThreadedSounds)
- new Thread(new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation), "Sound Effect").start();
- else
- new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation).run();
- return true;
- }
-
- public static boolean sendSoundToPlayers(World aWorld, String aSoundName, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) {
- if (isStringInvalid(aSoundName) || aWorld == null || aWorld.isRemote) return false;
- NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(aSoundName, aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ);
- return true;
- }
-
- public static int stackToInt(ItemStack aStack) {
- if (isStackInvalid(aStack)) return 0;
- return Item.getIdFromItem(aStack.getItem()) | (Items.feather.getDamage(aStack) << 16);
- }
-
- public static int stackToWildcard(ItemStack aStack) {
- if (isStackInvalid(aStack)) return 0;
- return Item.getIdFromItem(aStack.getItem()) | (W << 16);
- }
-
- public static ItemStack intToStack(int aStack) {
- int tID = aStack & (~0 >>> 16), tMeta = aStack >>> 16;
- Item tItem = Item.getItemById(tID);
- if (tItem != null) return new ItemStack(tItem, 1, tMeta);
- return null;
- }
-
- public static Integer[] stacksToIntegerArray(ItemStack... aStacks) {
- Integer[] rArray = new Integer[aStacks.length];
- for (int i = 0; i < rArray.length; i++) {
- rArray[i] = stackToInt(aStacks[i]);
- }
- return rArray;
- }
-
- public static int[] stacksToIntArray(ItemStack... aStacks) {
- int[] rArray = new int[aStacks.length];
- for (int i = 0; i < rArray.length; i++) {
- rArray[i] = stackToInt(aStacks[i]);
- }
- return rArray;
- }
-
- public static boolean arrayContains(Object aObject, Object... aObjects) {
- return listContains(aObject, Arrays.asList(aObjects));
- }
-
- public static boolean listContains(Object aObject, Collection aObjects) {
- if (aObjects == null) return false;
- return aObjects.contains(aObject);
- }
-
- public static <T> boolean arrayContainsNonNull(T... aArray) {
- if (aArray != null) for (Object tObject : aArray) if (tObject != null) return true;
- return false;
- }
-
- public static <T> ArrayList<T> getArrayListWithoutNulls(T... aArray) {
- if (aArray == null) return new ArrayList<T>();
- ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
- for (int i = 0; i < rList.size(); i++) if (rList.get(i) == null) rList.remove(i--);
- return rList;
- }
-
- public static <T> ArrayList<T> getArrayListWithoutTrailingNulls(T... aArray) {
- if (aArray == null) return new ArrayList<T>();
- ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
- for (int i = rList.size() - 1; i >= 0 && rList.get(i) == null; ) rList.remove(i--);
- return rList;
- }
-
- public static Block getBlock(Object aBlock) {
- return (Block) aBlock;
- }
-
- public static Block getBlockFromStack(ItemStack itemStack) {
- if (isStackInvalid(itemStack)) return Blocks.air;
- return getBlockFromItem(itemStack.getItem());
- }
-
- public static Block getBlockFromItem(Item item) {
- return Block.getBlockFromItem(item);
- }
-
- public static boolean isBlockValid(Object aBlock) {
- return (aBlock instanceof Block);
- }
-
- public static boolean isBlockInvalid(Object aBlock) {
- return aBlock == null || !(aBlock instanceof Block);
- }
-
- public static boolean isStringValid(Object aString) {
- return aString != null && !aString.toString().isEmpty();
- }
-
- public static boolean isStringInvalid(Object aString) {
- return aString == null || aString.toString().isEmpty();
- }
-
- public static boolean isStackValid(Object aStack) {
- return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
- }
-
- public static boolean isStackInvalid(Object aStack) {
- return aStack == null || !(aStack instanceof ItemStack) || ((ItemStack) aStack).getItem() == null || ((ItemStack) aStack).stackSize < 0;
- }
-
- public static boolean isDebugItem(ItemStack aStack) {
- return /*ItemList.Armor_Cheat.isStackEqual(aStack, T, T) || */areStacksEqual(GT_ModHandler.getIC2Item("debug", 1), aStack, true);
- }
-
- public static ItemStack updateItemStack(ItemStack aStack) {
- if (isStackValid(aStack) && aStack.getItem() instanceof GT_Generic_Item)
- ((GT_Generic_Item) aStack.getItem()).isItemStackUsable(aStack);
- return aStack;
- }
-
- public static boolean isOpaqueBlock(World aWorld, int aX, int aY, int aZ) {
- return aWorld.getBlock(aX, aY, aZ).isOpaqueCube();
- }
-
- public static boolean isBlockAir(World aWorld, int aX, int aY, int aZ) {
- return aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ);
- }
-
- public static boolean hasBlockHitBox(World aWorld, int aX, int aY, int aZ) {
- return aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null;
- }
-
- public static void setCoordsOnFire(World aWorld, int aX, int aY, int aZ, boolean aReplaceCenter) {
- if (aReplaceCenter)
- if (aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) == null)
- aWorld.setBlock(aX, aY, aZ, Blocks.fire);
- if (aWorld.getBlock(aX + 1, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX + 1, aY, aZ) == null)
- aWorld.setBlock(aX + 1, aY, aZ, Blocks.fire);
- if (aWorld.getBlock(aX - 1, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX - 1, aY, aZ) == null)
- aWorld.setBlock(aX - 1, aY, aZ, Blocks.fire);
- if (aWorld.getBlock(aX, aY + 1, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY + 1, aZ) == null)
- aWorld.setBlock(aX, aY + 1, aZ, Blocks.fire);
- if (aWorld.getBlock(aX, aY - 1, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY - 1, aZ) == null)
- aWorld.setBlock(aX, aY - 1, aZ, Blocks.fire);
- if (aWorld.getBlock(aX, aY, aZ + 1).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ + 1) == null)
- aWorld.setBlock(aX, aY, aZ + 1, Blocks.fire);
- if (aWorld.getBlock(aX, aY, aZ - 1).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ - 1) == null)
- aWorld.setBlock(aX, aY, aZ - 1, Blocks.fire);
- }
-
- public static ItemStack getProjectile(SubTag aProjectileType, IInventory aInventory) {
- if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) {
- ItemStack rStack = aInventory.getStackInSlot(i);
- if (isStackValid(rStack) && rStack.getItem() instanceof IProjectileItem && ((IProjectileItem) rStack.getItem()).hasProjectile(aProjectileType, rStack))
- return updateItemStack(rStack);
- }
- return null;
- }
-
- public static void removeNullStacksFromInventory(IInventory aInventory) {
- if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) {
- ItemStack tStack = aInventory.getStackInSlot(i);
- if (tStack != null && (tStack.stackSize == 0 || tStack.getItem() == null))
- aInventory.setInventorySlotContents(i, null);
- }
- }
-
- /**
- * Initializes a new texture page.
- */
- public static boolean addTexturePage(byte page){
- if(Textures.BlockIcons.casingTexturePages[page]==null){
- Textures.BlockIcons.casingTexturePages[page]=new ITexture[128];
- return true;
- }
- return false;
- }
-
- /**
- * Converts a Number to a String
- */
- public static String parseNumberToString(int aNumber) {
- boolean temp = true, negative = false;
-
- if (aNumber < 0) {
- aNumber *= -1;
- negative = true;
- }
-
- StringBuilder tStringB = new StringBuilder();
- for (int i = 1000000000; i > 0; i /= 10) {
- int tDigit = (aNumber / i) % 10;
- if (temp && tDigit != 0) temp = false;
- if (!temp) {
- tStringB.append(tDigit);
- if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(",");
- }
- }
-
- String tString = tStringB.toString();
-
- if (tString.equals(E)) tString = "0";
-
- return negative ? "-" + tString : tString;
- }
-
- public static NBTTagCompound getNBTContainingBoolean(NBTTagCompound aNBT, Object aTag, boolean aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setBoolean(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingByte(NBTTagCompound aNBT, Object aTag, byte aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setByte(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingShort(NBTTagCompound aNBT, Object aTag, short aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setShort(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingInteger(NBTTagCompound aNBT, Object aTag, int aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setInteger(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingFloat(NBTTagCompound aNBT, Object aTag, float aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setFloat(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingDouble(NBTTagCompound aNBT, Object aTag, double aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- aNBT.setDouble(aTag.toString(), aValue);
- return aNBT;
- }
-
- public static NBTTagCompound getNBTContainingString(NBTTagCompound aNBT, Object aTag, Object aValue) {
- if (aNBT == null) aNBT = new NBTTagCompound();
- if (aValue == null) return aNBT;
- aNBT.setString(aTag.toString(), aValue.toString());
- return aNBT;
- }
-
- public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sFrostHazmatList)) return false;
- return true;
- }
-
- public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sHeatHazmatList)) return false;
- return true;
- }
-
- public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sBioHazmatList)) return false;
- return true;
- }
-
- public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sRadioHazmatList)) return false;
- return true;
- }
-
- public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sElectroHazmatList)) return false;
- return true;
- }
-
- public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sGasHazmatList)) return false;
- return true;
- }
-
- public static float getHeatDamageFromItem(ItemStack aStack) {
- ItemData tData = GT_OreDictUnificator.getItemData(aStack);
- return tData == null ? 0 : (tData.mPrefix == null ? 0 : tData.mPrefix.mHeatDamage) + (tData.hasValidMaterialData() ? tData.mMaterial.mMaterial.mHeatDamage : 0);
- }
-
- public static int getRadioactivityLevel(ItemStack aStack) {
- ItemData tData = GT_OreDictUnificator.getItemData(aStack);
- if (tData != null && tData.hasValidMaterialData()) {
- if (tData.mMaterial.mMaterial.mEnchantmentArmors instanceof Enchantment_Radioactivity)
- return tData.mMaterial.mMaterial.mEnchantmentArmorsLevel;
- if (tData.mMaterial.mMaterial.mEnchantmentTools instanceof Enchantment_Radioactivity)
- return tData.mMaterial.mMaterial.mEnchantmentToolsLevel;
- }
- return EnchantmentHelper.getEnchantmentLevel(Enchantment_Radioactivity.INSTANCE.effectId, aStack);
- }
-
- public static boolean isImmuneToBreathingGasses(EntityLivingBase aEntity) {
- return isWearingFullGasHazmat(aEntity);
- }
-
- public static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage) {
- if (aDamage > 0 && aEntity != null && aEntity.getActivePotionEffect(Potion.fireResistance) == null && !isWearingFullHeatHazmat(aEntity)) {
- aEntity.attackEntityFrom(GT_DamageSources.getHeatDamage(), aDamage);
- return true;
- }
- return false;
- }
-
- public static boolean applyFrostDamage(EntityLivingBase aEntity, float aDamage) {
- if (aDamage > 0 && aEntity != null && !isWearingFullFrostHazmat(aEntity)) {
- aEntity.attackEntityFrom(GT_DamageSources.getFrostDamage(), aDamage);
- return true;
- }
- return false;
- }
-
- public static boolean applyElectricityDamage(EntityLivingBase aEntity, long aVoltage, long aAmperage) {
- long aDamage = getTier(aVoltage) * aAmperage * 4;
- if (aDamage > 0 && aEntity != null && !isWearingFullElectroHazmat(aEntity)) {
- aEntity.attackEntityFrom(GT_DamageSources.getElectricDamage(), aDamage);
- return true;
- }
- return false;
- }
-
- public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) {
- if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !isWearingFullRadioHazmat(aEntity)) {
- PotionEffect tEffect = null;
- aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- aEntity.addPotionEffect(new PotionEffect(24 /* IC2 Radiation */, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
- return true;
- }
- return false;
- }
-
- public static ItemStack setStack(Object aSetStack, Object aToStack) {
- if (isStackInvalid(aSetStack) || isStackInvalid(aToStack)) return null;
- ((ItemStack) aSetStack).func_150996_a(((ItemStack) aToStack).getItem());
- ((ItemStack) aSetStack).stackSize = ((ItemStack) aToStack).stackSize;
- Items.feather.setDamage((ItemStack) aSetStack, Items.feather.getDamage((ItemStack) aToStack));
- ((ItemStack) aSetStack).setTagCompound(((ItemStack) aToStack).getTagCompound());
- return (ItemStack) aSetStack;
- }
-
- public static FluidStack[] copyFluidArray(FluidStack... aStacks) {
- FluidStack[] rStacks = new FluidStack[aStacks.length];
- for (int i = 0; i < aStacks.length; i++) if (aStacks[i] != null) rStacks[i] = aStacks[i].copy();
- return rStacks;
- }
-
- public static ItemStack[] copyStackArray(Object... aStacks) {
- ItemStack[] rStacks = new ItemStack[aStacks.length];
- for (int i = 0; i < aStacks.length; i++) rStacks[i] = copy(aStacks[i]);
- return rStacks;
- }
-
- public static ItemStack copy(Object... aStacks) {
- for (Object tStack : aStacks) if (isStackValid(tStack)) return ((ItemStack) tStack).copy();
- return null;
- }
-
- public static ItemStack copyAmount(long aAmount, Object... aStacks) {
- ItemStack rStack = copy(aStacks);
- if (isStackInvalid(rStack)) return null;
- if (aAmount > 64) aAmount = 64;
- else if (aAmount == -1) aAmount = 111;
- else if (aAmount < 0) aAmount = 0;
- rStack.stackSize = (byte) aAmount;
- return rStack;
- }
-
- public static ItemStack copyMetaData(long aMetaData, Object... aStacks) {
- ItemStack rStack = copy(aStacks);
- if (isStackInvalid(rStack)) return null;
- Items.feather.setDamage(rStack, (short) aMetaData);
- return rStack;
- }
-
- public static ItemStack copyAmountAndMetaData(long aAmount, long aMetaData, Object... aStacks) {
- ItemStack rStack = copyAmount(aAmount, aStacks);
- if (isStackInvalid(rStack)) return null;
- Items.feather.setDamage(rStack, (short) aMetaData);
- return rStack;
- }
-
- /**
- * returns a copy of an ItemStack with its Stacksize being multiplied by aMultiplier
- */
- public static ItemStack mul(long aMultiplier, Object... aStacks) {
- ItemStack rStack = copy(aStacks);
- if (rStack == null) return null;
- rStack.stackSize *= aMultiplier;
- return rStack;
- }
-
- /**
- * Loads an ItemStack properly.
- */
- public static ItemStack loadItem(NBTTagCompound aNBT, String aTagName) {
- return loadItem(aNBT.getCompoundTag(aTagName));
- }
-
- public static FluidStack loadFluid(NBTTagCompound aNBT, String aTagName) {
- return loadFluid(aNBT.getCompoundTag(aTagName));
- }
-
- /**
- * Loads an ItemStack properly.
- */
- public static ItemStack loadItem(NBTTagCompound aNBT) {
- if (aNBT == null) return null;
- ItemStack rStack = ItemStack.loadItemStackFromNBT(aNBT);
- try {
- if (rStack != null && (rStack.getItem().getClass().getName().startsWith("ic2.core.migration"))) {
- rStack.getItem().onUpdate(rStack, DW, null, 0, false);
- }
- } catch (Throwable e) {
- e.printStackTrace(GT_Log.err);
- }
- return GT_OreDictUnificator.get(true, rStack);
- }
-
- /**
- * Loads an FluidStack properly.
- */
- public static FluidStack loadFluid(NBTTagCompound aNBT) {
- if (aNBT == null) return null;
- return FluidStack.loadFluidStackFromNBT(aNBT);
- }
-
- public static <E> E selectItemInList(int aIndex, E aReplacement, List<E> aList) {
- if (aList == null || aList.isEmpty()) return aReplacement;
- if (aList.size() <= aIndex) return aList.get(aList.size() - 1);
- if (aIndex < 0) return aList.get(0);
- return aList.get(aIndex);
- }
-
- public static <E> E selectItemInList(int aIndex, E aReplacement, E... aList) {
- if (aList == null || aList.length == 0) return aReplacement;
- if (aList.length <= aIndex) return aList[aList.length - 1];
- if (aIndex < 0) return aList[0];
- return aList[aIndex];
- }
-
- public static boolean isStackInList(ItemStack aStack, Collection<GT_ItemStack> aList) {
- if (aStack == null) {
- return false;
- }
- return isStackInList(new GT_ItemStack(aStack), aList);
- }
-
- public static boolean isStackInList(GT_ItemStack aStack, Collection<GT_ItemStack> aList) {
- return aStack != null && (aList.contains(aStack) || aList.contains(new GT_ItemStack(aStack.mItem, aStack.mStackSize, W)));
- }
-
- /**
- * re-maps all Keys of a Map after the Keys were weakened.
- */
- public static <X, Y> Map<X, Y> reMap(Map<X, Y> aMap) {
- Map<X, Y> tMap = new /*Concurrent*/HashMap<X, Y>();
- tMap.putAll(aMap);
- aMap.clear();
- aMap.putAll(tMap);
- return aMap;
- }
-
- /**
- * Why the fuck do neither Java nor Guava have a Function to do this?
- */
- public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesAcending(Map<X, Y> aMap) {
- List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
- Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
- @Override
- public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
- return aValue1.getValue().compareTo(aValue2.getValue());
- }
- });
- LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
- for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
- return rMap;
- }
-
- /**
- * Why the fuck do neither Java nor Guava have a Function to do this?
- */
- public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) {
- List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
- Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
- @Override
- public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
- return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
- }
- });
- LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
- for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
- return rMap;
- }
-
- /**
- * Translates a Material Amount into an Amount of Fluid in Fluid Material Units.
- */
- public static long translateMaterialToFluidAmount(long aMaterialAmount, boolean aRoundUp) {
- return translateMaterialToAmount(aMaterialAmount, L, aRoundUp);
- }
-
- /**
- * Translates a Material Amount into an Amount of Fluid. Second Parameter for things like Bucket Amounts (1000) and similar
- */
- public static long translateMaterialToAmount(long aMaterialAmount, long aAmountPerUnit, boolean aRoundUp) {
- return Math.max(0, ((aMaterialAmount * aAmountPerUnit) / M) + (aRoundUp && (aMaterialAmount * aAmountPerUnit) % M > 0 ? 1 : 0));
- }
-
- /**
- * This checks if the Dimension is really a Dimension and not another Planet or something.
- * Used for my Teleporter.
- */
- public static boolean isRealDimension(int aDimensionID) {
- if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true;
- return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID);
- }
-
- //public static boolean isRealDimension(int aDimensionID) {
- // try {
- // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("com.xcompwiz.mystcraft"))
- // return true;
- // } catch (Throwable e) {/*Do nothing*/}
- // try {
- // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("TwilightForest")) return true;
- // } catch (Throwable e) {/*Do nothing*/}
- // try {
- // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("galacticraft")) return true;
- // } catch (Throwable e) {/*Do nothing*/}
- // return GregTech_API.sDimensionalList.contains(aDimensionID);
- //}
-
- public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) {
- //Credit goes to BrandonCore Author :!:
-
- if (entity == null || entity.worldObj.isRemote) return false;
- if (entity.ridingEntity != null) entity.mountEntity(null);
- if (entity.riddenByEntity != null) entity.riddenByEntity.mountEntity(null);
-
- World startWorld = entity.worldObj;
- World destinationWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(aDimension);
-
- if (destinationWorld == null) {return false;}
-
- boolean interDimensional = startWorld.provider.dimensionId != destinationWorld.provider.dimensionId;
- if(!interDimensional)return false;
- startWorld.updateEntityWithOptionalForce(entity, false);//added
-
- if ((entity instanceof EntityPlayerMP) && interDimensional) {
- EntityPlayerMP player = (EntityPlayerMP) entity;
- player.closeScreen();//added
- player.dimension = aDimension;
- player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, destinationWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
- ((WorldServer) startWorld).getPlayerManager().removePlayer(player);
-
- startWorld.playerEntities.remove(player);
- startWorld.updateAllPlayersSleepingFlag();
- int i = entity.chunkCoordX;
- int j = entity.chunkCoordZ;
- if ((entity.addedToChunk) && (startWorld.getChunkProvider().chunkExists(i, j))) {
- startWorld.getChunkFromChunkCoords(i, j).removeEntity(entity);
- startWorld.getChunkFromChunkCoords(i, j).isModified = true;
- }
- startWorld.loadedEntityList.remove(entity);
- startWorld.onEntityRemoved(entity);
- }
-
- entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
-
- ((WorldServer) destinationWorld).theChunkProviderServer.loadChunk((int) aX >> 4, (int) aZ >> 4);
-
- destinationWorld.theProfiler.startSection("placing");
- if (interDimensional) {
- if (!(entity instanceof EntityPlayer)) {
- NBTTagCompound entityNBT = new NBTTagCompound();
- entity.isDead = false;
- entityNBT.setString("id", EntityList.getEntityString(entity));
- entity.writeToNBT(entityNBT);
- entity.isDead = true;
- entity = EntityList.createEntityFromNBT(entityNBT, destinationWorld);
- if (entity == null) {
- return false;
- }
- entity.dimension = destinationWorld.provider.dimensionId;
- }
- destinationWorld.spawnEntityInWorld(entity);
- entity.setWorld(destinationWorld);
- }
- entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
-
- destinationWorld.updateEntityWithOptionalForce(entity, false);
- entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
-
- if ((entity instanceof EntityPlayerMP)) {
- EntityPlayerMP player = (EntityPlayerMP) entity;
- if (interDimensional) {
- player.mcServer.getConfigurationManager().func_72375_a(player, (WorldServer) destinationWorld);
- }
- player.playerNetServerHandler.setPlayerLocation(aX, aY, aZ, player.rotationYaw, player.rotationPitch);
- }
-
- destinationWorld.updateEntityWithOptionalForce(entity, false);
-
- if (((entity instanceof EntityPlayerMP)) && interDimensional) {
- EntityPlayerMP player = (EntityPlayerMP) entity;
- player.theItemInWorldManager.setWorld((WorldServer) destinationWorld);
- player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) destinationWorld);
- player.mcServer.getConfigurationManager().syncPlayerInventory(player);
-
- for (PotionEffect potionEffect : (Iterable<PotionEffect>) player.getActivePotionEffects()) {
- player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potionEffect));
- }
-
- player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
- FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, startWorld.provider.dimensionId, destinationWorld.provider.dimensionId);
- }
- entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
-
- destinationWorld.theProfiler.endSection();
- entity.fallDistance = 0;
- return true;
- }
-
- public static int getScaleCoordinates(double aValue, int aScale) {
- return (int)Math.floor(aValue / aScale);
- }
-
- public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
- if (aList == null) return 0;
-
- ArrayList<String> tList = new ArrayList<String>();
- int rEUAmount = 0;
-
- TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
-
- Block tBlock = aWorld.getBlock(aX, aY, aZ);
-
- tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET+ " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " D: " +EnumChatFormatting.AQUA+ aWorld.provider.dimensionId +EnumChatFormatting.RESET+ " -----");
- try {
- if (tTileEntity != null && tTileEntity instanceof IInventory)
- tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
- else
- tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
-
- tList.add(trans("164","Hardness: ") +EnumChatFormatting.YELLOW+ tBlock.getBlockHardness(aWorld, aX, aY, aZ) +EnumChatFormatting.RESET+ trans("165"," Blast Resistance: ") +EnumChatFormatting.YELLOW+ tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) +EnumChatFormatting.RESET);
- if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD+ trans("166","Is valid Beacon Pyramid Material") +EnumChatFormatting.RESET);
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- if (tTileEntity != null) {
- try {
- if (tTileEntity instanceof IFluidHandler) {
- rEUAmount += 500;
- FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide));
- if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) {
- tList.add(trans("167","Tank ") + i + ": " +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) +EnumChatFormatting.RESET+ " L / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(tTanks[i].capacity) +EnumChatFormatting.RESET+ " L " +EnumChatFormatting.GOLD+ getFluidName(tTanks[i].fluid, true)+EnumChatFormatting.RESET);
- }
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.reactor.IReactorChamber) {
- rEUAmount += 500;
- tTileEntity = (TileEntity) (((ic2.api.reactor.IReactorChamber) tTileEntity).getReactor());
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.reactor.IReactor) {
- rEUAmount += 500;
- tList.add(trans("168","Heat: ") +EnumChatFormatting.GREEN+ ((ic2.api.reactor.IReactor) tTileEntity).getHeat() +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+ ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()+EnumChatFormatting.RESET);
- tList.add(trans("169","HEM: ") +EnumChatFormatting.YELLOW+((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() +EnumChatFormatting.RESET/*+ trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.tile.IWrenchable) {
- rEUAmount += 100;
- tList.add(trans("171","Facing: ") +EnumChatFormatting.GREEN+ ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() +EnumChatFormatting.RESET+ trans("172"," / Chance: ") +EnumChatFormatting.YELLOW+ (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) +EnumChatFormatting.RESET+ "%");
- tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? EnumChatFormatting.GREEN+ trans("173","You can remove this with a Wrench") +EnumChatFormatting.RESET : EnumChatFormatting.RED+ trans("174","You can NOT remove this with a Wrench") +EnumChatFormatting.RESET);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.energy.tile.IEnergyTile) {
- rEUAmount += 200;
- //aList.add(((ic2.api.energy.tile.IEnergyTile)tTileEntity).isAddedToEnergyNet()?"Added to E-net":"Not added to E-net! Bug?");
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.energy.tile.IEnergySink) {
- rEUAmount += 400;
- //aList.add("Demanded Energy: " + ((ic2.api.energy.tile.IEnergySink)tTileEntity).demandsEnergy());
- //tList.add("Max Safe Input: " + getTier(((ic2.api.energy.tile.IEnergySink)tTileEntity).getSinkTier()));
- //tList.add("Max Safe Input: " + ((ic2.api.energy.tile.IEnergySink)tTileEntity).getMaxSafeInput());
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.energy.tile.IEnergySource) {
- rEUAmount += 400;
- //aList.add("Max Energy Output: " + ((ic2.api.energy.tile.IEnergySource)tTileEntity).getMaxEnergyOutput());
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) {
- rEUAmount += 200;
- tList.add(trans("175","Conduction Loss: ") +EnumChatFormatting.YELLOW+ ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss()+EnumChatFormatting.RESET);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) {
- rEUAmount += 200;
- tList.add(trans("176","Contained Energy: ") +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()+EnumChatFormatting.RESET+" EU");
- //aList.add(((ic2.api.tile.IEnergyStorage)tTileEntity).isTeleporterCompatible(ic2.api.Direction.YP)?"Teleporter Compatible":"Not Teleporter Compatible");
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof IUpgradableMachine) {
- rEUAmount += 500;
- if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN+ trans("177","Has Muffler Upgrade") +EnumChatFormatting.RESET);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof IMachineProgress) {
- rEUAmount += 400;
- int tValue = 0;
- if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress()))
- tList.add(trans("178","Progress/Load: ") +EnumChatFormatting.GREEN+GT_Utility.formatNumbers(((IMachineProgress) tTileEntity).getProgress()) +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(tValue) +EnumChatFormatting.RESET);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ICoverable) {
- rEUAmount += 300;
- String tString = ((ICoverable) tTileEntity).getCoverBehaviorAtSide((byte) aSide).getDescription((byte) aSide, ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), ((ICoverable) tTileEntity).getCoverDataAtSide((byte) aSide), (ICoverable) tTileEntity);
- if (tString != null && !tString.equals(E)) tList.add(tString);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof IBasicEnergyContainer && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) {
- tList.add(trans("179","Max IN: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+((IBasicEnergyContainer)tTileEntity).getInputAmperage()+EnumChatFormatting.RESET+trans("183"," A"));
- tList.add(trans("181","Max OUT: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() +EnumChatFormatting.RESET+ trans("183"," A"));
- tList.add(trans("184","Energy: ") +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) +EnumChatFormatting.RESET+ " EU");
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof IGregTechTileEntity) {
- tList.add(trans("186","Owned by: ") +EnumChatFormatting.BLUE+ ((IGregTechTileEntity) tTileEntity).getOwnerName()+EnumChatFormatting.RESET);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof IGregTechDeviceInformation && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) {
- tList.addAll(Arrays.asList(((IGregTechDeviceInformation) tTileEntity).getInfoData()));
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- try {
- if (tTileEntity instanceof ic2.api.crops.ICropTile) {
- if (((ic2.api.crops.ICropTile) tTileEntity).getScanLevel() < 4) {
- rEUAmount += 10000;
- ((ic2.api.crops.ICropTile) tTileEntity).setScanLevel((byte) 4);
- }
- if (((ic2.api.crops.ICropTile) tTileEntity).getID() >= 0 && ((ic2.api.crops.ICropTile) tTileEntity).getID() < ic2.api.crops.Crops.instance.getCropList().length && ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()] != null) {
- rEUAmount += 1000;
- tList.add(trans("187","Type -- Crop-Name: ") + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].name()
- + trans("188"," Growth: ") + ((ic2.api.crops.ICropTile) tTileEntity).getGrowth()
- + trans("189"," Gain: ") + ((ic2.api.crops.ICropTile) tTileEntity).getGain()
- + trans("190"," Resistance: ") + ((ic2.api.crops.ICropTile) tTileEntity).getResistance()
- );
- tList.add(trans("191","Plant -- Fertilizer: ") + ((ic2.api.crops.ICropTile) tTileEntity).getNutrientStorage()
- + trans("192"," Water: ") + ((ic2.api.crops.ICropTile) tTileEntity).getHydrationStorage()
- + trans("193"," Weed-Ex: ") + ((ic2.api.crops.ICropTile) tTileEntity).getWeedExStorage()
- + trans("194"," Scan-Level: ") + ((ic2.api.crops.ICropTile) tTileEntity).getScanLevel()
- );
- tList.add(trans("195","Environment -- Nutrients: ") + ((ic2.api.crops.ICropTile) tTileEntity).getNutrients()
- + trans("196"," Humidity: ") + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity()
- + trans("197"," Air-Quality: ") + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality()
- );
- StringBuilder tStringB = new StringBuilder();
- for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) {
- tStringB.append(", ").append(tAttribute);
- }
- String tString = tStringB.toString();
- tList.add(trans("198","Attributes:") + tString.replaceFirst(",", E));
- tList.add(trans("199","Discovered by: ") + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy());
- }
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- }
-
- if (aPlayer.capabilities.isCreativeMode) {
- FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read
- if (tFluid!=null)
- tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L");
- else
- tList.add(EnumChatFormatting.GOLD+trans("201","Nothing")+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ '0' +EnumChatFormatting.RESET+" L");
- }
-// if(aPlayer.capabilities.isCreativeMode){
- int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair());
- if(chunkData !=null){
- if(chunkData[GTPOLLUTION]>0){
- tList.add(trans("202","Pollution in Chunk: ")+EnumChatFormatting.RED+chunkData[GTPOLLUTION]+EnumChatFormatting.RESET+trans("203"," gibbl"));
- }else{
- tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
- }
- }else{
- tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
- }
-
- try {
- if (tBlock instanceof IDebugableBlock) {
- rEUAmount += 500;
- ArrayList<String> temp = ((IDebugableBlock) tBlock).getDebugInfo(aPlayer, aX, aY, aZ, 3);
- if (temp != null) tList.addAll(temp);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
-
- BlockScanningEvent tEvent = new BlockScanningEvent(aWorld, aPlayer, aX, aY, aZ, (byte) aSide, aScanLevel, tBlock, tTileEntity, tList, aClickX, aClickY, aClickZ);
- tEvent.mEUCost = rEUAmount;
- MinecraftForge.EVENT_BUS.post(tEvent);
- if (!tEvent.isCanceled()) aList.addAll(tList);
- return tEvent.mEUCost;
- }
-
- public static String trans(String aKey, String aEnglish){
- return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false);
- }
-
- /**
- * @return an Array containing the X and the Y Coordinate of the clicked Point, with the top left Corner as Origin, like on the Texture Sheet. return values should always be between [0.0F and 0.99F].
- */
- public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, float aZ) {
- switch (aSide) {
- case 0:
- return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ))};
- case 1:
- return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ))};
- case 2:
- return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY))};
- case 3:
- return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY))};
- case 4:
- return new float[]{Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY))};
- case 5:
- return new float[]{Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY))};
- default:
- return new float[]{0.5F, 0.5F};
- }
- }
-
- /**
- * This Function determines the direction a Block gets when being Wrenched.
- * returns -1 if invalid. Even though that could never happen.
- */
- public static byte determineWrenchingSide(byte aSide, float aX, float aY, float aZ) {
- byte tBack = getOppositeSide(aSide);
- switch (aSide) {
- case 0:
- case 1:
- if (aX < 0.25) {
- if (aZ < 0.25) return tBack;
- if (aZ > 0.75) return tBack;
- return 4;
- }
- if (aX > 0.75) {
- if (aZ < 0.25) return tBack;
- if (aZ > 0.75) return tBack;
- return 5;
- }
- if (aZ < 0.25) return 2;
- if (aZ > 0.75) return 3;
- return aSide;
- case 2:
- case 3:
- if (aX < 0.25) {
- if (aY < 0.25) return tBack;
- if (aY > 0.75) return tBack;
- return 4;
- }
- if (aX > 0.75) {
- if (aY < 0.25) return tBack;
- if (aY > 0.75) return tBack;
- return 5;
- }
- if (aY < 0.25) return 0;
- if (aY > 0.75) return 1;
- return aSide;
- case 4:
- case 5:
- if (aZ < 0.25) {
- if (aY < 0.25) return tBack;
- if (aY > 0.75) return tBack;
- return 2;
- }
- if (aZ > 0.75) {
- if (aY < 0.25) return tBack;
- if (aY > 0.75) return tBack;
- return 3;
- }
- if (aY < 0.25) return 0;
- if (aY > 0.75) return 1;
- return aSide;
- }
- return -1;
- }
-
- public static String formatNumbers(long aNumber) {
- DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
- DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
- symbols.setGroupingSeparator(' ');
- return formatter.format(aNumber);
- }
-
- /*
- * Check if stack has enough items of given type and subtract from stack, if there's no creative or 111 stack.
- */
- public static boolean consumeItems(EntityPlayer player, ItemStack stack, Item item, int count) {
- if (stack != null && stack.getItem() == item && stack.stackSize >= count) {
- if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111))
- stack.stackSize -= count;
- return true;
- }
- return false;
- }
-
- /*
- * Check if stack has enough items of given gregtech material (will be oredicted)
- * and subtract from stack, if there's no creative or 111 stack.
- */
- public static boolean consumeItems(EntityPlayer player, ItemStack stack, gregtech.api.enums.Materials mat, int count) {
- if (stack != null
- && GT_OreDictUnificator.getItemData(stack).mMaterial.mMaterial == mat
- && stack.stackSize >= count) {
- if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111))
- stack.stackSize -= count;
- return true;
- }
- return false;
- }
-
- public static ArrayList<String> sortByValueToList( Map<String, Integer> map ) {
- List<Map.Entry<String, Integer>> list =
- new LinkedList<Map.Entry<String, Integer>>( map.entrySet() );
- Collections.sort( list, new Comparator<Map.Entry<String, Integer>>()
- {
- public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 )
- {
- return o2.getValue() - o1.getValue();
- }
- } );
-
- ArrayList<String> result = new ArrayList<String>();
- for (Map.Entry<String, Integer> e : list)
- result.add(e.getKey());
- return result;
- }
-
- public static String joinListToString(List<String> list) {
- StringBuilder result = new StringBuilder(32);
- for (String s : list)
- result.append(result.length()==0?s:'|'+s);
- return result.toString();
- }
-
- public static ItemStack getIntegratedCircuit(int config){
- return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]);
- }
-
- public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) {
- return aWorld.getBlock(aX, aY, aZ).getBlockHardness(aWorld, aX, aY, aZ);
- }
-
- public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) {
- if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) {
- return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(aBaseMetaTileEntity.getOwnerUuid(), aBaseMetaTileEntity.getOwnerName()));
- }
- return null;
- }
-
- public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) {
- if (aPlayer == null) return false;
- World aWorld = aPlayer.worldObj;
- BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer);
- MinecraftForge.EVENT_BUS.post(event);
- if (!event.isCanceled()) {
- if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ);
- return true;
- }
- return false;
- }
-
- public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) {
- if (aPlayer == null) return false;
- World aWorld = aPlayer.worldObj;
- BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN);
- if (!event.isCanceled()) {
- if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3);
- return true;
- }
- return false;
- }
-
- public static class ItemNBT {
- public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) {
- if (aNBT == null) {
- aStack.setTagCompound(null);
- return;
- }
- ArrayList<String> tTagsToRemove = new ArrayList<String>();
- for (Object tKey : aNBT.func_150296_c()) {
- NBTBase tValue = aNBT.getTag((String) tKey);
- if (tValue == null || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) || (tValue instanceof NBTTagString && isStringInvalid(((NBTTagString) tValue).func_150285_a_())))
- tTagsToRemove.add((String) tKey);
- }
- for (Object tKey : tTagsToRemove) aNBT.removeTag((String) tKey);
- aStack.setTagCompound(aNBT.hasNoTags() ? null : aNBT);
- }
-
- public static NBTTagCompound getNBT(ItemStack aStack) {
- NBTTagCompound rNBT = aStack.getTagCompound();
- return rNBT == null ? new NBTTagCompound() : rNBT;
- }
-
- public static void setPunchCardData(ItemStack aStack, String aPunchCardData) {
- NBTTagCompound tNBT = getNBT(aStack);
- tNBT.setString("GT.PunchCardData", aPunchCardData);
- setNBT(aStack, tNBT);
- }
-
- public static String getPunchCardData(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- return tNBT.getString("GT.PunchCardData");
- }
-
- public static void setLighterFuel(ItemStack aStack, long aFuel) {
- NBTTagCompound tNBT = getNBT(aStack);
- tNBT.setLong("GT.LighterFuel", aFuel);
- setNBT(aStack, tNBT);
- }
-
- public static long getLighterFuel(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- return tNBT.getLong("GT.LighterFuel");
- }
-
- public static void setMapID(ItemStack aStack, short aMapID) {
- NBTTagCompound tNBT = getNBT(aStack);
- tNBT.setShort("map_id", aMapID);
- setNBT(aStack, tNBT);
- }
-
- public static short getMapID(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- if (!tNBT.hasKey("map_id")) return -1;
- return tNBT.getShort("map_id");
- }
-
- public static void setBookTitle(ItemStack aStack, String aTitle) {
- NBTTagCompound tNBT = getNBT(aStack);
- tNBT.setString("title", aTitle);
- setNBT(aStack, tNBT);
- }
-
- public static String getBookTitle(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- return tNBT.getString("title");
- }
-
- public static void setBookAuthor(ItemStack aStack, String aAuthor) {
- NBTTagCompound tNBT = getNBT(aStack);
- tNBT.setString("author", aAuthor);
- setNBT(aStack, tNBT);
- }
-
- public static String getBookAuthor(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- return tNBT.getString("author");
- }
-
- public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String... aOres) {
- NBTTagCompound tNBT = getNBT(aStack);
- String tData = aX + "," + aY + "," + aZ + "," + aDim + ",";
- if (aFluid!=null)
- tData += (aFluid.amount) + "," + aFluid.getLocalizedName() + ",";//TODO CHECK IF THAT /5000 is needed (Not needed)
- for (String tString : aOres) {
- tData += tString + ",";
- }
- tNBT.setString("prospection", tData);
- setNBT(aStack, tNBT);
- }
-
- public static void setAdvancedProspectionData(
- byte aTier,
- ItemStack aStack,
- int aX, short aY, int aZ, int aDim,
- ArrayList<String> aOils,
- ArrayList<String> aOres,
- int aRadius) {
-
- setBookTitle(aStack, "Raw Prospection Data");
-
- NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack);
-
- tNBT.setByte("prospection_tier", aTier);
- tNBT.setString("prospection_pos", "Dim: " + aDim + "\nX: " + aX + " Y: " + aY + " Z: " + aZ);
-
- // ores
- Collections.sort(aOres);
- tNBT.setString("prospection_ores", joinListToString(aOres));
-
- // oils
- ArrayList<String> tOilsTransformed = new ArrayList<String>(aOils.size());
- for (String aStr : aOils) {
- String[] aStats = aStr.split(",");
- tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]);
- }
-
- tNBT.setString("prospection_oils", joinListToString(tOilsTransformed));
-
- String tOilsPosStr = "X: " + Math.floorDiv(aX, 16*8)*16*8 + " Z: " + Math.floorDiv(aZ, 16*8)*16*8 + "\n";
- int xOff = aX - Math.floorDiv(aX, 16*8)*16*8;
- xOff = xOff/16;
- int xOffRemain = 7 - xOff;
-
- int zOff = aZ - Math.floorDiv(aZ, 16*8)*16*8;
- zOff = zOff/16;
- int zOffRemain = 7 - zOff;
-
- for( ; zOff > 0; zOff-- ) {
- tOilsPosStr = tOilsPosStr.concat("--------\n");
- }
- for( ; xOff > 0; xOff-- ) {
- tOilsPosStr = tOilsPosStr.concat("-");
- }
-
- tOilsPosStr = tOilsPosStr.concat("P");
-
- for( ; xOffRemain > 0; xOffRemain-- ) {
- tOilsPosStr = tOilsPosStr.concat("-");
- }
- tOilsPosStr = tOilsPosStr.concat("\n");
- for( ; zOffRemain > 0; zOffRemain-- ) {
- tOilsPosStr = tOilsPosStr.concat("--------\n");
- }
- tOilsPosStr = tOilsPosStr.concat( " X: " + (Math.floorDiv(aX, 16*8) + 1)*16*8 + " Z: " + (Math.floorDiv(aZ, 16*8) + 1)*16*8 ); // +1 oilfied to find bottomright of [5]
-
- tNBT.setString("prospection_oils_pos", tOilsPosStr);
-
- tNBT.setString("prospection_radius", String.valueOf(aRadius));
-
- setNBT(aStack, tNBT);
- }
-
- public static void convertProspectionData(ItemStack aStack) {
- NBTTagCompound tNBT = getNBT(aStack);
- byte tTier = tNBT.getByte("prospection_tier");
-
- if (tTier == 0) { // basic prospection data
- String tData = tNBT.getString("prospection");
- String[] tDataArray = tData.split(",");
- if (tDataArray.length > 6) {
- tNBT.setString("author", " Dim: " + tDataArray[3] + "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2]);
- NBTTagList tNBTList = new NBTTagList();
- String tOres = " Prospected Ores: ";
- for (int i = 6; tDataArray.length > i; i++) {
- tOres += (tDataArray[i] + " ");
- }
- tNBTList.appendTag(new NBTTagString("Tier " + tTier + " Prospecting Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
- tNBT.setTag("pages", tNBTList);
- }
- setNBT(aStack, tNBT);
- } else { // advanced prospection data
- String tPos = tNBT.getString("prospection_pos");
- String tRadius = tNBT.getString("prospection_radius");
-
- String tOresStr = tNBT.getString("prospection_ores");
- String tOilsStr = tNBT.getString("prospection_oils");
- String tOilsPosStr = tNBT.getString("prospection_oils_pos");
-
- String[] tOres = tOresStr.isEmpty() ? null : tOresStr.split("\\|");
- String[] tOils = tOilsStr.isEmpty() ? null : tOilsStr.split("\\|");
-
- NBTTagList tNBTList = new NBTTagList();
-
- String tPageText = "Prospector report\n"
- + tPos + "\n\n"
- + "Oils: " + (tOils != null ? tOils.length : 0) + "\n\n"
- + "Ores within " + tRadius + " blocks\n\n"
- + "Location is center of orevein\n\n"
- + "Check NEI to confirm orevein type";
- tNBTList.appendTag(new NBTTagString(tPageText));
-
- if (tOres != null)
- fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres);
-
-
- if (tOils != null)
- fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils);
-
- tPageText = "Oil notes\n\n"
- + "Prospects from NW to SE 576 chunks"
- + "(9 8x8 oilfields)\n around and gives min-max amount" + "\n\n"
- + "[1][2][3]" + "\n"
- + "[4][5][6]" + "\n"
- + "[7][8][9]" + "\n"
- + "\n"
- + "[5] - Prospector in this 8x8 area";
- tNBTList.appendTag(new NBTTagString(tPageText));
-
- tPageText = "Corners of [5] are \n" +
- tOilsPosStr + "\n" +
- "P - Prospector in 8x8 field";
- tNBTList.appendTag(new NBTTagString(tPageText));
-
- tNBT.setString("author", tPos.replace("\n"," "));
- tNBT.setTag("pages", tNBTList);
- setNBT(aStack, tNBT);
- }
- }
-
- public static void fillBookWithList(NBTTagList aBook, String aPageHeader, String aListDelimiter, int aItemsPerPage, String[] list) {
- String aPageFormatter = " %d/%d";
- int tTotalPages = list.length / aItemsPerPage + (list.length % aItemsPerPage > 0 ? 1 : 0);
- int tPage = 0;
- String tPageText;
- do {
- tPageText = "";
- for (int i = tPage*aItemsPerPage; i < (tPage+1)*aItemsPerPage && i < list.length; i += 1)
- tPageText += (tPageText.isEmpty() ? "" : aListDelimiter) + list[i];
-
- if (!tPageText.isEmpty()) {
- String tPageCounter = tTotalPages > 1 ? String.format(aPageFormatter, tPage + 1, tTotalPages) : "";
- NBTTagString tPageTag = new NBTTagString(String.format(aPageHeader, tPageCounter) + tPageText);
- aBook.appendTag(tPageTag);
- }
-
- ++tPage;
- } while (!tPageText.isEmpty());
- }
-
- public static void addEnchantment(ItemStack aStack, Enchantment aEnchantment, int aLevel) {
- NBTTagCompound tNBT = getNBT(aStack), tEnchantmentTag;
- if (!tNBT.hasKey("ench", 9)) tNBT.setTag("ench", new NBTTagList());
- NBTTagList tList = tNBT.getTagList("ench", 10);
-
- boolean temp = true;
-
- for (int i = 0; i < tList.tagCount(); i++) {
- tEnchantmentTag = tList.getCompoundTagAt(i);
- if (tEnchantmentTag.getShort("id") == aEnchantment.effectId) {
- tEnchantmentTag.setShort("id", (short) aEnchantment.effectId);
- tEnchantmentTag.setShort("lvl", (byte) aLevel);
- temp = false;
- break;
- }
- }
-
- if (temp) {
- tEnchantmentTag = new NBTTagCompound();
- tEnchantmentTag.setShort("id", (short) aEnchantment.effectId);
- tEnchantmentTag.setShort("lvl", (byte) aLevel);
- tList.appendTag(tEnchantmentTag);
- }
- aStack.setTagCompound(tNBT);
- }
- }
-
- /**
- * THIS IS BULLSHIT!!! WHY DO I HAVE TO DO THIS SHIT JUST TO HAVE ENCHANTS PROPERLY!?!
- */
- public static class GT_EnchantmentHelper {
- private static final BullshitIteratorA mBullshitIteratorA = new BullshitIteratorA();
- private static final BullshitIteratorB mBullshitIteratorB = new BullshitIteratorB();
-
- private static void applyBullshit(IBullshit aBullshitModifier, ItemStack aStack) {
- if (aStack != null) {
- NBTTagList nbttaglist = aStack.getEnchantmentTagList();
- if (nbttaglist != null) {
- try {
- for (int i = 0; i < nbttaglist.tagCount(); ++i) {
- short short1 = nbttaglist.getCompoundTagAt(i).getShort("id");
- short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl");
- if (Enchantment.enchantmentsList[short1] != null)
- aBullshitModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2);
- }
- } catch (Throwable e) {/**/}
- }
- }
- }
-
- private static void applyArrayOfBullshit(IBullshit aBullshitModifier, ItemStack[] aStacks) {
- ItemStack[] aitemstack1 = aStacks;
- int i = aStacks.length;
- for (int j = 0; j < i; ++j) {
- ItemStack itemstack = aitemstack1[j];
- applyBullshit(aBullshitModifier, itemstack);
- }
- }
-
- public static void applyBullshitA(EntityLivingBase aPlayer, Entity aEntity, ItemStack aStack) {
- mBullshitIteratorA.mPlayer = aPlayer;
- mBullshitIteratorA.mEntity = aEntity;
- if (aPlayer != null) applyArrayOfBullshit(mBullshitIteratorA, aPlayer.getLastActiveItems());
- if (aStack != null) applyBullshit(mBullshitIteratorA, aStack);
- }
-
- public static void applyBullshitB(EntityLivingBase aPlayer, Entity aEntity, ItemStack aStack) {
- mBullshitIteratorB.mPlayer = aPlayer;
- mBullshitIteratorB.mEntity = aEntity;
- if (aPlayer != null) applyArrayOfBullshit(mBullshitIteratorB, aPlayer.getLastActiveItems());
- if (aStack != null) applyBullshit(mBullshitIteratorB, aStack);
- }
-
- interface IBullshit {
- void calculateModifier(Enchantment aEnchantment, int aLevel);
- }
-
- static final class BullshitIteratorA implements IBullshit {
- public EntityLivingBase mPlayer;
- public Entity mEntity;
-
- BullshitIteratorA() {
- }
-
- @Override
- public void calculateModifier(Enchantment aEnchantment, int aLevel) {
- aEnchantment.func_151367_b(mPlayer, mEntity, aLevel);
- }
- }
-
- static final class BullshitIteratorB implements IBullshit {
- public EntityLivingBase mPlayer;
- public Entity mEntity;
-
- BullshitIteratorB() {
- }
-
- @Override
- public void calculateModifier(Enchantment aEnchantment, int aLevel) {
- aEnchantment.func_151368_a(mPlayer, mEntity, aLevel);
- }
- }
- }
-
- public static String toSubscript(long no){
- char[] chars=Long.toString(no).toCharArray();
- for(int i=0;i<chars.length;i++){
- chars[i]+=8272;
- }
- return new String(chars);
- }
-
- public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials){
- return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials) : false;
- }
-
- public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){
- return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false;
- }
-
-}
+package gregtech.api.util;
+
+import cofh.api.transport.IItemDuct;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.common.FMLCommonHandler;
+import gregtech.api.GregTech_API;
+import gregtech.api.damagesources.GT_DamageSources;
+import gregtech.api.enchants.Enchantment_Radioactivity;
+import gregtech.api.enums.*;
+import gregtech.api.events.BlockScanningEvent;
+import gregtech.api.interfaces.IDebugableBlock;
+import gregtech.api.interfaces.IProjectileItem;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.*;
+import gregtech.api.items.GT_EnergyArmor_Item;
+import gregtech.api.items.GT_Generic_Item;
+import gregtech.api.net.GT_Packet_Sound;
+import gregtech.api.objects.GT_CopiedBlockTexture;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.ItemData;
+import gregtech.api.threads.GT_Runnable_Sound;
+import gregtech.common.GT_Proxy;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.api.recipe.RecipeOutput;
+import net.minecraft.block.Block;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.*;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTBase.NBTPrimitive;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+import net.minecraft.network.play.server.S07PacketRespawn;
+import net.minecraft.network.play.server.S1DPacketEntityEffect;
+import net.minecraft.network.play.server.S1FPacketSetExperience;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityChest;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraft.world.WorldServer;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.BlockSnapshot;
+import net.minecraftforge.common.util.FakePlayer;
+import net.minecraftforge.common.util.FakePlayerFactory;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.event.ForgeEventFactory;
+import net.minecraftforge.event.world.BlockEvent;
+import net.minecraftforge.fluids.*;
+import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.*;
+import java.util.Map.Entry;
+
+import static gregtech.GT_Mod.GT_FML_LOGGER;
+import static gregtech.api.enums.GT_Values.*;
+import static gregtech.common.GT_Proxy.GTPOLLUTION;
+import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * Just a few Utility Functions I use.
+ */
+public class GT_Utility {
+ /**
+ * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there.
+ */
+ private static final List<FluidContainerData> sFluidContainerList = new ArrayList<FluidContainerData>();
+ private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<GT_ItemStack, FluidContainerData>();
+ private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>();
+ public static volatile int VERSION = 509;
+ public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
+ public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>();
+ private static int sBookCount = 0;
+ public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000");
+
+ static {
+ GregTech_API.sItemStackMappings.add(sFilledContainerToData);
+ GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
+ }
+
+ public static int safeInt(long number, int margin){
+ return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number;
+ }
+
+ public static int safeInt(long number){
+ return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number;
+ }
+
+ public static Field getPublicField(Object aObject, String aField) {
+ Field rField = null;
+ try {
+ rField = aObject.getClass().getDeclaredField(aField);
+ } catch (Throwable e) {/*Do nothing*/}
+ return rField;
+ }
+
+ public static Field getField(Object aObject, String aField) {
+ Field rField = null;
+ try {
+ rField = aObject.getClass().getDeclaredField(aField);
+ rField.setAccessible(true);
+ } catch (Throwable e) {/*Do nothing*/}
+ return rField;
+ }
+
+ public static Field getField(Class aObject, String aField) {
+ Field rField = null;
+ try {
+ rField = aObject.getDeclaredField(aField);
+ rField.setAccessible(true);
+ } catch (Throwable e) {/*Do nothing*/}
+ return rField;
+ }
+
+ public static Method getMethod(Class aObject, String aMethod, Class<?>... aParameterTypes) {
+ Method rMethod = null;
+ try {
+ rMethod = aObject.getMethod(aMethod, aParameterTypes);
+ rMethod.setAccessible(true);
+ } catch (Throwable e) {/*Do nothing*/}
+ return rMethod;
+ }
+
+ public static Method getMethod(Object aObject, String aMethod, Class<?>... aParameterTypes) {
+ Method rMethod = null;
+ try {
+ rMethod = aObject.getClass().getMethod(aMethod, aParameterTypes);
+ rMethod.setAccessible(true);
+ } catch (Throwable e) {/*Do nothing*/}
+ return rMethod;
+ }
+
+ public static Field getField(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) {
+ try {
+ Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField);
+ if (aPrivate) tField.setAccessible(true);
+ return tField;
+ } catch (Throwable e) {
+ if (aLogErrors) e.printStackTrace(GT_Log.err);
+ }
+ return null;
+ }
+
+ public static Object getFieldContent(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) {
+ try {
+ Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField);
+ if (aPrivate) tField.setAccessible(true);
+ return tField.get(aObject instanceof Class || aObject instanceof String ? null : aObject);
+ } catch (Throwable e) {
+ if (aLogErrors) e.printStackTrace(GT_Log.err);
+ }
+ return null;
+ }
+
+ public static Object callPublicMethod(Object aObject, String aMethod, Object... aParameters) {
+ return callMethod(aObject, aMethod, false, false, true, aParameters);
+ }
+
+ public static Object callPrivateMethod(Object aObject, String aMethod, Object... aParameters) {
+ return callMethod(aObject, aMethod, true, false, true, aParameters);
+ }
+
+ public static Object callMethod(Object aObject, String aMethod, boolean aPrivate, boolean aUseUpperCasedDataTypes, boolean aLogErrors, Object... aParameters) {
+ try {
+ Class<?>[] tParameterTypes = new Class<?>[aParameters.length];
+ for (byte i = 0; i < aParameters.length; i++) {
+ if (aParameters[i] instanceof Class) {
+ tParameterTypes[i] = (Class) aParameters[i];
+ aParameters[i] = null;
+ } else {
+ tParameterTypes[i] = aParameters[i].getClass();
+ }
+ if (!aUseUpperCasedDataTypes) {
+ if (tParameterTypes[i] == Boolean.class) tParameterTypes[i] = boolean.class;
+ else if (tParameterTypes[i] == Byte.class) tParameterTypes[i] = byte.class;
+ else if (tParameterTypes[i] == Short.class) tParameterTypes[i] = short.class;
+ else if (tParameterTypes[i] == Integer.class) tParameterTypes[i] = int.class;
+ else if (tParameterTypes[i] == Long.class) tParameterTypes[i] = long.class;
+ else if (tParameterTypes[i] == Float.class) tParameterTypes[i] = float.class;
+ else if (tParameterTypes[i] == Double.class) tParameterTypes[i] = double.class;
+ }
+ }
+
+ Method tMethod = (aObject instanceof Class) ? ((Class) aObject).getMethod(aMethod, tParameterTypes) : aObject.getClass().getMethod(aMethod, tParameterTypes);
+ if (aPrivate) tMethod.setAccessible(true);
+ return tMethod.invoke(aObject, aParameters);
+ } catch (Throwable e) {
+ if (aLogErrors) e.printStackTrace(GT_Log.err);
+ }
+ return null;
+ }
+
+ public static Object callConstructor(String aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) {
+ if (aConstructorIndex < 0) {
+ try {
+ for (Constructor tConstructor : Class.forName(aClass).getConstructors()) {
+ try {
+ return tConstructor.newInstance(aParameters);
+ } catch (Throwable e) {/*Do nothing*/}
+ }
+ } catch (Throwable e) {
+ if (aLogErrors) e.printStackTrace(GT_Log.err);
+ }
+ } else {
+ try {
+ return Class.forName(aClass).getConstructors()[aConstructorIndex].newInstance(aParameters);
+ } catch (Throwable e) {
+ if (aLogErrors) e.printStackTrace(GT_Log.err);
+ }
+ }
+ return aReplacementObject;
+ }
+
+ public static String capitalizeString(String aString) {
+ if (aString != null && aString.length() > 0)
+ return aString.substring(0, 1).toUpperCase() + aString.substring(1);
+ return E;
+ }
+
+ public static boolean getPotion(EntityLivingBase aPlayer, int aPotionIndex) {
+ try {
+ Field tPotionHashmap = null;
+
+ Field[] var3 = EntityLiving.class.getDeclaredFields();
+ int var4 = var3.length;
+
+ for (int var5 = 0; var5 < var4; ++var5) {
+ Field var6 = var3[var5];
+ if (var6.getType() == HashMap.class) {
+ tPotionHashmap = var6;
+ tPotionHashmap.setAccessible(true);
+ break;
+ }
+ }
+
+ if (tPotionHashmap != null)
+ return ((HashMap) tPotionHashmap.get(aPlayer)).get(Integer.valueOf(aPotionIndex)) != null;
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ return false;
+ }
+
+ public static String getClassName(Object aObject) {
+ if (aObject == null) return "null";
+ return aObject.getClass().getName().substring(aObject.getClass().getName().lastIndexOf(".") + 1);
+ }
+
+ public static void removePotion(EntityLivingBase aPlayer, int aPotionIndex) {
+ try {
+ Field tPotionHashmap = null;
+
+ Field[] var3 = EntityLiving.class.getDeclaredFields();
+ int var4 = var3.length;
+
+ for (int var5 = 0; var5 < var4; ++var5) {
+ Field var6 = var3[var5];
+ if (var6.getType() == HashMap.class) {
+ tPotionHashmap = var6;
+ tPotionHashmap.setAccessible(true);
+ break;
+ }
+ }
+
+ if (tPotionHashmap != null) ((HashMap) tPotionHashmap.get(aPlayer)).remove(Integer.valueOf(aPotionIndex));
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ public static boolean getFullInvisibility(EntityPlayer aPlayer) {
+ try {
+ if (aPlayer.isInvisible()) {
+ for (int i = 0; i < 4; i++) {
+ if (aPlayer.inventory.armorInventory[i] != null) {
+ if (aPlayer.inventory.armorInventory[i].getItem() instanceof GT_EnergyArmor_Item) {
+ if ((((GT_EnergyArmor_Item) aPlayer.inventory.armorInventory[i].getItem()).mSpecials & 512) != 0) {
+ if (GT_ModHandler.canUseElectricItem(aPlayer.inventory.armorInventory[i], 10000)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ return false;
+ }
+
+ public static ItemStack suckOneItemStackAt(World aWorld, double aX, double aY, double aZ, double aL, double aH, double aW) {
+ for (EntityItem tItem : (ArrayList<EntityItem>) aWorld.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + aL, aY + aH, aZ + aW))) {
+ if (!tItem.isDead) {
+ aWorld.removeEntity(tItem);
+ tItem.setDead();
+ return tItem.getEntityItem();
+ }
+ }
+ return null;
+ }
+
+ public static byte getOppositeSide(int aSide) {
+ return (byte) ForgeDirection.getOrientation(aSide).getOpposite().ordinal();
+ }
+
+ public static byte getTier(long l) {
+ byte i = -1;
+ while (++i < V.length) if (l <= V[i]) return i;
+ return i;
+ }
+
+ public static void sendChatToPlayer(EntityPlayer aPlayer, String aChatMessage) {
+ if (aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
+ aPlayer.addChatComponentMessage(new ChatComponentText(aChatMessage));
+ }
+ }
+
+ public static void checkAvailabilities() {
+ if (CHECK_ALL) {
+ try {
+ Class tClass = IItemDuct.class;
+ tClass.getCanonicalName();
+ TE_CHECK = true;
+ } catch (Throwable e) {/**/}
+ try {
+ Class tClass = buildcraft.api.transport.IPipeTile.class;
+ tClass.getCanonicalName();
+ BC_CHECK = true;
+ } catch (Throwable e) {/**/}
+ try {
+ Class tClass = cofh.api.energy.IEnergyReceiver.class;
+ tClass.getCanonicalName();
+ RF_CHECK = true;
+ } catch (Throwable e) {/**/}
+ CHECK_ALL = false;
+ }
+ }
+
+ public static boolean isConnectableNonInventoryPipe(Object aTileEntity, int aSide) {
+ if (aTileEntity == null) return false;
+ checkAvailabilities();
+ if (TE_CHECK && aTileEntity instanceof IItemDuct) return true;
+ if (BC_CHECK && aTileEntity instanceof buildcraft.api.transport.IPipeTile)
+ return ((buildcraft.api.transport.IPipeTile) aTileEntity).isPipeConnected(ForgeDirection.getOrientation(aSide));
+ if (GregTech_API.mTranslocator && aTileEntity instanceof codechicken.translocator.TileItemTranslocator) return true;
+
+ return false;
+ }
+ /**
+ * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ return moveStackIntoPipe(aTileEntity1, aTileEntity2, aGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
+ }
+
+ /**
+ * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean dropItem) {
+ if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+ if (aTileEntity2 != null) {
+ checkAvailabilities();
+ if (TE_CHECK && aTileEntity2 instanceof IItemDuct) {
+ for (int i = 0; i < aGrabSlots.length; i++) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
+ byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize));
+ if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) {
+ //((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F);
+ aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
+ aTileEntity1.markDirty();
+ return tMovedItemCount;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+ }
+ if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) {
+ for (int i = 0; i < aGrabSlots.length; i++) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copy(tStack), false, ForgeDirection.getOrientation(aPutTo));
+ if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) {
+ tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo)));
+ aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
+ aTileEntity1.markDirty();
+ return tMovedItemCount;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+ }
+ }
+
+ ForgeDirection tDirection = ForgeDirection.getOrientation(aGrabFrom);
+ if (aTileEntity1 instanceof TileEntity && tDirection != ForgeDirection.UNKNOWN && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) {
+ int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ;
+ if (!hasBlockHitBox(((TileEntity) aTileEntity1).getWorldObj(), tX, tY, tZ) && dropItem) {
+ for (int i = 0; i < aGrabSlots.length; i++) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlots[i]), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
+ if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
+ ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
+ EntityItem tEntity = new EntityItem(((TileEntity) aTileEntity1).getWorldObj(), tX + 0.5, tY + 0.5, tZ + 0.5, tStack);
+ tEntity.motionX = tEntity.motionY = tEntity.motionZ = 0;
+ ((TileEntity) aTileEntity1).getWorldObj().spawnEntityInWorld(tEntity);
+ aTileEntity1.decrStackSize(aGrabSlots[i], tStack.stackSize);
+ aTileEntity1.markDirty();
+ return (byte) tStack.stackSize;
+ }
+ }
+ }
+ }
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed. (useful for internal Inventory Operations)
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+
+ ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), tStack3 = null;
+ if (tStack1 != null) {
+ if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0;
+ tStack3 = copy(tStack1);
+ aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, Math.min(tStack3.getMaxStackSize(), Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), aTileEntity2.getInventoryStackLimit())));
+ tStack3.stackSize = Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize));
+ if (tStack3.stackSize > aMaxMoveAtOnce) tStack3.stackSize = aMaxMoveAtOnce;
+ if (tStack3.stackSize + (tStack2 == null ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(), aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) {
+ tStack3 = aTileEntity1.decrStackSize(aGrabFrom, tStack3.stackSize);
+ aTileEntity1.markDirty();
+ if (tStack3 != null) {
+ if (tStack2 == null) {
+ aTileEntity2.setInventorySlotContents(aPutTo, copy(tStack3));
+ aTileEntity2.markDirty();
+ } else {
+ tStack2.stackSize += tStack3.stackSize;
+ aTileEntity2.markDirty();
+ }
+ return (byte) tStack3.stackSize;
+ }
+ }
+ }
+ return 0;
+ }
+
+ public static boolean isAllowedToTakeFromSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack) {
+ if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) {
+ return isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 0, aStack)
+ || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 1, aStack)
+ || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 2, aStack)
+ || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 3, aStack)
+ || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 4, aStack)
+ || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 5, aStack);
+ }
+ if (aTileEntity instanceof ISidedInventory)
+ return ((ISidedInventory) aTileEntity).canExtractItem(aSlot, aStack, aSide);
+ return true;
+ }
+
+ public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack, byte aMaxStackSize) {
+ ItemStack tStack = aTileEntity.getStackInSlot(aSlot);
+ if (tStack != null && (!areStacksEqual(tStack, aStack) || tStack.stackSize >= tStack.getMaxStackSize()))
+ return false;
+ if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) {
+ return isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 0, aStack, aMaxStackSize)
+ || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 1, aStack, aMaxStackSize)
+ || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 2, aStack, aMaxStackSize)
+ || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 3, aStack, aMaxStackSize)
+ || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 4, aStack, aMaxStackSize)
+ || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 5, aStack, aMaxStackSize);
+ }
+ if (aTileEntity instanceof ISidedInventory && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, aSide))
+ return false;
+ return aSlot < aTileEntity.getSizeInventory() && aTileEntity.isItemValidForSlot(aSlot, aStack);
+ }
+
+ /**
+ * Moves Stack from Inv-Side to Inv-Side.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ if (aTileEntity1 instanceof IInventory)
+ return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
+ return 0;
+ }
+
+ /**
+ * This is only because I needed an additional Parameter for the Double Chest Check.
+ */
+ private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) {
+ if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+
+ int[] tGrabSlots = null;
+ if (aTileEntity1 instanceof ISidedInventory)
+ tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);
+ if (tGrabSlots == null) {
+ tGrabSlots = new int[aTileEntity1.getSizeInventory()];
+ for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
+ }
+
+ if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) {
+ int[] tPutSlots = null;
+ if (aTileEntity2 instanceof ISidedInventory)
+ tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo);
+
+ if (tPutSlots == null) {
+ tPutSlots = new int[((IInventory) aTileEntity2).getSizeInventory()];
+ for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i;
+ }
+
+ for (int i = 0; i < tGrabSlots.length; i++) {
+ byte tMovedItemCount = 0;
+ for (int j = 0; j < tPutSlots.length; j++) {
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) {
+ if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
+ tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
+ if (tMovedItemCount >= aMaxMoveAtOnce) {
+ return tMovedItemCount;
+
+ }
+ }
+ }
+ }
+ }
+ if (tMovedItemCount > 0) return tMovedItemCount;
+ }
+
+ if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) {
+ TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1;
+ if (tTileEntity1.adjacentChestChecked) {
+ byte tAmount = 0;
+ if (tTileEntity1.adjacentChestXNeg != null) {
+ tAmount = moveOneItemStack(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity1.adjacentChestZNeg != null) {
+ tAmount = moveOneItemStack(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity1.adjacentChestXPos != null) {
+ tAmount = moveOneItemStack(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity1.adjacentChestZPos != null) {
+ tAmount = moveOneItemStack(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ }
+ if (tAmount != 0) return tAmount;
+ }
+ }
+ if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) {
+ TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2;
+ if (tTileEntity2.adjacentChestChecked) {
+ byte tAmount = 0;
+ if (tTileEntity2.adjacentChestXNeg != null) {
+ tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestZNeg != null) {
+ tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestXPos != null) {
+ tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestZPos != null) {
+ tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ }
+ if (tAmount != 0) return tAmount;
+ }
+ }
+ }
+
+ return moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests);
+ }
+
+ /**
+ * Moves Stack from Inv-Side to Inv-Slot.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ if (aTileEntity1 == null || !(aTileEntity1 instanceof IInventory) || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+
+ int[] tGrabSlots = null;
+ if (aTileEntity1 instanceof ISidedInventory)
+ tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);
+ if (tGrabSlots == null) {
+ tGrabSlots = new int[((IInventory) aTileEntity1).getSizeInventory()];
+ for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
+ }
+
+ if (aTileEntity2 instanceof IInventory) {
+ for (int i = 0; i < tGrabSlots.length; i++) {
+ if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) {
+ if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, aPutTo, (byte) 6, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) {
+ byte tMovedItemCount = moveStackFromSlotAToSlotB((IInventory) aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
+ if (tMovedItemCount > 0) return tMovedItemCount;
+ }
+ }
+ }
+ }
+ }
+
+ moveStackIntoPipe(((IInventory) aTileEntity1), aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
+ return 0;
+ }
+
+ /**
+ * Moves Stack from Inv-Slot to Inv-Slot.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveFromSlotToSlot(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ if (aTileEntity1 == null || aTileEntity2 == null || aGrabFrom < 0 || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+ if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabFrom), true, aInvertFilter)) {
+ if (isAllowedToTakeFromSlot(aTileEntity1, aGrabFrom, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom))) {
+ if (isAllowedToPutIntoSlot(aTileEntity2, aPutTo, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) {
+ byte tMovedItemCount = moveStackFromSlotAToSlotB(aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
+ if (tMovedItemCount > 0) return tMovedItemCount;
+ }
+ }
+ }
+ return 0;
+ }
+
+ public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) {
+ if (aStack == null || aStack.stackSize < 1) return false;
+ if (aList == null) return aTIfListEmpty;
+ while (aList.contains(null)) aList.remove(null);
+ if (aList.size() < 1) return aTIfListEmpty;
+ Iterator<ItemStack> tIterator = aList.iterator();
+ ItemStack tStack = null;
+ while (tIterator.hasNext())
+ if ((tStack = tIterator.next()) != null && areStacksEqual(aStack, tStack)) return !aInvertFilter;
+ return aInvertFilter;
+ }
+
+ public static boolean areStacksOrToolsEqual(ItemStack aStack1, ItemStack aStack2) {
+ if (aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem()) {
+ if (aStack1.getItem().isDamageable()) return true;
+ return ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound())) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
+ }
+ return false;
+ }
+
+ public static boolean areFluidsEqual(FluidStack aFluid1, FluidStack aFluid2) {
+ return areFluidsEqual(aFluid1, aFluid2, false);
+ }
+
+ public static boolean areFluidsEqual(FluidStack aFluid1, FluidStack aFluid2, boolean aIgnoreNBT) {
+ return aFluid1 != null && aFluid2 != null && aFluid1.getFluid() == aFluid2.getFluid() && (aIgnoreNBT || ((aFluid1.tag == null) == (aFluid2.tag == null)) && (aFluid1.tag == null || aFluid1.tag.equals(aFluid2.tag)));
+ }
+
+ public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2) {
+ return areStacksEqual(aStack1, aStack2, false);
+ }
+
+ public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) {
+ return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem() && (aIgnoreNBT || ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound()))) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W);
+ }
+
+ public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2) {
+ return areUnificationsEqual(aStack1, aStack2, false);
+ }
+
+ public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) {
+ return areStacksEqual(GT_OreDictUnificator.get(aStack1), GT_OreDictUnificator.get(aStack2), aIgnoreNBT);
+ }
+
+ public static String getFluidName(Fluid aFluid, boolean aLocalized) {
+ if (aFluid == null) return E;
+ String rName = aLocalized ? aFluid.getLocalizedName(new FluidStack(aFluid, 0)) : aFluid.getUnlocalizedName();
+ if (rName.contains("fluid.") || rName.contains("tile."))
+ return capitalizeString(rName.replaceAll("fluid.", E).replaceAll("tile.", E));
+ return rName;
+ }
+
+ public static String getFluidName(FluidStack aFluid, boolean aLocalized) {
+ if (aFluid == null) return E;
+ return getFluidName(aFluid.getFluid(), aLocalized);
+ }
+
+ public static void reInit() {
+ sFilledContainerToData.clear();
+ sEmptyContainerToFluidToData.clear();
+ for (FluidContainerData tData : sFluidContainerList) {
+ sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData);
+ Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer));
+ if (tFluidToContainer == null) {
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
+ GregTech_API.sFluidMappings.add(tFluidToContainer);
+ }
+ tFluidToContainer.put(tData.fluid.getFluid(), tData);
+ }
+ }
+
+ public static void addFluidContainerData(FluidContainerData aData) {
+ sFluidContainerList.add(aData);
+ sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData);
+ Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer));
+ if (tFluidToContainer == null) {
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
+ GregTech_API.sFluidMappings.add(tFluidToContainer);
+ }
+ tFluidToContainer.put(aData.fluid.getFluid(), aData);
+ }
+
+ public static ItemStack fillFluidContainer(FluidStack aFluid, ItemStack aStack, boolean aRemoveFluidDirectly, boolean aCheckIFluidContainerItems) {
+ if (isStackInvalid(aStack) || aFluid == null) return null;
+ if (GT_ModHandler.isWater(aFluid) && ItemList.Bottle_Empty.isStackEqual(aStack)) {
+ if (aFluid.amount >= 250) {
+ if (aRemoveFluidDirectly) aFluid.amount -= 250;
+ return new ItemStack(Items.potionitem, 1, 0);
+ }
+ return null;
+ }
+ if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getFluid(aStack) == null && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) <= aFluid.amount) {
+ if (aRemoveFluidDirectly)
+ aFluid.amount -= ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true);
+ else
+ ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true);
+ return aStack;
+ }
+ Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aStack));
+ if (tFluidToContainer == null) return null;
+ FluidContainerData tData = tFluidToContainer.get(aFluid.getFluid());
+ if (tData == null || tData.fluid.amount > aFluid.amount) return null;
+ if (aRemoveFluidDirectly) aFluid.amount -= tData.fluid.amount;
+ return copyAmount(1, tData.filledContainer);
+ }
+
+ public static ItemStack getFluidDisplayStack(Fluid aFluid) {
+ return aFluid == null ? null : getFluidDisplayStack(new FluidStack(aFluid, 0), false);
+ }
+
+ public static ItemStack getFluidDisplayStack(FluidStack aFluid, boolean aUseStackSize) {
+ if (aFluid == null || aFluid.getFluid() == null) return null;
+ int tmp = 0;
+ try {
+ tmp = aFluid.getFluid().getID();
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ //ItemStack rStack = ItemList.Display_Fluid.getWithDamage(aUseStackSize ? aFluid.amount / 1000 : 1, tmp);
+ ItemStack rStack = ItemList.Display_Fluid.getWithDamage(1, tmp);
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setLong("mFluidDisplayAmount", aFluid.amount);
+ tNBT.setLong("mFluidDisplayHeat", aFluid.getFluid().getTemperature(aFluid));
+ tNBT.setBoolean("mFluidState", aFluid.getFluid().isGaseous(aFluid));
+ rStack.setTagCompound(tNBT);
+ return rStack;
+ }
+
+ public static boolean containsFluid(ItemStack aStack, FluidStack aFluid, boolean aCheckIFluidContainerItems) {
+ if (isStackInvalid(aStack) || aFluid == null) return false;
+ if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)
+ return aFluid.isFluidEqual(((IFluidContainerItem) aStack.getItem()).getFluid(aStack = copyAmount(1, aStack)));
+ FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
+ return tData == null ? false : tData.fluid.isFluidEqual(aFluid);
+ }
+
+ public static FluidStack getFluidForFilledItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
+ if (isStackInvalid(aStack)) return null;
+ if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)
+ return ((IFluidContainerItem) aStack.getItem()).drain(copyAmount(1, aStack), Integer.MAX_VALUE, true);
+ FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
+ return tData == null ? null : tData.fluid.copy();
+ }
+
+ public static ItemStack getContainerForFilledItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
+ if (isStackInvalid(aStack)) return null;
+ FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack));
+ if (tData != null) return copyAmount(1, tData.emptyContainer);
+ if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) {
+ ((IFluidContainerItem) aStack.getItem()).drain(aStack = copyAmount(1, aStack), Integer.MAX_VALUE, true);
+ return aStack;
+ }
+ return null;
+ }
+
+ public static ItemStack getContainerItem(ItemStack aStack, boolean aCheckIFluidContainerItems) {
+ if (isStackInvalid(aStack)) return null;
+ if (aStack.getItem().hasContainerItem(aStack)) return aStack.getItem().getContainerItem(aStack);
+ /** These are all special Cases, in which it is intended to have only GT Blocks outputting those Container Items */
+ if (ItemList.Cell_Empty.isStackEqual(aStack, false, true)) return null;
+ if (ItemList.IC2_Fuel_Can_Filled.isStackEqual(aStack, false, true)) return ItemList.IC2_Fuel_Can_Empty.get(1);
+ if (aStack.getItem() == Items.potionitem || aStack.getItem() == Items.experience_bottle || ItemList.TF_Vial_FieryBlood.isStackEqual(aStack) || ItemList.TF_Vial_FieryTears.isStackEqual(aStack))
+ return ItemList.Bottle_Empty.get(1);
+
+ if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) {
+ ItemStack tStack = copyAmount(1, aStack);
+ ((IFluidContainerItem) aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true);
+ if (!areStacksEqual(aStack, tStack)) return tStack;
+ return null;
+ }
+
+ int tCapsuleCount = GT_ModHandler.getCapsuleCellContainerCount(aStack);
+ if (tCapsuleCount > 0) return ItemList.Cell_Empty.get(tCapsuleCount);
+
+ if (ItemList.IC2_ForgeHammer.isStackEqual(aStack) || ItemList.IC2_WireCutter.isStackEqual(aStack))
+ return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack);
+ return null;
+ }
+
+ public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){
+ if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false;
+ boolean rReturn = false;
+ Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator();
+ aOutput = GT_OreDictUnificator.get(aOutput);
+ while (tIterator.hasNext()) {
+ Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> tEntry = tIterator.next();
+ if (aInput == null || tEntry.getKey().matches(aContainer, aInput)) {
+ List<ItemStack> tList = tEntry.getValue().items;
+ if (tList != null) for (ItemStack tOutput : tList)
+ if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) {
+ tIterator.remove();
+ rReturn = true;
+ break;
+ }
+ }
+ }
+ return rReturn;
+ }
+
+ public static synchronized boolean removeSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, ItemStack aOutput) {
+ if ((isStackInvalid(aInput) && isStackInvalid(aOutput)) || aRecipeList == null) return false;
+ boolean rReturn = false;
+ Iterator<Map.Entry<IRecipeInput, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator();
+ aOutput = GT_OreDictUnificator.get(aOutput);
+ while (tIterator.hasNext()) {
+ Map.Entry<IRecipeInput, RecipeOutput> tEntry = tIterator.next();
+ if (aInput == null || tEntry.getKey().matches(aInput)) {
+ List<ItemStack> tList = tEntry.getValue().items;
+ if (tList != null) for (ItemStack tOutput : tList)
+ if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) {
+ tIterator.remove();
+ rReturn = true;
+ break;
+ }
+ }
+ }
+ return rReturn;
+ }
+
+ public static boolean addSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, NBTTagCompound aNBT, Object... aOutput) {
+ if (isStackInvalid(aInput) || aOutput.length == 0 || aRecipeList == null) return false;
+ ItemData tOreName = GT_OreDictUnificator.getAssociation(aInput);
+ for (int i = 0; i < aOutput.length; i++) {
+ if (aOutput[i] == null) {
+ GT_FML_LOGGER.info("EmptyIC2Output!" + aInput.getUnlocalizedName());
+ return false;
+ }
+ }
+ ItemStack[] tStack = GT_OreDictUnificator.getStackArray(true, aOutput);
+ if(tStack==null||(tStack.length>0&&GT_Utility.areStacksEqual(aInput, tStack[0])))return false;
+ if (tOreName != null) {
+ if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false;
+ aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack));
+ } else {
+ aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack));
+ }
+ return true;
+ }
+
+ public static ItemStack getWrittenBook(String aMapping, ItemStack aStackToPutNBT) {
+ if (isStringInvalid(aMapping)) return null;
+ ItemStack rStack = GregTech_API.sBookList.get(aMapping);
+ if (rStack == null) return aStackToPutNBT;
+ if (aStackToPutNBT != null) {
+ aStackToPutNBT.setTagCompound(rStack.getTagCompound());
+ return aStackToPutNBT;
+ }
+ return copyAmount(1, rStack);
+ }
+
+ public static ItemStack getWrittenBook(String aMapping, String aTitle, String aAuthor, String... aPages) {
+ if (isStringInvalid(aMapping)) return null;
+ ItemStack rStack = GregTech_API.sBookList.get(aMapping);
+ if (rStack != null) return copyAmount(1, rStack);
+ if (isStringInvalid(aTitle) || isStringInvalid(aAuthor) || aPages.length <= 0) return null;
+ sBookCount++;
+ rStack = new ItemStack(Items.written_book, 1);
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setString("title", GT_LanguageManager.addStringLocalization("Book." + aTitle + ".Name", aTitle));
+ tNBT.setString("author", aAuthor);
+ NBTTagList tNBTList = new NBTTagList();
+ for (byte i = 0; i < aPages.length; i++) {
+ aPages[i] = GT_LanguageManager.addStringLocalization("Book." + aTitle + ".Page" + ((i < 10) ? "0" + i : i), aPages[i]);
+ if (i < 48) {
+ if (aPages[i].length() < 256)
+ tNBTList.appendTag(new NBTTagString(aPages[i]));
+ else
+ GT_Log.err.println("WARNING: String for written Book too long! -> " + aPages[i]);
+ } else {
+ GT_Log.err.println("WARNING: Too much Pages for written Book! -> " + aTitle);
+ break;
+ }
+ }
+ tNBTList.appendTag(new NBTTagString("Credits to " + aAuthor + " for writing this Book. This was Book Nr. " + sBookCount + " at its creation. Gotta get 'em all!"));
+ tNBT.setTag("pages", tNBTList);
+ rStack.setTagCompound(tNBT);
+ GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + "' - Author: '" + aAuthor + "'");
+ GregTech_API.sBookList.put(aMapping, rStack);
+ return copy(rStack);
+ }
+
+ public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength) {
+ return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer());
+ }
+
+ public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) {
+ if (aEntity == null) return false;
+ return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ);
+ }
+
+ public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) {
+ return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ);
+ }
+
+ public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) {
+ if (isStringInvalid(aSoundName) || !FMLCommonHandler.instance().getEffectiveSide().isClient() || GT.getThePlayer() == null || !GT.getThePlayer().worldObj.isRemote)
+ return false;
+ if (GregTech_API.sMultiThreadedSounds)
+ new Thread(new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation), "Sound Effect").start();
+ else
+ new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation).run();
+ return true;
+ }
+
+ public static boolean sendSoundToPlayers(World aWorld, String aSoundName, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) {
+ if (isStringInvalid(aSoundName) || aWorld == null || aWorld.isRemote) return false;
+ NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(aSoundName, aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ);
+ return true;
+ }
+
+ public static int stackToInt(ItemStack aStack) {
+ if (isStackInvalid(aStack)) return 0;
+ return Item.getIdFromItem(aStack.getItem()) | (Items.feather.getDamage(aStack) << 16);
+ }
+
+ public static int stackToWildcard(ItemStack aStack) {
+ if (isStackInvalid(aStack)) return 0;
+ return Item.getIdFromItem(aStack.getItem()) | (W << 16);
+ }
+
+ public static ItemStack intToStack(int aStack) {
+ int tID = aStack & (~0 >>> 16), tMeta = aStack >>> 16;
+ Item tItem = Item.getItemById(tID);
+ if (tItem != null) return new ItemStack(tItem, 1, tMeta);
+ return null;
+ }
+
+ public static Integer[] stacksToIntegerArray(ItemStack... aStacks) {
+ Integer[] rArray = new Integer[aStacks.length];
+ for (int i = 0; i < rArray.length; i++) {
+ rArray[i] = stackToInt(aStacks[i]);
+ }
+ return rArray;
+ }
+
+ public static int[] stacksToIntArray(ItemStack... aStacks) {
+ int[] rArray = new int[aStacks.length];
+ for (int i = 0; i < rArray.length; i++) {
+ rArray[i] = stackToInt(aStacks[i]);
+ }
+ return rArray;
+ }
+
+ public static boolean arrayContains(Object aObject, Object... aObjects) {
+ return listContains(aObject, Arrays.asList(aObjects));
+ }
+
+ public static boolean listContains(Object aObject, Collection aObjects) {
+ if (aObjects == null) return false;
+ return aObjects.contains(aObject);
+ }
+
+ public static <T> boolean arrayContainsNonNull(T... aArray) {
+ if (aArray != null) for (Object tObject : aArray) if (tObject != null) return true;
+ return false;
+ }
+
+ public static <T> ArrayList<T> getArrayListWithoutNulls(T... aArray) {
+ if (aArray == null) return new ArrayList<T>();
+ ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
+ for (int i = 0; i < rList.size(); i++) if (rList.get(i) == null) rList.remove(i--);
+ return rList;
+ }
+
+ public static <T> ArrayList<T> getArrayListWithoutTrailingNulls(T... aArray) {
+ if (aArray == null) return new ArrayList<T>();
+ ArrayList<T> rList = new ArrayList<T>(Arrays.asList(aArray));
+ for (int i = rList.size() - 1; i >= 0 && rList.get(i) == null; ) rList.remove(i--);
+ return rList;
+ }
+
+ public static Block getBlock(Object aBlock) {
+ return (Block) aBlock;
+ }
+
+ public static Block getBlockFromStack(ItemStack itemStack) {
+ if (isStackInvalid(itemStack)) return Blocks.air;
+ return getBlockFromItem(itemStack.getItem());
+ }
+
+ public static Block getBlockFromItem(Item item) {
+ return Block.getBlockFromItem(item);
+ }
+
+ public static boolean isBlockValid(Object aBlock) {
+ return (aBlock instanceof Block);
+ }
+
+ public static boolean isBlockInvalid(Object aBlock) {
+ return aBlock == null || !(aBlock instanceof Block);
+ }
+
+ public static boolean isStringValid(Object aString) {
+ return aString != null && !aString.toString().isEmpty();
+ }
+
+ public static boolean isStringInvalid(Object aString) {
+ return aString == null || aString.toString().isEmpty();
+ }
+
+ public static boolean isStackValid(Object aStack) {
+ return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
+ }
+
+ public static boolean isStackInvalid(Object aStack) {
+ return aStack == null || !(aStack instanceof ItemStack) || ((ItemStack) aStack).getItem() == null || ((ItemStack) aStack).stackSize < 0;
+ }
+
+ public static boolean isDebugItem(ItemStack aStack) {
+ return /*ItemList.Armor_Cheat.isStackEqual(aStack, T, T) || */areStacksEqual(GT_ModHandler.getIC2Item("debug", 1), aStack, true);
+ }
+
+ public static ItemStack updateItemStack(ItemStack aStack) {
+ if (isStackValid(aStack) && aStack.getItem() instanceof GT_Generic_Item)
+ ((GT_Generic_Item) aStack.getItem()).isItemStackUsable(aStack);
+ return aStack;
+ }
+
+ public static boolean isOpaqueBlock(World aWorld, int aX, int aY, int aZ) {
+ return aWorld.getBlock(aX, aY, aZ).isOpaqueCube();
+ }
+
+ public static boolean isBlockAir(World aWorld, int aX, int aY, int aZ) {
+ return aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ);
+ }
+
+ public static boolean hasBlockHitBox(World aWorld, int aX, int aY, int aZ) {
+ return aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null;
+ }
+
+ public static void setCoordsOnFire(World aWorld, int aX, int aY, int aZ, boolean aReplaceCenter) {
+ if (aReplaceCenter)
+ if (aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) == null)
+ aWorld.setBlock(aX, aY, aZ, Blocks.fire);
+ if (aWorld.getBlock(aX + 1, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX + 1, aY, aZ) == null)
+ aWorld.setBlock(aX + 1, aY, aZ, Blocks.fire);
+ if (aWorld.getBlock(aX - 1, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX - 1, aY, aZ) == null)
+ aWorld.setBlock(aX - 1, aY, aZ, Blocks.fire);
+ if (aWorld.getBlock(aX, aY + 1, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY + 1, aZ) == null)
+ aWorld.setBlock(aX, aY + 1, aZ, Blocks.fire);
+ if (aWorld.getBlock(aX, aY - 1, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY - 1, aZ) == null)
+ aWorld.setBlock(aX, aY - 1, aZ, Blocks.fire);
+ if (aWorld.getBlock(aX, aY, aZ + 1).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ + 1) == null)
+ aWorld.setBlock(aX, aY, aZ + 1, Blocks.fire);
+ if (aWorld.getBlock(aX, aY, aZ - 1).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ - 1) == null)
+ aWorld.setBlock(aX, aY, aZ - 1, Blocks.fire);
+ }
+
+ public static ItemStack getProjectile(SubTag aProjectileType, IInventory aInventory) {
+ if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) {
+ ItemStack rStack = aInventory.getStackInSlot(i);
+ if (isStackValid(rStack) && rStack.getItem() instanceof IProjectileItem && ((IProjectileItem) rStack.getItem()).hasProjectile(aProjectileType, rStack))
+ return updateItemStack(rStack);
+ }
+ return null;
+ }
+
+ public static void removeNullStacksFromInventory(IInventory aInventory) {
+ if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) {
+ ItemStack tStack = aInventory.getStackInSlot(i);
+ if (tStack != null && (tStack.stackSize == 0 || tStack.getItem() == null))
+ aInventory.setInventorySlotContents(i, null);
+ }
+ }
+
+ /**
+ * Initializes new empty texture page for casings
+ * page 0 is old CASING_BLOCKS
+ *
+ * Then casings should be registered like this:
+ * for (byte i = MIN_USED_META; i < MAX_USED_META; i = (byte) (i + 1)) {
+ * Textures.BlockIcons.casingTexturePages[PAGE][i+START_INDEX] = new GT_CopiedBlockTexture(this, 6, i);
+ * }
+ *
+ * @param page 0 to 127
+ * @return true if it made empty page, false if one already existed...
+ */
+ public static boolean addTexturePage(byte page){
+ if(Textures.BlockIcons.casingTexturePages[page]==null){
+ Textures.BlockIcons.casingTexturePages[page]=new ITexture[128];
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return texture id from page and index, for use when determining hatches, but can also be precomputed from:
+ * (page<<7)+index
+ * @param page 0 to 127 page
+ * @param index 0 to 127 texture index
+ * @return casing texture 0 to 16383
+ */
+ public static int getTextureId(byte page,byte index){
+ if(page>=0 && index>=0){
+ return (page<<7)+index;
+ }
+ throw new RuntimeException("Index out of range: ["+page+"]["+index+"]");
+ }
+
+ /**
+ * Return texture id from page and index, for use when determining hatches, but can also be precomputed from:
+ * (page<<7)+index
+ * @param page 0 to 127 page
+ * @param startIndex 0 to 127 start texture index
+ * @param blockMeta meta of the block
+ * @return casing texture 0 to 16383
+ */
+ public static int getTextureId(byte page,byte startIndex,byte blockMeta){
+ if(page>=0 && startIndex>=0 && blockMeta>=0 && (startIndex+blockMeta)<=127){
+ return (page<<7)+(startIndex+blockMeta);
+ }
+ throw new RuntimeException("Index out of range: ["+page+"]["+startIndex+"+"+blockMeta+"="+(startIndex+blockMeta)+"]");
+ }
+
+ /**
+ * Return texture id from item stack, unoptimized but readable?
+ * @return casing texture 0 to 16383
+ */
+ @Deprecated
+ public static int getTextureId(ItemStack stack){
+ return getTextureId(Block.getBlockFromItem(stack.getItem()),(byte)stack.getItemDamage());
+ }
+
+ /**
+ * Return texture id from item stack, unoptimized but readable?
+ * @return casing texture 0 to 16383
+ */
+ public static int getTextureId(Block blockFromBlock,byte metaFromBlock){
+ for (int page = 0; page < Textures.BlockIcons.casingTexturePages.length; page++) {
+ ITexture[] casingTexturePage = Textures.BlockIcons.casingTexturePages[page];
+ if(casingTexturePage!=null){
+ for (int index = 0; index < casingTexturePage.length; index++) {
+ ITexture iTexture = casingTexturePage[index];
+ if(iTexture instanceof GT_CopiedBlockTexture){
+ Block block = ((GT_CopiedBlockTexture) iTexture).getBlock();
+ byte meta = ((GT_CopiedBlockTexture) iTexture).getMeta();
+ if(meta==metaFromBlock && blockFromBlock==block){
+ return (page<<7)+index;
+ }
+ }
+ }
+ }
+ }
+ throw new RuntimeException("Probably missing mapping or different texture class used for: "+
+ blockFromBlock.getUnlocalizedName()+" meta:"+metaFromBlock);
+ }
+
+ /**
+ * Converts a Number to a String
+ */
+ public static String parseNumberToString(int aNumber) {
+ boolean temp = true, negative = false;
+
+ if (aNumber < 0) {
+ aNumber *= -1;
+ negative = true;
+ }
+
+ StringBuilder tStringB = new StringBuilder();
+ for (int i = 1000000000; i > 0; i /= 10) {
+ int tDigit = (aNumber / i) % 10;
+ if (temp && tDigit != 0) temp = false;
+ if (!temp) {
+ tStringB.append(tDigit);
+ if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(",");
+ }
+ }
+
+ String tString = tStringB.toString();
+
+ if (tString.equals(E)) tString = "0";
+
+ return negative ? "-" + tString : tString;
+ }
+
+ public static NBTTagCompound getNBTContainingBoolean(NBTTagCompound aNBT, Object aTag, boolean aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setBoolean(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingByte(NBTTagCompound aNBT, Object aTag, byte aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setByte(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingShort(NBTTagCompound aNBT, Object aTag, short aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setShort(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingInteger(NBTTagCompound aNBT, Object aTag, int aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setInteger(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingFloat(NBTTagCompound aNBT, Object aTag, float aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setFloat(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingDouble(NBTTagCompound aNBT, Object aTag, double aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ aNBT.setDouble(aTag.toString(), aValue);
+ return aNBT;
+ }
+
+ public static NBTTagCompound getNBTContainingString(NBTTagCompound aNBT, Object aTag, Object aValue) {
+ if (aNBT == null) aNBT = new NBTTagCompound();
+ if (aValue == null) return aNBT;
+ aNBT.setString(aTag.toString(), aValue.toString());
+ return aNBT;
+ }
+
+ public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sFrostHazmatList)) return false;
+ return true;
+ }
+
+ public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sHeatHazmatList)) return false;
+ return true;
+ }
+
+ public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sBioHazmatList)) return false;
+ return true;
+ }
+
+ public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sRadioHazmatList)) return false;
+ return true;
+ }
+
+ public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sElectroHazmatList)) return false;
+ return true;
+ }
+
+ public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) {
+ for (byte i = 1; i < 5; i++)
+ if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sGasHazmatList)) return false;
+ return true;
+ }
+
+ public static float getHeatDamageFromItem(ItemStack aStack) {
+ ItemData tData = GT_OreDictUnificator.getItemData(aStack);
+ return tData == null ? 0 : (tData.mPrefix == null ? 0 : tData.mPrefix.mHeatDamage) + (tData.hasValidMaterialData() ? tData.mMaterial.mMaterial.mHeatDamage : 0);
+ }
+
+ public static int getRadioactivityLevel(ItemStack aStack) {
+ ItemData tData = GT_OreDictUnificator.getItemData(aStack);
+ if (tData != null && tData.hasValidMaterialData()) {
+ if (tData.mMaterial.mMaterial.mEnchantmentArmors instanceof Enchantment_Radioactivity)
+ return tData.mMaterial.mMaterial.mEnchantmentArmorsLevel;
+ if (tData.mMaterial.mMaterial.mEnchantmentTools instanceof Enchantment_Radioactivity)
+ return tData.mMaterial.mMaterial.mEnchantmentToolsLevel;
+ }
+ return EnchantmentHelper.getEnchantmentLevel(Enchantment_Radioactivity.INSTANCE.effectId, aStack);
+ }
+
+ public static boolean isImmuneToBreathingGasses(EntityLivingBase aEntity) {
+ return isWearingFullGasHazmat(aEntity);
+ }
+
+ public static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage) {
+ if (aDamage > 0 && aEntity != null && aEntity.getActivePotionEffect(Potion.fireResistance) == null && !isWearingFullHeatHazmat(aEntity)) {
+ aEntity.attackEntityFrom(GT_DamageSources.getHeatDamage(), aDamage);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean applyFrostDamage(EntityLivingBase aEntity, float aDamage) {
+ if (aDamage > 0 && aEntity != null && !isWearingFullFrostHazmat(aEntity)) {
+ aEntity.attackEntityFrom(GT_DamageSources.getFrostDamage(), aDamage);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean applyElectricityDamage(EntityLivingBase aEntity, long aVoltage, long aAmperage) {
+ long aDamage = getTier(aVoltage) * aAmperage * 4;
+ if (aDamage > 0 && aEntity != null && !isWearingFullElectroHazmat(aEntity)) {
+ aEntity.attackEntityFrom(GT_DamageSources.getElectricDamage(), aDamage);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) {
+ if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !isWearingFullRadioHazmat(aEntity)) {
+ PotionEffect tEffect = null;
+ aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ aEntity.addPotionEffect(new PotionEffect(24 /* IC2 Radiation */, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7)));
+ return true;
+ }
+ return false;
+ }
+
+ public static ItemStack setStack(Object aSetStack, Object aToStack) {
+ if (isStackInvalid(aSetStack) || isStackInvalid(aToStack)) return null;
+ ((ItemStack) aSetStack).func_150996_a(((ItemStack) aToStack).getItem());
+ ((ItemStack) aSetStack).stackSize = ((ItemStack) aToStack).stackSize;
+ Items.feather.setDamage((ItemStack) aSetStack, Items.feather.getDamage((ItemStack) aToStack));
+ ((ItemStack) aSetStack).setTagCompound(((ItemStack) aToStack).getTagCompound());
+ return (ItemStack) aSetStack;
+ }
+
+ public static FluidStack[] copyFluidArray(FluidStack... aStacks) {
+ FluidStack[] rStacks = new FluidStack[aStacks.length];
+ for (int i = 0; i < aStacks.length; i++) if (aStacks[i] != null) rStacks[i] = aStacks[i].copy();
+ return rStacks;
+ }
+
+ public static ItemStack[] copyStackArray(Object... aStacks) {
+ ItemStack[] rStacks = new ItemStack[aStacks.length];
+ for (int i = 0; i < aStacks.length; i++) rStacks[i] = copy(aStacks[i]);
+ return rStacks;
+ }
+
+ public static ItemStack copy(Object... aStacks) {
+ for (Object tStack : aStacks) if (isStackValid(tStack)) return ((ItemStack) tStack).copy();
+ return null;
+ }
+
+ public static ItemStack copyAmount(long aAmount, Object... aStacks) {
+ ItemStack rStack = copy(aStacks);
+ if (isStackInvalid(rStack)) return null;
+ if (aAmount > 64) aAmount = 64;
+ else if (aAmount == -1) aAmount = 111;
+ else if (aAmount < 0) aAmount = 0;
+ rStack.stackSize = (byte) aAmount;
+ return rStack;
+ }
+
+ public static ItemStack copyMetaData(long aMetaData, Object... aStacks) {
+ ItemStack rStack = copy(aStacks);
+ if (isStackInvalid(rStack)) return null;
+ Items.feather.setDamage(rStack, (short) aMetaData);
+ return rStack;
+ }
+
+ public static ItemStack copyAmountAndMetaData(long aAmount, long aMetaData, Object... aStacks) {
+ ItemStack rStack = copyAmount(aAmount, aStacks);
+ if (isStackInvalid(rStack)) return null;
+ Items.feather.setDamage(rStack, (short) aMetaData);
+ return rStack;
+ }
+
+ /**
+ * returns a copy of an ItemStack with its Stacksize being multiplied by aMultiplier
+ */
+ public static ItemStack mul(long aMultiplier, Object... aStacks) {
+ ItemStack rStack = copy(aStacks);
+ if (rStack == null) return null;
+ rStack.stackSize *= aMultiplier;
+ return rStack;
+ }
+
+ /**
+ * Loads an ItemStack properly.
+ */
+ public static ItemStack loadItem(NBTTagCompound aNBT, String aTagName) {
+ return loadItem(aNBT.getCompoundTag(aTagName));
+ }
+
+ public static FluidStack loadFluid(NBTTagCompound aNBT, String aTagName) {
+ return loadFluid(aNBT.getCompoundTag(aTagName));
+ }
+
+ /**
+ * Loads an ItemStack properly.
+ */
+ public static ItemStack loadItem(NBTTagCompound aNBT) {
+ if (aNBT == null) return null;
+ ItemStack rStack = ItemStack.loadItemStackFromNBT(aNBT);
+ try {
+ if (rStack != null && (rStack.getItem().getClass().getName().startsWith("ic2.core.migration"))) {
+ rStack.getItem().onUpdate(rStack, DW, null, 0, false);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ return GT_OreDictUnificator.get(true, rStack);
+ }
+
+ /**
+ * Loads an FluidStack properly.
+ */
+ public static FluidStack loadFluid(NBTTagCompound aNBT) {
+ if (aNBT == null) return null;
+ return FluidStack.loadFluidStackFromNBT(aNBT);
+ }
+
+ public static <E> E selectItemInList(int aIndex, E aReplacement, List<E> aList) {
+ if (aList == null || aList.isEmpty()) return aReplacement;
+ if (aList.size() <= aIndex) return aList.get(aList.size() - 1);
+ if (aIndex < 0) return aList.get(0);
+ return aList.get(aIndex);
+ }
+
+ public static <E> E selectItemInList(int aIndex, E aReplacement, E... aList) {
+ if (aList == null || aList.length == 0) return aReplacement;
+ if (aList.length <= aIndex) return aList[aList.length - 1];
+ if (aIndex < 0) return aList[0];
+ return aList[aIndex];
+ }
+
+ public static boolean isStackInList(ItemStack aStack, Collection<GT_ItemStack> aList) {
+ if (aStack == null) {
+ return false;
+ }
+ return isStackInList(new GT_ItemStack(aStack), aList);
+ }
+
+ public static boolean isStackInList(GT_ItemStack aStack, Collection<GT_ItemStack> aList) {
+ return aStack != null && (aList.contains(aStack) || aList.contains(new GT_ItemStack(aStack.mItem, aStack.mStackSize, W)));
+ }
+
+ /**
+ * re-maps all Keys of a Map after the Keys were weakened.
+ */
+ public static <X, Y> Map<X, Y> reMap(Map<X, Y> aMap) {
+ Map<X, Y> tMap = new /*Concurrent*/HashMap<X, Y>();
+ tMap.putAll(aMap);
+ aMap.clear();
+ aMap.putAll(tMap);
+ return aMap;
+ }
+
+ /**
+ * Why the fuck do neither Java nor Guava have a Function to do this?
+ */
+ public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesAcending(Map<X, Y> aMap) {
+ List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
+ Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
+ @Override
+ public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
+ return aValue1.getValue().compareTo(aValue2.getValue());
+ }
+ });
+ LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
+ for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
+ return rMap;
+ }
+
+ /**
+ * Why the fuck do neither Java nor Guava have a Function to do this?
+ */
+ public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) {
+ List<Map.Entry<X, Y>> tEntrySet = new LinkedList<Map.Entry<X, Y>>(aMap.entrySet());
+ Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() {
+ @Override
+ public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) {
+ return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
+ }
+ });
+ LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
+ for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue());
+ return rMap;
+ }
+
+ /**
+ * Translates a Material Amount into an Amount of Fluid in Fluid Material Units.
+ */
+ public static long translateMaterialToFluidAmount(long aMaterialAmount, boolean aRoundUp) {
+ return translateMaterialToAmount(aMaterialAmount, L, aRoundUp);
+ }
+
+ /**
+ * Translates a Material Amount into an Amount of Fluid. Second Parameter for things like Bucket Amounts (1000) and similar
+ */
+ public static long translateMaterialToAmount(long aMaterialAmount, long aAmountPerUnit, boolean aRoundUp) {
+ return Math.max(0, ((aMaterialAmount * aAmountPerUnit) / M) + (aRoundUp && (aMaterialAmount * aAmountPerUnit) % M > 0 ? 1 : 0));
+ }
+
+ /**
+ * This checks if the Dimension is really a Dimension and not another Planet or something.
+ * Used for my Teleporter.
+ */
+ public static boolean isRealDimension(int aDimensionID) {
+ if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true;
+ return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID);
+ }
+
+ //public static boolean isRealDimension(int aDimensionID) {
+ // try {
+ // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("com.xcompwiz.mystcraft"))
+ // return true;
+ // } catch (Throwable e) {/*Do nothing*/}
+ // try {
+ // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("TwilightForest")) return true;
+ // } catch (Throwable e) {/*Do nothing*/}
+ // try {
+ // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("galacticraft")) return true;
+ // } catch (Throwable e) {/*Do nothing*/}
+ // return GregTech_API.sDimensionalList.contains(aDimensionID);
+ //}
+
+ public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) {
+ //Credit goes to BrandonCore Author :!:
+
+ if (entity == null || entity.worldObj.isRemote) return false;
+ if (entity.ridingEntity != null) entity.mountEntity(null);
+ if (entity.riddenByEntity != null) entity.riddenByEntity.mountEntity(null);
+
+ World startWorld = entity.worldObj;
+ World destinationWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(aDimension);
+
+ if (destinationWorld == null) {return false;}
+
+ boolean interDimensional = startWorld.provider.dimensionId != destinationWorld.provider.dimensionId;
+ if(!interDimensional)return false;
+ startWorld.updateEntityWithOptionalForce(entity, false);//added
+
+ if ((entity instanceof EntityPlayerMP) && interDimensional) {
+ EntityPlayerMP player = (EntityPlayerMP) entity;
+ player.closeScreen();//added
+ player.dimension = aDimension;
+ player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, destinationWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
+ ((WorldServer) startWorld).getPlayerManager().removePlayer(player);
+
+ startWorld.playerEntities.remove(player);
+ startWorld.updateAllPlayersSleepingFlag();
+ int i = entity.chunkCoordX;
+ int j = entity.chunkCoordZ;
+ if ((entity.addedToChunk) && (startWorld.getChunkProvider().chunkExists(i, j))) {
+ startWorld.getChunkFromChunkCoords(i, j).removeEntity(entity);
+ startWorld.getChunkFromChunkCoords(i, j).isModified = true;
+ }
+ startWorld.loadedEntityList.remove(entity);
+ startWorld.onEntityRemoved(entity);
+ }
+
+ entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
+
+ ((WorldServer) destinationWorld).theChunkProviderServer.loadChunk((int) aX >> 4, (int) aZ >> 4);
+
+ destinationWorld.theProfiler.startSection("placing");
+ if (interDimensional) {
+ if (!(entity instanceof EntityPlayer)) {
+ NBTTagCompound entityNBT = new NBTTagCompound();
+ entity.isDead = false;
+ entityNBT.setString("id", EntityList.getEntityString(entity));
+ entity.writeToNBT(entityNBT);
+ entity.isDead = true;
+ entity = EntityList.createEntityFromNBT(entityNBT, destinationWorld);
+ if (entity == null) {
+ return false;
+ }
+ entity.dimension = destinationWorld.provider.dimensionId;
+ }
+ destinationWorld.spawnEntityInWorld(entity);
+ entity.setWorld(destinationWorld);
+ }
+ entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
+
+ destinationWorld.updateEntityWithOptionalForce(entity, false);
+ entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
+
+ if ((entity instanceof EntityPlayerMP)) {
+ EntityPlayerMP player = (EntityPlayerMP) entity;
+ if (interDimensional) {
+ player.mcServer.getConfigurationManager().func_72375_a(player, (WorldServer) destinationWorld);
+ }
+ player.playerNetServerHandler.setPlayerLocation(aX, aY, aZ, player.rotationYaw, player.rotationPitch);
+ }
+
+ destinationWorld.updateEntityWithOptionalForce(entity, false);
+
+ if (((entity instanceof EntityPlayerMP)) && interDimensional) {
+ EntityPlayerMP player = (EntityPlayerMP) entity;
+ player.theItemInWorldManager.setWorld((WorldServer) destinationWorld);
+ player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) destinationWorld);
+ player.mcServer.getConfigurationManager().syncPlayerInventory(player);
+
+ for (PotionEffect potionEffect : (Iterable<PotionEffect>) player.getActivePotionEffects()) {
+ player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potionEffect));
+ }
+
+ player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
+ FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, startWorld.provider.dimensionId, destinationWorld.provider.dimensionId);
+ }
+ entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch);
+
+ destinationWorld.theProfiler.endSection();
+ entity.fallDistance = 0;
+ return true;
+ }
+
+ public static int getScaleCoordinates(double aValue, int aScale) {
+ return (int)Math.floor(aValue / aScale);
+ }
+
+ public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
+ if (aList == null) return 0;
+
+ ArrayList<String> tList = new ArrayList<String>();
+ int rEUAmount = 0;
+
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+
+ Block tBlock = aWorld.getBlock(aX, aY, aZ);
+
+ tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET+ " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " D: " +EnumChatFormatting.AQUA+ aWorld.provider.dimensionId +EnumChatFormatting.RESET+ " -----");
+ try {
+ if (tTileEntity != null && tTileEntity instanceof IInventory)
+ tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
+ else
+ tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
+
+ tList.add(trans("164","Hardness: ") +EnumChatFormatting.YELLOW+ tBlock.getBlockHardness(aWorld, aX, aY, aZ) +EnumChatFormatting.RESET+ trans("165"," Blast Resistance: ") +EnumChatFormatting.YELLOW+ tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) +EnumChatFormatting.RESET);
+ if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD+ trans("166","Is valid Beacon Pyramid Material") +EnumChatFormatting.RESET);
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ if (tTileEntity != null) {
+ try {
+ if (tTileEntity instanceof IFluidHandler) {
+ rEUAmount += 500;
+ FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide));
+ if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) {
+ tList.add(trans("167","Tank ") + i + ": " +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) +EnumChatFormatting.RESET+ " L / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(tTanks[i].capacity) +EnumChatFormatting.RESET+ " L " +EnumChatFormatting.GOLD+ getFluidName(tTanks[i].fluid, true)+EnumChatFormatting.RESET);
+ }
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.reactor.IReactorChamber) {
+ rEUAmount += 500;
+ tTileEntity = (TileEntity) (((ic2.api.reactor.IReactorChamber) tTileEntity).getReactor());
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.reactor.IReactor) {
+ rEUAmount += 500;
+ tList.add(trans("168","Heat: ") +EnumChatFormatting.GREEN+ ((ic2.api.reactor.IReactor) tTileEntity).getHeat() +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+ ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()+EnumChatFormatting.RESET);
+ tList.add(trans("169","HEM: ") +EnumChatFormatting.YELLOW+((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() +EnumChatFormatting.RESET/*+ trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.tile.IWrenchable) {
+ rEUAmount += 100;
+ tList.add(trans("171","Facing: ") +EnumChatFormatting.GREEN+ ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() +EnumChatFormatting.RESET+ trans("172"," / Chance: ") +EnumChatFormatting.YELLOW+ (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) +EnumChatFormatting.RESET+ "%");
+ tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? EnumChatFormatting.GREEN+ trans("173","You can remove this with a Wrench") +EnumChatFormatting.RESET : EnumChatFormatting.RED+ trans("174","You can NOT remove this with a Wrench") +EnumChatFormatting.RESET);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.energy.tile.IEnergyTile) {
+ rEUAmount += 200;
+ //aList.add(((ic2.api.energy.tile.IEnergyTile)tTileEntity).isAddedToEnergyNet()?"Added to E-net":"Not added to E-net! Bug?");
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.energy.tile.IEnergySink) {
+ rEUAmount += 400;
+ //aList.add("Demanded Energy: " + ((ic2.api.energy.tile.IEnergySink)tTileEntity).demandsEnergy());
+ //tList.add("Max Safe Input: " + getTier(((ic2.api.energy.tile.IEnergySink)tTileEntity).getSinkTier()));
+ //tList.add("Max Safe Input: " + ((ic2.api.energy.tile.IEnergySink)tTileEntity).getMaxSafeInput());
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.energy.tile.IEnergySource) {
+ rEUAmount += 400;
+ //aList.add("Max Energy Output: " + ((ic2.api.energy.tile.IEnergySource)tTileEntity).getMaxEnergyOutput());
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) {
+ rEUAmount += 200;
+ tList.add(trans("175","Conduction Loss: ") +EnumChatFormatting.YELLOW+ ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss()+EnumChatFormatting.RESET);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) {
+ rEUAmount += 200;
+ tList.add(trans("176","Contained Energy: ") +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()+EnumChatFormatting.RESET+" EU");
+ //aList.add(((ic2.api.tile.IEnergyStorage)tTileEntity).isTeleporterCompatible(ic2.api.Direction.YP)?"Teleporter Compatible":"Not Teleporter Compatible");
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IUpgradableMachine) {
+ rEUAmount += 500;
+ if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN+ trans("177","Has Muffler Upgrade") +EnumChatFormatting.RESET);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IMachineProgress) {
+ rEUAmount += 400;
+ int tValue = 0;
+ if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress()))
+ tList.add(trans("178","Progress/Load: ") +EnumChatFormatting.GREEN+GT_Utility.formatNumbers(((IMachineProgress) tTileEntity).getProgress()) +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(tValue) +EnumChatFormatting.RESET);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ICoverable) {
+ rEUAmount += 300;
+ String tString = ((ICoverable) tTileEntity).getCoverBehaviorAtSide((byte) aSide).getDescription((byte) aSide, ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), ((ICoverable) tTileEntity).getCoverDataAtSide((byte) aSide), (ICoverable) tTileEntity);
+ if (tString != null && !tString.equals(E)) tList.add(tString);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IBasicEnergyContainer && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) {
+ tList.add(trans("179","Max IN: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+((IBasicEnergyContainer)tTileEntity).getInputAmperage()+EnumChatFormatting.RESET+trans("183"," A"));
+ tList.add(trans("181","Max OUT: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() +EnumChatFormatting.RESET+ trans("183"," A"));
+ tList.add(trans("184","Energy: ") +EnumChatFormatting.GREEN+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) +EnumChatFormatting.RESET+ " EU");
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IGregTechTileEntity) {
+ tList.add(trans("186","Owned by: ") +EnumChatFormatting.BLUE+ ((IGregTechTileEntity) tTileEntity).getOwnerName()+EnumChatFormatting.RESET);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IGregTechDeviceInformation && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) {
+ tList.addAll(Arrays.asList(((IGregTechDeviceInformation) tTileEntity).getInfoData()));
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.crops.ICropTile) {
+ if (((ic2.api.crops.ICropTile) tTileEntity).getScanLevel() < 4) {
+ rEUAmount += 10000;
+ ((ic2.api.crops.ICropTile) tTileEntity).setScanLevel((byte) 4);
+ }
+ if (((ic2.api.crops.ICropTile) tTileEntity).getID() >= 0 && ((ic2.api.crops.ICropTile) tTileEntity).getID() < ic2.api.crops.Crops.instance.getCropList().length && ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()] != null) {
+ rEUAmount += 1000;
+ tList.add(trans("187","Type -- Crop-Name: ") + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].name()
+ + trans("188"," Growth: ") + ((ic2.api.crops.ICropTile) tTileEntity).getGrowth()
+ + trans("189"," Gain: ") + ((ic2.api.crops.ICropTile) tTileEntity).getGain()
+ + trans("190"," Resistance: ") + ((ic2.api.crops.ICropTile) tTileEntity).getResistance()
+ );
+ tList.add(trans("191","Plant -- Fertilizer: ") + ((ic2.api.crops.ICropTile) tTileEntity).getNutrientStorage()
+ + trans("192"," Water: ") + ((ic2.api.crops.ICropTile) tTileEntity).getHydrationStorage()
+ + trans("193"," Weed-Ex: ") + ((ic2.api.crops.ICropTile) tTileEntity).getWeedExStorage()
+ + trans("194"," Scan-Level: ") + ((ic2.api.crops.ICropTile) tTileEntity).getScanLevel()
+ );
+ tList.add(trans("195","Environment -- Nutrients: ") + ((ic2.api.crops.ICropTile) tTileEntity).getNutrients()
+ + trans("196"," Humidity: ") + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity()
+ + trans("197"," Air-Quality: ") + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality()
+ );
+ StringBuilder tStringB = new StringBuilder();
+ for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) {
+ tStringB.append(", ").append(tAttribute);
+ }
+ String tString = tStringB.toString();
+ tList.add(trans("198","Attributes:") + tString.replaceFirst(",", E));
+ tList.add(trans("199","Discovered by: ") + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy());
+ }
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ if (aPlayer.capabilities.isCreativeMode) {
+ FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read
+ if (tFluid!=null)
+ tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L");
+ else
+ tList.add(EnumChatFormatting.GOLD+trans("201","Nothing")+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ '0' +EnumChatFormatting.RESET+" L");
+ }
+// if(aPlayer.capabilities.isCreativeMode){
+ int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair());
+ if(chunkData !=null){
+ if(chunkData[GTPOLLUTION]>0){
+ tList.add(trans("202","Pollution in Chunk: ")+EnumChatFormatting.RED+chunkData[GTPOLLUTION]+EnumChatFormatting.RESET+trans("203"," gibbl"));
+ }else{
+ tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
+ }
+ }else{
+ tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET);
+ }
+
+ try {
+ if (tBlock instanceof IDebugableBlock) {
+ rEUAmount += 500;
+ ArrayList<String> temp = ((IDebugableBlock) tBlock).getDebugInfo(aPlayer, aX, aY, aZ, 3);
+ if (temp != null) tList.addAll(temp);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+
+ BlockScanningEvent tEvent = new BlockScanningEvent(aWorld, aPlayer, aX, aY, aZ, (byte) aSide, aScanLevel, tBlock, tTileEntity, tList, aClickX, aClickY, aClickZ);
+ tEvent.mEUCost = rEUAmount;
+ MinecraftForge.EVENT_BUS.post(tEvent);
+ if (!tEvent.isCanceled()) aList.addAll(tList);
+ return tEvent.mEUCost;
+ }
+
+ public static String trans(String aKey, String aEnglish){
+ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false);
+ }
+
+ /**
+ * @return an Array containing the X and the Y Coordinate of the clicked Point, with the top left Corner as Origin, like on the Texture Sheet. return values should always be between [0.0F and 0.99F].
+ */
+ public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, float aZ) {
+ switch (aSide) {
+ case 0:
+ return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ))};
+ case 1:
+ return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ))};
+ case 2:
+ return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY))};
+ case 3:
+ return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY))};
+ case 4:
+ return new float[]{Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY))};
+ case 5:
+ return new float[]{Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY))};
+ default:
+ return new float[]{0.5F, 0.5F};
+ }
+ }
+
+ /**
+ * This Function determines the direction a Block gets when being Wrenched.
+ * returns -1 if invalid. Even though that could never happen.
+ */
+ public static byte determineWrenchingSide(byte aSide, float aX, float aY, float aZ) {
+ byte tBack = getOppositeSide(aSide);
+ switch (aSide) {
+ case 0:
+ case 1:
+ if (aX < 0.25) {
+ if (aZ < 0.25) return tBack;
+ if (aZ > 0.75) return tBack;
+ return 4;
+ }
+ if (aX > 0.75) {
+ if (aZ < 0.25) return tBack;
+ if (aZ > 0.75) return tBack;
+ return 5;
+ }
+ if (aZ < 0.25) return 2;
+ if (aZ > 0.75) return 3;
+ return aSide;
+ case 2:
+ case 3:
+ if (aX < 0.25) {
+ if (aY < 0.25) return tBack;
+ if (aY > 0.75) return tBack;
+ return 4;
+ }
+ if (aX > 0.75) {
+ if (aY < 0.25) return tBack;
+ if (aY > 0.75) return tBack;
+ return 5;
+ }
+ if (aY < 0.25) return 0;
+ if (aY > 0.75) return 1;
+ return aSide;
+ case 4:
+ case 5:
+ if (aZ < 0.25) {
+ if (aY < 0.25) return tBack;
+ if (aY > 0.75) return tBack;
+ return 2;
+ }
+ if (aZ > 0.75) {
+ if (aY < 0.25) return tBack;
+ if (aY > 0.75) return tBack;
+ return 3;
+ }
+ if (aY < 0.25) return 0;
+ if (aY > 0.75) return 1;
+ return aSide;
+ }
+ return -1;
+ }
+
+ public static String formatNumbers(long aNumber) {
+ DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
+ DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
+ symbols.setGroupingSeparator(' ');
+ return formatter.format(aNumber);
+ }
+
+ /*
+ * Check if stack has enough items of given type and subtract from stack, if there's no creative or 111 stack.
+ */
+ public static boolean consumeItems(EntityPlayer player, ItemStack stack, Item item, int count) {
+ if (stack != null && stack.getItem() == item && stack.stackSize >= count) {
+ if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111))
+ stack.stackSize -= count;
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * Check if stack has enough items of given gregtech material (will be oredicted)
+ * and subtract from stack, if there's no creative or 111 stack.
+ */
+ public static boolean consumeItems(EntityPlayer player, ItemStack stack, gregtech.api.enums.Materials mat, int count) {
+ if (stack != null
+ && GT_OreDictUnificator.getItemData(stack).mMaterial.mMaterial == mat
+ && stack.stackSize >= count) {
+ if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111))
+ stack.stackSize -= count;
+ return true;
+ }
+ return false;
+ }
+
+ public static ArrayList<String> sortByValueToList( Map<String, Integer> map ) {
+ List<Map.Entry<String, Integer>> list =
+ new LinkedList<Map.Entry<String, Integer>>( map.entrySet() );
+ Collections.sort( list, new Comparator<Map.Entry<String, Integer>>()
+ {
+ public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 )
+ {
+ return o2.getValue() - o1.getValue();
+ }
+ } );
+
+ ArrayList<String> result = new ArrayList<String>();
+ for (Map.Entry<String, Integer> e : list)
+ result.add(e.getKey());
+ return result;
+ }
+
+ public static String joinListToString(List<String> list) {
+ StringBuilder result = new StringBuilder(32);
+ for (String s : list)
+ result.append(result.length()==0?s:'|'+s);
+ return result.toString();
+ }
+
+ public static ItemStack getIntegratedCircuit(int config){
+ return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]);
+ }
+
+ public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) {
+ return aWorld.getBlock(aX, aY, aZ).getBlockHardness(aWorld, aX, aY, aZ);
+ }
+
+ public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) {
+ if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) {
+ return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(aBaseMetaTileEntity.getOwnerUuid(), aBaseMetaTileEntity.getOwnerName()));
+ }
+ return null;
+ }
+
+ public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) {
+ if (aPlayer == null) return false;
+ World aWorld = aPlayer.worldObj;
+ BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (!event.isCanceled()) {
+ if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) {
+ if (aPlayer == null) return false;
+ World aWorld = aPlayer.worldObj;
+ BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN);
+ if (!event.isCanceled()) {
+ if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3);
+ return true;
+ }
+ return false;
+ }
+
+ public static class ItemNBT {
+ public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) {
+ if (aNBT == null) {
+ aStack.setTagCompound(null);
+ return;
+ }
+ ArrayList<String> tTagsToRemove = new ArrayList<String>();
+ for (Object tKey : aNBT.func_150296_c()) {
+ NBTBase tValue = aNBT.getTag((String) tKey);
+ if (tValue == null || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) || (tValue instanceof NBTTagString && isStringInvalid(((NBTTagString) tValue).func_150285_a_())))
+ tTagsToRemove.add((String) tKey);
+ }
+ for (Object tKey : tTagsToRemove) aNBT.removeTag((String) tKey);
+ aStack.setTagCompound(aNBT.hasNoTags() ? null : aNBT);
+ }
+
+ public static NBTTagCompound getNBT(ItemStack aStack) {
+ NBTTagCompound rNBT = aStack.getTagCompound();
+ return rNBT == null ? new NBTTagCompound() : rNBT;
+ }
+
+ public static void setPunchCardData(ItemStack aStack, String aPunchCardData) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ tNBT.setString("GT.PunchCardData", aPunchCardData);
+ setNBT(aStack, tNBT);
+ }
+
+ public static String getPunchCardData(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ return tNBT.getString("GT.PunchCardData");
+ }
+
+ public static void setLighterFuel(ItemStack aStack, long aFuel) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ tNBT.setLong("GT.LighterFuel", aFuel);
+ setNBT(aStack, tNBT);
+ }
+
+ public static long getLighterFuel(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ return tNBT.getLong("GT.LighterFuel");
+ }
+
+ public static void setMapID(ItemStack aStack, short aMapID) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ tNBT.setShort("map_id", aMapID);
+ setNBT(aStack, tNBT);
+ }
+
+ public static short getMapID(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ if (!tNBT.hasKey("map_id")) return -1;
+ return tNBT.getShort("map_id");
+ }
+
+ public static void setBookTitle(ItemStack aStack, String aTitle) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ tNBT.setString("title", aTitle);
+ setNBT(aStack, tNBT);
+ }
+
+ public static String getBookTitle(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ return tNBT.getString("title");
+ }
+
+ public static void setBookAuthor(ItemStack aStack, String aAuthor) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ tNBT.setString("author", aAuthor);
+ setNBT(aStack, tNBT);
+ }
+
+ public static String getBookAuthor(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ return tNBT.getString("author");
+ }
+
+ public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String... aOres) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ String tData = aX + "," + aY + "," + aZ + "," + aDim + ",";
+ if (aFluid!=null)
+ tData += (aFluid.amount) + "," + aFluid.getLocalizedName() + ",";//TODO CHECK IF THAT /5000 is needed (Not needed)
+ for (String tString : aOres) {
+ tData += tString + ",";
+ }
+ tNBT.setString("prospection", tData);
+ setNBT(aStack, tNBT);
+ }
+
+ public static void setAdvancedProspectionData(
+ byte aTier,
+ ItemStack aStack,
+ int aX, short aY, int aZ, int aDim,
+ ArrayList<String> aOils,
+ ArrayList<String> aOres,
+ int aRadius) {
+
+ setBookTitle(aStack, "Raw Prospection Data");
+
+ NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack);
+
+ tNBT.setByte("prospection_tier", aTier);
+ tNBT.setString("prospection_pos", "Dim: " + aDim + "\nX: " + aX + " Y: " + aY + " Z: " + aZ);
+
+ // ores
+ Collections.sort(aOres);
+ tNBT.setString("prospection_ores", joinListToString(aOres));
+
+ // oils
+ ArrayList<String> tOilsTransformed = new ArrayList<String>(aOils.size());
+ for (String aStr : aOils) {
+ String[] aStats = aStr.split(",");
+ tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]);
+ }
+
+ tNBT.setString("prospection_oils", joinListToString(tOilsTransformed));
+
+ String tOilsPosStr = "X: " + Math.floorDiv(aX, 16*8)*16*8 + " Z: " + Math.floorDiv(aZ, 16*8)*16*8 + "\n";
+ int xOff = aX - Math.floorDiv(aX, 16*8)*16*8;
+ xOff = xOff/16;
+ int xOffRemain = 7 - xOff;
+
+ int zOff = aZ - Math.floorDiv(aZ, 16*8)*16*8;
+ zOff = zOff/16;
+ int zOffRemain = 7 - zOff;
+
+ for( ; zOff > 0; zOff-- ) {
+ tOilsPosStr = tOilsPosStr.concat("--------\n");
+ }
+ for( ; xOff > 0; xOff-- ) {
+ tOilsPosStr = tOilsPosStr.concat("-");
+ }
+
+ tOilsPosStr = tOilsPosStr.concat("P");
+
+ for( ; xOffRemain > 0; xOffRemain-- ) {
+ tOilsPosStr = tOilsPosStr.concat("-");
+ }
+ tOilsPosStr = tOilsPosStr.concat("\n");
+ for( ; zOffRemain > 0; zOffRemain-- ) {
+ tOilsPosStr = tOilsPosStr.concat("--------\n");
+ }
+ tOilsPosStr = tOilsPosStr.concat( " X: " + (Math.floorDiv(aX, 16*8) + 1)*16*8 + " Z: " + (Math.floorDiv(aZ, 16*8) + 1)*16*8 ); // +1 oilfied to find bottomright of [5]
+
+ tNBT.setString("prospection_oils_pos", tOilsPosStr);
+
+ tNBT.setString("prospection_radius", String.valueOf(aRadius));
+
+ setNBT(aStack, tNBT);
+ }
+
+ public static void convertProspectionData(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ byte tTier = tNBT.getByte("prospection_tier");
+
+ if (tTier == 0) { // basic prospection data
+ String tData = tNBT.getString("prospection");
+ String[] tDataArray = tData.split(",");
+ if (tDataArray.length > 6) {
+ tNBT.setString("author", " Dim: " + tDataArray[3] + "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2]);
+ NBTTagList tNBTList = new NBTTagList();
+ String tOres = " Prospected Ores: ";
+ for (int i = 6; tDataArray.length > i; i++) {
+ tOres += (tDataArray[i] + " ");
+ }
+ tNBTList.appendTag(new NBTTagString("Tier " + tTier + " Prospecting Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
+ tNBT.setTag("pages", tNBTList);
+ }
+ setNBT(aStack, tNBT);
+ } else { // advanced prospection data
+ String tPos = tNBT.getString("prospection_pos");
+ String tRadius = tNBT.getString("prospection_radius");
+
+ String tOresStr = tNBT.getString("prospection_ores");
+ String tOilsStr = tNBT.getString("prospection_oils");
+ String tOilsPosStr = tNBT.getString("prospection_oils_pos");
+
+ String[] tOres = tOresStr.isEmpty() ? null : tOresStr.split("\\|");
+ String[] tOils = tOilsStr.isEmpty() ? null : tOilsStr.split("\\|");
+
+ NBTTagList tNBTList = new NBTTagList();
+
+ String tPageText = "Prospector report\n"
+ + tPos + "\n\n"
+ + "Oils: " + (tOils != null ? tOils.length : 0) + "\n\n"
+ + "Ores within " + tRadius + " blocks\n\n"
+ + "Location is center of orevein\n\n"
+ + "Check NEI to confirm orevein type";
+ tNBTList.appendTag(new NBTTagString(tPageText));
+
+ if (tOres != null)
+ fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres);
+
+
+ if (tOils != null)
+ fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils);
+
+ tPageText = "Oil notes\n\n"
+ + "Prospects from NW to SE 576 chunks"
+ + "(9 8x8 oilfields)\n around and gives min-max amount" + "\n\n"
+ + "[1][2][3]" + "\n"
+ + "[4][5][6]" + "\n"
+ + "[7][8][9]" + "\n"
+ + "\n"
+ + "[5] - Prospector in this 8x8 area";
+ tNBTList.appendTag(new NBTTagString(tPageText));
+
+ tPageText = "Corners of [5] are \n" +
+ tOilsPosStr + "\n" +
+ "P - Prospector in 8x8 field";
+ tNBTList.appendTag(new NBTTagString(tPageText));
+
+ tNBT.setString("author", tPos.replace("\n"," "));
+ tNBT.setTag("pages", tNBTList);
+ setNBT(aStack, tNBT);
+ }
+ }
+
+ public static void fillBookWithList(NBTTagList aBook, String aPageHeader, String aListDelimiter, int aItemsPerPage, String[] list) {
+ String aPageFormatter = " %d/%d";
+ int tTotalPages = list.length / aItemsPerPage + (list.length % aItemsPerPage > 0 ? 1 : 0);
+ int tPage = 0;
+ String tPageText;
+ do {
+ tPageText = "";
+ for (int i = tPage*aItemsPerPage; i < (tPage+1)*aItemsPerPage && i < list.length; i += 1)
+ tPageText += (tPageText.isEmpty() ? "" : aListDelimiter) + list[i];
+
+ if (!tPageText.isEmpty()) {
+ String tPageCounter = tTotalPages > 1 ? String.format(aPageFormatter, tPage + 1, tTotalPages) : "";
+ NBTTagString tPageTag = new NBTTagString(String.format(aPageHeader, tPageCounter) + tPageText);
+ aBook.appendTag(tPageTag);
+ }
+
+ ++tPage;
+ } while (!tPageText.isEmpty());
+ }
+
+ public static void addEnchantment(ItemStack aStack, Enchantment aEnchantment, int aLevel) {
+ NBTTagCompound tNBT = getNBT(aStack), tEnchantmentTag;
+ if (!tNBT.hasKey("ench", 9)) tNBT.setTag("ench", new NBTTagList());
+ NBTTagList tList = tNBT.getTagList("ench", 10);
+
+ boolean temp = true;
+
+ for (int i = 0; i < tList.tagCount(); i++) {
+ tEnchantmentTag = tList.getCompoundTagAt(i);
+ if (tEnchantmentTag.getShort("id") == aEnchantment.effectId) {
+ tEnchantmentTag.setShort("id", (short) aEnchantment.effectId);
+ tEnchantmentTag.setShort("lvl", (byte) aLevel);
+ temp = false;
+ break;
+ }
+ }
+
+ if (temp) {
+ tEnchantmentTag = new NBTTagCompound();
+ tEnchantmentTag.setShort("id", (short) aEnchantment.effectId);
+ tEnchantmentTag.setShort("lvl", (byte) aLevel);
+ tList.appendTag(tEnchantmentTag);
+ }
+ aStack.setTagCompound(tNBT);
+ }
+ }
+
+ /**
+ * THIS IS BULLSHIT!!! WHY DO I HAVE TO DO THIS SHIT JUST TO HAVE ENCHANTS PROPERLY!?!
+ */
+ public static class GT_EnchantmentHelper {
+ private static final BullshitIteratorA mBullshitIteratorA = new BullshitIteratorA();
+ private static final BullshitIteratorB mBullshitIteratorB = new BullshitIteratorB();
+
+ private static void applyBullshit(IBullshit aBullshitModifier, ItemStack aStack) {
+ if (aStack != null) {
+ NBTTagList nbttaglist = aStack.getEnchantmentTagList();
+ if (nbttaglist != null) {
+ try {
+ for (int i = 0; i < nbttaglist.tagCount(); ++i) {
+ short short1 = nbttaglist.getCompoundTagAt(i).getShort("id");
+ short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl");
+ if (Enchantment.enchantmentsList[short1] != null)
+ aBullshitModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2);
+ }
+ } catch (Throwable e) {/**/}
+ }
+ }
+ }
+
+ private static void applyArrayOfBullshit(IBullshit aBullshitModifier, ItemStack[] aStacks) {
+ ItemStack[] aitemstack1 = aStacks;
+ int i = aStacks.length;
+ for (int j = 0; j < i; ++j) {
+ ItemStack itemstack = aitemstack1[j];
+ applyBullshit(aBullshitModifier, itemstack);
+ }
+ }
+
+ public static void applyBullshitA(EntityLivingBase aPlayer, Entity aEntity, ItemStack aStack) {
+ mBullshitIteratorA.mPlayer = aPlayer;
+ mBullshitIteratorA.mEntity = aEntity;
+ if (aPlayer != null) applyArrayOfBullshit(mBullshitIteratorA, aPlayer.getLastActiveItems());
+ if (aStack != null) applyBullshit(mBullshitIteratorA, aStack);
+ }
+
+ public static void applyBullshitB(EntityLivingBase aPlayer, Entity aEntity, ItemStack aStack) {
+ mBullshitIteratorB.mPlayer = aPlayer;
+ mBullshitIteratorB.mEntity = aEntity;
+ if (aPlayer != null) applyArrayOfBullshit(mBullshitIteratorB, aPlayer.getLastActiveItems());
+ if (aStack != null) applyBullshit(mBullshitIteratorB, aStack);
+ }
+
+ interface IBullshit {
+ void calculateModifier(Enchantment aEnchantment, int aLevel);
+ }
+
+ static final class BullshitIteratorA implements IBullshit {
+ public EntityLivingBase mPlayer;
+ public Entity mEntity;
+
+ BullshitIteratorA() {
+ }
+
+ @Override
+ public void calculateModifier(Enchantment aEnchantment, int aLevel) {
+ aEnchantment.func_151367_b(mPlayer, mEntity, aLevel);
+ }
+ }
+
+ static final class BullshitIteratorB implements IBullshit {
+ public EntityLivingBase mPlayer;
+ public Entity mEntity;
+
+ BullshitIteratorB() {
+ }
+
+ @Override
+ public void calculateModifier(Enchantment aEnchantment, int aLevel) {
+ aEnchantment.func_151368_a(mPlayer, mEntity, aLevel);
+ }
+ }
+ }
+
+ public static String toSubscript(long no){
+ char[] chars=Long.toString(no).toCharArray();
+ for(int i=0;i<chars.length;i++){
+ chars[i]+=8272;
+ }
+ return new String(chars);
+ }
+
+ public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials){
+ return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials) : false;
+ }
+
+ public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){
+ return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false;
+ }
+
+}