diff options
| author | korneel vandamme <krampus.sack.never@gmail.com> | 2020-02-20 17:15:57 +0100 |
|---|---|---|
| committer | korneel vandamme <krampus.sack.never@gmail.com> | 2020-02-20 17:15:57 +0100 |
| commit | 52cec59a102e3b18f8cca75e98c2d797bac4d19f (patch) | |
| tree | ef4c05612b350e3aec1632fff29da76a07eb7724 | |
| parent | eae5727a0419fec865acddb7374af677f8b83306 (diff) | |
| parent | 63d8ed92dc34e62f0b7a5338fd7126e0e6fa01aa (diff) | |
| download | GT5-Unofficial-52cec59a102e3b18f8cca75e98c2d797bac4d19f.tar.gz GT5-Unofficial-52cec59a102e3b18f8cca75e98c2d797bac4d19f.tar.bz2 GT5-Unofficial-52cec59a102e3b18f8cca75e98c2d797bac4d19f.zip | |
Merge branch 'master' of https://botn365@bitbucket.org/draknyte1/gtpp-development.git
21 files changed, 797 insertions, 166 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 7bfee9a42d..a70e1368c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,11 @@ jobs: JVM_OPTS: -Xms2048m Xmx4000m - steps: + steps: + - add_ssh_keys: + fingerprints: + - "17:37:c7:07:d3:2b:a9:b8:b8:8f:e8:d5:23:fd:9a:4c" + - checkout - run: @@ -47,11 +51,11 @@ jobs: - run: name: Run Master Script - command: sh Build_1_Master.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" + command: sh Build_1_Master.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://bitbucket.org/draknyte1/gtpp-development/get/cb20041176eb.zip" - run: name: Run Build Script - command: sh RunScript.sh + command: sh RunScript.sh "17:37:c7:07:d3:2b:a9:b8:b8:8f:e8:d5:23:fd:9a:4c" - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ path: build/libs @@ -1,5 +1,11 @@ # Welcome to the GT++ Github! +## Patreon +[Become a humble Patron!](https://www.patreon.com/bePatron?u=9530372) <-- Clicky clicky +There's cookies, capes and sometimes even cakes! +Monthly goals will permit a community vote, which dictates new content additions. +Funds raised are distributed between all active developers. (Currently Alkalus & Bot) + ## Current Build Status ### CircleCI - [](https://circleci.com/gh/alkcorp/GTplusplus/tree/master) Click the Green Passed/Red Failed button for the latest BETA builds! @@ -26,3 +32,6 @@ Distribution of the software in any form is only allowed with explicit, prior pe ## Derivative Works These modifications are provided freely and may be decompiled and modified for private use, either with a decompiler or a bytecode editor. Public use of modified or derivative versions is prohibited unless you are given specific written permission. Distribution of the source code, modified (including custom compilation) or otherwise, is prohibited by anyone except the author, except in the case of a derivative mod that has been given prior approval. Creating derivative works for commercial use is expressly forbidden and the owner reserves full right to seek damages. + +## Re-use of code +Feel free to poke about and try learn what you can from the work we've done here. I would prefer that it wasn't stolen, but if ever in doubt, please just ask Alkalus on Discord. If not for open source mods, this mod itself simply would not exist. It would probably be rare where anything would be directly copy/pasted, but please do give credit where due. Thanks & happy modding! diff --git a/bitbucket-pipelines.yml.disabled b/bitbucket-pipelines.yml.disabled new file mode 100644 index 0000000000..0009fd8ee4 --- /dev/null +++ b/bitbucket-pipelines.yml.disabled @@ -0,0 +1,19 @@ +# This is a sample build configuration for Java (Gradle). +# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples. +# Only use spaces to indent your .yml configuration. +# ----- +# You can specify a custom docker image from Docker Hub as your build environment. +image: openjdk:8 + +pipelines: + default: + - step: + caches: + - gradle + script: # Modify the commands below to build your repository. + # You must commit the Gradle wrapper to your repository + # https://docs.gradle.org/current/userguide/gradle_wrapper.html + - bash ./gradlew build + artifacts: # defining the artifacts to be kept. + - build/libs/*.jar + - build/libs/proguard.map
\ No newline at end of file diff --git a/build.gradle b/build.gradle index d15918d63e..ab5fec70de 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,8 @@ buildscript { } dependencies { classpath "net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT" - classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.55" + classpath 'net.sf.proguard:proguard-gradle:6.2.2' + //classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.55" } } @@ -62,7 +63,7 @@ file "version.properties" withReader { ext.config2 = new ConfigSlurper().parse prop } -apply plugin: 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' +//apply plugin: 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version = "${config.gtpp.version}.${config2.mod.version}" group= "gtPlusPlus" @@ -171,51 +172,48 @@ jar { } } -task sourceJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' - manifest { - attributes 'FMLCorePlugin': 'gtPlusPlus.preloader.asm.Preloader_FMLLoadingPlugin' - attributes 'FMLCorePluginContainsFMLMod': 'true' - } -} - -task devJar(type: Jar) { - from sourceSets.main.output - classifier = 'dev' - manifest { - attributes 'FMLCorePlugin': 'gtPlusPlus.preloader.asm.Preloader_FMLLoadingPlugin' - attributes 'FMLCorePluginContainsFMLMod': 'true' - } -} - -task discordChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { - file = new File("build/changelog/Basic ${project.version}.txt"); - untaggedName = "Current Basic release ${project.version}" - fromCommit = "${config.commit.hash}" - toRef = "HEAD" - templateContent = file('changeloggeneral.mustache').getText('UTF-8') -} -task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { - file = new File("build/changelog/${project.version}.md"); - untaggedName = "Current release ${project.version}" - fromCommit = "${config.commit.hash}" - toRef = "HEAD" - templateContent = file('changelog.mustache').getText('UTF-8') -} -task curseChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { - file = new File("build/changelog/Curse ${project.version}.md"); - untaggedName = "Current Curse release ${project.version}" - fromCommit = "${config.commit.hash}" - toRef = "HEAD" - templateContent = file('changelogcurse.mustache').getText('UTF-8') -} - -artifacts { - archives devJar - archives sourceJar -} - -build.finalizedBy(gitChangelogTask) -build.finalizedBy(curseChangelogTask) -build.finalizedBy(discordChangelogTask)
\ No newline at end of file +task generateDictionaries(type: JavaExec) { + group = "Execution" + description = "Generates the dictionaries for Proguard" + classpath = sourceSets.main.runtimeClasspath + main = "gtPlusPlus.GenerateDictionaries" +} + +// Define a ProGuard task. +task proguard(type: proguard.gradle.ProGuardTask) { + configuration 'proguard.txt' + injars "build/libs/"+archivesBaseName + "-" + version + ".jar" + outjars "build/libs/"+archivesBaseName + "-" + version + "-obf.jar" +} + +//task discordChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { + //file = new File("build/changelog/Basic ${project.version}.txt"); + //untaggedName = "Current Basic release ${project.version}" + //fromCommit = "${config.commit.hash}" + //toRef = "HEAD" + //templateContent = file('changeloggeneral.mustache').getText('UTF-8') +//} +//task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { + //file = new File("build/changelog/${project.version}.md"); + //untaggedName = "Current release ${project.version}" + //fromCommit = "${config.commit.hash}" + //toRef = "HEAD" + //templateContent = file('changelog.mustache').getText('UTF-8') +//} +//task curseChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { + //file = new File("build/changelog/Curse ${project.version}.md"); + //untaggedName = "Current Curse release ${project.version}" + //fromCommit = "${config.commit.hash}" + //toRef = "HEAD" + //templateContent = file('changelogcurse.mustache').getText('UTF-8') +//} + +// Generate Dicts for Proguard obfuscation +build.finalizedBy(generateDictionaries) + +// Obfuscate this bitch. +//build.finalizedBy(proguard) // Disabled until optimization is working 100% + +//build.finalizedBy(gitChangelogTask) +//build.finalizedBy(curseChangelogTask) +//build.finalizedBy(discordChangelogTask)
\ No newline at end of file diff --git a/build.properties b/build.properties index 5c691ec259..1ecc02e148 100644 --- a/build.properties +++ b/build.properties @@ -2,6 +2,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 ic2.version=2.2.790-experimental gt.version=5.09.31 -gtpp.version=1.7.04 +gtpp.version=1.7.05 commit.hash=aa9f04218e5298414f900b9fe61131f7ed26b8f1
\ No newline at end of file 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, |
