aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-22 21:55:14 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-22 21:55:14 +1000
commita6c18435d4bd220bc96127ecc63e0ad8df0c8c6f (patch)
tree8d5e19bfffb7dc735a9d3b6919cb9b8d69b70724 /src/Java/gtPlusPlus/core/util
parentcb2fe66fc1e0af40f23209398727faa08c330f20 (diff)
downloadGT5-Unofficial-a6c18435d4bd220bc96127ecc63e0ad8df0c8c6f.tar.gz
GT5-Unofficial-a6c18435d4bd220bc96127ecc63e0ad8df0c8c6f.tar.bz2
GT5-Unofficial-a6c18435d4bd220bc96127ecc63e0ad8df0c8c6f.zip
+ Added config for the Large Extruder.
+ Added config for machine component assemblers. + Added recipes for Large Extruder and its casings. % Changed default config value for custom circuits. It was true, now it is false. $ Tweaked ASM class handling when conditions are not met.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java91
-rw-r--r--src/Java/gtPlusPlus/core/util/sys/GeoUtils.java6
2 files changed, 77 insertions, 20 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
index 5642b4f3e9..62cb3f147e 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
@@ -1,7 +1,9 @@
package gtPlusPlus.core.util.minecraft;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
@@ -254,31 +256,44 @@ public class ItemUtils {
}
public static ItemStack getItemStackOfAmountFromOreDict(final String oredictName, final int amount){
-
String mTemp = oredictName;
-
//Banned Materials and replacements for GT5.8 compat.
if (oredictName.toLowerCase().contains("rutile")){
mTemp = oredictName.replace("Rutile", "Titanium");
}
if (oredictName.toLowerCase().contains("vanadiumsteel")){
mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel");
- }
+ }
- ItemStack mTempItem = getItemStackOfAmountFromOreDictNoBroken(mTemp, amount);
- if (mTempItem != null) {
- return mTempItem;
+ //Use Cache
+ if (mDustCache.containsKey(oredictName)) {
+ return getSimpleStack(mDustCache.get(oredictName), amount);
+ }
+ if (mOreDictCache.containsKey(mTemp)) {
+ return getCachedValue(mTemp, amount);
}
final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp);
if (!oreDictList.isEmpty()){
final ItemStack returnValue = oreDictList.get(0).copy();
returnValue.stackSize = amount;
+ setCachedValue(mTemp, returnValue);
return returnValue;
}
+ setCachedValue(oredictName, getSimpleStack(ModItems.AAA_Broken));
return getSimpleStack(ModItems.AAA_Broken, amount);
}
+ 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);
+ }
+
public static ItemStack getItemStackOfAmountFromOreDictNoBroken(final String oredictName, final int amount){
if (CORE.DEBUG){
Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(1));
@@ -286,7 +301,17 @@ public class ItemUtils {
Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(3));
Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(4));
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.
@@ -296,28 +321,26 @@ public class ItemUtils {
final Materials m = Materials.get(MaterialName);
returnValue = getGregtechDust(m, amount);
if (returnValue != null){
+ setCachedValue(oredictName, returnValue);
return returnValue;
}
- else {
- returnValue = getGregtechDust(oredictName, amount);
- if (returnValue != null) {
- return returnValue;
- }
- }
}
if (returnValue == null){
returnValue = getItemStackOfAmountFromOreDict(oredictName, amount);
if (returnValue != null){
- if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) || (returnValue.getItem() != ModItems.AAA_Broken)){
+ if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) || (returnValue.getItem() != ModItems.AAA_Broken)){
+ setCachedValue(oredictName, returnValue);
return returnValue.copy();
}
}
}
Logger.WARNING(oredictName+" was not valid.");
+ setCachedValue(oredictName, null);
return null;
}
catch (final Throwable t){
+ setCachedValue(oredictName, null);
return null;
}
}
@@ -625,29 +648,50 @@ public class ItemUtils {
return outputs;
}
- private static String getModId(final Item item) {
+ private static Map<Item, String> mModidCache = new HashMap<Item, String>();
+
+ private static String getModId(final Item item) {
+ if (mModidCache.containsKey(item)) {
+ return mModidCache.get(item);
+ }
+ String value = "";
try {
final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item);
- final String modname = (id.modId == null ? id.name : id.modId);
- return (id == null) || id.modId.equals("") ? "minecraft" : modname;
+ if (id != null) {
+ final String modname = (id.modId == null ? id.name : id.modId);
+ value = ((id == null) || id.modId.equals("")) ? "minecraft" : modname;
+ }
} catch (final Throwable t){
try {
final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item));
- final String modname = (t2.modId == null ? t2.name : t2.modId);
- return (t2 == null) || t2.modId.equals("") ? "minecraft" : modname;
+ if (t2 != null) {
+ final String modname = (t2.modId == null ? t2.name : t2.modId);
+ value = ((t2 == null) || t2.modId.equals("")) ? "minecraft" : modname;
+ }
}
catch (final Throwable t3){
- return "bad modid";
+ value = "bad modid";
}
}
+ if (!mModidCache.containsKey(item)) {
+ return mModidCache.put(item, value);
+ }
+ return value;
}
public static String getModId(final ItemStack key) {
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;
@@ -655,6 +699,7 @@ public class ItemUtils {
final String modid = getModId(oreDictList.get(xrc).getItem());
if (modid.equals("gregtech") || modid.equals(CORE.MODID)){
returnvalue = oreDictList.get(xrc).copy();
+ mDustCache.put(oredictName, returnvalue);
returnvalue.stackSize = amount;
return returnvalue;
}
@@ -665,6 +710,11 @@ 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;
@@ -672,6 +722,7 @@ public class ItemUtils {
final String modid = getModId(oreDictList.get(xrc).getItem());
if (!modid.equals("tconstruct")){
returnvalue = oreDictList.get(xrc).copy();
+ mDustCache.put(oredictName, returnvalue);
returnvalue.stackSize = amount;
return returnvalue;
}
@@ -694,7 +745,7 @@ public class ItemUtils {
//Utils.LOG_INFO("[Component Maker] Found "+mItemName+".");
return (gregstack);
}
-
+
public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Material mMat, int mAmount) {
diff --git a/src/Java/gtPlusPlus/core/util/sys/GeoUtils.java b/src/Java/gtPlusPlus/core/util/sys/GeoUtils.java
index ae3e6242ed..3f465aa30f 100644
--- a/src/Java/gtPlusPlus/core/util/sys/GeoUtils.java
+++ b/src/Java/gtPlusPlus/core/util/sys/GeoUtils.java
@@ -6,10 +6,12 @@ import java.net.*;
import org.apache.http.client.utils.URIBuilder;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
public class GeoUtils {
public static String determineUsersCountry(){
+ if (!CORE.DEBUG && !CORE.DEVENV) {
try {
if (NetworkUtils.checkNetworkIsAvailableWithValidInterface()){
return getUsersCountry();
@@ -21,6 +23,10 @@ public class GeoUtils {
Logger.INFO("Failed to initialise GeoUtils.");
return "Failed.";
}
+ }
+ else {
+ return "Debug/Dev";
+ }
}
private static String getUsersIPAddress() {