diff options
Diffstat (limited to 'src')
16 files changed, 713 insertions, 112 deletions
diff --git a/src/Java/gtPlusPlus/GenerateDictionaries.java b/src/Java/gtPlusPlus/GenerateDictionaries.java new file mode 100644 index 0000000000..abdf4f4027 --- /dev/null +++ b/src/Java/gtPlusPlus/GenerateDictionaries.java @@ -0,0 +1,176 @@ +package gtPlusPlus; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; + +import gtPlusPlus.api.objects.random.XSTR; + +public class GenerateDictionaries { + + public static void main(String[] args) { + + File aMainDictionary = new File("proguard/DictionaryMain.txt"); + File aMethodDict = new File("proguard/method-dict.txt"); + File aClassDict = new File("proguard/class-dict.txt"); + + if (Utils.doesFileExist(aMainDictionary)) { + Utils.log("Found Main Dictionary"); + List<String> aLines = Utils.readLines(aMainDictionary); + + ArrayList<String> aLinesToWriteMethods = new ArrayList<String>(); + ArrayList<String> aLinesToWriteClasses = new ArrayList<String>(); + + if (aLines != null && aLines.size() > 0) { + Utils.log("Main Dictionary has > 0 keywords ("+aLines.size()+")"); + HashSet<Integer> aUsedIndicies = new HashSet<Integer>(); + int aCount = aLines.size() / 5; + + Utils.log("Mapping "+aCount+" to each dict."); + // Map New Method Names + for (int i=0;aLinesToWriteMethods.size()<aCount;i++) { + Integer aIndex = Utils.randInt(0, aLines.size()-1); + if (!aUsedIndicies.contains(aIndex)) { + String aLineAtIndex = aLines.get(aIndex); + if (aLineAtIndex != null && aLineAtIndex.length() > 0) { + aLinesToWriteMethods.add(aLineAtIndex); + aUsedIndicies.add(aIndex); + } + } + if (i >= aCount * 5) { + break; + } + } + + // Map New Class Names + for (int i=0;aLinesToWriteClasses.size()<aCount;i++) { + Integer aIndex = Utils.randInt(0, aLines.size()-1); + if (!aUsedIndicies.contains(aIndex)) { + String aLineAtIndex = aLines.get(aIndex); + if (aLineAtIndex != null && aLineAtIndex.length() > 0) { + aLinesToWriteClasses.add(aLineAtIndex); + aUsedIndicies.add(aIndex); + } + } + if (i >= aCount * 5) { + break; + } + } + } + + // Remove old generated Dicts + if (Utils.doesFileExist(aMethodDict)) { + aMethodDict.delete(); + Utils.log("Removed old Method-Dict"); + } + if (Utils.doesFileExist(aClassDict)) { + aClassDict.delete(); + Utils.log("Removed old Class-Dict"); + } + + // Create new empty dict files + if (!Utils.doesFileExist(aMethodDict)) { + Utils.createFile(aMethodDict); + } + if (!Utils.doesFileExist(aClassDict)) { + Utils.createFile(aClassDict); + } + + Utils.log("Writing new Dictionaries."); + // Write + Utils.appendListToFile(aMethodDict, aLinesToWriteMethods); + Utils.appendListToFile(aClassDict, aLinesToWriteClasses); + + Utils.log("Finished all generation of new Dictionaries."); + + } + + } + + + + private static final class Utils { + + private static final Charset utf8 = StandardCharsets.UTF_8; + private static final Random rand = new XSTR(); + + private static final void log(String s) { + System.out.println("[GTPP-Proguard] "+s); + } + + public static int randInt(final int min, final int max) { + return rand.nextInt((max - min) + 1) + min; + } + + public static boolean doesFileExist(File f) { + if (f != null && f.exists() && !f.isDirectory()) { + return true; + } + return false; + } + + public static File createFile(File aFile) { + boolean blnCreated = false; + log("Trying to use relative path "+aFile.getPath()); + try { + //log("Trying to use path "+aFile.getCanonicalPath()); + //log("Trying to use absolute path "+aFile.getAbsolutePath()); + blnCreated = aFile.createNewFile(); + } catch (IOException ioe) { + log("Error while creating a new empty file :" + ioe); + return null; + } + return blnCreated ? aFile : null; + } + + public static boolean appendListToFile(File file, List<String> content) { + try { + long oldSize; + long newSize; + if (doesFileExist(file)) { + Path p = Paths.get(file.getPath()); + if (p != null && Files.isWritable(p)) { + oldSize = Files.size(p); + try { + Files.write(p, content, utf8, StandardOpenOption.APPEND); + } catch (IOException e) { + e.printStackTrace(); + } + newSize = Files.size(p); + return newSize > oldSize; + } + } + } catch (IOException e) { + } + return false; + } + + /** + * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3 + */ + public static List<String> readLines(File file) { + try { + return org.apache.commons.io.FileUtils.readLines(file, utf8); + } + catch (IOException e) { + return new ArrayList<String>(); + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index f1676689e7..69bd414d9c 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -701,6 +701,7 @@ public class RECIPES_GREGTECH { //NITINOL_60 CORE.RA.addBlastSmelterRecipe( new ItemStack[] { + ItemUtils.getGregtechCircuit(2), ELEMENT.getInstance().TITANIUM.getDust(3), ELEMENT.getInstance().NICKEL.getDust(2) }, diff --git a/src/Java/gtPlusPlus/core/util/data/FileUtils.java b/src/Java/gtPlusPlus/core/util/data/FileUtils.java index d7d6b9e36e..bec5e0eeff 100644 --- a/src/Java/gtPlusPlus/core/util/data/FileUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/FileUtils.java @@ -8,6 +8,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; +import java.util.ArrayList; import java.util.List; import gtPlusPlus.api.objects.Logger; @@ -26,17 +27,21 @@ public class FileUtils { public static File createFile(String path, String filename, String extension) { File file = new File(Utils.getMcDir(), path + filename + extension); + return createFile(file); + } + + public static File createFile(File aFile) { boolean blnCreated = false; - Logger.INFO("Trying to use path "+file.getPath()); + Logger.INFO("Trying to use path "+aFile.getPath()); try { - Logger.INFO("Trying to use path "+file.getCanonicalPath()); - Logger.INFO("Trying to use absolute path "+file.getAbsolutePath()); - blnCreated = file.createNewFile(); + Logger.INFO("Trying to use path "+aFile.getCanonicalPath()); + Logger.INFO("Trying to use absolute path "+aFile.getAbsolutePath()); + blnCreated = aFile.createNewFile(); } catch (IOException ioe) { Logger.INFO("Error while creating a new empty file :" + ioe); return null; } - return blnCreated ? file : null; + return blnCreated ? aFile : null; } public static File getFile(String filename, String extension) { @@ -92,4 +97,22 @@ public class FileUtils { } return false; } + + /** + * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3 + */ + public static List<String> readLines(File file) { + try { + return org.apache.commons.io.FileUtils.readLines(file, utf8); + } + catch (IOException e) { + return new ArrayList<String>(); + } + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 135f98dd17..4d8a02d800 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -43,7 +43,7 @@ public class ReflectionUtils { } } - + private static class CachedMethod { private final boolean STATIC; @@ -134,7 +134,7 @@ public class ReflectionUtils { return false; } - + /** * Returns a cached {@link Constructor} object. * @param aClass - Class containing the Constructor. @@ -145,7 +145,7 @@ public class ReflectionUtils { if (aClass == null || aTypes == null) { return null; } - + String aMethodKey = ArrayUtils.toString(aTypes); //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); CachedConstructor y = mCachedConstructors.get(aClass.getName() + "." + aMethodKey); @@ -162,9 +162,9 @@ public class ReflectionUtils { return y.get(); } } - - - + + + /** * Returns a cached {@link Class} object. @@ -227,14 +227,14 @@ public class ReflectionUtils { return y.get(); } } - + public static boolean isStaticMethod(Class<?> aClass, String aMethodName, Class<?>... aTypes) { return isStaticMethod(ReflectionUtils.getMethod(aClass, aMethodName, aTypes)); } - + public static boolean isStaticMethod(Method aMethod) { if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) { - return true; + return true; } return false; } @@ -467,7 +467,7 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return false; } - + public static boolean invoke(Object objectInstance, Method method, Object[] values){ if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); @@ -774,7 +774,7 @@ public class ReflectionUtils { } return m; } - + private static Constructor<?> getConstructor_Internal(Class<?> aClass, Class<?>... aTypes) { Constructor<?> c = null; try { @@ -801,7 +801,7 @@ public class ReflectionUtils { } return c; } - + private static Constructor<?> getConstructorRecursively(Class<?> aClass, Class<?>... aTypes) throws Exception { try { Logger.REFLECTION("Constructor: Recursion Lookup: "+aClass.getName()); @@ -921,31 +921,40 @@ public class ReflectionUtils { aClassName += (i > 0) ? "."+aData[i] : ""+aData[i]; Logger.REFLECTION("Building: "+aClassName); } - Logger.REFLECTION("Trying to search '"+aClassName+"' for inner classes."); - Class<?> clazz = ReflectionUtils.getClass(aClassName); - - Class[] y = clazz.getDeclaredClasses(); - if (y == null || y.length <= 0) { - Logger.REFLECTION("No hidden inner classes found."); - return null; - } - else { - boolean found = false; - for (Class<?> h : y) { - Logger.REFLECTION("Found hidden inner class: "+h.getCanonicalName()); - if (h.getSimpleName().toLowerCase().equals(aData[aData.length-1].toLowerCase())) { - Logger.REFLECTION("Found correct class. ["+aData[aData.length-1]+"] Caching at correct location: "+string); - Logger.REFLECTION("Found at location: "+h.getCanonicalName()); - ReflectionUtils.mCachedClasses.put(string, h); - aClass = h; - found = true; - break; + if (aClassName != null && aClassName.length() > 0) { + Logger.REFLECTION("Trying to search '"+aClassName+"' for inner classes."); + Class<?> clazz = ReflectionUtils.getClass(aClassName); + if (clazz != null) { + Class[] y = clazz.getDeclaredClasses(); + if (y == null || y.length <= 0) { + Logger.REFLECTION("No hidden inner classes found."); + return null; + } + else { + boolean found = false; + for (Class<?> h : y) { + Logger.REFLECTION("Found hidden inner class: "+h.getCanonicalName()); + if (h.getSimpleName().toLowerCase().equals(aData[aData.length-1].toLowerCase())) { + Logger.REFLECTION("Found correct class. ["+aData[aData.length-1]+"] Caching at correct location: "+string); + Logger.REFLECTION("Found at location: "+h.getCanonicalName()); + ReflectionUtils.mCachedClasses.put(string, h); + aClass = h; + found = true; + break; + } + } + if (!found) { + return null; + } } } - if (!found) { + else { return null; } } + else { + return null; + } } return aClass; } @@ -964,11 +973,9 @@ public class ReflectionUtils { */ private static void makeModifiable(Field nameField) throws Exception { nameField.setAccessible(true); - int modifiers = nameField.getModifiers(); - Field modifierField = nameField.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(nameField, modifiers); + Field modifiers = getField(Field.class, "modifiers"); + modifiers.setAccessible(true); + modifiers.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL); } diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index 88bcf6b28b..87ac77d5da 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -20,6 +20,9 @@ public class AsmConfig { public static boolean enableCofhPatch; public static boolean enableGcFuelChanges; public static boolean enableRcFlowFix; + public static int maxRailcraftTankProcessVolume; + public static int maxRailcraftFluidLoaderFlow; + public static int maxRailcraftFluidUnloaderFlow; public static boolean enableRcItemDupeFix; public static boolean enableTcAspectSafety; public static boolean enabledLwjglKeybindingFix; @@ -118,11 +121,31 @@ public class AsmConfig { //Railcraft Tank fix prop = config.get("general", "enableRcFlowFix", true); - prop.comment = "Quadruples max RC IO rates on tanks"; + prop.comment = "Allows Custom max IO rates on RC tanks"; prop.setLanguageKey("gtpp.enableRcFlowFix").setRequiresMcRestart(true); enableRcFlowFix = prop.getBoolean(true); propOrder.add(prop.getName()); + prop = config.get("general", "maxRailcraftTankProcessVolume", 4000); + prop.comment = "Max IO for RC fluid tanks (Not Carts). 'enableRcFlowFix' Must be enabled."; + prop.setLanguageKey("gtpp.maxRailcraftTankProcessVolume").setRequiresMcRestart(true); + maxRailcraftTankProcessVolume = prop.getInt(4000); + propOrder.add(prop.getName()); + + // Railcraft Loader Max flowrate + prop = config.get("general", "maxRailcraftFluidLoaderFlow", 20); + prop.comment = "Max Output rate for RC Fluid Loaders"; + prop.setLanguageKey("gtpp.maxRailcraftFluidLoaderFlow").setRequiresMcRestart(true); + maxRailcraftFluidLoaderFlow = prop.getInt(20); + propOrder.add(prop.getName()); + + // Railcraft Unloader Max flowrate + prop = config.get("general", "maxRailcraftFluidUnloaderFlow", 80); + prop.comment = "Max Output rate for RC Fluid Unloaders"; + prop.setLanguageKey("gtpp.maxRailcraftFluidUnloaderFlow").setRequiresMcRestart(true); + maxRailcraftFluidUnloaderFlow = prop.getInt(80); + propOrder.add(prop.getName()); + //Railcraft Dupe Fix prop = config.get("general", "enableRcItemDupeFix", true); prop.comment = "Fixes possible negative itemstacks"; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java index 7a92c3d18c..3ec4426ec1 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java @@ -9,6 +9,7 @@ import static org.objectweb.asm.Opcodes.ILOAD; import static org.objectweb.asm.Opcodes.INVOKESTATIC; import java.lang.reflect.Field; +import java.util.HashMap; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -18,7 +19,11 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; public class ClassTransformer_LWJGL_Keyboard { @@ -26,6 +31,8 @@ public class ClassTransformer_LWJGL_Keyboard { private final ClassReader reader; private final ClassWriter writer; + private static final HashMap<String, String> mBadKeyCache = new HashMap<String, String>(); + /** * Gets a key's name * @@ -40,7 +47,33 @@ public class ClassTransformer_LWJGL_Keyboard { return aTemp[key]; } } - return getKeyName()[0x00]; // Return nothing + String aCachedValue = mBadKeyCache.get("key-"+key); + if (aCachedValue == null) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Unable to map key code "+key+" to LWJGL keymap."); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Caching key value to be empty."); + //mBadKeyCache.put("key-"+key, getKeyName()[0x00]); + aCachedValue = "FIX!"; + mBadKeyCache.put("key-"+key, aCachedValue); + trySetClientKey(key); + } + return aCachedValue; // Return nothing + } + + public static void trySetClientKey(int aKey) { + if (Utils.isClient() && ReflectionUtils.doesClassExist("net.minecraft.client.Minecraft")) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Trying to set key value to be empty."); + GameSettings options = Minecraft.getMinecraft().gameSettings; + KeyBinding[] akeybinding = Minecraft.getMinecraft().gameSettings.keyBindings; + int i = akeybinding.length; + for (int j = 0; j < i; ++j) { + KeyBinding keybinding = akeybinding[j]; + if (keybinding != null && keybinding.getKeyCode() == aKey) { + options.setOptionKeyBinding(keybinding, 0); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Set keybind "+aKey+" to 0."); + break; + } + } + } } @SuppressWarnings("rawtypes") @@ -77,20 +110,27 @@ public class ClassTransformer_LWJGL_Keyboard { return new String[] {}; } - public ClassTransformer_LWJGL_Keyboard(byte[] basicClass) { + public ClassTransformer_LWJGL_Keyboard(byte[] basicClass, boolean isClientSettings) { ClassReader aTempReader = null; ClassWriter aTempWriter = null; aTempReader = new ClassReader(basicClass); - aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); - aTempReader.accept(new AddFieldAdapter(aTempWriter), 0); - injectMethod("getKeyName", aTempWriter); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + if (!isClientSettings) { + //gtPlusPlus.preloader.keyboard.BetterKeyboard.init(); + aTempReader.accept(new PatchLWJGL(aTempWriter), 0); + injectLWJGLPatch(aTempWriter); + } + else { + //gtPlusPlus.preloader.keyboard.BetterKeyboard.init(); + aTempReader.accept(new PatchClientSettings(aTempWriter), 0); + injectClientSettingPatch(aTempWriter); + } if (aTempReader != null && aTempWriter != null) { isValid = true; } else { isValid = false; } - FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, - "Valid? " + isValid + "."); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Valid? " + isValid + "."); reader = aTempReader; writer = aTempWriter; } @@ -107,37 +147,103 @@ public class ClassTransformer_LWJGL_Keyboard { return writer; } - public boolean injectMethod(String aMethodName, ClassWriter cw) { + private boolean isClientSettingsObfuscated = false; + + + public boolean injectLWJGLPatch(ClassWriter cw) { MethodVisitor mv; boolean didInject = false; FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, - "Injecting " + aMethodName + "."); - if (aMethodName.equals("getKeyName")) { - mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_SYNCHRONIZED, "getKeyName", "(I)Ljava/lang/String;", null, - null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(49, l0); - mv.visitVarInsn(ILOAD, 0); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard", - "getKeyName", "(I)Ljava/lang/String;", false); - mv.visitInsn(ARETURN); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLocalVariable("key", "I", null, l0, l1, 0); - mv.visitMaxs(1, 1); - mv.visitEnd(); - didInject = true; - } - FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, - "Method injection complete."); + "Injecting " + "getKeyName" + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_SYNCHRONIZED, "getKeyName", "(I)Ljava/lang/String;", null, + null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(49, l0); + mv.visitVarInsn(ILOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard", + "getKeyName", "(I)Ljava/lang/String;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("key", "I", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Method injection complete."); return didInject; } - public class AddFieldAdapter extends ClassVisitor { - public AddFieldAdapter(ClassVisitor cv) { + public boolean injectClientSettingPatch(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + String aMethodName = this.isClientSettingsObfuscated ? "func_74298_c" : "getKeyDisplayString"; + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, aMethodName, "(I)Ljava/lang/String;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(130, l0); + mv.visitVarInsn(ILOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/keyboard/BetterKeyboard", "getKeyDisplayString", "(I)Ljava/lang/String;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("p_74298_0_", "I", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public class PatchClientSettings extends ClassVisitor { + + public PatchClientSettings(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + private final String[] aMethodsToStrip = new String[] { "func_74298_c", "getKeyDisplayString" }; + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + boolean found = false; + + for (String s : aMethodsToStrip) { + if (name.equals(s)) { + if (name.equals(aMethodsToStrip[0])) { + isClientSettingsObfuscated = true; + } + else { + isClientSettingsObfuscated = false; + } + found = true; + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } else { + methodVisitor = null; + } + if (found) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Found method " + name + ", removing."); + } + return methodVisitor; + } + + } + + public class PatchLWJGL extends ClassVisitor { + + public PatchLWJGL(ClassVisitor cv) { super(ASM5, cv); this.cv = cv; } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidCartHandling.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidCartHandling.java new file mode 100644 index 0000000000..bf71582ae7 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidCartHandling.java @@ -0,0 +1,117 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.ACC_FINAL; +import static org.objectweb.asm.Opcodes.ACC_PRIVATE; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.ASM5; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.asm.AsmConfig; + +public class ClassTransformer_Railcraft_FluidCartHandling { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + //mods.railcraft.common.blocks.machine.gamma.TileFluidLoader + //mods.railcraft.common.blocks.machine.gamma.TileFluidLoader.TRANSFER_RATE + + //mods.railcraft.common.blocks.machine.gamma.TileFluidUnloader + //mods.railcraft.common.blocks.machine.gamma.TileFluidUnloader.TRANSFER_RATE + + public static final int TileFluidLoader_RATE = 20; + public static final int TileFluidUnloader_RATE = 80; + + private static final int TYPE_LOADER = 0; + private static final int TYPE_UNLOADER = 1; + + public ClassTransformer_Railcraft_FluidCartHandling(byte[] basicClass, boolean obfuscated, String aClassName) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + boolean aLoader = aClassName.equals("mods.railcraft.common.blocks.machine.gamma.TileFluidLoader"); + + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Attempting to patch field TRANSFER_RATE in "+aClassName+", default value is "+(aLoader ? 20 : 80)); + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + if (aLoader) { + aTempReader.accept(new AddFieldAdapter(aTempWriter), 0); + addField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "TRANSFER_RATE", aTempWriter, TYPE_LOADER); + } + else { + aTempReader.accept(new AddFieldAdapter(aTempWriter), 0); + addField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "TRANSFER_RATE", aTempWriter, TYPE_UNLOADER); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Valid? "+isValid+"."); + } + else { + isValid = false; + } + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean addField(int access, String fieldName, ClassWriter cv, int aType) { + int aValue = (aType == TYPE_LOADER ? AsmConfig.maxRailcraftFluidLoaderFlow : AsmConfig.maxRailcraftFluidUnloaderFlow); + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Injecting " + fieldName + " with new value: "+aValue); + FieldVisitor fv = cv.visitField(access, fieldName, "I", null, new Integer(aValue)); + if (fv != null) { + fv.visitEnd(); + return true; + } + return false; + } + + + + + public class AddFieldAdapter extends ClassVisitor { + + public AddFieldAdapter(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public FieldVisitor visitField( + int access, String name, String desc, String signature, Object value) { + if (name.equals("TRANSFER_RATE") && desc.equals("I")) { + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Removing "+"TRANSFER_RATE"+"."); + return null; + } + else { + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Found Field "+name+" | "+desc); + } + return cv.visitField(access, name, desc, signature, value); + } + + } + + + + + + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java index d1e2f1acb3..1249df0777 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java @@ -13,6 +13,7 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraft.inventory.IInventory; public class ClassTransformer_Railcraft_FluidHelper { @@ -21,13 +22,16 @@ public class ClassTransformer_Railcraft_FluidHelper { private final ClassReader reader; private final ClassWriter writer; - public static final int PROCESS_VOLUME = 16000; + public static int PROCESS_VOLUME; public ClassTransformer_Railcraft_FluidHelper(byte[] basicClass, boolean obfuscated2) { + + PROCESS_VOLUME = AsmConfig.maxRailcraftTankProcessVolume; + ClassReader aTempReader = null; ClassWriter aTempWriter = null; - FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Attempting to patch field PROCESS_VOLUME in mods.railcraft.common.fluids.FluidHelper"); + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Attempting to patch field PROCESS_VOLUME in mods.railcraft.common.fluids.FluidHelper with new value: "+PROCESS_VOLUME); boolean obfuscated = false; boolean a1 = false; @@ -99,7 +103,7 @@ public class ClassTransformer_Railcraft_FluidHelper { "[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Injecting " + fieldName + " with new value."); - FieldVisitor fv = cv.visitField(access, fieldName, "I", null, 16000); + FieldVisitor fv = cv.visitField(access, fieldName, "I", null, PROCESS_VOLUME); if (fv != null) { fv.visitEnd(); return true; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index d8dc71dff0..d378883665 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -84,9 +84,13 @@ public class Preloader_Transformer_Handler implements IClassTransformer { boolean probablyShouldBeFalse = false; // Fix LWJGL index array out of bounds on keybinding IDs - if (transformedName.equals("org.lwjgl.input.Keyboard") && mConfig.enabledLwjglKeybindingFix) { + if ((transformedName.equals("org.lwjgl.input.Keyboard") || transformedName.equals("bbj") || transformedName.equals("net.minecraft.client.settings.GameSettings")) && mConfig.enabledLwjglKeybindingFix) { + boolean isClientSettingsClass = false; + if (!transformedName.equals("org.lwjgl.input.Keyboard")) { + isClientSettingsClass = true; + } FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_LWJGL_Keyboard(basicClass).getWriter().toByteArray(); + return new ClassTransformer_LWJGL_Keyboard(basicClass, isClientSettingsClass).getWriter().toByteArray(); } //Enable mapping of Tickets and loaded chunks. - Forge @@ -115,11 +119,16 @@ public class Preloader_Transformer_Handler implements IClassTransformer { } //Fix RC stuff - //Patching PROCESS_VOLUME to allow 4x more transfer limits - if (transformedName.equals("mods.railcraft.common.fluids.FluidHelper") && mConfig.enableRcFlowFix) { + //Patching PROCESS_VOLUME to allow more transfer limits + if (transformedName.equals("mods.railcraft.common.fluids.FluidHelper") && (mConfig.enableRcFlowFix && mConfig.maxRailcraftTankProcessVolume != 4000)) { FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Transforming %s", transformedName); return new ClassTransformer_Railcraft_FluidHelper(basicClass, obfuscated).getWriter().toByteArray(); - } + } + //Patching TRANSFER_RATE in Fluid Loaders/Unloaders + if ((transformedName.equals("mods.railcraft.common.blocks.machine.gamma.TileFluidLoader") && mConfig.maxRailcraftFluidLoaderFlow != 20) || (transformedName.equals("mods.railcraft.common.blocks.machine.gamma.TileFluidUnloader") && mConfig.maxRailcraftFluidUnloaderFlow != 80)) { + FMLRelaunchLog.log("[GT++ ASM] Railcraft TRANSFER_RATE Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_Railcraft_FluidCartHandling(basicClass, obfuscated, transformedName).getWriter().toByteArray(); + } //Fix Weird glitch involving negative itemstacks. if (transformedName.equals("mods.railcraft.common.util.inventory.InvTools") && mConfig.enableRcItemDupeFix) { FMLRelaunchLog.log("[GT++ ASM] Railcraft negative ItemStack Fix", Level.INFO, "Transforming %s", transformedName); diff --git a/src/Java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java b/src/Java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java new file mode 100644 index 0000000000..e25c06653c --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/keyboard/BetterKeyboard.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package gtPlusPlus.preloader.keyboard; + +import java.lang.reflect.Field; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.Level; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.asm.transformers.ClassTransformer_LWJGL_Keyboard; +import net.minecraft.client.resources.I18n; + +/** + * <br> + * A raw Keyboard interface. This can be used to poll the current state of the + * keys, or read all the keyboard presses / releases since the last read. + * + * @author cix_foo <cix_foo@users.sourceforge.net> + * @author elias_naur <elias_naur@users.sourceforge.net> + * @author Brian Matzon <brian@matzon.dk> + * @version $Revision$ + * $Id$ + */ +public class BetterKeyboard { + + public static final int KEYBOARD_SIZE = Short.MAX_VALUE; + + private static boolean init = false; + + public static void init() { + if (!init) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Trying to patch out LWJGL internal arrays with larger ones."); + Field aKeyNameSize = ReflectionUtils.getField(Keyboard.class, "keyName"); + Field aKeyMapSize = ReflectionUtils.getField(Keyboard.class, "keyMap"); + Field aKeyDownBuffer = ReflectionUtils.getField(Keyboard.class, "keyDownBuffer"); + String[] aOldKeyNameArray = (String[]) ReflectionUtils.getFieldValue(aKeyNameSize); + if (aOldKeyNameArray != null && aOldKeyNameArray.length < Short.MAX_VALUE) { + String[] aNewKeyNameArray = new String[Short.MAX_VALUE]; + for (int i=0;i<aOldKeyNameArray.length;i++) { + aNewKeyNameArray[i] = aOldKeyNameArray[i]; + } + try { + ReflectionUtils.setFinalFieldValue(Keyboard.class, aKeyNameSize.getName(), aNewKeyNameArray); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Patched Field: "+aKeyNameSize.getName()); + } + catch (Throwable t) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Failed Patching Field: "+aKeyDownBuffer.getName()); + } + } + Map<String, Integer> aOldKeyMapArray = (Map<String, Integer>) ReflectionUtils.getFieldValue(aKeyMapSize); + if (aOldKeyNameArray != null && aOldKeyMapArray.size() < Short.MAX_VALUE) { + Map<String, Integer> aNewKeyMapArray = new HashMap<String, Integer>(Short.MAX_VALUE); + aNewKeyMapArray.putAll(aOldKeyMapArray); + try { + ReflectionUtils.setFinalFieldValue(Keyboard.class, aKeyMapSize.getName(), aNewKeyMapArray); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Patched Field: "+aKeyMapSize.getName()); + } + catch (Throwable t) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Failed Patching Field: "+aKeyDownBuffer.getName()); + } + } + ByteBuffer aOldByteBuffer = (ByteBuffer) ReflectionUtils.getFieldValue(aKeyDownBuffer); + if (aOldByteBuffer != null && aOldByteBuffer.capacity() == Keyboard.KEYBOARD_SIZE) { + ByteBuffer aNewByteBuffer = BufferUtils.createByteBuffer(Short.MAX_VALUE); + try { + ReflectionUtils.setFinalFieldValue(Keyboard.class, aKeyDownBuffer.getName(), aNewByteBuffer); + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Patched Field: "+aKeyDownBuffer.getName()); + } + catch (Throwable t) { + FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Failed Patching Field: "+aKeyDownBuffer.getName()); + } + } + init = true; + } + } + + + /** + * Gets a key's name + * @param key The key + * @return a String with the key's human readable name in it or null if the key is unnamed + */ + public static synchronized String getKeyName(int key) { + return ClassTransformer_LWJGL_Keyboard.getKeyName(key); + } + + + + + /** + * Represents a key or mouse button as a string. Args: key + */ + public static String getKeyDisplayString(int aKeyValue) { + return aKeyValue < 0 ? I18n.format("key.mouseButton", new Object[] {Integer.valueOf(aKeyValue + 101)}): getKeyName(aKeyValue); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 74e269e932..2891741b2c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -258,31 +258,31 @@ public class StaticFields59 { public static int getHeatingCapacityForCoilTier(int aCoilTier) { int mHeatingCapacity = 0; switch (aCoilTier) { - case 1: + case 0: mHeatingCapacity = 1800; break; - case 2: + case 1: mHeatingCapacity = 2700; break; - case 3: + case 2: mHeatingCapacity = 3600; break; - case 4: + case 3: mHeatingCapacity = 4500; break; - case 5: + case 4: mHeatingCapacity = 5400; break; - case 6: + case 5: mHeatingCapacity = 7200; break; - case 7: + case 6: mHeatingCapacity = 9000; break; - case 8: + case 7: mHeatingCapacity = 9900; break; - case 9: + case 8: mHeatingCapacity = 10800; break; default: diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java index 0c7067b3c0..358a8eec66 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java @@ -121,15 +121,16 @@ extends GregtechMeta_MultiBlockBase { if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); } - } + } ItemStack[] inputs = new ItemStack[tBusItems.size()]; int slot = 0; for (ItemStack g : tBusItems) { inputs[slot++] = g; } if (inputs.length > 0) { - log("Recipe. ["+inputs.length+"]["+getMaxParallelRecipes()+"]"); - if (checkRecipeGeneric(inputs, (FluidStack[]) ArrayUtils.getArrayFromArrayList(this.getStoredFluids()), getMaxParallelRecipes(), getEuDiscountForParallelism(), 250, 10000)) { + log("Recipe. ["+inputs.length+"]["+getMaxParallelRecipes()+"]"); + FluidStack[] fluid = this.getStoredFluids().toArray(new FluidStack[] {}); + if (checkRecipeGeneric(inputs,fluid , getMaxParallelRecipes(), getEuDiscountForParallelism(), 250, 10000)) { log("Recipe 2."); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index 05aec14500..caf694669c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -330,9 +330,10 @@ extends GregtechMeta_MultiBlockBase { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - - GT_Recipe tRecipe = this.getRecipeMap(tCircuit).findRecipe( + GT_Recipe.GT_Recipe_Map tRecipeMap = this.getRecipeMap(tCircuit); + if (tRecipeMap == null) + return false; + GT_Recipe tRecipe = tRecipeMap.findRecipe( getBaseMetaTileEntity(), this.mLastRecipeExtended[tCircuitID], false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 9754eebbb8..b8e6d0c252 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -197,6 +197,7 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { return false; } // mInventoryCrafter = new CraftingHelper(this); + setTier(); return tAmount >= 10; } @@ -225,7 +226,7 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { } catch (IllegalArgumentException | IllegalAccessException e) { } } - else if (this.mMachineMode == MODE.DISASSEMBLY) { + else if (this.mMachineMode == MODE.DISASSEMBLY || this.mMachineMode == MODE.CRAFTING) { return null; } return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; @@ -285,6 +286,11 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { // } // } + private void setTier() { + long tVoltage = getMaxInputVoltage(); + this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + } + @Override public boolean checkRecipe(final ItemStack aStack) { if (mMachineMode == MODE.DISASSEMBLY) { @@ -296,7 +302,6 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { //Logger.MACHINE_INFO("1"); for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - tBus.mRecipeMap = getRecipeMap(); //Logger.MACHINE_INFO("2"); if (isValidMetaTileEntity(tBus)) { //Logger.MACHINE_INFO("3"); @@ -380,6 +385,10 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { if (this.mTier > 5) { this.mMaxProgresstime >>= this.mTier - 5; } + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; inputItem.stackSize--; if (inputItem.stackSize <= 0) { tInputs[0] = null; @@ -508,6 +517,10 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { if (this.mTier > 5) { this.mMaxProgresstime >>= this.mTier - 5; } + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; if (mCorrectInputs == 9) { ItemStack mOutputItem = storedData_Output[0]; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 9b898e34af..3eabcf517e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -267,7 +267,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe mAllDynamoHatches.addAll(this.mDynamoHatches); if (LoadedMods.TecTech) { - mAllDynamoHatches.addAll(this.mTecTechEnergyHatches); + mAllEnergyHatches.addAll(this.mTecTechEnergyHatches); mAllDynamoHatches.addAll(this.mTecTechDynamoHatches); } diff --git a/src/Java/speiger/src/crops/api/ICropCardInfo.java b/src/Java/speiger/src/crops/api/ICropCardInfo.java deleted file mode 100644 index ff67eb06b1..0000000000 --- a/src/Java/speiger/src/crops/api/ICropCardInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package speiger.src.crops.api; - -import java.util.List; -import net.minecraft.item.ItemStack; - -public interface ICropCardInfo { - - List<String> getCropInformation(); - - ItemStack getDisplayItem(); - -}
\ No newline at end of file |