diff options
author | Alkalus <draknyte1@hotmail.com> | 2018-03-24 05:56:17 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-24 05:56:17 +1000 |
commit | 52ab567aac4c2fca4bea587138a668d56a6cb485 (patch) | |
tree | 21fed244828691793d695e5c44d33098a926f550 /src/Java | |
parent | 81efede21a70964c97ab2a95eb5544a2670252f3 (diff) | |
parent | cf868043e9e3d7a406261f12eed646c140db6f83 (diff) | |
download | GT5-Unofficial-52ab567aac4c2fca4bea587138a668d56a6cb485.tar.gz GT5-Unofficial-52ab567aac4c2fca4bea587138a668d56a6cb485.tar.bz2 GT5-Unofficial-52ab567aac4c2fca4bea587138a668d56a6cb485.zip |
Merge pull request #237 from codewarrior0/no-oredict-cache
Remove mOreDictCache and mDustCache from ItemUtils
Diffstat (limited to 'src/Java')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java | 67 |
1 files changed, 7 insertions, 60 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 5eaf84d107..42f130ad57 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -265,42 +265,13 @@ public class ItemUtils { if (oredictName.toLowerCase().contains("vanadiumsteel")){ mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); } - //Use Cache - if (mOreDictCache.containsKey(mTemp) && mOreDictCache.get(mTemp) != null && mOreDictCache.get(mTemp).getItem() != ModItems.AAA_Broken) { - //Logger.INFO("[ODC] Returning mOreDictCache value."); - return getCachedValue(mTemp, amount); - } - else if (mDustCache.containsKey(oredictName) && mDustCache.get(mTemp) != null && mOreDictCache.get(mTemp).getItem() != ModItems.AAA_Broken) { - //Logger.INFO("[ODC] Returning mDustCache value."); - return getSimpleStack(mDustCache.get(oredictName), amount); - } - else { - //Logger.INFO("[ODC] Setting mOreDictCache value."); - final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp); - if (!oreDictList.isEmpty()){ - final ItemStack returnValue = oreDictList.get(0).copy(); - returnValue.stackSize = amount; - if (returnValue.getItem() != ModItems.AAA_Broken) { - setCachedValue(mTemp, returnValue); - } - //Logger.INFO("[ODC] Setting and Returning mOreDictCache value."); - return returnValue; - } - setCachedValue(oredictName, getSimpleStack(ModItems.AAA_Broken)); - //Logger.INFO("[ODC] Returning AAA_Broken."); - return getSimpleStack(ModItems.AAA_Broken, amount); + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp); + if (!oreDictList.isEmpty()){ + final ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; } - - } - - private static Map<String, ItemStack> mOreDictCache = new HashMap(); - - private static ItemStack getCachedValue(String string, int amount) { - return getSimpleStack(mOreDictCache.get(string), amount); - } - - private static void setCachedValue(String string, ItemStack stack) { - mOreDictCache.put(string, stack); + return getSimpleStack(ModItems.AAA_Broken, amount); } public static ItemStack getItemStackOfAmountFromOreDictNoBroken(final String oredictName, final int amount){ @@ -312,15 +283,6 @@ public class ItemUtils { Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(5)); } - //Use Cache - if (mDustCache.containsKey(oredictName)) { - return getSimpleStack(mDustCache.get(oredictName), amount); - } - if (mOreDictCache.containsKey(oredictName)) { - return getCachedValue(oredictName, amount); - } - - try{ //Adds a check to grab dusts using GT methodology if possible. @@ -330,7 +292,6 @@ public class ItemUtils { final Materials m = Materials.get(MaterialName); returnValue = getGregtechDust(m, amount); if (returnValue != null){ - setCachedValue(oredictName, returnValue); return returnValue; } } @@ -339,7 +300,6 @@ public class ItemUtils { returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); if (returnValue != null){ if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) || (returnValue.getItem() != ModItems.AAA_Broken)){ - setCachedValue(oredictName, returnValue); return returnValue.copy(); } } @@ -690,15 +650,8 @@ public class ItemUtils { return getModId(key.getItem()); } - private static Map<String, ItemStack> mDustCache = new HashMap<String, ItemStack>(); - //Take 2 - GT/GT++ Dusts public static ItemStack getGregtechDust(final String oredictName, final int amount){ - - if (mDustCache.containsKey(oredictName)) { - return getSimpleStack(mDustCache.get(oredictName), amount); - } - final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); if (!oreDictList.isEmpty()){ ItemStack returnvalue; @@ -706,7 +659,6 @@ public class ItemUtils { final String modid = getModId(oreDictList.get(xrc).getItem()); if (modid != null && (modid.equals("gregtech") || modid.equals(CORE.MODID))){ returnvalue = oreDictList.get(xrc).copy(); - mDustCache.put(oredictName, returnvalue); returnvalue.stackSize = amount; return returnvalue; } @@ -717,11 +669,6 @@ public class ItemUtils { //Anything But Tinkers Dust public static ItemStack getNonTinkersDust(final String oredictName, final int amount){ - - if (mDustCache.containsKey(oredictName)) { - return getSimpleStack(mDustCache.get(oredictName), amount); - } - final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); if (!oreDictList.isEmpty()){ ItemStack returnvalue; @@ -729,7 +676,6 @@ public class ItemUtils { final String modid = getModId(oreDictList.get(xrc).getItem()); if (modid != null && !modid.equals("tconstruct")){ returnvalue = oreDictList.get(xrc).copy(); - mDustCache.put(oredictName, returnvalue); returnvalue.stackSize = amount; return returnvalue; } @@ -738,6 +684,7 @@ public class ItemUtils { //If only Tinkers dust exists, bow down and just use it. return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); } + public static ItemStack getGregtechOreStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { String mName = MaterialUtils.getMaterialName(mMat); |