aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorMuramasa- <haydenkilloh@gmail.com>2016-09-13 21:09:38 +0100
committerGitHub <noreply@github.com>2016-09-13 21:09:38 +0100
commit059cf34455b326abfed19da176d62ad478fca7c6 (patch)
treeb0b77ea0391b55f40a99931b54bb8992256737fe /src/main/java/gregtech/api/util
parent4091b39401329c7dbc849b37c3eafbb95943566b (diff)
parent0d9c100ade10ebc72905b0f2a298e9b078b233d8 (diff)
downloadGT5-Unofficial-059cf34455b326abfed19da176d62ad478fca7c6.tar.gz
GT5-Unofficial-059cf34455b326abfed19da176d62ad478fca7c6.tar.bz2
GT5-Unofficial-059cf34455b326abfed19da176d62ad478fca7c6.zip
Merge pull request #631 from Muramasa-/LoadTimes
Various Load Time Improvements
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_ModHandler.java243
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java5
-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.java63
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java33
7 files changed, 230 insertions, 122 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java
index c106816ba2..0171e35ff2 100644
--- a/src/main/java/gregtech/api/util/GT_BaseCrop.java
+++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java
@@ -177,7 +177,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_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index be85ca29ce..00d637398d 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -52,18 +52,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());
@@ -696,7 +752,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();
}
@@ -865,8 +921,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;
@@ -951,11 +1007,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;
}
}
@@ -1025,11 +1082,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);
@@ -1091,18 +1148,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;
}
@@ -1121,7 +1176,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;
@@ -1132,7 +1188,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;
}
}
@@ -1169,11 +1225,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);
@@ -1233,13 +1290,11 @@ 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++) {
+ int tList_sS=tList.size();
+ try {
+ for (int i = 0; i < tList_sS; i++) {
temp = false;
- try {
- temp = tList.get(i).matches(aCrafting, DW);
- } catch (Throwable e) {
- e.printStackTrace(GT_Log.err);
- }
+ temp = tList.get(i).matches(aCrafting, DW);
if (temp) {
ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) {
@@ -1251,7 +1306,7 @@ public class GT_ModHandler {
return GT_Utility.copy(tOutput);
}
}
- }
+ }} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
return null;
}
@@ -1261,47 +1316,67 @@ 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 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 {
- sSingleNonBlockDamagableRecipeList.add(tRecipe);
}
+ 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));
+ 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;
}
@@ -1319,7 +1394,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) {
@@ -1327,32 +1402,50 @@ 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;
}
diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java
index b404299fad..dddf2ec576 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;
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..27d3aed199 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;
@@ -272,7 +274,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 +282,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 +301,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 +315,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..309dc47889 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);
@@ -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) {
@@ -1379,7 +1378,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);
@@ -1559,7 +1558,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));
@@ -1994,16 +1993,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) {/**/}
}
}
}