├── .github └── workflows │ ├── gradle.yml │ └── nightly_cleanup.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src └── main ├── java └── dev │ └── amber │ ├── api │ └── render │ │ └── GradientFontRenderer.java │ └── backend │ └── mixin │ ├── AmberMixinLoader.java │ └── mixins │ └── MixinGuiBossOverlay.java ├── kotlin └── dev │ └── amber │ ├── api │ ├── render │ │ ├── Element.kt │ │ ├── RenderUtil2d.kt │ │ ├── VertexUtil.kt │ │ └── gui │ │ │ ├── Background.kt │ │ │ └── particle.kt │ ├── setting │ │ ├── Setting.kt │ │ ├── SettingManager.kt │ │ └── values │ │ │ ├── BooleanSetting.kt │ │ │ ├── DoubleSetting.kt │ │ │ ├── IntegerSetting.kt │ │ │ ├── ModeSetting.kt │ │ │ └── StringSetting.kt │ ├── util │ │ ├── ColorUtils.kt │ │ ├── Globals.kt │ │ ├── LOGGER.kt │ │ ├── MathUtils.kt │ │ └── MessageUtil.kt │ └── variables │ │ └── ABColor.kt │ ├── backend │ ├── events │ │ ├── core │ │ │ ├── EventHandler.kt │ │ │ ├── EventTarget.kt │ │ │ └── imp │ │ │ │ ├── Cancellable.kt │ │ │ │ ├── Event.kt │ │ │ │ ├── EventCancellable.kt │ │ │ │ └── Priority.kt │ │ └── list │ │ │ ├── EventClientTick.kt │ │ │ ├── EventGuiChange.kt │ │ │ ├── EventMessage.kt │ │ │ └── EventRenderTick.kt │ └── managers │ │ ├── list │ │ ├── CommandManager.kt │ │ ├── EventManager.kt │ │ └── ModuleManager.kt │ │ └── manager.kt │ └── frontend │ ├── Amber.kt │ ├── command │ ├── Command.kt │ └── commands │ │ └── TestCommand.kt │ ├── gui │ ├── GuiScreen.kt │ └── HudScreen.kt │ └── module │ ├── Module.kt │ └── modules │ ├── client │ ├── Blur.kt │ ├── GUIModule.kt │ ├── HUDModule.kt │ └── testRendering.kt │ ├── hud │ └── ExampleHUD.kt │ └── misc │ └── ExampleModule.kt └── resources ├── assets └── minecraft │ ├── amber │ ├── fade_in_blur.json │ └── img │ │ ├── logogradient.png │ │ └── logowhite.png │ └── shaders │ ├── post │ └── fade_in_blur.json │ └── program │ ├── fade_in_blur.fsh │ └── fade_in_blur.json ├── mcmod.info └── mixins.amber.json /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: [push,pull_request] 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up JDK 1.8 16 | uses: actions/setup-java@v1 17 | with: 18 | java-version: 1.8 19 | - name: Cache Gradle packages 20 | uses: actions/cache@v2 21 | with: 22 | path: | 23 | ~/.gradle/caches 24 | ~/.gradle/wrapper 25 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*','**/gradle-wrapper.properties') }} 26 | restore-keys: | 27 | ${{ runner.os }}-gradle- 28 | - name: Grant execute permission for gradlew 29 | run: chmod +x gradlew 30 | - name: Build with Gradle 31 | run: ./gradlew build 32 | - name: Upload package 33 | uses: actions/upload-artifact@v2 34 | with: 35 | path: build/libs/*-all.jar 36 | - name: Cleanup Gradle Cache 37 | run: | 38 | rm -rf ~/.gradle/caches/modules-2/modules-2.lock 39 | rm -rf ~/.gradle/caches/modules-2/gc.properties 40 | -------------------------------------------------------------------------------- /.github/workflows/nightly_cleanup.yml: -------------------------------------------------------------------------------- 1 | name: 'nightly_cleanup' 2 | on: 3 | schedule: 4 | - cron: '0 13 * * 1' 5 | 6 | jobs: 7 | delete-artifacts: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: kolpav/purge-artifacts-action@v1 11 | with: 12 | token: ${{ secrets.FOR_WEBHOOKS_SECRET }} 13 | expire-in: 7days # Setting this to 0 will delete all artifacts -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | 24 | # Files from Forge MDK 25 | forge*changelog.txt 26 | 27 | ## Mac files 28 | .DS_STORE 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU 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 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Amber Client 2 | ## What is this? 3 | This is an client developed by me in kotlin.
4 | I started this because i wanted to learn new things but, the more i coded this and the more bored i become and the less i felt i was learning.
5 | And now, since i complitely left minecraft anarchy developement, i find no reasons why on releasing this on the public.
6 | ## Features 7 | Nothing, i started this with 0 (i mean, i started this with a template (tempest) but, then i rewrote everything)
8 | It doesnt even have a gui, it just has renderUtils2d, a command system and uh, i think nothing else except some particles.
9 | No reasons on using this 10 | ## Credits 11 | * Tempest since i used it as a start 12 | * Lambda for the rounded render 13 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.4.30' 3 | repositories { 4 | mavenCentral() 5 | maven { url = 'https://files.minecraftforge.net/maven' } 6 | maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } 7 | } 8 | dependencies { 9 | classpath 'net.minecraftforge.gradle:ForgeGradle:3.+' 10 | classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0' 13 | } 14 | } 15 | 16 | apply plugin: 'net.minecraftforge.gradle' 17 | apply plugin: 'kotlin' 18 | apply plugin: "com.github.johnrengelman.shadow" 19 | apply plugin: 'eclipse' 20 | apply plugin: 'org.spongepowered.mixin' 21 | 22 | version project.modVersion 23 | group project.modGroup 24 | 25 | sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' 26 | 27 | minecraft { 28 | mappings channel: 'stable', version: '39-1.12' 29 | 30 | runs { 31 | client { 32 | workingDirectory project.file('run') 33 | 34 | property 'fml.coreMods.load', 'dev.amber.backend.mixin.AmberMixinLoader' 35 | property 'mixin.env.disableRefMap', 'true' 36 | 37 | property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' 38 | property 'forge.logging.console.level', 'debug' 39 | } 40 | } 41 | } 42 | 43 | //techale totally pasted this in from Kami Blue via suggestion of Xiaro... thanks! 44 | //need this to ensure mac support 45 | configurations { 46 | all { 47 | resolutionStrategy { 48 | force 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209' 49 | } 50 | } 51 | } 52 | 53 | dependencies { 54 | minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854' 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 56 | compile('org.spongepowered:mixin:0.7.4-SNAPSHOT') { 57 | exclude module: 'launchwrapper' 58 | exclude module: 'guava' 59 | exclude module: 'gson' 60 | exclude module: 'commons-io' 61 | } 62 | // Hacky way to get mixin work 63 | annotationProcessor('org.spongepowered:mixin:0.8.2:processor') { 64 | exclude module: 'gson' 65 | } 66 | } 67 | 68 | mixin { 69 | defaultObfuscationEnv 'searge' 70 | add sourceSets.main, 'mixins.amber.refmap.json' 71 | } 72 | 73 | processResources { 74 | inputs.property 'version', project.version 75 | 76 | exclude '**/rawimagefiles' 77 | 78 | from(sourceSets.main.resources.srcDirs) { 79 | include 'mcmod.info' 80 | expand 'version': project.version 81 | } 82 | } 83 | 84 | shadowJar { 85 | dependencies { 86 | include(dependency('org.spongepowered:mixin')) 87 | include(dependency('org.jetbrains.kotlin:kotlin-stdlib')) 88 | } 89 | exclude 'dummyThing' 90 | exclude 'LICENSE.txt' 91 | } 92 | 93 | reobf { 94 | shadowJar { 95 | classpath = sourceSets.main.compileClasspath 96 | } 97 | } 98 | 99 | jar { 100 | manifest { 101 | attributes([ 102 | 'MixinConfigs': 'mixins.amber.json', 103 | 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', 104 | 'TweakOrder': 0, 105 | 'FMLCorePluginContainsFMLMod': 'true', 106 | 'FMLCorePlugin': 'dev.amber.backend.mixin.AmberMixinLoader', 107 | 'ForceLoadAsMod': 'true', 108 | "Specification-Title": "", 109 | "Specification-Vendor": project.modName, 110 | "Specification-Version": project.modVersion, 111 | "Implementation-Title": project.name, 112 | "Implementation-Version": "${version}", 113 | "Implementation-Vendor" : project.modName, 114 | "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") 115 | ]) 116 | } 117 | 118 | } 119 | 120 | repositories { 121 | maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } 122 | maven { url = 'https://impactdevelopment.github.io/maven/' } 123 | maven { url = "https://jitpack.io" } 124 | } 125 | 126 | compileKotlin { 127 | kotlinOptions { 128 | jvmTarget = "1.8" 129 | } 130 | } 131 | 132 | compileTestKotlin { 133 | kotlinOptions { 134 | jvmTarget = "1.8" 135 | } 136 | } 137 | 138 | build.dependsOn(shadowJar) -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx3G 2 | org.gradle.daemon=false 3 | modName=amber 4 | modGroup=dev.amber 5 | modVersion=0.1.0 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechAle/Amber/86c89204f602ad17d72e1f56073bfa5a263ec284/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/dev/amber/api/render/GradientFontRenderer.java: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render; 2 | 3 | import com.ibm.icu.text.ArabicShaping; 4 | import com.ibm.icu.text.ArabicShapingException; 5 | import com.ibm.icu.text.Bidi; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.FontRenderer; 8 | import net.minecraft.client.renderer.BufferBuilder; 9 | import net.minecraft.client.renderer.GlStateManager; 10 | import net.minecraft.client.renderer.Tessellator; 11 | import net.minecraft.client.renderer.texture.TextureManager; 12 | import net.minecraft.client.renderer.texture.TextureUtil; 13 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats; 14 | import net.minecraft.client.resources.IResource; 15 | import net.minecraft.client.resources.IResourceManager; 16 | import net.minecraft.client.resources.IResourceManagerReloadListener; 17 | import net.minecraft.client.settings.GameSettings; 18 | import net.minecraft.util.ResourceLocation; 19 | import org.apache.commons.io.IOUtils; 20 | import org.lwjgl.opengl.GL11; 21 | 22 | import java.awt.image.BufferedImage; 23 | import java.io.Closeable; 24 | import java.io.IOException; 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.Locale; 28 | import java.util.Random; 29 | 30 | public class GradientFontRenderer implements IResourceManagerReloadListener 31 | { 32 | private static final ResourceLocation[] UNICODE_PAGE_LOCATIONS = new ResourceLocation[256]; 33 | protected final int[] charWidth = new int[256]; 34 | public int FONT_HEIGHT = 9; 35 | public Random fontRandom = new Random(); 36 | protected final byte[] glyphWidth = new byte[65536]; 37 | protected final ResourceLocation locationFontTexture; 38 | private final TextureManager renderEngine; 39 | protected float posX; 40 | protected float posY; 41 | private boolean bidiFlag; 42 | private boolean randomStyle; 43 | private boolean boldStyle; 44 | private boolean italicStyle; 45 | private boolean underlineStyle; 46 | private boolean strikethroughStyle; 47 | 48 | public GradientFontRenderer(GameSettings gameSettingsIn, ResourceLocation location, TextureManager textureManagerIn, boolean unicode) 49 | { 50 | this.locationFontTexture = location; 51 | this.renderEngine = textureManagerIn; 52 | bindTexture(this.locationFontTexture); 53 | 54 | for (int i = 0; i < 32; ++i) 55 | { 56 | int j = (i >> 3 & 1) * 85; 57 | int k = (i >> 2 & 1) * 170 + j; 58 | int l = (i >> 1 & 1) * 170 + j; 59 | int i1 = (i >> 0 & 1) * 170 + j; 60 | 61 | if (i == 6) 62 | { 63 | k += 85; 64 | } 65 | 66 | if (gameSettingsIn.anaglyph) 67 | { 68 | int j1 = (k * 30 + l * 59 + i1 * 11) / 100; 69 | int k1 = (k * 30 + l * 70) / 100; 70 | int l1 = (k * 30 + i1 * 70) / 100; 71 | k = j1; 72 | l = k1; 73 | i1 = l1; 74 | } 75 | 76 | if (i >= 16) 77 | { 78 | k /= 4; 79 | l /= 4; 80 | i1 /= 4; 81 | } 82 | 83 | int[] colorCode = new int[32]; 84 | colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255; 85 | } 86 | 87 | this.readGlyphSizes(); 88 | this.readFontTexture(); 89 | } 90 | 91 | public void onResourceManagerReload(IResourceManager resourceManager) 92 | { 93 | this.readFontTexture(); 94 | this.readGlyphSizes(); 95 | } 96 | 97 | private void readFontTexture() 98 | { 99 | IResource iresource = null; 100 | BufferedImage bufferedimage; 101 | 102 | try 103 | { 104 | iresource = getResource(this.locationFontTexture); 105 | bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream()); 106 | } 107 | catch (IOException ioexception) 108 | { 109 | throw new RuntimeException(ioexception); 110 | } 111 | finally 112 | { 113 | IOUtils.closeQuietly((Closeable)iresource); 114 | } 115 | 116 | int lvt_3_2_ = bufferedimage.getWidth(); 117 | int lvt_4_1_ = bufferedimage.getHeight(); 118 | int[] lvt_5_1_ = new int[lvt_3_2_ * lvt_4_1_]; 119 | bufferedimage.getRGB(0, 0, lvt_3_2_, lvt_4_1_, lvt_5_1_, 0, lvt_3_2_); 120 | int lvt_6_1_ = lvt_4_1_ / 16; 121 | int lvt_7_1_ = lvt_3_2_ / 16; 122 | boolean lvt_8_1_ = true; 123 | float lvt_9_1_ = 8.0F / (float)lvt_7_1_; 124 | 125 | for (int lvt_10_1_ = 0; lvt_10_1_ < 256; ++lvt_10_1_) 126 | { 127 | int j1 = lvt_10_1_ % 16; 128 | int k1 = lvt_10_1_ / 16; 129 | 130 | if (lvt_10_1_ == 32) 131 | { 132 | this.charWidth[lvt_10_1_] = 4; 133 | } 134 | 135 | int l1; 136 | 137 | for (l1 = lvt_7_1_ - 1; l1 >= 0; --l1) 138 | { 139 | int i2 = j1 * lvt_7_1_ + l1; 140 | boolean flag1 = true; 141 | 142 | for (int j2 = 0; j2 < lvt_6_1_ && flag1; ++j2) 143 | { 144 | int k2 = (k1 * lvt_7_1_ + j2) * lvt_3_2_; 145 | 146 | if ((lvt_5_1_[i2 + k2] >> 24 & 255) != 0) 147 | { 148 | flag1 = false; 149 | } 150 | } 151 | 152 | if (!flag1) 153 | { 154 | break; 155 | } 156 | } 157 | 158 | ++l1; 159 | this.charWidth[lvt_10_1_] = (int)(0.5D + (double)((float)l1 * lvt_9_1_)) + 1; 160 | } 161 | } 162 | 163 | private void readGlyphSizes() 164 | { 165 | IResource iresource = null; 166 | 167 | try 168 | { 169 | iresource = getResource(new ResourceLocation("font/glyph_sizes.bin")); 170 | iresource.getInputStream().read(this.glyphWidth); 171 | } 172 | catch (IOException ioexception) 173 | { 174 | throw new RuntimeException(ioexception); 175 | } 176 | finally 177 | { 178 | IOUtils.closeQuietly((Closeable)iresource); 179 | } 180 | } 181 | 182 | private float renderChar(char ch, boolean italic, int startColor, int endColor, boolean horizontal) 183 | { 184 | if (ch == 160) return 4.0F; // forge: display nbsp as space. MC-2595 185 | if (ch == ' ') 186 | { 187 | return 4.0F; 188 | } 189 | else 190 | { 191 | int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(ch); 192 | return i != -1 ? this.renderDefaultChar(i, italic, startColor, endColor, horizontal) : -1; 193 | } 194 | } 195 | 196 | protected float renderDefaultChar(int ch, boolean italic, int startColor, int endColor, boolean horizontal) 197 | { 198 | float startAlpha = ((startColor >> 24) & 0xFF) / 255f; 199 | float startRed = ((startColor >> 16) & 0xFF) / 255f; 200 | float startGreen = ((startColor >> 8) & 0xFF) / 255f; 201 | float startBlue = (startColor & 0xFF) / 255f; 202 | 203 | float endAlpha = ((endColor >> 24) & 0xFF) / 255f; 204 | float endRed = ((endColor >> 16) & 0xFF) / 255f; 205 | float endGreen = ((endColor >> 8) & 0xFF) / 255f; 206 | float endBlue = (endColor & 0xFF) / 255f; 207 | 208 | float charXPos = ch % 16 * 8f; 209 | float charYPos = (ch / 16) * 8f; 210 | bindTexture(this.locationFontTexture); 211 | int charWidth = this.charWidth[ch]; 212 | float width = (float) charWidth - 0.01F; 213 | 214 | GlStateManager.shadeModel(GL11.GL_SMOOTH); 215 | GlStateManager.glBegin(GL11.GL_QUADS); 216 | 217 | GlStateManager.color(startRed, startGreen, startBlue, startAlpha); 218 | GlStateManager.glTexCoord2f(charXPos / 128.0F, charYPos / 128.0F); // 0 0 219 | GlStateManager.glVertex3f(this.posX, this.posY, 0.0F); 220 | 221 | if (horizontal) { 222 | GlStateManager.color(startRed, startGreen, startBlue, startAlpha); 223 | } else { 224 | GlStateManager.color(endRed, endGreen, endBlue, endAlpha); 225 | } 226 | GlStateManager.glTexCoord2f(charXPos / 128.0F, (charYPos + 7.99F) / 128.0F); // 0 1 227 | GlStateManager.glVertex3f(this.posX, this.posY + 7.99F, 0.0F); 228 | 229 | GlStateManager.color(endRed, endGreen, endBlue, endAlpha); 230 | GlStateManager.glTexCoord2f((charXPos + width - 1.0F) / 128.0F, (charYPos + 7.99F) / 128.0F); // 1 1 231 | GlStateManager.glVertex3f(this.posX + width - 1.0F, this.posY + 7.99F, 0.0F); 232 | 233 | if (horizontal) { 234 | GlStateManager.color(endRed, endGreen, endBlue, endAlpha); 235 | } else { 236 | GlStateManager.color(startRed, startGreen, startBlue, startAlpha); 237 | } 238 | GlStateManager.glTexCoord2f((charXPos + width - 1.0F) / 128.0F, charYPos / 128.0F); // 1 0 239 | GlStateManager.glVertex3f(this.posX + width - 1.0F, this.posY, 0.0F); 240 | 241 | GlStateManager.glEnd(); 242 | GlStateManager.shadeModel(GL11.GL_FLAT); 243 | return (float) charWidth; 244 | } 245 | 246 | private ResourceLocation getUnicodePageLocation(int page) 247 | { 248 | if (UNICODE_PAGE_LOCATIONS[page] == null) 249 | { 250 | UNICODE_PAGE_LOCATIONS[page] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", page)); 251 | } 252 | 253 | return UNICODE_PAGE_LOCATIONS[page]; 254 | } 255 | 256 | private void loadGlyphTexture(int page) 257 | { 258 | bindTexture(this.getUnicodePageLocation(page)); 259 | } 260 | 261 | protected float renderUnicodeChar(char ch, boolean italic) 262 | { 263 | int i = this.glyphWidth[ch] & 255; 264 | 265 | if (i == 0) 266 | { 267 | return 0.0F; 268 | } 269 | else 270 | { 271 | int j = ch / 256; 272 | this.loadGlyphTexture(j); 273 | int k = i >>> 4; 274 | int l = i & 15; 275 | float f = (float)k; 276 | float f1 = (float)(l + 1); 277 | float f2 = (float)(ch % 16 * 16) + f; 278 | float f3 = (float)((ch & 255) / 16 * 16); 279 | float f4 = f1 - f - 0.02F; 280 | float f5 = italic ? 1.0F : 0.0F; 281 | GlStateManager.glBegin(5); 282 | GlStateManager.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); 283 | GlStateManager.glVertex3f(this.posX + f5, this.posY, 0.0F); 284 | GlStateManager.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); 285 | GlStateManager.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); 286 | GlStateManager.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); 287 | GlStateManager.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); 288 | GlStateManager.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); 289 | GlStateManager.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); 290 | GlStateManager.glEnd(); 291 | return (f1 - f) / 2.0F + 1.0F; 292 | } 293 | } 294 | 295 | 296 | public int drawString(String text, float x, float y, int topColor, int bottomColor, boolean dropShadow, boolean horizontal) 297 | { 298 | enableAlpha(); 299 | this.resetStyles(); 300 | int i; 301 | 302 | if (dropShadow) 303 | { 304 | i = this.renderString(text, x + 1.0F, y + 1.0F, topColor, bottomColor, horizontal, dropShadow); 305 | i = Math.max(i, this.renderString(text, x, y, topColor, bottomColor, horizontal, dropShadow)); 306 | } 307 | else 308 | { 309 | i = this.renderString(text, x, y, topColor, bottomColor, horizontal, dropShadow); 310 | } 311 | 312 | return i; 313 | } 314 | 315 | private String bidiReorder(String text) 316 | { 317 | try 318 | { 319 | Bidi bidi = new Bidi((new ArabicShaping(8)).shape(text), 127); 320 | bidi.setReorderingMode(0); 321 | return bidi.writeReordered(2); 322 | } 323 | catch (ArabicShapingException var3) 324 | { 325 | return text; 326 | } 327 | } 328 | 329 | private void resetStyles() 330 | { 331 | this.randomStyle = false; 332 | this.boldStyle = false; 333 | this.italicStyle = false; 334 | this.underlineStyle = false; 335 | this.strikethroughStyle = false; 336 | } 337 | 338 | private void renderStringAtPos(String text, boolean shadow, int startColor, int endColor, boolean horrizontal) 339 | { 340 | float totalWidth = this.getStringWidth(text); 341 | float currentCountWidth = 0; 342 | for (int i = 0; i < text.length(); ++i) 343 | { 344 | char c0 = text.charAt(i); 345 | 346 | if (c0 == 167 && i + 1 < text.length()) 347 | { 348 | int i1 = "0123456789abcdefklmnor".indexOf(String.valueOf(text.charAt(i + 1)).toLowerCase(Locale.ROOT).charAt(0)); 349 | 350 | if (i1 < 16) 351 | { 352 | this.randomStyle = false; 353 | this.boldStyle = false; 354 | this.strikethroughStyle = false; 355 | this.underlineStyle = false; 356 | this.italicStyle = false; 357 | 358 | if (i1 < 0) 359 | { 360 | i1 = 15; 361 | } 362 | 363 | if (shadow) 364 | { 365 | i1 += 16; 366 | } 367 | } 368 | else if (i1 == 16) 369 | { 370 | this.randomStyle = true; 371 | } 372 | else if (i1 == 17) 373 | { 374 | this.boldStyle = true; 375 | } 376 | else if (i1 == 18) 377 | { 378 | this.strikethroughStyle = true; 379 | } 380 | else if (i1 == 19) 381 | { 382 | this.underlineStyle = true; 383 | } 384 | else if (i1 == 20) 385 | { 386 | this.italicStyle = true; 387 | } 388 | else { 389 | this.randomStyle = false; 390 | this.boldStyle = false; 391 | this.strikethroughStyle = false; 392 | this.underlineStyle = false; 393 | this.italicStyle = false; 394 | } 395 | 396 | ++i; 397 | } 398 | else 399 | { 400 | int j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); 401 | 402 | if (this.randomStyle && j != -1) 403 | { 404 | int k = this.getCharWidth(c0); 405 | char c1; 406 | 407 | while (true) 408 | { 409 | j = this.fontRandom.nextInt("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".length()); 410 | c1 = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".charAt(j); 411 | 412 | if (k == this.getCharWidth(c1)) 413 | { 414 | break; 415 | } 416 | } 417 | 418 | c0 = c1; 419 | } 420 | 421 | float f1 = j == -1 ? 0.5f : 1f; 422 | boolean flag = (c0 == 0 || j == -1) && shadow; 423 | 424 | if (flag) 425 | { 426 | this.posX -= f1; 427 | this.posY -= f1; 428 | } 429 | 430 | float f; 431 | if (horrizontal) { 432 | float nextCharWidth = this.getCharWidth(c0); 433 | float firstMix = currentCountWidth / totalWidth; 434 | float lastMix = (currentCountWidth + nextCharWidth) / totalWidth; 435 | int firstColor = colorMix(startColor, endColor, firstMix); 436 | int lastColor = colorMix(startColor, endColor, lastMix); 437 | f = this.renderChar(c0, this.italicStyle, firstColor, lastColor, horrizontal); 438 | currentCountWidth += f; 439 | } else { 440 | f = this.renderChar(c0, this.italicStyle, startColor, endColor, horrizontal); 441 | } 442 | 443 | if (flag) 444 | { 445 | this.posX += f1; 446 | this.posY += f1; 447 | } 448 | 449 | if (this.boldStyle) 450 | { 451 | this.posX += f1; 452 | 453 | if (flag) 454 | { 455 | this.posX -= f1; 456 | this.posY -= f1; 457 | } 458 | 459 | this.renderChar(c0, this.italicStyle, startColor, endColor, horrizontal); 460 | this.posX -= f1; 461 | 462 | if (flag) 463 | { 464 | this.posX += f1; 465 | this.posY += f1; 466 | } 467 | 468 | ++f; 469 | } 470 | doDraw(f); 471 | } 472 | } 473 | } 474 | 475 | private int colorMix(int startColor, int endColor, float mix) { 476 | float startAlpha = ((startColor >> 24) & 0xFF) / 255f; 477 | float startRed = ((startColor >> 16) & 0xFF) / 255f; 478 | float startGreen = ((startColor >> 8) & 0xFF) / 255f; 479 | float startBlue = (startColor & 0xFF) / 255f; 480 | 481 | float endAlpha = ((endColor >> 24) & 0xFF) / 255f; 482 | float endRed = ((endColor >> 16) & 0xFF) / 255f; 483 | float endGreen = ((endColor >> 8) & 0xFF) / 255f; 484 | float endBlue = (endColor & 0xFF) / 255f; 485 | 486 | int mixAlpha = (int) (((1 - mix) * startAlpha + mix * endAlpha) * 255); 487 | int mixRed = (int) (((1 - mix) * startRed + mix * endRed) * 255); 488 | int mixGreen = (int) (((1 - mix) * startGreen + mix * endGreen) * 255); 489 | int mixBlue = (int) (((1 - mix) * startBlue + mix * endBlue) * 255); 490 | 491 | return (mixAlpha << 24) | (mixRed << 16) | (mixGreen << 8) | mixBlue; 492 | } 493 | 494 | protected void doDraw(float f) 495 | { 496 | { 497 | { 498 | 499 | if (this.strikethroughStyle) 500 | { 501 | Tessellator tessellator = Tessellator.getInstance(); 502 | BufferBuilder bufferbuilder = tessellator.getBuffer(); 503 | GlStateManager.disableTexture2D(); 504 | bufferbuilder.begin(7, DefaultVertexFormats.POSITION); 505 | bufferbuilder.pos((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D).endVertex(); 506 | bufferbuilder.pos((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D).endVertex(); 507 | bufferbuilder.pos((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D).endVertex(); 508 | bufferbuilder.pos((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D).endVertex(); 509 | tessellator.draw(); 510 | GlStateManager.enableTexture2D(); 511 | } 512 | 513 | if (this.underlineStyle) 514 | { 515 | Tessellator tessellator1 = Tessellator.getInstance(); 516 | BufferBuilder bufferbuilder1 = tessellator1.getBuffer(); 517 | GlStateManager.disableTexture2D(); 518 | bufferbuilder1.begin(7, DefaultVertexFormats.POSITION); 519 | int l = this.underlineStyle ? -1 : 0; 520 | bufferbuilder1.pos((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D).endVertex(); 521 | bufferbuilder1.pos((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D).endVertex(); 522 | bufferbuilder1.pos((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D).endVertex(); 523 | bufferbuilder1.pos((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D).endVertex(); 524 | tessellator1.draw(); 525 | GlStateManager.enableTexture2D(); 526 | } 527 | 528 | this.posX += (float)((int)f); 529 | } 530 | } 531 | } 532 | 533 | private int renderString(String text, float x, float y, int colorTop, int colorBottom, boolean horrizontal, boolean dropShadow) 534 | { 535 | if (text == null) 536 | { 537 | return 0; 538 | } 539 | else 540 | { 541 | if (this.bidiFlag) 542 | { 543 | text = this.bidiReorder(text); 544 | } 545 | 546 | if ((colorTop & -67108864) == 0) 547 | { 548 | colorTop |= -16777216; 549 | } 550 | 551 | if ((colorBottom & -67108864) == 0) 552 | colorBottom |= -16777216; 553 | 554 | if (dropShadow) 555 | { 556 | colorTop = (colorTop & 16579836) >> 2 | colorTop & -16777216; 557 | colorBottom = (colorBottom & 16579836) >> 2 | colorBottom & -16777216; 558 | } 559 | 560 | this.posX = x; 561 | this.posY = y; 562 | this.renderStringAtPos(text, dropShadow, colorTop, colorBottom, horrizontal); 563 | return (int)this.posX; 564 | } 565 | } 566 | 567 | public int getStringWidth(String text) 568 | { 569 | if (text == null) 570 | { 571 | return 0; 572 | } 573 | else 574 | { 575 | int i = 0; 576 | boolean flag = false; 577 | 578 | for (int j = 0; j < text.length(); ++j) 579 | { 580 | char c0 = text.charAt(j); 581 | int k = this.getCharWidth(c0); 582 | 583 | if (k < 0 && j < text.length() - 1) 584 | { 585 | ++j; 586 | c0 = text.charAt(j); 587 | 588 | if (c0 != 'l' && c0 != 'L') 589 | { 590 | if (c0 == 'r' || c0 == 'R') 591 | { 592 | flag = false; 593 | } 594 | } 595 | else 596 | { 597 | flag = true; 598 | } 599 | 600 | k = 0; 601 | } 602 | 603 | i += k; 604 | 605 | if (flag && k > 0) 606 | { 607 | ++i; 608 | } 609 | } 610 | 611 | return i; 612 | } 613 | } 614 | 615 | public int getCharWidth(char character) 616 | { 617 | if (character == 160) return 4; // forge: display nbsp as space. MC-2595 618 | if (character == 167) 619 | { 620 | return -1; 621 | } 622 | else if (character == ' ') 623 | { 624 | return 4; 625 | } 626 | else 627 | { 628 | int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(character); 629 | 630 | if (character > 0 && i != -1) 631 | { 632 | return this.charWidth[i]; 633 | } 634 | else if (this.glyphWidth[character] != 0) 635 | { 636 | int j = this.glyphWidth[character] & 255; 637 | int k = j >>> 4; 638 | int l = j & 15; 639 | ++l; 640 | return (l - k) / 2 + 1; 641 | } 642 | else 643 | { 644 | return 0; 645 | } 646 | } 647 | } 648 | 649 | 650 | public void setBidiFlag(boolean bidiFlagIn) 651 | { 652 | this.bidiFlag = bidiFlagIn; 653 | } 654 | 655 | public List listFormattedStringToWidth(String str, int wrapWidth) 656 | { 657 | return Arrays.asList(this.wrapFormattedStringToWidth(str, wrapWidth).split("\n")); 658 | } 659 | 660 | String wrapFormattedStringToWidth(String str, int wrapWidth) 661 | { 662 | int i = this.sizeStringToWidth(str, wrapWidth); 663 | 664 | if (str.length() <= i) 665 | { 666 | return str; 667 | } 668 | else 669 | { 670 | String s = str.substring(0, i); 671 | char c0 = str.charAt(i); 672 | boolean flag = c0 == ' ' || c0 == '\n'; 673 | String s1 = getFormatFromString(s) + str.substring(i + (flag ? 1 : 0)); 674 | return s + "\n" + this.wrapFormattedStringToWidth(s1, wrapWidth); 675 | } 676 | } 677 | 678 | private int sizeStringToWidth(String str, int wrapWidth) 679 | { 680 | int i = str.length(); 681 | int j = 0; 682 | int k = 0; 683 | int l = -1; 684 | 685 | for (boolean flag = false; k < i; ++k) 686 | { 687 | char c0 = str.charAt(k); 688 | 689 | switch (c0) 690 | { 691 | case '\n': 692 | --k; 693 | break; 694 | case ' ': 695 | l = k; 696 | default: 697 | j += this.getCharWidth(c0); 698 | 699 | if (flag) 700 | { 701 | ++j; 702 | } 703 | 704 | break; 705 | case '\u00a7': 706 | 707 | if (k < i - 1) 708 | { 709 | ++k; 710 | char c1 = str.charAt(k); 711 | 712 | if (c1 != 'l' && c1 != 'L') 713 | { 714 | if (c1 == 'r' || c1 == 'R' || isFormatColor(c1)) 715 | { 716 | flag = false; 717 | } 718 | } 719 | else 720 | { 721 | flag = true; 722 | } 723 | } 724 | } 725 | 726 | if (c0 == '\n') 727 | { 728 | ++k; 729 | l = k; 730 | break; 731 | } 732 | 733 | if (j > wrapWidth) 734 | { 735 | break; 736 | } 737 | } 738 | 739 | return k != i && l != -1 && l < k ? l : k; 740 | } 741 | 742 | private static boolean isFormatColor(char colorChar) 743 | { 744 | return colorChar >= '0' && colorChar <= '9' || colorChar >= 'a' && colorChar <= 'f' || colorChar >= 'A' && colorChar <= 'F'; 745 | } 746 | 747 | private static boolean isFormatSpecial(char formatChar) 748 | { 749 | return formatChar >= 'k' && formatChar <= 'o' || formatChar >= 'K' && formatChar <= 'O' || formatChar == 'r' || formatChar == 'R'; 750 | } 751 | 752 | public static String getFormatFromString(String text) 753 | { 754 | String s = ""; 755 | int i = -1; 756 | int j = text.length(); 757 | 758 | while ((i = text.indexOf(167, i + 1)) != -1) 759 | { 760 | if (i < j - 1) 761 | { 762 | char c0 = text.charAt(i + 1); 763 | 764 | if (isFormatColor(c0)) 765 | { 766 | s = "\u00a7" + c0; 767 | } 768 | else if (isFormatSpecial(c0)) 769 | { 770 | s = s + "\u00a7" + c0; 771 | } 772 | } 773 | } 774 | 775 | return s; 776 | } 777 | 778 | 779 | protected void enableAlpha() 780 | { 781 | GlStateManager.enableAlpha(); 782 | } 783 | 784 | protected void bindTexture(ResourceLocation location) 785 | { 786 | renderEngine.bindTexture(location); 787 | } 788 | 789 | protected IResource getResource(ResourceLocation location) throws IOException 790 | { 791 | return Minecraft.getMinecraft().getResourceManager().getResource(location); 792 | } 793 | 794 | } -------------------------------------------------------------------------------- /src/main/java/dev/amber/backend/mixin/AmberMixinLoader.java: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.mixin; 2 | 3 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | import org.spongepowered.asm.launch.MixinBootstrap; 7 | import org.spongepowered.asm.mixin.MixinEnvironment; 8 | import org.spongepowered.asm.mixin.Mixins; 9 | 10 | import java.util.Map; 11 | 12 | /* 13 | @author: Lambda 14 | @source: https://github.com/lambda-client/lambda/blob/master/src/main/java/com/lambda/client/mixin/MixinLoaderForge.java 15 | */ 16 | 17 | @IFMLLoadingPlugin.Name("AmberMixinLoader") 18 | @IFMLLoadingPlugin.MCVersion("1.12.2") 19 | public class AmberMixinLoader implements IFMLLoadingPlugin { 20 | 21 | /* This is NOT using LambdaMod, as importing it causes the issue described here: https://github.com/SpongePowered/Mixin/issues/388 */ 22 | public static final Logger log = LogManager.getLogger("Amber"); 23 | private static boolean isObfuscatedEnvironment = false; 24 | 25 | public AmberMixinLoader() { 26 | log.info("Amber init mixin..."); 27 | MixinBootstrap.init(); 28 | Mixins.addConfiguration("mixins.amber.json"); 29 | MixinEnvironment.getDefaultEnvironment().setObfuscationContext("searge"); 30 | log.info("Amber end mixin..."); 31 | log.info(MixinEnvironment.getDefaultEnvironment().getObfuscationContext()); 32 | } 33 | 34 | @Override 35 | public String[] getASMTransformerClass() { 36 | return new String[0]; 37 | } 38 | 39 | @Override 40 | public String getModContainerClass() { 41 | return null; 42 | } 43 | 44 | @Override 45 | public String getSetupClass() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public void injectData(Map data) { 51 | isObfuscatedEnvironment = (boolean) data.get("runtimeDeobfuscationEnabled"); 52 | } 53 | 54 | @Override 55 | public String getAccessTransformerClass() { 56 | return null; 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/java/dev/amber/backend/mixin/mixins/MixinGuiBossOverlay.java: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.mixin.mixins; 2 | 3 | import net.minecraft.client.gui.GuiBossOverlay; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.At; 6 | import org.spongepowered.asm.mixin.injection.Inject; 7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 8 | 9 | @Mixin(GuiBossOverlay.class) 10 | public class MixinGuiBossOverlay { 11 | 12 | @Inject(method = "renderBossHealth", at = @At("HEAD"), cancellable = true) 13 | private void renderBossHealth(CallbackInfo callbackInfo) { 14 | //callbackInfo.cancel(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/render/Element.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render 2 | 3 | abstract class Element { 4 | 5 | open var x: Float = 0f 6 | open var y: Float = 0f 7 | 8 | abstract fun render(): Boolean 9 | 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/render/RenderUtil2d.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render 2 | 3 | /** 4 | * @author TechAle 5 | * @since 12/09/21 6 | */ 7 | 8 | import com.mojang.realmsclient.gui.ChatFormatting 9 | import dev.amber.api.util.Globals.mc 10 | import dev.amber.api.util.MathUtils 11 | import dev.amber.api.variables.ABColor 12 | import net.minecraft.client.renderer.GlStateManager 13 | import net.minecraft.util.ResourceLocation 14 | import net.minecraft.util.math.Vec2f 15 | import org.lwjgl.opengl.GL11.* 16 | import kotlin.math.* 17 | import net.minecraft.client.Minecraft 18 | 19 | import net.minecraft.client.gui.ScaledResolution 20 | import net.minecraft.client.renderer.BufferBuilder 21 | import net.minecraft.client.renderer.Tessellator 22 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats 23 | import net.minecraft.realms.RealmsScreen.blit 24 | import org.lwjgl.opengl.GL11 25 | import java.io.BufferedReader 26 | import java.io.File 27 | import java.io.InputStreamReader 28 | import javax.imageio.ImageIO 29 | 30 | 31 | object RenderUtil2d { 32 | 33 | //region Rect 34 | 35 | /// Normal rect 36 | // Normal 37 | fun drawRect(Start: Vec2f, width: Float, height: Float, c: ABColor, once : Boolean = false) { 38 | // Prepare opengl 39 | if (once) 40 | VertexUtil.prepareGl() 41 | 42 | // We are drawing quads lol 43 | glBegin(GL_QUADS) 44 | // Prepare color and add vertices 45 | c.glColor() 46 | VertexUtil.add(Start) 47 | VertexUtil.add(Start.add(0f, height)) 48 | VertexUtil.add(Start.add(width, height)) 49 | VertexUtil.add(Start.add(width, 0f)) 50 | 51 | // End and release gl 52 | glEnd() 53 | if (once) 54 | VertexUtil.releaseGL() 55 | } 56 | // Gradient 57 | fun drawRect(Start: Vec2f, width: Float, height: Float, once : Boolean = false, colors: Array, topBottom: Boolean = false) { 58 | 59 | when(colors.size) { 60 | // No colors, return 61 | 0 -> return 62 | // Draw normal rect 63 | 1 -> drawRect(Start, width, height, colors[0], once) 64 | // Every other cases 65 | else -> { 66 | // Setup colors depending on the size 67 | val arr = when (colors.size) { 68 | 2, 3 -> if (topBottom) arrayOf(colors[0], colors[1], colors[1], colors[0]) 69 | else arrayOf(colors[0], colors[0], colors[1], colors[1]) 70 | else -> Array(4) {colors[it]} 71 | } 72 | 73 | // Prepare gl 74 | if (once) 75 | VertexUtil.prepareGl() 76 | 77 | // Draw with vertixes (and relative colors 78 | glBegin(GL_QUADS) 79 | VertexUtil.add(Start, arr[0]) 80 | VertexUtil.add(Start.add(0f, height), arr[1]) 81 | VertexUtil.add(Start.add(width, height), arr[2]) 82 | VertexUtil.add(Start.add(width, 0f), arr[3]) 83 | // End 84 | glEnd() 85 | 86 | // Release gl 87 | if (once) 88 | VertexUtil.releaseGL() 89 | } 90 | } 91 | } 92 | 93 | /// Outline rect 94 | // Normal 95 | fun drawRectOutline(Start: Vec2f, width: Float, height: Float, borderWidth: Float, borderColor: ABColor, once: Boolean = false) { 96 | // Prepare 97 | if (once) 98 | VertexUtil.prepareGl() 99 | 100 | // Top 101 | drawRect(Start, width , borderWidth, borderColor) 102 | // Bottom 103 | drawRect(Start.add(0f, height), width, borderWidth, borderColor) 104 | // Left 105 | drawRect(Start.add(0f, borderWidth), borderWidth, height - borderWidth, borderColor) 106 | // Right 107 | drawRect(Start.add(width, borderWidth), -borderWidth, height - borderWidth, borderColor) 108 | 109 | // Release 110 | if (once) 111 | VertexUtil.releaseGL() 112 | } 113 | // Gradient 114 | fun drawRectOutline(Start: Vec2f, width: Float, height: Float, borderWidth: Float, once : Boolean = false, colors: Array, topBottom: Boolean = false) { 115 | 116 | when(colors.size) { 117 | // No colors, return 118 | 0 -> return 119 | // Draw normal rect 120 | 1 -> drawRectOutline(Start, width, height, borderWidth, colors[0], once) 121 | else -> { 122 | val arr = when (colors.size) { 123 | 2, 3 -> if (topBottom) arrayOf(colors[0], colors[1], colors[1], colors[0]) 124 | else arrayOf(colors[0], colors[0], colors[1], colors[1]) 125 | else -> Array(4) {colors[it]} 126 | } 127 | 128 | // Prepare gl 129 | if (once) 130 | VertexUtil.prepareGl() 131 | 132 | /// Vertices 133 | // Top left 134 | drawRect(Start, borderWidth, borderWidth, arr[0], false) 135 | // Top right 136 | drawRect(Start.add(width, 0f), -borderWidth, borderWidth, arr[1], false) 137 | // Bottom right 138 | drawRect(Start.add(width, height), -borderWidth, -borderWidth, arr[2], false) 139 | // Bottom left 140 | drawRect(Start.add(0f, height), borderWidth, -borderWidth, arr[3], false) 141 | /// Gradient 142 | // Top 143 | drawRect(Start.add(borderWidth, 0f), width - borderWidth*2, borderWidth, false, arrayOf(arr[0], arr[1]), topBottom = false) 144 | // Right 145 | drawRect(Start.add(width, borderWidth), -borderWidth, height - borderWidth, false, arrayOf(arr[1], arr[2]), topBottom = true) 146 | // Bottom 147 | drawRect(Start.add(borderWidth, height), width - borderWidth*2, -borderWidth, false, arrayOf(arr[3], arr[2]), topBottom = false) 148 | // Left 149 | drawRect(Start.add(0f, borderWidth), borderWidth, height - borderWidth, false, arrayOf(arr[0], arr[3]), topBottom = true) 150 | 151 | // Release gl 152 | if (once) 153 | VertexUtil.releaseGL() 154 | } 155 | } 156 | 157 | } 158 | 159 | /// Border rect 160 | // Normal 161 | fun drawRectBorder(Start: Vec2f, width: Float, height: Float, borderWidth: Float, insideC: ABColor, borderColor: ABColor, once : Boolean = false ) { 162 | if (once) 163 | VertexUtil.prepareGl() 164 | 165 | // Draw inside 166 | drawRect(Start.add(borderWidth, borderWidth), width - borderWidth , height - borderWidth, insideC) 167 | /// Draw border 168 | drawRectOutline(Start, width, height, borderWidth, borderColor, once) 169 | 170 | if (once) 171 | VertexUtil.releaseGL() 172 | } 173 | // Gradient 174 | fun drawRectBorder(Start: Vec2f, width: Float, height: Float, borderWidth: Float, insideC: Array, insideTopBottom: Boolean = false, 175 | borderColor: Array, borderTopBottom: Boolean = false, once : Boolean = false ) { 176 | if (once) 177 | VertexUtil.prepareGl() 178 | 179 | // Draw inside 180 | drawRect(Start.add(borderWidth, borderWidth), width - borderWidth, height - borderWidth, false, insideC, insideTopBottom) 181 | /// Draw border 182 | drawRectOutline(Start, width, height, borderWidth, false, borderColor, borderTopBottom) 183 | 184 | if (once) 185 | VertexUtil.releaseGL() 186 | } 187 | 188 | //endregion 189 | 190 | //region Circle 191 | 192 | /// Filled circle 193 | // Normal 194 | fun drawCircleFilled(center: Vec2f, radius: Float, segments: Int = 0, color: ABColor, angleRange: Pair = Pair(0f, 360f), once: Boolean = false, onlyVertex: Boolean = false) { 195 | // Prepare gl 196 | if (once) 197 | VertexUtil.prepareGl() 198 | 199 | // Draw the circle main function 200 | drawArcFilled(center, radius, angleRange, segments, color, onlyVertex) 201 | 202 | // Release gl 203 | if (once) 204 | VertexUtil.releaseGL() 205 | } 206 | private fun drawArcFilled(center: Vec2f, radius: Float, angleRange: Pair, segments: Int = 0, color: ABColor, onlyVertex: Boolean = false) { 207 | // Get segments 208 | val arcVertices = getArcVertices(center, radius, angleRange, segments) 209 | // Draw everything 210 | drawTriangleFan(center, arcVertices, color, false, onlyVertex) 211 | } 212 | private fun getArcVertices(center: Vec2f, radius: Float, angleRange: Pair, segments: Int): Array { 213 | // I dunno what's here, some geometry stuff i guess. Thanks lambda 214 | val range = max(angleRange.first, angleRange.second) - min(angleRange.first, angleRange.second) 215 | val seg = calcSegments(segments, radius, range) 216 | val segAngle = (range / seg.toFloat()) 217 | 218 | return Array(seg + 1) { 219 | val angle = Math.toRadians((it * segAngle + angleRange.first).toDouble()) 220 | val unRounded = Vec2f(sin(angle).toFloat(), (-cos(angle)).toFloat()).times(radius).add(center) 221 | Vec2f(MathUtils.round(unRounded.x, 8).toFloat(), MathUtils.round(unRounded.y, 8).toFloat()) 222 | } 223 | } 224 | private fun calcSegments(segmentsIn: Int, radius: Float, range: Float): Int { 225 | // I dunno what's here, thanks lambda 226 | if (segmentsIn != -0) return segmentsIn 227 | val segments = radius * 0.5 * PI * (range / 360.0) 228 | return max(segments.roundToInt(), 16) 229 | } 230 | 231 | // Gradient 232 | fun drawCircleFilled(center: Vec2f, radius: Float, segments: Int = 0, color: Array, angleRange: Pair = Pair(0f, 360f), once: Boolean = false) { 233 | 234 | when (color.size) { 235 | // No circle 236 | 0 -> return 237 | // 1 color circle 238 | 1 -> drawCircleFilled(center, radius, segments, color[0], angleRange, once) 239 | else -> { 240 | // Prepearel 241 | if (once) 242 | VertexUtil.prepareGl() 243 | // Main function drawing circle 244 | drawArcFilled(center, radius, angleRange, segments, color) 245 | // Release 246 | if (once) 247 | VertexUtil.releaseGL() 248 | } 249 | 250 | } 251 | } 252 | private fun drawArcFilled(center: Vec2f, radius: Float, angleRange: Pair, segments: Int = 0, color: Array) { 253 | // Get vertices 254 | val arcVertices = getArcVertices(center, radius, angleRange, segments) 255 | // Draw 256 | drawTriangleFan(center, arcVertices, getGradientVertices(color, arcVertices), false) 257 | } 258 | 259 | fun getGradientVertices(color: Array, arcVertices: Array) : ArrayList { 260 | /* 261 | There, we have to calculate for each vertices the relative color. 262 | */ 263 | // First we have to understand the number od divisions (we remove 1 because the first color is at beginning) 264 | val sizes = color.size.toInt() - 1 265 | val pieces = arcVertices.size / (sizes.toFloat()) 266 | // Output 267 | var finalColors = arrayListOf() 268 | for (i in 0..color.size - 2) { 269 | // Get rgba 270 | val red = color[i].red 271 | val blue = color[i].blue 272 | var green = color[i].green 273 | var alpha = color[i].alpha 274 | // Here we have to take the percent of he changes 275 | val rChange = (color[i + 1].red - red)/pieces 276 | val gChange = (color[i + 1].green - green)/pieces 277 | val bChange = (color[i + 1].blue - blue)/pieces 278 | val aChange = (color[i + 1].alpha - alpha)/pieces 279 | // And for every piece 280 | for(j in 0..sizes) { 281 | // We add the relative color going percent (from 0% to 100%) 282 | finalColors.add(ABColor(red + (rChange * j).toInt(), green + (gChange*j).toInt(), blue + (bChange*j).toInt(), alpha + (aChange*j).toInt())) 283 | } 284 | 285 | } 286 | 287 | /* 288 | For some reasons, sometimes, the number of colors is not excact the same. 289 | We need it to be excact the same so, instead of debugging and making the entire 290 | code above 1000 complex, i just hard patch it by adding/removing colors 291 | */ 292 | // If we are above the limit 293 | if (finalColors.size > arcVertices.size) { 294 | // Remove till it's the same 295 | while (finalColors.size != arcVertices.size) 296 | finalColors.removeLast() 297 | // If we are belove 298 | } else if (finalColors.size < arcVertices.size) 299 | // Add the last color till it's the same 300 | while (finalColors.size != arcVertices.size) 301 | finalColors.add(color[color.size - 1]) 302 | 303 | // Return output 304 | return finalColors 305 | } 306 | 307 | /// Outline circle 308 | // Normal 309 | fun drawCircleOutline(center: Vec2f, radius: Float, segments: Int = 0, lineWidth: Float = 1f, color: ABColor, angleRange: Pair = Pair(0f, 360f), once: Boolean = false) { 310 | if (once) 311 | VertexUtil.prepareGl() 312 | drawArcOutline(center, radius, angleRange, segments, lineWidth, color) 313 | if (once) 314 | VertexUtil.releaseGL() 315 | } 316 | private fun drawArcOutline( center: Vec2f, radius: Float, angleRange: Pair, segments: Int = 0, lineWidth: Float = 1f, color: ABColor) { 317 | val arcVertices = getArcVertices(center, radius, angleRange, segments) 318 | drawLineStrip(arcVertices, lineWidth, color) 319 | } 320 | 321 | // Gradient 322 | fun drawCircleOutline(center: Vec2f, radius: Float, segments: Int = 0, lineWidth: Float = 1f, color: Array, angleRange: Pair = Pair(0f, 360f), once: Boolean = false) { 323 | // Prepare gl 324 | if (once) 325 | VertexUtil.prepareGl() 326 | 327 | // Main function drawing circle 328 | drawArcOutline(center, radius, angleRange, segments, lineWidth, color, once) 329 | // Release gl 330 | if (once) 331 | VertexUtil.releaseGL() 332 | } 333 | private fun drawArcOutline( center: Vec2f, radius: Float, angleRange: Pair, segments: Int = 0, lineWidth: Float = 1f, color: Array, once: Boolean = false) { 334 | // Get vertices 335 | val arcVertices = getArcVertices(center, radius, angleRange, segments) 336 | // Draw 337 | drawLineStrip(arcVertices, lineWidth, getGradientVertices(color, arcVertices), once) 338 | } 339 | 340 | 341 | /// Border circle 342 | // Normal 343 | fun drawCircleBorder(center: Vec2f, radius: Float, segments: Int = 0, lineWidth: Float = 1f, insideC: ABColor, outsideC: ABColor, angleRange: Pair = Pair(0f, 360f), once: Boolean = false) { 344 | // Prepare gl 345 | if (once) 346 | VertexUtil.prepareGl() 347 | 348 | // Draw inside 349 | drawCircleFilled(center, radius - lineWidth, segments, insideC, angleRange, false) 350 | // Draw outside 351 | drawCircleOutline(center, radius, segments, lineWidth + 2, outsideC, angleRange, false) 352 | 353 | // Release 354 | if (once) 355 | VertexUtil.releaseGL() 356 | } 357 | // Gradient 358 | fun drawCircleBorder(center: Vec2f, radius: Float, segments: Int = 0, lineWidth: Float = 1f, insideC: Array, outsideC: Array, angleRange: Pair = Pair(0f, 360f), once: Boolean = false) { 359 | // Prepare gl 360 | if (once) 361 | VertexUtil.prepareGl() 362 | 363 | // Inside 364 | drawCircleFilled(center, radius - lineWidth, segments, insideC, angleRange, false) 365 | // Outside 366 | drawCircleOutline(center, radius - lineWidth/2 - .5f, segments, lineWidth + 2, outsideC, angleRange, false) 367 | 368 | // Relase gl 369 | if (once) 370 | VertexUtil.releaseGL() 371 | } 372 | 373 | //endregion 374 | 375 | //region Rounded Rect 376 | 377 | /// Fill 378 | // Normal 379 | fun drawRoundedRect(Start: Vec2f, width: Float, height: Float, radius: Float, c: ABColor, once: Boolean = false) { 380 | if (once) 381 | VertexUtil.prepareGl() 382 | 383 | /// Rectangles 384 | // Draw body 385 | drawRect(Start.add(radius, 0f), width - radius * 2, height, c) 386 | // Draw left 387 | drawRect(Start.add(0f, radius), radius, height - radius * 2, c) 388 | // Draw Right 389 | drawRect(Start.add(width, radius), -radius, height - radius * 2, c) 390 | /// Circles 391 | // Top right 392 | drawCircleFilled(Start.add(width - radius, radius), radius, 90, c, Pair(0f, 90f), false) 393 | // Top left 394 | drawCircleFilled(Start.add(radius, radius), radius, 90, c, Pair(270f, 360f), false) 395 | // Bottom left 396 | drawCircleFilled(Start.add(radius, height - radius), radius, 90, c, Pair(180f, 270f), false) 397 | // Bottom right 398 | drawCircleFilled(Start.add(width - radius, height - radius), radius, 90, c, Pair(90f, 180f), false) 399 | 400 | if (once) 401 | VertexUtil.releaseGL() 402 | } 403 | // Gradient 404 | fun drawRoundedRect(Start: Vec2f, width: Float, height: Float, radius: Float, colors: Array, once: Boolean = false, topBottom: Boolean = false) { 405 | 406 | when(colors.size) { 407 | 0 -> return 408 | 1 -> drawRoundedRect(Start, width, height, radius, colors[0], once) 409 | else -> { 410 | // Prepare gl 411 | if (once) 412 | VertexUtil.prepareGl() 413 | 414 | val arr = when (colors.size) { 415 | 2, 3 -> if (topBottom) arrayOf(colors[0], colors[1], colors[1], colors[0]) 416 | else arrayOf(colors[0], colors[0], colors[1], colors[1]) 417 | else -> Array(4) {colors[it]} 418 | } 419 | 420 | /// Border 421 | /// Gradient 422 | // Top 423 | drawRect(Start.add(radius, 0f), width - radius*2, radius, false, arrayOf(arr[0], arr[1]), topBottom = false) 424 | // Right 425 | drawRect(Start.add(width, radius), -radius, height - radius*2, false, arrayOf(arr[1], arr[2]), topBottom = true) 426 | // Bottom 427 | drawRect(Start.add(radius, height), width - radius*2, -radius, false, arrayOf(arr[3], arr[2]), topBottom = false) 428 | // Left 429 | drawRect(Start.add(0f, radius), radius, height - radius*2, false, arrayOf(arr[0], arr[3]), topBottom = true) 430 | // Body 431 | drawRect(Start.add(radius, radius), width - radius * 2, height - radius*2, false, arrayOf(arr[0], arr[3], arr[2], arr[1])) 432 | /// Circles 433 | // Top right 434 | drawCircleFilled(Start.add(width - radius, radius), radius, 90, arr[1], Pair(0f, 90f), false) 435 | // Top left 436 | drawCircleFilled(Start.add(radius, radius), radius, 90, arr[0], Pair(270f, 360f), false) 437 | // Bottom left 438 | drawCircleFilled(Start.add(radius, height - radius), radius, 90, arr[3], Pair(180f, 270f), false) 439 | // Bottom right 440 | drawCircleFilled(Start.add(width - radius, height - radius), radius, 90, arr[2], Pair(90f, 180f), false) 441 | 442 | /* 443 | Old rounded rect. This doesnt really work, it create some shits render bugs 444 | /// Body 445 | glBegin(GL_POLYGON) 446 | /// Circles 447 | // Top left 448 | drawCircleFilled(Start.add(radius, radius), radius, 90, arr[0], Pair(270f, 360f), false, true) 449 | // Top right 450 | drawCircleFilled(Start.add(width - radius, radius), radius, 90, arr[1], Pair(0f, 90f), false, true) 451 | // Bottom right 452 | drawCircleFilled(Start.add(width - radius, height - radius), radius, 90, arr[2], Pair(90f, 180f), false, true) 453 | // Bottom left 454 | drawCircleFilled(Start.add(radius, height - radius), radius, 90, arr[3], Pair(180f, 270f), false, true) 455 | glEnd()*/ 456 | // Relase gl 457 | if (once) 458 | VertexUtil.releaseGL() 459 | } 460 | } 461 | } 462 | 463 | /// Outline 464 | // Normal 465 | fun drawRoundedRectOutline(Start: Vec2f, width: Float, height: Float, radius: Float, widthBorder: Float, c: ABColor, once: Boolean = false) { 466 | if (once) 467 | VertexUtil.prepareGl() 468 | 469 | /// Rectangle 470 | // Top 471 | drawLine(Start.add(radius, 0f), Start.add(width - radius , 0f), widthBorder, c) 472 | // Bottom 473 | drawLine(Start.add(radius, height), Start.add(width - radius, height), widthBorder, c) 474 | // Left 475 | drawLine(Start.add(0f, radius), Start.add(0f, height - radius ), widthBorder, c) 476 | // Right 477 | drawLine(Start.add(width, radius), Start.add(width, height - radius ), widthBorder, c) 478 | /// Circles 479 | // Top right 480 | drawCircleOutline(Start.add(width - radius, radius), radius, 0, widthBorder, c, Pair(0f, 90f)) 481 | // Top left 482 | drawCircleOutline(Start.add(radius, radius), radius, 0, widthBorder, c, Pair(270f, 360f)) 483 | // Bottom left 484 | drawCircleOutline(Start.add(radius, height - radius), radius, 0, widthBorder, c, Pair(180f, 270f)) 485 | // Bottom right 486 | drawCircleOutline(Start.add(width - radius, height - radius), radius, 0, widthBorder, c, Pair(90f, 180f)) 487 | 488 | if (once) 489 | VertexUtil.releaseGL() 490 | } 491 | // Gradient 492 | fun drawRoundedRectOutline(Start: Vec2f, width: Float, height: Float, radius: Float, widthBorder: Float, colors: Array, once: Boolean = false, topBottom: Boolean = false) { 493 | 494 | when(colors.size) { 495 | 0 -> return 496 | 1 -> drawRoundedRectOutline(Start, width, height, radius, widthBorder, colors[0]) 497 | else -> { 498 | 499 | if (once) 500 | VertexUtil.prepareGl() 501 | 502 | val arr = when (colors.size) { 503 | 2, 3 -> {if (topBottom) arrayOf(colors[0], colors[1], colors[1], colors[0]) 504 | else arrayOf(colors[0], colors[0], colors[1], colors[1])} 505 | else -> Array(4) {colors[it]} 506 | } 507 | 508 | /// Rectangle 509 | // Top 510 | 511 | drawLine(Start.add(radius, 0f), Start.add(width - radius , 0f), widthBorder, arr[0], arr[1]) 512 | // Bottom 513 | drawLine(Start.add(radius, height), Start.add(width - radius, height), widthBorder, arr[3], arr[2]) 514 | // Left 515 | drawLine(Start.add(0f, radius), Start.add(0f, height - radius ), widthBorder, arr[0], arr[3]) 516 | // Right 517 | drawLine(Start.add(width, radius), Start.add(width, height - radius ), widthBorder, arr[1], arr[2]) 518 | /// Circles 519 | // Top right 520 | drawCircleOutline(Start.add(width - radius, radius), radius, 0, widthBorder, arr[1], Pair(0f, 90f)) 521 | // Top left 522 | drawCircleOutline(Start.add(radius, radius), radius, 0, widthBorder, arr[0], Pair(270f, 360f)) 523 | // Bottom left 524 | drawCircleOutline(Start.add(radius, height - radius), radius, 0, widthBorder, arr[3], Pair(180f, 270f)) 525 | // Bottom right 526 | drawCircleOutline(Start.add(width - radius, height - radius), radius, 0, widthBorder, arr[2], Pair(90f, 180f)) 527 | 528 | 529 | 530 | if (once) 531 | VertexUtil.releaseGL() 532 | 533 | } 534 | } 535 | 536 | } 537 | 538 | /// Border 539 | // Normal 540 | fun drawRoundedRectBorder(Start: Vec2f, width: Float, height: Float, radius: Float, widthBorder: Float, cInside: ABColor, cOutside: ABColor, once: Boolean = false) { 541 | if (once) 542 | VertexUtil.prepareGl() 543 | // Inside 544 | drawRoundedRect(Start, width, height, radius, cInside) 545 | // Outside 546 | drawRoundedRectOutline(Start, width, height, radius, widthBorder, cOutside) 547 | if (once) 548 | VertexUtil.releaseGL() 549 | } 550 | // Gradient 551 | fun drawRoundedRectBorder(Start: Vec2f, width: Float, height: Float, radius: Float, widthBorder: Float, cInside: Array, insideTopBottom: Boolean = false, cOutside: Array, outsideTopBottom: Boolean = false, once: Boolean = false) { 552 | if (once) 553 | VertexUtil.prepareGl() 554 | // Inside 555 | drawRoundedRect(Start.add(widthBorder/2 - .8f, widthBorder/2 - .8f), width - widthBorder + 1.2f, height - widthBorder + 1.2f, radius, cInside, once, insideTopBottom) 556 | // Outside 557 | drawRoundedRectOutline(Start, width, height, radius, widthBorder, cOutside, outsideTopBottom, once) 558 | if (once) 559 | VertexUtil.releaseGL() 560 | } 561 | 562 | 563 | //endregion 564 | 565 | //region line 566 | 567 | fun drawLineStrip(vertices: Array, lineWidth: Float = 1f, c: ABColor, once: Boolean = false) { 568 | // Prepare gl 569 | if (once) 570 | VertexUtil.prepareGl() 571 | 572 | // Set width 573 | glLineWidth(lineWidth) 574 | 575 | // Set color and add vertices 576 | glBegin(GL_LINE_STRIP) 577 | c.glColor() 578 | for (vertex in vertices) { 579 | VertexUtil.add(vertex) 580 | } 581 | glEnd() 582 | 583 | // Relase gl 584 | if (once) 585 | VertexUtil.releaseGL() 586 | else 587 | // Well, we still have to reset lineWidth lol 588 | glLineWidth(1f) 589 | } 590 | 591 | fun drawLineStrip(vertices: Array, lineWidth: Float = 1f, c: ArrayList, once: Boolean = false) { 592 | // PrepareGl 593 | if (once) 594 | VertexUtil.prepareGl() 595 | // Set lineWidth 596 | glLineWidth(lineWidth) 597 | 598 | // Add every vertices with color 599 | glBegin(GL_LINE_STRIP) 600 | for ((idx, value) in vertices.withIndex()) { 601 | VertexUtil.add(value, c[idx]) 602 | } 603 | glEnd() 604 | 605 | // Relase 606 | if (once) 607 | VertexUtil.releaseGL() 608 | else 609 | // Reset 610 | glLineWidth(1f) 611 | } 612 | 613 | fun drawLine(start: Vec2f, end: Vec2f, lineWidth: Float = 1f, c: ABColor, once: Boolean = false) { 614 | // Preare gl 615 | if (once) { 616 | VertexUtil.prepareGl() 617 | } 618 | 619 | // Set width 620 | glLineWidth(lineWidth) 621 | // Set color and start+end 622 | glBegin(GL_LINES) 623 | c.glColor() 624 | glVertex2f(start.x, start.y) 625 | glVertex2f(end.x, end.y) 626 | glEnd() 627 | 628 | // End + reset 629 | if (once) { 630 | VertexUtil.releaseGL() 631 | } else glLineWidth(1f) 632 | } 633 | 634 | fun drawLine(start: Vec2f, end: Vec2f, lineWidth: Float = 1f, first: ABColor, second: ABColor, once: Boolean = false) { 635 | // Prepare 636 | if (once) { 637 | VertexUtil.prepareGl() 638 | } 639 | 640 | // Draw a line with 2 differents color 641 | glLineWidth(lineWidth) 642 | glBegin(GL_LINES) 643 | VertexUtil.add(start, first) 644 | VertexUtil.add(end, second) 645 | glEnd() 646 | 647 | // Release + reset 648 | if (once) { 649 | VertexUtil.releaseGL() 650 | } else glLineWidth(1f) 651 | } 652 | 653 | fun drawLine(start: Vec2f, end: Vec2f, lineWidth: Float = 1f, c: Array, once: Boolean = false) { 654 | 655 | when(c.size) { 656 | // NO colors lol 657 | 0 -> return 658 | // 1 color, simple lol 659 | 1 -> drawLine(start, end, lineWidth, c[0], once) 660 | // 2 colors, simple lo 661 | 2 -> drawLine(start, end, lineWidth, c[0], c[1], once) 662 | else -> { 663 | // Prepare 664 | if (once) { 665 | VertexUtil.prepareGl() 666 | } 667 | 668 | // Get the differences of every lines 669 | val size = c.size - 1 670 | val lines = ArrayList() 671 | val xDiff = (end.x - start.x)/size 672 | val yDiff = (end.y - start.y)/size 673 | 674 | // Add with percent 675 | for(i in 0..size) { 676 | lines.add(start.add(xDiff*i, yDiff*i)) 677 | } 678 | 679 | // Simple line draw 680 | glLineWidth(lineWidth) 681 | glBegin(GL_LINE_STRIP) 682 | 683 | for((idx, value) in lines.withIndex()) { 684 | VertexUtil.add(value, c[idx]) 685 | } 686 | 687 | glEnd() 688 | 689 | // Release 690 | if (once) { 691 | VertexUtil.releaseGL() 692 | } else glLineWidth(1f) 693 | } 694 | } 695 | 696 | } 697 | 698 | //endregion 699 | 700 | //region Triangle 701 | 702 | /* 703 | Is this ever going to be used? 704 | */ 705 | 706 | private fun drawTriangleFan(center: Vec2f, vertices: Array, c: ABColor, once: Boolean = false, onlyVertex: Boolean = false) { 707 | if (once) 708 | VertexUtil.prepareGl() 709 | if (!onlyVertex) 710 | glBegin(GL_TRIANGLE_FAN) 711 | c.glColor() 712 | if (!onlyVertex) 713 | glVertex2f(center.x, center.y) 714 | for (vertex in vertices) { 715 | glVertex2f(vertex.x, vertex.y) 716 | } 717 | if (!onlyVertex) 718 | glEnd() 719 | if (once) 720 | VertexUtil.releaseGL() 721 | } 722 | 723 | private fun drawTriangleFan(center: Vec2f, vertices: Array, c: ArrayList, once: Boolean = false) { 724 | if (once) 725 | VertexUtil.prepareGl() 726 | glBegin(GL_TRIANGLE_FAN) 727 | glVertex2f(center.x, center.y) 728 | for((index, value) in vertices.withIndex()) { 729 | VertexUtil.add(value, c[index]) 730 | } 731 | glEnd() 732 | if (once) 733 | VertexUtil.releaseGL() 734 | } 735 | 736 | public fun drawTriangle(pos1: Vec2f, pos2: Vec2f, pos3: Vec2f, c: ABColor, once: Boolean = false) { 737 | if (once) 738 | VertexUtil.prepareGl() 739 | 740 | glBegin(GL_TRIANGLES) 741 | c.glColor() 742 | VertexUtil.add(pos1) 743 | VertexUtil.add(pos2) 744 | VertexUtil.add(pos3) 745 | glEnd() 746 | 747 | if (once) 748 | VertexUtil.prepareGl() 749 | } 750 | 751 | public fun drawTriangle(pos1: Vec2f, pos2: Vec2f, pos3: Vec2f, c: Array, once: Boolean = false) { 752 | if (c.size != 3) 753 | return 754 | 755 | if (once) 756 | VertexUtil.prepareGl() 757 | 758 | glBegin(GL_TRIANGLES) 759 | VertexUtil.add(pos1, c[0]) 760 | VertexUtil.add(pos2, c[1]) 761 | VertexUtil.add(pos3, c[2]) 762 | glEnd() 763 | 764 | if (once) 765 | VertexUtil.prepareGl() 766 | 767 | } 768 | 769 | //endregion 770 | 771 | //region Text 772 | /* 773 | Justify values: 774 | 0 -> Left 775 | 1 -> Center 776 | 2 -> Right 777 | */ 778 | fun drawText(text: String, x: Float, y: Float, color: ABColor, justify: Int = 0, fontSize : Float = 1f) { 779 | 780 | // We are not going to waste resources for no lenght ofc 781 | if (text.length == 0) 782 | return 783 | 784 | // Get justify 785 | var xVal = when(justify) { 786 | 1 -> x - mc.fontRenderer.getStringWidth(text) / 2 787 | 2 -> x - mc.fontRenderer.getStringWidth(text) 788 | else -> x 789 | }; 790 | 791 | // Temp variable for size 792 | var sizeNow = false 793 | 794 | // Size 795 | if (fontSize != 1f) { 796 | GlStateManager.pushMatrix() 797 | GlStateManager.scale(fontSize, fontSize, fontSize) 798 | sizeNow = true 799 | } 800 | 801 | // Draw simple 802 | mc.fontRenderer.drawString( text, (xVal/fontSize).toInt(), (y/fontSize).toInt(), color.rgb); 803 | 804 | // Reset 805 | if (sizeNow) 806 | GlStateManager.popMatrix() 807 | } 808 | 809 | // Our custom gradient 810 | val renderString = GradientFontRenderer(mc.gameSettings, ResourceLocation("minecraft", "textures/font/ascii.png"), mc.renderEngine, false) 811 | 812 | // Draw with N colors 813 | fun drawText(text: String, x:Float, y:Float, c: Array, justify: Int = 0, fontSize: Float = -1f, horizontal: Boolean = true, dropShadow: Boolean = false) { 814 | when(c.size) { 815 | // As usual 816 | 0 -> return 817 | 1 -> drawText(text, x, y, c[0], justify, fontSize) 818 | // 2 colors 819 | 2 -> { 820 | // Not going to waste 821 | if (text.length == 0) 822 | return 823 | 824 | var xVal = when(justify) { 825 | 1 -> x - mc.fontRenderer.getStringWidth(text) / 2 826 | 2 -> x - mc.fontRenderer.getStringWidth(text) 827 | else -> x 828 | }; 829 | 830 | var sizeNow = false 831 | 832 | if (sizeNow) { 833 | GlStateManager.pushMatrix() 834 | GlStateManager.scale(fontSize, fontSize, fontSize) 835 | sizeNow = true 836 | } 837 | 838 | // Draw string with 2 colors 839 | renderString.drawString( text, xVal, y, c[0].rgb, c[1].rgb, dropShadow, horizontal); 840 | 841 | if (sizeNow) 842 | GlStateManager.popMatrix() 843 | 844 | 845 | } 846 | else -> { 847 | 848 | var start = text.length 849 | if (start == 0) 850 | return 851 | 852 | // Drop in case colors are more then letters (I'm not going to overcomplicate this shit and making pixel things) 853 | c.dropLastWhile { 854 | c.size > start 855 | } 856 | 857 | // We have to get every string with start end colors 858 | val stringSplitted = ArrayList() 859 | // We remove 1 because the first color is at beginning 860 | var nColors = c.size.toFloat() - 1 861 | 862 | // Temp variable 863 | var textMod = text 864 | 865 | // While we have lenght 866 | while (start > 0) { 867 | // Get nWords we are going to color 868 | var nWords : Float = start / nColors 869 | // If there is decimal, add 1 870 | if (!nWords.rem(1).equals(0f)) 871 | nWords++ 872 | 873 | // Add substring 874 | stringSplitted.add(textMod.substring(0..nWords.toInt() - 1)) 875 | 876 | // Remove what we added 877 | textMod = textMod.substring(nWords.toInt()) 878 | 879 | // Decrease start by the number of words and nColors 880 | start -= nWords.toInt() 881 | nColors-- 882 | 883 | } 884 | 885 | // Justify 886 | var xVal = when(justify) { 887 | 1 -> x - mc.fontRenderer.getStringWidth(text) / 2 888 | 2 -> x - mc.fontRenderer.getStringWidth(text) 889 | else -> x 890 | }; 891 | // We have to remember the width of every string 892 | var addX = 0f 893 | 894 | var sizeNow = false 895 | 896 | // Scale 897 | if (sizeNow) { 898 | GlStateManager.pushMatrix() 899 | GlStateManager.scale(fontSize, fontSize, fontSize) 900 | sizeNow = true 901 | } 902 | 903 | // For every string 904 | for((idx, value) in stringSplitted.withIndex()) { 905 | 906 | // Draw it form start to finish 907 | renderString.drawString( value, xVal + addX, y, c[idx].rgb, c[idx + 1].rgb, dropShadow, horizontal); 908 | 909 | // Add width 910 | addX += renderString.getStringWidth(value) 911 | 912 | } 913 | 914 | // Reset 915 | if (sizeNow) 916 | GlStateManager.popMatrix() 917 | } 918 | } 919 | } 920 | 921 | //endregion 922 | 923 | //region pictures 924 | 925 | // ImageIO.read(javaClass.classLoader.getResource("assets/minecraft/amber/img/testresources.png")) 926 | // mc.textureManager.getTexture(resourceLocation) 927 | // ImageIO.read(mc.resourceManager.getResource(resourceLocation).inputStream) 928 | //mc.ingameGUI.drawTexturedModalRect(x, y, 0, 0, br.width, br.height) 929 | 930 | fun showPicture(x: Int, y: Int, resourceLocation: ResourceLocation, width: Int = -1, height: Int = -1) { 931 | mc.textureManager.bindTexture(resourceLocation) 932 | // Get final width 933 | var widthFinal = width 934 | var heightFinal = height 935 | // If we have to get the width of something 936 | if (width == -1 || height == -1) { 937 | // Read the resource 938 | val br = ImageIO.read(mc.resourceManager.getResource(resourceLocation).inputStream) 939 | // And them get width / height in case is not default 940 | if (width == -1) 941 | widthFinal = br.width 942 | if (height == -1) 943 | heightFinal = br.height 944 | } 945 | 946 | GL11.glPushMatrix() 947 | // Reset color 948 | GL11.glColor4f(1f, 1f, 1f, 1f) 949 | // Draw it 950 | blit(x, y, 0f, 0f, widthFinal, heightFinal, widthFinal.toFloat(), heightFinal.toFloat()) 951 | GL11.glPopMatrix() 952 | } 953 | 954 | fun showPicture(x: Int, y: Int, resourceLocation: ResourceLocation, width: Int = -1, height: Int = -1, color: ABColor) { 955 | // Like before 956 | mc.textureManager.bindTexture(resourceLocation) 957 | var widthFinal = width 958 | var heightFinal = height 959 | if (width == -1 || height == -1) { 960 | val br = ImageIO.read(mc.resourceManager.getResource(resourceLocation).inputStream) 961 | if (width == -1) 962 | widthFinal = br.width 963 | if (height == -1) 964 | heightFinal = br.height 965 | } 966 | 967 | GL11.glPushMatrix(); 968 | // Custom color 969 | color.glColor() 970 | blit(x, y, 0f, 0f, widthFinal, heightFinal, widthFinal.toFloat(), heightFinal.toFloat()) 971 | GL11.glPopMatrix(); 972 | } 973 | 974 | 975 | //endregion 976 | 977 | //region extensions 978 | 979 | private fun Vec2f.add(center: Vec2f): Vec2f { 980 | return Vec2f(this.x + center.x, this.y + center.y) 981 | } 982 | 983 | private fun Vec2f.add(xVal: Float, yVal: Float): Vec2f { 984 | return Vec2f(this.x + xVal, this.y + yVal) 985 | } 986 | 987 | private fun Vec2f.times(radius: Float): Vec2f { 988 | return Vec2f(this.x * radius, this.y * radius) 989 | } 990 | 991 | //endregion 992 | 993 | 994 | } 995 | 996 | 997 | -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/render/VertexUtil.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render 2 | 3 | import dev.amber.api.variables.ABColor 4 | import net.minecraft.client.renderer.GlStateManager 5 | import net.minecraft.util.math.Vec2f 6 | import org.lwjgl.opengl.GL11 7 | import org.lwjgl.opengl.GL32 8 | 9 | object VertexUtil { 10 | 11 | fun prepareGl() { 12 | GlStateManager.pushMatrix() 13 | GL11.glLineWidth(1f) 14 | GL11.glEnable(GL11.GL_LINE_SMOOTH) 15 | GL11.glEnable(GL32.GL_DEPTH_CLAMP) 16 | GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST) 17 | GlStateManager.disableAlpha() 18 | GlStateManager.shadeModel(GL11.GL_SMOOTH) 19 | GlStateManager.disableCull() 20 | GlStateManager.enableBlend() 21 | GlStateManager.depthMask(false) 22 | GlStateManager.disableTexture2D() 23 | GlStateManager.disableLighting() 24 | } 25 | 26 | fun releaseGL() { 27 | GlStateManager.enableTexture2D() 28 | GlStateManager.enableDepth() 29 | GlStateManager.disableBlend() 30 | GlStateManager.enableCull() 31 | GlStateManager.shadeModel(GL11.GL_FLAT) 32 | GlStateManager.enableAlpha() 33 | GlStateManager.depthMask(true) 34 | GL11.glDisable(GL32.GL_DEPTH_CLAMP) 35 | GL11.glDisable(GL11.GL_LINE_SMOOTH) 36 | GlStateManager.color(1f, 1f, 1f) 37 | GL11.glLineWidth(1f) 38 | GlStateManager.popMatrix() 39 | } 40 | 41 | fun add(Coords: Vec2f) { 42 | GL11.glVertex2f(Coords.x, Coords.y) 43 | } 44 | 45 | fun add(Coords: Vec2f, color: ABColor) { 46 | color.glColor() 47 | GL11.glVertex2f(Coords.x, Coords.y) 48 | } 49 | 50 | 51 | 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/render/gui/Background.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render.gui 2 | 3 | import dev.amber.api.render.RenderUtil2d 4 | import dev.amber.api.render.VertexUtil 5 | import dev.amber.api.util.MathUtils 6 | import dev.amber.api.variables.ABColor 7 | import net.minecraft.util.ResourceLocation 8 | import net.minecraft.util.math.Vec2f 9 | import kotlin.math.sin 10 | import kotlin.random.Random 11 | 12 | object Background { 13 | 14 | /// Header 15 | // Logo 16 | fun drawLogo() { 17 | // Rect under the picture 18 | RenderUtil2d.drawRect( 19 | Start = Vec2f.ZERO, 20 | width = 154f, 21 | height = 60f, 22 | c = ABColor(0,0,0, 180) 23 | ) 24 | // Border rectangle 25 | RenderUtil2d.drawRect( 26 | Start = Vec2f(0f, 58f), 27 | width = 154f, 28 | height = 2f, 29 | c = ABColor(255, 0, 0) 30 | ) 31 | 32 | // Triangle 33 | RenderUtil2d.drawTriangle( 34 | pos1 = Vec2f(154f, 0f), 35 | pos2 = Vec2f(154f, 58f), 36 | pos3 = Vec2f(175f, 0f), 37 | ABColor(0, 0, 0, 180) 38 | ) 39 | 40 | // Above triangle 41 | RenderUtil2d.drawLine( 42 | start = Vec2f(154f, 59f), 43 | end = Vec2f(175f, 0f), 44 | c = ABColor(255, 0, 0), 45 | lineWidth = 3f 46 | ) 47 | 48 | // Release for showing the picture+text 49 | VertexUtil.releaseGL() 50 | // Amber picture 51 | RenderUtil2d.showPicture(x = 5, y = 5, 52 | resourceLocation = ResourceLocation("amber/img/logogradient.png"), 53 | width = 47, height = 45) 54 | 55 | // Tecture 56 | RenderUtil2d.drawText(text = "Amber", x = 60f, y= 16f, 57 | color = ABColor(255, 255, 255), 58 | fontSize = 3f) 59 | 60 | // Prepare gl again 61 | VertexUtil.prepareGl() 62 | } 63 | 64 | /// Bottom 65 | 66 | // Particles 67 | private val particles = arrayListOf() 68 | private const val spawnParticles = 5 69 | private const val waitSpawn = 1 70 | private const val life = 70 71 | private const val variationLife = 30 72 | private const val startX = 0 73 | private const val endX = 0 74 | private const val variationY = 5 75 | private const val speedY = 1f 76 | private const val variationSpeedY = 1f 77 | private var tick = 0 78 | private val typeParticle = particle.Type.SQUARE 79 | private const val height = 3f 80 | private const val width = 3f 81 | private val primaryColor = ABColor(255, 100, 0) 82 | private val startAlphaParticle : Int? = 255 83 | fun drawParticles(widthScreen: Float, heightScreen: Float) { 84 | 85 | particles.removeIf { e -> e.render() } 86 | 87 | if (tick++ > waitSpawn) { 88 | tick = 0 89 | 90 | for(i in 0..spawnParticles) 91 | particles.add(particle( 92 | Random.nextInt(startX, widthScreen.toInt() - endX).toFloat(), 93 | Random.nextInt(heightScreen.toInt(), heightScreen.toInt() + variationY).toFloat(), 94 | MathUtils.random(speedY, variationSpeedY), typeParticle, height, width, primaryColor, 95 | Random.nextInt(life, life + variationLife), startAlphaParticle)) 96 | } 97 | 98 | } 99 | 100 | // Header 101 | private const val number = 5 102 | private const val differenceSpeed = .3 103 | private var timer = 0.0 104 | private const val speed = .005 105 | private const val staticColorHeight = 10f 106 | private const val addHeight = 60f 107 | private const val varHeight = 20f 108 | private const val startAlpha = 255 109 | private const val finalAlpha = 0 110 | private const val finalAlphaAnimation = true 111 | fun drawDynamicBoxes(width: Float, height: Float) { 112 | // Get size of window 113 | when { 114 | number == 0 -> { 115 | return 116 | } 117 | number <= 2 -> drawDynamicBox(height, 0f, width, differenceSpeed) 118 | else -> { 119 | 120 | val space = width / number 121 | var x = 0f 122 | val middleBox: Boolean 123 | var numbers = number 124 | if (numbers % 2 == 1) { 125 | numbers -= 1 126 | middleBox = true 127 | } else middleBox = false 128 | 129 | for(i in 0..numbers/2) { 130 | drawDynamicBox(height, x, space, differenceSpeed * i) 131 | x += space 132 | } 133 | 134 | if (middleBox) { 135 | drawDynamicBox(height, x, space, differenceSpeed * numbers / 2 + differenceSpeed) 136 | x += space 137 | } 138 | 139 | for(i in numbers/2 downTo 0 step 1) { 140 | drawDynamicBox(height, x, space, differenceSpeed * i) 141 | x += space 142 | } 143 | 144 | } 145 | } 146 | } 147 | 148 | private fun drawDynamicBox(heightWindow: Float, x: Float, width: Float, differenceSpeed: Double) { 149 | 150 | val nowHeight = sin(timer + differenceSpeed) * varHeight 151 | 152 | val finalAlphaNow: Float 153 | val avgHeight = heightWindow - staticColorHeight 154 | finalAlphaNow = if (finalAlphaAnimation) { 155 | val startHeight = avgHeight - varHeight 156 | val endHeight = avgHeight + varHeight 157 | val rnHeight = avgHeight + nowHeight.toFloat() 158 | 159 | val percent = MathUtils.percentage(startHeight, endHeight, rnHeight) 160 | 161 | val alpha = (startAlpha - finalAlpha) * percent 162 | startAlpha - alpha 163 | } else finalAlpha.toFloat() 164 | 165 | val staticColor = ABColor(255, 50, 0, startAlpha) 166 | val startColor = ABColor(255, 50, 0, startAlpha) 167 | val endColor = ABColor(255, 50, 0, finalAlphaNow.toInt()) 168 | 169 | RenderUtil2d.drawRect(Vec2f(x, heightWindow), width, -staticColorHeight, staticColor) 170 | RenderUtil2d.drawRect(Vec2f(x, avgHeight), width, - addHeight - nowHeight.toFloat(), false, 171 | arrayOf(startColor, endColor), true) 172 | 173 | timer += speed 174 | } 175 | 176 | 177 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/render/gui/particle.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.render.gui 2 | 3 | import dev.amber.api.render.Element 4 | import dev.amber.api.render.RenderUtil2d 5 | import dev.amber.api.util.MathUtils 6 | import dev.amber.api.variables.ABColor 7 | import net.minecraft.util.math.Vec2f 8 | 9 | class particle(override var x: Float, override var y: Float, 10 | private val speedY: Float, 11 | private var typeParticle: Type, 12 | private val height: Float, 13 | private val width: Float = 1f, 14 | private val primaryColor: ABColor, 15 | private val endLife: Int = 100, 16 | private val startAlpha : Int? = null) 17 | : Element() { 18 | 19 | private var life = 0; 20 | override fun render() : Boolean { 21 | 22 | if (life++ >= endLife) 23 | return false 24 | 25 | val startColor: ABColor 26 | 27 | if (startAlpha == null) { 28 | startColor = primaryColor 29 | } else { 30 | val percentage = MathUtils.percentage(0, endLife, life) 31 | startColor = ABColor(primaryColor, (startAlpha - startAlpha * percentage).toInt()) 32 | } 33 | 34 | when(this.typeParticle) { 35 | Type.PENIS -> { 36 | RenderUtil2d.drawRect(Vec2f(x, y), width, height * 2 + width, startColor) 37 | RenderUtil2d.drawRect(Vec2f(x, y - height), -height, width, startColor) 38 | RenderUtil2d.drawRect(Vec2f(x + width, y - height), height, width, startColor) 39 | } 40 | 41 | Type.CROSS -> { 42 | RenderUtil2d.drawRect(Vec2f(x, y), width, height * 2 + width, startColor) 43 | RenderUtil2d.drawRect(Vec2f(x, y + height), -height, width, startColor) 44 | RenderUtil2d.drawRect(Vec2f(x + width, y + height), height, width, startColor) 45 | } 46 | 47 | Type.CIRCLE -> { 48 | RenderUtil2d.drawCircleFilled(Vec2f(x, y), height, 15, startColor) 49 | } 50 | 51 | Type.SQUARE -> { 52 | RenderUtil2d.drawRect(Vec2f(x, y), height, width, startColor) 53 | } 54 | 55 | } 56 | this.y -= speedY 57 | 58 | return false 59 | } 60 | 61 | enum class Type { 62 | PENIS, CIRCLE, SQUARE, CROSS 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/Setting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting 2 | 3 | /** 4 | * @author lukflug 5 | */ 6 | abstract class Setting( 7 | val displayName: String, 8 | private var value: T, 9 | val configName: String = displayName.replace(" ",""), 10 | val description: String = "", 11 | val visible: ()-> Boolean = {true} 12 | ) { 13 | open fun getState(): T = value 14 | open fun setState(value: T) {this.value = value} 15 | open fun getString(): String = value.toString() 16 | abstract fun fromString (input: String) 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/SettingManager.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting 2 | 3 | import dev.amber.frontend.module.Module 4 | import java.util.stream.Stream 5 | 6 | /** 7 | * @author lukflug 8 | */ 9 | object SettingManager { 10 | private val settings: MutableList>> = ArrayList() 11 | 12 | fun registerSetting(setting: Setting<*>, mod: Module): Setting<*> { 13 | settings.add(Pair(mod,setting)) 14 | return setting 15 | } 16 | 17 | fun getSettings(): Stream> = 18 | settings.stream().map{s -> s.second} 19 | 20 | fun getSettingByNameAndMod(name: String, mod: Module): Setting<*> = 21 | settings.stream().filter{s -> s.first == mod && s.second.displayName == name}.map{s -> s.second}.findFirst().orElse(null) 22 | 23 | fun getSettingsByModule(mod: Module): Stream> = 24 | settings.stream().filter{s -> s.first == mod}.map{s -> s.second} 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/values/BooleanSetting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting.values 2 | 3 | import dev.amber.api.setting.Setting 4 | 5 | /** 6 | * @author lukflug 7 | */ 8 | class BooleanSetting( 9 | displayName: String, 10 | value: Boolean, 11 | configName: String = displayName.replace(" ",""), 12 | description: String = "", 13 | visible: ()-> Boolean = {true} 14 | ): Setting(displayName,value,configName,description,visible) { 15 | 16 | fun invert() { 17 | setState(!getState()) 18 | } 19 | 20 | override fun fromString(input: String) { 21 | setState(input.toBoolean()) 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/values/DoubleSetting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting.values 2 | 3 | import dev.amber.api.setting.Setting 4 | import java.lang.Double.max 5 | import java.lang.Double.min 6 | 7 | /** 8 | * @author lukflug 9 | */ 10 | class DoubleSetting( 11 | displayName: String, 12 | value: Double, 13 | val min: Double, 14 | val max: Double, 15 | configName: String = displayName.replace(" ",""), 16 | description: String = "", 17 | visible: ()-> Boolean = {true} 18 | ): Setting(displayName, value, configName, description,visible) { 19 | 20 | override fun setState(value: Double) { 21 | super.setState(max(min(value, max(min, max)), min(min, max))) 22 | } 23 | 24 | override fun fromString(input: String) { 25 | setState(input.toDouble()) 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/values/IntegerSetting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting.values 2 | 3 | import dev.amber.api.setting.Setting 4 | import java.lang.Integer.max 5 | import java.lang.Integer.min 6 | 7 | /** 8 | * @author lukflug 9 | */ 10 | class IntegerSetting( 11 | displayName: String, 12 | value: Int, 13 | val min: Int, 14 | val max: Int, 15 | configName: String = displayName.replace(" ",""), 16 | description: String = "", 17 | visible: ()-> Boolean = {true} 18 | ): Setting(displayName, value, configName, description, visible) { 19 | 20 | override fun setState(value: Int) { 21 | super.setState(max(min(value, max(min,max)), min(min,max))) 22 | } 23 | 24 | override fun fromString(input: String) { 25 | setState(input.toInt()) 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/values/ModeSetting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting.values 2 | 3 | import dev.amber.api.setting.Setting 4 | 5 | /** 6 | * @author lukflug 7 | */ 8 | class ModeSetting>( 9 | displayName: String, 10 | value: E, 11 | configName: String = displayName.replace(" ",""), 12 | description: String = "", 13 | visible: ()-> Boolean = {true} 14 | ): Setting(displayName, value, configName, description, visible) { 15 | 16 | fun increment() { 17 | val values: Array = getState().declaringClass.enumConstants 18 | var index: Int = getState().ordinal+1 19 | if (index>values.size) index=0 20 | setState(values[index]) 21 | } 22 | 23 | fun decrement() { 24 | val values: Array = getState().declaringClass.enumConstants 25 | var index: Int = getState().ordinal-1 26 | if (index<0) index = values.size-1 27 | setState(values[index]) 28 | } 29 | 30 | override fun fromString(input: String) { 31 | for (candidate in getState().declaringClass.enumConstants) { 32 | if (candidate.toString().equals(input, true)) { 33 | setState(candidate) 34 | return 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/setting/values/StringSetting.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.setting.values 2 | 3 | import dev.amber.api.setting.Setting 4 | 5 | /** 6 | * @author lukflug 7 | */ 8 | class StringSetting( 9 | displayName: String, 10 | value: String, 11 | configName: String = displayName.replace(" ",""), 12 | description: String = "", 13 | visible: ()-> Boolean = {true} 14 | ): Setting(displayName, value, configName, description, visible) { 15 | 16 | override fun setState(value: String) { 17 | super.setState(value) 18 | } 19 | 20 | override fun fromString(input: String) { 21 | setState(input) 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/util/ColorUtils.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.util 2 | 3 | import dev.amber.api.variables.ABColor 4 | 5 | object ColorUtils { 6 | 7 | fun average(start: ABColor, end: ABColor) : ABColor { 8 | return ABColor(start.red - (start.red - end.red) / 2, 9 | start.green - (start.green - end.green) / 2, 10 | start.blue - (start.blue - end.blue) / 2, 11 | start.alpha - (start.alpha - end.alpha) / 2) 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/util/Globals.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.util 2 | 3 | import net.minecraft.client.Minecraft 4 | 5 | /** 6 | * @author A2H 7 | * @author Hoosiers 8 | */ 9 | object Globals { 10 | val mc: Minecraft = Minecraft.getMinecraft() 11 | 12 | fun nullCheck() { 13 | if (mc.player == null || mc.world == null) return 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/util/LOGGER.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.util 2 | 3 | import java.text.DateFormat 4 | import java.text.SimpleDateFormat 5 | import java.util.* 6 | import java.util.logging.* 7 | import java.util.logging.Formatter 8 | 9 | 10 | object LOGGER { 11 | 12 | private val log = Logger.getLogger("Amber") 13 | private var time = hashMapOf() 14 | 15 | fun startTimer(name: String) { 16 | time[name] = System.currentTimeMillis() 17 | info("Started timing process $name") 18 | } 19 | 20 | fun endTimer(name: String) { 21 | info("Ended timing process " + name + " with " + ( System.currentTimeMillis() - time.remove(name)!!) + "ms") 22 | } 23 | 24 | fun info(message: String) { 25 | log.info(message) 26 | } 27 | 28 | fun warning(message: String) { 29 | log.warning(message) 30 | } 31 | 32 | fun severe(message: String) { 33 | log.severe(message) 34 | } 35 | 36 | init { 37 | log.useParentHandlers = false 38 | val formatter = MyFormatter() 39 | val handler = ConsoleHandler() 40 | handler.formatter = formatter 41 | 42 | log.addHandler(handler) 43 | } 44 | 45 | // https://kodejava.org/how-do-i-create-a-custom-logger-formatter/ 46 | private class MyFormatter : Formatter() { 47 | override fun format(record: LogRecord): String { 48 | val builder = StringBuilder(1000) 49 | builder.append("[").append(df.format(Date(record.millis))).append("] ") 50 | builder.append("[Amber] ") 51 | builder.append("[").append(record.level).append("] ") 52 | builder.append(formatMessage(record)) 53 | builder.append("\n") 54 | return builder.toString() 55 | } 56 | 57 | override fun getHead(h: Handler): String { 58 | return super.getHead(h) 59 | } 60 | 61 | override fun getTail(h: Handler): String { 62 | return super.getTail(h) 63 | } 64 | 65 | companion object { 66 | // Create a DateFormat to format the logger timestamp. 67 | private val df: DateFormat = SimpleDateFormat("HH:mm:ss") 68 | } 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/util/MathUtils.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.util 2 | 3 | import kotlin.math.pow 4 | import kotlin.math.round 5 | 6 | object MathUtils { 7 | 8 | fun round(value: Float, places: Int): Double { 9 | val scale = 10.0.pow(places.toDouble()) 10 | return round(value * scale) / scale 11 | } 12 | 13 | fun round(value: Double, places: Int): Double { 14 | val scale = 10.0.pow(places.toDouble()) 15 | return round(value * scale) / scale 16 | } 17 | 18 | fun percentage(start: Int, end: Int, now: Int) : Float { 19 | return (now - start) / (end - start).toFloat() 20 | } 21 | 22 | fun percentage(start: Float, end: Float, now: Float) : Float { 23 | return (now - start) / (end - start) 24 | } 25 | 26 | fun random(start: Float, end: Float) : Float { 27 | return start + end * Math.random().toFloat() 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/util/MessageUtil.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.util 2 | 3 | import com.mojang.realmsclient.gui.ChatFormatting 4 | import dev.amber.api.util.Globals.mc 5 | import net.minecraft.util.text.TextComponentString 6 | 7 | /** 8 | * @author A2H 9 | * @author Hoosiers 10 | */ 11 | object MessageUtil { 12 | 13 | private var watermark = "${ChatFormatting.GRAY}[${ChatFormatting.LIGHT_PURPLE}Amber${ChatFormatting.GRAY}]${ChatFormatting.RESET}" 14 | 15 | fun sendClientMessage(message: String) { 16 | mc.player.sendMessage(TextComponentString("$watermark $message")) 17 | } 18 | 19 | fun sendServerMessage(message: String) { 20 | mc.player.sendChatMessage(message) 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/api/variables/ABColor.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.api.variables 2 | 3 | /* 4 | @author: TechALe 5 | @since: 08/09/21 6 | Took inspiration from gs 7 | */ 8 | import net.minecraft.client.renderer.GlStateManager 9 | import java.awt.Color 10 | 11 | 12 | class ABColor : Color { 13 | 14 | var rainbow: Boolean = false 15 | var desyncRainbow: Int = 0 16 | var rainbowSpeed: Float = 1f 17 | /* 18 | We have a lot of types of constructors lol 19 | */ 20 | // just rgb 21 | constructor(rgb: Int) : super(rgb) 22 | // rgb with alpha 23 | constructor(rgba: Int, hasalpha: Boolean) : super(rgba, hasalpha) 24 | // rbg separated 25 | constructor(r: Int, g: Int, b: Int) : super(r, g, b) 26 | // rgba separated 27 | constructor(r: Int, g: Int, b: Int, a: Int) : super(r, g, b, a) 28 | // From another color 29 | constructor(color: Color) : super(color.red, color.green, color.blue, color.alpha) 30 | // From ABColor 31 | constructor(color: ABColor, a : Int) : super(color.red, color.green, color.blue, a) 32 | // Rainbow 33 | constructor(rainbow: Boolean, desyncRainbow: Int = 0, rainbowSpeed: Float = 1f, alpha: Int = 255) : super(0, 0, 0, alpha) { 34 | this.rainbow = true 35 | this.desyncRainbow = desyncRainbow 36 | this.rainbowSpeed = rainbowSpeed 37 | } 38 | 39 | // Utilities 40 | fun fromHSB(hue: Float, saturation: Float, brightness: Float): ABColor { 41 | return ABColor(getHSBColor(hue, saturation, brightness)) 42 | } 43 | 44 | fun getHue(): Float { 45 | return RGBtoHSB(red, green, blue, null)[0] 46 | } 47 | 48 | fun getSaturation(): Float { 49 | return RGBtoHSB(red, green, blue, null)[1] 50 | } 51 | 52 | fun getBrightness(): Float { 53 | return RGBtoHSB(red, green, blue, null)[2] 54 | } 55 | 56 | fun getRainbow(): ABColor { 57 | return this.fromHSB(((System.currentTimeMillis() * rainbowSpeed + this.desyncRainbow * 100) % (360 * 32)) / (360f * 32), 1f, 1f); 58 | } 59 | 60 | fun glColor() { 61 | if (rainbow) { 62 | val color = getRainbow() 63 | GlStateManager.color(color.red / 255.0f, color.green / 255.0f, color.blue / 255.0f, alpha / 255.0f) 64 | } else 65 | GlStateManager.color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f) 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/EventHandler.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core 2 | 3 | import dev.amber.backend.events.core.imp.Event 4 | import dev.amber.backend.events.core.imp.Priority 5 | import java.lang.reflect.InvocationTargetException 6 | import java.lang.reflect.Method 7 | import java.util.* 8 | import java.util.concurrent.CopyOnWriteArrayList 9 | 10 | /** 11 | * @author DarkMagician6 12 | * @since 02-02-2014 13 | * Translated to kotlin by TechAle 14 | */ 15 | object EventHandler { 16 | private val REGISTRY_MAP = HashMap, MutableList>() 17 | fun register(obj: Any) { 18 | for (method in obj.javaClass.declaredMethods) { 19 | if (!isMethodBad(method)) { 20 | register(method, obj) 21 | } 22 | } 23 | } 24 | 25 | fun register(obj: Any, eventClass: Class) { 26 | for (method in obj.javaClass.declaredMethods) { 27 | if (!isMethodBad(method, eventClass)) { 28 | register(method, obj) 29 | } 30 | } 31 | } 32 | 33 | fun unregister(obj: Any) { 34 | for (dataList in REGISTRY_MAP.values) { 35 | dataList.removeIf { data: MethodData -> data.source == obj } 36 | } 37 | cleanMap(true) 38 | } 39 | 40 | fun unregister(obj: Any, eventClass: Class) { 41 | if (REGISTRY_MAP.containsKey(eventClass)) { 42 | REGISTRY_MAP[eventClass]!!.removeIf { data: MethodData -> data.source == obj } 43 | cleanMap(true) 44 | } 45 | } 46 | 47 | private fun register(method: Method, obj: Any) { 48 | val indexClass = method.parameterTypes[0] as Class 49 | val data = MethodData(obj, method, method.getAnnotation(EventTarget::class.java).value) 50 | if (!data.target.isAccessible) { 51 | data.target.isAccessible = true 52 | } 53 | if (REGISTRY_MAP.containsKey(indexClass)) { 54 | if (!REGISTRY_MAP[indexClass]!!.contains(data)) { 55 | REGISTRY_MAP[indexClass]!!.add(data) 56 | sortListValue(indexClass) 57 | } 58 | } else { 59 | REGISTRY_MAP.put(indexClass, object : CopyOnWriteArrayList() { 60 | private val serialVersionUID = 666L 61 | 62 | init { 63 | add(data) 64 | } 65 | }) 66 | } 67 | } 68 | 69 | fun removeEntry(indexClass: Class) { 70 | val mapIterator: MutableIterator, List>> = REGISTRY_MAP.entries.iterator() 71 | while (mapIterator.hasNext()) { 72 | if (mapIterator.next().key == indexClass) { 73 | mapIterator.remove() 74 | break 75 | } 76 | } 77 | } 78 | 79 | fun cleanMap(onlyEmptyEntries: Boolean) { 80 | val mapIterator: MutableIterator, List>> = REGISTRY_MAP.entries.iterator() 81 | while (mapIterator.hasNext()) { 82 | if (!onlyEmptyEntries || mapIterator.next().value.isEmpty()) { 83 | mapIterator.remove() 84 | } 85 | } 86 | } 87 | 88 | private fun sortListValue(indexClass: Class) { 89 | val sortedList: MutableList = CopyOnWriteArrayList() 90 | for (priority in Priority.VALUE_ARRAY) { 91 | for (data in REGISTRY_MAP[indexClass]!!) { 92 | if (data.priority == priority) { 93 | sortedList.add(data) 94 | } 95 | } 96 | } 97 | REGISTRY_MAP[indexClass] = sortedList 98 | } 99 | 100 | private fun isMethodBad(method: Method): Boolean { 101 | return method.parameterTypes.size != 1 || !method.isAnnotationPresent(EventTarget::class.java) 102 | } 103 | 104 | private fun isMethodBad(method: Method, eventClass: Class): Boolean { 105 | return isMethodBad(method) || method.parameterTypes[0] != eventClass 106 | } 107 | 108 | fun call(event: Event): Event { 109 | val dataList: List? = REGISTRY_MAP[event.javaClass] 110 | if (dataList != null) { 111 | for (data in dataList) { 112 | invoke(data, event) 113 | } 114 | } 115 | return event 116 | } 117 | 118 | private operator fun invoke(data: MethodData, argument: Event) { 119 | try { 120 | data.target.invoke(data.source, argument) 121 | } catch (e: IllegalAccessException) { 122 | e.printStackTrace() 123 | } catch (e: IllegalArgumentException) { 124 | e.printStackTrace() 125 | } catch (e: InvocationTargetException) { 126 | e.printStackTrace() 127 | } 128 | } 129 | 130 | private class MethodData(val source: Any, val target: Method, val priority: Byte) 131 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/EventTarget.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core 2 | 3 | import dev.amber.backend.events.core.imp.Priority 4 | 5 | /** 6 | * @author DarkMagician6 7 | * @since 07-30-2013 8 | * Translated to kotlin by TechAle 9 | */ 10 | @MustBeDocumented 11 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 12 | @kotlin.annotation.Retention(AnnotationRetention.RUNTIME) 13 | annotation class EventTarget(val value: Byte = Priority.MEDIUM) -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/imp/Cancellable.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core.imp 2 | 3 | /** 4 | * @author DarkMagician6 5 | * @since 08-27-2013 6 | * Translated to kotlin by TechAle 7 | */ 8 | interface Cancellable { 9 | fun isCancelled(): Boolean 10 | 11 | fun setCancelled(cancelled: Boolean) 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/imp/Event.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core.imp 2 | 3 | /** 4 | * @author DarkMagician6 5 | * @since 07-30-2013 6 | * Translated to kotlin by TechAle 7 | */ 8 | interface Event -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/imp/EventCancellable.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core.imp 2 | 3 | /** 4 | * @author DarkMagician6 5 | * @since 08-27-2013 6 | * Translated to kotlin by TechAle 7 | */ 8 | abstract class EventCancellable : Event, Cancellable { 9 | private var cancelled = false 10 | override fun isCancelled(): Boolean { 11 | return cancelled 12 | } 13 | 14 | override fun setCancelled(cancelled: Boolean) { 15 | this.cancelled = cancelled 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/core/imp/Priority.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.core.imp 2 | 3 | /** 4 | * @author DarkMagician6 5 | * @since 08-03-2013 6 | * Translated to kotlin by TechAle 7 | */ 8 | object Priority { 9 | const val HIGHEST: Byte = 0 10 | const val HIGH: Byte = 1 11 | const val MEDIUM: Byte = 2 12 | const val LOW: Byte = 3 13 | const val LOWEST: Byte = 4 14 | val VALUE_ARRAY = byteArrayOf( 15 | HIGHEST, 16 | HIGH, 17 | MEDIUM, 18 | LOW, 19 | LOWEST 20 | ) 21 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/list/EventClientTick.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.list 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | 8 | import dev.amber.backend.events.core.imp.EventCancellable 9 | import net.minecraftforge.fml.common.gameevent.TickEvent 10 | 11 | class EventClientTick( 12 | val phase : TickEvent.Phase 13 | ) : EventCancellable() { 14 | companion object 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/list/EventGuiChange.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.list 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | 8 | import dev.amber.backend.events.core.imp.Event 9 | import net.minecraftforge.client.event.GuiOpenEvent 10 | 11 | class EventGuiChange( 12 | val data : GuiOpenEvent 13 | ) : Event { 14 | companion object 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/list/EventMessage.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.list 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | 8 | import dev.amber.backend.events.core.imp.Event 9 | import net.minecraftforge.client.event.ClientChatEvent 10 | 11 | class EventMessage( 12 | text : ClientChatEvent 13 | ) : Event { 14 | val message = text 15 | 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/events/list/EventRenderTick.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.events.list 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | 8 | import dev.amber.backend.events.core.imp.Event 9 | import net.minecraftforge.fml.common.gameevent.TickEvent 10 | 11 | class EventRenderTick( 12 | val data : TickEvent.RenderTickEvent 13 | ) : Event { 14 | companion object 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/managers/list/CommandManager.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.managers.list 2 | 3 | import dev.amber.api.util.LOGGER 4 | import dev.amber.backend.events.core.EventTarget 5 | import dev.amber.backend.events.core.imp.Priority 6 | import dev.amber.backend.events.list.EventMessage 7 | import dev.amber.frontend.command.Command 8 | import dev.amber.client.command.commands.TestCommand 9 | 10 | /* 11 | @author TechAle 12 | @since 07/09/21 13 | */ 14 | object CommandManager : manager { 15 | val commands = arrayListOf() 16 | const val prefix = "-" 17 | 18 | override fun onLoad() { 19 | LOGGER.startTimer("Command Manager") 20 | addCommand(TestCommand) 21 | LOGGER.endTimer("Command Manager") 22 | } 23 | 24 | private fun addCommand(c : Command) { 25 | commands.add(c) 26 | } 27 | 28 | @EventTarget(Priority.HIGHEST) 29 | fun prova(event : EventMessage) { 30 | val msg = event.message.message 31 | 32 | if (msg.startsWith(prefix)) { 33 | event.message.isCanceled = true 34 | 35 | val command = msg.split(" ")[0].drop(1) 36 | var found = false 37 | 38 | commands.forEach { 39 | if (it.aliasList.contains(command)) { 40 | it.onCommand(msg.split(" ").drop(1)) 41 | found = true 42 | return@forEach 43 | } 44 | } 45 | // If not found 46 | if (!found) { 47 | // Message help 48 | println("Nothing found") 49 | } 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/managers/list/EventManager.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.managers.list 2 | 3 | import dev.amber.api.util.Globals.mc 4 | import dev.amber.backend.events.core.EventHandler 5 | import dev.amber.backend.events.list.EventGuiChange 6 | import dev.amber.backend.events.list.EventMessage 7 | import dev.amber.backend.events.list.EventRenderTick 8 | import dev.amber.backend.managers.list.ModuleManager.modules 9 | import dev.amber.frontend.module.Module 10 | import net.minecraftforge.client.event.ClientChatEvent 11 | import net.minecraftforge.client.event.GuiOpenEvent 12 | import net.minecraftforge.client.event.RenderGameOverlayEvent 13 | import net.minecraftforge.client.event.RenderWorldLastEvent 14 | import net.minecraftforge.fml.common.eventhandler.EventPriority 15 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent 16 | import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent 17 | import net.minecraftforge.fml.common.gameevent.TickEvent 18 | import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent 19 | import org.lwjgl.input.Keyboard 20 | import java.lang.reflect.Field 21 | 22 | 23 | /** 24 | * @author A2H 25 | */ 26 | @Suppress("UNUSED_PARAMETER") 27 | object EventManager : manager { 28 | 29 | override fun onLoad() { 30 | } 31 | 32 | @SubscribeEvent 33 | fun onClientTick(event: TickEvent.ClientTickEvent) { 34 | if (mc.player == null) return 35 | modules.filter(Module::enabled).forEach(Module::onTick) 36 | } 37 | 38 | private var _listShaders: Field? = null 39 | private var blurExclusions = ArrayList() 40 | private var start: Long = 0 41 | private var fadeTime = 0 42 | 43 | @SubscribeEvent 44 | fun onGuiChange(event: GuiOpenEvent) { 45 | EventHandler.call(EventGuiChange(event)) 46 | } 47 | 48 | private fun getProgress(): Float { 49 | return ((System.currentTimeMillis() - start) / (fadeTime.toFloat())).coerceAtMost(1f) 50 | } 51 | 52 | @SubscribeEvent 53 | fun onRenderTick(event: RenderTickEvent) { 54 | EventHandler.call(EventRenderTick(event)) 55 | } 56 | 57 | 58 | @SubscribeEvent 59 | fun onChat(event: ClientChatEvent) { 60 | EventHandler.call(EventMessage(event)) 61 | 62 | } 63 | 64 | @SubscribeEvent 65 | fun onRender(event: RenderGameOverlayEvent.Chat) { 66 | if (mc.renderManager.renderViewEntity == null) return 67 | modules.filter(Module::enabled).forEach(Module::onRender) 68 | } 69 | 70 | @SubscribeEvent(priority = EventPriority.HIGHEST) 71 | fun onKeyPress(event: KeyInputEvent?) { 72 | if (Keyboard.getEventKeyState()) { 73 | val key = Keyboard.getEventKey() 74 | 75 | modules.forEach { 76 | if (key == it.key) { 77 | it.toggle() 78 | } 79 | } 80 | } 81 | } 82 | 83 | @SubscribeEvent 84 | fun onRenderWorldLast(event: RenderWorldLastEvent) { 85 | if (mc.renderManager.renderViewEntity == null) return 86 | modules.filter(Module::enabled).forEach {it.onWorldRender(event)} 87 | } 88 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/managers/list/ModuleManager.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.managers.list 2 | 3 | import dev.amber.api.util.LOGGER 4 | import dev.amber.frontend.module.Module 5 | import dev.amber.frontend.module.modules.client.* 6 | import dev.amber.frontend.module.modules.misc.* 7 | import dev.amber.frontend.module.modules.hud.* 8 | 9 | /** 10 | * @author A2H 11 | */ 12 | object ModuleManager : manager { 13 | val modules = arrayListOf() 14 | 15 | override fun onLoad() { 16 | LOGGER.startTimer("Module Manager") 17 | addModule(ExampleModule) 18 | addModule(GUIModule) 19 | addModule(HUDModule) 20 | addModule(ExampleHUD) 21 | addModule(Blur) 22 | addModule(testRendering) 23 | LOGGER.endTimer("Module Manager") 24 | } 25 | 26 | private fun addModule(m : Module) { 27 | modules.add(m) 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/backend/managers/manager.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.backend.managers.list 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | 8 | interface manager { 9 | 10 | fun onLoad() 11 | 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/Amber.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend 2 | 3 | import dev.amber.api.util.LOGGER 4 | import dev.amber.backend.events.core.EventHandler 5 | import dev.amber.backend.managers.list.CommandManager 6 | import dev.amber.backend.managers.list.EventManager 7 | import dev.amber.backend.managers.list.ModuleManager 8 | import dev.amber.backend.managers.list.manager 9 | import net.minecraftforge.common.MinecraftForge 10 | import net.minecraftforge.fml.common.Mod 11 | import net.minecraftforge.fml.common.event.FMLInitializationEvent 12 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent 13 | 14 | 15 | /* 16 | @author TechAle 17 | @since 07/09/21 18 | */ 19 | 20 | @Suppress("UNUSED_PARAMETER") 21 | @Mod(modid = Amber.MODID, name = Amber.NAME, version = Amber.VERSION) 22 | class Amber { 23 | 24 | @Mod.EventHandler 25 | fun preInit(event: FMLPreInitializationEvent) {} 26 | 27 | @Mod.EventHandler 28 | fun init(event: FMLInitializationEvent) { 29 | LOGGER.startTimer("Init Amber") 30 | MinecraftForge.EVENT_BUS.register(EventManager) 31 | loadManager(CommandManager) 32 | loadManager(ModuleManager) 33 | loadManager(EventManager) 34 | LOGGER.endTimer("Init Amber") 35 | } 36 | 37 | private fun loadManager(manager : manager) { 38 | EventHandler.register(manager) 39 | manager.onLoad() 40 | } 41 | 42 | companion object { 43 | const val MODID = "amber" 44 | const val NAME = "Amber" 45 | const val VERSION = "0.1.0" 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/command/Command.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.command 2 | 3 | /* 4 | @author TechAle 5 | @since 07/09/21 6 | */ 7 | abstract class Command(val name: String, val syntax: String, vararg alias: String) { 8 | 9 | val aliasList: List = alias.toList() 10 | 11 | open fun onCommand(Options: List?) {} 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/command/commands/TestCommand.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.client.command.commands 2 | 3 | import dev.amber.frontend.command.Command 4 | 5 | object TestCommand : Command(name = "TestCommand", "Syntax", "tst", "gg") { 6 | 7 | override fun onCommand(Options: List?) { 8 | System.out.println("It works!") 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/gui/GuiScreen.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.client.gui 2 | 3 | import dev.amber.api.render.VertexUtil 4 | import dev.amber.api.render.gui.Background 5 | import dev.amber.api.util.Globals 6 | import dev.amber.api.util.MessageUtil 7 | import dev.amber.frontend.module.Module 8 | import dev.amber.frontend.module.modules.client.GUIModule 9 | import net.minecraft.client.gui.GuiScreen 10 | import net.minecraft.client.gui.ScaledResolution 11 | 12 | /** 13 | * @author A2H 14 | */ 15 | class GuiScreen : GuiScreen() { 16 | 17 | /* 18 | private val categoriesList = arrayListOf() 19 | private val moduleList = arrayListOf()*/ 20 | 21 | init { 22 | /* 23 | var xOffset = 3 24 | Module.Category.values().forEach { category -> 25 | if (category == Module.Category.HUD) return@forEach 26 | categoriesList.add(Categories(category, xOffset)) 27 | xOffset += 114 28 | var yOffset = 3 29 | modules.forEach { module -> 30 | if (category == module.category) { 31 | yOffset += 14 32 | moduleList.add(Modules(module, yOffset, module.category)) 33 | } 34 | } 35 | }*/ 36 | } 37 | 38 | override fun doesGuiPauseGame(): Boolean { 39 | return false 40 | } 41 | 42 | override fun onGuiClosed() { 43 | GUIModule.enabled = false 44 | } 45 | 46 | override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { 47 | /* 48 | fun isHover(X: Int, Y: Int, W: Int, H: Int, mX: Int, mY: Int): Boolean { 49 | return mX >= X && mX <= X + W && mY >= Y && mY <= Y + H 50 | } 51 | categoriesList.forEach { category -> 52 | drawRect(category.x - 1, y - 1, category.x + 1 + w, y + h + 1, Color(0, 255, 0).rgb) 53 | drawRect(category.x, y, category.x + w, y + h, Color(64, 64, 64).rgb) 54 | mc.fontRenderer.drawString(category.name.toString(), category.x + 3, y + 3, Color(196, 196, 196).rgb) 55 | 56 | moduleList.forEach { mL -> 57 | if (category.name == mL.category) { 58 | drawRect(category.x - 1, mL.y, category.x + w + 1, mL.y + h + 1, Color(0, 255, 0).rgb) 59 | drawRect(category.x, mL.y, category.x + w, mL.y + h, Color(64, 64, 64).rgb) 60 | if (mL.module.enabled) { 61 | mc.fontRenderer.drawString(mL.module.name, category.x + 3, mL.y + 3, Color(0, 255, 0).rgb) 62 | } else { 63 | mc.fontRenderer.drawString(mL.module.name, category.x + 3, mL.y + 3, Color(196, 196, 196).rgb) 64 | } 65 | if (lmClicked && isHover(category.x, mL.y, w, h, mouseX, mouseY)) { 66 | mL.module.toggle() 67 | lmClicked = false 68 | } 69 | } 70 | } 71 | } 72 | lmClicked = false*/ 73 | 74 | drawHeader() 75 | 76 | 77 | 78 | drawBottom() 79 | 80 | } 81 | 82 | // Just draw the header of the gui 83 | private fun drawHeader() { 84 | 85 | // Prepare opengGL 86 | VertexUtil.prepareGl() 87 | 88 | Background.drawLogo() 89 | 90 | } 91 | 92 | // Just draw the animations on the bottom of the gui 93 | private fun drawBottom() { 94 | 95 | val width = ScaledResolution(Globals.mc).scaledWidth.toFloat() 96 | val height = ScaledResolution(Globals.mc).scaledHeight.toFloat() 97 | 98 | Background.drawParticles(width, height) 99 | 100 | Background.drawDynamicBoxes(width, height) 101 | 102 | // Release openGl 103 | VertexUtil.releaseGL() 104 | } 105 | 106 | 107 | override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { 108 | if (mouseButton == 0) { 109 | MessageUtil.sendClientMessage("Clicked 0") 110 | } 111 | else if (mouseButton == 1) { 112 | MessageUtil.sendClientMessage("Clicked 1") 113 | } 114 | } 115 | 116 | override fun mouseReleased(mouseX: Int, mouseY: Int, mouseButton: Int) { 117 | if (mouseButton == 0) { 118 | MessageUtil.sendClientMessage("Released 0") 119 | } 120 | else if (mouseButton == 1) { 121 | MessageUtil.sendClientMessage("Released 1") 122 | } 123 | } 124 | 125 | override fun mouseClickMove(mouseX: Int, mouseY: Int, mouseButton: Int, timeSinceLastClick: Long) { 126 | if (mouseButton == 0) { 127 | //MessageUtil.sendClientMessage("Moved 0") 128 | } 129 | else if (mouseButton == 1) { 130 | //MessageUtil.sendClientMessage("Moved 1") 131 | } 132 | } 133 | 134 | 135 | } 136 | 137 | data class Categories(var name: Module.Category, val x: Int) 138 | 139 | data class Modules(var module: Module, val y: Int, var category: Module.Category) 140 | 141 | 142 | /// In mememory of every sketches 143 | // Watermark 144 | /* 145 | First scatch watermark 146 | // Prepare opengGL 147 | VertexUtil.prepareGl() 148 | // Rect under the picture 149 | RenderUtil2d.drawRect( 150 | Start = Vec2f.ZERO, 151 | width = 61f, 152 | height = 50f, 153 | c = ABColor(0,0,0, 180) 154 | ) 155 | GlStateManager.pushMatrix() 156 | GL11.glScalef(1f, .4f, 1f) 157 | // Circle belove 158 | RenderUtil2d.drawCircleBorder( 159 | center = Vec2f(0f, 125f), 160 | radius = 63f, 161 | segments = 1000, 162 | insideC = arrayOf(ABColor(0, 0, 0, 180)), 163 | outsideC = arrayOf(ABColor(0, 0, 0), ABColor(255, 0, 0)), 164 | angleRange = Pair(90f, 180f)) 165 | GlStateManager.popMatrix() 166 | // Border rectangle 167 | RenderUtil2d.drawRect( 168 | Start = Vec2f(61f, 48f), 169 | width = 93f, 170 | height = 2f, 171 | c = ABColor(255, 0, 0) 172 | ) 173 | 174 | // Inside rectangle 175 | RenderUtil2d.drawRect( 176 | Start = Vec2f(61f, 0f), 177 | width = 93f, 178 | height = 48f, 179 | c = ABColor(0, 0,0, 180) 180 | ) 181 | 182 | // Triangle 183 | RenderUtil2d.drawTriangle( 184 | pos1 = Vec2f(154f, 0f), 185 | pos2 = Vec2f(154f, 48f), 186 | pos3 = Vec2f(175f, 0f), 187 | ABColor(0, 0, 0, 180) 188 | ) 189 | 190 | // Above triangle 191 | RenderUtil2d.drawLine( 192 | start = Vec2f(154f, 49f), 193 | end = Vec2f(175f, 0f), 194 | c = ABColor(255, 0, 0), 195 | lineWidth = 3f 196 | ) 197 | 198 | // Release for showing the picture+text 199 | VertexUtil.releaseGL() 200 | // Amber picture 201 | RenderUtil2d.showPicture(x = 5, y = 5, 202 | resourceLocation = ResourceLocation("amber/img/logogradient.png"), 203 | width = 45, height = 45) 204 | 205 | // Tecture 206 | RenderUtil2d.drawText(text = "Amber", x = 60f, y= 16f, 207 | color = ABColor(255, 255, 255), 208 | fontSize = 3f) 209 | 210 | // Prepare gl again 211 | VertexUtil.prepareGl() 212 | */ 213 | /* 214 | Second sketch watermark 215 | 216 | // Prepare opengGL 217 | VertexUtil.prepareGl() 218 | // Rect under the picture 219 | RenderUtil2d.drawRect( 220 | Start = Vec2f.ZERO, 221 | width = 61f, 222 | height = 50f, 223 | c = ABColor(0,0,0, 180) 224 | ) 225 | GlStateManager.pushMatrix() 226 | GL11.glScalef(1f, .4f, 1f) 227 | // Circle belove 228 | RenderUtil2d.drawCircleBorder( 229 | center = Vec2f(0f, 125f), 230 | radius = 63f, 231 | segments = 1000, 232 | insideC = arrayOf(ABColor(0, 0, 0, 180)), 233 | outsideC = arrayOf(ABColor(0, 0, 0), ABColor(255, 0, 0)), 234 | angleRange = Pair(90f, 180f)) 235 | GlStateManager.popMatrix() 236 | // Border rectangle 237 | RenderUtil2d.drawRect( 238 | Start = Vec2f(61f, 48f), 239 | width = 73f, 240 | height = 2f, 241 | c = ABColor(255, 0, 0) 242 | ) 243 | 244 | // Inside rectangle 245 | RenderUtil2d.drawRect( 246 | Start = Vec2f(61f, 0f), 247 | width = 93f, 248 | height = 48f, 249 | c = ABColor(0, 0,0, 180) 250 | ) 251 | 252 | // Triangle 253 | RenderUtil2d.drawTriangle( 254 | pos1 = Vec2f(154f, 0f), 255 | pos2 = Vec2f(154f, 48f), 256 | pos3 = Vec2f(175f, 0f), 257 | ABColor(0, 0, 0, 180) 258 | ) 259 | 260 | // Release for showing the picture+text 261 | VertexUtil.releaseGL() 262 | // Amber picture 263 | RenderUtil2d.showPicture(x = 5, y = 5, 264 | resourceLocation = ResourceLocation("amber/img/logogradient.png"), 265 | width = 45, height = 45) 266 | 267 | // Tecture 268 | RenderUtil2d.drawText(text = "Amber", x = 60f, y= 16f, 269 | color = ABColor(255, 255, 255), 270 | fontSize = 3f) 271 | 272 | // Prepare gl again 273 | VertexUtil.prepareGl() 274 | */ 275 | /* 276 | Third sketch watermark 277 | // Prepare opengGL 278 | VertexUtil.prepareGl() 279 | // Rect under the picture 280 | RenderUtil2d.drawRect( 281 | Start = Vec2f.ZERO, 282 | width = 154f, 283 | height = 60f, 284 | c = ABColor(0,0,0, 180) 285 | ) 286 | // Border rectangle 287 | RenderUtil2d.drawRect( 288 | Start = Vec2f(0f, 58f), 289 | width = 154f, 290 | height = 2f, 291 | c = ABColor(255, 0, 0) 292 | ) 293 | 294 | // Triangle 295 | RenderUtil2d.drawTriangle( 296 | pos1 = Vec2f(154f, 0f), 297 | pos2 = Vec2f(154f, 58f), 298 | pos3 = Vec2f(175f, 0f), 299 | ABColor(0, 0, 0, 180) 300 | ) 301 | 302 | // Above triangle 303 | RenderUtil2d.drawLine( 304 | start = Vec2f(154f, 59f), 305 | end = Vec2f(175f, 0f), 306 | c = ABColor(255, 0, 0), 307 | lineWidth = 3f 308 | ) 309 | 310 | // Release for showing the picture+text 311 | VertexUtil.releaseGL() 312 | // Amber picture 313 | RenderUtil2d.showPicture(x = 5, y = 5, 314 | resourceLocation = ResourceLocation("amber/img/logogradient.png"), 315 | width = 45, height = 45) 316 | 317 | // Tecture 318 | RenderUtil2d.drawText(text = "Amber", x = 60f, y= 16f, 319 | color = ABColor(255, 255, 255), 320 | fontSize = 3f) 321 | 322 | // Prepare gl again 323 | VertexUtil.prepareGl() 324 | */ 325 | /* 326 | Four sketch watermark 327 | // Prepare opengGL 328 | VertexUtil.prepareGl() 329 | // Rect under the picture 330 | RenderUtil2d.drawRect( 331 | Start = Vec2f.ZERO, 332 | width = 61f, 333 | height = 50f, 334 | c = ABColor(0,0,0, 180) 335 | ) 336 | 337 | RenderUtil2d.drawTriangle( 338 | pos1 = Vec2f(0f, 50f), 339 | pos2 = Vec2f(61f, 50f), 340 | pos3 = Vec2f(0f, 90f), 341 | c = ABColor(0, 0, 0, 180) 342 | ) 343 | 344 | RenderUtil2d.drawLine( 345 | start = Vec2f(0f, 90f), 346 | end = Vec2f(61f, 49f), 347 | c = ABColor(255, 0, 0), 348 | lineWidth = 3f 349 | ) 350 | 351 | // Border rectangle 352 | RenderUtil2d.drawRect( 353 | Start = Vec2f(61f, 48f), 354 | width = 83f, 355 | height = 2f, 356 | c = ABColor(255, 0, 0) 357 | ) 358 | 359 | // Inside rectangle 360 | RenderUtil2d.drawRect( 361 | Start = Vec2f(61f, 0f), 362 | width = 83f, 363 | height = 48f, 364 | c = ABColor(0, 0,0, 180) 365 | ) 366 | 367 | // Triangle 368 | RenderUtil2d.drawTriangle( 369 | pos1 = Vec2f(144f, 0f), 370 | pos2 = Vec2f(144f, 48f), 371 | pos3 = Vec2f(175f, 0f), 372 | ABColor(0, 0, 0, 180) 373 | ) 374 | 375 | // Above triangle 376 | RenderUtil2d.drawLine( 377 | start = Vec2f(144f, 49f), 378 | end = Vec2f(175f, 0f), 379 | c = ABColor(255, 0, 0), 380 | lineWidth = 3f 381 | ) 382 | 383 | // Release for showing the picture+text 384 | VertexUtil.releaseGL() 385 | // Amber picture 386 | RenderUtil2d.showPicture(x = 5, y = 5, 387 | resourceLocation = ResourceLocation("amber/img/logogradient.png"), 388 | width = 45, height = 45) 389 | 390 | // Tecture 391 | RenderUtil2d.drawText(text = "Amber", x = 60f, y= 16f, 392 | color = ABColor(255, 255, 255), 393 | fontSize = 3f) 394 | 395 | // Prepare gl again 396 | VertexUtil.prepareGl() 397 | */ -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/gui/HudScreen.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.client.gui 2 | 3 | import dev.amber.backend.managers.list.ModuleManager.modules 4 | import dev.amber.frontend.module.Module 5 | import dev.amber.frontend.module.modules.client.HUDModule 6 | import net.minecraft.client.gui.GuiScreen 7 | import java.awt.Color 8 | 9 | /** 10 | * @author A2H 11 | * @author Hoosiers 12 | */ 13 | class HudScreen : GuiScreen() { 14 | 15 | private val hudModuleList = arrayListOf() 16 | private var lmClicked = false 17 | private var rmClicked = false 18 | private var y = 3 19 | private val w = 105 20 | private var h = 15 21 | 22 | init { 23 | var yOffset = 3 24 | modules.forEach { module -> 25 | if (module.category != Module.Category.HUD) return@forEach 26 | yOffset += 14 27 | hudModuleList.add(HudModules(module, yOffset)) 28 | } 29 | } 30 | 31 | override fun doesGuiPauseGame(): Boolean { 32 | return false 33 | } 34 | 35 | override fun onGuiClosed() { 36 | HUDModule.enabled = false 37 | } 38 | 39 | override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { 40 | fun isHover(X: Int, Y: Int, W: Int, H: Int, mX: Int, mY: Int): Boolean { 41 | return mX >= X && mX <= X + W && mY >= Y && mY <= Y + H 42 | } 43 | 44 | drawRect(2, y - 1, 4 + w, y + h + 1, Color(0, 255, 0).rgb) 45 | drawRect(3, y, 3 + w, y + h, Color(64, 64, 64).rgb) 46 | mc.fontRenderer.drawString("HUDEditor", 6, y + 3, Color(196, 196, 196).rgb) 47 | 48 | hudModuleList.forEach { hL -> 49 | drawRect(2, hL.y, 4 + w, hL.y + h + 1, Color(0, 255, 0).rgb) 50 | drawRect(3, hL.y, 3 + w, hL.y + h, Color(64, 64, 64).rgb) 51 | if (hL.module.enabled) { 52 | mc.fontRenderer.drawString(hL.module.name, 6, hL.y + 3, Color(0, 255, 0).rgb) 53 | } else { 54 | mc.fontRenderer.drawString(hL.module.name, 6, hL.y + 3, Color(196, 196, 196).rgb) 55 | } 56 | if (lmClicked && isHover(3, hL.y, w, h, mouseX, mouseY)) { 57 | hL.module.toggle() 58 | lmClicked = false 59 | } 60 | } 61 | 62 | lmClicked = false 63 | } 64 | 65 | override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { 66 | if (mouseButton == 0) { 67 | lmClicked = true 68 | } 69 | if (mouseButton == 1) { 70 | rmClicked = true 71 | } 72 | } 73 | } 74 | 75 | data class HudModules(var module: Module, val y: Int) -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/Module.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.module 2 | 3 | import dev.amber.backend.events.core.EventHandler 4 | import net.minecraftforge.client.event.RenderWorldLastEvent 5 | import org.lwjgl.input.Keyboard 6 | 7 | /** 8 | * @author A2H 9 | */ 10 | open class Module(val category: Category, val name : String, enable : Boolean = false) { 11 | var enabled = enable 12 | open var key = Keyboard.KEY_NONE 13 | 14 | init { 15 | if (enable) { 16 | enable() 17 | } 18 | } 19 | 20 | enum class Category { 21 | Combat, Exploits, Movement, Misc, Render, Client, HUD 22 | } 23 | 24 | fun toggle() { 25 | enabled = !enabled 26 | if (enabled) enable() 27 | else disable() 28 | } 29 | 30 | fun enable() { 31 | onEnable() 32 | EventHandler.register(this) 33 | } 34 | 35 | fun disable() { 36 | onDisable() 37 | EventHandler.unregister(this) 38 | } 39 | 40 | 41 | open fun onEnable() { 42 | } 43 | 44 | open fun onDisable() { 45 | } 46 | 47 | open fun onTick() {} 48 | 49 | open fun onRender() {} 50 | 51 | open fun onWorldRender(event: RenderWorldLastEvent) {} 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/client/Blur.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("DEPRECATION", "unused") 2 | 3 | package dev.amber.frontend.module.modules.client 4 | 5 | import com.google.common.base.Throwables 6 | import dev.amber.backend.events.core.EventTarget 7 | import dev.amber.backend.events.core.imp.Priority 8 | import dev.amber.backend.events.list.EventGuiChange 9 | import dev.amber.backend.events.list.EventRenderTick 10 | import dev.amber.frontend.module.Module 11 | import net.minecraft.client.Minecraft 12 | import net.minecraft.client.shader.Shader 13 | import net.minecraft.client.shader.ShaderGroup 14 | import net.minecraft.util.ResourceLocation 15 | import net.minecraftforge.fml.common.gameevent.TickEvent 16 | import net.minecraftforge.fml.relauncher.ReflectionHelper 17 | import java.lang.reflect.Field 18 | 19 | /** 20 | * @author TechAle 21 | * @since 12/09/21 22 | * Thanks to tterrag1098 for the blur mod (https://github.com/tterrag1098/Blur) 23 | */ 24 | object Blur : Module(category = Category.Client, "Blur", true) { 25 | 26 | private var listShaders: Field? = null 27 | private var blurExclusions = ArrayList() 28 | private var start: Long = 0 29 | private var fadeTime = 0 30 | 31 | @EventTarget(Priority.HIGHEST) 32 | fun guiChangeEvent(event : EventGuiChange) { 33 | if (listShaders == null) { 34 | // This was inverted lol 35 | listShaders = ReflectionHelper.findField(ShaderGroup::class.java, "listShaders", "field_148031_d") 36 | } 37 | if (Minecraft.getMinecraft().world != null) { 38 | val er = Minecraft.getMinecraft().entityRenderer 39 | val excluded = event.data.gui == null || blurExclusions.contains(event.data.gui.javaClass.name) 40 | if (!er.isShaderActive && !excluded) { 41 | er.loadShader(ResourceLocation("amber/fade_in_blur.json")) 42 | start = System.currentTimeMillis() 43 | } else if (er.isShaderActive && excluded) { 44 | er.stopUseShader() 45 | } 46 | } 47 | } 48 | 49 | override fun onEnable() { 50 | if (listShaders == null) { 51 | // This was inverted lol 52 | listShaders = ReflectionHelper.findField(ShaderGroup::class.java, "listShaders", "field_148031_d") 53 | } 54 | if (Minecraft.getMinecraft().world != null) { 55 | val er = Minecraft.getMinecraft().entityRenderer 56 | if (!er.isShaderActive) { 57 | er.loadShader(ResourceLocation("amber/fade_in_blur.json")) 58 | start = System.currentTimeMillis() 59 | } 60 | } 61 | 62 | } 63 | 64 | override fun onDisable() { 65 | if (Minecraft.getMinecraft().world != null) { 66 | val er = Minecraft.getMinecraft().entityRenderer 67 | if (er.isShaderActive) { 68 | er.stopUseShader() 69 | } 70 | } 71 | } 72 | 73 | @EventTarget(Priority.HIGHEST) 74 | fun renderTickEvent(event : EventRenderTick) { 75 | if (event.data.phase == TickEvent.Phase.END && Minecraft.getMinecraft().currentScreen != null && Minecraft.getMinecraft().entityRenderer.isShaderActive) { 76 | val sg = Minecraft.getMinecraft().entityRenderer.shaderGroup 77 | try { 78 | @Suppress("UNCHECKED_CAST") val shaders: List = listShaders?.get(sg) as List 79 | for (s in shaders) { 80 | s?.shaderManager?.getShaderUniform("Progress")?.set(getProgress()) 81 | } 82 | } catch (e: IllegalArgumentException) { 83 | Throwables.propagate(e) 84 | } catch (e: IllegalAccessException) { 85 | Throwables.propagate(e) 86 | } 87 | } 88 | } 89 | 90 | 91 | 92 | private fun getProgress(): Float { 93 | return ((System.currentTimeMillis() - start) / (fadeTime.toFloat())).coerceAtMost(1f) 94 | } 95 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/client/GUIModule.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.module.modules.client 2 | 3 | import dev.amber.api.util.Globals.mc 4 | import dev.amber.api.util.Globals.nullCheck 5 | import dev.amber.client.gui.GuiScreen 6 | import dev.amber.frontend.module.Module 7 | import org.lwjgl.input.Keyboard 8 | 9 | /** 10 | * @Author A2H 11 | */ 12 | object GUIModule : Module(Category.Client, "ClickGui") { 13 | override var key = Keyboard.KEY_RSHIFT 14 | 15 | override fun onEnable() { 16 | nullCheck() 17 | mc.displayGuiScreen(GuiScreen()) 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/client/HUDModule.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.module.modules.client 2 | 3 | import dev.amber.api.util.Globals.mc 4 | import dev.amber.api.util.Globals.nullCheck 5 | import dev.amber.client.gui.HudScreen 6 | import dev.amber.frontend.module.Module 7 | import org.lwjgl.input.Keyboard 8 | 9 | object HUDModule : Module(Category.Client, "HUDEditor") { 10 | override var key = Keyboard.KEY_RCONTROL 11 | 12 | override fun onEnable() { 13 | nullCheck() 14 | GUIModule.enabled = false 15 | mc.displayGuiScreen(HudScreen()) 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/client/testRendering.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("DEPRECATION", "unused") 2 | 3 | package dev.amber.frontend.module.modules.client 4 | 5 | 6 | import dev.amber.api.render.RenderUtil2d 7 | import dev.amber.api.render.VertexUtil 8 | import dev.amber.api.variables.ABColor 9 | import dev.amber.frontend.module.Module 10 | import net.minecraft.util.ResourceLocation 11 | import net.minecraft.util.math.Vec2f 12 | 13 | /** 14 | * @author TechAle 15 | * @since 12/09/21 16 | */ 17 | object testRendering : Module(category = Category.Client, "testRendering", false) { 18 | 19 | override fun onRender() { 20 | 21 | /// Text (text cannot be inside prepareGL and releaseGL) 22 | // Normal text 23 | RenderUtil2d.drawText("Quad", 0f, 0f, ABColor(255, 255, 255)) 24 | // Gradient text 25 | RenderUtil2d.drawText("Circle", 80f, 0f, arrayOf(ABColor(255, 255, 255), ABColor(0, 0, 0))) 26 | // Multi gradient 27 | RenderUtil2d.drawText("Rounded Rect", 180f, 0f, arrayOf(ABColor(255, 0, 0), ABColor(0, 255, 0), ABColor(0, 0, 255))) 28 | /// Pictures 29 | // Normal 30 | RenderUtil2d.showPicture(350, 50, ResourceLocation("amber/img/logogradient.png"), 100, 100) 31 | // Color 32 | RenderUtil2d.showPicture(350, 200, ResourceLocation("amber/img/logowhite.png"), 50, 50, ABColor(0, 255, 255)) 33 | VertexUtil.prepareGl() 34 | /// Rect 35 | // Normal rect 36 | RenderUtil2d.drawRect(Vec2f(10f, 30f), 50f, 50f, ABColor(255, 0, 0), ) 37 | // Outline gradient rect 2 colors top bottom 38 | RenderUtil2d.drawRectOutline(Vec2f(10f, 90f), 50f, 50f, 5f, once = false, 39 | arrayOf(ABColor(0, 0, 255), ABColor(0, 255, 0)), topBottom = true) 40 | // Border rect with inside 1 color and outside 4 colors 41 | RenderUtil2d.drawRectBorder(Vec2f(10f, 160f), 50f, 50f, 1f, 42 | arrayOf(ABColor(0, 0, 0, 150)), true, 43 | arrayOf(ABColor(0, 0, 255), ABColor(0, 255, 0), ABColor(255, 0, 0), ABColor(255, 255, 255)), true) 44 | // Simple line 1 color 45 | RenderUtil2d.drawLine(Vec2f(70f, 0f), Vec2f(70f, 300f), 5f, ABColor(0,0,0)) 46 | /// Circle 47 | // Filled 48 | RenderUtil2d.drawCircleFilled(Vec2f(100f, 60f), 20f, 720, ABColor(0, 255, 255)) 49 | // 3/4 outline 50 | RenderUtil2d.drawCircleOutline(Vec2f(100f, 110f), 20f, 720, 5f, 51 | arrayOf(ABColor(0, 255, 0), ABColor(0, 0, 255)), Pair(0f, 270f), false ) 52 | // Border 53 | RenderUtil2d.drawCircleBorder(Vec2f(100f, 170f), 20f, 720, 5f, 54 | arrayOf(ABColor(255, 255, 255), ABColor(0, 255, 255), ABColor(255, 255, 255)), 55 | arrayOf(ABColor(0, 0, 0), ABColor(255, 0, 0), ABColor(0, 0, 0)), 56 | Pair(0f, 366f), false) 57 | // 2 color line 58 | RenderUtil2d.drawLine(Vec2f(150f, 0f), Vec2f(150f, 300f), 5f, arrayOf(ABColor(0,255,255), ABColor(255, 255, 0))) 59 | /// Rounded rect 60 | // Normal 61 | RenderUtil2d.drawRoundedRect(Vec2f(160f, 50f), 50f, 10f, 2f, 62 | arrayOf(ABColor(0, 0, 0), ABColor(255, 255, 255))) 63 | // Outline 64 | RenderUtil2d.drawRoundedRectOutline(Vec2f(160f, 100f), 50f, 50f, 5f, 3f, ABColor(0, 255, 0)) 65 | // Border 66 | RenderUtil2d.drawRoundedRectBorder(Vec2f(160f, 170f), 50f, 50f, 10f, 3f, 67 | arrayOf(ABColor(255, 0, 0)), true, 68 | arrayOf(ABColor(255, 255, 0), ABColor(0, 255, 255)), false) 69 | RenderUtil2d.drawLine(Vec2f(300f, 0f), Vec2f(300f, 300f), 5f, 70 | arrayOf(ABColor(0, 0, 0), ABColor(255, 255, 255), ABColor(255, 255, 0), ABColor(0, 0, 255))) 71 | 72 | VertexUtil.releaseGL() 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/hud/ExampleHUD.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.module.modules.hud 2 | 3 | import dev.amber.api.util.Globals.mc 4 | import dev.amber.api.util.Globals.nullCheck 5 | import dev.amber.frontend.module.Module 6 | import java.awt.Color 7 | 8 | /** 9 | * @author Hoosiers 10 | */ 11 | object ExampleHUD : Module(category = Category.HUD, "ExampleHUD") { 12 | 13 | override fun onRender() { 14 | nullCheck() 15 | mc.fontRenderer.drawString("Hello Hi!", 10, 10, Color(255, 255, 255, 255).rgb) 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/dev/amber/frontend/module/modules/misc/ExampleModule.kt: -------------------------------------------------------------------------------- 1 | package dev.amber.frontend.module.modules.misc 2 | 3 | import dev.amber.api.setting.SettingManager 4 | import dev.amber.api.setting.values.BooleanSetting 5 | import dev.amber.api.setting.values.DoubleSetting 6 | import dev.amber.api.setting.values.IntegerSetting 7 | import dev.amber.api.setting.values.ModeSetting 8 | import dev.amber.api.util.MessageUtil 9 | import dev.amber.frontend.module.Module 10 | import org.lwjgl.input.Keyboard 11 | 12 | /** 13 | * @Author A2H 14 | */ 15 | object ExampleModule : Module(category = Category.Misc, "Example") { 16 | override var key = Keyboard.KEY_APOSTROPHE 17 | val settingA=SettingManager.registerSetting(BooleanSetting("Boolean Thingy",false),this) 18 | val settingB=SettingManager.registerSetting(DoubleSetting("Double Thingy",1.0,0.0,10.0),this) 19 | val settingC=SettingManager.registerSetting(IntegerSetting("Integer Thingy",25,0,100),this) 20 | val settingD=SettingManager.registerSetting(ModeSetting("Mode", Mode.A),this) 21 | 22 | override fun onEnable() { 23 | MessageUtil.sendClientMessage("Example Module") 24 | toggle() 25 | } 26 | 27 | enum class Mode { 28 | A,B,C; 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/amber/fade_in_blur.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | "swap" 4 | ], 5 | "passes": [ 6 | { 7 | "name": "fade_in_blur", 8 | "intarget": "minecraft:main", 9 | "outtarget": "swap", 10 | "uniforms": [ 11 | { 12 | "name": "BlurDir", 13 | "values": [ 1.0, 0.0 ] 14 | }, 15 | { 16 | "name": "Radius", 17 | "values": [ 4 ] 18 | } 19 | ] 20 | }, 21 | { 22 | "name": "fade_in_blur", 23 | "intarget": "swap", 24 | "outtarget": "minecraft:main", 25 | "uniforms": [ 26 | { 27 | "name": "BlurDir", 28 | "values": [ 0.0, 1.0 ] 29 | }, 30 | { 31 | "name": "Radius", 32 | "values": [ 4 ] 33 | } 34 | ] 35 | }, 36 | { 37 | "name": "fade_in_blur", 38 | "intarget": "minecraft:main", 39 | "outtarget": "swap", 40 | "uniforms": [ 41 | { 42 | "name": "BlurDir", 43 | "values": [ 1.0, 0.0 ] 44 | }, 45 | { 46 | "name": "Radius", 47 | "values": [ 4 ] 48 | } 49 | ] 50 | }, 51 | { 52 | "name": "fade_in_blur", 53 | "intarget": "swap", 54 | "outtarget": "minecraft:main", 55 | "uniforms": [ 56 | { 57 | "name": "BlurDir", 58 | "values": [ 0.0, 1.0 ] 59 | }, 60 | { 61 | "name": "Radius", 62 | "values": [ 4 ] 63 | } 64 | ] 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/amber/img/logogradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechAle/Amber/86c89204f602ad17d72e1f56073bfa5a263ec284/src/main/resources/assets/minecraft/amber/img/logogradient.png -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/amber/img/logowhite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechAle/Amber/86c89204f602ad17d72e1f56073bfa5a263ec284/src/main/resources/assets/minecraft/amber/img/logowhite.png -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/shaders/post/fade_in_blur.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | "swap" 4 | ], 5 | "passes": [ 6 | { 7 | "name": "fade_in_blur", 8 | "intarget": "minecraft:main", 9 | "outtarget": "swap", 10 | "uniforms": [ 11 | { 12 | "name": "BlurDir", 13 | "values": [ 1.0, 0.0 ] 14 | }, 15 | { 16 | "name": "Radius", 17 | "values": [ @radius@.0 ] 18 | } 19 | ] 20 | }, 21 | { 22 | "name": "fade_in_blur", 23 | "intarget": "swap", 24 | "outtarget": "minecraft:main", 25 | "uniforms": [ 26 | { 27 | "name": "BlurDir", 28 | "values": [ 0.0, 1.0 ] 29 | }, 30 | { 31 | "name": "Radius", 32 | "values": [ @radius@.0 ] 33 | } 34 | ] 35 | }, 36 | { 37 | "name": "fade_in_blur", 38 | "intarget": "minecraft:main", 39 | "outtarget": "swap", 40 | "uniforms": [ 41 | { 42 | "name": "BlurDir", 43 | "values": [ 1.0, 0.0 ] 44 | }, 45 | { 46 | "name": "Radius", 47 | "values": [ @radius@.0 ] 48 | } 49 | ] 50 | }, 51 | { 52 | "name": "fade_in_blur", 53 | "intarget": "swap", 54 | "outtarget": "minecraft:main", 55 | "uniforms": [ 56 | { 57 | "name": "BlurDir", 58 | "values": [ 0.0, 1.0 ] 59 | }, 60 | { 61 | "name": "Radius", 62 | "values": [ @radius@.0 ] 63 | } 64 | ] 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/shaders/program/fade_in_blur.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D DiffuseSampler; 4 | 5 | varying vec2 texCoord; 6 | varying vec2 oneTexel; 7 | 8 | uniform vec2 InSize; 9 | 10 | uniform vec2 BlurDir; 11 | uniform float Radius; 12 | uniform float Progress; 13 | 14 | void main() { 15 | vec4 blurred = vec4(0.0); 16 | float totalStrength = 0.0; 17 | float totalAlpha = 0.0; 18 | float totalSamples = 0.0; 19 | float progRadius = floor(Radius * Progress); 20 | for(float r = -progRadius; r <= progRadius; r += 1.0) { 21 | vec4 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir); 22 | 23 | // Accumulate average alpha 24 | totalAlpha = totalAlpha + sample.a; 25 | totalSamples = totalSamples + 1.0; 26 | 27 | // Accumulate smoothed blur 28 | float strength = 1.0 - abs(r / progRadius); 29 | totalStrength = totalStrength + strength; 30 | blurred = blurred + sample; 31 | } 32 | gl_FragColor = vec4(blurred.rgb / (progRadius * 2.0 + 1.0), totalAlpha); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/shaders/program/fade_in_blur.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "one", 5 | "dstrgb": "zero" 6 | }, 7 | "vertex": "sobel", 8 | "fragment": "fade_in_blur", 9 | "attributes": [ "Position" ], 10 | "samplers": [ 11 | { "name": "DiffuseSampler" } 12 | ], 13 | "uniforms": [ 14 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 15 | { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 16 | { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 17 | { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 18 | { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] }, 19 | { "name": "Progress", "type": "float", "count": 1, "values": [ 0.0 ] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "Amber", 4 | "name": "Amber", 5 | "description": "1.12.2 Utility Mod for Forge", 6 | "version": "0.1.0", 7 | "mcversion": "1.12.2", 8 | "url": "", 9 | "updateUrl": "", 10 | "authorList": ["TechAle"], 11 | "logoFile": "", 12 | "screenshots": [], 13 | "dependencies": [] 14 | } 15 | ] -------------------------------------------------------------------------------- /src/main/resources/mixins.amber.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "compatibilityLevel": "JAVA_8", 4 | "package": "dev.amber.backend.mixin.mixins", 5 | "refmap": "mixins.amber.refmap.json", 6 | "mixins": [ 7 | "MixinGuiBossOverlay" 8 | ] 9 | } --------------------------------------------------------------------------------