aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorMuramasa <haydenkilloh@gmail.com>2016-09-24 23:05:18 +0100
committerMuramasa <haydenkilloh@gmail.com>2016-09-24 23:05:18 +0100
commitfed8109b17fd2b41de17ceef92f37e39dc1ffc53 (patch)
tree9806dc7273bfc03fbb7a6eff1f6d0f98ce3a5bc3 /src/main/java/gregtech/api/util
parent291839871e1233ba0c72e48cf16847246a1ccc7c (diff)
parent380211de8a2aaeaa6b24bbde34625bba4e626d79 (diff)
downloadGT5-Unofficial-fed8109b17fd2b41de17ceef92f37e39dc1ffc53.tar.gz
GT5-Unofficial-fed8109b17fd2b41de17ceef92f37e39dc1ffc53.tar.bz2
GT5-Unofficial-fed8109b17fd2b41de17ceef92f37e39dc1ffc53.zip
Update with exp changes
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_BaseCrop.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java4
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java296
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java17
-rw-r--r--src/main/java/gregtech/api/util/GT_PlayedSound.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java4
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeRegistrator.java71
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java50
8 files changed, 297 insertions, 149 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java
index f01b05a60f..6cdd6ab02b 100644
--- a/src/main/java/gregtech/api/util/GT_BaseCrop.java
+++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java
@@ -175,7 +175,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo {
@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) {
+ if (mSpecialDrops != null && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) {
return GT_Utility.copy(mSpecialDrops[tDrop]);
}
return GT_Utility.copy(mDrop);
diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java
index a60189ea71..9937d0c069 100644
--- a/src/main/java/gregtech/api/util/GT_LanguageManager.java
+++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java
@@ -75,9 +75,11 @@ public class GT_LanguageManager {
public static String getTranslation(String aKey, String aSeperator) {
if (aKey == null) return E;
String rTranslation = E;
+ StringBuilder rTranslationSB = new StringBuilder(rTranslation);
for (String tString : aKey.split(aSeperator)) {
- rTranslation += getTranslation(tString);
+ rTranslationSB.append(getTranslation(tString));
}
+ rTranslation = String.valueOf(rTranslationSB);
return rTranslation;
}
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index 2154f3272e..070f748b95 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -1,5 +1,6 @@
package gregtech.api.util;
+import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.GT_Mod;
@@ -38,6 +39,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
+import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
@@ -53,18 +55,74 @@ import static gregtech.api.enums.GT_Values.*;
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);
+ 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 Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
+ private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
private static boolean sBufferCraftingRecipes = true;
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_list = new ArrayList<Integer>(100);
+ private static boolean sSingleNonBlockDamagableRecipeList_create = true;
+ 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}
+ };
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<Integer>(44);
+ public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;
+ public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<Integer>(50);
+ public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<Integer>(50);
+ public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<IRecipe>(1000);
static {
sNativeRecipeClasses.add(ShapedRecipes.class.getName());
@@ -501,7 +559,7 @@ public class GT_ModHandler {
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
}
-
+ addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3);
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)) {
@@ -537,6 +595,31 @@ public class GT_ModHandler {
return true;
}
+ static Class tClass;
+ static Method tMethod1;
+ static Method tMethod2;
+
+ public static boolean addMagneticraftRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){
+ if(GT_Mod.gregtechproxy.mMagneticraftRecipes && Loader.isModLoaded("Magneticraft")){
+ try {
+ if(tClass==null)tClass = Class.forName("com.cout970.magneticraft.api.access.MgRecipeRegister");
+ if(tMethod1==null)tMethod1 = tClass.getMethod("registerCrusherRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class);
+ if(tMethod2==null)tMethod2 = tClass.getMethod("registerGrinderRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class);
+
+ ItemData tData = GT_OreDictUnificator.getAssociation(aInput);
+ if(tData!=null&&tData.mPrefix!=null){
+ if(tData.mPrefix==OrePrefixes.ore||tData.mPrefix==OrePrefixes.oreBlackgranite||tData.mPrefix==OrePrefixes.oreEndstone||tData.mPrefix==OrePrefixes.oreNetherrack||tData.mPrefix==OrePrefixes.oreRedgranite){
+ tMethod1.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent));
+ }else if(tData.mPrefix==OrePrefixes.crushed||tData.mPrefix==OrePrefixes.crushedCentrifuged||tData.mPrefix==OrePrefixes.crushedPurified){
+ tMethod2.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent));
+ }
+ }
+
+ } catch (Exception e) {e.printStackTrace();}
+ }
+ return true;
+ }
+
/**
* Adds a Recipe to the Sawmills of GregTech and ThermalCraft
*/
@@ -699,7 +782,7 @@ public class GT_ModHandler {
public static void stopBufferingCraftingRecipes() {
sBufferCraftingRecipes = false;
- for (IRecipe tRecipe : sBufferRecipeList) GameRegistry.addRecipe(tRecipe);
+ for (IRecipe tRecipe : sBufferRecipeList) {GameRegistry.addRecipe(tRecipe);}
sBufferRecipeList.clear();
}
@@ -868,8 +951,8 @@ public class GT_ModHandler {
if (aRecipe[idx] instanceof Boolean) {
idx++;
}
- HashMap<Character, ItemStack> tItemStackMap = new HashMap<Character, ItemStack>();
- HashMap<Character, ItemData> tItemDataMap = new HashMap<Character, ItemData>();
+ /*ConcurrentHash*/Map<Character, ItemStack> tItemStackMap = new /*ConcurrentHash*/HashMap<Character, ItemStack>();
+ /*ConcurrentHash*/Map<Character, ItemData> tItemDataMap = new /*ConcurrentHash*/HashMap<Character, ItemData>();
tItemStackMap.put(' ', null);
boolean tRemoveRecipe = true;
@@ -954,11 +1037,12 @@ public class GT_ModHandler {
if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) {
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
- for (int i = 0; i < tList.size() && !tThereWasARecipe; i++) {
+ int tList_sS=tList.size();
+ for (int i = 0; i < tList_sS && !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--);
+ tList.remove(i--); tList_sS=tList.size();
tThereWasARecipe = true;
}
}
@@ -1028,11 +1112,11 @@ public class GT_ModHandler {
} else if (tObject instanceof String) {
tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1);
if (tRecipe[i] == null) break;
- } else if (tObject instanceof Boolean) {
+ }/* else if (tObject instanceof Boolean) {
//
} else {
throw new IllegalArgumentException();
- }
+ }*/
i++;
}
removeRecipe(tRecipe);
@@ -1094,18 +1178,16 @@ public class GT_ModHandler {
}, 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++) {
+ int tList_sS=tList.size();
+ try {
+ for (int i = 0; i < tList_sS; i++) {
+ for (; i < tList_sS; 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--);
+ if (rReturn != null) tList.remove(i--); tList_sS=tList.size();
}
}
- } catch (Throwable e) {
- e.printStackTrace(GT_Log.err);
- }
- }
+ }} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
return rReturn;
}
@@ -1124,7 +1206,8 @@ public class GT_ModHandler {
boolean rReturn = false;
ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList();
aOutput = GT_OreDictUnificator.get(aOutput);
- for (int i = 0; i < tList.size(); i++) {
+ int tList_sS=tList.size();
+ for (int i = 0; i < tList_sS; i++) {
IRecipe tRecipe = tList.get(i);
if (aNotRemoveShapelessRecipes && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe))
continue;
@@ -1135,7 +1218,7 @@ public class GT_ModHandler {
}
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--);
+ tList.remove(i--); tList_sS=tList.size();
rReturn = true;
}
}
@@ -1172,11 +1255,12 @@ public class GT_ModHandler {
sAllRecipeList.clear();
sAllRecipeList.addAll(tList);
}
- for (int i = 0, j = sAllRecipeList.size(); i < j; i++) {
+ int sAllRecipeList_sS=sAllRecipeList.size();
+ for (int i = 0, j = sAllRecipeList_sS; i < j; i++) {
IRecipe tRecipe = sAllRecipeList.get(i);
if (tRecipe.matches(aCrafting, aWorld)) {
if (i > 10) {
- sAllRecipeList.remove(i);
+ sAllRecipeList.remove(i); sAllRecipeList_sS=sAllRecipeList.size();
sAllRecipeList.add(i - 10, tRecipe);
}
return tRecipe.getCraftingResult(aCrafting);
@@ -1236,25 +1320,23 @@ public class GT_ModHandler {
}, 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 {
+ int tList_sS=tList.size();
+ try {
+ for (int i = 0; i < tList_sS; i++) {
+ temp = false;
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);
+ 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);
+ }
}
- }
- }
+ }} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
return null;
}
@@ -1264,47 +1346,69 @@ public class GT_ModHandler {
* 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()) {
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ if (aRecipe == null) {return rList;}
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) {
+ sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();}
+ if (sSingleNonBlockDamagableRecipeList_create/*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 (!(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 (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)) {
+ 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);
}
+ 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));
+ int aList_move = sSingleNonBlockDamagableRecipeList.size();
+ sSingleNonBlockDamagableRecipeList_list.add(aList_move);
+ sSingleNonBlockDamagableRecipeList_create = false;
+ sSingleNonBlockDamagableRecipeList_validsShapes1_update = true;
+ InventoryCrafting aCrafting = new InventoryCrafting(new Container() {
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3);
+ for (int i = 0; i < aList_move; i++) {
+ for (int j = 0; j < sShapes1.length; j++) {
+ ItemStack[] sRecipe = sShapes1[j];
+ for (int l = 0; l < 9 && l < sRecipe.length; l++) {aCrafting.setInventorySlotContents(l, sRecipe[l]);}
+ IRecipe vRecipe = sSingleNonBlockDamagableRecipeList.get(i);
+ if (vRecipe.matches(aCrafting, DW)) {
+ if (!(sSingleNonBlockDamagableRecipeList_validsShapes1.contains(j))) {sSingleNonBlockDamagableRecipeList_validsShapes1.add(j);}
+ sSingleNonBlockDamagableRecipeList_verified.add(vRecipe);
+ }
+ }
+ }
+
}
- ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe);
- if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished)
- sSingleNonBlockDamagableRecipeList.clear();
+ /*ArrayList<ItemStack> */
+ if (sSingleNonBlockDamagableRecipeList_verified.size() != 0) {rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList_verified, true, aRecipe);}
+ if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) {
+ sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();}
return rList;
}
@@ -1322,7 +1426,7 @@ public class GT_ModHandler {
*/
public static ArrayList<ItemStack> getRecipeOutputs(List<IRecipe> aList, boolean aDeleteFromList, ItemStack... aRecipe) {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- if (aRecipe == null) return rList;
+ if (aRecipe == null || aList.size() == 0) {return rList;}
boolean temp = false;
for (byte i = 0; i < aRecipe.length; i++) {
if (aRecipe[i] != null) {
@@ -1330,33 +1434,51 @@ public class GT_ModHandler {
break;
}
}
- if (!temp) return rList;
+ 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);
+ for (int i = 0; i < 9 && i < aRecipe.length; i++) {aCrafting.setInventorySlotContents(i, aRecipe[i]);}
+ int aList_sS=aList.size();
+ ArrayList<Integer> tempaList_list = new ArrayList<Integer>();
+ if(!aDeleteFromList) {
+ for (int i = 0; i < aList_sS; i++) {
+ IRecipe tempALg0 = aList.get(i);
+ if (tempALg0.matches(aCrafting, DW)) {
+ ItemStack tOutput = tempALg0.getCraftingResult(aCrafting);
+ if (tOutput == null || tOutput.stackSize <= 0) {
+ if (!(sVanillaRecipeList_warntOutput.contains(i))) {sVanillaRecipeList_warntOutput.add(i);}
+ } else {
+ rList.add(GT_Utility.copy(tOutput));
+ if (aDeleteFromList) {tempaList_list.add(i);}
+ }
+ }
}
- if (temp) {
- ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting);
+ } else {
+ for (int i = 0; i < aList_sS; i++) {
+ IRecipe tempALg0 = aList.get(i);
+ ItemStack tOutput = tempALg0.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.");
+ if (!(sSingleNonBlockDamagableRecipeList_warntOutput.contains(i))) {sSingleNonBlockDamagableRecipeList_warntOutput.add(i);}
} else {
rList.add(GT_Utility.copy(tOutput));
- if (aDeleteFromList) aList.remove(i--);
+ if (aDeleteFromList) {tempaList_list.add(i);}
}
}
}
+ //boolean tempaList_list_b = tempaList_list.size() != 0 ? true : false;
+ if (aDeleteFromList && tempaList_list.size() != 0) {
+ List<IRecipe> tempaList_2 = new ArrayList<IRecipe>();
+ for (int i = 0; i < aList_sS; i++) {
+ int k = 0, l = 0;
+ if (tempaList_list.get(k) == i) {k++;continue;}
+ tempaList_2.add(aList.get(l));l++;
+ }
+ aList = tempaList_2;
+ }
return rList;
}
@@ -1406,7 +1528,7 @@ public class GT_ModHandler {
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();
+ ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray(new ItemStack[tEntry.getValue().items.size()]);
if (tList.length == 0) break;
ItemStack[] rList = new ItemStack[aOutputSlots.length];
rRecipeMetaData.setTag("return", tEntry.getValue().metadata);
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
index 4060f5f906..456d8cee58 100644
--- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
+++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
@@ -15,6 +15,7 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
import java.util.Map.Entry;
import static gregtech.api.enums.GT_Values.*;
@@ -29,8 +30,8 @@ import static gregtech.api.enums.GT_Values.*;
* 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 /*ConcurrentHash*/Map<String, ItemStack> sName2StackMap = new /*ConcurrentHash*/HashMap<String, ItemStack>();
+ private static final /*ConcurrentHash*/Map<GT_ItemStack, ItemData> sItemStack2DataMap = new /*ConcurrentHash*/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;
@@ -265,12 +266,14 @@ public class GT_OreDictUnificator {
public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) {
ItemStack rStack = null;
- if (((aMaterialAmount >= M) || aMaterialAmount >= M * 32))
+ if (((aMaterialAmount >= M)))
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);
+ if (rStack == null) {
+ if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M);
+ if ((((aMaterialAmount * 4) >= M)))
+ rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M);
+ }
return rStack;
}
diff --git a/src/main/java/gregtech/api/util/GT_PlayedSound.java b/src/main/java/gregtech/api/util/GT_PlayedSound.java
index 858f3b826e..136171f7b7 100644
--- a/src/main/java/gregtech/api/util/GT_PlayedSound.java
+++ b/src/main/java/gregtech/api/util/GT_PlayedSound.java
@@ -15,7 +15,7 @@ public class GT_PlayedSound {
@Override
public boolean equals(Object aObject) {
- if (aObject != null && aObject instanceof GT_PlayedSound) {
+ if (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;
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 222da31402..079fa29fdc 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -512,11 +512,11 @@ public class GT_Recipe {
/**
* HashMap of Recipes based on their Items
*/
- public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new HashMap<GT_ItemStack, Collection<GT_Recipe>>();
+ public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/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>>();
+ public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/HashMap<Fluid, Collection<GT_Recipe>>();
/**
* The List of all Recipes
*/
diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
index 611c8d34e2..df26dce0d4 100644
--- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
+++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java
@@ -121,6 +121,8 @@ public class GT_RecipeRegistrator {
{"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R}
};
public static volatile int VERSION = 509;
+ public static int sRodMaterialList_cycles = 0;
+ private static int i_count = 0;
public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) {
if (GT_Utility.isStackInvalid(aStack)) return;
@@ -176,7 +178,7 @@ public class GT_RecipeRegistrator {
}
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));
+ registerReverseArcSmelting(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03));
}
public static void registerReverseArcSmelting(ItemStack aStack, ItemData aData) {
@@ -210,7 +212,11 @@ public class GT_RecipeRegistrator {
continue;
}
if (tMaterial.mMaterial.contains(SubTag.METAL)) {
+ if(GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed){
tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto;
+ }else{
+ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mSmeltInto;
+ }
continue;
}
tMaterial.mAmount = 0;
@@ -234,7 +240,7 @@ public class GT_RecipeRegistrator {
}
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);
+ registerReverseMacerating(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer);
}
public static void registerReverseMacerating(ItemStack aStack, ItemData aData, boolean aAllowHammer) {
@@ -272,7 +278,7 @@ public class GT_RecipeRegistrator {
* 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 aPlate 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) {
@@ -280,8 +286,11 @@ public class GT_RecipeRegistrator {
aMat = GT_Utility.copy(aMat);
ItemStack tStack;
ItemData aItemData = GT_OreDictUnificator.getItemData(aMat);
- if (aItemData == null || aItemData.mPrefix != OrePrefixes.ingot) aPlate = null;
+ boolean aItemData_b_0 = aItemData != null ? true : false;
+ if (!aItemData_b_0 || aItemData.mPrefix != OrePrefixes.ingot) {aPlate = null;}
if (aPlate != null && GT_OreDictUnificator.getFirstOre(aPlate, 1) == null) aPlate = null;
+ boolean aItemData_b_1 = aItemData.hasValidPrefixMaterialData() ? true : false;
+ boolean aPlate_b_0 = aPlate != null ? true : false;
sMt1.func_150996_a(aMat.getItem());
sMt1.stackSize = 1;
@@ -296,12 +305,13 @@ public class GT_RecipeRegistrator {
for (ItemStack tMat : tRecipe) {
if (tMat == sMt1) tAmount1++;
}
- if (aItemData != null && aItemData.hasValidPrefixMaterialData())
+ if (aItemData_b_0 && aItemData_b_1)
for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) {
GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1));
}
}
+ GT_ModHandler.getVanillyToolRecipeOutputs(sShapes1[0]);
for (Materials tMaterial : sRodMaterialList) {
ItemStack tMt2 = GT_OreDictUnificator.get(OrePrefixes.stick, tMaterial, 1);
if (tMt2 != null) {
@@ -309,37 +319,48 @@ public class GT_RecipeRegistrator {
sMt2.stackSize = 1;
Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2));
- for (int i = 0; i < sShapes1.length; i++) {
- ItemStack[] tRecipe = sShapes1[i];
+ if (GT_ModHandler.sSingleNonBlockDamagableRecipeList.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_verified.size() == 0) { sRodMaterialList_cycles++;continue;}
+ int sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size();
+ for (int i = 0; i < sShapes1_len; i++) {
+ int i2 = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.get(i);
+ ItemStack[] tRecipe = sShapes1[i2];
+ if (tRecipe == null) continue;
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;
+ List<ItemStack> tempTest = GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe);
+ if (GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update && GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() != 0) {sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size();GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;}
+ int tempTest_size_sS = tempTest.size();
+ if (tempTest_size_sS > 0) {
+ for (ItemStack tCrafted : tempTest/*GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)*/) {
+ if (aItemData_b_0 && aItemData_b_1) {
+ GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2)));
+ }
+
+ if (aRecipeReplacing && aPlate_b_0 && sShapesA[i2] != null && sShapesA[i2].length > 1) {
+ //assert aItemData != null;//dead dev code or decomp JAD?
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, new StringBuilder().append(aItemData.mMaterial.mMaterial).append('.').append(sShapesA[i2][0]).toString(), 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[i2][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[i2][1], sShapesA[i2][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[i2][1], sShapesA[i2][2], sShapesA[i2][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ }
}
}
}
}
}
+ sRodMaterialList_cycles++;
}
}
}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 29c5ab2c8b..34ef3d0963 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -20,7 +20,6 @@ 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;
@@ -83,11 +82,11 @@ 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>>();
+ private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<GT_ItemStack, FluidContainerData>();
+ private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>();
public static volatile int VERSION = 509;
public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
- public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new HashMap<GT_PlayedSound, Integer>();
+ public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>();
private static int sBookCount = 0;
static {
@@ -320,7 +319,7 @@ public class GT_Utility {
}
public static void sendChatToPlayer(EntityPlayer aPlayer, String aChatMessage) {
- if (aPlayer != null && aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
+ if (aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
aPlayer.addChatComponentMessage(new ChatComponentText(aChatMessage));
}
}
@@ -501,7 +500,7 @@ public class GT_Utility {
* @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)
+ if (aTileEntity1 instanceof IInventory)
return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
return 0;
}
@@ -598,7 +597,7 @@ public class GT_Utility {
for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
}
- if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) {
+ if (aTileEntity2 instanceof IInventory) {
for (int i = 0; i < tGrabSlots.length; i++) {
if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) {
@@ -698,7 +697,7 @@ public class GT_Utility {
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>());
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(tData.fluid.getFluid(), tData);
@@ -710,7 +709,7 @@ public class GT_Utility {
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>());
+ sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(aData.fluid.getFluid(), aData);
@@ -921,7 +920,7 @@ public class GT_Utility {
}
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);
+ return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ);
}
public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) {
@@ -1011,7 +1010,7 @@ public class GT_Utility {
}
public static boolean isBlockValid(Object aBlock) {
- return aBlock != null && (aBlock instanceof Block);
+ return (aBlock instanceof Block);
}
public static boolean isBlockInvalid(Object aBlock) {
@@ -1027,7 +1026,7 @@ public class GT_Utility {
}
public static boolean isStackValid(Object aStack) {
- return aStack != null && (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
+ return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}
public static boolean isStackInvalid(Object aStack) {
@@ -1095,7 +1094,6 @@ public class GT_Utility {
* Converts a Number to a String
*/
public static String parseNumberToString(int aNumber) {
- String tString = E;
boolean temp = true, negative = false;
if (aNumber < 0) {
@@ -1103,15 +1101,18 @@ public class GT_Utility {
negative = true;
}
+ StringBuilder tStringB = new StringBuilder();
for (int i = 1000000000; i > 0; i /= 10) {
int tDigit = (aNumber / i) % 10;
if (temp && tDigit != 0) temp = false;
if (!temp) {
- tString += tDigit;
- if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tString += ",";
+ tStringB.append(tDigit);
+ if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(",");
}
}
+ String tString = tStringB.toString();
+
if (tString.equals(E)) tString = "0";
return negative ? "-" + tString : tString;
@@ -1379,7 +1380,7 @@ public class GT_Utility {
* 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>();
+ Map<X, Y> tMap = new /*Concurrent*/HashMap<X, Y>();
tMap.putAll(aMap);
aMap.clear();
aMap.putAll(tMap);
@@ -1410,7 +1411,7 @@ public class GT_Utility {
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());
+ return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO
}
});
LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>();
@@ -1559,7 +1560,7 @@ public class GT_Utility {
tList.add("----- X: " + aX + " Y: " + aY + " Z: " + aZ + " -----");
try {
- if (tTileEntity != null && tTileEntity instanceof IInventory)
+ if (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));
@@ -1722,10 +1723,11 @@ public class GT_Utility {
+ " Humidity: " + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity()
+ " Air-Quality: " + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality()
);
- String tString = E;
+ StringBuilder tStringB = new StringBuilder();
for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) {
- tString += ", " + tAttribute;
+ tStringB.append(", ").append(tAttribute);
}
+ String tString = tStringB.toString();
tList.add("Attributes:" + tString.replaceFirst(",", E));
tList.add("Discovered by: " + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy());
}
@@ -1994,16 +1996,14 @@ public class GT_Utility {
if (aStack != null) {
NBTTagList nbttaglist = aStack.getEnchantmentTagList();
if (nbttaglist != null) {
- for (int i = 0; i < nbttaglist.tagCount(); ++i) {
- try {
+ try {
+ for (int i = 0; i < nbttaglist.tagCount(); ++i) {
short short1 = nbttaglist.getCompoundTagAt(i).getShort("id");
short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.enchantmentsList[short1] != null)
aBullshitModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2);
- } catch (Throwable e) {
- //
}
- }
+ } catch (Throwable e) {/**/}
}
}
}