From 6f9717541eae5088cb33db5387c99f67781709ea Mon Sep 17 00:00:00 2001 From: Lain MultipleInstances Date: Tue, 3 Nov 2020 14:39:18 +0800 Subject: [PATCH] update to 1.16.4 remove windows scripts switch to IDEA reformat all update .gitignore --- .gitignore | 5 +- build.gradle | 20 +- gradlew | 202 +++++++++--------- scripts/build.bat | 3 - scripts/cmd.bat | 3 - scripts/setupEclipse.bat | 3 - .../java/lain/mods/cleanview/CleanView.java | 9 +- src/main/java/lain/mods/cleanview/Proxy.java | 58 ++--- 8 files changed, 138 insertions(+), 165 deletions(-) delete mode 100644 scripts/build.bat delete mode 100644 scripts/cmd.bat delete mode 100644 scripts/setupEclipse.bat diff --git a/.gitignore b/.gitignore index 501b138..1fa8894 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ /.gradle/ /gradle.properties /build/ -/*.launch \ No newline at end of file +/*.launch +/.idea/ +/*.iml +/logs/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1eb8e24..429a837 100644 --- a/build.gradle +++ b/build.gradle @@ -13,18 +13,18 @@ apply plugin: 'eclipse' import net.minecraftforge.gradle.common.task.SignJar -version = "1.16.3-v1" -group= "lain.mods.cleanview" +version = "1.16.4-v1" +group = "lain.mods.cleanview" archivesBaseName = "CleanView" sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - mappings channel: 'snapshot', version: '20200514-1.16' + mappings channel: 'snapshot', version: '20201028-1.16.3' } dependencies { - minecraft 'net.minecraftforge:forge:1.16.3-34.0.1' + minecraft 'net.minecraftforge:forge:1.16.4-35.0.1' } processResources { @@ -33,12 +33,12 @@ processResources { jar { manifest { - attributes(["Specification-Title": "CleanView", - "Specification-Vendor": "zlainsama", - "Specification-Version": "1", - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"zlainsama", + attributes(["Specification-Title" : "CleanView", + "Specification-Vendor" : "zlainsama", + "Specification-Version" : "1", + "Implementation-Title" : project.name, + "Implementation-Version" : "${version}", + "Implementation-Vendor" : "zlainsama", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],) } } diff --git a/gradlew b/gradlew index cccdd3d..9a27a6c 100644 --- a/gradlew +++ b/gradlew @@ -10,22 +10,22 @@ # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +while [ -h "$PRG" ]; do + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' >/dev/null; then + PRG="$link" + else + PRG=$(dirname "$PRG")"/$link" + fi done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" +SAVED="$(pwd)" +cd "$(dirname \"$PRG\")/" >/dev/null +APP_HOME="$(pwd -P)" cd "$SAVED" >/dev/null APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=$(basename "$0") # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" @@ -33,15 +33,15 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn () { - echo "$*" +warn() { + echo "$*" } -die () { - echo - echo "$*" - echo - exit 1 +die() { + echo + echo "$*" + echo + exit 1 } # OS specific support (must be 'true' or 'false'). @@ -49,115 +49,115 @@ cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$(uname)" in +CYGWIN*) + cygwin=true + ;; +Darwin*) + darwin=true + ;; +MINGW*) + msys=true + ;; +NONSTOP*) + nonstop=true + ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME +if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ]; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." - fi + fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then + MAX_FD_LIMIT=$(ulimit -H -n) + if [ $? -eq 0 ]; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then + MAX_FD="$MAX_FD_LIMIT" fi + ulimit -n $MAX_FD + if [ $? -ne 0 ]; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" +if $cygwin; then + APP_HOME=$(cygpath --path --mixed "$APP_HOME") + CLASSPATH=$(cygpath --path --mixed "$CLASSPATH") + JAVACMD=$(cygpath --unix "$JAVACMD") + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null) + SEP="" + for dir in $ROOTDIRSRAW; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ]; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@"; do + CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -) + CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition + eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg") + else + eval $(echo args$i)="\"$arg\"" fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac + i=$((i + 1)) + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac fi # Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " +save() { + for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done + echo " " } APP_ARGS=$(save "$@") diff --git a/scripts/build.bat b/scripts/build.bat deleted file mode 100644 index 529c87f..0000000 --- a/scripts/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -cd .. -start gradlew build \ No newline at end of file diff --git a/scripts/cmd.bat b/scripts/cmd.bat deleted file mode 100644 index 0a75632..0000000 --- a/scripts/cmd.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -cd .. -start cmd \ No newline at end of file diff --git a/scripts/setupEclipse.bat b/scripts/setupEclipse.bat deleted file mode 100644 index 8e85884..0000000 --- a/scripts/setupEclipse.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -cd .. -start gradlew eclipse \ No newline at end of file diff --git a/src/main/java/lain/mods/cleanview/CleanView.java b/src/main/java/lain/mods/cleanview/CleanView.java index 2caf597..d6377e3 100644 --- a/src/main/java/lain/mods/cleanview/CleanView.java +++ b/src/main/java/lain/mods/cleanview/CleanView.java @@ -5,16 +5,13 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("cleanview") -public class CleanView -{ +public class CleanView { - public CleanView() - { + public CleanView() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupClient); } - private void setupClient(FMLClientSetupEvent event) - { + private void setupClient(FMLClientSetupEvent event) { Proxy.INSTANCE.init(); } diff --git a/src/main/java/lain/mods/cleanview/Proxy.java b/src/main/java/lain/mods/cleanview/Proxy.java index e075ac1..d07dfd7 100644 --- a/src/main/java/lain/mods/cleanview/Proxy.java +++ b/src/main/java/lain/mods/cleanview/Proxy.java @@ -1,8 +1,5 @@ package lain.mods.cleanview; -import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.util.Collection; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.util.InputMappings; @@ -15,25 +12,24 @@ import net.minecraftforge.event.TickEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; -enum Proxy -{ +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.util.Collection; + +enum Proxy { INSTANCE; KeyBinding keyToggle = new KeyBinding("key.togglecleanview", InputMappings.INPUT_INVALID.getKeyCode(), "key.categories.misc"); boolean lastState = false; + boolean enabled = true; DataParameter potionEffects = null; WeakReference lastCam = new WeakReference<>(null); - boolean enabled = true; - - void handleClientTickEvent(TickEvent.ClientTickEvent event) - { - if (event.phase == TickEvent.Phase.START) - { + void handleClientTickEvent(TickEvent.ClientTickEvent event) { + if (event.phase == TickEvent.Phase.START) { boolean state = keyToggle.isKeyDown(); - if (state != lastState) - { + if (state != lastState) { if (state) // onPressed enabled = !enabled; lastState = state; @@ -45,10 +41,8 @@ void handleClientTickEvent(TickEvent.ClientTickEvent event) if (!enabled) ent = null; - if (prevEnt != ent) - { - if (prevEnt instanceof LivingEntity) - { + if (prevEnt != ent) { + if (prevEnt instanceof LivingEntity) { Collection effects = ((LivingEntity) prevEnt).getActivePotionEffects(); if (!effects.isEmpty()) prevEnt.getDataManager().set(potionEffects, PotionUtils.getPotionColorFromEffectList(effects)); @@ -61,8 +55,7 @@ void handleClientTickEvent(TickEvent.ClientTickEvent event) } } - void init() - { + void init() { setup(); ClientRegistry.registerKeyBinding(keyToggle); @@ -70,37 +63,26 @@ void init() } @SuppressWarnings("unchecked") - void setup() - { + void setup() { Throwable t = null; Field f; - try - { + try { f = LivingEntity.class.getDeclaredField("field_184633_f"); - } - catch (Throwable t1) - { + } catch (Throwable t1) { t = t1; - try - { + try { f = LivingEntity.class.getDeclaredField("POTION_EFFECTS"); - } - catch (Throwable t2) - { + } catch (Throwable t2) { t.addSuppressed(t2); f = null; } } - try - { - if (f != null) - { + try { + if (f != null) { f.setAccessible(true); potionEffects = (DataParameter) f.get(null); } - } - catch (Throwable t3) - { + } catch (Throwable t3) { if (t == null) t = t3; else