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_BaseCrop.java254
-rw-r--r--src/main/java/gregtech/api/util/GT_CircuitryBehavior.java181
-rw-r--r--src/main/java/gregtech/api/util/GT_Config.java87
-rw-r--r--src/main/java/gregtech/api/util/GT_CoverBehavior.java218
-rw-r--r--src/main/java/gregtech/api/util/GT_CreativeTab.java24
-rw-r--r--src/main/java/gregtech/api/util/GT_FoodStat.java102
-rw-r--r--src/main/java/gregtech/api/util/GT_IBoxableWrapper.java11
-rw-r--r--src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java16
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java95
-rw-r--r--src/main/java/gregtech/api/util/GT_Log.java38
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java1868
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java354
-rw-r--r--src/main/java/gregtech/api/util/GT_PlayedSound.java28
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java1275
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeRegistrator.java347
-rw-r--r--src/main/java/gregtech/api/util/GT_Shaped_Recipe.java99
-rw-r--r--src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java98
-rw-r--r--src/main/java/gregtech/api/util/GT_SpawnEventHandler.java45
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java2052
19 files changed, 7192 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java
new file mode 100644
index 0000000000..304a0f3c62
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java
@@ -0,0 +1,254 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.Loader;
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.ConfigCategories;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.objects.ItemData;
+import gregtech.common.blocks.GT_Block_Ores;
+import gregtech.common.blocks.GT_TileEntity_Ores;
+import ic2.api.crops.CropCard;
+import ic2.api.crops.Crops;
+import ic2.api.crops.ICropTile;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import speiger.src.crops.api.ICropCardInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import static gregtech.api.enums.GT_Values.E;
+
+public class GT_BaseCrop extends CropCard implements ICropCardInfo {
+ public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>();
+ private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[];
+ private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], mGrowthSpeed = 0;
+ private ItemStack mDrop = null, mSpecialDrops[] = null;
+ private Materials mBlock = null;
+ private static boolean bIc2NeiLoaded = Loader.isModLoaded("Ic2Nei");
+
+ /**
+ * To create new Crops
+ *
+ * @param aID Default ID
+ * @param aCropName Name of the Crop
+ * @param aDiscoveredBy The one who discovered the Crop
+ * @param aDrop The Item which is dropped by the Crop. must be != null
+ * @param aBaseSeed Baseseed to plant this Crop. null == crossbreed only
+ * @param aTier tier of the Crop. forced to be >= 1
+ * @param aMaxSize maximum Size of the Crop. forced to be >= 3
+ * @param aGrowthSpeed how fast the Crop grows. if < 0 then its set to Tier*300
+ * @param aHarvestSize the size the Crop needs to be harvested. forced to be between 2 and max size
+ */
+ public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes, ItemStack aDrop, ItemStack[] aSpecialDrops) {
+ new GT_BaseCrop(aID, aCropName, aDiscoveredBy, aBaseSeed, aTier, aMaxSize, aGrowthSpeed, aAfterHarvestSize, aHarvestSize, aStatChemical, aStatFood, aStatDefensive, aStatColor, aStatWeed, aAttributes, null, aDrop, aSpecialDrops);
+ }
+
+ /**
+ * To create new Crops
+ *
+ * @param aID Default ID
+ * @param aCropName Name of the Crop
+ * @param aDiscoveredBy The one who discovered the Crop
+ * @param aDrop The Item which is dropped by the Crop. must be != null
+ * @param aBaseSeed Baseseed to plant this Crop. null == crossbreed only
+ * @param aTier tier of the Crop. forced to be >= 1
+ * @param aMaxSize maximum Size of the Crop. forced to be >= 3
+ * @param aGrowthSpeed how fast the Crop grows. if < 0 then its set to Tier*300
+ * @param aHarvestSize the size the Crop needs to be harvested. forced to be between 2 and max size
+ * @param aBlock the block below needed for crop to grow. If null no block needed
+ * @param aMeta meta of the block below(-1 if no meta)
+ */
+ public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes, Materials aBlock, ItemStack aDrop, ItemStack[] aSpecialDrops) {
+ mName = aCropName;
+ aID = GT_Config.addIDConfig(ConfigCategories.IDs.crops, mName.replaceAll(" ", "_"), aID);
+ if (aDiscoveredBy != null && !aDiscoveredBy.equals(E)) mDiscoveredBy = aDiscoveredBy;
+ if (aDrop != null && aID > 0 && aID < 256) {
+ mDrop = GT_Utility.copy(aDrop);
+ mSpecialDrops = aSpecialDrops;
+ mTier = Math.max(1, aTier);
+ mMaxSize = Math.max(3, aMaxSize);
+ mHarvestSize = Math.min(Math.max(aHarvestSize, 2), mMaxSize);
+ mAfterHarvestSize = Math.min(Math.max(aAfterHarvestSize, 1), mMaxSize - 1);
+ mStats[0] = aStatChemical;
+ mStats[1] = aStatFood;
+ mStats[2] = aStatDefensive;
+ mStats[3] = aStatColor;
+ mStats[4] = aStatWeed;
+ mAttributes = aAttributes;
+ mBlock = aBlock;
+ if(GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.crops, aCropName, true)){
+ if (!Crops.instance.registerCrop(this, aID))
+ throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!");
+ if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1);
+ sCropList.add(this);}
+ }
+ if (bIc2NeiLoaded) {
+ try {
+ Class.forName("speiger.src.crops.api.CropPluginAPI").getMethod("registerCropInfo", Class.forName("speiger.src.crops.api.ICropCardInfo")).invoke(Class.forName("speiger.src.crops.api.CropPluginAPI").getField("instance"), this);
+ } catch (IllegalAccessException ex) {
+ bIc2NeiLoaded = false;
+ } catch (IllegalArgumentException ex) {
+ bIc2NeiLoaded = false;
+ } catch (java.lang.reflect.InvocationTargetException ex) {
+ bIc2NeiLoaded = false;
+ } catch (NoSuchFieldException ex) {
+ bIc2NeiLoaded = false;
+ } catch (NoSuchMethodException ex) {
+ bIc2NeiLoaded = false;
+ } catch (SecurityException ex) {
+ bIc2NeiLoaded = false;
+ } catch (ClassNotFoundException ex) {
+ bIc2NeiLoaded = false;
+ }
+ }
+ }
+
+ @Override
+ public byte getSizeAfterHarvest(ICropTile crop) {
+ return (byte) mAfterHarvestSize;
+ }
+
+ @Override
+ public int growthDuration(ICropTile aCrop) {
+ if (mGrowthSpeed < 200) return super.growthDuration(aCrop);
+ return tier() * mGrowthSpeed;
+ }
+
+ public int getrootslength(ICropTile crop) {
+ return 5;
+ }
+
+ @Override
+ public String[] attributes() {
+ return mAttributes;
+ }
+
+ @Override
+ public String discoveredBy() {
+ return mDiscoveredBy;
+ }
+
+ @Override
+ public final boolean canGrow(ICropTile aCrop) {
+ if (mBlock != null && aCrop.getSize() == mMaxSize - 1) {
+ return isBlockBelow(aCrop);
+ }
+ return aCrop.getSize() < maxSize();
+ }
+
+ @Override
+ public final boolean canBeHarvested(ICropTile aCrop) {
+ return aCrop.getSize() >= mHarvestSize;
+ }
+
+ @Override
+ public boolean canCross(ICropTile aCrop) {
+ return aCrop.getSize() + 2 > maxSize();
+ }
+
+ @Override
+ public int stat(int n) {
+ if (n < 0 || n >= mStats.length) return 0;
+ return mStats[n];
+ }
+
+ @Override
+ public String name() {
+ return mName;
+ }
+
+ @Override
+ public int tier() {
+ return mTier;
+ }
+
+ @Override
+ public int maxSize() {
+ return mMaxSize;
+ }
+
+ @Override
+ public ItemStack getGain(ICropTile aCrop) {
+ int tDrop = 0;
+ if (mSpecialDrops != null && (tDrop = new Random().nextInt((mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) {
+ return GT_Utility.copy(mSpecialDrops[tDrop]);
+ }
+ return GT_Utility.copy(mDrop);
+ }
+
+ @Override
+ public boolean rightclick(ICropTile aCrop, EntityPlayer aPlayer) {
+ if (!canBeHarvested(aCrop)) return false;
+ return aCrop.harvest(aPlayer == null ? false : aPlayer instanceof EntityPlayerMP);
+ }
+
+ @Override
+ public int getOptimalHavestSize(ICropTile crop) {
+ return maxSize();
+ }
+
+ public boolean isBlockBelow(ICropTile aCrop) {
+ if (aCrop == null) {
+ return false;
+ }
+ for (int i = 1; i < this.getrootslength(aCrop); i++) {
+ Block tBlock = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ);
+ if ((tBlock instanceof GT_Block_Ores)) {
+ TileEntity tTileEntity = aCrop.getWorld().getTileEntity(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ);
+ if ((tTileEntity instanceof GT_TileEntity_Ores)) {
+ Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)];
+ if ((tMaterial != null) && (tMaterial != Materials._NULL)) {
+ if (tMaterial == mBlock) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ } else {
+ int tMetaID = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ);
+ ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID));
+ if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore")) && (tAssotiation.mMaterial.mMaterial == mBlock)) {
+ return true;
+ }
+ if ((tAssotiation != null) && (tAssotiation.mPrefix == OrePrefixes.block) && (tAssotiation.mMaterial.mMaterial == mBlock)) {
+ return true;
+ }
+ }
+// Block block = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ);
+// if (block.isAir(aCrop.getWorld(), aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ)) {
+// return false;
+// }
+// if (block == mBlock) {
+// int tMeta = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ);
+// if(mMeta < 0 || tMeta == mMeta){
+// return true;}
+// }
+ }
+ return false;
+ }
+
+ public List<String> getCropInformation() {
+ if (mBlock != null) {
+ ArrayList<String> result = new ArrayList<String>(1);
+ result.add(String.format("Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.name(), mBlock.name()));
+ return result;
+ }
+ return null;
+ }
+
+ public ItemStack getDisplayItem() {
+ if (mSpecialDrops != null && mSpecialDrops[mSpecialDrops.length - 1] != null) {
+ return GT_Utility.copy(mSpecialDrops[mSpecialDrops.length - 1]);
+ }
+ return GT_Utility.copy(mDrop);
+ }
+
+}
diff --git a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java
new file mode 100644
index 0000000000..4adf7e0f26
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java
@@ -0,0 +1,181 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.IRedstoneCircuitBlock;
+
+/**
+ * Redstone Circuit Control Code
+ * <p/>
+ * This should make everything possible what a Redstone Computer or BuildCraft Gate could do.
+ * It is intended to use this similar to BC-Gates (for acquiring Data) and RP Logic Gates.
+ * You could write an extremely specified and complex Logic Gate, which works only for you Setup, like
+ * with ComputerCraft, but you would have to write an extra Mod to add that, as it doesn't work Ingame.
+ * <p/>
+ * One can make use of the fact, that ItemStacks can be stored as Integer, so that you can scan
+ * Inventories for specific Items using that. Luckily the Buttons in the GUI enable Copy/Paste of
+ * ItemID+MetaData to Integer, including the WildCard Damage Value when you use rightclick to place it.
+ * You just need to use @GT_Utility.stackToInt(ItemStack aStack) to get it.
+ * <p/>
+ * All Functions run usually in a seperate try/catch Block, so that failed Logic won't crash the TileEntity.
+ */
+public abstract class GT_CircuitryBehavior {
+ /**
+ * @param aIndex 0 - 1023 are my own Indices, so use other Numbers!
+ */
+ public GT_CircuitryBehavior(int aIndex) {
+ GregTech_API.sCircuitryBehaviors.put(aIndex, this);
+ }
+
+ /**
+ * returns if there is Redstone applied to any of the valid Inputs (OR)
+ */
+ public static final boolean getAnyRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ if (aRedstoneCircuitBlock.getInputRedstone(i) > 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * returns if there is Redstone applied to all the valid Inputs (AND)
+ */
+ public static final boolean getAllRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ if (aRedstoneCircuitBlock.getInputRedstone(i) == 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * returns if there is Redstone applied to exactly one of the valid Inputs (XOR)
+ */
+ public static final boolean getOneRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ int tRedstoneAmount = 0;
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ if (aRedstoneCircuitBlock.getInputRedstone(i) > 0) {
+ tRedstoneAmount++;
+ }
+ }
+ }
+ return tRedstoneAmount == 1;
+ }
+
+ /**
+ * returns the strongest incoming RS-Power
+ */
+ public static final byte getStrongestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ byte tRedstoneAmount = 0;
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ tRedstoneAmount = (byte) Math.max(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i));
+ }
+ }
+ return tRedstoneAmount;
+ }
+
+ /*****************
+ * GUI Functions *
+ *****************/
+
+ /**
+ * returns the weakest incoming non-zero RS-Power
+ */
+ public static final byte getWeakestNonZeroRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0;
+ byte tRedstoneAmount = 15;
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ if (aRedstoneCircuitBlock.getInputRedstone(i) > 0)
+ tRedstoneAmount = (byte) Math.min(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i));
+ }
+ }
+ return tRedstoneAmount;
+ }
+
+ /**
+ * returns the weakest incoming RS-Power
+ */
+ public static final byte getWeakestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) {
+ if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0;
+ byte tRedstoneAmount = 15;
+ for (byte i = 0; i < 6; i++) {
+ if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) {
+ tRedstoneAmount = (byte) Math.min(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i));
+ }
+ }
+ return tRedstoneAmount;
+ }
+
+ /**
+ * Initializes the Parameters of this Circuit, all Parameters have been set to 0 right before calling this
+ *
+ * @param aCircuitData, The Data Storage you can use (8 Slots)
+ * @param aRedstoneCircuitBlock, The Circuit Block MetaTileEntity itself
+ */
+ public abstract void initParameters(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock);
+
+ /**
+ * Validates the Parameters of this Circuit when a value has been changed by the GUI
+ * Also called right after @initParameters and when the Chunk reloads
+ *
+ * @param aCircuitData, The Data Storage you can use (8 Slots and only the first 4 are User definable)
+ * @param aRedstoneCircuitBlock, The Circuit Block MetaTileEntity itself
+ */
+ public abstract void validateParameters(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock);
+
+
+ /****************************
+ * Useful Utility Functions *
+ ****************************/
+
+ /**
+ * Called every tick if the Block has enough Energy and if the Block is Active
+ *
+ * @param aCircuitData, The Data Storage you can use (8 Slots)
+ * @param aRedstoneCircuitBlock, The Circuit Block MetaTileEntity itself
+ */
+ public abstract void onTick(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock);
+
+ /**
+ * If the ItemStack should be displayed. Parameters are between 0 and 3.
+ */
+ public abstract boolean displayItemStack(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock, int aIndex);
+
+ /**
+ * The Name of the Gate for the GUI
+ */
+ @SideOnly(Side.CLIENT)
+ public abstract String getName();
+
+ /**
+ * The Description of the Gate for the GUI
+ */
+ @SideOnly(Side.CLIENT)
+ public abstract String getDescription();
+
+ /**
+ * The Description of the Data Field for the GUI
+ */
+ @SideOnly(Side.CLIENT)
+ public abstract String getDataDescription(int[] aCircuitData, int aCircuitDataIndex);
+
+ /**
+ * How the Integer should be displayed in the GUI.
+ * null means, that it just displays as regular Number.
+ */
+ @SideOnly(Side.CLIENT)
+ public String getDataDisplay(int[] aCircuitData, int aCircuitDataIndex) {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Config.java b/src/main/java/gregtech/api/util/GT_Config.java
new file mode 100644
index 0000000000..f4631f5de6
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Config.java
@@ -0,0 +1,87 @@
+package gregtech.api.util;
+
+import gregtech.api.GregTech_API;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.common.config.Property;
+
+import static gregtech.api.enums.GT_Values.E;
+
+public class GT_Config implements Runnable {
+ public static boolean troll = false;
+
+ public static Configuration sConfigFileIDs;
+ public final Configuration mConfig;
+
+ public GT_Config(Configuration aConfig) {
+ mConfig = aConfig;
+ mConfig.load();
+ mConfig.save();
+ GregTech_API.sAfterGTPreload.add(this); // in case of crash on startup
+ GregTech_API.sAfterGTLoad.add(this); // in case of crash on startup
+ GregTech_API.sAfterGTPostload.add(this);
+ }
+
+ public static int addIDConfig(Object aCategory, String aName, int aDefault) {
+ if (GT_Utility.isStringInvalid(aName)) return aDefault;
+ Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault);
+ int rResult = tProperty.getInt(aDefault);
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sConfigFileIDs.save();
+ return rResult;
+ }
+
+ public static String getStackConfigName(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return E;
+ Object rName = GT_OreDictUnificator.getAssociation(aStack);
+ if (rName != null) return rName.toString();
+ try {
+ if (GT_Utility.isStringValid(rName = aStack.getUnlocalizedName())) return rName.toString();
+ } catch (Throwable e) {/*Do nothing*/}
+ String sName = aStack.getItem().toString();
+ String[] tmp = sName.split("@");
+ if (tmp.length > 0) sName = tmp[0];
+ return sName + "." + aStack.getItemDamage();
+ }
+
+ public boolean get(Object aCategory, ItemStack aStack, boolean aDefault) {
+ String aName = getStackConfigName(aStack);
+ return get(aCategory, aName, aDefault);
+ }
+
+ public boolean get(Object aCategory, String aName, boolean aDefault) {
+ if (GT_Utility.isStringInvalid(aName)) return aDefault;
+ Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
+ boolean rResult = tProperty.getBoolean(aDefault);
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ return rResult;
+ }
+
+ public int get(Object aCategory, ItemStack aStack, int aDefault) {
+ return get(aCategory, getStackConfigName(aStack), aDefault);
+ }
+
+ public int get(Object aCategory, String aName, int aDefault) {
+ if (GT_Utility.isStringInvalid(aName)) return aDefault;
+ Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
+ int rResult = tProperty.getInt(aDefault);
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ return rResult;
+ }
+
+ public double get(Object aCategory, ItemStack aStack, double aDefault) {
+ return get(aCategory, getStackConfigName(aStack), aDefault);
+ }
+
+ public double get(Object aCategory, String aName, double aDefault) {
+ if (GT_Utility.isStringInvalid(aName)) return aDefault;
+ Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
+ double rResult = tProperty.getDouble(aDefault);
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ return rResult;
+ }
+
+ @Override
+ public void run() {
+ mConfig.save();
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java
new file mode 100644
index 0000000000..f3ba021ad1
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java
@@ -0,0 +1,218 @@
+package gregtech.api.util;
+
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.objects.GT_ItemStack;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+
+import static gregtech.api.enums.GT_Values.E;
+
+/**
+ * For Covers with a special behavior.
+ */
+public abstract class GT_CoverBehavior {
+ /**
+ * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time.
+ */
+ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ return aCoverVariable;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover.
+ * <p/>
+ * return true, if something actually happens.
+ */
+ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover Client Side
+ * <p/>
+ * return true, if something actually happens.
+ */
+ public boolean onCoverRightclickClient(byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ /**
+ * Called when someone rightclicks this Cover with a Screwdriver. Doesn't call @onCoverRightclick in this Case.
+ * <p/>
+ * return the new Value of the Cover Variable
+ */
+ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return aCoverVariable;
+ }
+
+ /**
+ * Checks if the Cover can be placed on this.
+ */
+ public boolean isCoverPlaceable(byte aSide, GT_ItemStack aStack, ICoverable aTileEntity) {
+ return true;
+ }
+
+ /**
+ * Removes the Cover if this returns true, or if aForced is true.
+ * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine.
+ */
+ public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) {
+ return true;
+ }
+
+ /**
+ * Gives a small Text for the status of the Cover.
+ */
+ public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return E;
+ }
+
+ /**
+ * How Blast Proof the Cover is. 30 is normal.
+ */
+ public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return 10.0F;
+ }
+
+ /**
+ * If it lets RS-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets RS-Signals out of the Block
+ */
+ public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Fibre-Signals into the Block
+ * <p/>
+ * This is just Informative so that Machines know if their Redstone Input is blocked or not
+ */
+ public boolean letsFibreGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Fibre-Signals out of the Block
+ */
+ public boolean letsFibreGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Energy into the Block
+ */
+ public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Energy out of the Block
+ */
+ public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not.
+ */
+ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Items into the Block, aSlot = -1 means if it is generally accepting Items (return false for no Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each Slot).
+ */
+ public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets Items out of the Block, aSlot = -1 means if it is generally accepting Items (return false for no Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each Slot).
+ */
+ public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * If it lets you rightclick the Machine normally
+ */
+ public boolean isGUIClickable(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * Needs to return true for Covers, which have a Redstone Output on their Facing.
+ */
+ public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * if this Cover should let Pipe Connections look connected even if it is not the case.
+ */
+ public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return false;
+ }
+
+ /**
+ * Called to determine the incoming Redstone Signal of a Machine.
+ * Returns the original Redstone per default.
+ * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0.
+ */
+ public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0;
+ }
+
+ /**
+ * Gets the Tick Rate for doCoverThings of the Cover
+ * <p/>
+ * 0 = No Ticks! Yes, 0 is Default, you have to override this
+ */
+ public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return 0;
+ }
+
+ /**
+ * If this is a simple Cover, which can also be used on Bronze Machines and similar.
+ */
+ public boolean isSimpleCover() {
+ return false;
+ }
+
+ /**
+ * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then).
+ */
+ public byte getLensColor(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return -1;
+ }
+
+ /**
+ * @return the ItemStack dropped by this Cover
+ */
+ public ItemStack getDrop(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide));
+ }
+
+ /**
+ * @return sets the Cover upon placement.
+ */
+ public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
+ aTileEntity.setCoverIDAtSide(aSide, GT_Utility.stackToInt(aCover));
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_CreativeTab.java b/src/main/java/gregtech/api/util/GT_CreativeTab.java
new file mode 100644
index 0000000000..80dac95df2
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_CreativeTab.java
@@ -0,0 +1,24 @@
+package gregtech.api.util;
+
+import gregtech.api.enums.ItemList;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+public class GT_CreativeTab extends CreativeTabs {
+ public GT_CreativeTab(String aName, String aLocalName) {
+ super("GregTech." + aName);
+ GT_LanguageManager.addStringLocalization("itemGroup.GregTech." + aName, aLocalName);
+ }
+
+ @Override
+ public ItemStack getIconItemStack() {
+ return ItemList.Tool_Cheat.get(1, new ItemStack(Blocks.iron_block, 1));
+ }
+
+ @Override
+ public Item getTabIconItem() {
+ return ItemList.Circuit_Integrated.getItem();
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java
new file mode 100644
index 0000000000..d0fe9bdbf4
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_FoodStat.java
@@ -0,0 +1,102 @@
+package gregtech.api.util;
+
+import gregtech.api.damagesources.GT_DamageSources;
+import gregtech.api.interfaces.IFoodStat;
+import gregtech.api.items.GT_MetaBase_Item;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.item.EnumAction;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.PotionEffect;
+
+public class GT_FoodStat implements IFoodStat {
+ private final int mFoodLevel;
+ private final int[] mPotionEffects;
+ private final float mSaturation;
+ private final EnumAction mAction;
+ private final ItemStack mEmptyContainer;
+ private final boolean mAlwaysEdible, mInvisibleParticles, mIsRotten;
+ private boolean mExplosive = false, mMilk = false;
+
+ /**
+ * @param aFoodLevel Amount of Food in Half Bacon [0 - 20]
+ * @param aSaturation Amount of Saturation [0.0F - 1.0F]
+ * @param aAction The Action to be used. If this is null, it uses the Eating Action
+ * @param aEmptyContainer An empty Container (Optional)
+ * @param aAlwaysEdible If this Item is always edible, like Golden Apples or Potions
+ * @param aInvisibleParticles If the Particles of the Potion Effects are invisible
+ * @param aPotionEffects An Array of Potion Effects with %4==0 Elements as follows
+ * ID of a Potion Effect. 0 for none
+ * Duration of the Potion in Ticks
+ * Level of the Effect. [0, 1, 2] are for [I, II, III]
+ * The likelihood that this Potion Effect takes place upon being eaten [1 - 100]
+ */
+ public GT_FoodStat(int aFoodLevel, float aSaturation, EnumAction aAction, ItemStack aEmptyContainer, boolean aAlwaysEdible, boolean aInvisibleParticles, boolean aIsRotten, int... aPotionEffects) {
+ mFoodLevel = aFoodLevel;
+ mSaturation = aSaturation;
+ mAction = aAction == null ? EnumAction.eat : aAction;
+ mPotionEffects = aPotionEffects;
+ mEmptyContainer = GT_Utility.copy(aEmptyContainer);
+ mInvisibleParticles = aInvisibleParticles;
+ mAlwaysEdible = aAlwaysEdible;
+ mIsRotten = aIsRotten;
+ }
+
+ public GT_FoodStat setExplosive() {
+ mExplosive = true;
+ return this;
+ }
+
+ public GT_FoodStat setMilk() {
+ mMilk = true;
+ return this;
+ }
+
+ @Override
+ public int getFoodLevel(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
+ return mFoodLevel;
+ }
+
+ @Override
+ public float getSaturation(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
+ return mSaturation;
+ }
+
+ @Override
+ public void onEaten(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
+ aStack.stackSize--;
+ ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer));
+ if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack))
+ aPlayer.dropPlayerItemWithRandomChoice(tStack, true);
+ aPlayer.worldObj.playSoundAtEntity(aPlayer, "random.burp", 0.5F, aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F);
+ if (!aPlayer.worldObj.isRemote) {
+ if (mMilk) {
+ aPlayer.curePotionEffects(new ItemStack(Items.milk_bucket, 1, 0));
+ }
+ for (int i = 3; i < mPotionEffects.length; i += 4) {
+ if (aPlayer.worldObj.rand.nextInt(100) < mPotionEffects[i]) {
+ aPlayer.addPotionEffect(new PotionEffect(mPotionEffects[i - 3], mPotionEffects[i - 2], mPotionEffects[i - 1], mInvisibleParticles));
+ }
+ }
+ if (mExplosive) {
+ aPlayer.worldObj.newExplosion(aPlayer, aPlayer.posX, aPlayer.posY, aPlayer.posZ, 4, true, true);
+ aPlayer.attackEntityFrom(GT_DamageSources.getExplodingDamage(), Float.MAX_VALUE);
+ }
+ }
+ }
+
+ @Override
+ public EnumAction getFoodAction(GT_MetaBase_Item aItem, ItemStack aStack) {
+ return mAction;
+ }
+
+ @Override
+ public boolean alwaysEdible(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
+ return mAlwaysEdible;
+ }
+
+ @Override
+ public boolean isRotten(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
+ return mIsRotten;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java b/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java
new file mode 100644
index 0000000000..fd1d229284
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_IBoxableWrapper.java
@@ -0,0 +1,11 @@
+package gregtech.api.util;
+
+import ic2.api.item.IBoxable;
+import net.minecraft.item.ItemStack;
+
+public class GT_IBoxableWrapper implements IBoxable {
+ @Override
+ public boolean canBeStoredInToolbox(ItemStack itemstack) {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java b/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java
new file mode 100644
index 0000000000..c3b7d34eb4
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java
@@ -0,0 +1,16 @@
+package gregtech.api.util;
+
+public class GT_ItsNotMyFaultException extends RuntimeException {
+ private static final long serialVersionUID = -8752778866486460495L;
+
+ private String mError;
+
+ public GT_ItsNotMyFaultException(String aError) {
+ mError = aError;
+ }
+
+ @Override
+ public String toString() {
+ return "The GregTech-Addon has a Problem.\nIT'S NOT MY FAULT!!! Below is how to fix it.\n" + mError + "\nDO NOT COME TO ME WITH THIS CRASH. YOU CAUSED IT YOURSELF, AND I TOLD YOU HOW TO FIX IT!!!";
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java
new file mode 100644
index 0000000000..a60189ea71
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java
@@ -0,0 +1,95 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import gregtech.api.GregTech_API;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.common.config.Property;
+
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import static gregtech.api.enums.GT_Values.E;
+
+public class GT_LanguageManager {
+ public static final HashMap<String, String> TEMPMAP = new HashMap<String, String>(), BUFFERMAP = new HashMap<String, String>();
+ public static Configuration sEnglishFile;
+
+ public static String addStringLocalization(String aKey, String aEnglish) {
+ return addStringLocalization(aKey, aEnglish, true);
+ }
+
+ public static String addStringLocalization(String aKey, String aEnglish, boolean aWriteIntoLangFile) {
+ if (aKey == null) return E;
+ if (aWriteIntoLangFile) aEnglish = writeToLangFile(aKey, aEnglish);
+ TEMPMAP.put(aKey.trim(), aEnglish);
+ LanguageRegistry.instance().injectLanguage("en_US", TEMPMAP);
+ TEMPMAP.clear();
+ return aEnglish;
+ }
+
+ private static synchronized String writeToLangFile(String aKey, String aEnglish) {
+ if (aKey == null) return E;
+ if (sEnglishFile == null) {
+ BUFFERMAP.put(aKey.trim(), aEnglish);
+ } else {
+ if (!BUFFERMAP.isEmpty()) {
+ for (Entry<String, String> tEntry : BUFFERMAP.entrySet()) {
+ Property tProperty = sEnglishFile.get("LanguageFile", tEntry.getKey(), tEntry.getValue());
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sEnglishFile.save();
+ }
+ BUFFERMAP.clear();
+ }
+ Property tProperty = sEnglishFile.get("LanguageFile", aKey.trim(), aEnglish);
+ if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sEnglishFile.save();
+ if (sEnglishFile.get("EnableLangFile", "UseThisFileAsLanguageFile", false).getBoolean(false))
+ aEnglish = tProperty.getString();
+ }
+ return aEnglish;
+ }
+
+ public static String getTranslation(String aKey) {
+ if (aKey == null) return E;
+ String tTrimmedKey = aKey.trim(), rTranslation = LanguageRegistry.instance().getStringLocalization(tTrimmedKey);
+ if (GT_Utility.isStringInvalid(rTranslation)) {
+ rTranslation = StatCollector.translateToLocal(tTrimmedKey);
+ if (GT_Utility.isStringInvalid(rTranslation) || tTrimmedKey.equals(rTranslation)) {
+ if (aKey.endsWith(".name")) {
+ rTranslation = StatCollector.translateToLocal(tTrimmedKey.substring(0, tTrimmedKey.length() - 5));
+ if (GT_Utility.isStringInvalid(rTranslation) || tTrimmedKey.substring(0, tTrimmedKey.length() - 5).equals(rTranslation)) {
+ return aKey;
+ }
+ } else {
+ rTranslation = StatCollector.translateToLocal(tTrimmedKey + ".name");
+ if (GT_Utility.isStringInvalid(rTranslation) || (tTrimmedKey + ".name").equals(rTranslation)) {
+ return aKey;
+ }
+ }
+ }
+ }
+ return rTranslation;
+ }
+
+ public static String getTranslation(String aKey, String aSeperator) {
+ if (aKey == null) return E;
+ String rTranslation = E;
+ for (String tString : aKey.split(aSeperator)) {
+ rTranslation += getTranslation(tString);
+ }
+ return rTranslation;
+ }
+
+ public static String getTranslateableItemStackName(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return "null";
+ NBTTagCompound tNBT = aStack.getTagCompound();
+ if (tNBT != null && tNBT.hasKey("display")) {
+ String tName = tNBT.getCompoundTag("display").getString("Name");
+ if (GT_Utility.isStringValid(tName)) {
+ return tName;
+ }
+ }
+ return aStack.getUnlocalizedName() + ".name";
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Log.java b/src/main/java/gregtech/api/util/GT_Log.java
new file mode 100644
index 0000000000..2b840c1b1e
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Log.java
@@ -0,0 +1,38 @@
+package gregtech.api.util;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * Just a simple Logging Function. If on Server, then this will point to System.out and System.err
+ */
+public class GT_Log {
+ public static PrintStream out = System.out;
+ public static PrintStream err = System.err;
+ public static PrintStream ore = new LogBuffer();
+ public static PrintStream pal = null;
+ public static File mLogFile;
+ public static File mOreDictLogFile;
+ public static File mPlayerActivityLogFile;
+
+ public static class LogBuffer extends PrintStream {
+ public final List<String> mBufferedOreDictLog = new ArrayList<String>();
+
+ public LogBuffer() {
+ super(new OutputStream() {
+ @Override
+ public void write(int arg0) {/*Do nothing*/}
+ });
+ }
+
+ @Override
+ public void println(String aString) {
+ mBufferedOreDictLog.add(aString);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
new file mode 100644
index 0000000000..83fe3ff509
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -0,0 +1,1868 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.event.FMLInterModComms;
+import cpw.mods.fml.common.registry.GameRegistry;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.*;
+import gregtech.api.interfaces.IDamagableItem;
+import gregtech.api.interfaces.IItemContainer;
+import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
+import gregtech.api.objects.GT_HashSet;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.ItemData;
+import ic2.api.item.IBoxable;
+import ic2.api.item.IC2Items;
+import ic2.api.item.IElectricItem;
+import ic2.api.reactor.IReactorComponent;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeOutput;
+import net.minecraft.block.Block;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.*;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+import static gregtech.api.enums.GT_Values.*;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This is the Interface I use for interacting with other Mods.
+ * <p/>
+ * Due to the many imports, this File can cause compile Problems if not all the APIs are installed
+ */
+public class GT_ModHandler {
+ public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<IRecipe>(1000);
+ private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<String, ItemStack>();
+ private static final List<IRecipe> sAllRecipeList = Collections.synchronizedList(new ArrayList<IRecipe>(5000)), sBufferRecipeList = new ArrayList<IRecipe>(1000);
+ public static volatile int VERSION = 509;
+ public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>();
+ public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>();
+ public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false);
+ private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new HashMap<IRecipeInput, RecipeOutput>();
+ private static boolean sBufferCraftingRecipes = true;
+
+ static {
+ sNativeRecipeClasses.add(ShapedRecipes.class.getName());
+ sNativeRecipeClasses.add(ShapedOreRecipe.class.getName());
+ sNativeRecipeClasses.add(GT_Shaped_Recipe.class.getName());
+ sNativeRecipeClasses.add(ShapelessRecipes.class.getName());
+ sNativeRecipeClasses.add(ShapelessOreRecipe.class.getName());
+ sNativeRecipeClasses.add(GT_Shapeless_Recipe.class.getName());
+ sNativeRecipeClasses.add(ic2.core.AdvRecipe.class.getName());
+ sNativeRecipeClasses.add(ic2.core.AdvShapelessRecipe.class.getName());
+ sNativeRecipeClasses.add("appeng.recipes.game.ShapedRecipe");
+ sNativeRecipeClasses.add("appeng.recipes.game.ShapelessRecipe");
+ sNativeRecipeClasses.add("forestry.core.utils.ShapedRecipeCustom");
+
+ // Recipe Classes, which should never be removed.
+ sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipeFireworks.class.getName());
+ sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesArmorDyes.class.getName());
+ sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipeBookCloning.class.getName());
+ sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesMapCloning.class.getName());
+ sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesMapExtending.class.getName());
+ sSpecialRecipeClasses.add("jds.bibliocraft.BiblioSpecialRecipes");
+ sSpecialRecipeClasses.add("dan200.qcraft.shared.EntangledQBlockRecipe");
+ sSpecialRecipeClasses.add("dan200.qcraft.shared.EntangledQuantumComputerRecipe");
+ sSpecialRecipeClasses.add("dan200.qcraft.shared.QBlockRecipe");
+ sSpecialRecipeClasses.add("appeng.recipes.game.FacadeRecipe");
+ sSpecialRecipeClasses.add("appeng.recipes.game.DisassembleRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.carts.LocomotivePaintingRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RotorRepairRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RoutingTableCopyRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RoutingTicketCopyRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.TankCartFilterRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.emblems.LocomotiveEmblemRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.emblems.EmblemPostColorRecipe");
+ sSpecialRecipeClasses.add("mods.railcraft.common.emblems.EmblemPostEmblemRecipe");
+ sSpecialRecipeClasses.add("mods.immibis.redlogic.interaction.RecipeDyeLumarButton");
+ sSpecialRecipeClasses.add("thaumcraft.common.items.armor.RecipesRobeArmorDyes");
+ sSpecialRecipeClasses.add("thaumcraft.common.items.armor.RecipesVoidRobeArmorDyes");
+ sSpecialRecipeClasses.add("thaumcraft.common.lib.crafting.ShapelessNBTOreRecipe");
+ sSpecialRecipeClasses.add("twilightforest.item.TFMapCloningRecipe");
+ sSpecialRecipeClasses.add("forestry.lepidopterology.MatingRecipe");
+ sSpecialRecipeClasses.add("micdoodle8.mods.galacticraft.planets.asteroids.recipe.CanisterRecipes");
+ sSpecialRecipeClasses.add("shedar.mods.ic2.nuclearcontrol.StorageArrayRecipe");
+ }
+
+ /**
+ * Returns if that Liquid is Water or Distilled Water
+ */
+ public static boolean isWater(FluidStack aFluid) {
+ if (aFluid == null) return false;
+ return aFluid.isFluidEqual(getWater(1)) || aFluid.isFluidEqual(getDistilledWater(1));
+ }
+
+ /**
+ * Returns a Liquid Stack with given amount of Water.
+ */
+ public static FluidStack getWater(long aAmount) {
+ return FluidRegistry.getFluidStack("water", (int) aAmount);
+ }
+
+ /**
+ * Returns a Liquid Stack with given amount of distilled Water.
+ */
+ public static FluidStack getDistilledWater(long aAmount) {
+ return FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount);
+ }
+
+ /**
+ * Returns if that Liquid is Lava
+ */
+ public static boolean isLava(FluidStack aFluid) {
+ if (aFluid == null) return false;
+ return aFluid.isFluidEqual(getLava(1));
+ }
+
+ /**
+ * Returns a Liquid Stack with given amount of Lava.
+ */
+ public static FluidStack getLava(long aAmount) {
+ return FluidRegistry.getFluidStack("lava", (int) aAmount);
+ }
+
+ /**
+ * Returns if that Liquid is Steam
+ */
+ public static boolean isSteam(FluidStack aFluid) {
+ if (aFluid == null) return false;
+ return aFluid.isFluidEqual(getSteam(1));
+ }
+
+ /**
+ * Returns a Liquid Stack with given amount of Steam.
+ */
+ public static FluidStack getSteam(long aAmount) {
+ return FluidRegistry.getFluidStack("steam", (int) aAmount);
+ }
+
+ /**
+ * Returns if that Liquid is Milk
+ */
+ public static boolean isMilk(FluidStack aFluid) {
+ if (aFluid == null) return false;
+ return aFluid.isFluidEqual(getMilk(1));
+ }
+
+ /**
+ * Returns a Liquid Stack with given amount of Milk.
+ */
+ public static FluidStack getMilk(long aAmount) {
+ return FluidRegistry.getFluidStack("milk", (int) aAmount);
+ }
+
+ public static ItemStack getEmptyFuelCan(long aAmount) {
+ return ItemList.IC2_Fuel_Can_Empty.get(aAmount);
+ }
+
+ public static ItemStack getEmptyCell(long aAmount) {
+ return ItemList.Cell_Empty.get(aAmount);
+ }
+
+ public static ItemStack getAirCell(long aAmount) {
+ return ItemList.Cell_Air.get(aAmount);
+ }
+
+ public static ItemStack getWaterCell(long aAmount) {
+ return ItemList.Cell_Water.get(aAmount);
+ }
+
+ public static ItemStack getLavaCell(long aAmount) {
+ return ItemList.Cell_Lava.get(aAmount);
+ }
+
+ /**
+ * @param aValue the Value of this Stack, when burning inside a Furnace (200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU)), limited to Short because the vanilla Furnace otherwise can't handle it properly, stupid Mojang...
+ */
+ public static ItemStack setFuelValue(ItemStack aStack, short aValue) {
+ aStack.setTagCompound(GT_Utility.getNBTContainingShort(aStack.getTagCompound(), "GT.ItemFuelValue", aValue));
+ return aStack;
+ }
+
+ /**
+ * @return the Value of this Stack, when burning inside a Furnace (200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU)), limited to Short because the vanilla Furnace otherwise can't handle it properly, stupid Mojang...
+ */
+ public static short getFuelValue(ItemStack aStack) {
+ return (short) TileEntityFurnace.getItemBurnTime(aStack);
+ }
+
+ /**
+ * @param aValue Fuel value in EU
+ */
+ public static ItemStack getFuelCan(int aValue) {
+ if (aValue < 5) return ItemList.IC2_Fuel_Can_Empty.get(1);
+ ItemStack rFuelCanStack = ItemList.IC2_Fuel_Can_Filled.get(1);
+ if (rFuelCanStack == null) return null;
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("value", aValue / 5);
+ rFuelCanStack.setTagCompound(tNBT);
+ return rFuelCanStack;
+ }
+
+ /**
+ * @param aFuelCan the Item you want to check
+ * @return the exact Value in EU the Fuel Can is worth if its even a Fuel Can.
+ */
+ public static int getFuelCanValue(ItemStack aFuelCan) {
+ if (GT_Utility.isStackInvalid(aFuelCan) || !ItemList.IC2_Fuel_Can_Filled.isStackEqual(aFuelCan, false, true))
+ return 0;
+ NBTTagCompound tNBT = aFuelCan.getTagCompound();
+ return tNBT == null ? 0 : tNBT.getInteger("value") * 5;
+ }
+
+ /**
+ * Gets an Item from IndustrialCraft, and returns a Replacement Item if not possible
+ */
+ public static ItemStack getIC2Item(String aItem, long aAmount, ItemStack aReplacement) {
+ if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
+ //if (D1) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API");
+ if (!sIC2ItemMap.containsKey(aItem)) try {
+ ItemStack tStack = IC2Items.getItem(aItem);
+ sIC2ItemMap.put(aItem, tStack);
+ if (tStack == null && D1) GT_Log.err.println(aItem + " is not found in the IC2 Items!");
+ } catch (Throwable e) {/*Do nothing*/}
+ return GT_Utility.copyAmount(aAmount, sIC2ItemMap.get(aItem), aReplacement);
+ }
+
+ /**
+ * Gets an Item from IndustrialCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
+ */
+ public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
+ ItemStack rStack = getIC2Item(aItem, aAmount, aReplacement);
+ if (rStack == null) return null;
+ Items.feather.setDamage(rStack, aMeta);
+ return rStack;
+ }
+
+ /**
+ * Gets an Item from IndustrialCraft, but the Damage Value can be specified
+ */
+ public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta) {
+ return getIC2Item(aItem, aAmount, aMeta, null);
+ }
+
+ /**
+ * Gets an Item from IndustrialCraft
+ */
+ public static ItemStack getIC2Item(String aItem, long aAmount) {
+ return getIC2Item(aItem, aAmount, null);
+ }
+
+ /**
+ * Gets an Item from RailCraft
+ */
+ public static ItemStack getModItem(String aModID, String aItem, long aAmount) {
+ return getModItem(aModID, aItem, aAmount, null);
+ }
+
+ /**
+ * Gets an Item from RailCraft, and returns a Replacement Item if not possible
+ */
+ public static ItemStack getModItem(String aModID, String aItem, long aAmount, ItemStack aReplacement) {
+ if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
+ return GT_Utility.copyAmount(aAmount, GameRegistry.findItemStack(aModID, aItem, (int) aAmount), aReplacement);
+ }
+
+ /**
+ * Gets an Item from RailCraft, but the Damage Value can be specified
+ */
+ public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta) {
+ ItemStack rStack = getModItem(aModID, aItem, aAmount);
+ if (rStack == null) return null;
+ Items.feather.setDamage(rStack, aMeta);
+ return rStack;
+ }
+
+ /**
+ * Gets an Item from RailCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
+ */
+ public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
+ ItemStack rStack = getModItem(aModID, aItem, aAmount, aReplacement);
+ if (rStack == null) return null;
+ Items.feather.setDamage(rStack, aMeta);
+ return rStack;
+ }
+
+ /**
+ * OUT OF ORDER
+ */
+ public static boolean getModeKeyDown(EntityPlayer aPlayer) {
+ return false;
+ }
+
+ /**
+ * OUT OF ORDER
+ */
+ public static boolean getBoostKeyDown(EntityPlayer aPlayer) {
+ return false;
+ }
+
+ /**
+ * OUT OF ORDER
+ */
+ public static boolean getJumpKeyDown(EntityPlayer aPlayer) {
+ return false;
+ }
+
+ /**
+ * Adds a Valuable Ore to the Miner
+ */
+ public static boolean addValuableOre(Block aBlock, int aMeta, int aValue) {
+ if (aValue <= 0) return false;
+ try {
+ Class.forName("ic2.core.IC2").getMethod("addValuableOre", IRecipeInput.class, int.class).invoke(null, new RecipeInputItemStack(new ItemStack(aBlock, 1, aMeta)), aValue);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Adds a Scrapbox Drop. Fails at April first for the "suddenly Hoes"-Feature of IC2
+ */
+ public static boolean addScrapboxDrop(float aChance, ItemStack aOutput) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aOutput == null || aChance <= 0) return false;
+ aOutput.stackSize = 1;
+ if (GT_Config.troll && !GT_Utility.areStacksEqual(aOutput, new ItemStack(Items.wooden_hoe, 1, 0))) return false;
+ aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance);
+ if (aChance <= 0) return false;
+ try {
+ GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copy(aOutput), aChance);
+ GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copy(aOutput), aChance);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Adds an Item to the Recycler Blacklist
+ */
+ public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) {
+ if (aRecycledStack == null) return false;
+ try {
+ ic2.api.recipe.Recipes.recyclerBlacklist.add(new RecipeInputItemStack(aRecycledStack));
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Just simple Furnace smelting. Unbelievable how Minecraft fails at making a simple ItemStack->ItemStack mapping...
+ */
+ public static boolean addSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aInput == null || aOutput == null || GT_Utility.getContainerItem(aInput, false) != null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.smelting, aInput, true)) return false;
+ FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F);
+ return true;
+ }
+
+ /**
+ * Adds to Furnace AND Alloysmelter AND Induction Smelter
+ */
+ public static boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput, boolean hidden) {
+ if (aInput == null || aOutput == null) return false;
+ boolean temp = false;
+ if (aInput.stackSize == 1 && addSmeltingRecipe(aInput, aOutput)) temp = true;
+ if (RA.addAlloySmelterRecipe(aInput, OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, aOutput, 130, 3,hidden))
+ temp = true;
+ if (addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true;
+ return temp;
+ }
+
+ /**
+ * LiquidTransposer Recipe for both directions
+ */
+ public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) {
+ aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
+ if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposer, aFullContainer, true))
+ return false;
+ try {
+ ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, true);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * LiquidTransposer Recipe for filling Containers
+ */
+ public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) {
+ aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
+ if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true))
+ return false;
+ try {
+ ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, false);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * LiquidTransposer Recipe for emptying Containers
+ */
+ public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) {
+ aEmptyContainer = GT_OreDictUnificator.get(true, aEmptyContainer);
+ if (aFullContainer == null || aEmptyContainer == null || aLiquid == null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true))
+ return false;
+ try {
+ ThermalExpansion.addTransposerExtract(aMJ * 10, aFullContainer, aEmptyContainer, aLiquid, 100, false);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * IC2-Extractor Recipe. Overloads old Recipes automatically
+ */
+ public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aInput == null || aOutput == null) return false;
+ GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null);
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false;
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput);
+ return true;
+ }
+
+ /**
+ * RC-BlastFurnace Recipes
+ */
+ public static boolean addRCBlastFurnaceRecipe(ItemStack aInput, ItemStack aOutput, int aTime) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aInput == null || aOutput == null || aTime <= 0) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rcblastfurnace, aInput, true)) return false;
+ aInput = GT_Utility.copy(aInput);
+ aOutput = GT_Utility.copy(aOutput);
+ try {
+ mods.railcraft.api.crafting.RailcraftCraftingManager.blastFurnace.addRecipe(aInput, true, false, aTime, aOutput);
+ } catch (Throwable e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1) {
+ return addPulverisationRecipe(aInput, aOutput1, null, 0, false);
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2) {
+ return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, false);
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance) {
+ return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, false);
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, boolean aOverwrite) {
+ return addPulverisationRecipe(aInput, aOutput1, null, 0, aOverwrite);
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, boolean aOverwrite) {
+ return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, aOverwrite);
+ }
+
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance, boolean aOverwrite) {
+ return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, null, 0, aOverwrite);
+ }
+
+ /**
+ * Adds Several Pulverizer-Type Recipes.
+ */
+ public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3, boolean aOverwrite) {
+ aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
+ aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
+ if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false;
+ GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null);
+
+ if (GT_Utility.getContainerItem(aInput, false) == null) {
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
+ }
+
+ RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2);
+
+ if (!OrePrefixes.log.contains(aInput)) {
+ if (Materials.Wood.contains(aOutput1)) {
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) {
+ if (aOutput2 == null)
+ ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1));
+ else
+ ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2);
+ }
+ } else {
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rockcrushing, aInput, true)) {
+ try {
+ if (GT_Utility.getBlockFromStack(aInput) != Blocks.obsidian && GT_Utility.getBlockFromStack(aInput) != Blocks.gravel) {
+ mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != W, false);
+ tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F / aInput.stackSize);
+ if (aOutput2 != null)
+ tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize);
+ if (aOutput3 != null)
+ tRecipe.addOutput(GT_Utility.copy(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize);
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ }
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) {
+ if (aOutput2 == null)
+ ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1));
+ else
+ ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds a Recipe to the Sawmills of GregTech and ThermalCraft
+ */
+ public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2) {
+ aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
+ aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
+ if (aInput1 == null || aOutput1 == null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.sawmill, aInput1, true)) return false;
+ try {
+ ThermalExpansion.addSawmillRecipe(1600, aInput1, aOutput1, aOutput2, 100);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Induction Smelter Recipes and Alloy Smelter Recipes
+ */
+ public static boolean addAlloySmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt, boolean aAllowSecondaryInputEmpty) {
+ if (aInput1 == null || (aInput2 == null && !aAllowSecondaryInputEmpty) || aOutput1 == null) return false;
+ aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
+ boolean temp = false;
+ if (RA.addAlloySmelterRecipe(aInput1, aInput2, aOutput1, aDuration, aEUt)) temp = true;
+ if (addInductionSmelterRecipe(aInput1, aInput2, aOutput1, null, aDuration * aEUt * 2, 0)) temp = true;
+ return temp;
+ }
+
+ /**
+ * Induction Smelter Recipes for TE
+ */
+ public static boolean addInductionSmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aEnergy, int aChance) {
+ aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
+ aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
+ if (aInput1 == null || aOutput1 == null || GT_Utility.getContainerItem(aInput1, false) != null) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true))
+ return false;
+ try {
+ ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copy(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Smelts Ores to Ingots
+ */
+ public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aInput == null || aOutput == null) return false;
+ FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F);
+ return true;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getExtractorRecipeList() {
+ try {
+ return ic2.api.recipe.Recipes.extractor.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sExtractorRecipes;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getCompressorRecipeList() {
+ try {
+ return ic2.api.recipe.Recipes.compressor.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sCompressorRecipes;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getMaceratorRecipeList() {
+ try {
+ return ic2.api.recipe.Recipes.macerator.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sMaceratorRecipes;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getThermalCentrifugeRecipeList() {
+ try {
+ return ic2.api.recipe.Recipes.centrifuge.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sThermalCentrifugeRecipes;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getOreWashingRecipeList() {
+ try {
+ return ic2.api.recipe.Recipes.oreWashing.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sOreWashingRecipes;
+ }
+
+ public static Map<IRecipeInput, RecipeOutput> getMassFabricatorList() {
+ try {
+ return ic2.api.recipe.Recipes.matterAmplifier.getRecipes();
+ } catch (Throwable e) {/*Do nothing*/}
+ return sMassfabRecipes;
+ }
+
+ /**
+ * IC2-ThermalCentrifuge Recipe. Overloads old Recipes automatically
+ */
+ public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) {
+ if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
+ GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null);
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("minHeat", aHeat);
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput);
+ return true;
+ }
+
+ /**
+ * IC2-OreWasher Recipe. Overloads old Recipes automatically
+ */
+ public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) {
+ if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
+ GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null);
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("amount", aWaterAmount);
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput);
+ return true;
+ }
+
+ /**
+ * IC2-Compressor Recipe. Overloads old Recipes automatically
+ */
+ public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput) {
+ aOutput = GT_OreDictUnificator.get(true, aOutput);
+ if (aInput == null || aOutput == null) return false;
+ GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null);
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false;
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput);
+ return true;
+ }
+
+ /**
+ * @param aValue Scrap = 5000, Scrapbox = 45000, Diamond Dust 125000
+ */
+ public static boolean addIC2MatterAmplifier(ItemStack aAmplifier, int aValue) {
+ if (aAmplifier == null || aValue <= 0) return false;
+ if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.massfabamplifier, aAmplifier, true)) return false;
+ try {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("amplification", aValue);
+ GT_Utility.callMethod(ic2.api.recipe.Recipes.matterAmplifier, "addRecipe", false, false, false, aAmplifier, tNBT);
+ } catch (Throwable e) {/*Do nothing*/}
+ return true;
+ }
+
+ /**
+ * Rolling Machine Crafting Recipe
+ */
+ public static boolean addRollingMachineRecipe(ItemStack aResult, Object[] aRecipe) {
+ aResult = GT_OreDictUnificator.get(true, aResult);
+ if (aResult == null || aRecipe == null || aResult.stackSize <= 0) return false;
+ try {
+ mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copy(aResult), aRecipe));
+ } catch (Throwable e) {
+ return addCraftingRecipe(GT_Utility.copy(aResult), aRecipe);
+ }
+ return true;
+ }
+
+ public static void stopBufferingCraftingRecipes() {
+ sBufferCraftingRecipes = false;
+ for (IRecipe tRecipe : sBufferRecipeList) GameRegistry.addRecipe(tRecipe);
+ sBufferRecipeList.clear();
+ }
+
+ /**
+ * Shapeless Crafting Recipes. Deletes conflicting Recipes too.
+ */
+ public static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) {
+ return addCraftingRecipe(aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, false, true, false, false, false, false, false, false, false, false, false, false, true, aRecipe);
+ }
+
+ /**
+ * Regular Crafting Recipes. Deletes conflicting Recipes too.
+ * <p/>
+ * You can insert instances of IItemContainer into the Recipe Input Array directly without having to call "get(1)" on them.
+ * <p/>
+ * Enums are automatically getting their "name()"-Method called in order to deliver an OreDict String.
+ * <p/>
+ * Lowercase Letters are reserved for Tools. They are as follows:
+ * <p/>
+ * 'b' ToolDictNames.craftingToolBlade
+ * 'c' ToolDictNames.craftingToolCrowbar,
+ * 'd' ToolDictNames.craftingToolScrewdriver,
+ * 'f' ToolDictNames.craftingToolFile,
+ * 'h' ToolDictNames.craftingToolHardHammer,
+ * 'i' ToolDictNames.craftingToolSolderingIron,
+ * 'j' ToolDictNames.craftingToolSolderingMetal,
+ * 'k' ToolDictNames.craftingToolKnive
+ * 'm' ToolDictNames.craftingToolMortar,
+ * 'p' ToolDictNames.craftingToolDrawplate,
+ * 'r' ToolDictNames.craftingToolSoftHammer,
+ * 's' ToolDictNames.craftingToolSaw,
+ * 'w' ToolDictNames.craftingToolWrench,
+ * 'x' ToolDictNames.craftingToolWireCutter,
+ */
+ public static boolean addCraftingRecipe(ItemStack aResult, Object[] aRecipe) {
+ return addCraftingRecipe(aResult, 0, aRecipe);
+ }
+
+ /**
+ * Regular Crafting Recipes. Deletes conflicting Recipes too.
+ * <p/>
+ * You can insert instances of IItemContainer into the Recipe Input Array directly without having to call "get(1)" on them.
+ * <p/>
+ * Enums are automatically getting their "name()"-Method called in order to deliver an OreDict String.
+ * <p/>
+ * Lowercase Letters are reserved for Tools. They are as follows:
+ * <p/>
+ * 'b' ToolDictNames.craftingToolBlade
+ * 'c' ToolDictNames.craftingToolCrowbar,
+ * 'd' ToolDictNames.craftingToolScrewdriver,
+ * 'f' ToolDictNames.craftingToolFile,
+ * 'h' ToolDictNames.craftingToolHardHammer,
+ * 'i' ToolDictNames.craftingToolSolderingIron,
+ * 'j' ToolDictNames.craftingToolSolderingMetal,
+ * 'k' ToolDictNames.craftingToolKnive
+ * 'm' ToolDictNames.craftingToolMortar,
+ * 'p' ToolDictNames.craftingToolDrawplate,
+ * 'r' ToolDictNames.craftingToolSoftHammer,
+ * 's' ToolDictNames.craftingToolSaw,
+ * 'w' ToolDictNames.craftingToolWrench,
+ * 'x' ToolDictNames.craftingToolWireCutter,
+ */
+ public static boolean addCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) {
+ return addCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & RecipeBits.MIRRORED) != 0, (aBitMask & RecipeBits.BUFFERED) != 0, (aBitMask & RecipeBits.KEEPNBT) != 0, (aBitMask & RecipeBits.DISMANTLEABLE) != 0, (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, (aBitMask & RecipeBits.REVERSIBLE) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, aRecipe);
+ }
+
+ /**
+ * Internal realisation of the Crafting Recipe adding Process.
+ */
+ private static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) {
+ aResult = GT_OreDictUnificator.get(true, aResult);
+ if (aOnlyAddIfResultIsNotNull && aResult == null) return false;
+ if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0);
+ if (aRecipe == null || aRecipe.length <= 0) return false;
+
+ boolean tThereWasARecipe = false;
+
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] instanceof IItemContainer)
+ aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1);
+ else if (aRecipe[i] instanceof Enum)
+ aRecipe[i] = ((Enum) aRecipe[i]).name();
+ else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof ItemData || aRecipe[i] instanceof String || aRecipe[i] instanceof Character))
+ aRecipe[i] = aRecipe[i].toString();
+ }
+
+ try {
+ String shape = E;
+ int idx = 0;
+ if (aRecipe[idx] instanceof Boolean) {
+ throw new IllegalArgumentException();
+ }
+
+ ArrayList<Object> tRecipeList = new ArrayList<Object>(Arrays.asList(aRecipe));
+
+ while (aRecipe[idx] instanceof String) {
+ String s = (String) aRecipe[idx++];
+ shape += s;
+ while (s.length() < 3) s += " ";
+ if (s.length() > 3) throw new IllegalArgumentException();
+
+ for (char c : s.toCharArray()) {
+ switch (c) {
+ case 'b':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolBlade.name());
+ break;
+ case 'c':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolCrowbar.name());
+ break;
+ case 'd':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolScrewdriver.name());
+ break;
+ case 'f':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolFile.name());
+ break;
+ case 'h':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolHardHammer.name());
+ break;
+ case 'i':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolSolderingIron.name());
+ break;
+ case 'j':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolSolderingMetal.name());
+ break;
+ case 'k':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolKnife.name());
+ break;
+ case 'm':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolMortar.name());
+ break;
+ case 'p':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolDrawplate.name());
+ break;
+ case 'r':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolSoftHammer.name());
+ break;
+ case 's':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolSaw.name());
+ break;
+ case 'w':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolWrench.name());
+ break;
+ case 'x':
+ tRecipeList.add(c);
+ tRecipeList.add(ToolDictNames.craftingToolWireCutter.name());
+ break;
+ }
+ }
+ }
+
+ aRecipe = tRecipeList.toArray();
+
+ if (aRecipe[idx] instanceof Boolean) {
+ idx++;
+ }
+ HashMap<Character, ItemStack> tItemStackMap = new HashMap<Character, ItemStack>();
+ HashMap<Character, ItemData> tItemDataMap = new HashMap<Character, ItemData>();
+ tItemStackMap.put(' ', null);
+
+ boolean tRemoveRecipe = true;
+
+ for (; idx < aRecipe.length; idx += 2) {
+ if (aRecipe[idx] == null || aRecipe[idx + 1] == null) {
+ if (D1) {
+ GT_Log.err.println("WARNING: Missing Item for shaped Recipe: " + (aResult == null ? "null" : aResult.getDisplayName()));
+ for (Object tContent : aRecipe) GT_Log.err.println(tContent);
+ }
+ return false;
+ }
+ Character chr = (Character) aRecipe[idx];
+ Object in = aRecipe[idx + 1];
+ if (in instanceof ItemStack) {
+ tItemStackMap.put(chr, GT_Utility.copy((ItemStack) in));
+ tItemDataMap.put(chr, GT_OreDictUnificator.getItemData((ItemStack) in));
+ } else if (in instanceof ItemData) {
+ String tString = in.toString();
+ if (tString.equals("plankWood")) {
+ tItemDataMap.put(chr, new ItemData(Materials.Wood, M));
+ } else if (tString.equals("stoneNetherrack")) {
+ tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M));
+ } else if (tString.equals("stoneObsidian")) {
+ tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M));
+ } else if (tString.equals("stoneEndstone")) {
+ tItemDataMap.put(chr, new ItemData(Materials.Endstone, M));
+ } else {
+ tItemDataMap.put(chr, (ItemData) in);
+ }
+ ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1);
+ if (tStack == null) tRemoveRecipe = false;
+ else tItemStackMap.put(chr, tStack);
+ in = aRecipe[idx + 1] = in.toString();
+ } else if (in instanceof String) {
+ if (in.equals(OreDictNames.craftingChest.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Wood, M * 8));
+ else if (in.equals(OreDictNames.craftingBook.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Paper, M * 3));
+ else if (in.equals(OreDictNames.craftingPiston.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 4, Materials.Wood, M * 3));
+ else if (in.equals(OreDictNames.craftingFurnace.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 8));
+ else if (in.equals(OreDictNames.craftingIndustrialDiamond.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Diamond, M));
+ else if (in.equals(OreDictNames.craftingAnvil.toString()))
+ tItemDataMap.put(chr, new ItemData(Materials.Iron, M * 10));
+ ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1);
+ if (tStack == null) tRemoveRecipe = false;
+ else tItemStackMap.put(chr, tStack);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ if (aReversible && aResult != null) {
+ ItemData[] tData = new ItemData[9];
+ int x = -1;
+ for (char chr : shape.toCharArray()) tData[++x] = tItemDataMap.get(chr);
+ if (GT_Utility.arrayContainsNonNull(tData))
+ GT_OreDictUnificator.addItemData(aResult, new ItemData(tData));
+ }
+
+ if (aCheckForCollisions && tRemoveRecipe) {
+ ItemStack[] tRecipe = new ItemStack[9];
+ int x = -1;
+ for (char chr : shape.toCharArray()) {
+ tRecipe[++x] = tItemStackMap.get(chr);
+ if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W)
+ Items.feather.setDamage(tRecipe[x], 0);
+ }
+ tThereWasARecipe = removeRecipe(tRecipe) != null || tThereWasARecipe;
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+
+ if (aResult == null || aResult.stackSize <= 0) return false;
+
+ if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT || aRemoveAllOtherShapedsWithSameOutput || aRemoveAllOtherNativeRecipes)
+ tThereWasARecipe = removeRecipeByOutput(aResult, !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, aRemoveAllOtherShapedsWithSameOutput, aRemoveAllOtherNativeRecipes) || tThereWasARecipe;
+
+ if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) {
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+ for (int i = 0; i < tList.size() && !tThereWasARecipe; i++) {
+ IRecipe tRecipe = tList.get(i);
+ if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue;
+ if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) {
+ tList.remove(i--);
+ tThereWasARecipe = true;
+ }
+ }
+ }
+
+ if (Items.feather.getDamage(aResult) == W || Items.feather.getDamage(aResult) < 0)
+ Items.feather.setDamage(aResult, 0);
+
+ GT_Utility.updateItemStack(aResult);
+
+ if (tThereWasARecipe || !aOnlyAddIfThereIsAnyRecipeOutputtingThis) {
+ if (sBufferCraftingRecipes && aBuffered)
+ sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored));
+ else
+ GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored));
+ }
+ return true;
+ }
+
+ /**
+ * Shapeless Crafting Recipes. Deletes conflicting Recipes too.
+ */
+ public static boolean addShapelessEnchantingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) {
+ return addShapelessCraftingRecipe(aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, true, false, false, false, aRecipe);
+ }
+
+ /**
+ * Shapeless Crafting Recipes. Deletes conflicting Recipes too.
+ */
+ public static boolean addShapelessCraftingRecipe(ItemStack aResult, Object[] aRecipe) {
+ return addShapelessCraftingRecipe(aResult, RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, aRecipe);
+ }
+
+ /**
+ * Shapeless Crafting Recipes. Deletes conflicting Recipes too.
+ */
+ public static boolean addShapelessCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) {
+ return addShapelessCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & RecipeBits.BUFFERED) != 0, (aBitMask & RecipeBits.KEEPNBT) != 0, (aBitMask & RecipeBits.DISMANTLEABLE) != 0, (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, aRecipe);
+ }
+
+ /**
+ * Shapeless Crafting Recipes. Deletes conflicting Recipes too.
+ */
+ private static boolean addShapelessCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, Object[] aRecipe) {
+ aResult = GT_OreDictUnificator.get(true, aResult);
+ if (aRecipe == null || aRecipe.length <= 0) return false;
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] instanceof IItemContainer)
+ aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1);
+ else if (aRecipe[i] instanceof Enum)
+ aRecipe[i] = ((Enum) aRecipe[i]).name();
+ else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof String || aRecipe[i] instanceof Character))
+ aRecipe[i] = aRecipe[i].toString();
+ }
+ try {
+ ItemStack[] tRecipe = new ItemStack[9];
+ int i = 0;
+ for (Object tObject : aRecipe) {
+ if (tObject == null) {
+ if (D1)
+ GT_Log.err.println("WARNING: Missing Item for shapeless Recipe: " + (aResult == null ? "null" : aResult.getDisplayName()));
+ for (Object tContent : aRecipe) GT_Log.err.println(tContent);
+ return false;
+ }
+ if (tObject instanceof ItemStack) {
+ tRecipe[i] = (ItemStack) tObject;
+ } else if (tObject instanceof String) {
+ tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1);
+ if (tRecipe[i] == null) break;
+ } else if (tObject instanceof Boolean) {
+ //
+ } else {
+ throw new IllegalArgumentException();
+ }
+ i++;
+ }
+ removeRecipe(tRecipe);
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+
+ if (aResult == null || aResult.stackSize <= 0) return false;
+
+ if (Items.feather.getDamage(aResult) == W || Items.feather.getDamage(aResult) < 0)
+ Items.feather.setDamage(aResult, 0);
+
+ GT_Utility.updateItemStack(aResult);
+
+ if (sBufferCraftingRecipes && aBuffered)
+ sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe));
+ else
+ GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe));
+ return true;
+ }
+
+ /**
+ * Removes a Smelting Recipe
+ */
+ public static boolean removeFurnaceSmelting(ItemStack aInput) {
+ if (aInput != null) {
+ for (Object tInput : FurnaceRecipes.smelting().getSmeltingList().keySet()) {
+ if (GT_Utility.isStackValid(tInput) && GT_Utility.areStacksEqual(aInput, (ItemStack) tInput, true)) {
+ FurnaceRecipes.smelting().getSmeltingList().remove(tInput);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Removes a Crafting Recipe and gives you the former output of it.
+ *
+ * @param aRecipe The content of the Crafting Grid as ItemStackArray with length 9
+ * @return the output of the old Recipe or null if there was nothing.
+ */
+ public static ItemStack removeRecipe(ItemStack... aRecipe) {
+ if (aRecipe == null) return null;
+ boolean temp = false;
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] != null) {
+ temp = true;
+ break;
+ }
+ }
+ if (!temp) return null;
+ ItemStack rReturn = null;
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return false;
+ }
+ }, 3, 3);
+ for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+ for (int i = 0; i < tList.size(); i++) {
+ try {
+ for (; i < tList.size(); i++) {
+ if ((!(tList.get(i) instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tList.get(i)).isRemovable()) && tList.get(i).matches(aCrafting, DW)) {
+ rReturn = tList.get(i).getCraftingResult(aCrafting);
+ if (rReturn != null) tList.remove(i--);
+ }
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+ return rReturn;
+ }
+
+ public static boolean removeRecipeByOutput(ItemStack aOutput) {
+ return removeRecipeByOutput(aOutput, true, false, false);
+ }
+
+ /**
+ * Removes a Crafting Recipe.
+ *
+ * @param aOutput The output of the Recipe.
+ * @return if it has removed at least one Recipe.
+ */
+ public static boolean removeRecipeByOutput(ItemStack aOutput, boolean aIgnoreNBT, boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) {
+ if (aOutput == null) return false;
+ boolean rReturn = false;
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+ aOutput = GT_OreDictUnificator.get(aOutput);
+ for (int i = 0; i < tList.size(); i++) {
+ IRecipe tRecipe = tList.get(i);
+ if (aNotRemoveShapelessRecipes && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe))
+ continue;
+ if (aOnlyRemoveNativeHandlers) {
+ if (!sNativeRecipeClasses.contains(tRecipe.getClass().getName())) continue;
+ } else {
+ if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue;
+ }
+ ItemStack tStack = tRecipe.getRecipeOutput();
+ if ((!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) {
+ tList.remove(i--);
+ rReturn = true;
+ }
+ }
+ return rReturn;
+ }
+
+ /**
+ * Checks all Crafting Handlers for Recipe Output
+ * Used for the Autocrafting Table
+ */
+ public static ItemStack getAllRecipeOutput(World aWorld, ItemStack... aRecipe) {
+ if (aRecipe == null || aRecipe.length == 0) return null;
+
+ if (aWorld == null) aWorld = DW;
+
+ boolean temp = false;
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] != null) {
+ temp = true;
+ break;
+ }
+ }
+ if (!temp) return null;
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return false;
+ }
+ }, 3, 3);
+ for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ List<IRecipe> tList = CraftingManager.getInstance().getRecipeList();
+ synchronized (sAllRecipeList) {
+ if (sAllRecipeList.size() != tList.size()) {
+ sAllRecipeList.clear();
+ sAllRecipeList.addAll(tList);
+ }
+ for (int i = 0, j = sAllRecipeList.size(); i < j; i++) {
+ IRecipe tRecipe = sAllRecipeList.get(i);
+ if (tRecipe.matches(aCrafting, aWorld)) {
+ if (i > 10) {
+ sAllRecipeList.remove(i);
+ sAllRecipeList.add(i - 10, tRecipe);
+ }
+ return tRecipe.getCraftingResult(aCrafting);
+ }
+ }
+ }
+
+ int tIndex = 0;
+ ItemStack tStack1 = null, tStack2 = null;
+ for (int i = 0, j = aCrafting.getSizeInventory(); i < j; i++) {
+ ItemStack tStack = aCrafting.getStackInSlot(i);
+ if (tStack != null) {
+ if (tIndex == 0) tStack1 = tStack;
+ if (tIndex == 1) tStack2 = tStack;
+ tIndex++;
+ }
+ }
+
+ if (tIndex == 2) {
+ assert tStack1 != null && tStack2 != null;
+ if (tStack1.getItem() == tStack2.getItem() && tStack1.stackSize == 1 && tStack2.stackSize == 1 && tStack1.getItem().isRepairable()) {
+ int tNewDamage = tStack1.getMaxDamage() + tStack1.getItemDamage() - tStack2.getItemDamage() + tStack1.getMaxDamage() / 20;
+ return new ItemStack(tStack1.getItem(), 1, tNewDamage < 0 ? 0 : tNewDamage);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Gives you a copy of the Output from a Crafting Recipe
+ * Used for Recipe Detection.
+ */
+ public static ItemStack getRecipeOutput(ItemStack... aRecipe) {
+ return getRecipeOutput(false, aRecipe);
+ }
+
+ /**
+ * Gives you a copy of the Output from a Crafting Recipe
+ * Used for Recipe Detection.
+ */
+ public static ItemStack getRecipeOutput(boolean aUncopiedStack, ItemStack... aRecipe) {
+ if (aRecipe == null) return null;
+ boolean temp = false;
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] != null) {
+ temp = true;
+ break;
+ }
+ }
+ if (!temp) return null;
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return false;
+ }
+ }, 3, 3);
+ for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
+ for (int i = 0; i < tList.size(); i++) {
+ temp = false;
+ try {
+ temp = tList.get(i).matches(aCrafting, DW);
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ if (temp) {
+ ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting);
+ if (tOutput == null || tOutput.stackSize <= 0) {
+ // Seriously, who would ever do that shit?
+ if (!GregTech_API.sPostloadFinished)
+ throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that.");
+ } else {
+ if (aUncopiedStack) return tOutput;
+ return GT_Utility.copy(tOutput);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gives you a list of the Outputs from a Crafting Recipe
+ * If you have multiple Mods, which add Bronze Armor for example
+ * This also removes old Recipes from the List.
+ */
+ public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) {
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished)
+ sSingleNonBlockDamagableRecipeList.clear();
+ if (sSingleNonBlockDamagableRecipeList.isEmpty()) {
+ for (IRecipe tRecipe : (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
+ ItemStack tStack = tRecipe.getRecipeOutput();
+ if (GT_Utility.isStackValid(tStack) && tStack.getMaxStackSize() == 1 && tStack.getMaxDamage() > 0 && !(tStack.getItem() instanceof ItemBlock) && !(tStack.getItem() instanceof IReactorComponent) && !isElectricItem(tStack) && !GT_Utility.isStackInList(tStack, sNonReplaceableItems)) {
+ if (!(tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) {
+ if (tRecipe instanceof ShapedOreRecipe) {
+ boolean temp = true;
+ for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput())
+ if (tObject != null) {
+ if (tObject instanceof ItemStack && (((ItemStack) tObject).getItem() == null || ((ItemStack) tObject).getMaxStackSize() < 2 || ((ItemStack) tObject).getMaxDamage() > 0 || ((ItemStack) tObject).getItem() instanceof ItemBlock)) {
+ temp = false;
+ break;
+ }
+ if (tObject instanceof List && ((List) tObject).isEmpty()) {
+ temp = false;
+ break;
+ }
+ }
+ if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe);
+ } else if (tRecipe instanceof ShapedRecipes) {
+ boolean temp = true;
+ for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) {
+ if (tObject != null && (tObject.getItem() == null || tObject.getMaxStackSize() < 2 || tObject.getMaxDamage() > 0 || tObject.getItem() instanceof ItemBlock)) {
+ temp = false;
+ break;
+ }
+ }
+ if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe);
+ } else {
+ sSingleNonBlockDamagableRecipeList.add(tRecipe);
+ }
+ }
+ }
+ }
+ GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size() > 1024 ? " Scanning all these Recipes is the reason for the startup Lag you receive right now." : E));
+ }
+ ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe);
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished)
+ sSingleNonBlockDamagableRecipeList.clear();
+ return rList;
+ }
+
+ /**
+ * Gives you a list of the Outputs from a Crafting Recipe
+ * If you have multiple Mods, which add Bronze Armor for example
+ */
+ public static ArrayList<ItemStack> getRecipeOutputs(ItemStack... aRecipe) {
+ return getRecipeOutputs(CraftingManager.getInstance().getRecipeList(), false, aRecipe);
+ }
+
+ /**
+ * Gives you a list of the Outputs from a Crafting Recipe
+ * If you have multiple Mods, which add Bronze Armor for example
+ */
+ public static ArrayList<ItemStack> getRecipeOutputs(List<IRecipe> aList, boolean aDeleteFromList, ItemStack... aRecipe) {
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ if (aRecipe == null) return rList;
+ boolean temp = false;
+ for (byte i = 0; i < aRecipe.length; i++) {
+ if (aRecipe[i] != null) {
+ temp = true;
+ break;
+ }
+ }
+ if (!temp) return rList;
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return false;
+ }
+ }, 3, 3);
+ for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
+ for (int i = 0; i < aList.size(); i++) {
+ temp = false;
+ try {
+ temp = aList.get(i).matches(aCrafting, DW);
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ if (temp) {
+ ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting);
+ if (tOutput == null || tOutput.stackSize <= 0) {
+ // Seriously, who would ever do that shit?
+ if (!GregTech_API.sPostloadFinished)
+ throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that.");
+ } else {
+ rList.add(GT_Utility.copy(tOutput));
+ if (aDeleteFromList) aList.remove(i--);
+ }
+ }
+ }
+ return rList;
+ }
+
+ /**
+ * Used in my own Macerator. Decreases StackSize of the Input if wanted.
+ */
+ public static ItemStack getMaceratorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) {
+ return GT_Utility.copy(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]);
+ }
+
+ /**
+ * Used in my own Extractor. Decreases StackSize of the Input if wanted.
+ */
+ public static ItemStack getExtractorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) {
+ return GT_Utility.copy(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]);
+ }
+
+ /**
+ * Used in my own Compressor. Decreases StackSize of the Input if wanted.
+ */
+ public static ItemStack getCompressorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) {
+ return GT_Utility.copy(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]);
+ }
+
+ /**
+ * Used in my own Furnace.
+ */
+ public static ItemStack getSmeltingOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) {
+ if (aInput == null || aInput.stackSize < 1) return null;
+ ItemStack rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput));
+ if (rStack != null && (aOutputSlot == null || (GT_Utility.areStacksEqual(rStack, aOutputSlot) && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) {
+ if (aRemoveInput) aInput.stackSize--;
+ return rStack;
+ }
+ return null;
+ }
+
+ /**
+ * Used in my own Machines. Decreases StackSize of the Input if wanted.
+ * <p/>
+ * Checks also if there is enough Space in the Output Slots.
+ */
+ public static ItemStack[] getMachineOutput(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, boolean aRemoveInput, NBTTagCompound rRecipeMetaData, ItemStack... aOutputSlots) {
+ if (aOutputSlots == null || aOutputSlots.length <= 0) return new ItemStack[0];
+ if (aInput == null) return new ItemStack[aOutputSlots.length];
+ try {
+ for (Entry<IRecipeInput, RecipeOutput> tEntry : aRecipeList.entrySet()) {
+ if (tEntry.getKey().matches(aInput)) {
+ if (tEntry.getKey().getAmount() <= aInput.stackSize) {
+ ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray();
+ if (tList.length == 0) break;
+ ItemStack[] rList = new ItemStack[aOutputSlots.length];
+ rRecipeMetaData.setTag("return", tEntry.getValue().metadata);
+ for (byte i = 0; i < aOutputSlots.length && i < tList.length; i++) {
+ if (tList[i] != null) {
+ if (aOutputSlots[i] == null || (GT_Utility.areStacksEqual(tList[i], aOutputSlots[i]) && tList[i].stackSize + aOutputSlots[i].stackSize <= aOutputSlots[i].getMaxStackSize())) {
+ rList[i] = GT_Utility.copy(tList[i]);
+ } else {
+ return new ItemStack[aOutputSlots.length];
+ }
+ }
+ }
+
+ if (aRemoveInput) aInput.stackSize -= tEntry.getKey().getAmount();
+ return rList;
+ }
+ break;
+ }
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ return new ItemStack[aOutputSlots.length];
+ }
+
+ /**
+ * Used in my own Recycler.
+ * <p/>
+ * Only produces Scrap if aScrapChance == 0. aScrapChance is usually the random Number I give to the Function
+ * If you directly insert 0 as aScrapChance then you can check if its Recycler-Blacklisted or similar
+ */
+ public static ItemStack getRecyclerOutput(ItemStack aInput, int aScrapChance) {
+ if (aInput == null || aScrapChance != 0) return null;
+ try {
+ if (ic2.api.recipe.Recipes.recyclerWhitelist.isEmpty())
+ return ic2.api.recipe.Recipes.recyclerBlacklist.contains(aInput) ? null : ItemList.IC2_Scrap.get(1);
+ return ic2.api.recipe.Recipes.recyclerWhitelist.contains(aInput) ? ItemList.IC2_Scrap.get(1) : null;
+ } catch (Throwable e) {/*Do nothing*/}
+ try {
+ return ic2.api.recipe.Recipes.recyclerBlacklist.contains(aInput) ? null : ItemList.IC2_Scrap.get(1);
+ } catch (Throwable e) {/*Do nothing*/}
+ return null;
+ }
+
+ /**
+ * For the Scrapboxinator
+ */
+ public static ItemStack getRandomScrapboxDrop() {
+ return ic2.api.recipe.Recipes.scrapboxDrops.getDrop(ItemList.IC2_Scrapbox.get(1), false);
+ }
+
+ /**
+ * Charges an Electric Item. Only if it's a valid Electric Item of course.
+ * This forces the Usage of proper Voltages (so not the transfer limits defined by the Items) unless you ignore the Transfer Limit.
+ * If aTier is Integer.MAX_VALUE it will ignore Tier based Limitations.
+ *
+ * @return the actually used Energy.
+ */
+ public static int chargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate) {
+ try {
+ if (isElectricItem(aStack)) {
+ int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack);
+ if (tTier < 0 || tTier == aTier || aTier == Integer.MAX_VALUE) {
+ if (!aIgnoreLimit && tTier >= 0)
+ aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))]);
+ if (aCharge > 0) {
+ int rCharge = (int) Math.max(0.0, ic2.api.item.ElectricItem.manager.charge(aStack, aCharge, tTier, true, aSimulate));
+ return rCharge + (rCharge * 4 > aTier ? aTier : 0);
+ }
+ }
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ return 0;
+ }
+
+ /**
+ * Discharges an Electric Item. Only if it's a valid Electric Item for that of course.
+ * This forces the Usage of proper Voltages (so not the transfer limits defined by the Items) unless you ignore the Transfer Limit.
+ * If aTier is Integer.MAX_VALUE it will ignore Tier based Limitations.
+ *
+ * @return the Energy got from the Item.
+ */
+ public static int dischargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate, boolean aIgnoreDischargability) {
+ try {
+// if (isElectricItem(aStack) && (aIgnoreDischargability || ((ic2.api.item.IElectricItem)aStack.getItem()).canProvideEnergy(aStack))) {
+ if (isElectricItem(aStack)) {
+ int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack);
+ if (tTier < 0 || tTier == aTier || aTier == Integer.MAX_VALUE) {
+ if (!aIgnoreLimit && tTier >= 0)
+ aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))]);
+ if (aCharge > 0) {
+// int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate));
+ int rCharge = (int) Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, true, !aIgnoreDischargability, aSimulate));
+ return rCharge - (rCharge * 4 > aTier ? aTier : 0);
+ }
+ }
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ return 0;
+ }
+
+ /**
+ * Uses an Electric Item. Only if it's a valid Electric Item for that of course.
+ *
+ * @return if the action was successful
+ */
+ public static boolean canUseElectricItem(ItemStack aStack, int aCharge) {
+ try {
+ if (isElectricItem(aStack)) {
+ return ic2.api.item.ElectricItem.manager.canUse(aStack, aCharge);
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ return false;
+ }
+
+ /**
+ * Uses an Electric Item. Only if it's a valid Electric Item for that of course.
+ *
+ * @return if the action was successful
+ */
+ public static boolean useElectricItem(ItemStack aStack, int aCharge, EntityPlayer aPlayer) {
+ try {
+ if (isElectricItem(aStack)) {
+ ic2.api.item.ElectricItem.manager.use(aStack, 0, aPlayer);
+ if (ic2.api.item.ElectricItem.manager.canUse(aStack, aCharge)) {
+ return ic2.api.item.ElectricItem.manager.use(aStack, aCharge, aPlayer);
+ }
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ return false;
+ }
+
+ /**
+ * Uses an Item. Tries to discharge in case of Electric Items
+ */
+ public static boolean damageOrDechargeItem(ItemStack aStack, int aDamage, int aDecharge, EntityLivingBase aPlayer) {
+ if (GT_Utility.isStackInvalid(aStack) || (aStack.getMaxStackSize() <= 1 && aStack.stackSize > 1)) return false;
+ if (aPlayer != null && aPlayer instanceof EntityPlayer && ((EntityPlayer) aPlayer).capabilities.isCreativeMode)
+ return true;
+ if (aStack.getItem() instanceof IDamagableItem) {
+ return ((IDamagableItem) aStack.getItem()).doDamageToItem(aStack, aDamage);
+ } else if (GT_ModHandler.isElectricItem(aStack)) {
+ if (canUseElectricItem(aStack, aDecharge)) {
+ if (aPlayer != null && aPlayer instanceof EntityPlayer) {
+ return GT_ModHandler.useElectricItem(aStack, aDecharge, (EntityPlayer) aPlayer);
+ }
+ return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, true) >= aDecharge;
+ }
+ } else if (aStack.getItem().isDamageable()) {
+ if (aPlayer == null) {
+ aStack.setItemDamage(aStack.getItemDamage() + aDamage);
+ } else {
+ aStack.damageItem(aDamage, aPlayer);
+ }
+ if (aStack.getItemDamage() >= aStack.getMaxDamage()) {
+ aStack.setItemDamage(aStack.getMaxDamage() + 1);
+ ItemStack tStack = GT_Utility.getContainerItem(aStack, true);
+ if (tStack != null) {
+ aStack.func_150996_a(tStack.getItem());
+ aStack.setItemDamage(tStack.getItemDamage());
+ aStack.stackSize = tStack.stackSize;
+ aStack.setTagCompound(tStack.getTagCompound());
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Uses a Soldering Iron
+ */
+ public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer) {
+ if (aPlayer == null || aStack == null) return false;
+ if (GT_Utility.isStackInList(aStack, GregTech_API.sSolderingToolList)) {
+ if (aPlayer instanceof EntityPlayer) {
+ EntityPlayer tPlayer = (EntityPlayer) aPlayer;
+ if (tPlayer.capabilities.isCreativeMode) return true;
+ if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) {
+ for (int i = 0; i < tPlayer.inventory.mainInventory.length; i++) {
+ if (GT_Utility.isStackInList(tPlayer.inventory.mainInventory[i], GregTech_API.sSolderingMetalList)) {
+ if (tPlayer.inventory.mainInventory[i].stackSize < 1) return false;
+ if (tPlayer.inventory.mainInventory[i].stackSize == 1) {
+ tPlayer.inventory.mainInventory[i] = null;
+ } else {
+ tPlayer.inventory.mainInventory[i].stackSize--;
+ }
+ if (tPlayer.inventoryContainer != null) tPlayer.inventoryContainer.detectAndSendChanges();
+ if (canUseElectricItem(aStack, 10000)) {
+ return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer);
+ }
+ GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer);
+ return false;
+ }
+ }
+ }
+ } else {
+ damageOrDechargeItem(aStack, 1, 1000, aPlayer);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Is this an electric Item, which can charge other Items?
+ */
+ public static boolean isChargerItem(ItemStack aStack) {
+ try {
+ if (isElectricItem(aStack)) {
+ return ((ic2.api.item.IElectricItem) aStack.getItem()).canProvideEnergy(aStack);
+ }
+ } catch (Throwable e) {/*Do nothing*/}
+ return false;
+ }
+
+ /**
+ * Is this an electric Item?
+ */
+ public static boolean isElectricItem(ItemStack aStack) {
+ try {
+ return aStack != null && aStack.getItem() instanceof ic2.api.item.IElectricItem && ((IElectricItem) aStack.getItem()).getTier(aStack) < Integer.MAX_VALUE;
+ } catch (Throwable e) {/*Do nothing*/}
+ return false;
+ }
+
+ public static boolean isElectricItem(ItemStack aStack, byte aTier) {
+ try {
+ return aStack != null && aStack.getItem() instanceof ic2.api.item.IElectricItem && ((IElectricItem) aStack.getItem()).getTier(aStack) == aTier;
+ } catch (Throwable e) {/*Do nothing*/}
+ return false;
+ }
+
+ public static void registerBoxableItemToToolBox(ItemStack aStack) {
+ if (aStack != null) registerBoxableItemToToolBox(aStack.getItem());
+ }
+
+ public static void registerBoxableItemToToolBox(Item aItem) {
+ if (aItem != null && sBoxableWrapper != null) {
+ try {
+ ic2.api.item.ItemWrapper.registerBoxable(aItem, (IBoxable) sBoxableWrapper);
+ } catch (Throwable e) {/*Do nothing*/}
+ }
+ }
+
+ public static int getCapsuleCellContainerCountMultipliedWithStackSize(ItemStack... aStacks) {
+ int rAmount = 0;
+ for (ItemStack tStack : aStacks)
+ if (tStack != null) rAmount += getCapsuleCellContainerCount(tStack) * tStack.stackSize;
+ return rAmount;
+ }
+
+ public static int getCapsuleCellContainerCount(ItemStack aStack) {
+ if (aStack == null) return 0;
+ return GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(aStack, true), ItemList.Cell_Empty.get(1)) || OrePrefixes.cell.contains(aStack) || OrePrefixes.cellPlasma.contains(aStack) || GT_Utility.areStacksEqual(aStack, getIC2Item("waterCell", 1, W)) ? 1 : 0;
+ }
+
+ public static class RecipeBits {
+ /**
+ * Mirrors the Recipe
+ */
+ public static long MIRRORED = B[0];
+ /**
+ * Buffers the Recipe for later addition. This makes things more efficient.
+ */
+ public static long BUFFERED = B[1];
+ /**
+ * This is a special Tag I used for crafting Coins up and down.
+ */
+ public static long KEEPNBT = B[2];
+ /**
+ * Makes the Recipe Reverse Craftable in the Disassembler.
+ */
+ public static long DISMANTLEABLE = B[3];
+ /**
+ * Prevents the Recipe from accidentally getting removed by my own Handlers.
+ */
+ public static long NOT_REMOVABLE = B[4];
+ /**
+ * Reverses the Output of the Recipe for smelting and pulverising.
+ */
+ public static long REVERSIBLE = B[5];
+ /**
+ * Removes all Recipes with the same Output Item regardless of NBT, unless another Recipe Deletion Bit is added too.
+ */
+ public static long DELETE_ALL_OTHER_RECIPES = B[6];
+ /**
+ * Removes all Recipes with the same Output Item limited to the same NBT.
+ */
+ public static long DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT = B[7];
+ /**
+ * Removes all Recipes with the same Output Item limited to Shaped Recipes.
+ */
+ public static long DELETE_ALL_OTHER_SHAPED_RECIPES = B[8];
+ /**
+ * Removes all Recipes with the same Output Item limited to native Recipe Handlers.
+ */
+ public static long DELETE_ALL_OTHER_NATIVE_RECIPES = B[9];
+ /**
+ * Disables the check for colliding Recipes.
+ */
+ public static long DO_NOT_CHECK_FOR_COLLISIONS = B[10];
+ /**
+ * Only adds the Recipe if there is another Recipe having that Output
+ */
+ public static long ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT = B[11];
+ /**
+ * Only adds the Recipe if it has an Output
+ */
+ public static long ONLY_ADD_IF_RESULT_IS_NOT_NULL = B[12];
+ }
+
+ /**
+ * Copy of the original Helper Class of Thermal Expansion, just to make sure it works even when other Mods include TE-APIs
+ */
+ public static class ThermalExpansion {
+ public static void addFurnaceRecipe(int energy, ItemStack input, ItemStack output) {
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("output", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ output.writeToNBT(toSend.getCompoundTag("output"));
+ FMLInterModComms.sendMessage("ThermalExpansion", "FurnaceRecipe", toSend);
+ }
+
+ public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput) {
+ addPulverizerRecipe(energy, input, primaryOutput, null, 0);
+ }
+
+ public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {
+ addPulverizerRecipe(energy, input, primaryOutput, secondaryOutput, 100);
+ }
+
+ public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
+ if (input == null || primaryOutput == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("primaryOutput", new NBTTagCompound());
+ toSend.setTag("secondaryOutput", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
+ if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
+ toSend.setInteger("secondaryChance", secondaryChance);
+ FMLInterModComms.sendMessage("ThermalExpansion", "PulverizerRecipe", toSend);
+ }
+
+ public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput) {
+ addSawmillRecipe(energy, input, primaryOutput, null, 0);
+ }
+
+ public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {
+ addSawmillRecipe(energy, input, primaryOutput, secondaryOutput, 100);
+ }
+
+ public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
+ if (input == null || primaryOutput == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("primaryOutput", new NBTTagCompound());
+ toSend.setTag("secondaryOutput", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
+ if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
+ toSend.setInteger("secondaryChance", secondaryChance);
+ FMLInterModComms.sendMessage("ThermalExpansion", "SawmillRecipe", toSend);
+ }
+
+ public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput) {
+ addSmelterRecipe(energy, primaryInput, secondaryInput, primaryOutput, null, 0);
+ }
+
+ public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput) {
+ addSmelterRecipe(energy, primaryInput, secondaryInput, primaryOutput, secondaryOutput, 100);
+ }
+
+ public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
+ if (primaryInput == null || secondaryInput == null || primaryOutput == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("primaryInput", new NBTTagCompound());
+ toSend.setTag("secondaryInput", new NBTTagCompound());
+ toSend.setTag("primaryOutput", new NBTTagCompound());
+ toSend.setTag("secondaryOutput", new NBTTagCompound());
+ primaryInput.writeToNBT(toSend.getCompoundTag("primaryInput"));
+ secondaryInput.writeToNBT(toSend.getCompoundTag("secondaryInput"));
+ primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
+ if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
+ toSend.setInteger("secondaryChance", secondaryChance);
+ FMLInterModComms.sendMessage("ThermalExpansion", "SmelterRecipe", toSend);
+ }
+
+ public static void addSmelterBlastOre(Materials aMaterial) {
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setString("oreType", aMaterial.toString());
+ FMLInterModComms.sendMessage("ThermalExpansion", "SmelterBlastOreType", toSend);
+ }
+
+ public static void addCrucibleRecipe(int energy, ItemStack input, FluidStack output) {
+ if (input == null || output == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("output", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ output.writeToNBT(toSend.getCompoundTag("output"));
+ FMLInterModComms.sendMessage("ThermalExpansion", "CrucibleRecipe", toSend);
+ }
+
+ public static void addTransposerFill(int energy, ItemStack input, ItemStack output, FluidStack fluid, boolean reversible) {
+ if (input == null || output == null || fluid == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("output", new NBTTagCompound());
+ toSend.setTag("fluid", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ output.writeToNBT(toSend.getCompoundTag("output"));
+ toSend.setBoolean("reversible", reversible);
+ fluid.writeToNBT(toSend.getCompoundTag("fluid"));
+ FMLInterModComms.sendMessage("ThermalExpansion", "TransposerFillRecipe", toSend);
+ }
+
+ public static void addTransposerExtract(int energy, ItemStack input, ItemStack output, FluidStack fluid, int chance, boolean reversible) {
+ if (input == null || output == null || fluid == null) return;
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setInteger("energy", energy);
+ toSend.setTag("input", new NBTTagCompound());
+ toSend.setTag("output", new NBTTagCompound());
+ toSend.setTag("fluid", new NBTTagCompound());
+ input.writeToNBT(toSend.getCompoundTag("input"));
+ output.writeToNBT(toSend.getCompoundTag("output"));
+ toSend.setBoolean("reversible", reversible);
+ toSend.setInteger("chance", chance);
+ fluid.writeToNBT(toSend.getCompoundTag("fluid"));
+ FMLInterModComms.sendMessage("ThermalExpansion", "TransposerExtractRecipe", toSend);
+ }
+
+ public static void addMagmaticFuel(String fluidName, int energy) {
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setString("fluidName", fluidName);
+ toSend.setInteger("energy", energy);
+ FMLInterModComms.sendMessage("ThermalExpansion", "MagmaticFuel", toSend);
+ }
+
+ public static void addCompressionFuel(String fluidName, int energy) {
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setString("fluidName", fluidName);
+ toSend.setInteger("energy", energy);
+ FMLInterModComms.sendMessage("ThermalExpansion", "CompressionFuel", toSend);
+ }
+
+ public static void addCoolant(String fluidName, int energy) {
+ NBTTagCompound toSend = new NBTTagCompound();
+ toSend.setString("fluidName", fluidName);
+ toSend.setInteger("energy", energy);
+ FMLInterModComms.sendMessage("ThermalExpansion", "Coolant", toSend);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
new file mode 100644
index 0000000000..b404299fad
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
@@ -0,0 +1,354 @@
+package gregtech.api.util;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.SubTag;
+import gregtech.api.objects.GT_HashSet;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.ItemData;
+import gregtech.api.objects.MaterialStack;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import static gregtech.api.enums.GT_Values.*;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This is the Core of my OreDict Unification Code
+ * <p/>
+ * If you just want to use this to unificate your Items, then use the Function in the GregTech_API File
+ * <p/>
+ * P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome.
+ */
+public class GT_OreDictUnificator {
+ private static final HashMap<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>();
+ private static final HashMap<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>();
+ private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>();
+ public static volatile int VERSION = 509;
+ private static int isRegisteringOre = 0, isAddingOre = 0;
+ private static boolean mRunThroughTheList = true;
+
+ static {
+ GregTech_API.sItemStackMappings.add(sItemStack2DataMap);
+ }
+
+ /**
+ * The Blacklist just prevents the Item from being unificated into something else.
+ * Useful if you have things like the Industrial Diamond, which is better than regular Diamond, but also usable in absolutely all Diamond Recipes.
+ */
+ public static void addToBlacklist(ItemStack aStack) {
+ if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList))
+ sNoUnificationList.add(aStack);
+ }
+
+ public static boolean isBlacklisted(ItemStack aStack) {
+ return GT_Utility.isStackInList(aStack, sNoUnificationList);
+ }
+
+ public static void add(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) {
+ set(aPrefix, aMaterial, aStack, false, false);
+ }
+
+ public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) {
+ set(aPrefix, aMaterial, aStack, true, false);
+ }
+
+ public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, boolean aAlreadyRegistered) {
+ if (aMaterial == null || aPrefix == null || GT_Utility.isStackInvalid(aStack) || Items.feather.getDamage(aStack) == W)
+ return;
+ isAddingOre++;
+ aStack = GT_Utility.copyAmount(1, aStack);
+ if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack);
+ addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack));
+ if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString())))
+ sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack);
+ isAddingOre--;
+ }
+
+ public static ItemStack getFirstOre(Object aName, long aAmount) {
+ if (GT_Utility.isStringInvalid(aName)) return null;
+ ItemStack tStack = sName2StackMap.get(aName.toString());
+ if (GT_Utility.isStackValid(tStack)) return GT_Utility.copyAmount(aAmount, tStack);
+ return GT_Utility.copyAmount(aAmount, getOres(aName).toArray());
+ }
+
+ public static ItemStack get(Object aName, long aAmount) {
+ return get(aName, null, aAmount, true, true);
+ }
+
+ public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount) {
+ return get(aName, aReplacement, aAmount, true, true);
+ }
+
+ public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, long aAmount) {
+ return get(aPrefix, aMaterial, null, aAmount);
+ }
+
+ public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) {
+ return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true);
+ }
+
+ public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, boolean aNoInvalidAmounts) {
+ if (aNoInvalidAmounts && aAmount < 1) return null;
+ if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos)
+ GT_Log.err.println("Unknown Key for Unification, Typo? " + aName);
+ return GT_Utility.copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement);
+ }
+
+ public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) {
+ for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i]));
+ return aStacks;
+ }
+
+ public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) {
+ ItemStack[] rStacks = new ItemStack[aStacks.length];
+ for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i]));
+ return rStacks;
+ }
+
+ public static ItemStack setStack(ItemStack aStack) {
+ return setStack(true, aStack);
+ }
+
+ public static ItemStack setStack(boolean aUseBlackList, ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return aStack;
+ ItemStack tStack = get(aUseBlackList, aStack);
+ if (GT_Utility.areStacksEqual(aStack, tStack)) return aStack;
+ aStack.func_150996_a(tStack.getItem());
+ Items.feather.setDamage(aStack, Items.feather.getDamage(tStack));
+ return aStack;
+ }
+
+ public static ItemStack get(ItemStack aStack) {
+ return get(true, aStack);
+ }
+
+ public static ItemStack get(boolean aUseBlackList, ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return null;
+ ItemData tPrefixMaterial = getAssociation(aStack);
+ ItemStack rStack = null;
+ if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed))
+ return GT_Utility.copy(aStack);
+ if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) {
+ tPrefixMaterial.mBlackListed = true;
+ return GT_Utility.copy(aStack);
+ }
+ if (tPrefixMaterial.mUnificationTarget == null)
+ tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString());
+ rStack = tPrefixMaterial.mUnificationTarget;
+ if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack);
+ assert rStack != null;
+ rStack.setTagCompound(aStack.getTagCompound());
+ return GT_Utility.copyAmount(aStack.stackSize, rStack);
+ }
+
+ public static void addItemData(ItemStack aStack, ItemData aData) {
+ if (GT_Utility.isStackValid(aStack) && getItemData(aStack) == null && aData != null) setItemData(aStack, aData);
+ }
+
+ public static void setItemData(ItemStack aStack, ItemData aData) {
+ if (GT_Utility.isStackInvalid(aStack) || aData == null) return;
+ ItemData tData = getItemData(aStack);
+ if (tData == null || !tData.hasValidPrefixMaterialData()) {
+ if (tData != null) for (Object tObject : tData.mExtraData)
+ if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject);
+ if (aStack.stackSize > 1) {
+ if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize;
+ for (MaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize;
+ aStack = GT_Utility.copyAmount(1, aStack);
+ }
+ sItemStack2DataMap.put(new GT_ItemStack(aStack), aData);
+ if (aData.hasValidMaterialData()) {
+ long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M;
+ for (MaterialStack tMaterial : aData.mByProducts)
+ tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M;
+ if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack);
+ }
+ if (mRunThroughTheList) {
+ if (GregTech_API.sLoadStarted) {
+ mRunThroughTheList = false;
+ for (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet())
+ if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling)
+ GT_RecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue());
+ }
+ } else {
+ if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling)
+ GT_RecipeRegistrator.registerMaterialRecycling(aStack, aData);
+ }
+ } else {
+ for (Object tObject : aData.mExtraData)
+ if (!tData.mExtraData.contains(tObject)) tData.mExtraData.add(tObject);
+ }
+ }
+
+ public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) {
+ if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return;
+ if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++)
+ setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed));
+ setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed));
+ }
+
+ public static ItemData getItemData(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return null;
+ ItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack));
+ if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack)));
+ return rData;
+ }
+
+ public static ItemData getAssociation(ItemStack aStack) {
+ ItemData rData = getItemData(aStack);
+ return rData != null && rData.hasValidPrefixMaterialData() ? rData : null;
+ }
+
+ public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) {
+ if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false;
+ for (ItemStack tOreStack : getOres(aName.toString()))
+ if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true;
+ return false;
+ }
+
+ public static boolean isItemStackDye(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return false;
+ for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true;
+ return false;
+ }
+
+ public static boolean registerOre(OrePrefixes aPrefix, Object aMaterial, ItemStack aStack) {
+ return registerOre(aPrefix.get(aMaterial), aStack);
+ }
+
+ public static boolean registerOre(Object aName, ItemStack aStack) {
+ if (aName == null || GT_Utility.isStackInvalid(aStack)) return false;
+ String tName = aName.toString();
+ if (GT_Utility.isStringInvalid(tName)) return false;
+ ArrayList<ItemStack> tList = getOres(tName);
+ for (int i = 0; i < tList.size(); i++) if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) return false;
+ isRegisteringOre++;
+ OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack));
+ isRegisteringOre--;
+ return true;
+ }
+
+ public static boolean isRegisteringOres() {
+ return isRegisteringOre > 0;
+ }
+
+ public static boolean isAddingOres() {
+ return isAddingOre > 0;
+ }
+
+ public static void resetUnificationEntries() {
+ for (ItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null;
+ }
+
+ public static ItemStack getGem(MaterialStack aMaterial) {
+ return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getGem(Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) {
+ ItemStack rStack = null;
+ if (((aMaterialAmount >= M) || aMaterialAmount >= M * 32))
+ rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M);
+ if (rStack == null && (((aMaterialAmount * 4) >= M)))
+ rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M);
+ return rStack;
+ }
+
+ public static ItemStack getDust(MaterialStack aMaterial) {
+ return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getDust(Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getDust(Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = null;
+ if (((aMaterialAmount % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 4) % M == 0) || aMaterialAmount >= M * 8))
+ rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M);
+ if (rStack == null && (((aMaterialAmount * 9) >= M)))
+ rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M);
+ return rStack;
+ }
+
+ public static ItemStack getIngot(MaterialStack aMaterial) {
+ return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getIngot(Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getIngot(Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = null;
+ if (((aMaterialAmount % (M * 9) == 0 && aMaterialAmount / (M * 9) > 1) || aMaterialAmount >= M * 72))
+ rStack = get(OrePrefixes.block, aMaterial, aMaterialAmount / (M * 9));
+ if (rStack == null && ((aMaterialAmount % M == 0) || aMaterialAmount >= M * 8))
+ rStack = get(OrePrefixes.ingot, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 9) >= M)))
+ rStack = get(OrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M);
+ return rStack;
+ }
+
+ public static ItemStack getIngotOrDust(Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = getIngot(aMaterial, aMaterialAmount);
+ if (rStack == null) rStack = getDust(aMaterial, aMaterialAmount);
+ return rStack;
+ }
+
+ public static ItemStack getIngotOrDust(MaterialStack aMaterial) {
+ ItemStack rStack = getIngot(aMaterial);
+ if(aMaterial!=null&&aMaterial.mMaterial!=null&&(aMaterial.mMaterial==Materials.Naquadah||aMaterial.mMaterial==Materials.NaquadahEnriched))rStack = getDust(aMaterial);
+ if (rStack == null) rStack = getDust(aMaterial);
+ return rStack;
+ }
+
+ public static ItemStack getDustOrIngot(Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = getDust(aMaterial, aMaterialAmount);
+ if (rStack == null) rStack = getIngot(aMaterial, aMaterialAmount);
+ return rStack;
+ }
+
+ public static ItemStack getDustOrIngot(MaterialStack aMaterial) {
+ ItemStack rStack = getDust(aMaterial);
+ if (rStack == null) rStack = getIngot(aMaterial);
+ return rStack;
+ }
+
+ /**
+ * @return a Copy of the OreDictionary.getOres() List
+ */
+ public static ArrayList<ItemStack> getOres(OrePrefixes aPrefix, Object aMaterial) {
+ return getOres(aPrefix.get(aMaterial));
+ }
+
+ /**
+ * @return a Copy of the OreDictionary.getOres() List
+ */
+ public static ArrayList<ItemStack> getOres(Object aOreName) {
+ String aName = aOreName == null ? E : aOreName.toString();
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName));
+ return rList;
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_PlayedSound.java b/src/main/java/gregtech/api/util/GT_PlayedSound.java
new file mode 100644
index 0000000000..858f3b826e
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_PlayedSound.java
@@ -0,0 +1,28 @@
+package gregtech.api.util;
+
+import static gregtech.api.enums.GT_Values.E;
+
+public class GT_PlayedSound {
+ public final String mSoundName;
+ public final int mX, mY, mZ;
+
+ public GT_PlayedSound(String aSoundName, double aX, double aY, double aZ) {
+ mSoundName = aSoundName == null ? E : aSoundName;
+ mX = (int) aX;
+ mY = (int) aY;
+ mZ = (int) aZ;
+ }
+
+ @Override
+ public boolean equals(Object aObject) {
+ if (aObject != null && aObject instanceof GT_PlayedSound) {
+ return ((GT_PlayedSound) aObject).mX == mX && ((GT_PlayedSound) aObject).mY == mY && ((GT_PlayedSound) aObject).mZ == mZ && ((GT_PlayedSound) aObject).mSoundName.equals(mSoundName);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return mX + mY + mZ + mSoundName.hashCode();
+ }
+} \ 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
new file mode 100644
index 0000000000..71b0019980
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -0,0 +1,1275 @@
+package gregtech.api.util;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.SubTag;
+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 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.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 {
+ 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;
+ 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 (int i = 0; i < aInputs.length; i++)
+ if (aInputs[i] != null && Items.feather.getDamage(aInputs[i]) != W)
+ for (int j = 0; j < aOutputs.length; j++) {
+ if (GT_Utility.areStacksEqual(aInputs[i], aOutputs[j])) {
+ if (aInputs[i].stackSize >= aOutputs[j].stackSize) {
+ aInputs[i].stackSize -= aOutputs[j].stackSize;
+ aOutputs[j] = null;
+ } else {
+ aOutputs[j].stackSize -= aInputs[i].stackSize;
+ }
+ }
+ }
+
+ if (aOptimize && aDuration >= 32) {
+ ArrayList<ItemStack> tList = new ArrayList<ItemStack>();
+ 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 (int j = 0, k = tList.size(); temp && j < k; j++)
+ if (tList.get(j).stackSize % i != 0) temp = false;
+ for (int j = 0; temp && j < aFluidInputs.length; j++)
+ if (aFluidInputs[j].amount % i != 0) temp = false;
+ for (int j = 0; temp && j < aFluidOutputs.length; j++)
+ if (aFluidOutputs[j].amount % i != 0) temp = false;
+ if (temp) {
+ for (int j = 0, k = tList.size(); j < k; j++) tList.get(j).stackSize /= i;
+ for (int j = 0; j < aFluidInputs.length; j++) aFluidInputs[j].amount /= i;
+ for (int j = 0; j < aFluidOutputs.length; j++) aFluidOutputs[j].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);
+ 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);
+ 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 ? aInput2 < 64 ? aInput2 : 64 : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? aInput2 < 64 ? 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 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 boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
+ if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
+ for (FluidStack tFluid : mFluidInputs)
+ if (tFluid != null) {
+ boolean temp = true;
+ for (FluidStack aFluid : aFluidInputs)
+ if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
+ temp = false;
+ break;
+ }
+ if (temp) return false;
+ }
+
+ if (mInputs.length > 0 && aInputs == null) return false;
+
+ for (ItemStack tStack : mInputs)
+ if (tStack != null) {
+ boolean temp = true;
+ for (ItemStack aStack : aInputs)
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
+ temp = false;
+ break;
+ }
+ if (temp) return false;
+ }
+
+ if (aDecreaseStacksizeBySuccess) {
+ if (aFluidInputs != null) {
+ for (FluidStack tFluid : mFluidInputs)
+ if (tFluid != null) {
+ for (FluidStack aFluid : aFluidInputs)
+ if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
+ aFluid.amount -= tFluid.amount;
+ break;
+ }
+ }
+ }
+
+ if (aInputs != null) {
+ for (ItemStack tStack : mInputs)
+ if (tStack != null) {
+ for (ItemStack aStack : aInputs)
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
+ aStack.stackSize -= tStack.stackSize;
+ break;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public static class GT_Recipe_Map {
+ /**
+ * Contains all Recipe Maps
+ */
+ public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<GT_Recipe_Map>();
+
+ public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map_OreWasher(new HashSet<GT_Recipe>(0), "ic.recipe.orewasher", "Ore Washer", "ic2.blockOreWashingPlant", RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map_ThermalCentrifuge(new HashSet<GT_Recipe>(0), "ic.recipe.thermalcentrifuge", "Thermal Centrifuge", "ic2.blockCentrifuge", RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, false);
+ public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map_Compressor(new HashSet<GT_Recipe>(0), "ic.recipe.compressor", "Compressor", "ic2.compressor", RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map_Extractor(new HashSet<GT_Recipe>(0), "ic.recipe.extractor", "Extractor", "ic2.extractor", RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, false);
+ public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(3), "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<GT_Recipe>(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 sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(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<GT_Recipe>(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 sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "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<GT_Recipe>(10000), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer", 4, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "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<GT_Recipe>(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<GT_Recipe>(100), "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<GT_Recipe>(10000), "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<GT_Recipe>(200), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 0, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(100), "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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true);
+ public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "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<GT_Recipe>(200), "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<GT_Recipe>(500), "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 sImplosionRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "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<GT_Recipe>(100), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/Default", 2, 4, 0, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "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<GT_Recipe>(50), "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<GT_Recipe>(400), "gt.recipe.metalbender", "Metal Bender", 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<GT_Recipe>(3000), "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<GT_Recipe>(300), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 2, 1, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(300), "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<GT_Recipe>(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<GT_Recipe>(400), "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<GT_Recipe>(200), "gt.recipe.cuttingsaw", "Cutting Saw", null, RES_PATH_GUI + "basicmachines/Cutter", 1, 2, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.slicer", "Slicer", 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<GT_Recipe>(1000), "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<GT_Recipe>(200), "gt.recipe.hammer", "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<GT_Recipe>(10), "gt.recipe.uuamplifier", "UU Amplifier", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "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<GT_Recipe>(10), "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<GT_Recipe>(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<GT_Recipe>(10), "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<GT_Recipe>(10), "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<GT_Recipe>(10), "gt.recipe.magicfuels", "Magic 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 sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.smallnaquadahreactor", "Small 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_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.largenaquadahreactor", "Large 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_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "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 sAssemblylineRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.assemblyline", "Assemblyline", null, RES_PATH_GUI + "basicmachines/Default", 15, 1, 4, 0, 1, E, 1, E, false, false);
+
+ /**
+ * HashMap of Recipes based on their Items
+ */
+ public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new HashMap<GT_ItemStack, Collection<GT_Recipe>>();
+ /**
+ * HashMap of Recipes based on their Fluids
+ */
+ public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new HashMap<Fluid, Collection<GT_Recipe>>();
+ /**
+ * 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));
+ }
+
+ /**
+ * 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 add(GT_Recipe aRecipe) {
+ mRecipeList.add(aRecipe);
+ for (FluidStack aFluid : aRecipe.mFluidInputs)
+ if (aFluid != null) {
+ Collection<GT_Recipe> tList = mRecipeFluidMap.get(aFluid.getFluid());
+ if (tList == null) mRecipeFluidMap.put(aFluid.getFluid(), tList = new HashSet<GT_Recipe>(1));
+ tList.add(aRecipe);
+ }
+ return addToItemMap(aRecipe);
+ }
+
+ public void reInit() {
+ Map<GT_ItemStack, Collection<GT_Recipe>> tMap = mRecipeItemMap;
+ if (tMap != null) tMap.clear();
+ for (GT_Recipe tRecipe : mRecipeList) {
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs);
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs);
+ if (tMap != null) 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 && mRecipeFluidMap.containsKey(aFluid);
+ }
+
+ 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, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, 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 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, 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, true, 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, true, 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, true, 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, true, 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.get(tStack);
+ if (tList == null) mRecipeItemMap.put(tStack, tList = new HashSet<GT_Recipe>(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, 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)
+ ((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)
+ ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
+ return null;
+ }
+ if (tData.mMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ if (aTileEntity instanceof IGregTechTileEntity)
+ ((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)
+ ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4);
+ return null;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ if (aTileEntity instanceof IGregTechTileEntity)
+ ((IGregTechTileEntity) aTileEntity).setOnFire();
+ return null;
+ }
+ }
+ }
+ if (TileEntityFurnace.getItemBurnTime(tStack) > 0) {
+ if (aTileEntity instanceof IGregTechTileEntity) ((IGregTechTileEntity) aTileEntity).setOnFire();
+ 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[tRecipeOutputs.size()]), 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, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
+ 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);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
new file mode 100644
index 0000000000..611c8d34e2
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
@@ -0,0 +1,347 @@
+package gregtech.api.util;
+
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.*;
+import gregtech.api.enums.TC_Aspects.TC_AspectStack;
+import gregtech.api.interfaces.internal.IThaumcraftCompat;
+import gregtech.api.objects.ItemData;
+import gregtech.api.objects.MaterialStack;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static gregtech.api.enums.GT_Values.*;
+
+/**
+ * Class for Automatic Recipe registering.
+ */
+public class GT_RecipeRegistrator {
+ /**
+ * List of Materials, which are used in the Creation of Sticks. All Rod Materials are automatically added to this List.
+ */
+ public static final List<Materials> sRodMaterialList = new ArrayList<Materials>();
+ private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0);
+ private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R";
+ private static final ItemStack[][]
+ sShapes1 = new ItemStack[][]{
+ {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null},
+ {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1},
+ {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null},
+ {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1},
+ {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1},
+ {null, sMt1, null, null, sMt1, null, null, sMt2, null},
+ {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, null, null, sMt2, null, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null},
+ {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2},
+ {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null},
+ {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2},
+ {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null},
+ {null, sMt2, null, null, sMt1, null, null, sMt1, null},
+ {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1},
+ {null, sMt2, null, null, sMt2, null, null, sMt1, null},
+ {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null},
+ {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null},
+ {sMt1, null, null, null, sMt2, null, null, null, sMt2},
+ {null, null, sMt1, null, sMt2, null, sMt2, null, null},
+ {sMt1, null, null, null, sMt2, null, null, null, null},
+ {null, null, sMt1, null, sMt2, null, null, null, null},
+ {sMt1, sMt2, null, null, null, null, null, null, null},
+ {sMt2, sMt1, null, null, null, null, null, null, null},
+ {sMt1, null, null, sMt2, null, null, null, null, null},
+ {sMt2, null, null, sMt1, null, null, null, null, null},
+ {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null},
+ {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null},
+ {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, null, null, null, sMt1, null, null, null, null},
+ {null, sMt1, null, sMt1, null, null, null, null, null},
+ {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null},
+ {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2}
+ };
+ private static final String[][] sShapesA = new String[][]{
+ null,
+ null,
+ null,
+ {"Helmet", s_P + s_P + s_P, s_P + s_H + s_P},
+ {"ChestPlate", s_P + s_H + s_P, s_P + s_P + s_P, s_P + s_P + s_P},
+ {"Pants", s_P + s_P + s_P, s_P + s_H + s_P, s_P + " " + s_P},
+ {"Boots", s_P + " " + s_P, s_P + s_H + s_P},
+ {"Sword", " " + s_P + " ", s_F + s_P + s_H, " " + s_R + " "},
+ {"Pickaxe", s_P + s_I + s_I, s_F + s_R + s_H, " " + s_R + " "},
+ {"Shovel", s_F + s_P + s_H, " " + s_R + " ", " " + s_R + " "},
+ {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "},
+ {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "},
+ {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "},
+ {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sword", " " + s_R + " ", s_F + s_P + s_H, " " + s_P + " "},
+ {"Pickaxe", " " + s_R + " ", s_F + s_R + s_H, s_P + s_I + s_I},
+ {"Shovel", " " + s_R + " ", " " + s_R + " ", s_F + s_P + s_H},
+ {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H},
+ {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H},
+ {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H},
+ {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H},
+ {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R},
+ {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R},
+ {"Knive", s_H + s_P, s_R + s_F},
+ {"Knive", s_F + s_H, s_P + s_R},
+ {"Knive", s_F + s_H, s_P + s_R},
+ {"Knive", s_P + s_F, s_R + s_H},
+ {"Knive", s_P + s_F, s_R + s_H},
+ null,
+ null,
+ null,
+ null,
+ {"WarAxe", s_P + s_P + s_P, s_P + s_R + s_P, s_F + s_R + s_H},
+ null,
+ null,
+ null,
+ {"Shears", s_H + s_P, s_P + s_F},
+ {"Shears", s_H + s_P, s_P + s_F},
+ {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "},
+ {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R}
+ };
+ public static volatile int VERSION = 509;
+
+ public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) {
+ if (GT_Utility.isStackInvalid(aStack)) return;
+ if (aByproduct != null) {
+ aByproduct = aByproduct.clone();
+ aByproduct.mAmount /= aStack.stackSize;
+ }
+ GT_OreDictUnificator.addItemData(GT_Utility.copyAmount(1, aStack), new ItemData(aMaterial, aMaterialAmount / aStack.stackSize, aByproduct));
+ }
+
+ public static void registerMaterialRecycling(ItemStack aStack, ItemData aData) {
+ if (GT_Utility.isStackInvalid(aStack) || GT_Utility.areStacksEqual(new ItemStack(Items.blaze_rod), aStack) || aData == null || !aData.hasValidMaterialData() || aData.mMaterial.mAmount <= 0 || GT_Utility.getFluidForFilledItem(aStack, false) != null)
+ return;
+ registerReverseMacerating(GT_Utility.copyAmount(1, aStack), aData, aData.mPrefix == null);
+ registerReverseSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, true);
+ registerReverseFluidSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, aData.getByProduct(0));
+ registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData);
+ }
+
+ /**
+ * @param aStack the stack to be recycled.
+ * @param aMaterial the Material.
+ * @param aMaterialAmount the amount of it in Material Units.
+ */
+ public static void registerReverseFluidSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) {
+ if (aStack == null || aMaterial == null || aMaterial.mSmeltInto.mStandardMoltenFluid == null || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) || (L * aMaterialAmount) / (M * aStack.stackSize) <= 0)
+ return;
+ ItemData tData = GT_OreDictUnificator.getItemData(aStack);
+ boolean tHide = (aMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes);
+ if(tHide && tData!=null&&tData.hasValidPrefixData()&&tData.mPrefix==OrePrefixes.ingot){
+ tHide=false;
+ }
+ RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GT_OreDictUnificator.getDust(Materials.Ash, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GT_OreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GT_OreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature())), tHide);
+ }
+
+ /**
+ * @param aStack the stack to be recycled.
+ * @param aMaterial the Material.
+ * @param aMaterialAmount the amount of it in Material Units.
+ * @param aAllowAlloySmelter if it is allowed to be recycled inside the Alloy Smelter.
+ */
+ public static void registerReverseSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, boolean aAllowAlloySmelter) {
+ if (aStack == null || aMaterial == null || aMaterialAmount <= 0 || aMaterial.contains(SubTag.NO_SMELTING) || (aMaterialAmount > M && aMaterial.contains(SubTag.METAL)))
+ return;
+ aMaterialAmount /= aStack.stackSize;
+ if(aMaterial==Materials.Naquadah||aMaterial==Materials.NaquadahEnriched)return;
+
+ boolean tHide = (aMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes);
+ if (aAllowAlloySmelter)
+ GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount),tHide);
+ else
+ GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
+ }
+
+ public static void registerReverseArcSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03) {
+ registerReverseArcSmelting(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03));
+ }
+
+ public static void registerReverseArcSmelting(ItemStack aStack, ItemData aData) {
+ if (aStack == null || aData == null) return;
+ aData = new ItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+ boolean tIron = false;
+
+
+ for (MaterialStack tMaterial : aData.getAllMaterialStacks()) {
+ if (tMaterial.mMaterial == Materials.Iron||tMaterial.mMaterial == Materials.Copper ||
+ tMaterial.mMaterial == Materials.WroughtIron||tMaterial.mMaterial == Materials.AnnealedCopper) tIron = true;
+
+ if (tMaterial.mMaterial.contains(SubTag.UNBURNABLE)) {
+ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
+ tMaterial.mMaterial = Materials.Ash;
+ tMaterial.mAmount /= 4;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ tMaterial.mMaterial = Materials.Ash;
+ tMaterial.mAmount /= 2;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.NO_SMELTING)) {
+ tMaterial.mAmount = 0;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.METAL)) {
+ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto;
+ continue;
+ }
+ tMaterial.mAmount = 0;
+ }
+
+ aData = new ItemData(aData);
+ if (aData.mByProducts.length > 3) for (MaterialStack tMaterial : aData.getAllMaterialStacks()){
+ if (tMaterial.mMaterial == Materials.Ash) tMaterial.mAmount = 0;
+ }
+
+ aData = new ItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ long tAmount = 0;
+ for (MaterialStack tMaterial : aData.getAllMaterialStacks())
+ tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass();
+
+ boolean tHide = !tIron && GT_Mod.gregtechproxy.mHideRecyclingRecipes;
+ RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getIngotOrDust(aData.mMaterial), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 96, tHide);
+ }
+
+ public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) {
+ registerReverseMacerating(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer);
+ }
+
+ public static void registerReverseMacerating(ItemStack aStack, ItemData aData, boolean aAllowHammer) {
+ if (aStack == null || aData == null) return;
+ aData = new ItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ for (MaterialStack tMaterial : aData.getAllMaterialStacks())
+ tMaterial.mMaterial = tMaterial.mMaterial.mMacerateInto;
+
+ aData = new ItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ long tAmount = 0;
+ for (MaterialStack tMaterial : aData.getAllMaterialStacks())
+ tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass();
+ boolean tHide = (aData.mMaterial.mMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes);
+ RA.addPulveriserRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getDust(aData.mMaterial), GT_OreDictUnificator.getDust(aData.getByProduct(0)), GT_OreDictUnificator.getDust(aData.getByProduct(1)), GT_OreDictUnificator.getDust(aData.getByProduct(2))}, null, aData.mMaterial.mMaterial==Materials.Marble ? 1 : (int) Math.max(16, tAmount / M), 4, tHide);
+
+ if (aAllowHammer) for (MaterialStack tMaterial : aData.getAllMaterialStacks())
+ if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) && !tMaterial.mMaterial.contains(SubTag.METAL)) {
+ if (RA.addForgeHammerRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getDust(aData.mMaterial), 200, 32))
+ break;
+ }
+ ItemStack tDust = GT_OreDictUnificator.getDust(aData.mMaterial);
+ if (tDust != null && GT_ModHandler.addPulverisationRecipe(GT_Utility.copyAmount(1, aStack), tDust, GT_OreDictUnificator.getDust(aData.getByProduct(0)), 100, GT_OreDictUnificator.getDust(aData.getByProduct(1)), 100, true)) {
+ if (GregTech_API.sThaumcraftCompat != null)
+ GregTech_API.sThaumcraftCompat.addCrucibleRecipe(IThaumcraftCompat.ADVANCEDENTROPICPROCESSING, aStack, tDust, Arrays.asList(new TC_AspectStack(TC_Aspects.PERDITIO, Math.max(1, (aData.mMaterial.mAmount * 2) / M))));
+ }
+ }
+
+ /**
+ * You give this Function a Material and it will scan almost everything for adding recycling Recipes
+ *
+ * @param aMat a Material, for example an Ingot or a Gem.
+ * @param aOutput the Dust you usually get from macerating aMat
+ * @param aRecipeReplacing allows to replace the Recipe with a Plate variant
+ */
+ public static synchronized void registerUsagesForMaterials(ItemStack aMat, String aPlate, boolean aRecipeReplacing) {
+ if (aMat == null) return;
+ aMat = GT_Utility.copy(aMat);
+ ItemStack tStack;
+ ItemData aItemData = GT_OreDictUnificator.getItemData(aMat);
+ if (aItemData == null || aItemData.mPrefix != OrePrefixes.ingot) aPlate = null;
+ if (aPlate != null && GT_OreDictUnificator.getFirstOre(aPlate, 1) == null) aPlate = null;
+
+ sMt1.func_150996_a(aMat.getItem());
+ sMt1.stackSize = 1;
+ Items.feather.setDamage(sMt1, Items.feather.getDamage(aMat));
+
+ sMt2.func_150996_a(new ItemStack(Blocks.dirt).getItem());
+ sMt2.stackSize = 1;
+ Items.feather.setDamage(sMt2, 0);
+
+ for (ItemStack[] tRecipe : sShapes1) {
+ int tAmount1 = 0;
+ for (ItemStack tMat : tRecipe) {
+ if (tMat == sMt1) tAmount1++;
+ }
+ if (aItemData != null && aItemData.hasValidPrefixMaterialData())
+ for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) {
+ GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1));
+ }
+ }
+
+ for (Materials tMaterial : sRodMaterialList) {
+ ItemStack tMt2 = GT_OreDictUnificator.get(OrePrefixes.stick, tMaterial, 1);
+ if (tMt2 != null) {
+ sMt2.func_150996_a(tMt2.getItem());
+ sMt2.stackSize = 1;
+ Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2));
+
+ for (int i = 0; i < sShapes1.length; i++) {
+ ItemStack[] tRecipe = sShapes1[i];
+
+ int tAmount1 = 0, tAmount2 = 0;
+ for (ItemStack tMat : tRecipe) {
+ if (tMat == sMt1) tAmount1++;
+ if (tMat == sMt2) tAmount2++;
+ }
+ for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) {
+ if (aItemData != null && aItemData.hasValidPrefixMaterialData())
+ GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2)));
+
+ if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) {
+ assert aItemData != null;
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) {
+ if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) {
+ switch (sShapesA[i].length) {
+ case 2:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ case 3:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ default:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java
new file mode 100644
index 0000000000..e51c490519
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java
@@ -0,0 +1,99 @@
+package gregtech.api.util;
+
+import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
+import gregtech.api.items.GT_MetaGenerated_Tool;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+
+public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRecipe {
+ public final boolean mDismantleable, mRemovableByGT, mKeepingNBT;
+ private final Enchantment[] mEnchantmentsAdded;
+ private final int[] mEnchantmentLevelsAdded;
+
+ public GT_Shaped_Recipe(ItemStack aResult, boolean aDismantleAble, boolean aRemovableByGT, boolean aKeepingNBT, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object... aRecipe) {
+ super(aResult, aRecipe);
+ mEnchantmentsAdded = aEnchantmentsAdded;
+ mEnchantmentLevelsAdded = aEnchantmentLevelsAdded;
+ mRemovableByGT = aRemovableByGT;
+ mKeepingNBT = aKeepingNBT;
+ mDismantleable = aDismantleAble;
+ }
+
+ @Override
+ public boolean matches(InventoryCrafting aGrid, World aWorld) {
+ if (mKeepingNBT) {
+ ItemStack tStack = null;
+ for (int i = 0; i < aGrid.getSizeInventory(); i++) {
+ if (aGrid.getStackInSlot(i) != null) {
+ if (tStack != null) {
+ if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) || (tStack.hasTagCompound() && !tStack.getTagCompound().equals(aGrid.getStackInSlot(i).getTagCompound())))
+ return false;
+ }
+ tStack = aGrid.getStackInSlot(i);
+ }
+ }
+ }
+ return super.matches(aGrid, aWorld);
+ }
+
+ @Override
+ public ItemStack getCraftingResult(InventoryCrafting aGrid) {
+ ItemStack rStack = super.getCraftingResult(aGrid);
+ if (rStack != null) {
+ // Update the Stack
+ GT_Utility.updateItemStack(rStack);
+
+ // Keeping NBT
+ if (mKeepingNBT) for (int i = 0; i < aGrid.getSizeInventory(); i++) {
+ if (aGrid.getStackInSlot(i) != null && aGrid.getStackInSlot(i).hasTagCompound()) {
+ rStack.setTagCompound((NBTTagCompound) aGrid.getStackInSlot(i).getTagCompound().copy());
+ break;
+ }
+ }
+
+ // Charge Values
+ if (GT_ModHandler.isElectricItem(rStack)) {
+ GT_ModHandler.dischargeElectricItem(rStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+ int tCharge = 0;
+ for (int i = 0; i < aGrid.getSizeInventory(); i++)
+ tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true);
+ if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false);
+ }
+
+ // Saving Ingredients inside the Item.
+ if (mDismantleable) {
+ NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
+ if (rNBT == null) rNBT = new NBTTagCompound();
+ for (int i = 0; i < 9; i++) {
+ ItemStack tStack = aGrid.getStackInSlot(i);
+ if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
+ tStack = GT_Utility.copyAmount(1, tStack);
+ if(GT_Utility.isStackValid(tStack)){
+ GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+ tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));}
+ }
+ }
+ rNBT.setTag("GT.CraftingComponents", tNBT);
+ rStack.setTagCompound(rNBT);
+ }
+
+ // Add Enchantments
+ for (int i = 0; i < mEnchantmentsAdded.length; i++)
+ GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]);
+
+ // Update the Stack again
+ GT_Utility.updateItemStack(rStack);
+ }
+ return rStack;
+ }
+
+ @Override
+ public boolean isRemovable() {
+ return mRemovableByGT;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java
new file mode 100644
index 0000000000..937ba0a837
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java
@@ -0,0 +1,98 @@
+package gregtech.api.util;
+
+import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
+import gregtech.api.items.GT_MetaGenerated_Tool;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
+
+public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_CraftingRecipe {
+ public final boolean mDismantleable, mRemovableByGT, mKeepingNBT;
+ private final Enchantment[] mEnchantmentsAdded;
+ private final int[] mEnchantmentLevelsAdded;
+
+ public GT_Shapeless_Recipe(ItemStack aResult, boolean aDismantleAble, boolean aRemovableByGT, boolean aKeepingNBT, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object... aRecipe) {
+ super(aResult, aRecipe);
+ mEnchantmentsAdded = aEnchantmentsAdded;
+ mEnchantmentLevelsAdded = aEnchantmentLevelsAdded;
+ mRemovableByGT = aRemovableByGT;
+ mKeepingNBT = aKeepingNBT;
+ mDismantleable = aDismantleAble;
+ }
+
+ @Override
+ public boolean matches(InventoryCrafting aGrid, World aWorld) {
+ if (mKeepingNBT) {
+ ItemStack tStack = null;
+ for (int i = 0; i < aGrid.getSizeInventory(); i++) {
+ if (aGrid.getStackInSlot(i) != null) {
+ if (tStack != null) {
+ if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) || (tStack.hasTagCompound() && !tStack.getTagCompound().equals(aGrid.getStackInSlot(i).getTagCompound())))
+ return false;
+ }
+ tStack = aGrid.getStackInSlot(i);
+ }
+ }
+ }
+ return super.matches(aGrid, aWorld);
+ }
+
+ @Override
+ public ItemStack getCraftingResult(InventoryCrafting aGrid) {
+ ItemStack rStack = super.getCraftingResult(aGrid);
+ if (rStack != null) {
+ // Update the Stack
+ GT_Utility.updateItemStack(rStack);
+
+ // Keeping NBT
+ if (mKeepingNBT) for (int i = 0; i < aGrid.getSizeInventory(); i++) {
+ if (aGrid.getStackInSlot(i) != null && aGrid.getStackInSlot(i).hasTagCompound()) {
+ rStack.setTagCompound((NBTTagCompound) aGrid.getStackInSlot(i).getTagCompound().copy());
+ break;
+ }
+ }
+
+ // Charge Values
+ if (GT_ModHandler.isElectricItem(rStack)) {
+ GT_ModHandler.dischargeElectricItem(rStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+ int tCharge = 0;
+ for (int i = 0; i < aGrid.getSizeInventory(); i++)
+ tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true);
+ if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false);
+ }
+
+ // Saving Ingredients inside the Item.
+ if (mDismantleable) {
+ NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
+ if (rNBT == null) rNBT = new NBTTagCompound();
+ for (int i = 0; i < 9; i++) {
+ ItemStack tStack = aGrid.getStackInSlot(i);
+ if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
+ tStack = GT_Utility.copyAmount(1, tStack);
+ GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+ tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));
+ }
+ }
+ rNBT.setTag("GT.CraftingComponents", tNBT);
+ rStack.setTagCompound(rNBT);
+ }
+
+ // Add Enchantments
+ for (int i = 0; i < mEnchantmentsAdded.length; i++)
+ GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]);
+
+ // Update the Stack again
+ GT_Utility.updateItemStack(rStack);
+ }
+ return rStack;
+ }
+
+ @Override
+ public boolean isRemovable() {
+ return mRemovableByGT;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java
new file mode 100644
index 0000000000..9063b1f7c9
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java
@@ -0,0 +1,45 @@
+package gregtech.api.util;
+
+import cpw.mods.fml.common.eventhandler.Event;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gregtech.api.metatileentity.BaseMetaTileEntity;
+import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_MonsterRepellent;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GT_SpawnEventHandler {
+
+ public static volatile List<int[]> mobReps = new ArrayList();
+
+ public GT_SpawnEventHandler() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @SubscribeEvent
+ public void denyMobSpawn(CheckSpawn event) {
+ if (event.getResult() == Event.Result.ALLOW) {
+ return;
+ }
+ if (event.entityLiving.isCreatureType(EnumCreatureType.monster, false)) {
+ for (int[] rep : mobReps) {
+ if (rep[3] == event.entity.worldObj.provider.dimensionId) {
+ TileEntity tTile = event.entity.worldObj.getTileEntity(rep[0], rep[1], rep[2]);
+ if (tTile instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_MonsterRepellent) {
+ int r = ((GT_MetaTileEntity_MonsterRepellent) ((BaseMetaTileEntity) tTile).getMetaTileEntity()).mRange;
+ double dx = rep[0] + 0.5F - event.entity.posX;
+ double dy = rep[1] + 0.5F - event.entity.posY;
+ double dz = rep[2] + 0.5F - event.entity.posZ;
+ if ((dx * dx + dz * dz + dy * dy) <= Math.pow(r, 2)) {
+ event.setResult(Event.Result.DENY);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
new file mode 100644
index 0000000000..c6d1ab5285
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -0,0 +1,2052 @@
+package gregtech.api.util;
+
+import cofh.api.transport.IItemDuct;
+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.GT_Values;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.SubTag;
+import gregtech.api.events.BlockScanningEvent;
+import gregtech.api.interfaces.IDebugableBlock;
+import gregtech.api.interfaces.IProjectileItem;
+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.ICannerBottleRecipeManager;
+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.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityChest;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.ChunkPosition;
+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.ForgeDirection;
+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.api.enums.GT_Values.*;
+
+/**
+ * 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 HashMap<GT_ItemStack, FluidContainerData>();
+ private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new 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 HashMap<GT_PlayedSound, Integer>();
+ private static int sBookCount = 0;
+
+ static {
+ GregTech_API.sItemStackMappings.add(sFilledContainerToData);
+ GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
+ }
+
+ 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 != null && 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) if (aTileEntity instanceof IItemDuct) return true;
+ if (BC_CHECK) if (aTileEntity instanceof buildcraft.api.transport.IPipeTile)
+ return ((buildcraft.api.transport.IPipeTile) aTileEntity).isPipeConnected(ForgeDirection.getOrientation(aSide));
+ 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) {
+ 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)) {
+ 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 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 != null && 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++) {
+ 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)) {
+ byte tMovedItemCount = moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
+ 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);
+ }
+
+ /**
+ * 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 != null && 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 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 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) {
+ System.out.println("EmptyIC2Output!" + aInput.getUnlocalizedName());
+ return false;
+ }
+ }
+ if (tOreName != null) {
+ aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, GT_OreDictUnificator.getStackArray(true, aOutput)));
+ } else {
+ aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, GT_OreDictUnificator.getStackArray(true, aOutput)));
+ }
+ 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, 0.9F + new Random().nextFloat() * 0.2F, 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(Object aStack) {
+ if (isStackInvalid(aStack)) return Blocks.air;
+ return Block.getBlockFromItem(((ItemStack) aStack).getItem());
+ }
+
+ public static boolean isBlockValid(Object aBlock) {
+ return aBlock != null && (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 != null && (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);
+ }
+ }
+
+ /**
+ * Converts a Number to a String
+ */
+ public static String parseNumberToString(int aNumber) {
+ String tString = E;
+ boolean temp = true, negative = false;
+
+ if (aNumber < 0) {
+ aNumber *= -1;
+ negative = true;
+ }
+
+ for (int i = 1000000000; i > 0; i /= 10) {
+ int tDigit = (aNumber / i) % 10;
+ if (temp && tDigit != 0) temp = false;
+ if (!temp) {
+ tString += tDigit;
+ if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tString += ",";
+ }
+ }
+
+ 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 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 -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;
+ }
+
+ /**
+ * 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) {
+ 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*/}
+ return GregTech_API.sDimensionalList.contains(aDimensionID);
+ }
+
+ public static boolean moveEntityToDimensionAtCoords(Entity aEntity, int aDimension, double aX, double aY, double aZ) {
+ WorldServer tTargetWorld = DimensionManager.getWorld(aDimension), tOriginalWorld = DimensionManager.getWorld(aEntity.worldObj.provider.dimensionId);
+ if (tTargetWorld != null && tOriginalWorld != null && tTargetWorld != tOriginalWorld) {
+ if (aEntity.ridingEntity != null) aEntity.mountEntity(null);
+ if (aEntity.riddenByEntity != null) aEntity.riddenByEntity.mountEntity(null);
+
+ if (aEntity instanceof EntityPlayerMP) {
+ EntityPlayerMP aPlayer = (EntityPlayerMP) aEntity;
+ aPlayer.dimension = aDimension;
+ aPlayer.playerNetServerHandler.sendPacket(new S07PacketRespawn(aPlayer.dimension, aPlayer.worldObj.difficultySetting, aPlayer.worldObj.getWorldInfo().getTerrainType(), aPlayer.theItemInWorldManager.getGameType()));
+ tOriginalWorld.removePlayerEntityDangerously(aPlayer);
+ aPlayer.isDead = false;
+ aPlayer.setWorld(tTargetWorld);
+ MinecraftServer.getServer().getConfigurationManager().func_72375_a(aPlayer, tOriginalWorld);
+ aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch);
+ aPlayer.theItemInWorldManager.setWorld(tTargetWorld);
+ MinecraftServer.getServer().getConfigurationManager().updateTimeAndWeatherForPlayer(aPlayer, tTargetWorld);
+ MinecraftServer.getServer().getConfigurationManager().syncPlayerInventory(aPlayer);
+ Iterator tIterator = aPlayer.getActivePotionEffects().iterator();
+ while (tIterator.hasNext()) {
+ PotionEffect potioneffect = (PotionEffect) tIterator.next();
+ aPlayer.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(aPlayer.getEntityId(), potioneffect));
+ }
+ aPlayer.playerNetServerHandler.setPlayerLocation(aX + 0.5, aY + 0.5, aZ + 0.5, aPlayer.rotationYaw, aPlayer.rotationPitch);
+ FMLCommonHandler.instance().firePlayerChangedDimensionEvent(aPlayer, tOriginalWorld.provider.dimensionId, aDimension);
+ } else {
+ aEntity.setPosition(aX + 0.5, aY + 0.5, aZ + 0.5);
+ aEntity.worldObj.removeEntity(aEntity);
+ aEntity.dimension = aDimension;
+ aEntity.isDead = false;
+ Entity tNewEntity = EntityList.createEntityByName(EntityList.getEntityString(aEntity), tTargetWorld);
+ if (tNewEntity != null) {
+ tNewEntity.copyDataFrom(aEntity, true);
+ aEntity.setDead();
+ tNewEntity.isDead = false;
+ boolean temp = tNewEntity.forceSpawn;
+ tNewEntity.forceSpawn = true;
+ tTargetWorld.spawnEntityInWorld(tNewEntity);
+ tNewEntity.forceSpawn = temp;
+ tNewEntity.isDead = false;
+ aEntity = tNewEntity;
+ }
+ }
+
+ if (aEntity instanceof EntityLivingBase) {
+ ((EntityLivingBase) aEntity).setPositionAndUpdate(aX, aY, aZ);
+ } else {
+ aEntity.setPosition(aX, aY, aZ);
+ }
+
+ tOriginalWorld.resetUpdateEntityTick();
+ tTargetWorld.resetUpdateEntityTick();
+ return true;
+ }
+ return false;
+ }
+
+ public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
+
+
+ Random tRandom = new Random((aWorld.getSeed() + (aX / 96) + (7 * (aZ / 96))));
+ int oil = tRandom.nextInt(3);
+ double amount = tRandom.nextInt(50) + tRandom.nextDouble();
+ oil = tRandom.nextInt(4);
+// System.out.println("Oil: "+(aX/96)+" "+(aZ/96)+" "+oil+" "+amount);
+// amount = 40;
+ Fluid tFluid = null;
+ switch (oil) {
+ case 0:
+ tFluid = Materials.NatruralGas.mGas;
+ break;
+ case 1:
+ tFluid = Materials.OilLight.mFluid;
+ break;
+ case 2:
+ tFluid = Materials.OilMedium.mFluid;
+ break;
+ case 3:
+ tFluid = Materials.OilHeavy.mFluid;
+ break;
+ default:
+ tFluid = Materials.Oil.mFluid;
+ }
+ int tAmount = (int) (Math.pow(amount, 5) / 100);
+ ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16);
+ if(GT_Proxy.chunkData.containsKey(tPos)){
+ int[] tInts = GT_Proxy.chunkData.get(tPos);
+ if(tInts.length>0){
+ if(tInts[0]>=0){tAmount = tInts[0];}
+ }
+ GT_Proxy.chunkData.remove(tPos);
+ }
+ tAmount = tAmount - 5;
+ GT_Proxy.chunkData.put(tPos, new int[]{tAmount});
+
+ return new FluidStack(tFluid, tAmount);
+ }
+
+ 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: " + aX + " Y: " + aY + " Z: " + aZ + " -----");
+ try {
+ if (tTileEntity != null && tTileEntity instanceof IInventory)
+ tList.add("Name: " + ((IInventory) tTileEntity).getInventoryName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ));
+ else
+ tList.add("Name: " + tBlock.getUnlocalizedName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ));
+
+ tList.add("Hardness: " + tBlock.getBlockHardness(aWorld, aX, aY, aZ) + " Blast Resistance: " + tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ));
+ if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add("Is valid Beacon Pyramid Material");
+ } 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("Tank " + i + ": " + GT_Utility.formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + " / " + GT_Utility.formatNumbers(tTanks[i].capacity) + " " + getFluidName(tTanks[i].fluid, true));
+ }
+ }
+ } 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("Heat: " + ((ic2.api.reactor.IReactor) tTileEntity).getHeat() + "/" + ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()
+ + " HEM: " + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() + " 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("Facing: " + ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() + " / Chance: " + (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) + "%");
+ tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? "You can remove this with a Wrench" : "You can NOT remove this with a Wrench");
+ }
+ } 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("Conduction Loss: " + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss());
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) {
+ rEUAmount += 200;
+ tList.add("Contained Energy: " + ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() + " of " + ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity());
+ //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("Has Muffler Upgrade");
+ }
+ } 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("Progress: " + GT_Utility.formatNumbers(tValue) + " / " + GT_Utility.formatNumbers(((IMachineProgress) tTileEntity).getProgress()));
+ }
+ } 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("Max IN: " + ((IBasicEnergyContainer) tTileEntity).getInputVoltage() + " EU");
+ tList.add("Max OUT: " + ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() + " EU at " + ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() + " Amperes");
+ tList.add("Energy: " + GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + " / " + GT_Utility.formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + "EU");
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (tTileEntity instanceof IGregTechTileEntity) {
+ tList.add("Owned by: " + ((IGregTechTileEntity) tTileEntity).getOwnerName());
+ }
+ } 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("Type -- Crop-Name: " + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].name()
+ + " Growth: " + ((ic2.api.crops.ICropTile) tTileEntity).getGrowth()
+ + " Gain: " + ((ic2.api.crops.ICropTile) tTileEntity).getGain()
+ + " Resistance: " + ((ic2.api.crops.ICropTile) tTileEntity).getResistance()
+ );
+ tList.add("Plant -- Fertilizer: " + ((ic2.api.crops.ICropTile) tTileEntity).getNutrientStorage()
+ + " Water: " + ((ic2.api.crops.ICropTile) tTileEntity).getHydrationStorage()
+ + " Weed-Ex: " + ((ic2.api.crops.ICropTile) tTileEntity).getWeedExStorage()
+ + " Scan-Level: " + ((ic2.api.crops.ICropTile) tTileEntity).getScanLevel()
+ );
+ tList.add("Environment -- Nutrients: " + ((ic2.api.crops.ICropTile) tTileEntity).getNutrients()
+ + " Humidity: " + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity()
+ + " Air-Quality: " + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality()
+ );
+ String tString = E;
+ for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) {
+ tString += ", " + tAttribute;
+ }
+ tList.add("Attributes:" + tString.replaceFirst(",", E));
+ tList.add("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&&GT_Values.D1) {
+ FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ);
+ tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName());
+ }
+
+ 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;
+ }
+
+ /**
+ * @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);
+ }
+
+ 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 + "," + (aFluid.amount / 5000) + "," + aFluid.getLocalizedName() + ",";
+ for (String tString : aOres) {
+ tData += tString + ",";
+ }
+ tNBT.setString("prospection", tData);
+ setNBT(aStack, tNBT);
+ }
+
+ public static void convertProspectionData(ItemStack aStack) {
+ NBTTagCompound tNBT = getNBT(aStack);
+ String tData = tNBT.getString("prospection");
+ String[] tDataArray = tData.split(",");
+ if (tDataArray.length > 6) {
+ tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]);
+ NBTTagList tNBTList = new NBTTagList();
+ String tOres = " Prospected Ores: ";
+ for (int i = 6; tDataArray.length > i; i++) {
+ tOres += (tDataArray[i] + " ");
+ }
+ tNBTList.appendTag(new NBTTagString("Prospection 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);
+ }
+
+ 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) {
+ for (int i = 0; i < nbttaglist.tagCount(); ++i) {
+ try {
+ 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);
+ }
+ }
+ }
+
+} \ No newline at end of file