├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── build.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src ├── api └── java │ └── yalter │ └── mousetweaks │ └── api │ └── IMTModGuiContainer2.java └── main ├── java └── github │ └── kasuminova │ └── ae2ctl │ ├── AE2CTLegacy.java │ ├── client │ ├── ClientProxy.java │ ├── gui │ │ ├── AEBaseGuiContainerDynamic.java │ │ ├── GuiCraftingTree.java │ │ ├── util │ │ │ ├── MousePos.java │ │ │ ├── RenderFunction.java │ │ │ ├── RenderPos.java │ │ │ ├── RenderSize.java │ │ │ └── TextureProperties.java │ │ └── widget │ │ │ ├── Button.java │ │ │ ├── Button4State.java │ │ │ ├── Button5State.java │ │ │ ├── MultiLineLabel.java │ │ │ ├── Scrollbar.java │ │ │ ├── SizedColumn.java │ │ │ ├── SizedRow.java │ │ │ ├── base │ │ │ ├── DynamicWidget.java │ │ │ ├── WidgetController.java │ │ │ └── WidgetGui.java │ │ │ ├── container │ │ │ ├── Column.java │ │ │ ├── Row.java │ │ │ ├── ScrollingColumn.java │ │ │ └── WidgetContainer.java │ │ │ ├── event │ │ │ ├── GuiEvent.java │ │ │ └── WidgetEvent.java │ │ │ ├── impl │ │ │ └── craftingtree │ │ │ │ ├── Background.java │ │ │ │ ├── CraftingTree.java │ │ │ │ ├── PlaceHolder.java │ │ │ │ ├── TreeNode.java │ │ │ │ ├── TreeRow.java │ │ │ │ └── event │ │ │ │ ├── CraftingTreeDataUpdateEvent.java │ │ │ │ └── TreeNodeSelectEvent.java │ │ │ └── vanilla │ │ │ └── GuiButtonImageExt.java │ └── handler │ │ └── ClientTickHandler.java │ ├── common │ ├── CommonProxy.java │ ├── container │ │ └── ContainerCraftingTree.java │ ├── integration │ │ ├── JEIUtils.java │ │ └── ae2 │ │ │ └── data │ │ │ ├── LiteCraftTreeNode.java │ │ │ └── LiteCraftTreeProc.java │ ├── mod │ │ └── Mods.java │ ├── network │ │ ├── PktCraftingTreeData.java │ │ └── PktSwitchCraftingTree.java │ └── util │ │ ├── AEItemStackSet.java │ │ ├── ByteBufUtils.java │ │ ├── CraftingTreeProcessUtil.java │ │ └── NumberUtils.java │ └── mixin │ ├── AE2CTLLateMixinLoader.java │ └── ae2 │ ├── AccessorContainerCraftConfirm.java │ ├── AccessorCraftingTreeNode.java │ └── MixinGuiCraftConfirm.java └── resources ├── assets └── ae2ctl │ ├── lang │ ├── en_US.lang │ └── zh_CN.lang │ └── textures │ └── gui │ ├── guicraftingtree_256x256_dark.png │ ├── guicraftingtree_256x256_light.png │ ├── guicraftingtree_320x256_dark.png │ ├── guicraftingtree_320x256_light.png │ ├── guicraftingtree_384x320_dark.png │ ├── guicraftingtree_384x320_light.png │ ├── guicraftingtree_512x320_dark.png │ ├── guicraftingtree_512x320_light.png │ ├── guicraftingtree_640x384_dark.png │ ├── guicraftingtree_640x384_light.png │ ├── guicraftingtree_dark.png │ └── guicraftingtree_light.png ├── mcmod.info └── mixins.ae2ctl.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build mod 2 | 3 | on: [ push, pull_request, workflow_dispatch ] 4 | 5 | jobs: 6 | build: 7 | name: Build mod 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: Set up JDK 1.8 13 | uses: actions/setup-java@v3 14 | with: 15 | distribution: 'adopt' 16 | java-version: '8' 17 | - name: Grant execute permission for gradlew 18 | run: chmod +x gradlew 19 | - name: Build with Gradle 20 | run: ./gradlew -Pnet.minecraftforge.gradle.disableUpdateChecker=true build 21 | - name: Upload artifacts 22 | uses: actions/upload-artifact@v3 23 | with: 24 | name: AE2CT-Legacy 25 | path: build/libs 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | # mpeltonen/sbt-idea plugin 11 | .idea_modules/ 12 | 13 | # JIRA plugin 14 | atlassian-ide-plugin.xml 15 | 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # BlueJ files 23 | *.ctxt 24 | 25 | # Package Files # 26 | *.jar 27 | *.war 28 | *.nar 29 | *.ear 30 | *.zip 31 | *.tar.gz 32 | *.rar 33 | 34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 35 | hs_err_pid* 36 | 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | # General 52 | .DS_Store 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # Windows thumbnail cache files 79 | Thumbs.db 80 | Thumbs.db:encryptable 81 | ehthumbs.db 82 | ehthumbs_vista.db 83 | 84 | # Dump file 85 | *.stackdump 86 | 87 | # Folder config file 88 | [Dd]esktop.ini 89 | 90 | # Recycle Bin used on file shares 91 | $RECYCLE.BIN/ 92 | 93 | # Windows Installer files 94 | *.cab 95 | *.msi 96 | *.msix 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | 103 | .gradle 104 | build/ 105 | 106 | # Ignore Gradle GUI config 107 | gradle-app.setting 108 | 109 | # Cache of project 110 | .gradletasknamecache 111 | 112 | **/build/ 113 | 114 | # Common working directory 115 | run/ 116 | 117 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 118 | !gradle-wrapper.jar 119 | 120 | gradle.properties -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.gradle.ext.Gradle 2 | import org.jetbrains.gradle.ext.RunConfigurationContainer 3 | import java.util.* 4 | 5 | plugins { 6 | id("java-library") 7 | id("maven-publish") 8 | id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7" 9 | id("eclipse") 10 | id("com.gtnewhorizons.retrofuturagradle") version "1.3.19" 11 | } 12 | 13 | // Project properties 14 | group = "github.kasuminova.ae2ctl" 15 | version = "0.1.2" 16 | 17 | // Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod 18 | java { 19 | toolchain { 20 | languageVersion.set(JavaLanguageVersion.of(17)) 21 | // Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64 22 | vendor.set(JvmVendorSpec.AZUL) 23 | } 24 | // Generate sources and javadocs jars when building and publishing 25 | withSourcesJar() 26 | withJavadocJar() 27 | } 28 | 29 | // Most RFG configuration lives here, see the JavaDoc for com.gtnewhorizons.retrofuturagradle.MinecraftExtension 30 | minecraft { 31 | mcVersion.set("1.12.2") 32 | 33 | // Username for client run configurations 34 | username.set("Kasumi_Nova") 35 | 36 | // Generate a field named VERSION with the mod version in the injected Tags class 37 | injectedTags.put("VERSION", project.version) 38 | 39 | // If you need the old replaceIn mechanism, prefer the injectTags task because it doesn't inject a javac plugin. 40 | // tagReplacementFiles.add("RfgExampleMod.java") 41 | 42 | // Enable assertions in the mod's package when running the client or server 43 | val args = mutableListOf("-ea:${project.group}") 44 | 45 | // Mixin args 46 | args.add("-Dmixin.hotSwap=true") 47 | args.add("-Dmixin.checks.interfaces=true") 48 | args.add("-Dmixin.debug.export=true") 49 | extraRunJvmArguments.addAll(args) 50 | 51 | // If needed, add extra tweaker classes like for mixins. 52 | // extraTweakClasses.add("org.spongepowered.asm.launch.MixinTweaker") 53 | 54 | // Exclude some Maven dependency groups from being automatically included in the reobfuscated runs 55 | groupsToExcludeFromAutoReobfMapping.addAll("com.diffplug", "com.diffplug.durian", "net.industrial-craft") 56 | } 57 | 58 | // Generates a class named rfg.examplemod.Tags with the mod version in it, you can find it at 59 | tasks.injectTags.configure { 60 | outputClassName.set("${project.group}.Tags") 61 | } 62 | 63 | // Put the version from gradle into mcmod.info 64 | tasks.processResources.configure { 65 | // inputs.property("version", project.version) 66 | // 67 | // filesMatching("mcmod.info") { 68 | // expand(mapOf("version" to project.version)) 69 | // } 70 | } 71 | 72 | tasks.compileJava.configure { 73 | sourceCompatibility = "17" 74 | options.release = 8 75 | options.encoding = "UTF-8" // Use the UTF-8 charset for Java compilation 76 | 77 | javaCompiler = javaToolchains.compilerFor { 78 | languageVersion = JavaLanguageVersion.of(17) 79 | } 80 | } 81 | 82 | tasks.compileTestJava.configure { 83 | sourceCompatibility = "17" 84 | options.release = 8 85 | options.encoding = "UTF-8" // Use the UTF-8 charset for Java compilation 86 | 87 | javaCompiler = javaToolchains.compilerFor { 88 | languageVersion = JavaLanguageVersion.of(17) 89 | } 90 | } 91 | 92 | tasks.javadoc.configure { 93 | // No need for JavaDoc. 94 | actions = Collections.emptyList() 95 | } 96 | 97 | //tasks.deobfuscateMergedJarToSrg.configure { 98 | // accessTransformerFiles.from("src/main/resources/META-INF/lumenized_at.cfg") 99 | //} 100 | //tasks.srgifyBinpatchedJar.configure { 101 | // accessTransformerFiles.from("src/main/resources/META-INF/lumenized_at.cfg") 102 | //} 103 | 104 | // Create a new dependency type for runtime-only dependencies that don't get included in the maven publication 105 | val runtimeOnlyNonPublishable: Configuration by configurations.creating { 106 | description = "Runtime only dependencies that are not published alongside the jar" 107 | isCanBeConsumed = false 108 | isCanBeResolved = false 109 | } 110 | listOf(configurations.runtimeClasspath, configurations.testRuntimeClasspath).forEach { 111 | it.configure { 112 | extendsFrom( 113 | runtimeOnlyNonPublishable 114 | ) 115 | } 116 | } 117 | 118 | // Dependencies 119 | repositories { 120 | flatDir { 121 | dirs("lib") 122 | } 123 | maven { 124 | url = uri("https://maven.aliyun.com/nexus/content/groups/public/") 125 | } 126 | maven { 127 | url = uri("https://maven.aliyun.com/nexus/content/repositories/jcenter") 128 | } 129 | maven { 130 | url = uri("https://maven.cleanroommc.com") 131 | } 132 | maven { 133 | url = uri("https://cfa2.cursemaven.com") 134 | } 135 | maven { 136 | url = uri("https://cursemaven.com") 137 | } 138 | maven { 139 | url = uri("https://maven.blamejared.com/") 140 | } 141 | maven { 142 | url = uri("https://repo.spongepowered.org/maven") 143 | } 144 | maven { 145 | name = "GeckoLib" 146 | url = uri("https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/") 147 | } 148 | maven { 149 | name = "OvermindDL1 Maven" 150 | url = uri("https://gregtech.overminddl1.com/") 151 | mavenContent { 152 | excludeGroup("net.minecraftforge") // missing the `universal` artefact 153 | } 154 | } 155 | maven { 156 | name = "GTNH Maven" 157 | url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/") 158 | isAllowInsecureProtocol = true 159 | } 160 | } 161 | 162 | dependencies { 163 | annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2") 164 | compileOnly("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2") 165 | // workaround for https://github.com/bsideup/jabel/issues/174 166 | annotationProcessor("net.java.dev.jna:jna-platform:5.13.0") 167 | // Allow jdk.unsupported classes like sun.misc.Unsafe, workaround for JDK-8206937 and fixes Forge crashes in tests. 168 | patchedMinecraft("me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0") 169 | // allow Jabel to work in tests 170 | testAnnotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:1.0.0") 171 | testCompileOnly("com.github.bsideup.jabel:jabel-javac-plugin:1.0.0") { 172 | isTransitive = false // We only care about the 1 annotation class 173 | } 174 | testCompileOnly("me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0") 175 | 176 | // Mixins 177 | // implementation("zone.rong:mixinbooter:7.1") 178 | val mixin : String = modUtils.enableMixins("zone.rong:mixinbooter:8.9", "mixins.ae2ctl.refmap.json").toString() 179 | api (mixin) { 180 | isTransitive = false 181 | } 182 | annotationProcessor("org.ow2.asm:asm-debug-all:5.2") 183 | annotationProcessor("com.google.guava:guava:30.0-jre") 184 | annotationProcessor("com.google.code.gson:gson:2.8.9") 185 | annotationProcessor (mixin) { 186 | isTransitive = false 187 | } 188 | compileOnlyApi("org.jetbrains:annotations:24.1.0") 189 | annotationProcessor("org.jetbrains:annotations:24.1.0") 190 | 191 | // Mod Dependencies 192 | implementation(rfg.deobf("curse.maven:CodeChickenLib-242818:2779848")) 193 | implementation(rfg.deobf("curse.maven:ae2-extended-life-570458:5378163")) 194 | implementation(rfg.deobf("curse.maven:had-enough-items-557549:4810661")) 195 | } 196 | 197 | idea { 198 | module { 199 | isDownloadJavadoc = true 200 | isDownloadSources = true 201 | inheritOutputDirs = true // Fix resources in IJ-Native runs 202 | } 203 | project { 204 | this.withGroovyBuilder { 205 | "settings" { 206 | "runConfigurations" { 207 | val self = this.delegate as RunConfigurationContainer 208 | self.add(Gradle("1. Run Client").apply { 209 | setProperty("taskNames", listOf("runClient")) 210 | }) 211 | self.add(Gradle("2. Run Server").apply { 212 | setProperty("taskNames", listOf("runServer")) 213 | }) 214 | self.add(Gradle("3. Run Obfuscated Client").apply { 215 | setProperty("taskNames", listOf("runObfClient")) 216 | }) 217 | self.add(Gradle("4. Run Obfuscated Server").apply { 218 | setProperty("taskNames", listOf("runObfServer")) 219 | }) 220 | } 221 | "compiler" { 222 | val self = this.delegate as org.jetbrains.gradle.ext.IdeaCompilerConfiguration 223 | afterEvaluate { 224 | self.javac.moduleJavacAdditionalOptions = mapOf( 225 | (project.name + ".main") to 226 | tasks.compileJava.get().options.compilerArgs.map { '"' + it + '"' }.joinToString(" ") 227 | ) 228 | } 229 | } 230 | } 231 | } 232 | } 233 | } 234 | 235 | tasks.processIdeaSettings.configure { 236 | dependsOn(tasks.injectTags) 237 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NovaEngineering-Source/AE2CT-Legacy/99ab83936ab9d0a51f93de91f76b05a839aedf5f/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.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /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/master/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 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || 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 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /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 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | // RetroFuturaGradle 5 | name = "GTNH Maven" 6 | url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/") 7 | isAllowInsecureProtocol = true 8 | mavenContent { 9 | includeGroup("com.gtnewhorizons") 10 | includeGroup("com.gtnewhorizons.retrofuturagradle") 11 | } 12 | } 13 | gradlePluginPortal() 14 | mavenCentral() 15 | mavenLocal() 16 | } 17 | } 18 | 19 | plugins { 20 | // Automatic toolchain provisioning 21 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" 22 | } 23 | 24 | rootProject.name = "AE2CT-Legacy" 25 | -------------------------------------------------------------------------------- /src/api/java/yalter/mousetweaks/api/IMTModGuiContainer2.java: -------------------------------------------------------------------------------- 1 | package yalter.mousetweaks.api; 2 | 3 | import net.minecraft.inventory.Container; 4 | import net.minecraft.inventory.Slot; 5 | 6 | /** 7 | * This is the interface you want to implement in your GuiScreen to make it compatible with Mouse Tweaks. 8 | * If this interface is not enough (for example, you need a custom slot click function, or if you use a custom Container 9 | * which happens to be incompatible), check IMTModGuiContainer2Ex instead. 10 | * If you just need to disable Mouse Tweaks or the wheel tweak, see the MouseTweaksIgnore 11 | * or the MouseTweaksDisableWheelTweak annotations. 12 | */ 13 | public interface IMTModGuiContainer2 { 14 | /** 15 | * If you want to disable Mouse Tweaks in your GuiScreen, return true from this method. 16 | * 17 | * @return True if Mouse Tweaks should be disabled, false otherwise. 18 | */ 19 | boolean MT_isMouseTweaksDisabled(); 20 | 21 | /** 22 | * If you want to disable the Wheel Tweak in your GuiScreen, return true from this method. 23 | * 24 | * @return True if the Wheel Tweak should be disabled, false otherwise. 25 | */ 26 | boolean MT_isWheelTweakDisabled(); 27 | 28 | /** 29 | * Returns the Container. 30 | * 31 | * @return Container that is currently in use. 32 | */ 33 | Container MT_getContainer(); 34 | 35 | /** 36 | * Returns the Slot that is currently selected by the player, or null if no Slot is selected. 37 | * 38 | * @return Slot that is located under the mouse, or null if no Slot it currently under the mouse. 39 | */ 40 | Slot MT_getSlotUnderMouse(); 41 | 42 | /** 43 | * Return true if the given Slot behaves like the vanilla crafting output slots (inside the crafting table, 44 | * or the furnace output slot, or the anvil output slot, etc.). These slots are handled differently by Mouse Tweaks. 45 | * 46 | * @param slot the slot to check 47 | * @return True if slot is a crafting output slot. 48 | */ 49 | boolean MT_isCraftingOutput(Slot slot); 50 | 51 | /** 52 | * Return true if the given Slot should be ignored by Mouse Tweaks. Examples of ignored slots are the item select 53 | * slots and the Destroy Item slot in the vanilla creative inventory. 54 | * 55 | * @param slot the slot to check 56 | * @return Tru if slot should be ignored by Mouse Tweaks. 57 | */ 58 | boolean MT_isIgnored(Slot slot); 59 | 60 | /** 61 | * If your container has an RMB dragging functionality (like vanilla containers), disable it inside this method. 62 | * This method is called every frame (render tick), which is after all mouseClicked / mouseClickMove / mouseReleased 63 | * events are handled (although note these events are handled every game tick, which is far less frequent than every 64 | * render tick).

65 | *

66 | * If true is returned from this method, Mouse Tweaks (after checking other conditions like isIgnored) will click 67 | * the slot on which the right mouse button was initially pressed (in most cases this is the slot currently under 68 | * mouse). This is needed because the vanilla RMB dragging functionality prevents the initial slot click.

69 | *

70 | * For vanilla containers this method looks like this: 71 | *

72 |      * this.ignoreMouseUp = true;
73 |      *
74 |      * if (this.dragSplitting) {
75 |      *     if (this.dragSplittingButton == 1) {
76 |      *         this.dragSplitting = false;
77 |      *         return true;
78 |      *     }
79 |      * }
80 |      *
81 |      * return false;
82 |      * 
83 | * 84 | * @return True if Mouse Tweaks should click the slot on which the RMB was pressed. 85 | */ 86 | boolean MT_disableRMBDraggingFunctionality(); 87 | } -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/AE2CTLegacy.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl; 2 | 3 | import github.kasuminova.ae2ctl.common.CommonProxy; 4 | import github.kasuminova.ae2ctl.common.network.PktCraftingTreeData; 5 | import github.kasuminova.ae2ctl.common.network.PktSwitchCraftingTree; 6 | import net.minecraftforge.fml.common.Mod; 7 | import net.minecraftforge.fml.common.SidedProxy; 8 | import net.minecraftforge.fml.common.event.*; 9 | import net.minecraftforge.fml.common.network.NetworkRegistry; 10 | import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | import org.apache.logging.log4j.Logger; 13 | 14 | @Mod(modid = AE2CTLegacy.MOD_ID, name = AE2CTLegacy.MOD_NAME, version = AE2CTLegacy.VERSION, 15 | dependencies = "required-after:forge@[14.23.5.0,);" + 16 | "required-after:appliedenergistics2;" + 17 | "required-after:jei;" + 18 | "required-after:mixinbooter@[8.0,);", 19 | acceptedMinecraftVersions = "[1.12, 1.13)", 20 | acceptableRemoteVersions = "[0.1.0, 0.2.0)" 21 | ) 22 | @SuppressWarnings("MethodMayBeStatic") 23 | public class AE2CTLegacy { 24 | public static final String MOD_ID = "ae2ctl"; 25 | public static final String MOD_NAME = "AE2 Crafting Tree - Legacy"; 26 | 27 | public static final String VERSION = Tags.VERSION; 28 | 29 | public static final String CLIENT_PROXY = "github.kasuminova.ae2ctl.client.ClientProxy"; 30 | public static final String COMMON_PROXY = "github.kasuminova.ae2ctl.common.CommonProxy"; 31 | 32 | public static final SimpleNetworkWrapper NET_CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID); 33 | 34 | @Mod.Instance(MOD_ID) 35 | public static AE2CTLegacy instance = null; 36 | 37 | @SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY) 38 | public static CommonProxy proxy = null; 39 | 40 | public static Logger log = null; 41 | 42 | public AE2CTLegacy() { 43 | } 44 | 45 | @Mod.EventHandler 46 | public void construction(FMLConstructionEvent event) { 47 | proxy.construction(); 48 | } 49 | 50 | @Mod.EventHandler 51 | public void preInit(FMLPreInitializationEvent event) { 52 | event.getModMetadata().version = VERSION; 53 | log = event.getModLog(); 54 | 55 | NET_CHANNEL.registerMessage(PktCraftingTreeData.class, PktCraftingTreeData.class, 0, Side.CLIENT); 56 | NET_CHANNEL.registerMessage(PktSwitchCraftingTree.class, PktSwitchCraftingTree.class, 1, Side.SERVER); 57 | 58 | proxy.preInit(); 59 | } 60 | 61 | @Mod.EventHandler 62 | public void init(FMLInitializationEvent event) { 63 | proxy.init(); 64 | } 65 | 66 | @Mod.EventHandler 67 | public void postInit(FMLPostInitializationEvent event) { 68 | proxy.postInit(); 69 | } 70 | 71 | @Mod.EventHandler 72 | public void loadComplete(FMLLoadCompleteEvent event) { 73 | proxy.loadComplete(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/ClientProxy.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client; 2 | 3 | 4 | import appeng.api.storage.ITerminalHost; 5 | import appeng.container.implementations.ContainerCraftConfirm; 6 | import github.kasuminova.ae2ctl.client.gui.GuiCraftingTree; 7 | import github.kasuminova.ae2ctl.client.handler.ClientTickHandler; 8 | import github.kasuminova.ae2ctl.common.CommonProxy; 9 | import net.minecraft.entity.player.EntityPlayer; 10 | import net.minecraft.util.math.MathHelper; 11 | import net.minecraft.world.World; 12 | import net.minecraftforge.common.MinecraftForge; 13 | 14 | import javax.annotation.Nullable; 15 | 16 | public class ClientProxy extends CommonProxy { 17 | 18 | @Override 19 | public void construction() { 20 | super.construction(); 21 | } 22 | 23 | @Override 24 | public void preInit() { 25 | super.preInit(); 26 | MinecraftForge.EVENT_BUS.register(ClientTickHandler.class); 27 | } 28 | 29 | @Override 30 | public void init() { 31 | super.init(); 32 | } 33 | 34 | @Override 35 | public void postInit() { 36 | super.postInit(); 37 | } 38 | 39 | @Override 40 | public void loadComplete() { 41 | super.loadComplete(); 42 | } 43 | 44 | @Nullable 45 | @Override 46 | public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) { 47 | GuiType type = GuiType.values()[MathHelper.clamp(ID, 0, GuiType.values().length - 1)]; 48 | return switch (type) { 49 | case CRAFTING_TREE -> { 50 | if (!(player.openContainer instanceof ContainerCraftConfirm confirm)) { 51 | yield null; 52 | } 53 | yield new GuiCraftingTree(player.inventory, (ITerminalHost) confirm.getTarget()); 54 | } 55 | }; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/AEBaseGuiContainerDynamic.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui; 2 | 3 | import appeng.client.gui.AEBaseGui; 4 | import github.kasuminova.ae2ctl.client.gui.util.MousePos; 5 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetController; 6 | import net.minecraft.client.gui.FontRenderer; 7 | import net.minecraft.inventory.Container; 8 | import net.minecraft.inventory.Slot; 9 | import net.minecraft.item.ItemStack; 10 | import net.minecraftforge.fml.client.config.GuiUtils; 11 | import org.lwjgl.input.Mouse; 12 | 13 | import javax.annotation.Nonnull; 14 | import java.io.IOException; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public abstract class AEBaseGuiContainerDynamic extends AEBaseGui { 19 | 20 | protected WidgetController widgetController = null; 21 | protected Slot hoveredSlot = null; 22 | 23 | public AEBaseGuiContainerDynamic(final Container container) { 24 | super(container); 25 | } 26 | 27 | @Override 28 | public void updateScreen() { 29 | super.updateScreen(); 30 | widgetController.update(); 31 | } 32 | 33 | @Override 34 | public void initGui() { 35 | super.initGui(); 36 | widgetController.getGui() 37 | .setGuiLeft(guiLeft) 38 | .setGuiTop(guiTop) 39 | .setXSize(width) 40 | .setYSize(height); 41 | widgetController.init(); 42 | } 43 | 44 | @Override 45 | public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { 46 | widgetController.postRender(new MousePos(mouseX, mouseY), false); 47 | } 48 | 49 | @Override 50 | public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { 51 | widgetController.render(new MousePos(mouseX, mouseY), true); 52 | } 53 | 54 | @Override 55 | protected void renderHoveredToolTip(final int mouseX, final int mouseY) { 56 | updateHoveredSlot(mouseX, mouseY); 57 | 58 | ItemStack stackInSlot = hoveredSlot == null ? ItemStack.EMPTY : hoveredSlot.getStack(); 59 | List hoverTooltips = widgetController.getHoverTooltips(new MousePos(mouseX, mouseY)); 60 | if (stackInSlot.isEmpty() && hoverTooltips.isEmpty()) { 61 | return; 62 | } 63 | List itemTooltip = stackInSlot.isEmpty() ? new ArrayList<>() : this.getItemToolTip(stackInSlot); 64 | itemTooltip.addAll(hoverTooltips); 65 | 66 | FontRenderer font = stackInSlot.getItem().getFontRenderer(stackInSlot); 67 | GuiUtils.preItemToolTip(stackInSlot); 68 | this.drawHoveringText(itemTooltip, mouseX, mouseY, (font == null ? fontRenderer : font)); 69 | GuiUtils.postItemToolTip(); 70 | } 71 | 72 | @Override 73 | public void handleMouseInput() throws IOException { 74 | final int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; 75 | final int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; 76 | if (widgetController.onMouseInput(new MousePos(mouseX, mouseY))) { 77 | return; 78 | } 79 | super.handleMouseInput(); 80 | } 81 | 82 | @Override 83 | protected void mouseClicked(final int mouseX, final int mouseY, final int mouseButton) throws IOException { 84 | if (widgetController.onMouseClicked(new MousePos(mouseX, mouseY), mouseButton)) { 85 | return; 86 | } 87 | super.mouseClicked(mouseX, mouseY, mouseButton); 88 | } 89 | 90 | @Override 91 | protected void mouseReleased(final int mouseX, final int mouseY, final int state) { 92 | if (widgetController.onMouseReleased(new MousePos(mouseX, mouseY))) { 93 | return; 94 | } 95 | super.mouseReleased(mouseX, mouseY, state); 96 | } 97 | 98 | @Override 99 | protected void keyTyped(final char typedChar, final int keyCode) throws IOException { 100 | if (widgetController.onKeyTyped(typedChar, keyCode)) { 101 | return; 102 | } 103 | super.keyTyped(typedChar, keyCode); 104 | } 105 | 106 | @Override 107 | public void drawHoveringText(@Nonnull final List textLines, final int x, final int y) { 108 | super.drawHoveringText(textLines, x, y); 109 | } 110 | 111 | protected void updateHoveredSlot(final int mouseX, final int mouseY) { 112 | hoveredSlot = this.inventorySlots.inventorySlots.stream() 113 | .filter(slot -> this.isMouseOverSlot(slot, mouseX, mouseY) && slot.isEnabled()) 114 | .findFirst() 115 | .orElse(null); 116 | } 117 | 118 | protected boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY) { 119 | return this.isPointInRegion(slotIn.xPos, slotIn.yPos, 16, 16, mouseX, mouseY); 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/GuiCraftingTree.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui; 2 | 3 | import appeng.api.storage.ITerminalHost; 4 | import github.kasuminova.ae2ctl.AE2CTLegacy; 5 | import github.kasuminova.ae2ctl.client.gui.util.TextureProperties; 6 | import github.kasuminova.ae2ctl.client.gui.widget.Button4State; 7 | import github.kasuminova.ae2ctl.client.gui.widget.Button5State; 8 | import github.kasuminova.ae2ctl.client.gui.widget.MultiLineLabel; 9 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetController; 10 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetGui; 11 | import github.kasuminova.ae2ctl.client.gui.widget.impl.craftingtree.Background; 12 | import github.kasuminova.ae2ctl.client.gui.widget.impl.craftingtree.CraftingTree; 13 | import github.kasuminova.ae2ctl.client.gui.widget.impl.craftingtree.event.CraftingTreeDataUpdateEvent; 14 | import github.kasuminova.ae2ctl.common.container.ContainerCraftingTree; 15 | import github.kasuminova.ae2ctl.common.integration.ae2.data.LiteCraftTreeNode; 16 | import github.kasuminova.ae2ctl.common.network.PktSwitchCraftingTree; 17 | import net.minecraft.client.gui.Gui; 18 | import net.minecraft.client.renderer.GlStateManager; 19 | import net.minecraft.client.resources.I18n; 20 | import net.minecraft.entity.player.InventoryPlayer; 21 | import net.minecraft.util.ResourceLocation; 22 | 23 | import java.util.Collections; 24 | 25 | /** 26 | * TODO: Dark mode switch. 27 | */ 28 | public class GuiCraftingTree extends AEBaseGuiContainerDynamic { 29 | 30 | private static final TextureProperties BUTTON_BACK = TextureProperties.of( 31 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 32 | 232, 100, 24, 20 33 | ); 34 | private static final TextureProperties BUTTON_BACK_HOVERED = TextureProperties.of( 35 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 36 | 208, 100, 24, 20 37 | ); 38 | private static final TextureProperties BUTTON_BACK_MOUSEDOWN = TextureProperties.of( 39 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 40 | 184, 100, 24, 20 41 | ); 42 | 43 | private static final TextureProperties BUTTON_MISSING_ONLY = TextureProperties.of( 44 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 45 | 232, 60, 24, 20 46 | ); 47 | private static final TextureProperties BUTTON_MISSING_ONLY_HOVERED = TextureProperties.of( 48 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 49 | 208, 60, 24, 20 50 | ); 51 | private static final TextureProperties BUTTON_MISSING_ONLY_MOUSEDOWN = TextureProperties.of( 52 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 53 | 184, 60, 24, 20 54 | ); 55 | private static final TextureProperties BUTTON_MISSING_ONLY_CLICKED = TextureProperties.of( 56 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 57 | 160, 60, 24, 20 58 | ); 59 | 60 | private static final TextureProperties BUTTON_SCREENSHOT = TextureProperties.of( 61 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 62 | 232, 0, 24, 20 63 | ); 64 | private static final TextureProperties BUTTON_SCREENSHOT_HOVERED = TextureProperties.of( 65 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 66 | 208, 0, 24, 20 67 | ); 68 | private static final TextureProperties BUTTON_SCREENSHOT_MOUSEDOWN = TextureProperties.of( 69 | new ResourceLocation(AE2CTLegacy.MOD_ID, "textures/gui/guicraftingtree_dark.png"), 70 | 184, 0, 24, 20 71 | ); 72 | 73 | private final CraftingTree tree = new CraftingTree(); 74 | 75 | private final Button4State screenshot = new Button4State(); 76 | private final Button5State missingOnly = new Button5State(); 77 | private final Button4State back = new Button4State(); 78 | 79 | private Background background; 80 | 81 | public GuiCraftingTree(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { 82 | super(new ContainerCraftingTree(inventoryPlayer, te)); 83 | this.background = Background.getLargest(this.width, this.height, true); 84 | this.xSize = background.getTexture().width(); 85 | this.ySize = background.getTexture().height(); 86 | this.guiLeft = (this.width - this.xSize) / 2; 87 | this.guiTop = (this.height - this.ySize) / 2; 88 | 89 | this.widgetController = new WidgetController(WidgetGui.of(this, this.xSize, this.ySize, guiLeft, guiTop)); 90 | this.widgetController.addWidget(tree 91 | .setWidthHeight(background.getInternalWidth(), background.getInternalHeight()) 92 | .setAbsXY(background.getInternalXOffset(), background.getInternalYOffset()) 93 | ); 94 | // Title 95 | this.widgetController.addWidget(new MultiLineLabel(Collections.singletonList(I18n.format("gui.crafting_tree.title"))) 96 | .setAutoWrap(false) 97 | .setMargin(0) 98 | .setAbsXY(6, 9) 99 | ); 100 | // Right Top 101 | this.widgetController.addWidget(screenshot 102 | .setMouseDownTexture(BUTTON_SCREENSHOT_MOUSEDOWN) 103 | .setHoveredTexture(BUTTON_SCREENSHOT_HOVERED) 104 | .setTexture(BUTTON_SCREENSHOT) 105 | .setTooltipFunction(input -> Collections.singletonList(I18n.format("gui.crafting_tree.screenshot"))) 106 | .setOnClickedListener(btn -> {}) 107 | .setWidthHeight(24, 20) 108 | .setAbsXY(xSize - 86, 3)); 109 | this.widgetController.addWidget(missingOnly 110 | .setClickedTexture(BUTTON_MISSING_ONLY_CLICKED) 111 | .setMouseDownTexture(BUTTON_MISSING_ONLY_MOUSEDOWN) 112 | .setHoveredTexture(BUTTON_MISSING_ONLY_HOVERED) 113 | .setTexture(BUTTON_MISSING_ONLY) 114 | .setTooltipFunction(input -> missingOnly.isClicked() 115 | ? Collections.singletonList(I18n.format("gui.crafting_tree.default")) 116 | : Collections.singletonList(I18n.format("gui.crafting_tree.missing_only")) 117 | ) 118 | .setOnClickedListener(btn -> tree.setMissingOnly(missingOnly.isClicked())) 119 | .setWidthHeight(24, 20) 120 | .setAbsXY(xSize - 58, 3)); 121 | this.widgetController.addWidget(back 122 | .setMouseDownTexture(BUTTON_BACK_MOUSEDOWN) 123 | .setHoveredTexture(BUTTON_BACK_HOVERED) 124 | .setTexture(BUTTON_BACK) 125 | .setTooltipFunction(input -> Collections.singletonList(I18n.format("gui.crafting_tree.back"))) 126 | .setOnClickedListener(btn -> AE2CTLegacy.NET_CHANNEL.sendToServer(new PktSwitchCraftingTree())) 127 | .setWidthHeight(24, 20) 128 | .setAbsXY(xSize - 30, 3)); 129 | } 130 | 131 | @Override 132 | public void initGui() { 133 | this.background = Background.getLargest(this.width, this.height, true); 134 | this.xSize = background.getTexture().width(); 135 | this.ySize = background.getTexture().height(); 136 | this.guiLeft = (this.width - this.xSize) / 2; 137 | this.guiTop = (this.height - this.ySize) / 2; 138 | 139 | this.tree.setWidthHeight(background.getInternalWidth(), background.getInternalHeight()) 140 | .setAbsXY(background.getInternalXOffset(), background.getInternalYOffset()); 141 | this.screenshot.setAbsXY(xSize - 86, 3); 142 | this.missingOnly.setAbsXY(xSize - 58, 3); 143 | this.back.setAbsXY(xSize - 30, 3); 144 | 145 | super.initGui(); 146 | } 147 | 148 | @Override 149 | public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { 150 | GlStateManager.color(1.0F, 1.0F, 1.0F); 151 | 152 | assert background.getTexture().texRes() != null; 153 | this.mc.getTextureManager().bindTexture(background.getTexture().texRes()); 154 | final int x = (this.width - this.xSize) / 2; 155 | final int y = (this.height - this.ySize) / 2; 156 | Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, xSize, ySize, xSize, ySize); 157 | 158 | super.drawBG(offsetX, offsetY, mouseX, mouseY); 159 | } 160 | 161 | public void onDataUpdate(final LiteCraftTreeNode root) { 162 | if (LiteCraftTreeNode.isMissing(root)) { 163 | this.missingOnly.setClicked(true); 164 | } 165 | this.widgetController.postGuiEvent(new CraftingTreeDataUpdateEvent(root)); 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/util/MousePos.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.util; 2 | 3 | import com.github.bsideup.jabel.Desugar; 4 | 5 | @Desugar 6 | public record MousePos(int mouseX, int mouseY) { 7 | 8 | public MousePos relativeTo(RenderPos renderPos) { 9 | return new MousePos(mouseX - renderPos.posX(), mouseY - renderPos.posY()); 10 | } 11 | 12 | public MousePos add(RenderPos renderPos) { 13 | return new MousePos(mouseX + renderPos.posX(), mouseY + renderPos.posY()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/util/RenderFunction.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.util; 2 | 3 | import github.kasuminova.ae2ctl.client.gui.widget.base.DynamicWidget; 4 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetGui; 5 | 6 | @FunctionalInterface 7 | public interface RenderFunction { 8 | 9 | void doRender(DynamicWidget dynamicWidget, WidgetGui gui, RenderSize renderSize, RenderPos renderPos, MousePos mousePos); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/util/RenderPos.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.util; 2 | 3 | import com.github.bsideup.jabel.Desugar; 4 | 5 | @Desugar 6 | public record RenderPos(int posX, int posY) { 7 | 8 | public RenderPos add(RenderPos another) { 9 | return new RenderPos(posX + another.posX, posY + another.posY); 10 | } 11 | 12 | public RenderPos subtract(RenderPos another) { 13 | return new RenderPos(posX - another.posX, posY - another.posY); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/util/RenderSize.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.util; 2 | 3 | import com.github.bsideup.jabel.Desugar; 4 | 5 | @Desugar 6 | public record RenderSize(int width, int height) { 7 | 8 | public boolean isLimited() { 9 | return width != -1 && height != -1; 10 | } 11 | 12 | public boolean isWidthLimited() { 13 | return width != -1; 14 | } 15 | 16 | public boolean isHeightLimited() { 17 | return height != -1; 18 | } 19 | 20 | public RenderSize smaller(final RenderSize another) { 21 | return new RenderSize(Math.min(width, another.width), Math.min(height, another.height)); 22 | } 23 | 24 | public RenderSize add(final RenderSize another) { 25 | return new RenderSize(width + another.width, height + another.height); 26 | } 27 | 28 | public RenderSize subtract(final RenderSize another) { 29 | return new RenderSize(width - another.width, height - another.height); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/util/TextureProperties.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.util; 2 | 3 | import com.github.bsideup.jabel.Desugar; 4 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetGui; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.renderer.texture.TextureManager; 7 | import net.minecraft.util.ResourceLocation; 8 | 9 | import javax.annotation.Nullable; 10 | import javax.annotation.ParametersAreNonnullByDefault; 11 | import java.util.Optional; 12 | import java.util.function.Consumer; 13 | 14 | @Desugar 15 | @ParametersAreNonnullByDefault 16 | @SuppressWarnings("unused") 17 | public record TextureProperties(@Nullable ResourceLocation texRes, int texX, int texY, int width, int height) { 18 | 19 | public static final TextureProperties EMPTY = new TextureProperties(null, 0, 0, 0, 0); 20 | 21 | public static TextureProperties of(@Nullable final ResourceLocation texRes, final int texX, final int texY, final int width, final int height) { 22 | return new TextureProperties(texRes, texX, texY, width, height); 23 | } 24 | 25 | public static TextureProperties of(final int texX, final int texY, final int width, final int height) { 26 | return of(null, texX, texY, width, height); 27 | } 28 | 29 | public static TextureProperties of(final int texX, final int texY, final int widthHeight) { 30 | return of(null, texX, texY, widthHeight, widthHeight); 31 | } 32 | 33 | public static TextureProperties of(@Nullable final ResourceLocation texRes, final int texX, final int texY) { 34 | return of(texRes, texX, texY, 0, 0); 35 | } 36 | 37 | public static TextureProperties of(final int texX, final int texY) { 38 | return of(null, texX, texY); 39 | } 40 | 41 | public void bind(final TextureManager textureManager) { 42 | if (texRes != null) { 43 | bind(textureManager, texRes); 44 | } 45 | } 46 | 47 | private static void bind(final TextureManager textureManager, final ResourceLocation texRes) { 48 | textureManager.bindTexture(texRes); 49 | } 50 | 51 | // Default render 52 | 53 | public void render(final RenderPos renderPos, final WidgetGui gui) { 54 | render(renderPos, gui.getGui()); 55 | } 56 | 57 | public void render(final RenderPos renderPos, final GuiScreen gui) { 58 | bind(gui.mc.getTextureManager()); 59 | gui.drawTexturedModalRect(renderPos.posX(), renderPos.posY(), texX, texY, width, height); 60 | } 61 | 62 | public void renderIfPresent(final RenderPos renderPos, final WidgetGui gui) { 63 | ifPresent(t -> t.render(renderPos, gui)); 64 | } 65 | 66 | public void renderIfPresent(final RenderPos renderPos, final GuiScreen gui) { 67 | ifPresent(t -> t.render(renderPos, gui)); 68 | } 69 | 70 | public void renderIfPresent(final RenderPos renderPos, final WidgetGui gui, final Consumer before) { 71 | ifPresent(t -> before.andThen(t1 -> t.render(renderPos, gui)).accept(t)); 72 | } 73 | 74 | public void renderIfPresent(final RenderPos renderPos, final GuiScreen gui, final Consumer before) { 75 | ifPresent(t -> before.andThen(t1 -> t.render(renderPos, gui)).accept(t)); 76 | } 77 | 78 | public void renderIfPresent(final RenderPos renderPos, final WidgetGui gui, @Nullable final Consumer before, @Nullable final Consumer after) { 79 | ifPresent(t -> { 80 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 81 | t.render(renderPos, gui); 82 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 83 | }); 84 | } 85 | 86 | public void renderIfPresent(final RenderPos renderPos, final GuiScreen gui, @Nullable final Consumer before, @Nullable final Consumer after) { 87 | ifPresent(t -> { 88 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 89 | t.render(renderPos, gui); 90 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 91 | }); 92 | } 93 | 94 | public void ifPresent(final Consumer runnable) { 95 | if (texRes != null && width > 0 && height > 0) { 96 | runnable.accept(this); 97 | } 98 | } 99 | 100 | // Custom texture render 101 | 102 | public void render(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final WidgetGui gui) { 103 | render(customTexRes, renderPos, gui.getGui()); 104 | } 105 | 106 | public void render(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final GuiScreen gui) { 107 | TextureManager textureManager = gui.mc.getTextureManager(); 108 | if (texRes != null) { 109 | bind(textureManager); 110 | } else { 111 | if (customTexRes != null) { 112 | bind(textureManager, customTexRes); 113 | } else { 114 | return; 115 | } 116 | } 117 | gui.drawTexturedModalRect(renderPos.posX(), renderPos.posY(), texX, texY, width, height); 118 | } 119 | 120 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final WidgetGui gui) { 121 | ifSizePresent(t -> t.render(customTexRes, renderPos, gui)); 122 | } 123 | 124 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final GuiScreen gui) { 125 | ifSizePresent(t -> t.render(customTexRes, renderPos, gui)); 126 | } 127 | 128 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final WidgetGui gui, final Consumer before) { 129 | ifSizePresent(t -> before.andThen(t1 -> t.render(customTexRes, renderPos, gui)).accept(t)); 130 | } 131 | 132 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final GuiScreen gui, final Consumer before) { 133 | ifSizePresent(t -> before.andThen(t1 -> t.render(customTexRes, renderPos, gui)).accept(t)); 134 | } 135 | 136 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final WidgetGui gui, @Nullable final Consumer before, @Nullable final Consumer after) { 137 | ifPresent(t -> { 138 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 139 | t.render(customTexRes, renderPos, gui); 140 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 141 | }); 142 | } 143 | 144 | public void renderIfPresent(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final GuiScreen gui, @Nullable final Consumer before, @Nullable final Consumer after) { 145 | ifPresent(t -> { 146 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 147 | t.render(customTexRes, renderPos, gui); 148 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 149 | }); 150 | } 151 | 152 | public void ifSizePresent(final Consumer runnable) { 153 | if (width > 0 && height > 0) { 154 | runnable.accept(this); 155 | } 156 | } 157 | 158 | // Custom texture and size render 159 | 160 | public void render(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final RenderSize renderSize, final WidgetGui gui) { 161 | render(customTexRes, renderPos, renderSize, gui.getGui()); 162 | } 163 | 164 | public void render(@Nullable final ResourceLocation customTexRes, final RenderPos renderPos, final RenderSize renderSize, final GuiScreen gui) { 165 | TextureManager textureManager = gui.mc.getTextureManager(); 166 | if (texRes != null) { 167 | bind(textureManager); 168 | } else { 169 | if (customTexRes != null) { 170 | bind(textureManager, customTexRes); 171 | } else { 172 | return; 173 | } 174 | } 175 | gui.drawTexturedModalRect(renderPos.posX(), renderPos.posY(), texX, texY, renderSize.width(), renderSize.height()); 176 | } 177 | 178 | // Custom size render 179 | 180 | public void render(final RenderPos renderPos, final RenderSize renderSize, final WidgetGui gui) { 181 | render(renderPos, renderSize, gui.getGui()); 182 | } 183 | 184 | public void render(final RenderPos renderPos, final RenderSize renderSize, final GuiScreen gui) { 185 | bind(gui.mc.getTextureManager()); 186 | gui.drawTexturedModalRect(renderPos.posX(), renderPos.posY(), texX, texY, renderSize.width(), renderSize.height()); 187 | } 188 | 189 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final WidgetGui gui) { 190 | ifTexPresent(t -> t.render(renderPos, renderSize, gui)); 191 | } 192 | 193 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final GuiScreen gui) { 194 | ifTexPresent(t -> t.render(renderPos, renderSize, gui)); 195 | } 196 | 197 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final WidgetGui gui, final Consumer before) { 198 | ifTexPresent(t -> before.andThen(t1 -> t.render(renderPos, renderSize, gui)).accept(t)); 199 | } 200 | 201 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final GuiScreen gui, final Consumer before) { 202 | ifTexPresent(t -> before.andThen(t1 -> t.render(renderPos, renderSize, gui)).accept(t)); 203 | } 204 | 205 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final WidgetGui gui, @Nullable final Consumer before, @Nullable final Consumer after) { 206 | ifPresent(t -> { 207 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 208 | t.render(renderPos, renderSize, gui); 209 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 210 | }); 211 | } 212 | 213 | public void renderIfPresent(final RenderPos renderPos, final RenderSize renderSize, final GuiScreen gui, @Nullable final Consumer before, @Nullable final Consumer after) { 214 | ifPresent(t -> { 215 | Optional.ofNullable(before).ifPresent(bc -> bc.accept(t)); 216 | t.render(renderPos, renderSize, gui); 217 | Optional.ofNullable(after).ifPresent(ac -> ac.accept(t)); 218 | }); 219 | } 220 | 221 | public void ifTexPresent(final Consumer runnable) { 222 | if (texRes != null) { 223 | runnable.accept(this); 224 | } 225 | } 226 | 227 | } 228 | -------------------------------------------------------------------------------- /src/main/java/github/kasuminova/ae2ctl/client/gui/widget/Button.java: -------------------------------------------------------------------------------- 1 | package github.kasuminova.ae2ctl.client.gui.widget; 2 | 3 | import github.kasuminova.ae2ctl.client.gui.util.MousePos; 4 | import github.kasuminova.ae2ctl.client.gui.util.RenderPos; 5 | import github.kasuminova.ae2ctl.client.gui.util.RenderSize; 6 | import github.kasuminova.ae2ctl.client.gui.util.TextureProperties; 7 | import github.kasuminova.ae2ctl.client.gui.widget.base.DynamicWidget; 8 | import github.kasuminova.ae2ctl.client.gui.widget.base.WidgetGui; 9 | import net.minecraft.util.ResourceLocation; 10 | 11 | import java.util.List; 12 | import java.util.Optional; 13 | import java.util.function.Consumer; 14 | import java.util.function.Function; 15 | 16 | /** 17 | * A button component with three states: Normal / Hovered / Unavailable. 18 | */ 19 | @SuppressWarnings("unused") 20 | public class Button extends DynamicWidget { 21 | 22 | protected ResourceLocation textureLocation = null; 23 | protected TextureProperties texture = TextureProperties.EMPTY; 24 | protected TextureProperties hoveredTexture = TextureProperties.EMPTY; 25 | protected TextureProperties unavailableTexture= TextureProperties.EMPTY; 26 | 27 | protected boolean available = true; 28 | 29 | protected Consumer