├── .gitattributes ├── .github └── workflows │ └── build.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 └── net │ └── kyrptonaught │ └── lemclienthelper │ ├── ClientData │ ├── ClientDataMod.java │ └── ClientDataNetworking.java │ ├── LEMClientHelperMod.java │ ├── ResourcePreloader │ ├── AllPacks.java │ ├── ResourcePreloaderConfig.java │ └── ResourcePreloaderMod.java │ ├── ServerConfigs │ ├── ServerConfigsConfig.java │ └── ServerConfigsMod.java │ ├── SmallInv │ ├── ExtendedSlot.java │ ├── MovableSlot.java │ ├── SmallInvConfig.java │ ├── SmallInvMod.java │ └── SmallInvPlayerInv.java │ ├── SpectateSqueaker │ ├── SpectateSqueakerMod.java │ └── SpectateSqueakerNetworking.java │ ├── TakeEverything │ ├── LambdControlsCompat.java │ ├── TakeEverythingConfig.java │ ├── TakeEverythingMod.java │ └── TakeEverythingNetworking.java │ ├── config │ ├── ArmorHudPreviewItem.java │ ├── ModMenuIntegration.java │ └── ResourcepackDownloadItem.java │ ├── customWorldBorder │ ├── CustomWorldBorderArea.java │ ├── CustomWorldBorderMod.java │ ├── CustomWorldBorderNetworking.java │ └── duckInterface │ │ └── CustomWorldBorder.java │ ├── hud │ ├── ArmorHudRenderer.java │ ├── HudConfig.java │ └── HudMod.java │ ├── mixin │ ├── ResourcePreloader │ │ └── ClientBuiltInResourcePackProviderMixin.java │ ├── SmallInv │ │ ├── HandledScreenMixin.java │ │ ├── MidnightControlsMixin.java │ │ ├── MinecraftClientMixin.java │ │ ├── ScreenHandlerMixin.java │ │ └── invs │ │ │ ├── GenericContainerScreenMixin.java │ │ │ ├── InventoryScreenMixin.java │ │ │ └── MultipleScreenMixin.java │ ├── SpectateSquaker │ │ └── MinecraftClientMixin.java │ ├── SyncedKeybinds │ │ └── GameOptionsMixin.java │ ├── TakeEverything │ │ └── ScreenHandlerMixin.java │ ├── bookGui │ │ └── BookScreenMixin.java │ └── customWorldBorder │ │ └── WorldBorderMixin.java │ └── syncedKeybinds │ ├── GameOptionKeyExpander.java │ ├── SyncedKeybind.java │ ├── SyncedKeybindsConfig.java │ ├── SyncedKeybindsMod.java │ └── SyncedKeybindsNetworking.java └── resources ├── assets └── lemclienthelper │ ├── icon.png │ ├── lang │ └── en_us.json │ └── textures │ └── gui │ └── legacy_inventory.png ├── fabric.mod.json ├── lemclienthelper.accesswidener └── lemclienthelper.mixins.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Automatically build the project and run any configured tests for every push 2 | # and submitted pull request. This can help catch issues that only occur on 3 | # certain platforms or Java versions, and provides a first line of defence 4 | # against bad commits. 5 | 6 | name: build 7 | on: [push] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-java@v4 17 | with: 18 | distribution: 'temurin' # See 'Supported distributions' for available options 19 | java-version: '17' 20 | 21 | - name: validate gradle wrapper 22 | uses: gradle/wrapper-validation-action@v2 23 | 24 | - name: make gradle wrapper executable 25 | run: chmod +x ./gradlew 26 | 27 | - name: build 28 | run: ./gradlew build 29 | 30 | - name: capture build artifacts 31 | uses: actions/upload-artifact@v4 32 | with: 33 | name: Artifacts 34 | path: build/libs/ 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/java,gradle,windows,intellij,forgegradle 2 | # Edit at https://www.gitignore.io/?templates=java,gradle,windows,intellij,forgegradle 3 | 4 | ### ForgeGradle ### 5 | # Minecraft client/server files 6 | run/ 7 | 8 | ### Intellij ### 9 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 10 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 11 | 12 | # User-specific stuff 13 | .idea/**/workspace.xml 14 | .idea/**/tasks.xml 15 | .idea/**/usage.statistics.xml 16 | .idea/**/dictionaries 17 | .idea/**/shelf 18 | 19 | # Generated files 20 | .idea/**/contentModel.xml 21 | 22 | # Sensitive or high-churn files 23 | .idea/**/dataSources/ 24 | .idea/**/dataSources.ids 25 | .idea/**/dataSources.local.xml 26 | .idea/**/sqlDataSources.xml 27 | .idea/**/dynamic.xml 28 | .idea/**/uiDesigner.xml 29 | .idea/**/dbnavigator.xml 30 | 31 | # Gradle 32 | .idea/**/gradle.xml 33 | .idea/**/libraries 34 | 35 | # Gradle and Maven with auto-import 36 | # When using Gradle or Maven with auto-import, you should exclude module files, 37 | # since they will be recreated, and may cause churn. Uncomment if using 38 | # auto-import. 39 | # .idea/modules.xml 40 | # .idea/*.iml 41 | # .idea/modules 42 | 43 | # CMake 44 | cmake-build-*/ 45 | 46 | # Mongo Explorer plugin 47 | .idea/**/mongoSettings.xml 48 | 49 | # File-based project format 50 | *.iws 51 | *.ipr 52 | *.iml 53 | 54 | # IntelliJ 55 | out/ 56 | 57 | # mpeltonen/sbt-idea plugin 58 | .idea_modules/ 59 | 60 | # JIRA plugin 61 | atlassian-ide-plugin.xml 62 | 63 | # Cursive Clojure plugin 64 | .idea/replstate.xml 65 | 66 | # Crashlytics plugin (for Android Studio and IntelliJ) 67 | com_crashlytics_export_strings.xml 68 | crashlytics.properties 69 | crashlytics-build.properties 70 | fabric.properties 71 | 72 | # Editor-based Rest Client 73 | .idea/httpRequests 74 | 75 | # Android studio 3.1+ serialized cache file 76 | .idea/caches/build_file_checksums.ser 77 | 78 | # JetBrains templates 79 | **___jb_tmp___ 80 | 81 | ### Intellij Patch ### 82 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 83 | 84 | # *.iml 85 | # modules.xml 86 | # .idea/misc.xml 87 | # *.ipr 88 | 89 | # Sonarlint plugin 90 | .idea/sonarlint 91 | 92 | ### Java ### 93 | # Compiled class file 94 | *.class 95 | 96 | # Log file 97 | *.log 98 | 99 | # BlueJ files 100 | *.ctxt 101 | 102 | # Mobile Tools for Java (J2ME) 103 | .mtj.tmp/ 104 | 105 | # Package Files # 106 | *.jar 107 | *.war 108 | *.nar 109 | *.ear 110 | *.zip 111 | *.tar.gz 112 | *.rar 113 | 114 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 115 | hs_err_pid* 116 | 117 | ### Windows ### 118 | # Windows thumbnail cache files 119 | Thumbs.db 120 | ehthumbs.db 121 | ehthumbs_vista.db 122 | 123 | # Dump file 124 | *.stackdump 125 | 126 | # Folder config file 127 | [Dd]esktop.ini 128 | 129 | # Recycle Bin used on file shares 130 | $RECYCLE.BIN/ 131 | 132 | # Windows Installer files 133 | *.cab 134 | *.msi 135 | *.msix 136 | *.msm 137 | *.msp 138 | 139 | # Windows shortcuts 140 | *.lnk 141 | 142 | ### Gradle ### 143 | .gradle 144 | build/ 145 | 146 | # Ignore Gradle GUI config 147 | gradle-app.setting 148 | 149 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 150 | !gradle-wrapper.jar 151 | 152 | # Cache of project 153 | .gradletasknamecache 154 | 155 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 156 | # gradle/wrapper/gradle-wrapper.properties 157 | 158 | ### Gradle Patch ### 159 | **/build/ 160 | ### macOS ### 161 | # General 162 | .DS_Store 163 | .AppleDouble 164 | .LSOverride 165 | 166 | # Icon must end with two \r 167 | Icon 168 | 169 | # Thumbnails 170 | ._* 171 | 172 | # Files that might appear in the root of a volume 173 | .DocumentRevisions-V100 174 | .fseventsd 175 | .Spotlight-V100 176 | .TemporaryItems 177 | .Trashes 178 | .VolumeIcon.icns 179 | .com.apple.timemachine.donotpresent 180 | 181 | # Directories potentially created on remote AFP share 182 | .AppleDB 183 | .AppleDesktop 184 | Network Trash Folder 185 | Temporary Items 186 | .apdisk 187 | # End of https://www.gitignore.io/api/java,gradle,windows,intellij,forgegradle 188 | .idea/runConfigurations/Minecraft_Server.xml 189 | .idea/jarRepositories.xml 190 | .idea/misc.xml 191 | .idea/modules.xml 192 | .idea/runConfigurations.xml 193 | .idea/runConfigurations/Minecraft_Client.xml 194 | .idea/runConfigurations/Minecraft_Server.xml 195 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # PolyForm Perimeter License 1.0.0 2 | 3 | 4 | 5 | ## Acceptance 6 | 7 | In order to get any license under these terms, you must agree 8 | to them as both strict obligations and conditions to all 9 | your licenses. 10 | 11 | ## Copyright License 12 | 13 | The licensor grants you a copyright license for the 14 | software to do everything you might do with the software 15 | that would otherwise infringe the licensor's copyright 16 | in it for any permitted purpose. However, you may 17 | only distribute the software according to [Distribution 18 | License](#distribution-license) and make changes or new works 19 | based on the software according to [Changes and New Works 20 | License](#changes-and-new-works-license). 21 | 22 | ## Distribution License 23 | 24 | The licensor grants you an additional copyright license 25 | to distribute copies of the software. Your license 26 | to distribute covers distributing the software with 27 | changes and new works permitted by [Changes and New Works 28 | License](#changes-and-new-works-license). 29 | 30 | ## Notices 31 | 32 | You must ensure that anyone who gets a copy of any part of 33 | the software from you also gets a copy of these terms or the 34 | URL for them above, as well as copies of any plain-text lines 35 | beginning with `Required Notice:` that the licensor provided 36 | with the software. For example: 37 | 38 | > Required Notice: Copyright Yoyodyne, Inc. (http://example.com) 39 | 40 | ## Changes and New Works License 41 | 42 | The licensor grants you an additional copyright license to 43 | make changes and new works based on the software for any 44 | permitted purpose. 45 | 46 | ## Patent License 47 | 48 | The licensor grants you a patent license for the software that 49 | covers patent claims the licensor can license, or becomes able 50 | to license, that you would infringe by using the software. 51 | 52 | ## Noncompete 53 | 54 | Any purpose is a permitted purpose, except for providing to 55 | others any product that competes with the software. 56 | 57 | ## Competition 58 | 59 | If you use this software to market a product as a substitute 60 | for the functionality or value of the software, it competes 61 | with the software. A product may compete regardless how it is 62 | designed or deployed. For example, a product may compete even 63 | if it provides its functionality via any kind of interface 64 | (including services, libraries or plug-ins), even if it is 65 | ported to a different platforms or programming languages, 66 | and even if it is provided free of charge. 67 | 68 | ## Fair Use 69 | 70 | You may have "fair use" rights for the software under the 71 | law. These terms do not limit them. 72 | 73 | ## No Other Rights 74 | 75 | These terms do not allow you to sublicense or transfer any of 76 | your licenses to anyone else, or prevent the licensor from 77 | granting licenses to anyone else. These terms do not imply 78 | any other licenses. 79 | 80 | ## Patent Defense 81 | 82 | If you make any written claim that the software infringes or 83 | contributes to infringement of any patent, your patent license 84 | for the software granted under these terms ends immediately. If 85 | your company makes such a claim, your patent license ends 86 | immediately for work on behalf of your company. 87 | 88 | ## Violations 89 | 90 | The first time you are notified in writing that you have 91 | violated any of these terms, or done anything with the software 92 | not covered by your licenses, your licenses can nonetheless 93 | continue if you come into full compliance with these terms, 94 | and take practical steps to correct past violations, within 95 | 32 days of receiving notice. Otherwise, all your licenses 96 | end immediately. 97 | 98 | ## No Liability 99 | 100 | ***As far as the law allows, the software comes as is, without 101 | any warranty or condition, and the licensor will not be liable 102 | to you for any damages arising out of these terms or the use 103 | or nature of the software, under any kind of legal claim.*** 104 | 105 | ## Definitions 106 | 107 | The **licensor** is the individual or entity offering these 108 | terms, and the **software** is the software the licensor makes 109 | available under these terms. 110 | 111 | A **product** can be a good or service, or a combination 112 | of them. 113 | 114 | **You** refers to the individual or entity agreeing to these 115 | terms. 116 | 117 | **Your company** is any legal entity, sole proprietorship, 118 | or other kind of organization that you work for, plus all 119 | organizations that have control over, are under the control of, 120 | or are under common control with that organization. **Control** 121 | means ownership of substantially all the assets of an entity, 122 | or the power to direct its management and policies by vote, 123 | contract, or otherwise. Control can be direct or indirect. 124 | 125 | **Your licenses** are all the licenses granted to you for the 126 | software under these terms. 127 | 128 | **Use** means anything you do with the software requiring one 129 | of your licenses. 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Legacy Edition Minigames Logo](https://github.com/Legacy-Edition-Minigames/LEMClientHelper/assets/49575478/7bfcab08-e43d-489e-ae15-340b63758fe1) 2 | 3 | # LEM Client Helper 4 | 5 | Currently supports Minecraft 1.20.4. 6 | 7 | LCH is a Fabric mod that enhances the experience on [Legacy Edition Minigames](https://www.legacyminigames.xyz) servers, by default it does not affect Singleplayer or non-LEM servers. 8 | 9 | This mod adds the following features and options customizable through [Mod Menu](https://modrinth.com/mod/modmenu): 10 | 11 | ## Take Everything 12 | 13 | Take Everything allows you to take all items out of a chest with one button. 14 | 15 | The default keybind is `Spacebar`, you can change it in Minecraft's Control settings 16 | 17 | ## Resource Preloader 18 | 19 | Resource Preloading allows you to download the resource packs in advance to allow for faster loading times in LEM servers. 20 | 21 | Preloading is only accessable via the mod's config page, resources will not be preloaded automatically. 22 | 23 | Preloading will automatically continue in the background if you would like to close the config menu and play. 24 | 25 | The limit for how many packs can be cached is expanded to support the large amount of resource packs LEM utilizes(20 -> 30). 26 | 27 | ### Options 28 | 29 | - Completed Notification: A notification will be displayed in-game once a pack has been preloaded. 30 | 31 | - Delete Packs: Deletes the resource pack cache. 32 | 33 | - Preview Pack List: Displays a list of all the packs that will be downloaded. 34 | 35 | - Start Download: Starts downloading the packs to preload them. 36 | 37 | ## Local Server Config 38 | 39 | This allows you to set some LEM server options on the client, ignoring what you have it set to on the server. 40 | 41 | Setting these options to `0` will make them use the options you set on the server. 42 | 43 | This is useful if you play on multiple devices, with different display sizes 44 | 45 | ### Options 46 | 47 | - GUI Scale: Changes the GUI Scale the server expects for some UI elements, notably chest refill icon. 48 | 49 | - Panorama Scale: Changes the GUI Scale the server will use for the panorama renderer. 50 | 51 | ## Armor HUD 52 | 53 | LCH provides a more accurate Armor Bar than what is displayed without the mod. 54 | 55 | ![Armor Bar](https://github.com/Legacy-Edition-Minigames/LEMClientHelper/assets/65347035/7525e797-2cf1-4593-9f65-230a851fcfb1) 56 | 57 | ### Options 58 | 59 | - Enabled Armor HUD: The Armor Bar will be displayed if this is enabled. 60 | 61 | - Always Show Armor HUD: The Armor Bar will be visible outside of LEM servers when enabled. 62 | 63 | - Armor HUD Scale Modifier: Changes how large the Armor Bar will be, accepts values between `1.00`-`4.00`. 64 | 65 | - Armor HUD X Offset: Changes the distance of the Armor Bar from the edge of the screen. 66 | 67 | ## Small Inv 68 | 69 | LCH provides a more accurate Small Inventory UI than what is displayed without the mod. 70 | 71 | ![Small Ivnentory](https://github.com/Legacy-Edition-Minigames/LEMClientHelper/assets/65347035/2ffaa1d4-a704-4f34-96ba-0ff15f843919) 72 | 73 | ### Options 74 | 75 | - Enabled: The accurate Small Inventory will be used if this is enabled. If it is disabled it will use the vanilla UI. 76 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '1.5-SNAPSHOT' 3 | id 'maven-publish' 4 | } 5 | 6 | version = project.mod_version 7 | group = project.maven_group 8 | 9 | repositories { 10 | maven { url = "https://maven.terraformersmc.com/" } 11 | maven { url = "https://maven.kyrptonaught.dev" } 12 | maven { url = "https://api.modrinth.com/maven" } 13 | maven { url = "https://aperlambda.github.io/maven" } 14 | maven { url = "https://maven.gegy.dev" } 15 | } 16 | 17 | loom { 18 | accessWidenerPath = file("src/main/resources/lemclienthelper.accesswidener") 19 | } 20 | 21 | dependencies { 22 | // To change the versions see the gradle.properties file 23 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 24 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 25 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 26 | 27 | // Fabric API. This is technically optional, but you probably want it anyway. 28 | modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 29 | 30 | modImplementation('net.kyrptonaught:kyrptconfig:1.6.0-1.20.4') 31 | include('net.kyrptonaught:kyrptconfig:1.6.0-1.20.4') 32 | 33 | modImplementation ("com.terraformersmc:modmenu:9.0.0"){ 34 | transitive(false) 35 | } 36 | 37 | //modImplementation "com.ptsmods:devlogin:3.5" 38 | 39 | //midnightcontrols 40 | modImplementation "dev.lambdaurora:spruceui:5.0.3+1.20.4" 41 | modImplementation "maven.modrinth:midnightlib:1.5.3-fabric" 42 | modImplementation "maven.modrinth:midnightcontrols:1.9.3+1.20.4" 43 | api('org.aperlambda:lambdajcommon:1.8.1') { 44 | exclude group: 'com.google.code.gson' 45 | exclude group: 'com.google.guava' 46 | } 47 | } 48 | 49 | base { 50 | archivesName = project.archives_base_name 51 | } 52 | 53 | processResources { 54 | inputs.property "version", project.version 55 | 56 | filesMatching("fabric.mod.json") { 57 | expand "version": project.version 58 | } 59 | } 60 | 61 | tasks.withType(JavaCompile).configureEach { 62 | it.options.release = 17 63 | } 64 | 65 | java { 66 | sourceCompatibility = JavaVersion.VERSION_17 67 | targetCompatibility = JavaVersion.VERSION_17 68 | } 69 | 70 | jar { 71 | from("LICENSE") { 72 | rename { "${it}_${base.archivesName.get()}"} 73 | } 74 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | org.gradle.parallel=true 3 | 4 | # Fabric Properties 5 | minecraft_version=1.20.4 6 | yarn_mappings=1.20.4+build.3 7 | loader_version=0.15.7 8 | 9 | #Fabric api 10 | fabric_version=0.96.4+1.20.4 11 | 12 | # Mod Properties 13 | mod_version=0.0.28-1.20.4 14 | maven_group=net.kyrptonaught 15 | archives_base_name=lemclienthelper -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Legacy-Edition-Minigames/LEMClientHelper/0e87b4709fcb571baf06c576b2dc9bdf540a7291/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.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /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 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /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 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ClientData; 2 | 3 | import net.fabricmc.loader.api.FabricLoader; 4 | 5 | public class ClientDataMod { 6 | 7 | public static void onInitialize() { 8 | ClientDataNetworking.sendHasLEMPacket(); 9 | } 10 | 11 | public static boolean isOptifineLoaded(FabricLoader loader) { 12 | return loader.isModLoaded("optifabric") || loader.isModLoaded("optifine"); 13 | } 14 | 15 | public static boolean isControllerModLoaded(FabricLoader loader) { 16 | return loader.isModLoaded("midnightcontrols") || 17 | loader.isModLoaded("lambdacontrols") || 18 | loader.isModLoaded("controllable") || 19 | loader.isModLoaded("controllermod"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataNetworking.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ClientData; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking; 7 | import net.fabricmc.loader.api.FabricLoader; 8 | import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsMod; 9 | import net.minecraft.network.PacketByteBuf; 10 | import net.minecraft.util.Identifier; 11 | 12 | import java.util.concurrent.CompletableFuture; 13 | 14 | public class ClientDataNetworking { 15 | public static final Identifier HAS_MODS_PACKET = new Identifier("scoreboardplayerinfo", "has_mods_packet"); 16 | 17 | 18 | @Environment(EnvType.CLIENT) 19 | public static void sendHasLEMPacket() { 20 | ClientLoginNetworking.registerGlobalReceiver(HAS_MODS_PACKET, (client, handler, buf, listenerAdder) -> { 21 | FabricLoader loader = FabricLoader.getInstance(); 22 | 23 | PacketByteBuf respondeBuf = new PacketByteBuf(Unpooled.buffer()); 24 | respondeBuf.writeBoolean(true); //LEMClientHelper, Always true 25 | respondeBuf.writeBoolean(ClientDataMod.isOptifineLoaded(loader)); 26 | respondeBuf.writeBoolean(ClientDataMod.isControllerModLoaded(loader)); 27 | respondeBuf.writeInt(ServerConfigsMod.getConfig().guiScale); 28 | respondeBuf.writeInt(ServerConfigsMod.getConfig().panScale); 29 | 30 | return CompletableFuture.completedFuture(respondeBuf); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/LEMClientHelperMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 5 | import net.fabricmc.loader.api.FabricLoader; 6 | import net.kyrptonaught.kyrptconfig.config.ConfigManager; 7 | import net.kyrptonaught.lemclienthelper.ClientData.ClientDataMod; 8 | import net.kyrptonaught.lemclienthelper.ResourcePreloader.ResourcePreloaderMod; 9 | import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsMod; 10 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; 11 | import net.kyrptonaught.lemclienthelper.SpectateSqueaker.SpectateSqueakerMod; 12 | import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingMod; 13 | import net.kyrptonaught.lemclienthelper.customWorldBorder.CustomWorldBorderMod; 14 | import net.kyrptonaught.lemclienthelper.hud.HudMod; 15 | import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsMod; 16 | import net.minecraft.client.option.KeyBinding; 17 | import net.minecraft.client.util.InputUtil; 18 | import net.minecraft.util.Identifier; 19 | 20 | public class LEMClientHelperMod implements ClientModInitializer { 21 | public static final String MOD_ID = "lemclienthelper"; 22 | public static ConfigManager.MultiConfigManager configManager = new ConfigManager.MultiConfigManager(MOD_ID); 23 | public static Identifier PRESENCE_PACKET = new Identifier("serverutils", "presence"); 24 | 25 | @Override 26 | public void onInitializeClient() { 27 | TakeEverythingMod.onInitialize(); 28 | ResourcePreloaderMod.onInitialize(); 29 | SmallInvMod.onInitialize(); 30 | ClientDataMod.onInitialize(); 31 | SyncedKeybindsMod.onInitialize(); 32 | SpectateSqueakerMod.onInitialize(); 33 | ServerConfigsMod.onInitialize(); 34 | CustomWorldBorderMod.onInitialize(); 35 | HudMod.onInitialize(); 36 | // if (FabricLoader.getInstance().isModLoaded("lambdacontrols")) 37 | if (FabricLoader.getInstance().isModLoaded("midnightcontrols")) 38 | registerControllerKeys(); 39 | //TODO: Implement this armor hud with config and or server integration 40 | //configManager.load(); 41 | } 42 | 43 | public static void registerControllerKeys() { 44 | TakeEverythingMod.registerControllerKeys(); 45 | } 46 | 47 | public static boolean isKeybindPressed(KeyBinding keyBinding, int pressedKeyCode, boolean isMouse) { 48 | InputUtil.Key keycode = KeyBindingHelper.getBoundKeyOf(keyBinding); 49 | 50 | if (isMouse) { 51 | if (keycode.getCategory() != InputUtil.Type.MOUSE) return false; 52 | } else { 53 | if (keycode.getCategory() != InputUtil.Type.KEYSYM) return false; 54 | } 55 | return keycode.getCode() == pressedKeyCode; 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/AllPacks.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ResourcePreloader; 2 | 3 | import net.minecraft.text.Text; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | public class AllPacks { 10 | public List packs = new ArrayList<>(); 11 | 12 | public static class RPOption { 13 | public String packname; 14 | public String url; 15 | 16 | public UUID uuid; 17 | public Text status; 18 | public Text status2; 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ResourcePreloader; 2 | 3 | import blue.endless.jankson.Comment; 4 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 5 | 6 | public class ResourcePreloaderConfig implements AbstractConfigFile { 7 | public static final String DEFAULT_URL = "https://raw.githubusercontent.com/Legacy-Edition-Minigames/Minigames/main/config/serverutils/switchableresourcepacks.json5"; 8 | 9 | @Comment("Should display toast's for completed downloads") 10 | public boolean toastComplete = true; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ResourcePreloader; 2 | 3 | import com.google.common.hash.HashFunction; 4 | import com.google.common.hash.Hashing; 5 | import com.mojang.util.UndashedUuid; 6 | import net.kyrptonaught.jankson.Jankson; 7 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 8 | import net.minecraft.GameVersion; 9 | import net.minecraft.SharedConstants; 10 | import net.minecraft.client.MinecraftClient; 11 | import net.minecraft.client.realms.SizeUnit; 12 | import net.minecraft.client.session.Session; 13 | import net.minecraft.client.toast.SystemToast; 14 | import net.minecraft.resource.ResourceType; 15 | import net.minecraft.text.Text; 16 | import net.minecraft.util.NetworkUtils; 17 | import net.minecraft.util.Util; 18 | import net.minecraft.util.path.CacheFiles; 19 | 20 | import java.io.InputStream; 21 | import java.net.Proxy; 22 | import java.net.URL; 23 | import java.nio.charset.StandardCharsets; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.util.Map; 27 | import java.util.OptionalLong; 28 | import java.util.UUID; 29 | import java.util.concurrent.atomic.AtomicInteger; 30 | 31 | public class ResourcePreloaderMod { 32 | public static String MOD_ID = "resourcepreloader"; 33 | public static AllPacks allPacks; 34 | 35 | public static void onInitialize() { 36 | LEMClientHelperMod.configManager.registerFile(MOD_ID, new ResourcePreloaderConfig()); 37 | LEMClientHelperMod.configManager.load(MOD_ID); 38 | } 39 | 40 | public static ResourcePreloaderConfig getConfig() { 41 | return (ResourcePreloaderConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 42 | } 43 | 44 | public static void getPackList() { 45 | try { 46 | URL url = new URL(ResourcePreloaderConfig.DEFAULT_URL); 47 | 48 | Jankson jankson = LEMClientHelperMod.configManager.getJANKSON(); 49 | try (InputStream in = url.openStream()) { 50 | allPacks = jankson.fromJson(jankson.load(in), AllPacks.class); 51 | } 52 | 53 | for (int i = allPacks.packs.size() - 1; i >= 0; i--) { 54 | AllPacks.RPOption rpOption = allPacks.packs.get(i); 55 | rpOption.uuid = UUID.nameUUIDFromBytes(rpOption.packname.getBytes(StandardCharsets.UTF_8)); 56 | checkPack(rpOption.uuid); 57 | } 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | 63 | public static void downloadPacks() { 64 | Path downloadsDirectory = MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"); 65 | HashFunction SHA1 = Hashing.sha1(); 66 | Map headers = getHeaders(MinecraftClient.getInstance().getSession()); 67 | Proxy proxy = MinecraftClient.getInstance().getNetworkProxy(); 68 | 69 | AtomicInteger counter = new AtomicInteger(allPacks.packs.size()); 70 | for (AllPacks.RPOption rpOption : allPacks.packs) { 71 | if (!checkPack(rpOption.uuid)) { 72 | Util.getDownloadWorkerExecutor().execute(() -> downloadPack(rpOption, downloadsDirectory, SHA1, headers, proxy, () -> { 73 | counter.getAndDecrement(); 74 | if (counter.get() <= 0 && getConfig().toastComplete) { 75 | SystemToast.add(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.PERIODIC_NOTIFICATION, Text.translatable("key.lemclienthelper.alldownloadcomplete"), null); 76 | } 77 | })); 78 | } 79 | } 80 | } 81 | 82 | public static void downloadPack(AllPacks.RPOption rpOption, Path downloadsDirectory, HashFunction SHA1, Map headers, Proxy proxy, Runnable onComplete) { 83 | try { 84 | NetworkUtils.download(downloadsDirectory.resolve(rpOption.uuid.toString()), new URL(rpOption.url), headers, SHA1, null, 0xFA00000, proxy, createListener(rpOption, onComplete)); 85 | } catch (Exception e) { 86 | e.printStackTrace(); 87 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloaderror"), null); 88 | } 89 | } 90 | 91 | public static void deletePacks() { 92 | CacheFiles.clear(MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"), 0); 93 | } 94 | 95 | private static boolean checkPack(UUID packID) { 96 | Path downloadsDirectory = MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"); 97 | if (Files.exists(downloadsDirectory.resolve(packID.toString()))) { 98 | setStatus(packID, Text.translatable("key.lemclienthelper.alreadydownloaded"), null); 99 | return true; 100 | } 101 | 102 | setStatus(packID, null, null); 103 | return false; 104 | } 105 | 106 | public static void setStatus(UUID packID, Text status, Text status2) { 107 | for (AllPacks.RPOption rpOption : allPacks.packs) { 108 | if (rpOption.uuid == packID) { 109 | rpOption.status = status; 110 | rpOption.status2 = status2; 111 | } 112 | } 113 | } 114 | 115 | private static Map getHeaders(Session session) { 116 | GameVersion gameVersion = SharedConstants.getGameVersion(); 117 | return Map.of("X-Minecraft-Username", session.getUsername(), "X-Minecraft-UUID", UndashedUuid.toString(session.getUuidOrNull()), "X-Minecraft-Version", gameVersion.getName(), "X-Minecraft-Version-ID", gameVersion.getId(), "X-Minecraft-Pack-Format", String.valueOf(gameVersion.getResourceVersion(ResourceType.CLIENT_RESOURCES)), "User-Agent", "Minecraft Java/" + gameVersion.getName()); 118 | } 119 | 120 | private static NetworkUtils.DownloadListener createListener(AllPacks.RPOption rpOption, Runnable onComplete) { 121 | return new NetworkUtils.DownloadListener() { 122 | private OptionalLong contentLength = OptionalLong.empty(); 123 | 124 | private Text getProgress(long writtenBytes) { 125 | return this.contentLength.isPresent() ? Text.translatable("download.pack.progress.percent", writtenBytes * 100L / this.contentLength.getAsLong()) : Text.translatable("download.pack.progress.bytes", SizeUnit.getUserFriendlyString(writtenBytes)); 126 | } 127 | 128 | @Override 129 | public void onStart() { 130 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), null); 131 | } 132 | 133 | @Override 134 | public void onContentLength(OptionalLong contentLength) { 135 | this.contentLength = contentLength; 136 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), getProgress(0L)); 137 | } 138 | 139 | @Override 140 | public void onProgress(long writtenBytes) { 141 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), getProgress(writtenBytes)); 142 | } 143 | 144 | @Override 145 | public void onFinish(boolean success) { 146 | if (!success) { 147 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloaderror"), null); 148 | } else { 149 | setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloadcomplete"), null); 150 | } 151 | onComplete.run(); 152 | } 153 | }; 154 | } 155 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ServerConfigs/ServerConfigsConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ServerConfigs; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 4 | 5 | public class ServerConfigsConfig implements AbstractConfigFile { 6 | //client side config options that interact with the server go here 7 | public int guiScale = 0; 8 | public int panScale = 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/ServerConfigs/ServerConfigsMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.ServerConfigs; 2 | 3 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 4 | 5 | public class ServerConfigsMod { 6 | public static String MOD_ID = "serverconfigs"; 7 | 8 | public static void onInitialize() { 9 | LEMClientHelperMod.configManager.registerFile(MOD_ID, new ServerConfigsConfig()); 10 | LEMClientHelperMod.configManager.load(MOD_ID); 11 | } 12 | 13 | public static ServerConfigsConfig getConfig() { 14 | return (ServerConfigsConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SmallInv; 2 | 3 | 4 | import com.mojang.datafixers.util.Pair; 5 | import net.minecraft.entity.player.PlayerEntity; 6 | import net.minecraft.item.ItemStack; 7 | import net.minecraft.screen.slot.Slot; 8 | import net.minecraft.util.Identifier; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.Optional; 12 | 13 | public class ExtendedSlot extends Slot { 14 | private final Slot baseSlot; 15 | 16 | public ExtendedSlot(Slot slot) { 17 | super(slot.inventory, slot.getIndex(), slot.x, slot.y); 18 | baseSlot = slot; 19 | this.id = slot.id; 20 | } 21 | 22 | public void onQuickTransfer(ItemStack newItem, ItemStack original) { 23 | baseSlot.onQuickTransfer(newItem, original); 24 | } 25 | 26 | protected void onCrafted(ItemStack stack, int amount) { 27 | super.onCrafted(stack, amount); 28 | } 29 | 30 | protected void onTake(int amount) { 31 | super.onTake(amount); 32 | } 33 | 34 | protected void onCrafted(ItemStack stack) { 35 | super.onCrafted(stack); 36 | } 37 | 38 | public void onTakeItem(PlayerEntity player, ItemStack stack) { 39 | baseSlot.onTakeItem(player, stack); 40 | } 41 | 42 | public boolean canInsert(ItemStack stack) { 43 | return baseSlot.canInsert(stack); 44 | } 45 | 46 | public ItemStack getStack() { 47 | return baseSlot.getStack(); 48 | } 49 | 50 | public boolean hasStack() { 51 | return baseSlot.hasStack(); 52 | } 53 | 54 | public void setStack(ItemStack stack) { 55 | baseSlot.setStack(stack); 56 | } 57 | 58 | public void markDirty() { 59 | baseSlot.markDirty(); 60 | } 61 | 62 | public int getMaxItemCount() { 63 | return baseSlot.getMaxItemCount(); 64 | } 65 | 66 | public int getMaxItemCount(ItemStack stack) { 67 | return baseSlot.getMaxItemCount(stack); 68 | } 69 | 70 | @Nullable 71 | public Pair getBackgroundSprite() { 72 | return baseSlot.getBackgroundSprite(); 73 | } 74 | 75 | public ItemStack takeStack(int amount) { 76 | return baseSlot.takeStack(amount); 77 | } 78 | 79 | public boolean canTakeItems(PlayerEntity playerEntity) { 80 | return baseSlot.canTakeItems(playerEntity); 81 | } 82 | 83 | public boolean isEnabled() { 84 | return baseSlot.isEnabled(); 85 | } 86 | 87 | public Optional tryTakeStackRange(int min, int max, PlayerEntity player) { 88 | return baseSlot.tryTakeStackRange(min, max, player); 89 | } 90 | 91 | public ItemStack takeStackRange(int min, int max, PlayerEntity player) { 92 | return baseSlot.takeStackRange(min, max, player); 93 | } 94 | 95 | public ItemStack insertStack(ItemStack stack) { 96 | return baseSlot.insertStack(stack); 97 | } 98 | 99 | public ItemStack insertStack(ItemStack stack, int count) { 100 | return baseSlot.insertStack(stack, count); 101 | } 102 | 103 | public boolean canTakePartial(PlayerEntity player) { 104 | return baseSlot.canTakePartial(player); 105 | } 106 | 107 | public int getIndex() { 108 | return baseSlot.getIndex(); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/MovableSlot.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SmallInv; 2 | 3 | import net.minecraft.screen.slot.Slot; 4 | 5 | public class MovableSlot extends ExtendedSlot { 6 | public boolean isEnabled = true; 7 | private int oldX = -1, oldY = -1; 8 | 9 | public MovableSlot(Slot slot) { 10 | super(slot); 11 | } 12 | 13 | @Override 14 | public boolean isEnabled() { 15 | return isEnabled && super.isEnabled(); 16 | } 17 | 18 | public void setPos(int x, int y) { 19 | if (oldX == -1 && oldY == -1) { 20 | this.oldX = this.x; 21 | this.oldY = this.y; 22 | } 23 | this.x = x; 24 | this.y = y; 25 | } 26 | 27 | public void resetPos() { 28 | if (oldX != -1 && oldY != -1) { 29 | this.x = oldX; 30 | this.y = oldY; 31 | } 32 | oldX = -1; 33 | oldY = -1; 34 | isEnabled = true; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SmallInv; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 4 | 5 | public class SmallInvConfig implements AbstractConfigFile { 6 | 7 | public boolean enabled = true; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SmallInv; 2 | 3 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 4 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 5 | import net.minecraft.client.option.KeyBinding; 6 | import net.minecraft.client.util.InputUtil; 7 | import net.minecraft.entity.player.PlayerEntity; 8 | import net.minecraft.item.ItemStack; 9 | import net.minecraft.util.Pair; 10 | import org.lwjgl.glfw.GLFW; 11 | 12 | import java.util.HashMap; 13 | 14 | public class SmallInvMod { 15 | 16 | public static String MOD_ID = "smallinv"; 17 | public static HashMap> SMALLINVSLOTS = new HashMap<>(); 18 | 19 | public static KeyBinding closeSmallInvKey; 20 | 21 | public static void onInitialize() { 22 | LEMClientHelperMod.configManager.registerFile(MOD_ID, new SmallInvConfig()); 23 | LEMClientHelperMod.configManager.load(MOD_ID); 24 | closeSmallInvKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(LEMClientHelperMod.MOD_ID + ".key.closesmallinv", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_I, "key.category." + LEMClientHelperMod.MOD_ID)); 25 | 26 | registerSmallSlot(5, 55, 9); 27 | registerSmallSlot(6, 55, 27); 28 | registerSmallSlot(7, 55, 45); 29 | registerSmallSlot(8, 55, 63); 30 | registerSmallSlot(45, 134, 63); 31 | registerSmallSlot(36, 8, 99); 32 | registerSmallSlot(37, 26, 99); 33 | registerSmallSlot(38, 44, 99); 34 | registerSmallSlot(39, 62, 99); 35 | registerSmallSlot(40, 80, 99); 36 | registerSmallSlot(41, 98, 99); 37 | registerSmallSlot(42, 116, 99); 38 | registerSmallSlot(43, 134, 99); 39 | registerSmallSlot(44, 152, 99); 40 | } 41 | 42 | public static SmallInvConfig getConfig() { 43 | return (SmallInvConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 44 | } 45 | 46 | public static boolean isSmallInv(PlayerEntity player) { 47 | //if (true) return true; // force enabling for testing 48 | if (!getConfig().enabled) return false; 49 | 50 | //give @p knowledge_book{display:{Name:'{"text":" "}'},SmallInv:1,CustomModelData:1} 51 | for (ItemStack itemStack : player.getInventory().main) { 52 | if (itemStack.hasNbt() && itemStack.getNbt().contains("SmallInv") && itemStack.getNbt().getInt("SmallInv") == 1) 53 | return true; 54 | } 55 | return false; 56 | } 57 | 58 | public static void tryMoveSlot(MovableSlot slot) { 59 | if (SMALLINVSLOTS.containsKey(slot.id)) { 60 | Pair pos = SMALLINVSLOTS.get(slot.id); 61 | slot.setPos(pos.getLeft(), pos.getRight()); 62 | slot.isEnabled = true; 63 | } else slot.isEnabled = false; 64 | } 65 | 66 | private static void registerSmallSlot(int id, int x, int y) { 67 | SMALLINVSLOTS.put(id, new Pair<>(x, y)); 68 | } 69 | 70 | public static boolean isKeybindPressed(int pressedKeyCode, boolean isMouse) { 71 | InputUtil.Key keycode = KeyBindingHelper.getBoundKeyOf(closeSmallInvKey); 72 | 73 | if (isMouse) { 74 | if (keycode.getCategory() != InputUtil.Type.MOUSE) return false; 75 | } else { 76 | if (keycode.getCategory() != InputUtil.Type.KEYSYM) return false; 77 | } 78 | return keycode.getCode() == pressedKeyCode; 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvPlayerInv.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SmallInv; 2 | 3 | public interface SmallInvPlayerInv { 4 | void setIsSmall(boolean small); 5 | 6 | boolean getIsSmall(); 7 | 8 | default boolean isSmallSupported() { 9 | return false; 10 | } 11 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SpectateSqueakerMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SpectateSqueaker; 2 | 3 | public class SpectateSqueakerMod { 4 | public static final String MOD_ID = "spectatesqueak"; 5 | 6 | public static void onInitialize() { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SpectateSqueakerNetworking.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.SpectateSqueaker; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 7 | import net.minecraft.network.PacketByteBuf; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class SpectateSqueakerNetworking { 11 | private static final Identifier SQUEAK_PACKET = new Identifier(SpectateSqueakerMod.MOD_ID, "squeak_packet"); 12 | 13 | @Environment(EnvType.CLIENT) 14 | public static void sendTakeEverythingPacket() { 15 | PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); 16 | ClientPlayNetworking.send(SQUEAK_PACKET, buf); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/LambdControlsCompat.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.TakeEverything; 2 | 3 | import eu.midnightdust.midnightcontrols.client.MidnightControlsClient; 4 | import eu.midnightdust.midnightcontrols.client.compat.CompatHandler; 5 | import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat; 6 | import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding; 7 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.lwjgl.glfw.GLFW; 10 | 11 | public class LambdControlsCompat implements CompatHandler { 12 | 13 | public static void register() { 14 | MidnightControlsCompat.registerCompatHandler(new LambdControlsCompat()); 15 | } 16 | 17 | public static boolean takeEverything() { 18 | TakeEverythingNetworking.sendTakeEverythingPacket(); 19 | return true; 20 | } 21 | 22 | 23 | @Override 24 | public void handle(@NotNull MidnightControlsClient mod) { 25 | new ButtonBinding.Builder(LEMClientHelperMod.MOD_ID + ".takeeverything") 26 | .category(ButtonBinding.INVENTORY_CATEGORY) 27 | .buttons(GLFW.GLFW_GAMEPAD_BUTTON_LEFT_THUMB) 28 | .action((client, action, value, buttonState) -> takeEverything()) 29 | .onlyInInventory() 30 | .register(); 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.TakeEverything; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 4 | import net.kyrptonaught.kyrptconfig.keybinding.CustomKeyBinding; 5 | 6 | public class TakeEverythingConfig implements AbstractConfigFile { 7 | 8 | public boolean enabled = true; 9 | 10 | public CustomKeyBinding keybinding = CustomKeyBinding.configDefault(TakeEverythingMod.MOD_ID, "key.keyboard.space"); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.TakeEverything; 2 | 3 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 4 | import net.kyrptonaught.kyrptconfig.config.NonConflicting.NonConflictingKeyBinding; 5 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 6 | import net.minecraft.client.option.KeyBinding; 7 | import net.minecraft.client.util.InputUtil; 8 | 9 | public class TakeEverythingMod { 10 | public static String MOD_ID = "take_everything"; 11 | 12 | public static KeyBinding takeEverythingKey; 13 | 14 | public static void onInitialize() { 15 | LEMClientHelperMod.configManager.registerFile(MOD_ID, new TakeEverythingConfig()); 16 | LEMClientHelperMod.configManager.load(MOD_ID); 17 | 18 | takeEverythingKey = KeyBindingHelper.registerKeyBinding(new NonConflictingKeyBinding( 19 | LEMClientHelperMod.MOD_ID + ".key.takeeverything", 20 | "key.category." + LEMClientHelperMod.MOD_ID, 21 | getConfig().keybinding, 22 | setKey -> LEMClientHelperMod.configManager.save(MOD_ID) 23 | )); 24 | } 25 | 26 | public static TakeEverythingConfig getConfig() { 27 | return (TakeEverythingConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 28 | } 29 | 30 | public static void registerControllerKeys() { 31 | LambdControlsCompat.register(); 32 | } 33 | 34 | public static boolean isKeybindPressed(int pressedKeyCode, InputUtil.Type type) { 35 | return getConfig().keybinding.matches(pressedKeyCode, type); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingNetworking.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.TakeEverything; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 7 | import net.minecraft.network.PacketByteBuf; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class TakeEverythingNetworking { 11 | private static final Identifier TAKE_EVERYTHING_PACKET = new Identifier("takeeverything", "take_everything_packet"); 12 | 13 | @Environment(EnvType.CLIENT) 14 | public static void sendTakeEverythingPacket() { 15 | if (TakeEverythingMod.getConfig().enabled) { 16 | PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); 17 | ClientPlayNetworking.send(TAKE_EVERYTHING_PACKET, buf); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/config/ArmorHudPreviewItem.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.config; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.screen.items.BooleanItem; 4 | import net.kyrptonaught.lemclienthelper.hud.ArmorHudRenderer; 5 | import net.minecraft.client.gui.DrawContext; 6 | import net.minecraft.text.Text; 7 | 8 | public class ArmorHudPreviewItem extends BooleanItem { 9 | public ArmorHudPreviewItem(Text name, Boolean value, Boolean defaultValue) { 10 | super(name, value, defaultValue); 11 | } 12 | 13 | @Override 14 | public void render2(DrawContext context, int x, int y, int mouseX, int mouseY, float delta) { 15 | super.render2(context, x, y, mouseX, mouseY, delta); 16 | if (value) { 17 | ArmorHudRenderer.onHudRenderDummy(context, 20, 1); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.config; 2 | 3 | import com.terraformersmc.modmenu.api.ConfigScreenFactory; 4 | import com.terraformersmc.modmenu.api.ModMenuApi; 5 | import net.kyrptonaught.kyrptconfig.config.screen.ConfigScreen; 6 | import net.kyrptonaught.kyrptconfig.config.screen.ConfigSection; 7 | import net.kyrptonaught.kyrptconfig.config.screen.items.BooleanItem; 8 | import net.kyrptonaught.kyrptconfig.config.screen.items.ButtonItem; 9 | import net.kyrptonaught.kyrptconfig.config.screen.items.KeybindItem; 10 | import net.kyrptonaught.kyrptconfig.config.screen.items.SubItem; 11 | import net.kyrptonaught.kyrptconfig.config.screen.items.number.FloatItem; 12 | import net.kyrptonaught.kyrptconfig.config.screen.items.number.IntegerItem; 13 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 14 | import net.kyrptonaught.lemclienthelper.ResourcePreloader.ResourcePreloaderConfig; 15 | import net.kyrptonaught.lemclienthelper.ResourcePreloader.ResourcePreloaderMod; 16 | import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsConfig; 17 | import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsMod; 18 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; 19 | import net.kyrptonaught.lemclienthelper.hud.HudConfig; 20 | import net.kyrptonaught.lemclienthelper.hud.HudMod; 21 | import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybind; 22 | import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsConfig; 23 | import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsMod; 24 | import net.minecraft.text.Text; 25 | 26 | public class ModMenuIntegration implements ModMenuApi { 27 | 28 | @Override 29 | public ConfigScreenFactory getModConfigScreenFactory() { 30 | return (screen) -> { 31 | ConfigScreen configScreen = new ConfigScreen(screen, Text.translatable("key.lemclienthelper.title")); 32 | configScreen.setSavingEvent(() -> { 33 | LEMClientHelperMod.configManager.save(); 34 | }); 35 | 36 | //Resource Preloader 37 | ResourcePreloaderConfig config = ResourcePreloaderMod.getConfig(); 38 | ConfigSection rplSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.resourcepreloader")); 39 | 40 | rplSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.toastcomplete"), config.toastComplete, true).setSaveConsumer(val -> config.toastComplete = val)); 41 | 42 | SubItem sub = new SubItem<>(Text.translatable("key.lemclienthelper.packdownloads"), true); 43 | 44 | rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.deletePacks")).setClickEvent(() -> { 45 | configScreen.save(); 46 | ResourcePreloaderMod.deletePacks(); 47 | ResourcePreloaderMod.getPackList(); 48 | addPacksToSub(sub); 49 | })); 50 | 51 | 52 | rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.previewList")).setClickEvent(() -> { 53 | configScreen.save(); 54 | ResourcePreloaderMod.getPackList(); 55 | addPacksToSub(sub); 56 | })); 57 | 58 | rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.startdownload")).setClickEvent(() -> { 59 | configScreen.save(); 60 | ResourcePreloaderMod.getPackList(); 61 | ResourcePreloaderMod.downloadPacks(); 62 | addPacksToSub(sub); 63 | })); 64 | 65 | rplSection.addConfigItem(sub); 66 | addPacksToSub(sub); 67 | 68 | //Server Configs 69 | ServerConfigsConfig serverConfig = ServerConfigsMod.getConfig(); 70 | ConfigSection serverConfigSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.serverconfig")); 71 | 72 | IntegerItem guiItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Text.translatable("key.lemclienthelper.serverconfig.guiscale"), serverConfig.guiScale, 0)); 73 | guiItem.setMinMax(0, 4); 74 | guiItem.setSaveConsumer(val -> serverConfig.guiScale = val); 75 | guiItem.setToolTipWithNewLine("key.lemclienthelper.serverconfig.guiscale.tooltip"); 76 | 77 | IntegerItem panItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Text.translatable("key.lemclienthelper.serverconfig.panscale"), serverConfig.panScale, 0)); 78 | panItem.setMinMax(0, 4); 79 | panItem.setSaveConsumer(val -> serverConfig.panScale = val); 80 | panItem.setToolTipWithNewLine("key.lemclienthelper.serverconfig.panscale.tooltip"); 81 | 82 | 83 | //Hud 84 | HudConfig clientGUI = HudMod.getConfig(); 85 | ConfigSection clientGUISection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.clientgui")); 86 | 87 | clientGUISection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.clientgui.enabled"), clientGUI.enabled, true).setSaveConsumer(val -> clientGUI.enabled = val)); 88 | clientGUISection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.clientgui.alwaysshow"), clientGUI.alwaysEnabled, false).setSaveConsumer(val -> clientGUI.alwaysEnabled = val)); 89 | 90 | FloatItem armorHudScale = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.armorscale"), clientGUI.armorHudScale, 1f)); 91 | armorHudScale.setMinMax(1f, 4f); 92 | armorHudScale.setSaveConsumer(val -> clientGUI.armorHudScale = val); 93 | armorHudScale.setToolTipWithNewLine("key.lemclienthelper.clientgui.armorscale.tooltip"); 94 | 95 | FloatItem armorHudXOffset = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.xOffset"), clientGUI.xOffset, 20f)); 96 | armorHudXOffset.setMinMax(0f, 100f); 97 | armorHudXOffset.setSaveConsumer(val -> clientGUI.xOffset = val); 98 | armorHudXOffset.setToolTipWithNewLine("key.lemclienthelper.clientgui.xOffset.tooltip"); 99 | 100 | FloatItem armorHudTransparency = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.transparency"), clientGUI.transparency, .75f)); 101 | armorHudTransparency.setMinMax(0f, 1f); 102 | armorHudTransparency.setSaveConsumer(val -> clientGUI.transparency = val); 103 | armorHudTransparency.setToolTipWithNewLine("key.lemclienthelper.clientgui.transparency.tooltip"); 104 | 105 | //clientGUISection.addConfigItem(new ArmorHudPreviewItem(Text.translatable("key.lemclienthelper.clientgui.displaypreview"), clientGUI.enabled, false)); 106 | 107 | 108 | //Small Inv 109 | ConfigSection smallInvSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.smallinv")); 110 | smallInvSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.smallinv.enabled"), SmallInvMod.getConfig().enabled, true).setSaveConsumer(val -> SmallInvMod.getConfig().enabled = val)); 111 | 112 | 113 | //Synced Keybinds 114 | SyncedKeybindsConfig syncedKeybindsConfig = SyncedKeybindsMod.getConfig(); 115 | ConfigSection syncedKeybinds = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.syncedkeybinds")); 116 | 117 | SubItem syncedKeybindItems = new SubItem<>(Text.translatable("key.lemclienthelper.syncedkeys"), true); 118 | syncedKeybindItems.setToolTipWithNewLine("key.lemclienthelper.syncedkeys.tooltip"); 119 | syncedKeybinds.addConfigItem(syncedKeybindItems); 120 | 121 | for (String id : syncedKeybindsConfig.keybinds.keySet()) { 122 | SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem = syncedKeybindsConfig.keybinds.get(id); 123 | KeybindItem keybindItem = (KeybindItem) new KeybindItem(Text.translatable("lch.key.sync." + id.replace(":", ".")), keybindConfigItem.keybinding, keybindConfigItem.defaultKeybinding).setSaveConsumer(val -> { 124 | keybindConfigItem.keybinding = val; 125 | SyncedKeybind syncedKeybind = SyncedKeybindsMod.syncedKeybindList.get(id); 126 | if (syncedKeybind != null) 127 | syncedKeybind.updateBoundKey(val); 128 | }); 129 | syncedKeybindItems.addConfigItem(keybindItem); 130 | } 131 | 132 | return configScreen; 133 | }; 134 | } 135 | 136 | public void addPacksToSub(SubItem sub) { 137 | if (ResourcePreloaderMod.allPacks != null && ResourcePreloaderMod.allPacks.packs.size() > 0) { 138 | sub.clearConfigItems(); 139 | ResourcePreloaderMod.allPacks.packs.forEach(rpOption -> { 140 | sub.addConfigItem(new ResourcepackDownloadItem(rpOption).setToolTip(Text.literal(rpOption.url))); 141 | }); 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/config/ResourcepackDownloadItem.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.config; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.screen.items.ConfigItem; 4 | import net.kyrptonaught.lemclienthelper.ResourcePreloader.AllPacks; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.font.TextRenderer; 7 | import net.minecraft.client.gui.DrawContext; 8 | import net.minecraft.text.Text; 9 | 10 | public class ResourcepackDownloadItem extends ConfigItem { 11 | private final AllPacks.RPOption rpOption; 12 | 13 | public ResourcepackDownloadItem(AllPacks.RPOption option) { 14 | super(Text.literal(option.packname), null, null); 15 | this.rpOption = option; 16 | } 17 | 18 | @Override 19 | public int getContentSize() { 20 | return 2; 21 | } 22 | 23 | @Override 24 | public void render(DrawContext context, int x, int y, int mouseX, int mouseY, float delta) { 25 | super.render(context, x, y, mouseX, mouseY, delta); 26 | TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; 27 | 28 | if (rpOption.status != null) { 29 | int titleX = MinecraftClient.getInstance().getWindow().getScaledWidth() - 90; 30 | 31 | if (rpOption.status2 == null) { 32 | context.drawCenteredTextWithShadow(textRenderer, rpOption.status, titleX, y + 10 - 4, 16777215); 33 | } else { 34 | //Text task = (Text.literal("")).append(progressListener.task).append(" " + progressListener.progress + "%"); 35 | 36 | context.drawCenteredTextWithShadow(textRenderer, rpOption.status, titleX, y + 2, 16777215); 37 | context.drawCenteredTextWithShadow(textRenderer, rpOption.status2, titleX, y + 11, 16777215); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.customWorldBorder; 2 | 3 | import net.minecraft.util.function.BooleanBiFunction; 4 | import net.minecraft.util.shape.VoxelShape; 5 | import net.minecraft.util.shape.VoxelShapes; 6 | import net.minecraft.world.border.WorldBorder; 7 | import net.minecraft.world.border.WorldBorderStage; 8 | 9 | public class CustomWorldBorderArea implements WorldBorder.Area { 10 | private final WorldBorder worldBorder; 11 | private final double xSize, zSize; 12 | 13 | public CustomWorldBorderArea(WorldBorder worldBorder, double xSize, double zSize) { 14 | this.worldBorder = worldBorder; 15 | this.xSize = xSize; 16 | this.zSize = zSize; 17 | } 18 | 19 | 20 | @Override 21 | public double getBoundWest() { 22 | return worldBorder.getCenterX() - xSize; 23 | } 24 | 25 | @Override 26 | public double getBoundEast() { 27 | return worldBorder.getCenterX() + xSize; 28 | } 29 | 30 | @Override 31 | public double getBoundNorth() { 32 | return worldBorder.getCenterZ() - zSize; 33 | } 34 | 35 | @Override 36 | public double getBoundSouth() { 37 | return worldBorder.getCenterZ() + zSize; 38 | } 39 | 40 | @Override 41 | public double getSize() { 42 | return Math.max(xSize, zSize); 43 | } 44 | 45 | @Override 46 | public double getShrinkingSpeed() { 47 | return 0; 48 | } 49 | 50 | @Override 51 | public long getSizeLerpTime() { 52 | return 0; 53 | } 54 | 55 | @Override 56 | public double getSizeLerpTarget() { 57 | return 0; 58 | } 59 | 60 | @Override 61 | public WorldBorderStage getStage() { 62 | return WorldBorderStage.STATIONARY; 63 | } 64 | 65 | @Override 66 | public void onMaxRadiusChanged() { 67 | } 68 | 69 | @Override 70 | public void onCenterChanged() { 71 | } 72 | 73 | @Override 74 | public WorldBorder.Area getAreaInstance() { 75 | return this; 76 | } 77 | 78 | @Override 79 | public VoxelShape asVoxelShape() { 80 | return VoxelShapes.combineAndSimplify(VoxelShapes.UNBOUNDED, VoxelShapes.cuboid(Math.floor(this.getBoundWest()), Double.NEGATIVE_INFINITY, Math.floor(this.getBoundNorth()), Math.ceil(this.getBoundEast()), Double.POSITIVE_INFINITY, Math.ceil(this.getBoundSouth())), BooleanBiFunction.ONLY_FIRST); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.customWorldBorder; 2 | 3 | public class CustomWorldBorderMod { 4 | 5 | public static void onInitialize() { 6 | CustomWorldBorderNetworking.registerReceive(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderNetworking.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.customWorldBorder; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 7 | import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; 8 | import net.kyrptonaught.lemclienthelper.customWorldBorder.duckInterface.CustomWorldBorder; 9 | import net.minecraft.network.PacketByteBuf; 10 | import net.minecraft.server.network.ServerPlayerEntity; 11 | import net.minecraft.util.Identifier; 12 | 13 | public class CustomWorldBorderNetworking { 14 | public static final Identifier CUSTOM_BORDER_PACKET = new Identifier("customworldborder", "customborder"); 15 | 16 | public static void sendCustomWorldBorderPacket(ServerPlayerEntity player, double xCenter, double zCenter, double xSize, double zSize) { 17 | PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); 18 | buf.writeDouble(xCenter); 19 | buf.writeDouble(zCenter); 20 | buf.writeDouble(xSize); 21 | buf.writeDouble(zSize); 22 | 23 | ServerPlayNetworking.send(player, CUSTOM_BORDER_PACKET, buf); 24 | } 25 | 26 | @Environment(EnvType.CLIENT) 27 | public static void registerReceive() { 28 | ClientPlayNetworking.registerGlobalReceiver(CUSTOM_BORDER_PACKET, (client, handler, packet, sender) -> { 29 | double xCenter = packet.readDouble(); 30 | double zCenter = packet.readDouble(); 31 | double xSize = packet.readDouble(); 32 | double zSize = packet.readDouble(); 33 | client.execute(() -> ((CustomWorldBorder) client.world.getWorldBorder()).setShape(xCenter, zCenter, xSize, zSize)); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/duckInterface/CustomWorldBorder.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.customWorldBorder.duckInterface; 2 | 3 | public interface CustomWorldBorder { 4 | 5 | void setShape(double xCenter, double zCenter, double xSize, double zSize); 6 | 7 | void setShape(double xCenter, double zCenter, double size); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudRenderer.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.hud; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.gui.DrawContext; 6 | import net.minecraft.client.render.*; 7 | import net.minecraft.item.ItemStack; 8 | import net.minecraft.item.Items; 9 | import net.minecraft.util.Identifier; 10 | import org.joml.Matrix4f; 11 | 12 | import java.util.List; 13 | 14 | public class ArmorHudRenderer { 15 | private static final Identifier[] EMPTY_SLOTS = new Identifier[]{ 16 | new Identifier("minecraft", "textures/item/empty_armor_slot_boots.png"), 17 | new Identifier("minecraft", "textures/item/empty_armor_slot_leggings.png"), 18 | new Identifier("minecraft", "textures/item/empty_armor_slot_chestplate.png"), 19 | new Identifier("minecraft", "textures/item/empty_armor_slot_helmet.png") 20 | }; 21 | 22 | public static void onHudRender(DrawContext context, float v) { 23 | MinecraftClient client = MinecraftClient.getInstance(); 24 | //HudMod.SHOULD_RENDER_ARMOR = true; 25 | if (client.player != null && HudMod.shouldDisplay()) { 26 | int height = client.getWindow().getScaledHeight(); 27 | 28 | context.getMatrices().push(); 29 | context.getMatrices().translate(HudMod.getConfig().xOffset, height / 2f, 0); 30 | context.getMatrices().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale, 1f); 31 | context.getMatrices().translate(0, -32, 0); 32 | context.setShaderColor(1f, 1f, 1f, HudMod.getConfig().transparency); 33 | 34 | for (int i = 0; i < 4; i++) { 35 | ItemStack armorStack = client.player.getInventory().getArmorStack(i); 36 | int y = 16 * (3 - i); 37 | if (armorStack.isEmpty()) { 38 | draw(context, EMPTY_SLOTS[i], 0, y); 39 | } else { 40 | context.drawItem(armorStack, 0, y); 41 | context.drawItemInSlot(client.textRenderer, armorStack, 0, y); 42 | } 43 | } 44 | context.setShaderColor(1f, 1f, 1f, 1f); 45 | context.getMatrices().pop(); 46 | } 47 | } 48 | 49 | public static void onHudRenderDummy(DrawContext context, float xOffset, float scale) { 50 | MinecraftClient client = MinecraftClient.getInstance(); 51 | int height = client.getWindow().getScaledHeight(); 52 | 53 | context.getMatrices().push(); 54 | context.getMatrices().translate(xOffset, height / 2f, 0); 55 | context.getMatrices().scale(scale, scale, 1f); 56 | context.getMatrices().translate(0, -32, 0); 57 | context.setShaderColor(1f, 1f, 1f, HudMod.getConfig().transparency); 58 | 59 | List armors = List.of(Items.GOLDEN_HELMET.getDefaultStack(), ItemStack.EMPTY, Items.GOLDEN_LEGGINGS.getDefaultStack(), Items.GOLDEN_BOOTS.getDefaultStack()); 60 | 61 | for (int i = 0; i < 4; i++) { 62 | ItemStack armorStack = armors.get(i); 63 | int y = 16 * (3 - i); 64 | if (armorStack.isEmpty()) { 65 | draw(context, EMPTY_SLOTS[i], 0, y); 66 | } else { 67 | context.drawItem(armorStack, 0, y); 68 | context.drawItemInSlot(client.textRenderer, armorStack, 0, y); 69 | } 70 | } 71 | context.setShaderColor(1f, 1f, 1f, 1f); 72 | context.getMatrices().pop(); 73 | } 74 | 75 | private static void draw(DrawContext context, Identifier texture, float x, float y) { 76 | RenderSystem.setShaderTexture(0, texture); 77 | RenderSystem.setShader(GameRenderer::getPositionColorTexProgram); 78 | RenderSystem.enableBlend(); 79 | Matrix4f matrix4f = context.getMatrices().peek().getPositionMatrix(); 80 | BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); 81 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE); 82 | bufferBuilder.vertex(matrix4f, x, y, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f).next(); 83 | bufferBuilder.vertex(matrix4f, x, y + 16, 0f).color(1, 1f, 1f, 1f).texture(0f, 1f).next(); 84 | bufferBuilder.vertex(matrix4f, x + 16, y + 16, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f).next(); 85 | bufferBuilder.vertex(matrix4f, x + 16, y, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f).next(); 86 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); 87 | RenderSystem.disableBlend(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.hud; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 4 | 5 | public class HudConfig implements AbstractConfigFile { 6 | public boolean enabled = true; 7 | 8 | public boolean alwaysEnabled = false; 9 | 10 | public float armorHudScale = 1; 11 | 12 | public float xOffset = 20; 13 | 14 | public float transparency =.75f; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.hud; 2 | 3 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; 4 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 5 | import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; 6 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 7 | import net.minecraft.util.Identifier; 8 | 9 | public class HudMod { 10 | public static String MOD_ID = "hud"; 11 | 12 | private static final Identifier ARMOR_HUD_ENABLE = new Identifier("armorhud", "armor_hud_render_enable"); 13 | private static final Identifier ARMOR_HUD_DISABLE = new Identifier("armorhud", "armor_hud_render_disable"); 14 | 15 | public static boolean SHOULD_RENDER_ARMOR = false; 16 | 17 | 18 | public static void onInitialize() { 19 | LEMClientHelperMod.configManager.registerFile(MOD_ID, new HudConfig()); 20 | LEMClientHelperMod.configManager.load(MOD_ID); 21 | //register hud's here 22 | HudRenderCallback.EVENT.register(ArmorHudRenderer::onHudRender); 23 | 24 | ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_ARMOR = false); 25 | 26 | ClientPlayNetworking.registerGlobalReceiver(ARMOR_HUD_ENABLE, (client, handler, buf, responseSender) -> SHOULD_RENDER_ARMOR = true); 27 | ClientPlayNetworking.registerGlobalReceiver(ARMOR_HUD_DISABLE, (client, handler, buf, responseSender) -> SHOULD_RENDER_ARMOR = false); 28 | } 29 | 30 | public static boolean shouldDisplay() { 31 | return getConfig().alwaysEnabled || SHOULD_RENDER_ARMOR; 32 | } 33 | 34 | public static HudConfig getConfig() { 35 | return (HudConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/ResourcePreloader/ClientBuiltInResourcePackProviderMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.ResourcePreloader; 2 | 3 | import net.minecraft.util.Downloader; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(Downloader.class) 9 | public class ClientBuiltInResourcePackProviderMixin { 10 | 11 | @ModifyConstant(method = "", constant = @Constant(intValue = 20)) 12 | private int dontDeleteLEMPacks(int constant) { 13 | return 30; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/HandledScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv; 2 | 3 | import net.kyrptonaught.lemclienthelper.SmallInv.MovableSlot; 4 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; 5 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; 8 | import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; 9 | import net.minecraft.client.gui.screen.ingame.HandledScreen; 10 | import net.minecraft.client.gui.screen.ingame.InventoryScreen; 11 | import net.minecraft.screen.GenericContainerScreenHandler; 12 | import net.minecraft.screen.PlayerScreenHandler; 13 | import net.minecraft.screen.ScreenHandler; 14 | import net.minecraft.text.Text; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.Shadow; 17 | import org.spongepowered.asm.mixin.injection.At; 18 | import org.spongepowered.asm.mixin.injection.Inject; 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 20 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 21 | 22 | @Mixin(HandledScreen.class) 23 | public abstract class HandledScreenMixin extends Screen implements SmallInvPlayerInv { 24 | 25 | @Shadow 26 | protected int playerInventoryTitleY; 27 | 28 | @Shadow 29 | public abstract ScreenHandler getScreenHandler(); 30 | 31 | @Shadow 32 | protected int backgroundHeight; 33 | 34 | protected HandledScreenMixin(Text title) { 35 | super(title); 36 | } 37 | 38 | @Inject(method = "init", at = @At("RETURN")) 39 | public void setPlayerTitleY(CallbackInfo ci) { 40 | if (getIsSmall()) 41 | if (((Object) this instanceof GenericContainerScreen)) this.playerInventoryTitleY += 3; 42 | else this.playerInventoryTitleY += 5; 43 | } 44 | 45 | @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) 46 | public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { 47 | if (SmallInvMod.isKeybindPressed(keyCode, false)) { 48 | setIsSmall(false); 49 | cir.setReturnValue(true); 50 | } 51 | } 52 | 53 | @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) 54 | public void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { 55 | if (SmallInvMod.isKeybindPressed(button, true)) { 56 | setIsSmall(false); 57 | cir.setReturnValue(true); 58 | } 59 | } 60 | 61 | @Inject(method = "isClickOutsideBounds", at = @At("HEAD"), cancellable = true) 62 | public void isClickOutsideSmallBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable cir) { 63 | if (getIsSmall()) { 64 | HandledScreen handledScreen = (HandledScreen) (Object) this; 65 | if (!(handledScreen instanceof InventoryScreen) && 66 | !(handledScreen instanceof CreativeInventoryScreen)) 67 | if (mouseY >= (top + (this.backgroundHeight - 85 + 30))) cir.setReturnValue(true); 68 | } 69 | } 70 | 71 | boolean isSmall = false; 72 | 73 | @Override 74 | public boolean getIsSmall() { 75 | return isSmall; 76 | } 77 | 78 | @Override 79 | public void setIsSmall(boolean small) { 80 | if (!this.isSmallSupported()) return; 81 | 82 | if (getIsSmall() && !small) playerInventoryTitleY -= 4; 83 | isSmall = small; 84 | int setY = -1; 85 | ScreenHandler handler = getScreenHandler(); 86 | if (handler instanceof CreativeInventoryScreen.CreativeScreenHandler) return; 87 | for (int i = 0; i < handler.slots.size(); i++) { 88 | if (handler.slots.get(i) instanceof MovableSlot slot) 89 | if (handler instanceof PlayerScreenHandler) { 90 | if (small) 91 | SmallInvMod.tryMoveSlot(slot); 92 | else slot.resetPos(); 93 | } else { 94 | if (small) { 95 | if (setY == -1) { 96 | setY = slot.y + 4; 97 | if (handler instanceof GenericContainerScreenHandler) setY--; 98 | } 99 | if (i >= handler.slots.size() - 9) { 100 | slot.setPos(slot.x, setY); 101 | slot.isEnabled = true; 102 | } else slot.isEnabled = false; 103 | } else slot.resetPos(); 104 | } 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MidnightControlsMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv; 2 | 3 | import eu.midnightdust.midnightcontrols.client.controller.InputHandlers; 4 | import net.minecraft.screen.slot.Slot; 5 | import org.aperlambda.lambdacommon.utils.Pair; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Pseudo; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 11 | 12 | @Pseudo 13 | @Mixin(InputHandlers.class) 14 | public class MidnightControlsMixin { 15 | 16 | @Inject(method = "lambda$handleInventorySlotPad$17", at = @At(value = "HEAD"), cancellable = true) 17 | private static void skipDisabledSlots(int guiLeft, int guiTop, double mouseX, double mouseY, Slot mouseSlot, int direction, Pair entry, CallbackInfoReturnable cir) { 18 | if (!entry.key.isEnabled()) cir.setReturnValue(false); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv; 2 | 3 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; 4 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.screen.ingame.HandledScreen; 8 | import net.minecraft.client.network.ClientPlayerEntity; 9 | import org.jetbrains.annotations.Nullable; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(MinecraftClient.class) 17 | public class MinecraftClientMixin { 18 | 19 | @Shadow 20 | @Nullable 21 | public ClientPlayerEntity player; 22 | 23 | @Inject(method = "setScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", ordinal = 2)) 24 | public void attemptOpenSmallInv(Screen screen, CallbackInfo ci) { 25 | if (screen instanceof HandledScreen handledScreen) { 26 | ((SmallInvPlayerInv) handledScreen).setIsSmall(SmallInvMod.isSmallInv(player)); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/ScreenHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv; 2 | 3 | import net.kyrptonaught.lemclienthelper.SmallInv.MovableSlot; 4 | import net.minecraft.entity.player.PlayerInventory; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.screen.PlayerScreenHandler; 7 | import net.minecraft.screen.ScreenHandler; 8 | import net.minecraft.screen.slot.Slot; 9 | import net.minecraft.util.collection.DefaultedList; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.Unique; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | @Mixin(ScreenHandler.class) 19 | public abstract class ScreenHandlerMixin { 20 | 21 | @Shadow 22 | @Final 23 | public DefaultedList slots; 24 | 25 | @Shadow 26 | @Final 27 | private DefaultedList trackedStacks; 28 | 29 | @Shadow 30 | @Final 31 | private DefaultedList previousTrackedStacks; 32 | 33 | @Inject(method = "addSlot", at = @At("HEAD"), cancellable = true) 34 | protected void addSlot(Slot slot, CallbackInfoReturnable cir) { 35 | if (isPlayerScreen() || slot.inventory instanceof PlayerInventory) { 36 | slot = new MovableSlot(slot); 37 | slot.id = this.slots.size(); 38 | this.slots.add(slot); 39 | this.trackedStacks.add(ItemStack.EMPTY); 40 | this.previousTrackedStacks.add(ItemStack.EMPTY); 41 | cir.setReturnValue(slot); 42 | } 43 | } 44 | 45 | @Unique 46 | private boolean isPlayerScreen() { 47 | //this works but IDEA big mad 48 | return (Object) this instanceof PlayerScreenHandler; 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/GenericContainerScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; 2 | 3 | 4 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; 5 | import net.minecraft.client.gui.DrawContext; 6 | import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; 7 | import net.minecraft.client.gui.screen.ingame.HandledScreen; 8 | import net.minecraft.entity.player.PlayerInventory; 9 | import net.minecraft.screen.GenericContainerScreenHandler; 10 | import net.minecraft.screen.ScreenHandler; 11 | import net.minecraft.text.Text; 12 | import net.minecraft.util.Identifier; 13 | import org.spongepowered.asm.mixin.Final; 14 | import org.spongepowered.asm.mixin.Mixin; 15 | import org.spongepowered.asm.mixin.Shadow; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Redirect; 18 | 19 | @Mixin(GenericContainerScreen.class) 20 | public abstract class GenericContainerScreenMixin extends HandledScreen implements SmallInvPlayerInv { 21 | @Shadow 22 | @Final 23 | private int rows; 24 | 25 | public GenericContainerScreenMixin(ScreenHandler handler, PlayerInventory inventory, Text title) { 26 | super((GenericContainerScreenHandler) handler, inventory, title); 27 | } 28 | 29 | @Redirect(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 1)) 30 | public void drawSmallInv(DrawContext instance, Identifier texture, int x, int y, int u, int v, int width, int height) { 31 | if (getIsSmall()) { 32 | int j = (this.height - this.backgroundHeight) / 2; 33 | instance.drawTexture(texture, x, j + this.rows * 18 + 17, 0, 126, this.backgroundWidth, 13); 34 | instance.drawTexture(texture, x, j + (this.rows * 18 + 17) + 12, 0, 193, this.backgroundWidth, 29); 35 | } else instance.drawTexture(texture, x, y, u, v, width, height); 36 | } 37 | 38 | @Override 39 | public boolean isSmallSupported() { 40 | return true; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/InventoryScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 5 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; 6 | import net.minecraft.client.gui.DrawContext; 7 | import net.minecraft.client.gui.Element; 8 | import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; 9 | import net.minecraft.client.gui.screen.ingame.InventoryScreen; 10 | import net.minecraft.client.gui.widget.TexturedButtonWidget; 11 | import net.minecraft.client.render.GameRenderer; 12 | import net.minecraft.entity.player.PlayerInventory; 13 | import net.minecraft.screen.PlayerScreenHandler; 14 | import net.minecraft.text.Text; 15 | import net.minecraft.util.Identifier; 16 | import org.spongepowered.asm.mixin.Mixin; 17 | import org.spongepowered.asm.mixin.Shadow; 18 | import org.spongepowered.asm.mixin.injection.At; 19 | import org.spongepowered.asm.mixin.injection.Inject; 20 | import org.spongepowered.asm.mixin.injection.ModifyArg; 21 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 22 | 23 | @Mixin(InventoryScreen.class) 24 | public abstract class InventoryScreenMixin extends AbstractInventoryScreen implements SmallInvPlayerInv { 25 | @Shadow 26 | private float mouseX; 27 | @Shadow 28 | private float mouseY; 29 | private static final Identifier TEXTURE = new Identifier(LEMClientHelperMod.MOD_ID, "textures/gui/legacy_inventory.png"); 30 | 31 | private static TexturedButtonWidget bookWidget; 32 | 33 | public InventoryScreenMixin(PlayerScreenHandler screenHandler, PlayerInventory playerInventory, Text text) { 34 | super(screenHandler, playerInventory, text); 35 | } 36 | 37 | @ModifyArg(method = "init", at = @At(target = "Lnet/minecraft/client/gui/screen/ingame/InventoryScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;", value = "INVOKE")) 38 | public Element fkRecipeBook(Element element) { 39 | if (element instanceof TexturedButtonWidget button) 40 | bookWidget = button; 41 | return element; 42 | } 43 | 44 | @Inject(method = "drawForeground", at = @At("HEAD"), cancellable = true) 45 | public void smallInvTitle(DrawContext context, int mouseX, int mouseY, CallbackInfo ci) { 46 | if (getIsSmall()) { 47 | context.drawText(this.textRenderer, Text.translatable("container.inventory"), 6, 86, 0x404040, false); 48 | ci.cancel(); 49 | } 50 | } 51 | 52 | @Inject(method = "drawBackground", at = @At("HEAD"), cancellable = true) 53 | public void smallInv(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) { 54 | if (getIsSmall()) { 55 | this.backgroundHeight = 124; 56 | bookWidget.visible = false; 57 | RenderSystem.setShader(GameRenderer::getPositionTexProgram); 58 | RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); 59 | context.drawTexture(TEXTURE, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight, this.backgroundWidth, this.backgroundHeight); 60 | InventoryScreen.drawEntity(context, x + 26 + 52, y + 8 + 2, x + 75 + 52, y + 78 + 2, 30, 0.0625f, this.mouseX, this.mouseY, this.client.player); 61 | ci.cancel(); 62 | } else { 63 | this.backgroundHeight = 166; 64 | bookWidget.visible = true; 65 | } 66 | } 67 | 68 | @Override 69 | public boolean isSmallSupported() { 70 | return true; 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/MultipleScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; 2 | 3 | import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.screen.ingame.*; 6 | import net.minecraft.util.Identifier; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(value = { 12 | BeaconScreen.class, 13 | BrewingStandScreen.class, 14 | CartographyTableScreen.class, 15 | CraftingScreen.class, 16 | EnchantmentScreen.class, 17 | ForgingScreen.class, 18 | AbstractFurnaceScreen.class, 19 | Generic3x3ContainerScreen.class, 20 | GrindstoneScreen.class, 21 | HopperScreen.class, 22 | HorseScreen.class, 23 | LoomScreen.class, 24 | ShulkerBoxScreen.class, 25 | StonecutterScreen.class 26 | }) 27 | public abstract class MultipleScreenMixin implements SmallInvPlayerInv { 28 | 29 | @Redirect(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 0)) 30 | public void drawSmallInv(DrawContext instance, Identifier texture, int x, int y, int u, int v, int width, int height) { 31 | if (getIsSmall()) { 32 | 33 | if ((HandledScreen) (Object) this instanceof ShulkerBoxScreen) height--; 34 | instance.drawTexture(texture, x, y, 0, 0, width, height - 83); //shrink orig texture 35 | 36 | instance.drawTexture(texture, x, y + (height - 83) - 1, 0, height - 30, width, 30);//draw hotbar 37 | instance.drawTexture(texture, x, y + (height - 83) - 1, 0, height - 86, width, 2); //add extra separator 38 | } else instance.drawTexture(texture, x, y, u, v, width, height); 39 | } 40 | 41 | @Override 42 | public boolean isSmallSupported() { 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SpectateSquaker/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SpectateSquaker; 2 | 3 | import net.kyrptonaught.lemclienthelper.SpectateSqueaker.SpectateSqueakerNetworking; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.network.ClientPlayerEntity; 6 | import net.minecraft.client.option.GameOptions; 7 | import net.minecraft.entity.Entity; 8 | import org.jetbrains.annotations.Nullable; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(MinecraftClient.class) 17 | public abstract class MinecraftClientMixin { 18 | 19 | @Shadow 20 | @Nullable 21 | public ClientPlayerEntity player; 22 | 23 | @Shadow 24 | public abstract @Nullable Entity getCameraEntity(); 25 | 26 | @Shadow 27 | @Final 28 | public GameOptions options; 29 | 30 | @Inject(method = "handleInputEvents", at = @At(value = "TAIL")) 31 | public void trySqueak(CallbackInfo ci) { 32 | if (player != null && player.isSpectator() && (this.player.equals(getCameraEntity())) && options.attackKey.isPressed()) 33 | SpectateSqueakerNetworking.sendTakeEverythingPacket(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/SyncedKeybinds/GameOptionsMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.SyncedKeybinds; 2 | 3 | import net.kyrptonaught.lemclienthelper.syncedKeybinds.GameOptionKeyExpander; 4 | import net.minecraft.client.option.GameOptions; 5 | import net.minecraft.client.option.KeyBinding; 6 | import org.spongepowered.asm.mixin.Final; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Mutable; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | @Mixin(GameOptions.class) 16 | public class GameOptionsMixin implements GameOptionKeyExpander { 17 | 18 | @Mutable 19 | @Final 20 | @Shadow 21 | public KeyBinding[] allKeys; 22 | 23 | @Override 24 | public void addSyncedKeybinds(KeyBinding newKeybinding) { 25 | allKeys = Arrays.copyOf(allKeys, allKeys.length + 1); 26 | 27 | allKeys[allKeys.length - 1] = newKeybinding; 28 | } 29 | 30 | @Override 31 | public void removeSyncedKeybinds(KeyBinding newKeybinding) { 32 | List bindings = new ArrayList<>(List.of(allKeys)); 33 | bindings.remove(newKeybinding); 34 | allKeys = bindings.toArray(new KeyBinding[0]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/TakeEverything/ScreenHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.TakeEverything; 2 | 3 | import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingMod; 4 | import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingNetworking; 5 | import net.minecraft.client.gui.screen.ingame.HandledScreen; 6 | import net.minecraft.client.util.InputUtil; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 11 | 12 | @Mixin(HandledScreen.class) 13 | public abstract class ScreenHandlerMixin { 14 | 15 | @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) 16 | private void lephelper$mouseClicked(double x, double y, int button, CallbackInfoReturnable callbackInfoReturnable) { 17 | if (TakeEverythingMod.isKeybindPressed(button, InputUtil.Type.MOUSE)) { 18 | TakeEverythingNetworking.sendTakeEverythingPacket(); 19 | callbackInfoReturnable.setReturnValue(true); 20 | } 21 | } 22 | 23 | @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) 24 | private void lebhelper$keyPressed(int keycode, int scancode, int modifiers, CallbackInfoReturnable callbackInfoReturnable) { 25 | if (TakeEverythingMod.isKeybindPressed(keycode, InputUtil.Type.KEYSYM)) { 26 | TakeEverythingNetworking.sendTakeEverythingPacket(); 27 | callbackInfoReturnable.setReturnValue(true); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/bookGui/BookScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.bookGui; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.screen.ingame.BookScreen; 5 | import net.minecraft.text.Style; 6 | import org.lwjgl.glfw.GLFW; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Unique; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | 14 | @Mixin(BookScreen.class) 15 | public class BookScreenMixin { 16 | 17 | @Unique 18 | private static Double mouseX, mouseY; 19 | 20 | @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/BookScreen;closeScreen()V")) 21 | public void saveMouse(Style style, CallbackInfoReturnable cir) { 22 | mouseX = MinecraftClient.getInstance().mouse.getX(); 23 | mouseY = MinecraftClient.getInstance().mouse.getY(); 24 | } 25 | 26 | @Inject(method = "init", at = @At(value = "HEAD")) 27 | public void loadMouse(CallbackInfo ci) { 28 | if (mouseX != null && mouseY != null) { 29 | GLFW.glfwSetCursorPos(MinecraftClient.getInstance().getWindow().getHandle(), mouseX, mouseY); 30 | mouseX = null; 31 | mouseY = null; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/mixin/customWorldBorder/WorldBorderMixin.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.mixin.customWorldBorder; 2 | 3 | import net.kyrptonaught.lemclienthelper.customWorldBorder.CustomWorldBorderArea; 4 | import net.kyrptonaught.lemclienthelper.customWorldBorder.duckInterface.CustomWorldBorder; 5 | import net.minecraft.world.border.WorldBorder; 6 | import net.minecraft.world.border.WorldBorderListener; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(WorldBorder.class) 14 | public abstract class WorldBorderMixin implements CustomWorldBorder { 15 | 16 | @Shadow 17 | private WorldBorder.Area area; 18 | 19 | @Shadow 20 | public abstract void setCenter(double x, double z); 21 | 22 | @Shadow 23 | public abstract void setSize(double size); 24 | 25 | @Override 26 | public void setShape(double xCenter, double zCenter, double xSize, double zSize) { 27 | setCenter(xCenter, zCenter); 28 | this.area = new CustomWorldBorderArea((WorldBorder) (Object) this, xSize, zSize); 29 | } 30 | 31 | @Override 32 | public void setShape(double xCenter, double zCenter, double size) { 33 | setCenter(xCenter, zCenter); 34 | setSize(size); 35 | } 36 | 37 | @Inject(method = "addListener", at = @At("HEAD"), cancellable = true) 38 | public void noListeners(WorldBorderListener listener, CallbackInfo ci) { 39 | ci.cancel(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/GameOptionKeyExpander.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.syncedKeybinds; 2 | 3 | import net.minecraft.client.option.KeyBinding; 4 | 5 | public interface GameOptionKeyExpander { 6 | 7 | void addSyncedKeybinds(KeyBinding newKeybinding); 8 | 9 | void removeSyncedKeybinds(KeyBinding newKeybinding); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybind.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.syncedKeybinds; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.NonConflicting.NonConflictingKeyBinding; 4 | import net.kyrptonaught.kyrptconfig.keybinding.CustomKeyBinding; 5 | import net.kyrptonaught.kyrptconfig.keybinding.DisplayOnlyKeyBind; 6 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 7 | import net.minecraft.client.option.KeyBinding; 8 | 9 | public class SyncedKeybind { 10 | public String ID; 11 | private final CustomKeyBinding keyBinding; 12 | private KeyBinding vanillaBind; 13 | 14 | public SyncedKeybind(String id, SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem) { 15 | this.ID = id; 16 | keyBinding = CustomKeyBinding.configDefault(SyncedKeybindsMod.MOD_ID, keybindConfigItem.defaultKeybinding); 17 | keyBinding.setRaw(keybindConfigItem.keybinding); 18 | } 19 | 20 | public boolean wasPressed() { 21 | return keyBinding.wasPressed(); 22 | } 23 | 24 | public boolean isHeld() { 25 | return keyBinding.isKeybindPressed(); 26 | } 27 | 28 | public KeyBinding getVanillaBind() { 29 | if (vanillaBind == null) 30 | vanillaBind = new NonConflictingKeyBinding( 31 | "lch.key.sync." + ID.replace(":", "."), 32 | "key.category." + LEMClientHelperMod.MOD_ID, 33 | keyBinding, 34 | setKey -> { 35 | SyncedKeybindsMod.getConfig().keybinds.get(ID).keybinding = keyBinding.rawKey; 36 | LEMClientHelperMod.configManager.save(SyncedKeybindsMod.MOD_ID); 37 | } 38 | ); 39 | return vanillaBind; 40 | } 41 | 42 | public void updateBoundKey(String key) { 43 | keyBinding.setRaw(key); 44 | ((DisplayOnlyKeyBind) getVanillaBind()).updateSetKey(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsConfig.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.syncedKeybinds; 2 | 3 | import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; 4 | 5 | import java.util.HashMap; 6 | 7 | public class SyncedKeybindsConfig implements AbstractConfigFile { 8 | 9 | public HashMap keybinds = new HashMap<>(); 10 | 11 | public static class KeybindConfigItem { 12 | public String keybinding; 13 | public String controllerBind; 14 | 15 | public String defaultKeybinding; 16 | public String defaultControllerbind; 17 | 18 | public KeybindConfigItem(String keybinding, String controllerBind) { 19 | this.keybinding = keybinding; 20 | this.controllerBind = controllerBind; 21 | updateDefaults(keybinding, controllerBind); 22 | } 23 | 24 | public void updateDefaults(String keybinding, String controllerBind) { 25 | this.defaultKeybinding = keybinding; 26 | this.defaultControllerbind = controllerBind; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsMod.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.syncedKeybinds; 2 | 3 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; 4 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; 5 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 6 | import net.minecraft.client.MinecraftClient; 7 | 8 | import java.util.HashMap; 9 | 10 | public class SyncedKeybindsMod { 11 | public static final String MOD_ID = "syncedkeybinds"; 12 | 13 | public static HashMap syncedKeybindList = new HashMap<>(); 14 | 15 | public static void onInitialize() { 16 | LEMClientHelperMod.configManager.registerGsonFile(MOD_ID, new SyncedKeybindsConfig()); 17 | LEMClientHelperMod.configManager.load(MOD_ID); 18 | SyncedKeybindsNetworking.registerReceivePacket(); 19 | ClientTickEvents.START_WORLD_TICK.register((world) -> { 20 | if (MinecraftClient.getInstance().currentScreen == null) { 21 | syncedKeybindList.values().forEach(syncedKeybind -> { 22 | if (syncedKeybind.wasPressed()) 23 | SyncedKeybindsNetworking.sendKeyPacket(syncedKeybind.ID); 24 | }); 25 | } 26 | }); 27 | ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { 28 | syncedKeybindList.values().forEach(syncedKeybind -> { 29 | ((GameOptionKeyExpander) MinecraftClient.getInstance().options).removeSyncedKeybinds(syncedKeybind.getVanillaBind()); 30 | 31 | }); 32 | syncedKeybindList.clear(); 33 | }); 34 | } 35 | 36 | public static void registerNewKeybind(String id, String keybind, String controllerbind) { 37 | getConfig().keybinds.putIfAbsent(id, new SyncedKeybindsConfig.KeybindConfigItem(keybind, controllerbind)); 38 | SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem = getConfig().keybinds.get(id); 39 | keybindConfigItem.updateDefaults(keybind, controllerbind); 40 | 41 | SyncedKeybind syncedKeybind = new SyncedKeybind(id, keybindConfigItem); 42 | syncedKeybindList.put(id, syncedKeybind); 43 | 44 | ((GameOptionKeyExpander) MinecraftClient.getInstance().options).addSyncedKeybinds(syncedKeybind.getVanillaBind()); 45 | } 46 | 47 | public static SyncedKeybindsConfig getConfig() { 48 | return (SyncedKeybindsConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsNetworking.java: -------------------------------------------------------------------------------- 1 | package net.kyrptonaught.lemclienthelper.syncedKeybinds; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 7 | import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; 8 | import net.minecraft.network.PacketByteBuf; 9 | import net.minecraft.util.Identifier; 10 | 11 | public class SyncedKeybindsNetworking { 12 | public static final Identifier SYNC_KEYBINDS_PACKET = new Identifier(SyncedKeybindsMod.MOD_ID, "sync_keybinds_packet"); 13 | public static final Identifier KEYBIND_PRESSED_PACKET = new Identifier(SyncedKeybindsMod.MOD_ID, "keybind_pressed_packet"); 14 | 15 | @Environment(EnvType.CLIENT) 16 | public static void sendKeyPacket(String keyID) { 17 | PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); 18 | buf.writeString(keyID); 19 | ClientPlayNetworking.send(KEYBIND_PRESSED_PACKET, buf); 20 | } 21 | 22 | public static void registerReceivePacket() { 23 | ClientPlayNetworking.registerGlobalReceiver(SYNC_KEYBINDS_PACKET, (client, handler, packetByteBuf, responseSender) -> { 24 | int count = packetByteBuf.readInt(); 25 | DataHolder[] dataHolders = new DataHolder[count]; 26 | 27 | for (int i = 0; i < count; i++) { 28 | String id = packetByteBuf.readString(); 29 | String keybinding = packetByteBuf.readString(); 30 | String controllerBind = packetByteBuf.readString(); 31 | dataHolders[i] = new DataHolder(id, keybinding, controllerBind); 32 | } 33 | client.execute(() -> { 34 | for (DataHolder dataHolder : dataHolders) 35 | SyncedKeybindsMod.registerNewKeybind(dataHolder.id, dataHolder.keybinding, dataHolder.controllerBind); 36 | LEMClientHelperMod.configManager.save(SyncedKeybindsMod.MOD_ID); 37 | }); 38 | }); 39 | } 40 | 41 | public record DataHolder(String id, String keybinding, String controllerBind) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/resources/assets/lemclienthelper/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Legacy-Edition-Minigames/LEMClientHelper/0e87b4709fcb571baf06c576b2dc9bdf540a7291/src/main/resources/assets/lemclienthelper/icon.png -------------------------------------------------------------------------------- /src/main/resources/assets/lemclienthelper/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "key.category.lemclienthelper": "LEM Client Helper", 3 | "lemclienthelper.key.takeeverything": "Take Everything", 4 | "lambdacontrols.action.lemclienthelper.takeeverything": "Take Everything", 5 | "midnightcontrols.action.lemclienthelper.takeeverything": "Take Everything", 6 | "lemclienthelper.key.closesmallinv": "Close Small Inv", 7 | "key.lemclienthelper.title": "LEMClientHelper Config", 8 | "key.lemclienthelper.resourcepreloader": "Resource Preloader", 9 | "key.lemclienthelper.downloadurl": "Download URL", 10 | "key.lemclienthelper.packdownloads": "Server Packs", 11 | "key.lemclienthelper.multiDownload": "Allow Simultaneous Downloads", 12 | "key.lemclienthelper.deletePacks": "Delete Packs", 13 | "key.lemclienthelper.previewList": "Preview Pack List", 14 | "key.lemclienthelper.startdownload": "Start Download", 15 | "key.lemclienthelper.toastcomplete": "Completed Notification", 16 | "key.lemclienthelper.alreadydownloaded": "Already Downloaded", 17 | "key.lemclienthelper.downloaderror": "Download Failed", 18 | "key.lemclienthelper.downloadcomplete": "Download Complete", 19 | "key.lemclienthelper.wrongpackcompatibility": "Wrong Pack Type", 20 | "key.lemclienthelper.alldownloadcomplete": "All Downloads Complete", 21 | "key.lemclienthelper.downloading": "Downloading...", 22 | "key.lemclienthelper.smallinv": "Small Inv", 23 | "key.lemclienthelper.smallinv.enabled": "Enabled", 24 | "key.lemclienthelper.clientgui": "Armor HUD", 25 | "key.lemclienthelper.clientgui.enabled": "Enabled Armor HUD", 26 | "key.lemclienthelper.clientgui.alwaysshow": "Always Show Armor HUD", 27 | "key.lemclienthelper.clientgui.armorscale": "Armor HUD Scale Modifier", 28 | "key.lemclienthelper.clientgui.armorscale.tooltip": "Sets the scale the Armor HUD will be rendered at.\nValues between 1-4.", 29 | "key.lemclienthelper.clientgui.xOffset": "Armor HUD X Offset", 30 | "key.lemclienthelper.clientgui.xOffset.tooltip": "Sets the X Offset the Armor HUD will be rendered at.\nValues between 0-100.", 31 | "key.lemclienthelper.clientgui.transparency": "Armor HUD Transparency", 32 | "key.lemclienthelper.clientgui.transparency.tooltip": "Sets the transparency the Armor HUD will be rendered at.\nValues between 0.0-1.0.", 33 | "key.lemclienthelper.syncedkeybinds": "Synced Keybinds", 34 | "key.lemclienthelper.syncedkeys": "Synced Keys", 35 | "key.lemclienthelper.syncedkeys.tooltip": "These are keybindings synced from a LEM server\nOnly functional on LEM servers", 36 | "key.lemclienthelper.serverconfig": "Local Server Config", 37 | "key.lemclienthelper.serverconfig.guiscale": "GUI Scale", 38 | "key.lemclienthelper.serverconfig.panscale": "Panorama Scale", 39 | "key.lemclienthelper.serverconfig.guiscale.tooltip": "Sets your GUI Scale 1-4 on official LEM servers.\nSetting this value to 0 will use your option set on the server", 40 | "key.lemclienthelper.serverconfig.panscale.tooltip": "Sets your Panorama Scale 1-4 on official LEM servers.\nSetting this value to 0 will use your option set on the server" 41 | } -------------------------------------------------------------------------------- /src/main/resources/assets/lemclienthelper/textures/gui/legacy_inventory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Legacy-Edition-Minigames/LEMClientHelper/0e87b4709fcb571baf06c576b2dc9bdf540a7291/src/main/resources/assets/lemclienthelper/textures/gui/legacy_inventory.png -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "lemclienthelper", 4 | "version": "0.0.28-1.20.4", 5 | "name": "LEM Client Helper", 6 | "description": "LEM Client Helper", 7 | "authors": [ 8 | "Kyrptonaught" 9 | ], 10 | "contributors": [ 11 | "Virusnest", 12 | "S_N00B", 13 | "DBTDerpbox" 14 | ], 15 | "contact": { 16 | "homepage": "https://github.com/Legacy-Edition-Minigames/lemclienthelper", 17 | "sources": "https://github.com/Legacy-Edition-Minigames/lemclienthelper" 18 | }, 19 | "license": "MIT", 20 | "icon": "assets/lemclienthelper/icon.png", 21 | "environment": "client", 22 | "entrypoints": { 23 | "client": [ 24 | "net.kyrptonaught.lemclienthelper.LEMClientHelperMod" 25 | ], 26 | "modmenu": [ 27 | "net.kyrptonaught.lemclienthelper.config.ModMenuIntegration" 28 | ] 29 | }, 30 | "accessWidener": "lemclienthelper.accesswidener", 31 | "mixins": [ 32 | { 33 | "config": "lemclienthelper.mixins.json", 34 | "environment": "client" 35 | } 36 | ], 37 | "depends": { 38 | "fabric": "*" 39 | }, 40 | "breaks": { 41 | "legacy": "*" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/resources/lemclienthelper.accesswidener: -------------------------------------------------------------------------------- 1 | accessWidener v1 named 2 | 3 | # small inv 4 | mutable field net/minecraft/screen/slot/Slot x I 5 | mutable field net/minecraft/screen/slot/Slot y I 6 | 7 | # customWorldBorder 8 | accessible class net/minecraft/world/border/WorldBorder$Area -------------------------------------------------------------------------------- /src/main/resources/lemclienthelper.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.kyrptonaught.lemclienthelper.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "client": [ 6 | "bookGui.BookScreenMixin", 7 | "customWorldBorder.WorldBorderMixin", 8 | "ResourcePreloader.ClientBuiltInResourcePackProviderMixin", 9 | "SmallInv.HandledScreenMixin", 10 | "SmallInv.MidnightControlsMixin", 11 | "SmallInv.MinecraftClientMixin", 12 | "SmallInv.ScreenHandlerMixin", 13 | "SmallInv.invs.GenericContainerScreenMixin", 14 | "SmallInv.invs.InventoryScreenMixin", 15 | "SmallInv.invs.MultipleScreenMixin", 16 | "SpectateSquaker.MinecraftClientMixin", 17 | "SyncedKeybinds.GameOptionsMixin", 18 | "TakeEverything.ScreenHandlerMixin" 19 | ], 20 | "injectors": { 21 | "defaultRequire": 1 22 | } 23 | } 24 | --------------------------------------------------------------------------------