├── .github └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── ct │ ├── ContainerTweaksPlugin.java │ └── module │ └── ContainerTweaks.java └── resources └── rusherhack-plugin.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Plugin Build 2 | 3 | on: 4 | pull_request: 5 | push: 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Check out repository 12 | uses: actions/checkout@v4 13 | with: 14 | persist-credentials: false 15 | 16 | - name: Setup JDK 17 | uses: actions/setup-java@v4 18 | with: 19 | java-version: '17' 20 | distribution: 'temurin' 21 | 22 | - name: Elevate wrapper permissions 23 | run: chmod +x ./gradlew 24 | 25 | - name: Setup Gradle 26 | uses: gradle/actions/setup-gradle@v4 27 | with: 28 | dependency-graph: generate-and-submit 29 | 30 | - name: Build Plugin 31 | run: ./gradlew build 32 | 33 | - name: Get Version 34 | run: echo "PLUGIN_VERSION=$(./gradlew -q getPluginVersion)" >> $GITHUB_ENV 35 | 36 | - name: Upload Artifact 37 | uses: actions/upload-artifact@v4 38 | with: 39 | name: ContainerTweaks-${{ env.PLUGIN_VERSION }} 40 | path: build/libs/*.jar 41 | if-no-files-found: error 42 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Plugin Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[0-9]+.[0-9]+' 7 | workflow_dispatch: 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Check out repository 14 | uses: actions/checkout@v4 15 | with: 16 | persist-credentials: false 17 | 18 | - name: Setup JDK 19 | uses: actions/setup-java@v4 20 | with: 21 | java-version: '17' 22 | distribution: 'temurin' 23 | 24 | - name: Elevate wrapper permissions 25 | run: chmod +x ./gradlew 26 | 27 | - name: Setup Gradle 28 | uses: gradle/actions/setup-gradle@v4 29 | with: 30 | dependency-graph: generate-and-submit 31 | 32 | - name: Build Plugin 33 | run: ./gradlew build 34 | 35 | - name: Get Version 36 | run: echo "PLUGIN_VERSION=$(./gradlew -q getPluginVersion)" >> $GITHUB_ENV 37 | 38 | - name: Upload Artifact 39 | uses: actions/upload-artifact@v4 40 | with: 41 | name: ContainerTweaks-${{ env.PLUGIN_VERSION }} 42 | path: build/libs/*.jar 43 | if-no-files-found: error 44 | 45 | - name: Github Release 46 | uses: ncipollo/release-action@v1 47 | with: 48 | tag: ${{ env.PLUGIN_VERSION }} 49 | commit: mainline 50 | artifacts: "build/libs/ContainerTweaks-*.jar" 51 | allowUpdates: true 52 | makeLatest: true 53 | omitBodyDuringUpdate: true 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | # mpeltonen/sbt-idea plugin 11 | .idea_modules/ 12 | 13 | # JIRA plugin 14 | atlassian-ide-plugin.xml 15 | 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # BlueJ files 23 | *.ctxt 24 | 25 | # Package Files # 26 | *.jar 27 | *.war 28 | *.nar 29 | *.ear 30 | *.zip 31 | *.tar.gz 32 | *.rar 33 | 34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 35 | hs_err_pid* 36 | 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | # General 52 | .DS_Store 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # Windows thumbnail cache files 79 | Thumbs.db 80 | Thumbs.db:encryptable 81 | ehthumbs.db 82 | ehthumbs_vista.db 83 | 84 | # Dump file 85 | *.stackdump 86 | 87 | # Folder config file 88 | [Dd]esktop.ini 89 | 90 | # Recycle Bin used on file shares 91 | $RECYCLE.BIN/ 92 | 93 | # Windows Installer files 94 | *.cab 95 | *.msi 96 | *.msix 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | 103 | .gradle 104 | build/ 105 | 106 | # Ignore Gradle GUI config 107 | gradle-app.setting 108 | 109 | # Cache of project 110 | .gradletasknamecache 111 | 112 | **/build/ 113 | 114 | # Common working directory 115 | run/ 116 | 117 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 118 | !gradle-wrapper.jar 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 rfresh2 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ContainerTweaks Rusherhack Plugin 2 | 3 | Simple tweaks for quickly moving items in containers. 4 | 5 | A couple of these are inspired by [MouseTweaks](https://github.com/YaLTeR/MouseTweaks) 6 | 7 | ## Installation 8 | 9 | Download the latest release [here](https://github.com/rfresh2/ContainerTweaks-rusherhack/releases) 10 | 11 | Place the jar into your `.minecraft/rusherhack/plugins` folder 12 | 13 | ## Usage 14 | 15 | Enable the ContainerTweaks module in the Misc category 16 | 17 | ### Settings 18 | 19 | * `QuickMove` - Click an item to move all of that item to the opposite container. Works with or without an item already held in the cursor. 20 | * `HoldKey` - Keybind you must hold while clicking 21 | * `MoveAll` - Moves all items in the container regardless of type 22 | * `OnlyShulkers` - Only moves shulker boxes 23 | * `DragMove` - Click and drag across container or inventory items to move them to the opposite container 24 | * `HoldKey` - Keybind you must hold while dragging 25 | * `DragPickup` - Hold and drag with an item in your cursor to pickup stacks of that item into your cursor 26 | 27 | 28 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '1.9-SNAPSHOT' 3 | id 'maven-publish' 4 | } 5 | 6 | version = project.mod_version 7 | group = project.maven_group 8 | 9 | configurations { 10 | rusherhackApi 11 | rusherhackApi.canBeResolved(true) 12 | compileOnly.extendsFrom(rusherhackApi) 13 | productionRuntime { 14 | extendsFrom configurations.minecraftLibraries 15 | extendsFrom configurations.loaderLibraries 16 | extendsFrom configurations.minecraftRuntimeLibraries 17 | } 18 | } 19 | 20 | repositories { 21 | // Add repositories to retrieve artifacts from in here. 22 | // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. 23 | // See https://docs.gradle.org/current/userguide/declaring_repositories.html 24 | // for more information about repositories. 25 | 26 | maven { 27 | name = "rusherhack" 28 | //releases repository will have the latest api version for last stable rusherhack release 29 | //snapshots will always be the latest api version 30 | //url = "https://maven.rusherhack.org/releases" 31 | url = "https://maven.rusherhack.org/snapshots" 32 | } 33 | 34 | maven { 35 | name = 'ParchmentMC' 36 | url = 'https://maven.parchmentmc.org' 37 | } 38 | } 39 | 40 | dependencies { 41 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 42 | productionRuntime(modImplementation("net.fabricmc:fabric-loader:0.16.7")) 43 | productionRuntime("net.fabricmc:intermediary:1.20.4") 44 | 45 | //mojmap + parchment mappings 46 | mappings loom.layered() { 47 | officialMojangMappings() 48 | parchment("org.parchmentmc.data:parchment-1.20.4:2024.04.14@zip") 49 | } 50 | rusherhackApi "org.rusherhack:rusherhack-api:1.20.4-SNAPSHOT" 51 | } 52 | 53 | 54 | tasks.register('runPlugin', JavaExec) { 55 | group = "build" 56 | dependsOn remapJar, downloadAssets, copyPluginToRunDir 57 | classpath.from configurations.productionRuntime 58 | mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient" 59 | workingDir = file("run") 60 | 61 | doFirst { 62 | classpath.from loom.minecraftProvider.minecraftClientJar 63 | workingDir.mkdirs() 64 | 65 | args( 66 | "--assetIndex", loom.minecraftProvider.versionInfo.assetIndex().fabricId(loom.minecraftProvider.minecraftVersion()), 67 | "--assetsDir", new File(loom.files.userCache, "assets").absolutePath, 68 | "--gameDir", workingDir.absolutePath 69 | ) 70 | 71 | def rusherLoaderJarFile = project.layout.getProjectDirectory().file("lib/rusherhack-loader.jar").asFile 72 | if (!rusherLoaderJarFile.exists()) { 73 | throw new GradleException("rusherhack-loader.jar must be copied to the lib directory!") 74 | } 75 | def rusherLoaderJarPath = project.layout.getProjectDirectory().file("lib/rusherhack-loader.jar").asFile.absolutePath 76 | 77 | jvmArgs( 78 | "-Drusherhack.enablePlugins=true", 79 | "-Dfabric.addMods=${rusherLoaderJarPath}", 80 | ) 81 | } 82 | } 83 | 84 | tasks.register("copyPluginToRunDir", Copy) { 85 | group = "build" 86 | dependsOn remapJar 87 | from remapJar.outputs 88 | into file("run/rusherhack/plugins") 89 | } 90 | 91 | tasks.register("getPluginVersion") { 92 | doLast { 93 | println(project.mod_version) 94 | } 95 | } 96 | 97 | loom { 98 | //apply accesswidener from rusherhack-api 99 | for (final def f in zipTree(this.project.configurations.rusherhackApi.singleFile)) { 100 | if(f.name == "rusherhack.accesswidener") { 101 | accessWidenerPath = f 102 | } 103 | } 104 | 105 | //disable run configs 106 | runConfigs.configureEach { 107 | ideConfigGenerated = false 108 | } 109 | } 110 | 111 | def targetJavaVersion = 17 112 | tasks.withType(JavaCompile).configureEach { 113 | // ensure that the encoding is set to UTF-8, no matter what the system default is 114 | // this fixes some edge cases with special characters not displaying correctly 115 | // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html 116 | // If Javadoc is generated, this must be specified in that task too. 117 | it.options.encoding = "UTF-8" 118 | if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { 119 | it.options.release = targetJavaVersion 120 | } 121 | } 122 | 123 | java { 124 | def javaVersion = JavaVersion.toVersion(targetJavaVersion) 125 | if (JavaVersion.current() < javaVersion) { 126 | toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) 127 | } 128 | archivesBaseName = project.archives_base_name 129 | } 130 | 131 | jar { 132 | manifest { 133 | //attributes.clear() 134 | attributes( 135 | "Minecraft-Version": project.minecraft_version 136 | ) 137 | } 138 | } 139 | 140 | remapJar { 141 | archiveVersion = "$project.version+$project.minecraft_version_range" 142 | } 143 | 144 | 145 | processResources { 146 | inputs.property "mod_version", project.mod_version 147 | 148 | filesMatching("rusherhack-plugin.json") { 149 | expand(mod_version: project.mod_version) 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | 4 | #properties 5 | minecraft_version = 1.20.4 6 | minecraft_version_range = 1.20-1.21.1 7 | mod_version = 1.11 8 | maven_group = ct 9 | archives_base_name = ContainerTweaks 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfresh2/ContainerTweaks-rusherhack/e102c019028b6d0c9f14ec3cc69e99999b9048b0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | if ! command -v java >/dev/null 2>&1 137 | then 138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 139 | 140 | Please set the JAVA_HOME variable in your environment to match the 141 | location of your Java installation." 142 | fi 143 | fi 144 | 145 | # Increase the maximum file descriptors if we can. 146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 147 | case $MAX_FD in #( 148 | max*) 149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 150 | # shellcheck disable=SC2039,SC3045 151 | MAX_FD=$( ulimit -H -n ) || 152 | warn "Could not query maximum file descriptor limit" 153 | esac 154 | case $MAX_FD in #( 155 | '' | soft) :;; #( 156 | *) 157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 158 | # shellcheck disable=SC2039,SC3045 159 | ulimit -n "$MAX_FD" || 160 | warn "Could not set maximum file descriptor limit to $MAX_FD" 161 | esac 162 | fi 163 | 164 | # Collect all arguments for the java command, stacking in reverse order: 165 | # * args from the command line 166 | # * the main class name 167 | # * -classpath 168 | # * -D...appname settings 169 | # * --module-path (only if needed) 170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 171 | 172 | # For Cygwin or MSYS, switch paths to Windows format before running java 173 | if "$cygwin" || "$msys" ; then 174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 176 | 177 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 178 | 179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 180 | for arg do 181 | if 182 | case $arg in #( 183 | -*) false ;; # don't mess with options #( 184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 185 | [ -e "$t" ] ;; #( 186 | *) false ;; 187 | esac 188 | then 189 | arg=$( cygpath --path --ignore --mixed "$arg" ) 190 | fi 191 | # Roll the args list around exactly as many times as the number of 192 | # args, so each arg winds up back in the position where it started, but 193 | # possibly modified. 194 | # 195 | # NB: a `for` loop captures its iteration list before it begins, so 196 | # changing the positional parameters here affects neither the number of 197 | # iterations, nor the values presented in `arg`. 198 | shift # remove old arg 199 | set -- "$@" "$arg" # push replacement arg 200 | done 201 | fi 202 | 203 | 204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 206 | 207 | # Collect all arguments for the java command: 208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 209 | # and any embedded shellness will be escaped. 210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 211 | # treated as '${Hostname}' itself on the command line. 212 | 213 | set -- \ 214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 215 | -classpath "$CLASSPATH" \ 216 | org.gradle.wrapper.GradleWrapperMain \ 217 | "$@" 218 | 219 | # Stop when "xargs" is not available. 220 | if ! command -v xargs >/dev/null 2>&1 221 | then 222 | die "xargs is not available" 223 | fi 224 | 225 | # Use "xargs" to parse quoted args. 226 | # 227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 228 | # 229 | # In Bash we could simply go: 230 | # 231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 232 | # set -- "${ARGS[@]}" "$@" 233 | # 234 | # but POSIX shell has neither arrays nor command substitution, so instead we 235 | # post-process each arg (as a line of input to sed) to backslash-escape any 236 | # character that might be a shell metacharacter, then use eval to reverse 237 | # that process (while maintaining the separation between arguments), and wrap 238 | # the whole thing up as a single "set" statement. 239 | # 240 | # This will of course break if any of these variables contains a newline or 241 | # an unmatched quote. 242 | # 243 | 244 | eval "set -- $( 245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 246 | xargs -n1 | 247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 248 | tr '\n' ' ' 249 | )" '"$@"' 250 | 251 | exec "$JAVACMD" "$@" 252 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | gradlePluginPortal() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ct/ContainerTweaksPlugin.java: -------------------------------------------------------------------------------- 1 | package ct; 2 | 3 | import ct.module.ContainerTweaks; 4 | import org.rusherhack.client.api.RusherHackAPI; 5 | import org.rusherhack.client.api.plugin.Plugin; 6 | 7 | public class ContainerTweaksPlugin extends Plugin { 8 | @Override 9 | public void onLoad() { 10 | RusherHackAPI.getModuleManager().registerFeature(new ContainerTweaks()); 11 | getLogger().info("ContainerTweaks plugin loaded"); 12 | } 13 | 14 | @Override 15 | public void onUnload() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ct/module/ContainerTweaks.java: -------------------------------------------------------------------------------- 1 | package ct.module; 2 | 3 | import com.google.common.collect.Lists; 4 | import net.minecraft.client.gui.components.Button; 5 | import net.minecraft.client.gui.components.events.GuiEventListener; 6 | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; 7 | import net.minecraft.client.gui.screens.inventory.CraftingScreen; 8 | import net.minecraft.client.gui.screens.inventory.InventoryScreen; 9 | import net.minecraft.world.Container; 10 | import net.minecraft.world.entity.player.Inventory; 11 | import net.minecraft.world.inventory.*; 12 | import net.minecraft.world.item.BlockItem; 13 | import net.minecraft.world.item.ItemStack; 14 | import net.minecraft.world.level.block.ShulkerBoxBlock; 15 | import org.lwjgl.glfw.GLFW; 16 | import org.rusherhack.client.api.RusherHackAPI; 17 | import org.rusherhack.client.api.accessors.gui.IMixinAbstractContainerScreen; 18 | import org.rusherhack.client.api.accessors.gui.IMixinScreen; 19 | import org.rusherhack.client.api.events.client.EventUpdate; 20 | import org.rusherhack.client.api.events.client.input.EventMouse; 21 | import org.rusherhack.client.api.feature.module.ModuleCategory; 22 | import org.rusherhack.client.api.feature.module.ToggleableModule; 23 | import org.rusherhack.client.api.setting.BindSetting; 24 | import org.rusherhack.core.event.stage.Stage; 25 | import org.rusherhack.core.event.subscribe.Subscribe; 26 | import org.rusherhack.core.setting.BooleanSetting; 27 | import org.rusherhack.core.setting.NumberSetting; 28 | 29 | import java.util.HashSet; 30 | import java.util.List; 31 | import java.util.Set; 32 | 33 | public class ContainerTweaks extends ToggleableModule { 34 | final BooleanSetting dragMove = new BooleanSetting("DragMove", true); 35 | final BindSetting dragMoveBind = new BindSetting("HoldKey", RusherHackAPI.getBindManager().createKeyboardKey(GLFW.GLFW_KEY_LEFT_SHIFT)); 36 | // Shulkers with larger NBT seem to be most sensitive to multiple moves per tick 37 | final NumberSetting maxDragMovesPerTick = new NumberSetting<>("MaxPerTick", 2, 1, 5); 38 | final BooleanSetting quickMove = new BooleanSetting("QuickMove", true); 39 | final BindSetting quickMoveBind = new BindSetting("HoldKey", RusherHackAPI.getBindManager().createKeyboardKey(GLFW.GLFW_KEY_LEFT_CONTROL)); 40 | final BooleanSetting quickMoveAll = new BooleanSetting("MoveAll", "Whether to move only items matching the hovered stack or all items in the container", false); 41 | final BooleanSetting quickMoveOnlyShulkers = new BooleanSetting("OnlyShulkers", "Whether to only quick move shulkers", false); 42 | final BooleanSetting quickMoveReverseOrderInventory = new BooleanSetting( 43 | "ReverseFromInv", 44 | "Moves items from higher inv slot ids before lower slot id's when moving from player inventory", 45 | false 46 | ); 47 | final BooleanSetting quickMoveReverseOrderContainer = new BooleanSetting( 48 | "ReverseToInv", 49 | "Moves items from higher inv slot ids before lower slot id's when moving to player inventory", 50 | false 51 | ); 52 | final BooleanSetting hijackChestStealer = new BooleanSetting( 53 | "ChestStealer", 54 | "Hijack the ChestStealer button actions to use quick move", 55 | false 56 | ); 57 | final BooleanSetting dragPickup = new BooleanSetting("DragPickup", true); 58 | private boolean dragging = false; 59 | private Set dragMovedSlots = new HashSet<>(5); 60 | 61 | public ContainerTweaks() { 62 | super("ContainerTweaks", "Simple tweaks for moving items in containers", ModuleCategory.MISC); 63 | dragMove.addSubSettings(dragMoveBind, maxDragMovesPerTick); 64 | quickMove.addSubSettings(quickMoveBind, 65 | quickMoveAll, 66 | quickMoveOnlyShulkers, 67 | quickMoveReverseOrderInventory, 68 | quickMoveReverseOrderContainer, 69 | hijackChestStealer); 70 | registerSettings(dragMove, quickMove, dragPickup); 71 | } 72 | 73 | @Override 74 | public void onDisable() { 75 | dragging = false; 76 | } 77 | 78 | private Button stealButton = null; 79 | private Button fillButton = null; 80 | 81 | @Subscribe(stage = Stage.PRE) 82 | public void tick(EventUpdate event) { 83 | dragMovedSlots.clear(); 84 | if (quickMove.getValue() 85 | && hijackChestStealer.getValue() 86 | && mc.screen instanceof AbstractContainerScreen handler 87 | && (fillButton == null || stealButton == null) 88 | ) { 89 | Button rhStealButton = null; 90 | Button rhFillButton = null; 91 | for (GuiEventListener child : handler.children()) { 92 | if (child instanceof Button b && b != stealButton && b != fillButton) { 93 | var buttonMessage = b.getMessage().getString(); 94 | if (buttonMessage.equals("Steal")) 95 | rhStealButton = b; 96 | else if (buttonMessage.equals("Fill")) 97 | rhFillButton = b; 98 | } 99 | } 100 | if (rhStealButton != null) { 101 | stealButton = Button.builder(rhStealButton.getMessage(), button -> { 102 | handler.getMenu().slots.stream().findFirst().ifPresent(slot -> { 103 | var fromContainer = slot.container; 104 | chestStealerQuickMove(fromContainer, handler); 105 | }); 106 | }) 107 | .pos(rhStealButton.getX(), rhStealButton.getY()) 108 | .size(rhStealButton.getWidth(), rhStealButton.getHeight()) 109 | .build(); 110 | ((IMixinScreen) handler).invokeRemoveWidget(rhStealButton); 111 | ((IMixinScreen) handler).invokeAddRenderableWidget(stealButton); 112 | } 113 | if (rhFillButton != null) { 114 | fillButton = Button.builder(rhFillButton.getMessage(), button -> { 115 | var fromContainer = mc.player.getInventory(); 116 | chestStealerQuickMove(fromContainer, handler); 117 | }) 118 | .pos(rhFillButton.getX(), rhFillButton.getY()) 119 | .size(rhFillButton.getWidth(), rhFillButton.getHeight()) 120 | .build(); 121 | ((IMixinScreen) handler).invokeRemoveWidget(rhFillButton); 122 | ((IMixinScreen) handler).invokeAddRenderableWidget(fillButton); 123 | } 124 | } else { 125 | stealButton = null; 126 | fillButton = null; 127 | } 128 | } 129 | 130 | @Subscribe 131 | public void dragMove(final EventMouse.Move event) { 132 | if (!dragMove.getValue() || !dragging || !dragMoveBind.getValue().isKeyDown()) return; 133 | if (mc.screen instanceof AbstractContainerScreen handler) { 134 | Slot hoveredSlot = ((IMixinAbstractContainerScreen) handler).getHoveredSlot(); 135 | if (hoveredSlot == null) return; 136 | // this is invoked more frequently than once per tick 137 | // i think it wouldn't be an issue if we hooked into the screen's mouse drag event 138 | if (dragMovedSlots.size() > maxDragMovesPerTick.getValue()) return; 139 | if (dragMovedSlots.contains(hoveredSlot.index)) return; 140 | quickMove(handler, hoveredSlot.index); 141 | dragMovedSlots.add(hoveredSlot.index); 142 | } 143 | } 144 | 145 | @Subscribe 146 | public void dragPickup(final EventMouse.Move event) { 147 | if (!dragPickup.getValue() || !dragging) return; 148 | if (mc.screen instanceof AbstractContainerScreen handler) { 149 | ItemStack mouseStack = mc.player.containerMenu.getCarried(); 150 | if (mouseStack.isEmpty()) return; 151 | Slot hoveredSlot = ((IMixinAbstractContainerScreen) handler).getHoveredSlot(); 152 | if (hoveredSlot == null) return; 153 | if (handler instanceof CraftingScreen craftingScreen && hoveredSlot.index < craftingScreen.getMenu().getSize()) return; 154 | if (handler instanceof InventoryScreen && hoveredSlot.index < 5) return; 155 | if (mouseStack.getCount() + hoveredSlot.getItem().getCount() > mouseStack.getMaxStackSize()) return; 156 | pickup(handler, hoveredSlot.index); 157 | if (hoveredSlot instanceof ResultSlot 158 | || hoveredSlot instanceof FurnaceResultSlot 159 | || hoveredSlot instanceof MerchantResultSlot) return; 160 | pickup(handler, hoveredSlot.index); 161 | } 162 | } 163 | 164 | @Subscribe(stage = Stage.PRE) 165 | public void quickMove(final EventMouse.Key event) { 166 | if (!quickMove.getValue() || event.getAction() != 0) return; 167 | if (mc.screen instanceof AbstractContainerScreen handler && event.getButton() == 0 && quickMoveBind.getValue().isKeyDown()) { 168 | Slot hoveredSlot = ((IMixinAbstractContainerScreen) handler).getHoveredSlot(); 169 | if (hoveredSlot == null) return; 170 | ItemStack mouseStack = mc.player.containerMenu.getCarried(); 171 | if (mouseStack.isEmpty()) { 172 | // todo: this state is actually not being seen for some reason 173 | // is there processing happening before or during this event in mc code elsewhere? 174 | // we do pick up the item from the click but its not this code doing it 175 | pickup(handler, hoveredSlot.index); 176 | mouseStack = mc.player.containerMenu.getCarried(); 177 | } 178 | final boolean isFromPlayerInv = hoveredSlot.container instanceof Inventory; 179 | for(Slot slot : getQuickMoveSlotList(handler, isFromPlayerInv)) { 180 | if (slot != null 181 | && slot.mayPickup(mc.player) 182 | && slot.hasItem() 183 | && slot.container == hoveredSlot.container 184 | && (quickMoveAll.getValue() || AbstractContainerMenu.canItemQuickReplace(slot, mouseStack, true)) 185 | ) { 186 | if (quickMoveOnlyShulkers.getValue() 187 | && (!(slot.getItem().getItem() instanceof BlockItem blockItem) 188 | || !(blockItem.getBlock() instanceof ShulkerBoxBlock))) 189 | continue; 190 | quickMove(handler, slot.index); 191 | } 192 | } 193 | pickup(handler, hoveredSlot.index); 194 | quickMove(handler, hoveredSlot.index); 195 | } 196 | } 197 | 198 | public void chestStealerQuickMove( 199 | final Container fromContainer, 200 | final AbstractContainerScreen handler 201 | ) { 202 | final boolean isFromPlayerInv = fromContainer instanceof Inventory; 203 | for(Slot slot : getQuickMoveSlotList(handler, isFromPlayerInv)) { 204 | if (slot != null 205 | && slot.mayPickup(mc.player) 206 | && slot.hasItem() 207 | && slot.container == fromContainer 208 | ) { 209 | if (quickMoveOnlyShulkers.getValue() 210 | && (!(slot.getItem().getItem() instanceof BlockItem blockItem) 211 | || !(blockItem.getBlock() instanceof ShulkerBoxBlock))) 212 | continue; 213 | quickMove(handler, slot.index); 214 | } 215 | } 216 | } 217 | 218 | public List getQuickMoveSlotList(final AbstractContainerScreen containerScreen, final boolean isFromPlayerInv) { 219 | final List slots = containerScreen.getMenu().slots; 220 | if (isFromPlayerInv) 221 | if (quickMoveReverseOrderInventory.getValue()) 222 | return Lists.reverse(slots); 223 | else 224 | return slots; 225 | else 226 | if (quickMoveReverseOrderContainer.getValue()) 227 | return Lists.reverse(slots); 228 | else 229 | return slots; 230 | } 231 | 232 | @Subscribe(stage = Stage.PRE) 233 | public void updateDrag(final EventMouse.Key event) { 234 | if (event.getButton() != 0) return; 235 | switch (event.getAction()) { 236 | case GLFW.GLFW_PRESS -> dragging = true; 237 | case GLFW.GLFW_RELEASE -> dragging = false; 238 | } 239 | } 240 | 241 | // avoiding InventoryUtils.clickSlot as it ticks the network connection on every call for some reason 242 | // that's fine if you do it once per tick but not for multiple clicks per tick, at least on strict servers 243 | public void clickSlot(AbstractContainerScreen screen, int slotId, ClickType clickType) { 244 | if (mc.gameMode == null) return; 245 | mc.gameMode.handleInventoryMouseClick(screen.getMenu().containerId, slotId, 0, clickType, mc.player); 246 | } 247 | 248 | public void pickup(AbstractContainerScreen screen, int slotId) { 249 | clickSlot(screen, slotId, ClickType.PICKUP); 250 | } 251 | 252 | public void quickMove(AbstractContainerScreen screen, int slotId) { 253 | clickSlot(screen, slotId, ClickType.QUICK_MOVE); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /src/main/resources/rusherhack-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugin-Class": "ct.ContainerTweaksPlugin", 3 | "Name": "ContainerTweaks", 4 | "Version": "${mod_version}", 5 | "Description": "Simple tweaks for moving items in containers", 6 | "Authors": [ 7 | "rfresh2" 8 | ], 9 | "Minecraft-Versions": [ 10 | "1.20.1", 11 | "1.20.2", 12 | "1.20.4", 13 | "1.20.6", 14 | "1.21", 15 | "1.21.1" 16 | ] 17 | } 18 | --------------------------------------------------------------------------------