├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── assets │ ├── discord-join-badge.svg │ ├── xray-fabric-logo.svg │ └── xray-forge-badge.svg └── workflows │ └── release.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── .DS_Store ├── client ├── .DS_Store ├── java │ └── pro │ │ └── mikey │ │ ├── .DS_Store │ │ └── fabric │ │ ├── .DS_Store │ │ └── xray │ │ ├── ScanController.java │ │ ├── ScanTask.java │ │ ├── StateSettings.java │ │ ├── Utils.java │ │ ├── XRay.java │ │ ├── cache │ │ ├── BlockSearchCache.java │ │ └── BlockSearchEntry.java │ │ ├── mixins │ │ └── MixinBlockItem.java │ │ ├── records │ │ ├── BasicColor.java │ │ ├── BlockEntry.java │ │ ├── BlockGroup.java │ │ ├── BlockPosWithColor.java │ │ └── BlockWithStack.java │ │ ├── render │ │ └── RenderOutlines.java │ │ ├── screens │ │ ├── AbstractScreen.java │ │ ├── MainScreen.java │ │ └── forge │ │ │ ├── GuiAddBlock.java │ │ │ ├── GuiBase.java │ │ │ ├── GuiBlockList.java │ │ │ ├── GuiEdit.java │ │ │ ├── GuiHelp.java │ │ │ ├── GuiOverlay.java │ │ │ ├── GuiSelectionScreen.java │ │ │ ├── RatioSliderWidget.java │ │ │ └── ScrollingList.java │ │ └── storage │ │ ├── BlockStore.java │ │ ├── SettingsStore.java │ │ └── Store.java └── resources │ └── advanced-xray-fabric.mixins.json └── main └── resources ├── advanced-xray-fabric.accesswidener ├── assets └── advanced-xray-fabric │ ├── icon.png │ ├── lang │ ├── en_us.json │ ├── fr_fr.json │ ├── ja_jp.json │ └── zh_cn.json │ ├── shaders │ └── frag │ │ └── rendertype_lines_unaffected.fsh │ └── textures │ └── gui │ ├── bg-help.png │ ├── bg.png │ ├── circle.png │ └── color-bg.png └── fabric.mod.json /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: If you've found a bug that you think needs to be fixed then use this template. Be sure to fill out the form as shown and don't leave any sections off. 4 | --- 5 | 6 | **Describe the bug** 7 | A clear and concise description of what the bug is. 8 | 9 | **To Reproduce** 10 | Steps to reproduce the behavior: 11 | 1. step one 12 | 13 | **Expected behavior** 14 | A clear and concise description of what you expected to happen. 15 | 16 | **Screenshots** 17 | If applicable (delete if not), add screenshots to help explain your problem. 18 | 19 | **Minecraft Enviorment** 20 | - Minecraft Version: [eg: 1.12.2] 21 | - XRay Mod Version: [eg: 1.5.0] 22 | - Mod Pack & Version if applicable 23 | - Forge Version if applicable 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/assets/discord-join-badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/assets/xray-fabric-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /.github/assets/xray-forge-badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Clone project 13 | uses: actions/checkout@v3 14 | - name: Set up JDK 15 | uses: actions/setup-java@v2 16 | with: 17 | distribution: "temurin" 18 | java-version: 21 19 | - name: Fix borked permissions 20 | run: chmod +x ./gradlew 21 | - name: Run gradle tasks 22 | uses: gradle/gradle-build-action@v2 23 | env: 24 | SNAPSHOT: false 25 | SAPS_TOKEN: ${{ secrets.SAPS_TOKEN }} 26 | CURSE_TOKEN: ${{ secrets.CURSE_DEPLOY_TOKEN }} 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | with: 29 | arguments: publish publishMods 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | logs/ 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # fabric 28 | 29 | remappedSrc/ 30 | run/ 31 | 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [21.4.0] 2 | 3 | ### Changes 4 | 5 | - Ported to 1.21.4 6 | 7 | ## [21.2.0] 8 | 9 | ### Changes 10 | 11 | - Ported to 1.21.2 12 | - Tooltip on entry hover has how been moved to help text under the main gui 13 | 14 | ### Fixed 15 | 16 | - Scrollbar should no longer click through to the entry behind it 17 | 18 | ## [21.0.0] 19 | 20 | ### Changes 21 | 22 | - Ported to 1.21 23 | - Changed the version system to match the Minecraft versioning system / Neoforges versioning system 24 | 25 | ## [86.0.0] 26 | 27 | ### Changes 28 | 29 | - Ported to 1.20.6 30 | 31 | ## [85.0.0] 32 | 33 | ### Changes 34 | 35 | - Ported to 1.20.5 36 | 37 | ## [84.0.0] 38 | 39 | ### Changes 40 | 41 | - Ported to 1.20.4 42 | 43 | ## [83.0.0] 44 | 45 | ### Changes 46 | 47 | - Ported to 1.20.3 48 | 49 | ## [82.0.0] 50 | 51 | Why have you bumped the version to 82.0.0? Well, it's a long story but the short and sweet of it is that 82 is the current incremental version of Minecraft for 1.20.2. For example 1.20.1 was 81. This makes it a little simpler for me to maintain versions across multiple Minecraft versions without having to worry about the version numbers conflicting. 52 | 53 | ### Changes 54 | 55 | - Ported to 1.20.2 56 | 57 | ## [1.6.0] 58 | 59 | ### Changes 60 | 61 | - Ported to 1.20.1 62 | -------------------------------------------------------------------------------- /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 | ![XRay Logo](https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/refs/heads/main/.github/assets/xray-fabric-logo.svg) 2 | 3 | # [Advanced XRay (Fabric Edition)](https://www.curseforge.com/minecraft/mc-mods/advanced-xray-fabric-edition) 4 | 5 | Find the project on [CurseForge](https://www.curseforge.com/minecraft/mc-mods/advanced-xray-fabric-edition) 6 | 7 | [![](https://cf.way2muchnoise.eu/short_444663.svg)](https://www.curseforge.com/minecraft/mc-mods/advanced-xray-fabric-edition) 8 | [![](https://cf.way2muchnoise.eu/versions/444663.svg)](https://www.curseforge.com/minecraft/mc-mods/advanced-xray-fabric-edition) 9 | 10 | [![GitHub license](https://img.shields.io/github/license/advancedxray/XRay-Fabric)](https://github.com/advancedxray/XRay-Fabric/blob/main/LICENSE) 11 | [![GitHub issues](https://img.shields.io/github/issues/advancedxray/XRay-Fabric)](https://github.com/advancedxray/XRay-Fabric/issues) 12 | ![GitHub Release Date](https://img.shields.io/github/release-date/advancedxray/xray-Fabric) 13 | ![GitHub last commit](https://img.shields.io/github/last-commit/advancedxray/xray-Fabric) 14 | 15 | Fabric Loader based XRay mod designed to aid players who don't like the ore searching process. This mod is an exact 1:1 copy of my [Advanced XRay Forge Mod](https://github.com/advancedxray/XRay-Mod/) which is typically the more up-to-date version of the mod. 16 | 17 | ##### Looking for the Forge version? Click the button below :tada: 18 | 19 | drawing 20 | 21 | 22 | ## Features 23 | Advanced XRay Fabric Edition is a feature rich XRay / Block ESP mod designed to aid players in the block searching process. I've designed the mod to be as user friendly as possible. Out of the box you'll have *Easy to use GUI for adding, deleting and editing block you want to find*, *Full RGB color picker support*, *Searchable block list with in-hand and in-world options for adding blocks*, *Json Stored list to share and edit easily outside of the game*. 24 | 25 | ## How to use 26 | 27 | **Using XRay** 28 | 29 | *Please note that these aren't always the ones set by default. Be sure to check your controls settings under `XRay` to find the correct keys* 30 | 31 | - Press `Backslash` to toggle XRay `ON/OFF` 32 | - Press `Z` to open the `selection & settings` Gui 33 | 34 | **Adding Blocks** 35 | 36 | - Open the GUI Editor pressing `[Default] Z` 37 | - Select the method you'd like to use to add a block, either From hand, What you can see, or By searching a list 38 | - Modify the Name, Color, and anything else you'd like to change 39 | - Click add and Enable the Block 40 | 41 | **Editing Blocks** 42 | 43 | - Shift Right click on any item in the GUI and edit as needed 44 | - Click save and the changed will be applied 45 | 46 | ## Previews 47 | 48 | The [Imgur Album](http://imgur.com/a/23dX5) 49 | ![XRAY](http://i.imgur.com/N3KOEaE.png) 50 | 51 | ## Use on public servers 52 | 53 | I **DO NOT** support the use of this mod on any public servers which do not allow this kind of mod. The mod **does** work on servers but I do not approve of, and will not, support anyone that attempts to use this mod on servers. I **do not** have the time to review each issue; I will simply close any issue with server connections in the crash log. 54 | 55 | If you wish to use this mod on private servers then that's on you. If you use this on public servers and are banned then that's on you and I will **not** support your use of this mod in that way. 56 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '1.10-SNAPSHOT' 3 | id 'maven-publish' 4 | id 'pro.mikey.plugins.insaniam' version "0.1-SNAPSHOT" 5 | id "me.modmuss50.mod-publish-plugin" version "0.5.1" 6 | } 7 | 8 | def ENV = System.getenv() 9 | version = "${project.mod_version}" 10 | group = project.maven_group 11 | 12 | base { 13 | archivesName = project.archives_base_name 14 | } 15 | 16 | loom { 17 | splitEnvironmentSourceSets() 18 | 19 | accessWidenerPath = file("src/main/resources/advanced-xray-fabric.accesswidener") 20 | 21 | mods { 22 | "xray" { 23 | sourceSet sourceSets.client 24 | sourceSet sourceSets.main 25 | } 26 | } 27 | } 28 | 29 | dependencies { 30 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 31 | mappings loom.officialMojangMappings() 32 | 33 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 34 | modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 35 | } 36 | 37 | processResources { 38 | inputs.property "version", project.version 39 | inputs.property "fabricloader", project.loader_version 40 | inputs.property "mc_version", project.minecraft_version 41 | 42 | filesMatching("fabric.mod.json") { 43 | expand "version": project.version, 44 | "fabricloader": project.loader_version, 45 | "mc_version": project.minecraft_version 46 | } 47 | } 48 | 49 | tasks.withType(JavaCompile).configureEach { 50 | it.options.release = 21 51 | } 52 | 53 | java { 54 | withSourcesJar() 55 | 56 | sourceCompatibility = JavaVersion.VERSION_21 57 | targetCompatibility = JavaVersion.VERSION_21 58 | } 59 | 60 | jar { 61 | from("LICENSE") { 62 | rename { "${it}_${project.archivesBaseName}" } 63 | } 64 | } 65 | 66 | // configure the maven publication 67 | publishing { 68 | publications { 69 | mavenJava(MavenPublication) { 70 | groupId project.group 71 | artifactId project.archivesBaseName 72 | version project.version 73 | from components.java 74 | } 75 | } 76 | repositories { 77 | maven { 78 | url "https://maven.saps.dev/releases" 79 | credentials { 80 | username "mikeymods" 81 | password "${ENV.SAPS_TOKEN}" 82 | } 83 | } 84 | } 85 | } 86 | 87 | def changelogData = insaniamUtils.createChangelog { 88 | file = file('CHANGELOG.md') 89 | versionPattern = ~/## \[[^]]+]/ 90 | fallbackValue = "No changelog provided" 91 | version = project.mod_version 92 | } 93 | 94 | publishMods { 95 | def curseToken = providers.environmentVariable("CURSE_TOKEN") 96 | 97 | dryRun = curseToken.getOrNull() == null 98 | changelog = changelogData 99 | version = project.mod_version 100 | type = STABLE 101 | file = remapJar.archiveFile 102 | 103 | curseforge { 104 | displayName = "Advanced XRay Fabric ${mod_version}" 105 | accessToken = curseToken 106 | projectId = project.curse_id 107 | minecraftVersions.add("${minecraft_version}") 108 | modLoaders.add("fabric") 109 | javaVersions.add(JavaVersion.VERSION_21) 110 | } 111 | 112 | github { 113 | repository = "AdvancedXRay/XRay-Fabric" 114 | accessToken = providers.environmentVariable("GITHUB_TOKEN") 115 | commitish = providers.environmentVariable("GITHUB_SHA").orElse("main") 116 | tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("v${mod_version}") 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx4G 3 | minecraft_version=1.21.5 4 | 5 | # Mod Properties 6 | mod_version=21.5.0 7 | maven_group=pro.mikey 8 | archives_base_name=advanced-xray-fabric 9 | 10 | loader_version=0.16.12 11 | fabric_version=0.120.0+1.21.5 12 | 13 | curse_id=444663 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven { 5 | name = 'Fabric' 6 | url = 'https://maven.fabricmc.net/' 7 | } 8 | maven { 9 | name = 'saps' 10 | url = 'https://maven.saps.dev/snapshots' 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/.DS_Store -------------------------------------------------------------------------------- /src/client/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/client/.DS_Store -------------------------------------------------------------------------------- /src/client/java/pro/mikey/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/client/java/pro/mikey/.DS_Store -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/client/java/pro/mikey/fabric/.DS_Store -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/ScanController.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray; 2 | 3 | import net.minecraft.Util; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.core.BlockPos; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.item.context.BlockPlaceContext; 8 | import net.minecraft.world.level.ChunkPos; 9 | import net.minecraft.world.level.Level; 10 | import net.minecraft.world.level.block.Block; 11 | import net.minecraft.world.level.block.entity.BlockEntity; 12 | import net.minecraft.world.level.block.state.BlockState; 13 | import pro.mikey.fabric.xray.records.BlockPosWithColor; 14 | import pro.mikey.fabric.xray.storage.BlockStore; 15 | import pro.mikey.fabric.xray.storage.SettingsStore; 16 | 17 | import java.util.Collections; 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | public class ScanController { 22 | public static Set renderQueue = Collections.synchronizedSet(new HashSet<>()); 23 | private static ChunkPos playerLastChunk; 24 | 25 | /** 26 | * No point even running if the player is still in the same chunk. 27 | */ 28 | private static boolean playerLocationChanged() { 29 | if (Minecraft.getInstance().player == null) 30 | return false; 31 | 32 | ChunkPos plyChunkPos = Minecraft.getInstance().player.chunkPosition(); 33 | int range = StateSettings.getHalfRange(); 34 | 35 | return playerLastChunk == null || 36 | plyChunkPos.x > playerLastChunk.x + range || plyChunkPos.x < playerLastChunk.x - range || 37 | plyChunkPos.z > playerLastChunk.z + range || plyChunkPos.z < playerLastChunk.z - range; 38 | } 39 | 40 | /** 41 | * Runs the scan task by checking if the thread is ready but first attempting to provide the cache 42 | * if the cache is still valid. 43 | * 44 | * @param forceRerun if the task is required to re-run for instance, a block is broken in the 45 | * world. 46 | */ 47 | public static synchronized void runTask(boolean forceRerun) { 48 | Minecraft client = Minecraft.getInstance(); 49 | if (client.player == null && client.level == null) { 50 | return; 51 | } 52 | 53 | if (!SettingsStore.getInstance().get().isActive() || (!forceRerun && !playerLocationChanged())) { 54 | return; 55 | } 56 | 57 | // Update the players last chunk to eval against above. 58 | playerLastChunk = client.player.chunkPosition(); 59 | Util.backgroundExecutor().execute(new ScanTask()); 60 | } 61 | 62 | public static void blockBroken(Level world, Player playerEntity, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) { 63 | if (!SettingsStore.getInstance().get().isActive()) return; 64 | 65 | if (renderQueue.stream().anyMatch(e -> e.pos().equals(blockPos))) { 66 | runTask(true); 67 | } 68 | } 69 | 70 | public static void blockPlaced(BlockPlaceContext context) { 71 | if (!SettingsStore.getInstance().get().isActive()) return; 72 | 73 | BlockState defaultState = Block.byItem(context.getItemInHand().getItem()).defaultBlockState(); 74 | if (BlockStore.getInstance().getCache().get().stream().anyMatch(e -> e.getState() == defaultState)) { 75 | runTask(true); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/ScanTask.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.world.entity.player.Player; 6 | import net.minecraft.world.level.Level; 7 | import net.minecraft.world.level.block.state.BlockState; 8 | import net.minecraft.world.level.chunk.LevelChunkSection; 9 | import net.minecraft.world.level.material.LavaFluid; 10 | import org.jetbrains.annotations.Nullable; 11 | import pro.mikey.fabric.xray.cache.BlockSearchEntry; 12 | import pro.mikey.fabric.xray.records.BasicColor; 13 | import pro.mikey.fabric.xray.records.BlockPosWithColor; 14 | import pro.mikey.fabric.xray.render.RenderOutlines; 15 | import pro.mikey.fabric.xray.storage.BlockStore; 16 | import pro.mikey.fabric.xray.storage.SettingsStore; 17 | 18 | import java.util.Arrays; 19 | import java.util.HashSet; 20 | import java.util.Objects; 21 | import java.util.Set; 22 | import java.util.concurrent.atomic.AtomicBoolean; 23 | 24 | public class ScanTask implements Runnable { 25 | private static AtomicBoolean isScanning = new AtomicBoolean(false); 26 | 27 | ScanTask() { 28 | } 29 | 30 | /** 31 | * Check if we're valid and push back the blocks color for the render queue 32 | */ 33 | @Nullable 34 | public static BasicColor isValidBlock(BlockPos pos, Level world, Set blocks) { 35 | BlockState state = world.getBlockState(pos); 36 | if (state.isAir()) { 37 | return null; 38 | } 39 | 40 | if (SettingsStore.getInstance().get().isShowLava() && state.getFluidState().getType() instanceof LavaFluid) { 41 | return new BasicColor(210, 10, 10); 42 | } 43 | 44 | BlockState defaultState = state.getBlock().defaultBlockState(); 45 | 46 | return blocks.stream() 47 | .filter(localState -> localState.isDefault() && defaultState == localState.getState() || !localState.isDefault() && state == localState.getState()) 48 | .findFirst() 49 | .map(BlockSearchEntry::getColor) 50 | .orElse(null); 51 | } 52 | 53 | @Override 54 | public void run() { 55 | if (isScanning.get()) { 56 | return; 57 | } 58 | 59 | isScanning.set(true); 60 | Set c = this.collectBlocks(); 61 | ScanController.renderQueue.clear(); 62 | ScanController.renderQueue.addAll(c); 63 | isScanning.set(false); 64 | RenderOutlines.requestedRefresh.set(true); 65 | } 66 | 67 | /** 68 | * This is an "exact" copy from the forge version of the mod but with the optimisations that the 69 | * rewrite (Fabric) version has brought like chunk location based cache, etc. 70 | * 71 | *

This is only run if the cache is invalidated. 72 | * 73 | * @implNote Using the {@link BlockPos#betweenClosed(BlockPos, BlockPos)} may be a better system for the 74 | * scanning. 75 | */ 76 | private Set collectBlocks() { 77 | Set blocks = BlockStore.getInstance().getCache().get(); 78 | 79 | // If we're not looking for blocks, don't run. 80 | if (blocks.isEmpty() && !SettingsStore.getInstance().get().isShowLava()) { 81 | if (!ScanController.renderQueue.isEmpty()) { 82 | ScanController.renderQueue.clear(); 83 | } 84 | return new HashSet<>(); 85 | } 86 | 87 | Minecraft instance = Minecraft.getInstance(); 88 | 89 | final Level world = instance.level; 90 | final Player player = instance.player; 91 | 92 | // Just stop if we can't get the player or world. 93 | if (world == null || player == null) { 94 | return new HashSet<>(); 95 | } 96 | 97 | final Set renderQueue = new HashSet<>(); 98 | 99 | int cX = player.chunkPosition().x; 100 | int cZ = player.chunkPosition().z; 101 | 102 | int range = StateSettings.getHalfRange(); 103 | 104 | for (int i = cX - range; i <= cX + range; i++) { 105 | int chunkStartX = i << 4; 106 | for (int j = cZ - range; j <= cZ + range; j++) { 107 | int chunkStartZ = j << 4; 108 | 109 | for (int k = chunkStartX; k < chunkStartX + 16; k++) { 110 | for (int l = chunkStartZ; l < chunkStartZ + 16; l++) { 111 | for (int m = world.getMinY(); m < world.getMaxY() + (1 << 4); m++) { 112 | BlockPos pos = new BlockPos(k, m, l); 113 | BasicColor validBlock = isValidBlock(pos, world, blocks); 114 | if (validBlock != null) { 115 | renderQueue.add(new BlockPosWithColor(pos, validBlock)); 116 | } 117 | } 118 | } 119 | } 120 | } 121 | } 122 | 123 | return renderQueue; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/StateSettings.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray; 2 | 3 | import net.minecraft.util.Mth; 4 | import pro.mikey.fabric.xray.storage.SettingsStore; 5 | 6 | public class StateSettings { 7 | private static final int maxStepsToScan = 5; 8 | 9 | private transient boolean isActive; 10 | private boolean showLava; 11 | private int range; 12 | private boolean showOverlay; 13 | 14 | public StateSettings() { 15 | this.isActive = false; 16 | this.showLava = false; 17 | this.showOverlay = true; 18 | this.range = 3; 19 | } 20 | 21 | public boolean isActive() { 22 | return this.isActive; 23 | } 24 | 25 | void setActive(boolean active) { 26 | this.isActive = active; 27 | } 28 | 29 | public boolean isShowLava() { 30 | return this.showLava; 31 | } 32 | 33 | public void setShowLava(boolean showLava) { 34 | this.showLava = showLava; 35 | } 36 | 37 | public static int getRadius() { 38 | return Mth.clamp(SettingsStore.getInstance().get().range, 0, maxStepsToScan) * 3; 39 | } 40 | 41 | public static int getHalfRange() { 42 | return Math.max(0, getRadius() / 2); 43 | } 44 | 45 | public static int getVisualRadius() { 46 | return Math.max(1, getRadius()); 47 | } 48 | 49 | public void increaseRange() { 50 | if (SettingsStore.getInstance().get().range < maxStepsToScan) 51 | SettingsStore.getInstance().get().range = SettingsStore.getInstance().get().range + 1; 52 | else 53 | SettingsStore.getInstance().get().range = 0; 54 | } 55 | 56 | public void decreaseRange() { 57 | if (SettingsStore.getInstance().get().range > 0) 58 | SettingsStore.getInstance().get().range = SettingsStore.getInstance().get().range - 1; 59 | else 60 | SettingsStore.getInstance().get().range = maxStepsToScan; 61 | } 62 | 63 | public boolean showOverlay() { 64 | return this.showOverlay; 65 | } 66 | 67 | public void setShowOverlay(boolean showOverlay) { 68 | this.showOverlay = showOverlay; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/Utils.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | 5 | public class Utils { 6 | public static ResourceLocation rl(String path) { 7 | return ResourceLocation.fromNamespaceAndPath(XRay.MOD_ID, path); 8 | } 9 | 10 | public static ResourceLocation rlFull(String namespaceAndPath) { 11 | return ResourceLocation.tryParse(namespaceAndPath); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/XRay.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; 5 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; 6 | import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 7 | import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; 8 | import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; 9 | import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; 10 | import net.minecraft.ChatFormatting; 11 | import net.minecraft.client.KeyMapping; 12 | import net.minecraft.client.Minecraft; 13 | import net.minecraft.network.chat.Component; 14 | import org.apache.logging.log4j.LogManager; 15 | import org.apache.logging.log4j.Logger; 16 | import org.lwjgl.glfw.GLFW; 17 | import pro.mikey.fabric.xray.render.RenderOutlines; 18 | import pro.mikey.fabric.xray.screens.forge.GuiOverlay; 19 | import pro.mikey.fabric.xray.screens.forge.GuiSelectionScreen; 20 | import pro.mikey.fabric.xray.storage.BlockStore; 21 | import pro.mikey.fabric.xray.storage.SettingsStore; 22 | 23 | public class XRay implements ClientModInitializer { 24 | public static final String MOD_ID = "advanced-xray-fabric"; 25 | public static final String PREFIX_GUI = String.format("%s:textures/gui/", MOD_ID); 26 | public static final Logger LOGGER = LogManager.getLogger(MOD_ID); 27 | 28 | private final KeyMapping xrayButton = new KeyMapping("keybinding.enable_xray", GLFW.GLFW_KEY_BACKSLASH, "category.xray"); 29 | 30 | private final KeyMapping guiButton = new KeyMapping("keybinding.open_gui", GLFW.GLFW_KEY_G, "category.xray"); 31 | 32 | @Override 33 | public void onInitializeClient() { 34 | LOGGER.info("XRay mod has been initialized"); 35 | 36 | ClientTickEvents.END_CLIENT_TICK.register(this::clientTickEvent); 37 | ClientLifecycleEvents.CLIENT_STOPPING.register(this::gameClosing); 38 | ClientLifecycleEvents.CLIENT_STARTED.register(this::started); 39 | HudRenderCallback.EVENT.register(GuiOverlay::RenderGameOverlayEvent); 40 | 41 | WorldRenderEvents.LAST.register(RenderOutlines::render); 42 | PlayerBlockBreakEvents.AFTER.register(ScanController::blockBroken); 43 | 44 | KeyBindingHelper.registerKeyBinding(this.xrayButton); 45 | KeyBindingHelper.registerKeyBinding(this.guiButton); 46 | 47 | } 48 | 49 | private void started(Minecraft minecraft) { 50 | LOGGER.info("Client started, setting up xray store"); 51 | } 52 | 53 | /** 54 | * Upon game closing, attempt to save our json stores. This means we can be a little lazy with how 55 | * we go about saving throughout the rest of the mod 56 | */ 57 | private void gameClosing(Minecraft client) { 58 | SettingsStore.getInstance().write(); 59 | BlockStore.getInstance().write(); 60 | } 61 | 62 | /** 63 | * Used to handle keybindings and fire off threaded scanning tasks 64 | */ 65 | private void clientTickEvent(Minecraft mc) { 66 | if (mc.player == null || mc.level == null || mc.screen != null) { 67 | return; 68 | } 69 | 70 | // Try and run the task :D 71 | ScanController.runTask(false); 72 | 73 | while (this.guiButton.consumeClick()) { 74 | mc.setScreen(new GuiSelectionScreen()); 75 | } 76 | 77 | while (this.xrayButton.consumeClick()) { 78 | BlockStore.getInstance().updateCache(); 79 | 80 | StateSettings stateSettings = SettingsStore.getInstance().get(); 81 | stateSettings.setActive(!stateSettings.isActive()); 82 | 83 | ScanController.runTask(true); 84 | 85 | mc.player.displayClientMessage(Component.translatable("message.xray_" + (!stateSettings.isActive() ? "deactivate" : "active")).withStyle(stateSettings.isActive() ? ChatFormatting.GREEN : ChatFormatting.RED), true); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/cache/BlockSearchCache.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.cache; 2 | 3 | import pro.mikey.fabric.xray.records.BlockEntry; 4 | import pro.mikey.fabric.xray.records.BlockGroup; 5 | 6 | import java.util.HashSet; 7 | import java.util.List; 8 | import java.util.Set; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Physical representation of what we're searching for. Contains the actual state, Scraps unneeded 13 | * data and cleans up some logic along the way. 14 | * 15 | *

I control when this list is populated and has changes through the first load and the gui. 16 | */ 17 | public class BlockSearchCache { 18 | private Set cache = new HashSet<>(); 19 | 20 | public void processGroupedList(List blockEntries) { 21 | if (blockEntries == null || blockEntries.isEmpty()) { 22 | return; 23 | } 24 | 25 | // Flatten the grouped list down to a single cacheable list 26 | this.cache = 27 | blockEntries.stream() 28 | .flatMap( 29 | e -> 30 | e.entries().stream() 31 | .filter(BlockEntry::isActive) 32 | .map(a -> new BlockSearchEntry(a.getState(), a.getHex(), a.isDefault()))) 33 | .collect(Collectors.toSet()); 34 | } 35 | 36 | public Set get() { 37 | return this.cache; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/cache/BlockSearchEntry.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.cache; 2 | 3 | import com.google.common.base.MoreObjects; 4 | import com.google.common.base.Objects; 5 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 6 | import net.minecraft.core.registries.BuiltInRegistries; 7 | import net.minecraft.nbt.CompoundTag; 8 | import net.minecraft.nbt.NbtUtils; 9 | import net.minecraft.nbt.TagParser; 10 | import net.minecraft.world.level.block.Blocks; 11 | import net.minecraft.world.level.block.state.BlockState; 12 | import pro.mikey.fabric.xray.records.BasicColor; 13 | 14 | public class BlockSearchEntry { 15 | private final BlockState state; 16 | private final BasicColor color; 17 | private final boolean isDefault; 18 | 19 | BlockSearchEntry(BlockState state, BasicColor color, boolean isDefault) { 20 | this.state = state; 21 | this.color = color; 22 | this.isDefault = isDefault; 23 | } 24 | 25 | public static BlockState blockStateFromStringNBT(String nbt) { 26 | CompoundTag tag; 27 | try { 28 | tag = TagParser.parseCompoundFully(nbt); 29 | } catch (CommandSyntaxException e) { 30 | e.printStackTrace(); 31 | return Blocks.AIR.defaultBlockState(); 32 | } 33 | 34 | return NbtUtils.readBlockState(BuiltInRegistries.BLOCK, tag); 35 | } 36 | 37 | public static String blockStateToStringNBT(BlockState state) { 38 | return NbtUtils.writeBlockState(state).toString(); 39 | } 40 | 41 | public BlockState getState() { 42 | return this.state; 43 | } 44 | 45 | public BasicColor getColor() { 46 | return this.color; 47 | } 48 | 49 | public boolean isDefault() { 50 | return this.isDefault; 51 | } 52 | 53 | // We don't care about the color and isDefault 54 | @Override 55 | public boolean equals(Object o) { 56 | if (this == o) { 57 | return true; 58 | } 59 | if (o == null || this.getClass() != o.getClass()) { 60 | return false; 61 | } 62 | BlockSearchEntry that = (BlockSearchEntry) o; 63 | return Objects.equal(this.state, that.state); 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | return Objects.hashCode(this.state); 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return MoreObjects.toStringHelper(this) 74 | .add("state", this.state) 75 | .add("color", this.color) 76 | .add("isDefault", this.isDefault) 77 | .toString(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/mixins/MixinBlockItem.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.mixins; 2 | 3 | import net.minecraft.world.InteractionResult; 4 | import net.minecraft.world.item.BlockItem; 5 | import net.minecraft.world.item.context.BlockPlaceContext; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | import pro.mikey.fabric.xray.ScanController; 11 | 12 | // Thanks to architectury 13 | @Mixin(BlockItem.class) 14 | public abstract class MixinBlockItem { 15 | @Inject(method = "place", at = @At("TAIL")) 16 | private void place(BlockPlaceContext context, CallbackInfoReturnable cir) { 17 | if (context.getLevel().isClientSide) { 18 | ScanController.blockPlaced(context); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/records/BasicColor.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.records; 2 | 3 | import java.awt.*; 4 | 5 | public record BasicColor( 6 | int red, 7 | int green, 8 | int blue 9 | ) { 10 | public static BasicColor of(String hex) { 11 | if (!hex.startsWith("#")) { 12 | return new BasicColor(0, 0, 0); 13 | } 14 | 15 | Color color = Color.decode(hex); 16 | return new BasicColor(color.getRed(), color.getGreen(), color.getBlue()); 17 | } 18 | 19 | String toHex() { 20 | return String.format("#%02x%02x%02x", this.red, this.green, this.blue); 21 | } 22 | 23 | /** 24 | * Convert the color to an int along with a alpha value of 255 25 | */ 26 | public int toInt() { 27 | return (255 << 24) + (this.red << 16) + (this.green << 8) + this.blue; 28 | } 29 | 30 | public int toInt(int alpha) { 31 | return (alpha << 24) + (this.red << 16) + (this.green << 8) + this.blue; 32 | } 33 | 34 | public static int rgbaToInt(int red, int green, int blue, float alpha) { 35 | return ((int) (alpha * 255) << 24) + (red << 16) + (green << 8) + blue; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/records/BlockEntry.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.records; 2 | 3 | import com.google.gson.*; 4 | import net.minecraft.nbt.NbtUtils; 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | import pro.mikey.fabric.xray.cache.BlockSearchEntry; 8 | 9 | import java.lang.reflect.Type; 10 | 11 | public class BlockEntry { 12 | private BlockState state; 13 | private ItemStack stack; 14 | private String name; 15 | private BasicColor color; 16 | private int order; 17 | private boolean isDefault; 18 | private boolean active; 19 | 20 | public BlockEntry(BlockState state, String name, BasicColor color, int order, boolean isDefault, boolean active) { 21 | this.state = state; 22 | this.stack = new ItemStack(this.state.getBlock()); 23 | this.name = name; 24 | this.color = color; 25 | this.order = order; 26 | this.isDefault = isDefault; 27 | this.active = active; 28 | } 29 | 30 | public BlockState getState() { 31 | return this.state; 32 | } 33 | 34 | public void setState(BlockState state) { 35 | this.state = state; 36 | } 37 | 38 | public String getName() { 39 | return this.name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public BasicColor getHex() { 47 | return this.color; 48 | } 49 | 50 | public int getOrder() { 51 | return this.order; 52 | } 53 | 54 | public void setOrder(int order) { 55 | this.order = order; 56 | } 57 | 58 | public boolean isDefault() { 59 | return this.isDefault; 60 | } 61 | 62 | public void setDefault(boolean aDefault) { 63 | this.isDefault = aDefault; 64 | } 65 | 66 | public boolean isActive() { 67 | return this.active; 68 | } 69 | 70 | public void setActive(boolean active) { 71 | this.active = active; 72 | } 73 | 74 | public ItemStack getStack() { 75 | return this.stack; 76 | } 77 | 78 | public void setStack(ItemStack stack) { 79 | this.stack = stack; 80 | } 81 | 82 | public void setColor(BasicColor color) { 83 | this.color = color; 84 | } 85 | 86 | public static class Serializer implements JsonSerializer, JsonDeserializer { 87 | @Override 88 | public BlockEntry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { 89 | JsonObject asJsonObject = json.getAsJsonObject(); 90 | return new BlockEntry( 91 | BlockSearchEntry.blockStateFromStringNBT(asJsonObject.get("state").getAsString()), 92 | asJsonObject.get("name").getAsString(), 93 | BasicColor.of(asJsonObject.get("color").getAsString()), 94 | asJsonObject.get("order").getAsInt(), 95 | asJsonObject.get("isDefault").getAsBoolean(), 96 | asJsonObject.get("active").getAsBoolean()); 97 | } 98 | 99 | @Override 100 | public JsonElement serialize(BlockEntry src, Type typeOfSrc, JsonSerializationContext context) { 101 | JsonObject object = new JsonObject(); 102 | object.addProperty("state", NbtUtils.writeBlockState(src.getState()).toString()); 103 | object.addProperty("name", src.name); 104 | object.addProperty("color", src.color.toHex()); 105 | object.addProperty("order", src.order); 106 | object.addProperty("isDefault", src.isDefault); 107 | object.addProperty("active", src.active); 108 | return object; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/records/BlockGroup.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.records; 2 | 3 | import java.util.List; 4 | import java.util.Objects; 5 | 6 | public final class BlockGroup { 7 | private String name; 8 | private List entries; 9 | private int order; 10 | private boolean active; 11 | 12 | public BlockGroup( 13 | String name, 14 | List entries, 15 | int order, 16 | boolean active 17 | ) { 18 | this.name = name; 19 | this.entries = entries; 20 | this.order = order; 21 | this.active = active; 22 | } 23 | 24 | public String name() { 25 | return name; 26 | } 27 | 28 | public List entries() { 29 | return entries; 30 | } 31 | 32 | public int order() { 33 | return order; 34 | } 35 | 36 | public boolean active() { 37 | return active; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public List getEntries() { 49 | return entries; 50 | } 51 | 52 | public void setEntries(List entries) { 53 | this.entries = entries; 54 | } 55 | 56 | public int getOrder() { 57 | return order; 58 | } 59 | 60 | public void setOrder(int order) { 61 | this.order = order; 62 | } 63 | 64 | public boolean isActive() { 65 | return active; 66 | } 67 | 68 | public void setActive(boolean active) { 69 | this.active = active; 70 | } 71 | 72 | @Override 73 | public boolean equals(Object obj) { 74 | if (obj == this) return true; 75 | if (obj == null || obj.getClass() != this.getClass()) return false; 76 | var that = (BlockGroup) obj; 77 | return Objects.equals(this.name, that.name) && 78 | Objects.equals(this.entries, that.entries) && 79 | this.order == that.order && 80 | this.active == that.active; 81 | } 82 | 83 | @Override 84 | public int hashCode() { 85 | return Objects.hash(name, entries, order, active); 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "BlockGroup[" + 91 | "name=" + name + ", " + 92 | "entries=" + entries + ", " + 93 | "order=" + order + ", " + 94 | "active=" + active + ']'; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/records/BlockPosWithColor.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.records; 2 | 3 | import net.minecraft.core.BlockPos; 4 | 5 | public record BlockPosWithColor( 6 | BlockPos pos, 7 | BasicColor color 8 | ) { 9 | } 10 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/records/BlockWithStack.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.records; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | import net.minecraft.world.level.block.Block; 5 | 6 | public record BlockWithStack( 7 | Block block, 8 | ItemStack stack 9 | ) { 10 | } 11 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/render/RenderOutlines.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.render; 2 | 3 | import com.mojang.blaze3d.buffers.BufferType; 4 | import com.mojang.blaze3d.buffers.BufferUsage; 5 | import com.mojang.blaze3d.buffers.GpuBuffer; 6 | import com.mojang.blaze3d.pipeline.BlendFunction; 7 | import com.mojang.blaze3d.pipeline.RenderTarget; 8 | import com.mojang.blaze3d.platform.DepthTestFunction; 9 | import com.mojang.blaze3d.shaders.UniformType; 10 | import com.mojang.blaze3d.systems.RenderPass; 11 | import com.mojang.blaze3d.systems.RenderSystem; 12 | import com.mojang.blaze3d.pipeline.RenderPipeline; 13 | import com.mojang.blaze3d.vertex.*; 14 | import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; 15 | import net.minecraft.client.Minecraft; 16 | import net.minecraft.client.renderer.RenderPipelines; 17 | import net.minecraft.client.renderer.ShapeRenderer; 18 | import net.minecraft.resources.ResourceLocation; 19 | import net.minecraft.world.phys.Vec3; 20 | import org.joml.Matrix4fStack; 21 | import pro.mikey.fabric.xray.ScanController; 22 | import pro.mikey.fabric.xray.XRay; 23 | import pro.mikey.fabric.xray.records.BlockPosWithColor; 24 | import pro.mikey.fabric.xray.storage.SettingsStore; 25 | 26 | import java.util.OptionalDouble; 27 | import java.util.OptionalInt; 28 | import java.util.concurrent.atomic.AtomicBoolean; 29 | 30 | public class RenderOutlines { 31 | private static GpuBuffer vertexBuffer; 32 | private static int indexCount = 0; 33 | private static final RenderSystem.AutoStorageIndexBuffer indices = RenderSystem.getSequentialBuffer(VertexFormat.Mode.LINES); 34 | public static AtomicBoolean requestedRefresh = new AtomicBoolean(false); 35 | 36 | public static RenderPipeline LINES_NO_DEPTH = RenderPipeline.builder(RenderPipelines.MATRICES_COLOR_SNIPPET) 37 | .withLocation("pipeline/xray_lines") 38 | .withVertexShader("core/rendertype_lines") 39 | .withFragmentShader(ResourceLocation.fromNamespaceAndPath(XRay.MOD_ID, "frag/rendertype_lines_unaffected")) 40 | .withUniform("LineWidth", UniformType.FLOAT) 41 | .withUniform("ScreenSize", UniformType.VEC2) 42 | .withBlend(BlendFunction.TRANSLUCENT) 43 | .withCull(false) 44 | .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.LINES) 45 | .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) 46 | .build(); 47 | 48 | public static synchronized void render(WorldRenderContext context) { 49 | 50 | if (ScanController.renderQueue.isEmpty() || !SettingsStore.getInstance().get().isActive()) { 51 | return; 52 | } 53 | 54 | RenderPipeline pipeline = LINES_NO_DEPTH; 55 | if (vertexBuffer == null || requestedRefresh.get()) { 56 | requestedRefresh.set(false); 57 | 58 | if (vertexBuffer != null) { 59 | vertexBuffer.close(); 60 | } 61 | 62 | BufferBuilder bufferBuilder = Tesselator.getInstance().begin( 63 | pipeline.getVertexFormatMode(), pipeline.getVertexFormat() 64 | ); 65 | 66 | for (BlockPosWithColor blockProps : ScanController.renderQueue) { 67 | PoseStack poseStack = context.matrixStack(); 68 | if (blockProps == null || poseStack == null) { 69 | continue; 70 | } 71 | 72 | final float size = 1.0f; 73 | final int x = blockProps.pos().getX(), y = blockProps.pos().getY(), z = blockProps.pos().getZ(); 74 | 75 | final float red = (blockProps.color().red()) / 255f; 76 | final float green = (blockProps.color().green()) / 255f; 77 | final float blue = (blockProps.color().blue()) / 255f; 78 | 79 | ShapeRenderer.renderLineBox(poseStack, bufferBuilder, x, y, z, x + size, y + size, z + size, red, green, blue, 1f); 80 | } 81 | 82 | try (MeshData meshData = bufferBuilder.buildOrThrow()) { 83 | vertexBuffer = RenderSystem.getDevice() 84 | .createBuffer(() -> "Outline vertex buffer", BufferType.VERTICES, BufferUsage.STATIC_WRITE, meshData.vertexBuffer()); 85 | indexCount = meshData.drawState().indexCount(); 86 | } 87 | } 88 | 89 | if (indexCount != 0) { 90 | Vec3 playerPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition().reverse(); 91 | RenderTarget renderTarget = Minecraft.getInstance().getMainRenderTarget(); 92 | 93 | if (renderTarget.getColorTexture() == null) { 94 | return; 95 | } 96 | 97 | GpuBuffer gpuBuffer = indices.getBuffer(indexCount); 98 | 99 | try (RenderPass renderPass = RenderSystem.getDevice() 100 | .createCommandEncoder() 101 | .createRenderPass(renderTarget.getColorTexture(), OptionalInt.empty(), renderTarget.getDepthTexture(), OptionalDouble.empty())) { 102 | 103 | Matrix4fStack matrix4fStack = RenderSystem.getModelViewStack(); 104 | matrix4fStack.pushMatrix(); 105 | matrix4fStack.translate((float) playerPos.x(), (float) playerPos.y(), (float) playerPos.z()); 106 | renderPass.setPipeline(pipeline); 107 | renderPass.setIndexBuffer(gpuBuffer, indices.type()); 108 | renderPass.setVertexBuffer(0, vertexBuffer); 109 | renderPass.drawIndexed(0, indexCount); 110 | 111 | matrix4fStack.popMatrix(); 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/AbstractScreen.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import com.mojang.blaze3d.vertex.PoseStack; 5 | import net.minecraft.client.gui.GuiGraphics; 6 | import net.minecraft.client.gui.screens.Screen; 7 | import net.minecraft.client.renderer.RenderType; 8 | import net.minecraft.network.chat.Component; 9 | import net.minecraft.resources.ResourceLocation; 10 | import pro.mikey.fabric.xray.Utils; 11 | 12 | public abstract class AbstractScreen extends Screen { 13 | private static final ResourceLocation TEXTURE = Utils.rlFull("textures/gui/recipe_book.png"); 14 | 15 | AbstractScreen(Component title) { 16 | super(title); 17 | } 18 | 19 | @Override 20 | public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { 21 | super.render(guiGraphics, mouseX, mouseY, delta); 22 | 23 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 24 | int i = (this.width - 147) / 2; 25 | int j = (this.height - 166) / 2; 26 | 27 | guiGraphics.blit(RenderType::guiTextured, TEXTURE, i, j, 1, 1, 147, 166, 256, 256); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/MainScreen.java: -------------------------------------------------------------------------------- 1 | //package pro.mikey.fabric.xray.screens; 2 | // 3 | //import com.mojang.blaze3d.vertex.PoseStack; 4 | //import net.minecraft.client.gui.GuiGraphics; 5 | //import net.minecraft.network.chat.Component; 6 | //import net.minecraft.world.item.ItemStack; 7 | //import net.minecraft.world.item.Items; 8 | //import pro.mikey.fabric.xray.records.BlockEntry; 9 | //import pro.mikey.fabric.xray.records.BlockGroup; 10 | //import pro.mikey.fabric.xray.storage.BlockStore; 11 | // 12 | //import java.util.ArrayList; 13 | //import java.util.List; 14 | // 15 | //public class MainScreen extends AbstractScreen { 16 | // private final List blocks = new ArrayList<>(); 17 | // 18 | // public MainScreen() { 19 | // super(Component.empty()); 20 | // 21 | // List read = BlockStore.getInstance().read(); 22 | // if (read != null) { 23 | // this.blocks.addAll(read); 24 | // } 25 | // } 26 | // 27 | //// @Override 28 | //// public void init(MinecraftClient client, int width, int height) { 29 | //// super.init(client, width, height); 30 | //// } 31 | // 32 | // @Override 33 | // public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { 34 | // super.render(guiGraphics, mouseX, mouseY, delta); 35 | // 36 | // int y = 50; 37 | // for (BlockGroup group : this.blocks) { 38 | // guiGraphics.drawString(this.font, "Hello", this.width / 2 - 40, y, 0xFFFFFF); 39 | // 40 | // y += this.font.lineHeight + 10; 41 | // for (BlockEntry entry : group.entries()) { 42 | // drawString(matrices, this.font, entry.getName(), this.width / 2 - 40, y, 0xFFFFFF); 43 | // 44 | // matrices.pushPose(); 45 | // matrices.translate(this.width / 2f - 60, y - 5, 0); 46 | // matrices.scale(.8f, .8f, .8f); 47 | // this.itemRenderer.renderAndDecorateFakeItem(matrices, new ItemStack(Items.GOLD_BLOCK), 0, 0); 48 | // matrices.popPose(); 49 | // 50 | // y += this.font.lineHeight + 10; 51 | // } 52 | // 53 | // y += 10; 54 | // } 55 | // } 56 | // 57 | // @Override 58 | // public boolean isPauseScreen() { 59 | // return false; 60 | // } 61 | // 62 | // @Override 63 | // public void onClose() { 64 | // this.blocks.clear(); 65 | // super.onClose(); 66 | // } 67 | //} 68 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiAddBlock.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.platform.Lighting; 4 | import net.minecraft.client.gui.GuiGraphics; 5 | import net.minecraft.client.gui.components.Button; 6 | import net.minecraft.client.gui.components.EditBox; 7 | import net.minecraft.client.resources.language.I18n; 8 | import net.minecraft.network.chat.Component; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | import pro.mikey.fabric.xray.records.BasicColor; 12 | import pro.mikey.fabric.xray.records.BlockEntry; 13 | import pro.mikey.fabric.xray.records.BlockGroup; 14 | import pro.mikey.fabric.xray.storage.BlockStore; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Objects; 18 | import java.util.function.Supplier; 19 | 20 | public class GuiAddBlock extends GuiBase { 21 | private final ItemStack itemStack; 22 | private final Supplier previousScreenCallback; 23 | private BlockState selectBlock; 24 | private EditBox oreName; 25 | private Button addBtn; 26 | private RatioSliderWidget redSlider; 27 | private RatioSliderWidget greenSlider; 28 | private RatioSliderWidget blueSlider; 29 | private Button changeDefaultState; 30 | private BlockState lastState; 31 | private boolean oreNameCleared = false; 32 | 33 | GuiAddBlock(BlockState selectedBlock, Supplier previousScreenCallback) { 34 | super(false); 35 | this.selectBlock = selectedBlock; 36 | this.lastState = null; 37 | this.previousScreenCallback = previousScreenCallback; 38 | this.itemStack = new ItemStack(this.selectBlock.getBlock(), 1); 39 | } 40 | 41 | @Override 42 | public void init() { 43 | // Called when the gui should be (re)created 44 | boolean isDefaultState = this.selectBlock == this.selectBlock.getBlock().defaultBlockState(); 45 | this.addRenderableWidget(this.changeDefaultState = new Button.Builder(Component.literal(isDefaultState ? "Already scanning for all states" : "Scan for all block states"), button -> { 46 | this.lastState = this.selectBlock; 47 | this.selectBlock = this.selectBlock.getBlock().defaultBlockState(); 48 | button.active = false; 49 | }).pos(this.getWidth() / 2 - 100, this.getHeight() / 2 + 60).size(202,20).build()); 50 | 51 | if (isDefaultState) { 52 | this.changeDefaultState.active = false; 53 | } 54 | 55 | this.addRenderableWidget(this.addBtn = new Button.Builder(Component.translatable("xray.single.add"), button -> { 56 | this.onClose(); 57 | 58 | BlockGroup group = BlockStore.getInstance().get().size() >= 1 ? BlockStore.getInstance().get().get(0) : new BlockGroup("default", new ArrayList<>(), 1, true); 59 | group.entries().add(new BlockEntry(this.selectBlock, this.oreName.getValue(), new BasicColor((int) (this.redSlider.getValue() * 255), (int) (this.greenSlider.getValue() * 255), (int) (this.blueSlider.getValue() * 255)), group.entries().size() + 1, this.selectBlock == this.selectBlock.getBlock().defaultBlockState(), true)); 60 | 61 | if (BlockStore.getInstance().get().size() > 0) { 62 | BlockStore.getInstance().get().set(0, group); 63 | } else { 64 | BlockStore.getInstance().get().add(group); 65 | } 66 | BlockStore.getInstance().write(); 67 | BlockStore.getInstance().updateCache(); 68 | 69 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 70 | }).pos(this.getWidth() / 2 - 100, this.getHeight() / 2 + 85).size(128, 20).build()); 71 | this.addRenderableWidget(new Button.Builder(Component.translatable("xray.single.cancel"), b -> { 72 | this.onClose(); 73 | this.getMinecraft().setScreen(this.previousScreenCallback.get()); 74 | }).pos(this.getWidth() / 2 + 30,this.getHeight() / 2 + 85).size(72, 20).build()); 75 | 76 | this.addRenderableWidget(this.redSlider = new RatioSliderWidget(this.getWidth() / 2 - 100, this.getHeight() / 2 - 40, 100, 20, Component.translatable("xray.color.red"), 0)); 77 | this.addRenderableWidget(this.greenSlider = new RatioSliderWidget(this.getWidth() / 2 - 100, this.getHeight() / 2 - 18, 100, 20, Component.translatable("xray.color.green"), 0)); 78 | 79 | this.addRenderableWidget(this.blueSlider = new RatioSliderWidget(this.getWidth() / 2 - 100, this.getHeight() / 2 + 4, 100, 20, Component.translatable("xray.color.blue"), 0)); 80 | 81 | this.oreName = new EditBox(this.getMinecraft().font, this.getWidth() / 2 - 100, this.getHeight() / 2 - 70, 202, 20, Component.empty()); 82 | 83 | this.oreName.setValue(this.selectBlock.getBlock().getName().getString()); 84 | this.addRenderableWidget(this.oreName); 85 | this.addRenderableWidget(this.redSlider); 86 | this.addRenderableWidget(this.greenSlider); 87 | this.addRenderableWidget(this.blueSlider); 88 | this.addRenderableWidget(this.changeDefaultState); 89 | } 90 | 91 | @Override 92 | public void tick() { 93 | super.tick(); 94 | // this.oreName.tick(); 95 | } 96 | 97 | @Override 98 | public void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 99 | int color = (255 << 24) | ((int) (this.redSlider.getValue() * 255) << 16) | ((int) (this.greenSlider.getValue() * 255) << 8) | (int) (this.blueSlider.getValue() * 255); 100 | 101 | guiGraphics.fill(this.getWidth() / 2 + 2, this.getHeight() / 2 - 40, (this.getWidth() / 2 + 2) + 100, (this.getHeight() / 2 - 40) + 64, color); 102 | 103 | guiGraphics.drawString(this.font, this.selectBlock.getBlock().getName().getString(), this.getWidth() / 2 - 100, this.getHeight() / 2 - 90, 0xffffff); 104 | 105 | this.oreName.render(guiGraphics, x, y, partialTicks); 106 | 107 | guiGraphics.drawString(this.font, "Color", this.getWidth() / 2 + 10, this.getHeight() / 2 - 35, 0xffffff); 108 | 109 | // Lighting.setupFor3DItems(); 110 | guiGraphics.renderItem(this.itemStack, this.getWidth() / 2 + 85, this.getHeight() / 2 - 105); 111 | // Lighting.setupForFlatItems(); 112 | } 113 | 114 | @Override 115 | public boolean mouseClicked(double x, double y, int mouse) { 116 | if (this.oreName.mouseClicked(x, y, mouse)) { 117 | this.setFocused(this.oreName); 118 | } 119 | 120 | if (this.oreName.isFocused() && !this.oreNameCleared) { 121 | this.oreName.setValue(""); 122 | this.oreNameCleared = true; 123 | } 124 | 125 | if (!this.oreName.isFocused() && this.oreNameCleared && Objects.equals(this.oreName.getValue(), "")) { 126 | this.oreNameCleared = false; 127 | this.oreName.setValue(I18n.get("xray.input.gui")); 128 | } 129 | 130 | return super.mouseClicked(x, y, mouse); 131 | } 132 | 133 | @Override 134 | public boolean mouseReleased(double x, double y, int mouse) { 135 | return super.mouseReleased(x, y, mouse); 136 | } 137 | 138 | @Override 139 | public boolean hasTitle() { 140 | return true; 141 | } 142 | 143 | @Override 144 | public String title() { 145 | return I18n.get("xray.title.config"); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiBase.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.gui.Font; 6 | import net.minecraft.client.gui.GuiGraphics; 7 | import net.minecraft.client.gui.components.Renderable; 8 | import net.minecraft.client.gui.screens.Screen; 9 | import net.minecraft.client.renderer.RenderType; 10 | import net.minecraft.network.chat.Component; 11 | import net.minecraft.resources.ResourceLocation; 12 | import pro.mikey.fabric.xray.Utils; 13 | import pro.mikey.fabric.xray.XRay; 14 | 15 | public abstract class GuiBase extends Screen { 16 | static final ResourceLocation BG_LARGE = Utils.rlFull(XRay.PREFIX_GUI + "bg-help.png"); 17 | private static final ResourceLocation BG_NORMAL = Utils.rlFull(XRay.PREFIX_GUI + "bg.png"); 18 | private final boolean hasSide; 19 | private String sideTitle = ""; 20 | private int backgroundWidth = 229; 21 | private int backgroundHeight = 235; 22 | 23 | GuiBase(boolean hasSide) { 24 | super(Component.empty()); 25 | this.hasSide = hasSide; 26 | } 27 | 28 | abstract void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks); 29 | 30 | @Override 31 | public boolean charTyped(char keyTyped, int __unknown) { 32 | super.charTyped(keyTyped, __unknown); 33 | 34 | if (keyTyped == 1 && this.getMinecraft().player != null) { 35 | this.getMinecraft().player.clientSideCloseContainer(); 36 | } 37 | 38 | return false; 39 | } 40 | 41 | @Override 42 | public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 43 | super.render(guiGraphics, x, y, partialTicks); 44 | this.renderExtra(guiGraphics, x, y, partialTicks); 45 | 46 | this.renderBackground(guiGraphics, x, y, partialTicks); 47 | int width = this.width; 48 | int height = this.height; 49 | if (this.hasSide) { 50 | guiGraphics.blit(RenderType::guiTextured, this.getBackground(), width / 2 + 60, height / 2 - 180 / 2, 0, 0, 150, 180, 150, 180); 51 | guiGraphics.blit( 52 | RenderType::guiTextured, 53 | this.getBackground(), 54 | width / 2 - 150, 55 | height / 2 - 118, 56 | 0, 57 | 0, 58 | this.backgroundWidth, 59 | this.backgroundHeight, 60 | this.backgroundWidth, 61 | this.backgroundHeight 62 | ); 63 | } 64 | 65 | if (!this.hasSide) { 66 | guiGraphics.blit( 67 | RenderType::guiTextured, 68 | this.getBackground(), 69 | width / 2 - this.backgroundWidth / 2 + 1, 70 | height / 2 - this.backgroundHeight / 2, 71 | 0, 72 | 0, 73 | this.backgroundWidth, 74 | this.backgroundHeight, 75 | this.backgroundWidth, 76 | this.backgroundHeight 77 | ); 78 | } 79 | 80 | PoseStack pose = guiGraphics.pose(); 81 | pose.pushPose(); 82 | for (Renderable renderable : this.renderables) { 83 | renderable.render(guiGraphics, x, y, partialTicks); 84 | } 85 | pose.popPose(); 86 | 87 | this.renderExtra(guiGraphics, x, y, partialTicks); 88 | 89 | if (this.hasTitle()) { 90 | if (this.hasSide) { 91 | guiGraphics.drawString( 92 | this.font, this.title(), width / 2 - 138, height / 2 - 105, 0xffff00); 93 | } else { 94 | guiGraphics.drawString( 95 | this.font, 96 | this.title(), 97 | width / 2 - ( this.backgroundWidth / 2) + 14, 98 | height / 2 - ( this.backgroundHeight / 2) + 13, 99 | 0xffff00 100 | ); 101 | } 102 | } 103 | 104 | if (this.hasSide && this.hasSideTitle()) { 105 | guiGraphics.drawString(this.font, this.sideTitle, width / 2 + 80, height / 2 - 77, 0xffff00); 106 | } 107 | } 108 | 109 | public ResourceLocation getBackground() { 110 | return BG_NORMAL; 111 | } 112 | 113 | public boolean hasTitle() { 114 | return false; 115 | } 116 | 117 | public String title() { 118 | return ""; 119 | } 120 | 121 | private boolean hasSideTitle() { 122 | return !this.sideTitle.isEmpty(); 123 | } 124 | 125 | void setSideTitle(String title) { 126 | this.sideTitle = title; 127 | } 128 | 129 | void setSize(int width, int height) { 130 | this.backgroundWidth = width; 131 | this.backgroundHeight = height; 132 | } 133 | 134 | Font getFontRender() { 135 | return this.getMinecraft().font; 136 | } 137 | 138 | int getWidth() { 139 | return this.width; 140 | } 141 | 142 | int getHeight() { 143 | return this.height; 144 | } 145 | 146 | @Override 147 | public boolean isPauseScreen() { 148 | return false; 149 | } 150 | 151 | public Minecraft getMinecraft() { 152 | return this.minecraft; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiBlockList.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import net.minecraft.client.gui.Font; 5 | import net.minecraft.client.gui.GuiGraphics; 6 | import net.minecraft.client.gui.components.AbstractSelectionList; 7 | import net.minecraft.client.gui.components.Button; 8 | import net.minecraft.client.gui.components.EditBox; 9 | import net.minecraft.core.registries.BuiltInRegistries; 10 | import net.minecraft.network.chat.Component; 11 | import net.minecraft.resources.ResourceLocation; 12 | import net.minecraft.world.item.BlockItem; 13 | import net.minecraft.world.item.ItemStack; 14 | import net.minecraft.world.item.Items; 15 | import net.minecraft.world.level.block.Block; 16 | import pro.mikey.fabric.xray.records.BasicColor; 17 | import pro.mikey.fabric.xray.records.BlockWithStack; 18 | 19 | import java.awt.*; 20 | import java.util.List; 21 | import java.util.stream.Collectors; 22 | 23 | public class GuiBlockList extends GuiBase { 24 | private final List blocks; 25 | private ScrollingBlockList blockList; 26 | private EditBox search; 27 | private String lastSearched = ""; 28 | 29 | GuiBlockList() { 30 | super(false); 31 | this.blocks = BuiltInRegistries.ITEM.stream().filter(item -> item instanceof BlockItem && item != Items.AIR).map(item -> new BlockWithStack(Block.byItem(item), new ItemStack(item))).toList(); 32 | } 33 | 34 | @Override 35 | public void init() { 36 | this.blockList = new ScrollingBlockList((this.getWidth() / 2) + 1, this.getHeight() / 2 - 12, 202, 185, this.blocks); 37 | this.addRenderableWidget(this.blockList); 38 | 39 | this.search = new EditBox(this.getFontRender(), this.getWidth() / 2 - 100, this.getHeight() / 2 + 85, 140, 18, Component.empty()); 40 | this.search.setFocused(true); 41 | this.setFocused(this.search); 42 | 43 | this.addRenderableWidget(this.search); 44 | this.addRenderableWidget(this.blockList); 45 | 46 | this.addRenderableWidget(new Button.Builder(Component.translatable("xray.single.cancel"), b -> { 47 | assert this.getMinecraft() != null; 48 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 49 | }).pos(this.getWidth() / 2 + 43, this.getHeight() / 2 + 84).size(60, 20).build()); 50 | } 51 | 52 | @Override 53 | public void tick() { 54 | // this.search.tick 55 | if (!this.search.getValue().equals(this.lastSearched)) { 56 | this.reloadBlocks(); 57 | } 58 | 59 | super.tick(); 60 | } 61 | 62 | private void reloadBlocks() { 63 | if (this.lastSearched.equals(this.search.getValue())) { 64 | return; 65 | } 66 | 67 | this.blockList.updateEntries(this.search.getValue().isEmpty() ? this.blocks : this.blocks.stream().filter(e -> e.stack().getHoverName().getString().toLowerCase().contains(this.search.getValue().toLowerCase())).collect(Collectors.toList())); 68 | 69 | this.lastSearched = this.search.getValue(); 70 | this.blockList.setScrollAmount(0); 71 | } 72 | 73 | @Override 74 | public void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 75 | // this.search.render(guiGraphics, x, y, partialTicks); 76 | // this.blockList.render(guiGraphics, x, y, partialTicks); 77 | } 78 | 79 | @Override 80 | public boolean mouseClicked(double x, double y, int button) { 81 | if (this.search.mouseClicked(x, y, button)) { 82 | this.setFocused(this.search); 83 | } 84 | 85 | return super.mouseClicked(x, y, button); 86 | } 87 | 88 | // @Override 89 | // public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double p_mouseScrolled_5_) { 90 | // this.blockList.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, p_mouseScrolled_5_); 91 | // return super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, p_mouseScrolled_5_); 92 | // } 93 | 94 | static class ScrollingBlockList extends ScrollingList { 95 | static final int SLOT_HEIGHT = 35; 96 | 97 | ScrollingBlockList(int x, int y, int width, int height, List blocks) { 98 | super(x, y, width, height, SLOT_HEIGHT); 99 | this.updateEntries(blocks); 100 | } 101 | 102 | @Override 103 | public void setSelected(BlockSlot entry) { 104 | if (entry == null) { 105 | return; 106 | } 107 | 108 | assert this.minecraft.player != null; 109 | this.minecraft.setScreen(new GuiAddBlock(entry.getBlock().block().defaultBlockState(), GuiBlockList::new)); 110 | } 111 | 112 | void updateEntries(List blocks) { 113 | this.clearEntries(); 114 | blocks.forEach(block -> this.addEntry(new BlockSlot(block, this))); 115 | } 116 | 117 | public static class BlockSlot extends AbstractSelectionList.Entry { 118 | BlockWithStack block; 119 | ScrollingBlockList parent; 120 | 121 | BlockSlot(BlockWithStack block, ScrollingBlockList parent) { 122 | this.block = block; 123 | this.parent = parent; 124 | } 125 | 126 | BlockWithStack getBlock() { 127 | return this.block; 128 | } 129 | 130 | @Override 131 | public void render(GuiGraphics graphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) { 132 | Font font = this.parent.minecraft.font; 133 | 134 | ResourceLocation resource = BuiltInRegistries.BLOCK.getKey(this.block.block()); 135 | graphics.drawString(font, this.block.stack().getItem().getName().getString(), left + 35, top + 7, Color.WHITE.getRGB()); 136 | graphics.drawString(font, resource.getNamespace(), left + 35, top + 17, Color.WHITE.getRGB()); 137 | 138 | graphics.renderItem(this.block.stack(), left + 10, top + 7); 139 | } 140 | 141 | @Override 142 | public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) { 143 | this.parent.setSelected(this); 144 | return false; 145 | } 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiEdit.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.platform.Lighting; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.gui.GuiGraphics; 6 | import net.minecraft.client.gui.components.Button; 7 | import net.minecraft.client.gui.components.EditBox; 8 | import net.minecraft.client.resources.language.I18n; 9 | import net.minecraft.network.chat.Component; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | import pro.mikey.fabric.xray.records.BasicColor; 12 | import pro.mikey.fabric.xray.records.BlockEntry; 13 | import pro.mikey.fabric.xray.storage.BlockStore; 14 | 15 | public class GuiEdit extends GuiBase { 16 | private final BlockEntry block; 17 | private EditBox oreName; 18 | private RatioSliderWidget redSlider; 19 | private RatioSliderWidget greenSlider; 20 | private RatioSliderWidget blueSlider; 21 | private Button changeDefaultState; 22 | private BlockState lastState; 23 | 24 | GuiEdit(BlockEntry block) { 25 | super(true); // Has a sidebar 26 | this.setSideTitle(I18n.get("xray.single.tools")); 27 | 28 | this.block = block; 29 | } 30 | 31 | @Override 32 | public void init() { 33 | this.addRenderableWidget(this.changeDefaultState = new Button.Builder( Component.literal(this.block.isDefault() ? "Already scanning for all states" : "Scan for all block states"), button -> { 34 | this.lastState = this.block.getState(); 35 | this.block.setState(this.block.getState().getBlock().defaultBlockState()); 36 | button.active = false; 37 | }).pos(this.getWidth() / 2 - 138, this.getHeight() / 2 + 60).size(202, 20).build()); 38 | 39 | if (this.block.isDefault()) { 40 | this.changeDefaultState.active = false; 41 | } 42 | 43 | this.addRenderableWidget(new Button.Builder(Component.translatable("xray.single.delete"), b -> { 44 | try { 45 | BlockStore.getInstance().get().get(0).entries().remove(this.block); 46 | BlockStore.getInstance().write(); 47 | BlockStore.getInstance().updateCache(); 48 | } catch (Exception e) { 49 | } 50 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 51 | }).pos((this.getWidth() / 2) + 78, this.getHeight() / 2 - 60).size(120, 20).build()); 52 | 53 | this.addRenderableWidget(new Button.Builder( Component.translatable("xray.single.cancel"), b -> { 54 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 55 | }).pos((this.getWidth() / 2) + 78, this.getHeight() / 2 + 58).size(120, 20).build()); 56 | this.addRenderableWidget(new Button.Builder(Component.translatable("xray.single.save"), b -> { 57 | try { 58 | int index = BlockStore.getInstance().get().get(0).entries().indexOf(this.block); 59 | BlockEntry entry = BlockStore.getInstance().get().get(0).entries().get(index); 60 | entry.setName(this.oreName.getValue()); 61 | entry.setColor(new BasicColor((int) (this.redSlider.getValue() * 255), (int) (this.greenSlider.getValue() * 255), (int) (this.blueSlider.getValue() * 255))); 62 | entry.setState(this.block.getState()); 63 | entry.setDefault(this.lastState != null); 64 | BlockStore.getInstance().get().get(0).entries().set(index, entry); 65 | BlockStore.getInstance().write(); 66 | BlockStore.getInstance().updateCache(); 67 | } catch (Exception ignored) { 68 | } // lazy catching for basic failures 69 | 70 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 71 | }).pos(this.getWidth() / 2 - 138, this.getHeight() / 2 + 83).size(202, 20).build()); 72 | 73 | this.addRenderableWidget(this.redSlider = new RatioSliderWidget(this.getWidth() / 2 - 138, this.getHeight() / 2 - 40, 100, 20, Component.translatable("xray.color.red"), 0)); 74 | this.addRenderableWidget(this.greenSlider = new RatioSliderWidget(this.getWidth() / 2 - 138, this.getHeight() / 2 - 18, 100, 20, Component.translatable("xray.color.green"), 0)); 75 | this.addRenderableWidget(this.blueSlider = new RatioSliderWidget(this.getWidth() / 2 - 138, this.getHeight() / 2 + 4, 100, 20, Component.translatable("xray.color.blue"), 0)); 76 | 77 | this.oreName = new EditBox(this.getMinecraft().font, this.getWidth() / 2 - 138, this.getHeight() / 2 - 63, 202, 20, Component.empty()); 78 | this.oreName.setValue(this.block.getName()); 79 | this.addRenderableWidget(this.oreName); 80 | this.addRenderableWidget(this.redSlider); 81 | this.addRenderableWidget(this.greenSlider); 82 | this.addRenderableWidget(this.blueSlider); 83 | 84 | this.redSlider.setValue(this.block.getHex().red() / 255f); 85 | this.greenSlider.setValue(this.block.getHex().green() / 255f); 86 | this.blueSlider.setValue(this.block.getHex().blue() / 255f); 87 | } 88 | 89 | @Override 90 | public void tick() { 91 | super.tick(); 92 | // this.oreName.tick(); 93 | } 94 | 95 | @Override 96 | public void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 97 | guiGraphics.drawString(this.font, this.block.getName(), this.getWidth() / 2 - 138, this.getHeight() / 2 - 90, 0xffffff); 98 | 99 | this.oreName.render(guiGraphics, x, y, partialTicks); 100 | 101 | int color = (255 << 24) | ((int) (this.redSlider.getValue() * 255) << 16) | ((int) (this.greenSlider.getValue() * 255) << 8) | (int) (this.blueSlider.getValue() * 255); 102 | 103 | guiGraphics.fill(this.getWidth() / 2 - 35, this.getHeight() / 2 - 40, (this.getWidth() / 2 - 35) + 100, (this.getHeight() / 2 - 40) + 64, color); 104 | 105 | guiGraphics.drawString(this.font, "Color", this.getWidth() / 2 - 30, this.getHeight() / 2 - 35, 0xffffff); 106 | // Lighting.setupFor3DItems(); 107 | // TODO: Check 108 | guiGraphics.renderItem(this.block.getStack(), this.getWidth() / 2 + 50, this.getHeight() / 2 - 105); 109 | // Lighting.setupForFlatItems(); 110 | } 111 | 112 | @Override 113 | public boolean mouseClicked(double x, double y, int mouse) { 114 | if (this.oreName.mouseClicked(x, y, mouse)) { 115 | this.setFocused(this.oreName); 116 | } 117 | 118 | return super.mouseClicked(x, y, mouse); 119 | } 120 | 121 | @Override 122 | public boolean mouseReleased(double x, double y, int mouse) { 123 | return super.mouseReleased(x, y, mouse); 124 | } 125 | 126 | @Override 127 | public boolean hasTitle() { 128 | return true; 129 | } 130 | 131 | @Override 132 | public String title() { 133 | return I18n.get("xray.title.edit"); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiHelp.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import net.minecraft.client.gui.GuiGraphics; 4 | import net.minecraft.client.gui.components.Button; 5 | import net.minecraft.client.resources.language.I18n; 6 | import net.minecraft.network.chat.Component; 7 | import net.minecraft.resources.ResourceLocation; 8 | 9 | import java.awt.*; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class GuiHelp extends GuiBase { 14 | private final List areas = new ArrayList<>(); 15 | 16 | public GuiHelp() { 17 | super(false); 18 | this.setSize(380, 210); 19 | } 20 | 21 | @Override 22 | public void init() { 23 | super.init(); 24 | 25 | this.areas.clear(); 26 | this.areas.add(new LinedText("xray.message.help.gui")); 27 | this.areas.add(new LinedText("xray.message.help.warning")); 28 | 29 | this.addRenderableWidget( 30 | new Button.Builder( 31 | Component.translatable("xray.single.close"), 32 | b -> { 33 | this.getMinecraft().setScreen(new GuiSelectionScreen()); 34 | }).pos((this.getWidth() / 2) - 100, 35 | (this.getHeight() / 2) + 80).size(200, 36 | 20).build()); 37 | } 38 | 39 | @Override 40 | public void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 41 | int lineY = (this.getHeight() / 2) - 85; 42 | for (LinedText linedText : this.areas) { 43 | for (String line : linedText.getLines()) { 44 | lineY += 12; 45 | guiGraphics.drawString(this.font, line, (this.getWidth() / 2) - 176, lineY, Color.WHITE.getRGB()); 46 | } 47 | lineY += 10; 48 | } 49 | } 50 | 51 | @Override 52 | public boolean hasTitle() { 53 | return true; 54 | } 55 | 56 | @Override 57 | public ResourceLocation getBackground() { 58 | return BG_LARGE; 59 | } 60 | 61 | @Override 62 | public String title() { 63 | return I18n.get("xray.single.help"); 64 | } 65 | 66 | private static class LinedText { 67 | private final String[] lines; 68 | 69 | LinedText(String key) { 70 | this.lines = I18n.get(key).split("\\R"); 71 | } 72 | 73 | String[] getLines() { 74 | return this.lines; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiOverlay.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.systems.GpuDevice; 4 | import com.mojang.blaze3d.systems.RenderSystem; 5 | import net.minecraft.client.DeltaTracker; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.GuiGraphics; 8 | import net.minecraft.client.renderer.RenderType; 9 | import net.minecraft.client.resources.language.I18n; 10 | import net.minecraft.resources.ResourceLocation; 11 | import pro.mikey.fabric.xray.Utils; 12 | import pro.mikey.fabric.xray.XRay; 13 | import pro.mikey.fabric.xray.storage.SettingsStore; 14 | 15 | public class GuiOverlay { 16 | private static final ResourceLocation circle = Utils.rlFull(XRay.PREFIX_GUI + "circle.png"); 17 | 18 | public static void RenderGameOverlayEvent(GuiGraphics guiGraphics, DeltaTracker counter) { 19 | // Draw Indicator 20 | if (!SettingsStore.getInstance().get().isActive() || !SettingsStore.getInstance().get().showOverlay()) { 21 | return; 22 | } 23 | 24 | GpuDevice gpuDevice = RenderSystem.tryGetDevice(); 25 | boolean renderDebug = gpuDevice != null && gpuDevice.isDebuggingEnabled(); 26 | 27 | int x = 5, y = 5; 28 | if (renderDebug) { 29 | x = Minecraft.getInstance().getWindow().getGuiScaledWidth() - 10; 30 | y = Minecraft.getInstance().getWindow().getGuiScaledHeight() - 10; 31 | } 32 | 33 | guiGraphics.blit(RenderType::guiTextured, circle, x, y, 0f, 0f, 5, 5, 5, 5, 0xFF00FF00); 34 | 35 | int width = Minecraft.getInstance().font.width(I18n.get("xray.overlay")); 36 | guiGraphics.drawString(Minecraft.getInstance().font, I18n.get("xray.overlay"), x + (!renderDebug ? 10 : -width - 5), y - (!renderDebug ? 1 : 2), 0xff00ff00); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/GuiSelectionScreen.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import com.mojang.blaze3d.platform.Lighting; 4 | import com.mojang.blaze3d.vertex.PoseStack; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.Font; 7 | import net.minecraft.client.gui.GuiGraphics; 8 | import net.minecraft.client.gui.components.AbstractSelectionList; 9 | import net.minecraft.client.gui.components.Button; 10 | import net.minecraft.client.gui.components.EditBox; 11 | import net.minecraft.client.gui.components.Tooltip; 12 | import net.minecraft.client.gui.components.events.GuiEventListener; 13 | import net.minecraft.client.player.LocalPlayer; 14 | import net.minecraft.client.renderer.RenderType; 15 | import net.minecraft.client.renderer.entity.ItemRenderer; 16 | import net.minecraft.client.resources.language.I18n; 17 | import net.minecraft.network.chat.Component; 18 | import net.minecraft.resources.ResourceLocation; 19 | import net.minecraft.world.InteractionHand; 20 | import net.minecraft.world.item.BlockItem; 21 | import net.minecraft.world.item.ItemStack; 22 | import net.minecraft.world.level.block.Block; 23 | import net.minecraft.world.level.block.Blocks; 24 | import net.minecraft.world.level.block.state.BlockState; 25 | import net.minecraft.world.phys.BlockHitResult; 26 | import net.minecraft.world.phys.HitResult; 27 | import pro.mikey.fabric.xray.ScanController; 28 | import pro.mikey.fabric.xray.StateSettings; 29 | import pro.mikey.fabric.xray.Utils; 30 | import pro.mikey.fabric.xray.XRay; 31 | import pro.mikey.fabric.xray.records.BasicColor; 32 | import pro.mikey.fabric.xray.records.BlockEntry; 33 | import pro.mikey.fabric.xray.records.BlockGroup; 34 | import pro.mikey.fabric.xray.storage.BlockStore; 35 | import pro.mikey.fabric.xray.storage.SettingsStore; 36 | 37 | import java.awt.*; 38 | import java.util.List; 39 | import java.util.*; 40 | import java.util.concurrent.atomic.AtomicInteger; 41 | import java.util.stream.Collectors; 42 | 43 | public class GuiSelectionScreen extends GuiBase { 44 | private static final List ORE_TAGS = List.of(Blocks.GOLD_ORE, Blocks.IRON_ORE, Blocks.DIAMOND_ORE, Blocks.REDSTONE_ORE, Blocks.LAPIS_ORE, Blocks.COAL_ORE, Blocks.EMERALD_ORE, Blocks.COPPER_ORE, Blocks.DEEPSLATE_GOLD_ORE, Blocks.DEEPSLATE_IRON_ORE, Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.DEEPSLATE_REDSTONE_ORE, Blocks.DEEPSLATE_LAPIS_ORE, Blocks.DEEPSLATE_COAL_ORE, Blocks.DEEPSLATE_EMERALD_ORE, Blocks.DEEPSLATE_COPPER_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ANCIENT_DEBRIS); 45 | 46 | private static final ResourceLocation CIRCLE = Utils.rlFull(XRay.PREFIX_GUI + "circle.png"); 47 | private final List originalList; 48 | public ItemRenderer render; 49 | private Button distButtons; 50 | private EditBox search; 51 | private String lastSearch = ""; 52 | private List itemList; 53 | private ScrollingBlockList scrollList; 54 | 55 | public GuiSelectionScreen() { 56 | super(true); 57 | this.setSideTitle(I18n.get("xray.single.tools")); 58 | 59 | populateDefault(); 60 | 61 | this.itemList = BlockStore.getInstance().get().size() >= 1 ? BlockStore.getInstance().get().get(0).entries() : new ArrayList<>(); 62 | this.itemList.sort(Comparator.comparingInt(BlockEntry::getOrder)); 63 | 64 | this.originalList = this.itemList; 65 | } 66 | 67 | private void populateDefault() { 68 | if (BlockStore.getInstance().justCreated && BlockStore.getInstance().get().size() == 0) { 69 | AtomicInteger order = new AtomicInteger(); 70 | Random random = new Random(); 71 | 72 | BlockStore.getInstance().get().add(new BlockGroup("default", ORE_TAGS.stream().map(e -> 73 | new BlockEntry(e.defaultBlockState(), e.asItem().getName().getString(), new BasicColor(random.nextInt(255), random.nextInt(255), random.nextInt(255)), order.getAndIncrement(), true, true)).collect(Collectors.toList()), 0, true) 74 | ); 75 | 76 | BlockStore.getInstance().updateCache(); 77 | } 78 | } 79 | 80 | @Override 81 | public void init() { 82 | if (this.minecraft.player == null) { 83 | return; 84 | } 85 | 86 | this.render = Minecraft.getInstance().getItemRenderer(); 87 | // this.buttons.clear(); 88 | 89 | this.search = new EditBox(this.getFontRender(), this.getWidth() / 2 - 137, this.getHeight() / 2 - 105, 202, 18, Component.empty()); 90 | this.search.setCanLoseFocus(true); 91 | 92 | this.addRenderableWidget(this.search); 93 | 94 | // sidebar buttons 95 | this.addRenderableWidget(Button.builder( Component.translatable("xray.input.add"), button -> { 96 | this.minecraft.setScreen(new GuiBlockList()); 97 | }) 98 | .pos((this.getWidth() / 2) + 79, this.getHeight() / 2 - 60) 99 | .size( 120, 20) 100 | .tooltip(Tooltip.create(Component.translatable("xray.tooltips.add_block"))) 101 | .build()); 102 | 103 | this.addRenderableWidget(Button.builder(Component.translatable("xray.input.add_hand"), button -> { 104 | ItemStack handItem = this.minecraft.player.getItemInHand(InteractionHand.MAIN_HAND); 105 | 106 | // Check if the hand item is a block or not 107 | if (!(handItem.getItem() instanceof BlockItem)) { 108 | this.minecraft.player.displayClientMessage(Component.literal("[XRay] " + I18n.get("xray.message.invalid_hand", handItem.getHoverName().getString())), false); 109 | return; 110 | } 111 | 112 | this.minecraft.setScreen(new GuiAddBlock(((BlockItem) handItem.getItem()).getBlock().defaultBlockState(), GuiSelectionScreen::new)); 113 | }) 114 | .pos(this.getWidth() / 2 + 79, this.getHeight() / 2 - 38) 115 | .size( 120, 20) 116 | .tooltip(Tooltip.create(Component.translatable("xray.tooltips.add_block_in_hand"))) 117 | .build()); 118 | 119 | this.addRenderableWidget(Button.builder(Component.translatable("xray.input.add_look"), button -> { 120 | LocalPlayer player = this.minecraft.player; 121 | if (this.minecraft.level == null || player == null) { 122 | return; 123 | } 124 | 125 | this.onClose(); 126 | try { 127 | HitResult look = player.pick(100, 1f, false); 128 | 129 | if (look.getType() == BlockHitResult.Type.BLOCK) { 130 | BlockState state = this.minecraft.level.getBlockState(((BlockHitResult) look).getBlockPos()); 131 | 132 | this.minecraft.setScreen(new GuiAddBlock(state, GuiSelectionScreen::new)); 133 | } else { 134 | player.displayClientMessage(Component.literal("[XRay] " + I18n.get("xray.message.nothing_infront")), false); 135 | } 136 | } catch (NullPointerException ex) { 137 | player.displayClientMessage(Component.literal("[XRay] " + I18n.get("xray.message.thats_odd")), false); 138 | } 139 | }) 140 | .pos(this.getWidth() / 2 + 79, this.getHeight() / 2 - 16) 141 | .size(120, 20) 142 | .tooltip(Tooltip.create(Component.translatable("xray.tooltips.add_block_looking_at"))) 143 | .build()); 144 | 145 | this.addRenderableWidget(this.distButtons = Button.builder(Component.translatable("xray.input.show-lava", SettingsStore.getInstance().get().isShowLava()), button -> { 146 | SettingsStore.getInstance().get().setShowLava(!SettingsStore.getInstance().get().isShowLava()); 147 | ScanController.runTask(true); 148 | button.setMessage(Component.translatable("xray.input.show-lava", SettingsStore.getInstance().get().isShowLava())); 149 | }) 150 | .pos((this.getWidth() / 2) + 79, this.getHeight() / 2 + 6) 151 | .size(120, 20) 152 | .tooltip(Tooltip.create(Component.translatable("xray.tooltips.show_lava"))) 153 | .build()); 154 | 155 | this.addRenderableWidget(this.distButtons = Button.builder(Component.translatable("xray.input.distance", StateSettings.getVisualRadius()), button -> { 156 | SettingsStore.getInstance().get().increaseRange(); 157 | button.setMessage(Component.translatable("xray.input.distance", StateSettings.getVisualRadius())); 158 | }) 159 | .pos((this.getWidth() / 2) + 79, this.getHeight() / 2 + 36) 160 | .size(120, 20) 161 | .tooltip(Tooltip.create(Component.translatable("xray.tooltips.distance"))) 162 | .build()); 163 | 164 | this.addRenderableWidget(new Button.Builder( Component.translatable("xray.single.help"), button -> { 165 | this.minecraft.setScreen(new GuiHelp()); 166 | }).pos(this.getWidth() / 2 + 79, this.getHeight() / 2 + 58).size(60,20).build()); 167 | this.addRenderableWidget(new Button.Builder(Component.translatable("xray.single.close"), button -> this.onClose()).pos((this.getWidth() / 2 + 79) + 62, this.getHeight() / 2 + 58).size(59,20).build()); 168 | 169 | this.scrollList = new ScrollingBlockList((this.getWidth() / 2) - 37, this.getHeight() / 2 + 10, 203, 185, this.itemList, this); 170 | this.addRenderableWidget(this.scrollList); 171 | } 172 | 173 | private void updateSearch() { 174 | if (this.lastSearch.equals(this.search.getValue())) { 175 | return; 176 | } 177 | 178 | if (this.search.getValue().equals("")) { 179 | this.itemList = this.originalList; 180 | this.scrollList.updateEntries(this.itemList); 181 | this.lastSearch = ""; 182 | return; 183 | } 184 | 185 | this.itemList = this.originalList.stream().filter(b -> b.getName().toLowerCase().contains(this.search.getValue().toLowerCase())).collect(Collectors.toCollection(ArrayList::new)); 186 | 187 | this.itemList.sort(Comparator.comparingInt(BlockEntry::getOrder)); 188 | 189 | this.scrollList.updateEntries(this.itemList); 190 | this.lastSearch = this.search.getValue(); 191 | } 192 | 193 | @Override 194 | public void tick() { 195 | super.tick(); 196 | this.updateSearch(); 197 | } 198 | 199 | @Override 200 | public boolean mouseClicked(double x, double y, int mouse) { 201 | if (this.search.mouseClicked(x, y, mouse)) { 202 | this.setFocused(this.search); 203 | } 204 | 205 | if (mouse == 1 && this.distButtons.isMouseOver(x, y)) { 206 | SettingsStore.getInstance().get().decreaseRange(); 207 | 208 | this.distButtons.setMessage(Component.translatable("xray.input.distance", StateSettings.getVisualRadius())); 209 | this.distButtons.playDownSound(this.minecraft.getSoundManager()); 210 | } 211 | 212 | return super.mouseClicked(x, y, mouse); 213 | } 214 | 215 | @Override 216 | public void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks) { 217 | if (!this.search.isFocused() && this.search.getValue().equals("")) { 218 | guiGraphics.drawString(this.font, I18n.get("xray.single.search"), this.getWidth() / 2 - 130, this.getHeight() / 2 - 101, Color.GRAY.getRGB()); 219 | } 220 | 221 | PoseStack pose = guiGraphics.pose(); 222 | pose.pushPose(); 223 | pose.translate(this.getWidth() / 2f - 140, ((this.getHeight() / 2f) - 3) + 120, 0); 224 | pose.scale(0.75f, 0.75f, 0.75f); 225 | guiGraphics.drawString(this.font, Component.translatable("xray.tooltips.edit1"), 0, 0, Color.GRAY.getRGB()); 226 | pose.translate(0, 12, 0); 227 | guiGraphics.drawString(this.font, Component.translatable("xray.tooltips.edit2"), 0, 0, Color.GRAY.getRGB()); 228 | pose.popPose(); 229 | } 230 | 231 | @Override 232 | public void onClose() { 233 | SettingsStore.getInstance().write(); 234 | BlockStore.getInstance().write(); 235 | BlockStore.getInstance().updateCache(); 236 | 237 | ScanController.runTask(true); 238 | 239 | super.onClose(); 240 | } 241 | 242 | public static class ScrollingBlockList extends ScrollingList { 243 | static final int SLOT_HEIGHT = 35; 244 | GuiSelectionScreen parent; 245 | 246 | ScrollingBlockList(int x, int y, int width, int height, List blocks, GuiSelectionScreen parent) { 247 | super(x, y, width, height, SLOT_HEIGHT); 248 | this.updateEntries(blocks); 249 | this.parent = parent; 250 | } 251 | 252 | void setSelected(BlockSlot entry, int mouse) { 253 | if (entry == null) { 254 | return; 255 | } 256 | 257 | if (GuiSelectionScreen.hasShiftDown()) { 258 | this.minecraft.setScreen(new GuiEdit(entry.block)); 259 | return; 260 | } 261 | 262 | try { 263 | int index = BlockStore.getInstance().get().get(0).entries().indexOf(entry.getBlock()); 264 | BlockEntry blockEntry = BlockStore.getInstance().get().get(0).entries().get(index); 265 | blockEntry.setActive(!blockEntry.isActive()); 266 | BlockStore.getInstance().get().get(0).entries().set(index, blockEntry); 267 | BlockStore.getInstance().write(); 268 | BlockStore.getInstance().updateCache(); 269 | } catch (Exception ignored) { 270 | } 271 | } 272 | 273 | void updateEntries(List blocks) { 274 | this.clearEntries(); 275 | blocks.forEach(block -> this.addEntry(new BlockSlot(block, this))); // @mcp: func_230513_b_ = addEntry 276 | } 277 | 278 | 279 | public class BlockSlot extends AbstractSelectionList.Entry { 280 | BlockEntry block; 281 | ScrollingBlockList parent; 282 | 283 | BlockSlot(BlockEntry block, ScrollingBlockList parent) { 284 | this.block = block; 285 | this.parent = parent; 286 | } 287 | 288 | public BlockEntry getBlock() { 289 | return this.block; 290 | } 291 | 292 | @Override 293 | public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) { 294 | BlockEntry blockData = this.block; 295 | 296 | Font font = this.parent.minecraft.font; 297 | 298 | guiGraphics.drawString(font, blockData.getName(), left + 35, top + 7, 0xFFFFFF); 299 | guiGraphics.drawString(font, blockData.isActive() ? "Enabled" : "Disabled", left + 35, top + 17, blockData.isActive() ? Color.GREEN.getRGB() : Color.RED.getRGB()); 300 | 301 | guiGraphics.renderItem(blockData.getStack(), left + 10, top + 7); 302 | 303 | guiGraphics.blit(RenderType::guiTextured, GuiSelectionScreen.CIRCLE, (left + entryWidth) - 17, (int) (top + (entryHeight / 2f) - 9), 0, 0, 14, 14, 14, 14, BasicColor.rgbaToInt(0, 0, 0, .5f)); 304 | guiGraphics.blit(RenderType::guiTextured, GuiSelectionScreen.CIRCLE, (left + entryWidth) - 15, (int) (top + (entryHeight / 2f) - 7), 0, 0, 10, 10, 10, 10, blockData.getHex().toInt()); 305 | } 306 | 307 | @Override 308 | public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int mouse) { 309 | this.parent.setSelected(this, mouse); 310 | return false; 311 | } 312 | } 313 | } 314 | } 315 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/RatioSliderWidget.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import net.minecraft.client.gui.components.AbstractSliderButton; 4 | import net.minecraft.network.chat.Component; 5 | 6 | public class RatioSliderWidget extends AbstractSliderButton { 7 | private final Component message; 8 | 9 | RatioSliderWidget(int x, int y, int width, int height, Component text, double value) { 10 | super(x, y, width, height, text, value); 11 | this.message = text; 12 | this.updateMessage(); 13 | } 14 | 15 | @Override 16 | protected void applyValue() {} 17 | 18 | @Override 19 | protected void updateMessage() { 20 | this.setMessage(Component.literal(this.message.getString() + ((int) (this.value * 255)))); 21 | } 22 | 23 | double getValue() { 24 | return this.value; 25 | } 26 | 27 | void setValue(double value) { 28 | this.value = Math.max(0, Math.min(1, value)); 29 | this.updateMessage(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/screens/forge/ScrollingList.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.screens.forge; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiGraphics; 5 | import net.minecraft.client.gui.components.AbstractSelectionList; 6 | import net.minecraft.client.gui.narration.NarrationElementOutput; 7 | 8 | public class ScrollingList> extends AbstractSelectionList { 9 | ScrollingList(int x, int y, int width, int height, int slotHeightIn) { 10 | super( 11 | Minecraft.getInstance(), 12 | width, 13 | height, 14 | y - (height / 2), 15 | slotHeightIn); 16 | this.setX(x - (width / 2)); 17 | } 18 | 19 | @Override 20 | public void renderWidget(GuiGraphics stack, int mouseX, int mouseY, float partialTicks) { 21 | super.renderWidget(stack, mouseX, mouseY, partialTicks); 22 | } 23 | 24 | @Override 25 | protected int scrollBarX() { 26 | return (this.getX() + this.width) - 6; 27 | } 28 | 29 | @Override 30 | protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) { 31 | 32 | } 33 | 34 | @Override 35 | public int getRowWidth() { 36 | return this.width - 10; 37 | } 38 | 39 | @Override 40 | public int getRowLeft() { 41 | return this.getX(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/storage/BlockStore.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.storage; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.reflect.TypeToken; 6 | import pro.mikey.fabric.xray.cache.BlockSearchCache; 7 | import pro.mikey.fabric.xray.records.BlockEntry; 8 | import pro.mikey.fabric.xray.records.BlockGroup; 9 | 10 | import java.lang.reflect.Type; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class BlockStore extends Store> { 15 | private static BlockStore instance; 16 | private final BlockSearchCache cache = new BlockSearchCache(); 17 | private final List blockEntries; 18 | 19 | private BlockStore() { 20 | super("blocks"); 21 | 22 | this.blockEntries = this.read(); 23 | this.updateCache(this.blockEntries); // ensure the cache is up to date 24 | } 25 | 26 | public static BlockStore getInstance() { 27 | if (instance == null) { 28 | instance = new BlockStore(); 29 | } 30 | 31 | return instance; 32 | } 33 | 34 | public void updateCache() { 35 | this.updateCache(this.get()); 36 | } 37 | 38 | private void updateCache(List data) { 39 | this.cache.processGroupedList(data); 40 | } 41 | 42 | public BlockSearchCache getCache() { 43 | return this.cache; 44 | } 45 | 46 | @Override 47 | public List get() { 48 | return this.blockEntries; 49 | } 50 | 51 | @Override 52 | public Gson getGson() { 53 | return new GsonBuilder() 54 | .registerTypeAdapter(BlockEntry.class, new BlockEntry.Serializer()) 55 | .setPrettyPrinting() 56 | .create(); 57 | } 58 | 59 | @Override 60 | public List providedDefault() { 61 | return new ArrayList<>(); 62 | } 63 | 64 | @Override 65 | Type getType() { 66 | return new TypeToken>() { 67 | }.getType(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/storage/SettingsStore.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.storage; 2 | 3 | import pro.mikey.fabric.xray.StateSettings; 4 | 5 | import java.lang.reflect.Type; 6 | 7 | public class SettingsStore extends Store { 8 | private static SettingsStore instance; 9 | private final StateSettings settings; 10 | 11 | private SettingsStore() { 12 | super("settings"); 13 | this.settings = this.read(); 14 | } 15 | 16 | public static SettingsStore getInstance() { 17 | if (instance == null) { 18 | instance = new SettingsStore(); 19 | } 20 | 21 | return instance; 22 | } 23 | 24 | @Override 25 | public StateSettings providedDefault() { 26 | return new StateSettings(); 27 | } 28 | 29 | @Override 30 | public StateSettings get() { 31 | return this.settings; 32 | } 33 | 34 | @Override 35 | Type getType() { 36 | return StateSettings.class; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/client/java/pro/mikey/fabric/xray/storage/Store.java: -------------------------------------------------------------------------------- 1 | package pro.mikey.fabric.xray.storage; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.JsonIOException; 6 | import com.google.gson.JsonSyntaxException; 7 | import net.minecraft.client.Minecraft; 8 | import pro.mikey.fabric.xray.XRay; 9 | 10 | import java.io.*; 11 | import java.lang.reflect.Type; 12 | 13 | public abstract class Store { 14 | private static final String CONFIG_PATH = String.format("%s/config/%s", Minecraft.getInstance().gameDirectory, XRay.MOD_ID); 15 | 16 | private final String name; 17 | private final String file; 18 | 19 | public boolean justCreated = false; 20 | 21 | Store(String name) { 22 | this.name = name; 23 | this.file = String.format("%s/%s.json", CONFIG_PATH, this.name); 24 | 25 | this.read(); 26 | } 27 | 28 | public Gson getGson() { 29 | return new GsonBuilder().setPrettyPrinting().create(); 30 | } 31 | 32 | public T read() { 33 | Gson gson = this.getGson(); 34 | 35 | try { 36 | try { 37 | return gson.fromJson(new FileReader(this.file), this.getType()); 38 | } catch (JsonIOException | JsonSyntaxException e) { 39 | XRay.LOGGER.fatal("Fatal error with json loading on {}.json", this.name, e); 40 | } 41 | } catch (FileNotFoundException ignored) { 42 | this.justCreated = true; 43 | 44 | // Write a blank version of the file 45 | if (new File(CONFIG_PATH).mkdirs()) { 46 | this.write(true); 47 | } 48 | } 49 | 50 | return this.providedDefault(); 51 | } 52 | 53 | public void write() { 54 | this.write(false); 55 | } 56 | 57 | private void write(Boolean firstWrite) { 58 | Gson gson = this.getGson(); 59 | 60 | try { 61 | try (FileWriter writer = new FileWriter(this.file)) { 62 | gson.toJson(firstWrite ? this.providedDefault() : this.get(), writer); 63 | writer.flush(); 64 | } 65 | } catch (IOException | JsonIOException e) { 66 | XRay.LOGGER.catching(e); 67 | } 68 | } 69 | 70 | public abstract T providedDefault(); 71 | 72 | public abstract T get(); 73 | 74 | abstract Type getType(); 75 | } 76 | -------------------------------------------------------------------------------- /src/client/resources/advanced-xray-fabric.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "pro.mikey.fabric.xray.mixins", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "MixinBlockItem" 10 | ], 11 | "injectors": { 12 | "defaultRequire": 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/resources/advanced-xray-fabric.accesswidener: -------------------------------------------------------------------------------- 1 | accessWidener v1 named 2 | accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry 3 | accessible field net/minecraft/client/gui/screens/Screen renderables Ljava/util/List; 4 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/main/resources/assets/advanced-xray-fabric/icon.png -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "category.xray": "Advanced XRay", 3 | "keybinding.enable_xray": "Enable XRay", 4 | "keybinding.open_gui": "Open Gui", 5 | "message.xray_active": "XRay activated", 6 | "message.xray_deactivate": "XRay deactivated", 7 | "spacer": "-------------------------------------------------------", 8 | "comment_forge": "Forge mod old lang stuff, please never translate", 9 | "xray.single.cancel": "Cancel", 10 | "xray.single.add": "Add", 11 | "xray.single.delete": "Delete", 12 | "xray.single.save": "Save", 13 | "xray.single.tools": "Tools", 14 | "xray.single.close": "Close", 15 | "xray.single.search": "Search", 16 | "xray.single.help": "Help", 17 | "xray.overlay": "XRay Active", 18 | "xray.color.red": "Red: ", 19 | "xray.color.green": "Green: ", 20 | "xray.color.blue": "Blue: ", 21 | "xray.input.gui": "GUI Name", 22 | "xray.input.add": "Add Block", 23 | "xray.input.add_hand": "Add Block in hand", 24 | "xray.input.add_look": "Add Looking at", 25 | "xray.input.distance": "Distance: %s", 26 | "xray.input.show-lava": "Show Lava: %s", 27 | "xray.input.toggle_oredict": "Use Dictionary", 28 | "xray.title.config": "Configure Block", 29 | "xray.title.edit": "Edit Block", 30 | "xray.title.edit_meta": "Edit Meta", 31 | "xray.message.missing_input": "You need to have all the inputs filled in", 32 | "xray.message.already_exists": "This block has already been added to the block list", 33 | "xray.message.added_block": "Successfully added %s.", 34 | "xray.message.updated_block": "Entry Updated", 35 | "xray.message.remove_block": "%s has been removed", 36 | "xray.message.block_exists": "%s already exists. Please enter a different name.", 37 | "xray.message.unknown": "Looks like the block you've tried to edit doesn't exist.", 38 | "xray.message.removed": "Successfully removed %s.", 39 | "xray.message.config_missing": "Config file not found. Creating now.", 40 | "xray.message.invalid_hand": "%s needs to be a block", 41 | "xray.message.thats_odd": "Something went wrong? Sorry about that. Make an issue if this continues to happen", 42 | "xray.message.nothing_infront": "You're not looking at anything are you?", 43 | "xray.message.not_a_number": "{%s} is not a number. Please use a number for your meta", 44 | "xray.message.meta_not_supported": "{%s} isn't a valid meta data for {%s}", 45 | "xray.message.state_warning": "Warning, this will limit you to default\nblocks. Use looking at or in hand to get\nthe absolute block you require.\nIn some cases (chests) this may be what you need to do\nif that's the case then this is the right option.", 46 | "xray.tooltips.add_block": "Select a block to add to the XRay'd blocks\nThis uses block defaults, if you require a specific block\nthen use 'Add Looking At'.", 47 | "xray.tooltips.add_block_in_hand": "Automatically selects the block you've\ngot in your hand to add to the list.", 48 | "xray.tooltips.add_block_looking_at": "Automatically selects the block you're\nlooking at to add to the list.", 49 | "xray.tooltips.show_lava": "Displays lava in RED like a normal block.\nWatch out! It's hot.", 50 | "xray.tooltips.distance": "This is the amount of chunks around the player.", 51 | "xray.tooltips.edit1": "Click to enable / disable", 52 | "xray.tooltips.edit2": "Hold shift and click to edit.", 53 | "xray.message.help.gui": "To edit a block simply shift click on the block you wish to edit.\nIf you want to enable / disable a block then click on a block\n and it'll toggle on and off.", 54 | "xray.message.help.warning": "As a warning, using any distance over 64 will cause FPS drops due\nto the vast amount of blocks that we have to scan. (It's like 256^3)" 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/lang/fr_fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "category.xray": "Advanced XRay", 3 | "keybinding.enable_xray": "Activer XRay", 4 | "keybinding.open_gui": "Ouvrir le menu", 5 | 6 | "message.xray_active": "XRay activé", 7 | "message.xray_deactivate": "XRay désactivé" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/lang/ja_jp.json: -------------------------------------------------------------------------------- 1 | { 2 | "category.xray": "Advanced XRay", 3 | "keybinding.enable_xray": "XRayを有効化", 4 | "keybinding.open_gui": "GUIを開く", 5 | 6 | "message.xray_active": "XRayを有効化しました", 7 | "message.xray_deactivate": "XRayを無効化しました" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "category.xray": "高级 X 射线", 3 | "keybinding.enable_xray": "启用 X 射线", 4 | "keybinding.open_gui": "打开图像界面", 5 | "message.xray_active": "启动 X 射线", 6 | "message.xray_deactivate": "停用 X 射线", 7 | "spacer": "-------------------------------------------------------", 8 | "comment_forge": "Forge mod old lang stuff, please never translate", 9 | "xray.single.cancel": "取消", 10 | "xray.single.add": "添加", 11 | "xray.single.delete": "删除", 12 | "xray.single.save": "删除", 13 | "xray.single.tools": "工具", 14 | "xray.single.close": "关闭", 15 | "xray.single.search": "搜索", 16 | "xray.single.help": "帮助", 17 | "xray.overlay": "X射线活性", 18 | "xray.color.red": "红色: ", 19 | "xray.color.green": "绿色: ", 20 | "xray.color.blue": "蓝色: ", 21 | "xray.input.gui": "GUI Name", 22 | "xray.input.add": "添加区块", 23 | "xray.input.add_hand": "添加手中的方块", 24 | "xray.input.add_look": "添加查看", 25 | "xray.input.distance": "加载区块: %s", 26 | "xray.input.show-lava": "显示 岩浆: %s", 27 | "xray.input.toggle_oredict": "使用词典", 28 | "xray.title.config": "配置块", 29 | "xray.title.edit": "编辑区块", 30 | "xray.title.edit_meta": "编辑元数据", 31 | "xray.message.missing_input": "您需要填写所有输入", 32 | "xray.message.already_exists": "此阻止已添加到阻止列表", 33 | "xray.message.added_block": "添加成功 %s.", 34 | "xray.message.updated_block": "条目已更新", 35 | "xray.message.remove_block": "%s 已被删除", 36 | "xray.message.block_exists": "%s 已存在。请输入其他名称。", 37 | "xray.message.unknown": "您尝试编辑的方块似乎不存在。", 38 | "xray.message.removed": "已成功移除 %s.", 39 | "xray.message.config_missing": "未找到配置文件。立即创建.", 40 | "xray.message.invalid_hand": "%s 需要成为一个块", 41 | "xray.message.thats_odd": "好像出问题了,如果这个问题不是第一次出现,请反馈到https://github.com/AdvancedXRay/XRay-Fabric/issues", 42 | "xray.message.nothing_infront": "你什么也没看吧?", 43 | "xray.message.not_a_number": "{%s} 不是数字。请使用数字作为您的元信息", 44 | "xray.message.meta_not_supported": "{%s} 不是有效的元数据 {%s}", 45 | "xray.message.state_warning": "警告,这会将您限制为默认\n方块。使用查看或手中的方块来获取\n您所需的绝对方块。\n在某些情况下(箱子)这可能是您需要做的\n如果是这种情况,那么这是正确的选择.", 46 | "xray.tooltips.add_block": "选着一个方块加入到追踪列表中\n这里面基本是原生的方块,如果你要特殊方块\n需要点击“添加查看”。", 47 | "xray.tooltips.add_block_in_hand": "将右手拿的方块添加到追踪列表中。", 48 | "xray.tooltips.add_block_looking_at": "自动选择您正在查看的块以添加到列表中.", 49 | "xray.tooltips.show_lava": "显示岩浆(包括源和流动),如果是当前加载过的区块,可能存在数据更新不及时,只需要重新开关即可.", 50 | "xray.tooltips.distance": "加载玩家周围的区块数量(是个正方形,如果是1就行1*1区块,3就是3*3区块).", 51 | "xray.tooltips.edit1": "点击启用/禁用", 52 | "xray.tooltips.edit2": "按住 Shift 并单击以编辑.", 53 | "xray.message.help.gui": "如果要修改已经在追踪列表中的数据只需要按住shift然后点击对应的条目即可。\n如果你只是想开关,只要鼠标左键点击就行。", 54 | "xray.message.help.warning": "需要注意的是\n不要将范围调太大,会掉fps,因为我需要扫描所有的方块" 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/shaders/frag/rendertype_lines_unaffected.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertexColor; 4 | out vec4 fragColor; 5 | 6 | void main() { 7 | fragColor = vertexColor; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/textures/gui/bg-help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/main/resources/assets/advanced-xray-fabric/textures/gui/bg-help.png -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/textures/gui/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/main/resources/assets/advanced-xray-fabric/textures/gui/bg.png -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/textures/gui/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/main/resources/assets/advanced-xray-fabric/textures/gui/circle.png -------------------------------------------------------------------------------- /src/main/resources/assets/advanced-xray-fabric/textures/gui/color-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdvancedXRay/XRay-Fabric/e2a29ae4caf36df9e9d32ed51340050fbd360ff3/src/main/resources/assets/advanced-xray-fabric/textures/gui/color-bg.png -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "advanced-xray-fabric", 4 | "version": "${version}", 5 | "name": "Advanced XRay (Fabric)", 6 | "description": "An Advanced XRay mod for Fabric with all your block finding needs baked right in!", 7 | "authors": [ 8 | "ErrorMikey" 9 | ], 10 | "contact": { 11 | "homepage": "https://github.com/AdvancedXRay/xray-fabric", 12 | "sources": "https://github.com/AdvancedXRay/xray-fabric" 13 | }, 14 | "license": "MIT", 15 | "icon": "assets/advanced-xray-fabric/icon.png", 16 | "environment": "client", 17 | "entrypoints": { 18 | "client": [ 19 | "pro.mikey.fabric.xray.XRay" 20 | ] 21 | }, 22 | "mixins": [ 23 | { 24 | "config": "advanced-xray-fabric.mixins.json", 25 | "environment": "client" 26 | } 27 | ], 28 | "depends": { 29 | "fabricloader": ">=0.16.9", 30 | "fabric-api": "*", 31 | "minecraft": ">=1.21.1" 32 | }, 33 | "accessWidener": "advanced-xray-fabric.accesswidener" 34 | } 35 | --------------------------------------------------------------------------------