├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ ├── build.yaml │ └── release.yml ├── .gitignore ├── HEADER ├── LICENSE ├── README.md ├── advancedtooltips-1.19 ├── build.gradle └── src │ └── main │ └── resources │ ├── assets │ └── advancedtooltips │ │ └── icon.png │ └── fabric.mod.json ├── advancedtooltips-core ├── build.gradle └── src │ └── main │ ├── java │ ├── com │ │ └── github │ │ │ └── reviversmc │ │ │ └── advancedtooltips │ │ │ ├── AdvancedTooltips.java │ │ │ ├── AdvancedTooltipsCommand.java │ │ │ ├── AdvancedTooltipsConfig.java │ │ │ ├── HiddenEffectMode.java │ │ │ ├── JukeboxTooltipMode.java │ │ │ ├── SaturationTooltipMode.java │ │ │ ├── SignTooltipMode.java │ │ │ ├── api │ │ │ ├── AdvancedTooltipsEntrypoint.java │ │ │ ├── InventoryProvider.java │ │ │ └── InventoryProviderManager.java │ │ │ ├── mixin │ │ │ ├── ArmorStandItemMixin.java │ │ │ ├── BannerPatternItemMixin.java │ │ │ ├── BlockItemMixin.java │ │ │ ├── CameraAccessor.java │ │ │ ├── EntityAccessor.java │ │ │ ├── EntityBucketItemMixin.java │ │ │ ├── FilledMapItemMixin.java │ │ │ ├── ItemEntityAccessor.java │ │ │ ├── ItemStackMixin.java │ │ │ ├── LingeringPotionItemMixin.java │ │ │ ├── PotionItemMixin.java │ │ │ ├── SignItemMixin.java │ │ │ ├── SpawnEggItemMixin.java │ │ │ ├── SpectralArrowItemMixin.java │ │ │ ├── TippedArrowItemMixin.java │ │ │ └── WitherEntityAccessor.java │ │ │ └── tooltip │ │ │ ├── ArmorStandTooltipComponent.java │ │ │ ├── ArmorTooltipComponent.java │ │ │ ├── BannerTooltipComponent.java │ │ │ ├── BeesTooltipComponent.java │ │ │ ├── CampfireTooltipComponent.java │ │ │ ├── CompoundTooltipComponent.java │ │ │ ├── ConvertibleTooltipData.java │ │ │ ├── EntityBucketTooltipComponent.java │ │ │ ├── EntityTooltipComponent.java │ │ │ ├── FoodTooltipComponent.java │ │ │ ├── InventoryTooltipComponent.java │ │ │ ├── JukeboxTooltipComponent.java │ │ │ ├── MapTooltipComponent.java │ │ │ ├── SignTooltipComponent.java │ │ │ ├── SpawnEntityTooltipComponent.java │ │ │ └── StatusEffectTooltipComponent.java │ └── io │ │ └── github │ │ └── queerbric │ │ └── inspecio │ │ └── api │ │ ├── InspecioEntrypoint.java │ │ └── InventoryProvider.java │ └── resources │ ├── advancedtooltips.mixins.json │ ├── assets │ └── advancedtooltips │ │ ├── lang │ │ ├── de_de.json │ │ ├── en_us.json │ │ ├── fr_ca.json │ │ ├── fr_fr.json │ │ ├── ko_kr.json │ │ ├── ru_ru.json │ │ ├── tr_tr.json │ │ └── zh_cn.json │ │ └── textures │ │ ├── mob_effects │ │ └── mystery.png │ │ └── tooltips │ │ └── honey_level.png │ ├── data │ └── inspecio │ │ └── tags │ │ └── items │ │ └── hidden_effects.json │ └── fabric.mod.json ├── assets ├── banner.png ├── banner.xcf ├── icon.png ├── icon.xcf └── preview-images │ ├── armor.png │ ├── armor_stand.png │ ├── banner_pattern.png │ ├── beacon.png │ ├── beehive.png │ ├── bucket_of_axolotl.png │ ├── bucket_of_tropical_fish.png │ ├── campfire.png │ ├── colored_shulker_box_tooltip.png │ ├── compact_shulker_box_tooltip.png │ ├── filled_map.png │ ├── fox_spawn_egg.png │ ├── golden_carrot.png │ ├── jukebox.png │ ├── lodestone_compass.png │ ├── loot_table.png │ ├── potion.png │ ├── repair_cost.png │ ├── sign.png │ ├── simple_shulker_box_tooltip.png │ └── suspicious_stew.png ├── common.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 4 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.{yml,yaml}] 11 | indent_size = 2 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" 9 | directory: "/advancedtooltips-core" 10 | schedule: 11 | interval: "daily" 12 | - package-ecosystem: "gradle" 13 | directory: "/advancedtooltips-1.19" 14 | schedule: 15 | interval: "daily" 16 | 17 | - package-ecosystem: "github-actions" 18 | directory: "/" 19 | schedule: 20 | interval: "daily" 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | 12 | - name: Set up JDK 17 13 | uses: actions/setup-java@v3 14 | with: 15 | java-version: "17" 16 | distribution: "temurin" 17 | cache: gradle 18 | 19 | - name: Make Gradle wrapper executable 20 | run: chmod +x ./gradlew 21 | 22 | - name: Validate Gradle wrapper 23 | uses: gradle/wrapper-validation-action@v1 24 | 25 | - name: Build 1.19 project 26 | run: ./gradlew :advancedtooltips-1.19:build --no-daemon --stacktrace 27 | 28 | - name: Upload build artifacts 29 | uses: actions/upload-artifact@v3 30 | with: 31 | name: build-artifacts 32 | path: | 33 | **/build/libs 34 | !advancedtooltips-core/ 35 | - name: Cleanup Gradle Cache 36 | run: | 37 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 38 | rm -f ~/.gradle/caches/modules-2/gc.properties 39 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v3 17 | with: 18 | java-version: "17" 19 | distribution: "temurin" 20 | cache: gradle 21 | 22 | - name: Make Gradle wrapper executable 23 | run: chmod +x ./gradlew 24 | 25 | - name: Validate Gradle wrapper 26 | uses: gradle/wrapper-validation-action@v1 27 | 28 | - name: Build mod 29 | run: ./gradlew :advancedtooltips-1.19:build --stacktrace 30 | 31 | - name: Publish 1.19 version 32 | uses: Kir-Antipov/mc-publish@v3.2 33 | with: 34 | modrinth-id: hErQiboW 35 | modrinth-token: ${{ secrets.MODRINTH_TOKEN }} 36 | curseforge-id: 640815 37 | curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} 38 | github-token: ${{ secrets.GITHUB_TOKEN }} 39 | files-primary: advancedtooltips-1.19/build/libs/!(*-@(dev|sources)).jar 40 | name: 1.6.0 for MC 1.19 41 | version: 1.6.0+1.19 42 | version-type: release 43 | loaders: | 44 | fabric 45 | dependencies: | 46 | fabric-api | depends 47 | 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # LambdAurora's ignore file 3 | # 4 | # v0.16 5 | 6 | # JetBrains 7 | .idea/ 8 | *.iml 9 | *.ipr 10 | *.iws 11 | ## Intellij IDEA 12 | out/ 13 | ## CLion 14 | cmake-build-debug*/ 15 | cmake-build-release*/ 16 | ## Eclipse 17 | eclipse 18 | *.launch 19 | .settings 20 | .metadata 21 | .classpath 22 | .project 23 | ## Visual Studio 24 | .vs/ 25 | CMakeSettings.json 26 | 27 | # Build system 28 | ## Cargo 29 | Cargo.lock 30 | ## CMake 31 | CMakeCache.txt 32 | CMakeFiles/ 33 | ## Gradle 34 | .gradle/ 35 | ## Node.JS 36 | node_modules/ 37 | 38 | # Editors 39 | ## VSCode 40 | .vscode/ 41 | 42 | # Logging 43 | logs/ 44 | 45 | # Languages 46 | ## Java 47 | classes/ 48 | ## Python 49 | __pycache__/ 50 | venv/ 51 | ## Rust 52 | **/*.rs.bk 53 | 54 | # OS 55 | ## Windows 56 | desktop.ini 57 | # MacOS 58 | .DS_Store 59 | 60 | # File types 61 | *.dll 62 | *.so 63 | *.dylib 64 | *.lib 65 | lib*.a 66 | *.png~ 67 | *.tar.?z 68 | 69 | # Common 70 | bin/ 71 | build/ 72 | dist/ 73 | lib/ 74 | obj/ 75 | run/ 76 | target/ 77 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 - 2022 LambdAurora , Emi 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this program. If not, see . -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Advanced Tooltips 4 | [![CurseForge downloads](https://cf.way2muchnoise.eu/advanced-tooltips.svg)](https://www.curseforge.com/minecraft/mc-mods/advanced-tooltips) 5 | [![CurseForge versions](https://cf.way2muchnoise.eu/versions/advanced-tooltips.svg)](https://www.curseforge.com/minecraft/mc-mods/advanced-tooltips) 6 | [![Modrinth downloads](https://img.shields.io/modrinth/dt/advanced-tooltips?color=00AF5C&label=modrinth&style=flat&logo=modrinth)](https://modrinth.com/mod/advanced-tooltips) 7 | ![Environment: server](https://img.shields.io/badge/environment-client-1976d2?style=flat) 8 | [![Discord chat](https://img.shields.io/badge/chat%20on-discord-7289DA?logo=discord&logoColor=white)](https://discord.gg/6bTGYFppfz) 9 | 10 | More and better tooltips on items! 11 | 12 | ## What is this mod? 13 | **Advanced Tooltips** adds new tooltips to items like shulker boxes, filled maps, fish buckets, armor, food, banner patterns, and more! It's is also pretty configurable, most parts can be enabled/disabled to your heart's desire! 14 | 15 | This is a Fabric port of the now Quilt-exclusive mod "Inspecio", found [here](https://www.curseforge.com/minecraft/mc-mods/inspecio). 16 | 17 | 18 | 19 | ## Pictures 20 | 21 | #### Armor tooltip 22 | ![armor](assets/preview-images/armor.png) 23 | 24 | 25 | #### Food tooltip 26 | ![food](assets/preview-images/golden_carrot.png) 27 | 28 | 29 | #### Effects tooltips 30 | ![potion](assets/preview-images/potion.png) 31 | 32 | ![suspicious stew](assets/preview-images/suspicious_stew.png) 33 | 34 | ![beacon](assets/preview-images/beacon.png) 35 | 36 | 37 | #### Shulker Box tooltips (and other storage blocks) 38 | Normal: 39 | 40 | ![normal](assets/preview-images/simple_shulker_box_tooltip.png) 41 | 42 | Colored: 43 | 44 | ![colored](assets/preview-images/colored_shulker_box_tooltip.png) 45 | 46 | Compact: 47 | 48 | ![compact](assets/preview-images/compact_shulker_box_tooltip.png) 49 | 50 | 51 | #### Jukebox tooltip 52 | ![jukebox](assets/preview-images/jukebox.png) 53 | 54 | 55 | #### Loot Table Tooltip 56 | ![loot_table](assets/preview-images/loot_table.png) 57 | 58 | 59 | #### Bee Hive Tooltip 60 | ![bees](assets/preview-images/beehive.png) 61 | 62 | 63 | #### Sign Tooltip 64 | ![sign](assets/preview-images/sign.png) 65 | 66 | 67 | #### Banner Pattern 68 | ![banner_pattern](assets/preview-images/banner_pattern.png) 69 | 70 | 71 | #### Campfire 72 | ![campfire](assets/preview-images/campfire.png) 73 | 74 | 75 | #### Filled Map 76 | ![map](assets/preview-images/filled_map.png) 77 | 78 | 79 | 80 | #### Entities 81 | 82 | ##### Armor Stand 83 | ![armor_stand](assets/preview-images/armor_stand.png) 84 | 85 | 86 | ##### Bucket of Fish 87 | ![tropical_fish_bucket](assets/preview-images/bucket_of_tropical_fish.png) 88 | 89 | 90 | ##### Bucket of Axolotl 91 | ![axolotl](assets/preview-images/bucket_of_axolotl.png) 92 | 93 | 94 | ##### Spawn Eggs 95 | ![fox_spawn_egg](assets/preview-images/fox_spawn_egg.png) 96 | 97 | 98 | #### Lodestone Compass 99 | ![lodestone_compass](assets/preview-images/lodestone_compass.png) 100 | 101 | #### Repair Cost 102 | ![repair_cost](assets/preview-images/repair_cost.png) 103 | 104 | ## Configuration 105 | The configuration file of the mod is located in `/config/advanced-tooltips.json`. 106 | 107 | You can use the command `/tooltips config` to manage configuration. 108 | 109 | Here's the default configuration: 110 | 111 | ```json 112 | { 113 | "jukebox": "fancy", 114 | "sign": "fancy", 115 | "advanced_tooltips": { 116 | "repair_cost": true, 117 | "lodestone_coords": false 118 | }, 119 | "filled_map": { 120 | "enabled": true, 121 | "show_player_icon": false 122 | }, 123 | "food": { 124 | "hunger": true, 125 | "saturation": "merged" 126 | }, 127 | "containers": { 128 | "campfire": true, 129 | "storage": { 130 | "enabled": true, 131 | "compact": false, 132 | "loot_table": true 133 | }, 134 | "shulker_box": { 135 | "enabled": true, 136 | "compact": false, 137 | "loot_table": true, 138 | "color": true 139 | } 140 | }, 141 | "effects": { 142 | "food": true, 143 | "hidden_motion": true, 144 | "hidden_effect_mode": "enchantment", 145 | "beacon": true, 146 | "potions": true, 147 | "tipped_arrows": true, 148 | "spectral_arrow": true 149 | }, 150 | "entities": { 151 | "fish_bucket": { 152 | "enabled": true, 153 | "always_show_name": false, 154 | "spin": true 155 | }, 156 | "spawn_egg": { 157 | "enabled": true, 158 | "always_show_name": false, 159 | "spin": true 160 | }, 161 | "pufferfish_puff_state": 2, 162 | "armor_stand": { 163 | "enabled": true, 164 | "always_show_name": false, 165 | "spin": true 166 | }, 167 | "bee": { 168 | "enabled": true, 169 | "always_show_name": false, 170 | "spin": true, 171 | "show_honey_level": true 172 | }, 173 | "mob_spawner": { 174 | "enabled": true, 175 | "always_show_name": false, 176 | "spin": true 177 | } 178 | }, 179 | "armor": true, 180 | "banner_pattern": true 181 | } 182 | ``` 183 | 184 | Here's a list of each configuration entries and what they do: 185 | 186 | - `armor` (`bool`) - `true` if the display of the armor bar on armor items is enabled, or `false` otherwise. 187 | - `banner_pattern` (`bool`) - `true` if the display of the pattern in the tooltip of banner patterns is enabled, or `false` otherwise. 188 | - `advanced_tooltips` 189 | - `repair_cost` (`bool`) - `true` if the display the repair cost value is enabled, or `false` otherwise. 190 | - `lodestone_coords` (`bool`) - `true` if a display of the lodestone coordinates on lodestone compass is enabled, or `false` otherwise. 191 | - `containers` 192 | - `campfire` (`bool`) - `true` if the display of a special tooltip on campfires which hold custom NBT is enabled, or `false` otherwise. 193 | - `storage` 194 | - `enabled` (`bool`) - `true` if the inventory of storage items like chests, barrels, etc. should be shown in the tooltip, or `false` otherwise. 195 | - `compact` (`bool`) - `true` if the inventory should be compacted to take as little space as possible, or `false` otherwise. 196 | - `loot_table` (`bool`) - `true` if the loot table identifier should be displayed in the tooltip if specified, or `false` otherwise. 197 | - `shulker_box` 198 | - `enabled` (`bool`) - `true` if the inventory of shulker boxes should be shown in the tooltip, or `false` otherwise. 199 | - `compact` (`bool`) - `true` if the inventory should be compacted to take as little space as possible, or `false` otherwise. 200 | - `loot_table` (`bool`) - `true` if the loot table identifier should be displayed in the tooltip if specified, or `false` otherwise. 201 | - `color` (`bool`) - `true` if the inventory tooltip should be colored the same as the shulker box, or `false` otherwise. 202 | - `effects` 203 | - `potions` (`bool`) - `true` if replacing the effect tooltips with a fancy one on potion items is enabled, or `false` otherwise. 204 | - `tipped_arrows` (`bool`) - `true` if replacing the effect tooltips with a fancy one on tipped arrows is enabled, or `false` otherwise. 205 | - `spectral_arrow` (`bool`) - `true` if replacing the effect tooltips with a fancy one on spectral arrow item is enabled, or `false` otherwise. 206 | - `food` (`bool`) - `true` if adding effect tooltips on food items is enabled, or `false` otherwise. 207 | - `hidden_motion` (`bool`) - `true` if using obfuscated text for hidden effect tooltips is enabled, or `false` otherwise. 208 | - `hidden_effect_mode` (`string`) - `"enchantment"` will display the obfuscated text for hidden effect tooltips with the enchantment font, `"obfuscated"` will use the normal font. 209 | - `beacon` (`bool`) - `true` if adding a tooltip with the primary and secondary effects (if they exist) is enabled, or `false` otherwise. 210 | - `entities` 211 | - `armor_stand` 212 | - `enabled` (`bool`) - `true` if armor stand tooltip should be displayed, or `false` otherwise. 213 | - `always_show_name` (`bool`) - `true` if the name of an armor stand should always be shown, or `false` otherwise and use the CTRL key instead. 214 | - `spin` (`bool`) - `true` if the armor stand spin in the tooltip, or `false` otherwise 215 | - `bee` 216 | - `enabled` (`bool`) - `true` if displaying the bees in the beehive tooltip is enabled, or `false` otherwise. 217 | - `always_show_name` (`bool`) - `true` if the name of the bees should always be shown, or `false` otherwise and use the CTRL key instead. 218 | - `spin` (`bool`) - `true` if the bees spin in the tooltip, or `false` otherwise. 219 | - `show_honey_level` (`bool`) `true` if the honey level should be shown, or `false` otherwise. 220 | - `fish_bucket` 221 | - `enabled` (`bool`) - `true` if fish bucket tooltips should display the entity they hold, or `false` otherwise. 222 | - `spin` (`bool`) - `true` if the entity spins in the tooltip, or `false` otherwise. 223 | - `mob_spawner` 224 | - `enabled` (`bool`) - `true` if mob spawner tooltips should display the entity they hold, or `false` otherwise. 225 | - `always_show_name` (`bool`) - `true` if the name of the hold entity should always be shown, or `false` otherwise. 226 | - `spin` (`bool`) - `true` if the entity spins in the tooltip, or `false` otherwise. 227 | - `spawn_egg` 228 | - `enabled` (`bool`) - `true` if spawn egg tooltips should display the entity they hold, or `false` otherwise. 229 | - `always_show_name` (`bool`) - `true` if the name of the hold entity should always be shown, or `false` otherwise. 230 | - `spin` (`bool`) - `true` if the entity spins in the tooltip, or `false` otherwise. 231 | - `pufferfish_puff_state` (`int`) - the pufferfish puff state, between 0 and 2 inclusive. 232 | - `filled_map` 233 | - `enabled` (`bool`) - `true` if filled map tooltips should display the map, or `false` otherwise. 234 | - `show_player_icon` (`bool`) - `true` if show the player icon on filled map tooltips, or `false` otherwise. 235 | - `food` 236 | - `hunger` (`bool`) - `true` if hunger bar should be displayed on food items, or `false` otherwise. 237 | - `saturation` (`string`) - `"disabled"` does nothing, `"merged"` adds the saturation bar as an outline to the hunger bar, `"separated"` adds its own saturation bar. 238 | - `jukebox` (`string`) - `"disabled"` does nothing, `"fast"` will add the inserted disc name if possible in the tooltip of jukeboxes, `"fancy"` will display the disc item as well. 239 | - `sign` (`string`) - `"disabled"` does nothing, `"fast"` will add the sign content as text tooltip if possible, `"fancy"` will add a fancy sign tooltip if possible. 240 | 241 | [fabric]: https://fabricmc.net 242 | [Mod loader: Fabric]: https://img.shields.io/badge/modloader-Fabric-1976d2?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFHGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE4LTEyLTE2VDE2OjU0OjE3LTA4OjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHN0RXZ0OndoZW49IjIwMTgtMTItMTZUMTY6NTQ6MTctMDg6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE4IChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4/HiGMAAAAtUlEQVRYw+XXrQqAMBQF4D2P2eBL+QIG8RnEJFaNBjEum+0+zMQLtwwv+wV3ZzhhMDgfJ0wUSinxZUQWgKos1JP/AbD4OneIDyQPwCFniA+EJ4CaXm4TxAXCC0BNHgLhAdAnx9hC8PwGSRtAFVMQjF7cNTWED8B1cgwW20yfJgAvrssAsZ1cB3g/xckAxr6FmCDU5N6f488BrpCQ4rQBJkiMYh4ACmLzwOQF0CExinkCsvw7vgGikl+OotaKRwAAAABJRU5ErkJggg== 243 | -------------------------------------------------------------------------------- /advancedtooltips-1.19/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '0.12-SNAPSHOT' 3 | id 'io.github.juuxel.loom-quiltflower' version '1.7.4' 4 | id 'org.quiltmc.quilt-mappings-on-loom' version '4.2.0' 5 | id 'maven-publish' 6 | } 7 | 8 | sourceCompatibility = JavaVersion.VERSION_17 9 | targetCompatibility = JavaVersion.VERSION_17 10 | 11 | 12 | archivesBaseName = project.archives_base_name 13 | def mod_version = project.mod_version as Object 14 | version = "${mod_version}+1.19" 15 | 16 | apply from: '../common.gradle' 17 | 18 | 19 | dependencies { 20 | include implementation(project(path: ":advancedtooltips-core", configuration: "namedElements")) 21 | 22 | minecraft "com.mojang:minecraft:${project.minecraft_version_1_19}" 23 | mappings(loom.layered { 24 | addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${minecraft_version_1_19}+build.${project.quilt_mappings_1_19}:v2")) 25 | }) 26 | 27 | // Required Fabric API modules 28 | modImplementation(fabricApi.module('fabric-api-base', project.fabric_api_version_1_19)) 29 | modImplementation(fabricApi.module('fabric-command-api-v2', project.fabric_api_version_1_19)) 30 | modImplementation(fabricApi.module('fabric-rendering-v1', project.fabric_api_version_1_19)) 31 | modImplementation(fabricApi.module('fabric-resource-loader-v0', project.fabric_api_version_1_19)) 32 | 33 | // Use the full Fabric API while debugging, otherwise ModMenu complains 34 | modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version_1_19}" 35 | 36 | // ModMenu integration 37 | modImplementation "com.terraformersmc:modmenu:${project.modmenu_version_1_19}" 38 | // Cloth Config for config screen 39 | modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version_1_19}") { 40 | exclude(group: "net.fabricmc.fabric-api") 41 | } 42 | 43 | 44 | if (project.use_third_party_mods == "true") { 45 | configurations { 46 | modRuntimeOnly { 47 | transitive = true 48 | exclude module: "fabric-loader" 49 | exclude module: "fabric-api-base" 50 | exclude module: "fabric-command-api-v2" 51 | exclude module: "fabric-rendering-v1" 52 | exclude module: "fabric-resource-loader-v0" 53 | } 54 | } 55 | 56 | modRuntimeOnly "maven.modrinth:lazydfu:${project.lazydfu_version_1_19}" 57 | modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version_1_19}" 58 | runtimeOnly "org.joml:joml:${project.joml_version_sodium_1_19}" 59 | // modRuntimeOnly "maven.modrinth:lithium:${project.lithium_version_1_19}" 60 | modRuntimeOnly "maven.modrinth:starlight:${project.starlight_version_1_19}" 61 | modRuntimeOnly "maven.modrinth:smoothboot-fabric:${project.smoothboot_version_1_19}" 62 | modRuntimeOnly "curse.maven:no-fade-452768:${project.no_fade_version_1_19}" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /advancedtooltips-1.19/src/main/resources/assets/advancedtooltips/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/advancedtooltips-1.19/src/main/resources/assets/advancedtooltips/icon.png -------------------------------------------------------------------------------- /advancedtooltips-1.19/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "advanced-tooltips", 4 | "version": "${version}", 5 | "name": "Advanced Tooltips", 6 | "description": "More and better tooltips on items!", 7 | "authors": [ 8 | "NebelNidas", 9 | "Emi", 10 | "LambdAurora" 11 | ], 12 | "contributors": [], 13 | "contact": { 14 | "sources": "https://github.com/ReviversMC/advanced-tooltips", 15 | "issues": "https://github.com/ReviversMC/advanced-tooltips/issues" 16 | }, 17 | "license": "LGPL-3.0-or-later", 18 | "icon": "assets/advancedtooltips/icon.png", 19 | "environment": "client", 20 | "entrypoints": { 21 | "client": [ 22 | "com.github.reviversmc.advancedtooltips.AdvancedTooltips" 23 | ] 24 | }, 25 | "provides": [ 26 | "inspecio" 27 | ], 28 | "depends": { 29 | "minecraft": ">=1.19", 30 | "advanced-tooltips-core": "*" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /advancedtooltips-core/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '0.12-SNAPSHOT' 3 | id 'io.github.juuxel.loom-quiltflower' version '1.7.4' 4 | id 'org.quiltmc.quilt-mappings-on-loom' version '4.2.0' 5 | id 'maven-publish' 6 | } 7 | 8 | sourceCompatibility = JavaVersion.VERSION_17 9 | targetCompatibility = JavaVersion.VERSION_17 10 | 11 | 12 | archivesBaseName = project.archives_base_name 13 | version = project.mod_version 14 | 15 | apply from: '../common.gradle' 16 | 17 | 18 | dependencies { 19 | minecraft "com.mojang:minecraft:${project.minecraft_version_1_19}" 20 | mappings(loom.layered { 21 | addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${minecraft_version_1_19}+build.${project.quilt_mappings_1_19}:v2")) 22 | }) 23 | 24 | // Required Fabric API modules 25 | modImplementation(fabricApi.module('fabric-api-base', project.fabric_api_version_1_19)) 26 | modImplementation(fabricApi.module('fabric-command-api-v2', project.fabric_api_version_1_19)) 27 | modImplementation(fabricApi.module('fabric-rendering-v1', project.fabric_api_version_1_19)) 28 | modImplementation(fabricApi.module('fabric-resource-loader-v0', project.fabric_api_version_1_19)) 29 | 30 | // ModMenu integration 31 | modImplementation "com.terraformersmc:modmenu:${project.modmenu_version_1_19}" 32 | // Cloth Config for config screen 33 | modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version_1_19}") { 34 | exclude(group: "net.fabricmc.fabric-api") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/AdvancedTooltips.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips; 19 | 20 | import net.fabricmc.api.ClientModInitializer; 21 | import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; 22 | import net.fabricmc.loader.api.FabricLoader; 23 | import net.minecraft.block.Block; 24 | import net.minecraft.block.DispenserBlock; 25 | import net.minecraft.block.HopperBlock; 26 | import net.minecraft.block.ShulkerBoxBlock; 27 | import net.minecraft.entity.effect.StatusEffect; 28 | import net.minecraft.entity.effect.StatusEffectInstance; 29 | import net.minecraft.inventory.Inventories; 30 | import net.minecraft.item.BlockItem; 31 | import net.minecraft.item.Item; 32 | import net.minecraft.item.ItemStack; 33 | import net.minecraft.item.Items; 34 | import net.minecraft.nbt.NbtCompound; 35 | import net.minecraft.nbt.NbtElement; 36 | import net.minecraft.tag.TagKey; 37 | import net.minecraft.text.Text; 38 | import net.minecraft.util.DyeColor; 39 | import net.minecraft.util.Formatting; 40 | import net.minecraft.util.Identifier; 41 | import net.minecraft.util.collection.DefaultedList; 42 | import net.minecraft.util.registry.Registry; 43 | import org.apache.logging.log4j.LogManager; 44 | import org.apache.logging.log4j.Logger; 45 | import org.jetbrains.annotations.Nullable; 46 | 47 | import com.github.reviversmc.advancedtooltips.api.AdvancedTooltipsEntrypoint; 48 | import com.github.reviversmc.advancedtooltips.api.InventoryProvider; 49 | import com.github.reviversmc.advancedtooltips.tooltip.ConvertibleTooltipData; 50 | 51 | import io.github.queerbric.inspecio.api.InspecioEntrypoint; 52 | 53 | import java.util.List; 54 | import java.util.function.Consumer; 55 | 56 | public class AdvancedTooltips implements ClientModInitializer { 57 | public static final String NAMESPACE = "advancedtooltips"; 58 | private static final Logger LOGGER = LogManager.getLogger(NAMESPACE); 59 | private static AdvancedTooltipsConfig config = AdvancedTooltipsConfig.defaultConfig(); 60 | 61 | // TODO: Switch to Client Tag API: https://github.com/FabricMC/fabric/pull/2308 62 | public static final TagKey HIDDEN_EFFECTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(NAMESPACE, "hidden_effects")); 63 | public static List hiddenEffectsItems = List.of(Items.SUSPICIOUS_STEW); 64 | 65 | 66 | @Override 67 | public void onInitializeClient() { 68 | reloadConfig(); 69 | 70 | InventoryProvider.register((stack, config) -> { 71 | if (config != null && config.isEnabled() && stack.getItem() instanceof BlockItem blockItem) { 72 | DyeColor color = null; 73 | if (blockItem.getBlock() instanceof ShulkerBoxBlock shulkerBoxBlock && ((AdvancedTooltipsConfig.ShulkerBoxConfig) config).hasColor()) 74 | color = shulkerBoxBlock.getColor(); 75 | 76 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 77 | if (nbt == null) return null; 78 | 79 | DefaultedList inventory = DefaultedList.ofSize(getInvSizeFor(stack), ItemStack.EMPTY); 80 | Inventories.readNbt(nbt, inventory); 81 | if (inventory.stream().allMatch(ItemStack::isEmpty)) 82 | return null; 83 | 84 | return new InventoryProvider.Context(inventory, color); 85 | } 86 | 87 | return null; 88 | }); 89 | 90 | TooltipComponentCallback.EVENT.register(data -> { 91 | if (data instanceof ConvertibleTooltipData convertible) { 92 | return convertible.getComponent(); 93 | } 94 | return null; 95 | }); 96 | 97 | AdvancedTooltipsCommand.init(); 98 | 99 | List entrypoints = FabricLoader.getInstance().getEntrypoints("advancedtooltips", AdvancedTooltipsEntrypoint.class); 100 | for (var entrypoint : entrypoints) { 101 | entrypoint.onAdvancedTooltipsInitialized(); 102 | } 103 | List legacyEntrypoints = FabricLoader.getInstance().getEntrypoints("inspecio", InspecioEntrypoint.class); 104 | for (var entrypoint : legacyEntrypoints) { 105 | entrypoint.onInspecioInitialized(); 106 | } 107 | } 108 | 109 | /** 110 | * Prints a message to the terminal. 111 | * 112 | * @param info the message to log 113 | */ 114 | public static void log(String info) { 115 | LOGGER.info("[Advanced Tooltips] " + info); 116 | } 117 | 118 | /** 119 | * Prints a warning message to the terminal. 120 | * 121 | * @param info the message to log 122 | */ 123 | public static void warn(String info) { 124 | LOGGER.warn("[Advanced Tooltips] " + info); 125 | } 126 | 127 | /** 128 | * Prints a warning message to the terminal. 129 | * 130 | * @param info the message to log 131 | * @param params parameters to the message. 132 | */ 133 | public static void warn(String info, Object... params) { 134 | LOGGER.warn("[Advanced Tooltips] " + info, params); 135 | } 136 | 137 | /** 138 | * Prints a warning message to the terminal. 139 | * 140 | * @param info the message to log 141 | * @param throwable the exception to log, including its stack trace. 142 | */ 143 | public static void warn(String info, Throwable throwable) { 144 | LOGGER.warn("[Advanced Tooltips] " + info, throwable); 145 | } 146 | 147 | public static AdvancedTooltipsConfig getConfig() { 148 | return config; 149 | } 150 | 151 | static void reloadConfig() { 152 | config = AdvancedTooltipsConfig.load(); 153 | } 154 | 155 | static Consumer onConfigError(String path) { 156 | return error -> { 157 | AdvancedTooltipsConfig.shouldSaveConfigAfterLoad = true; 158 | warn("Configuration error at \"" + path + "\", error: " + error); 159 | }; 160 | } 161 | 162 | static String getVersion() { 163 | return FabricLoader.getInstance().getModContainer(NAMESPACE) 164 | .map(container -> { 165 | var version = container.getMetadata().getVersion().getFriendlyString(); 166 | if (version.equals("${version}")) 167 | return "dev"; 168 | return version; 169 | }).orElse("unknown"); 170 | } 171 | 172 | private static int getInvSizeFor(ItemStack stack) { 173 | if (stack.getItem() instanceof BlockItem blockItem) { 174 | var block = blockItem.getBlock(); 175 | if (block instanceof DispenserBlock) 176 | return 9; 177 | else if (block instanceof HopperBlock) 178 | return 5; 179 | return 27; 180 | } 181 | return 0; 182 | } 183 | 184 | /** 185 | * Appends block item tooltips. 186 | * 187 | * @param stack the stack to add tooltip to 188 | * @param block the block 189 | * @param tooltip the tooltip 190 | */ 191 | public static void appendBlockItemTooltip(ItemStack stack, Block block, List tooltip) { 192 | var config = AdvancedTooltips.getConfig().getContainersConfig().forBlock(block); 193 | if (config != null && config.hasLootTable()) { 194 | var blockEntityNbt = BlockItem.getBlockEntityNbtFromStack(stack); 195 | if (blockEntityNbt != null && blockEntityNbt.contains("LootTable")) { 196 | tooltip.add(Text.translatable("advancedtooltips.tooltip.loot_table", 197 | Text.literal(blockEntityNbt.getString("LootTable")) 198 | .formatted(Formatting.GOLD)) 199 | .formatted(Formatting.GRAY)); 200 | } 201 | } 202 | } 203 | 204 | public static void removeVanillaTooltips(List tooltips, int fromIndex) { 205 | if (fromIndex >= tooltips.size()) return; 206 | 207 | int keepIndex = tooltips.indexOf(Text.empty()); 208 | if (keepIndex != -1) { 209 | // we wanna keep tooltips that come after a line break 210 | keepIndex++; 211 | 212 | int tooltipsToKeep = tooltips.size() - keepIndex; 213 | 214 | // shift tooltips to keep to the front 215 | for (int i = 0; i < tooltipsToKeep; i++) { 216 | tooltips.set(fromIndex + i, tooltips.get(keepIndex + i)); 217 | } 218 | 219 | // don't remove them 220 | fromIndex += tooltipsToKeep; 221 | } 222 | 223 | tooltips.subList(fromIndex, tooltips.size()).clear(); 224 | } 225 | 226 | public static @Nullable StatusEffectInstance getRawEffectFromTag(NbtCompound tag, String tagKey) { 227 | if (tag == null) { 228 | return null; 229 | } 230 | if (tag.contains(tagKey, NbtElement.INT_TYPE)) { 231 | var effect = StatusEffect.byRawId(tag.getInt(tagKey)); 232 | if (effect != null) 233 | return new StatusEffectInstance(effect, 200, 0); 234 | } 235 | return null; 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/HiddenEffectMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips; 19 | 20 | import com.mojang.brigadier.StringReader; 21 | import com.mojang.brigadier.arguments.ArgumentType; 22 | import com.mojang.brigadier.context.CommandContext; 23 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 24 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; 25 | import com.mojang.brigadier.suggestion.Suggestions; 26 | import com.mojang.brigadier.suggestion.SuggestionsBuilder; 27 | import com.mojang.serialization.DataResult; 28 | import com.mojang.serialization.DynamicOps; 29 | import com.mojang.serialization.codecs.PrimitiveCodec; 30 | import net.minecraft.text.MutableText; 31 | import net.minecraft.text.Text; 32 | import net.minecraft.util.Formatting; 33 | import net.minecraft.util.Identifier; 34 | import org.jetbrains.annotations.NotNull; 35 | 36 | import java.util.Arrays; 37 | import java.util.Collection; 38 | import java.util.List; 39 | import java.util.Optional; 40 | import java.util.concurrent.CompletableFuture; 41 | import java.util.stream.Collectors; 42 | 43 | /** 44 | * Represents the different hidden effect modes. 45 | */ 46 | public enum HiddenEffectMode { 47 | OBFUSCATED { 48 | @Override 49 | public String getText(boolean isLong, boolean motion) { 50 | return (motion ? "f" : "?").repeat(isLong ? 8 : 2); 51 | } 52 | 53 | @Override 54 | public MutableText stylize(MutableText text, boolean motion) { 55 | return motion ? text.formatted(Formatting.OBFUSCATED) : text; 56 | } 57 | }, 58 | ENCHANTMENT { 59 | @Override 60 | public String getText(boolean isLong, boolean motion) { 61 | return isLong ? "lostquasar" : "na"; 62 | } 63 | 64 | @Override 65 | public MutableText stylize(MutableText text, boolean motion) { 66 | text = text.styled(style -> style.withFont(ALT_FONT_ID)); 67 | return motion ? text.formatted(Formatting.OBFUSCATED) : text; 68 | } 69 | }; 70 | 71 | private static final Identifier ALT_FONT_ID = new Identifier("minecraft", "alt"); 72 | 73 | public static final PrimitiveCodec CODEC = new PrimitiveCodec<>() { 74 | @Override 75 | public DataResult read(final DynamicOps ops, final T input) { 76 | return ops.getStringValue(input).map(id -> byId(id).orElse(ENCHANTMENT)); 77 | } 78 | 79 | @Override 80 | public T write(final DynamicOps ops, final HiddenEffectMode value) { 81 | return ops.createString(value.getName()); 82 | } 83 | 84 | @Override 85 | public String toString() { 86 | return "HiddenEffectMode"; 87 | } 88 | }; 89 | 90 | /** 91 | * Gets the text to be used. 92 | * 93 | * @param isLong {@code true} if the text is long, or {@code false} otherwise 94 | * @param motion {@code true} if motion is allowed, or {@code false} otherwise 95 | * @return the text 96 | */ 97 | public abstract String getText(boolean isLong, boolean motion); 98 | 99 | /** 100 | * Stylizes the given text. 101 | * 102 | * @param text the text to style 103 | * @param motion {@code true} if motion is allowed, or {@code false} otherwise 104 | * @return the stylized text 105 | */ 106 | public abstract MutableText stylize(MutableText text, boolean motion); 107 | 108 | /** 109 | * {@return the next available hidden effect mode} 110 | */ 111 | public HiddenEffectMode next() { 112 | var v = values(); 113 | if (v.length == this.ordinal() + 1) 114 | return v[0]; 115 | return v[this.ordinal() + 1]; 116 | } 117 | 118 | public @NotNull String getName() { 119 | return this.name().toLowerCase(); 120 | } 121 | 122 | /** 123 | * Gets the hidden effect mode from its identifier. 124 | * 125 | * @param id the identifier of the hidden effect mode 126 | * @return the hidden effect mode if found, else empty 127 | */ 128 | public static @NotNull Optional byId(@NotNull String id) { 129 | return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); 130 | } 131 | 132 | public static class HiddenEffectType implements ArgumentType { 133 | private static final SimpleCommandExceptionType UNKNOWN_VALUE = new SimpleCommandExceptionType( 134 | Text.translatable("advancedtooltips.command.error.unknown_hidden_effect_mode")); 135 | private static final List VALUES = List.of(values()); 136 | 137 | private HiddenEffectType() { 138 | } 139 | 140 | public static HiddenEffectType hiddenEffectMode() { 141 | return new HiddenEffectType(); 142 | } 143 | 144 | public static HiddenEffectMode getHiddenEffectMode(final CommandContext context, final String name) { 145 | return context.getArgument(name, HiddenEffectMode.class); 146 | } 147 | 148 | @Override 149 | public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { 150 | VALUES.stream().map(HiddenEffectMode::getName) 151 | .filter(s -> s.startsWith(builder.getRemainingLowerCase())) 152 | .forEach(builder::suggest); 153 | return builder.buildFuture(); 154 | } 155 | 156 | @Override 157 | public Collection getExamples() { 158 | return VALUES.stream().map(HiddenEffectMode::getName).collect(Collectors.toList()); 159 | } 160 | 161 | @Override 162 | public HiddenEffectMode parse(StringReader reader) throws CommandSyntaxException { 163 | var value = reader.readString(); 164 | return VALUES.stream().filter(s -> s.name().equalsIgnoreCase(value)).findFirst().orElseThrow(() -> UNKNOWN_VALUE.createWithContext(reader)); 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/JukeboxTooltipMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips; 19 | 20 | import com.mojang.brigadier.StringReader; 21 | import com.mojang.brigadier.arguments.ArgumentType; 22 | import com.mojang.brigadier.context.CommandContext; 23 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 24 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; 25 | import com.mojang.brigadier.suggestion.Suggestions; 26 | import com.mojang.brigadier.suggestion.SuggestionsBuilder; 27 | import com.mojang.serialization.DataResult; 28 | import com.mojang.serialization.DynamicOps; 29 | import com.mojang.serialization.codecs.PrimitiveCodec; 30 | import net.minecraft.text.Text; 31 | import org.jetbrains.annotations.NotNull; 32 | 33 | import java.util.Arrays; 34 | import java.util.Collection; 35 | import java.util.List; 36 | import java.util.Optional; 37 | import java.util.concurrent.CompletableFuture; 38 | import java.util.stream.Collectors; 39 | 40 | /** 41 | * Represents the different tooltip modes for jukeboxes. 42 | */ 43 | public enum JukeboxTooltipMode { 44 | DISABLED, 45 | FAST, 46 | FANCY; 47 | 48 | public static final PrimitiveCodec CODEC = new PrimitiveCodec<>() { 49 | @Override 50 | public DataResult read(final DynamicOps ops, final T input) { 51 | return ops.getStringValue(input).map(id -> byId(id).orElse(DISABLED)); 52 | } 53 | 54 | @Override 55 | public T write(final DynamicOps ops, final JukeboxTooltipMode value) { 56 | return ops.createString(value.getName()); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "JukeboxTooltipMode"; 62 | } 63 | }; 64 | 65 | public boolean isEnabled() { 66 | return this != DISABLED; 67 | } 68 | 69 | /** 70 | * Returns the next jukebox tooltip mode available. 71 | * 72 | * @return the next available jukebox tooltip mode 73 | */ 74 | public JukeboxTooltipMode next() { 75 | var v = values(); 76 | if (v.length == this.ordinal() + 1) 77 | return v[0]; 78 | return v[this.ordinal() + 1]; 79 | } 80 | 81 | public @NotNull String getName() { 82 | return this.name().toLowerCase(); 83 | } 84 | 85 | /** 86 | * Gets the jukebox tooltip mode from its identifier. 87 | * 88 | * @param id the identifier of the jukebox tooltip mode 89 | * @return the jukebox tooltip mode if found, else empty 90 | */ 91 | public static @NotNull Optional byId(@NotNull String id) { 92 | return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); 93 | } 94 | 95 | public static class JukeboxArgumentType implements ArgumentType { 96 | private static final SimpleCommandExceptionType UNKNOWN_VALUE = new SimpleCommandExceptionType( 97 | Text.translatable("advancedtooltips.command.error.unknown_jukebox_tooltip_mode")); 98 | private static final List VALUES = List.of(values()); 99 | 100 | private JukeboxArgumentType() { 101 | } 102 | 103 | public static JukeboxArgumentType jukeboxTooltipMode() { 104 | return new JukeboxArgumentType(); 105 | } 106 | 107 | public static JukeboxTooltipMode getJukeboxTooltipMode(final CommandContext context, final String name) { 108 | return context.getArgument(name, JukeboxTooltipMode.class); 109 | } 110 | 111 | @Override 112 | public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { 113 | VALUES.stream().map(JukeboxTooltipMode::getName) 114 | .filter(s -> s.startsWith(builder.getRemainingLowerCase())) 115 | .forEach(builder::suggest); 116 | return builder.buildFuture(); 117 | } 118 | 119 | @Override 120 | public Collection getExamples() { 121 | return VALUES.stream().map(JukeboxTooltipMode::getName).collect(Collectors.toList()); 122 | } 123 | 124 | @Override 125 | public JukeboxTooltipMode parse(StringReader reader) throws CommandSyntaxException { 126 | var value = reader.readString(); 127 | return VALUES.stream().filter(s -> s.name().equalsIgnoreCase(value)).findFirst().orElseThrow(() -> UNKNOWN_VALUE.createWithContext(reader)); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/SaturationTooltipMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips; 19 | 20 | import com.mojang.brigadier.StringReader; 21 | import com.mojang.brigadier.arguments.ArgumentType; 22 | import com.mojang.brigadier.context.CommandContext; 23 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 24 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; 25 | import com.mojang.brigadier.suggestion.Suggestions; 26 | import com.mojang.brigadier.suggestion.SuggestionsBuilder; 27 | import com.mojang.serialization.DataResult; 28 | import com.mojang.serialization.DynamicOps; 29 | import com.mojang.serialization.codecs.PrimitiveCodec; 30 | 31 | import net.minecraft.text.Text; 32 | 33 | import org.jetbrains.annotations.NotNull; 34 | 35 | import java.util.Arrays; 36 | import java.util.Collection; 37 | import java.util.List; 38 | import java.util.Optional; 39 | import java.util.concurrent.CompletableFuture; 40 | import java.util.stream.Collectors; 41 | 42 | /** 43 | * Represents the different tooltip modes for saturation. 44 | */ 45 | public enum SaturationTooltipMode { 46 | DISABLED, 47 | MERGED, 48 | SEPARATED; 49 | 50 | public static final PrimitiveCodec CODEC = new PrimitiveCodec<>() { 51 | @Override 52 | public DataResult read(final DynamicOps ops, final T input) { 53 | return ops.getStringValue(input).map(id -> byId(id).orElse(DISABLED)); 54 | } 55 | 56 | @Override 57 | public T write(final DynamicOps ops, final SaturationTooltipMode value) { 58 | return ops.createString(value.getName()); 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "SaturationTooltipMode"; 64 | } 65 | }; 66 | 67 | public boolean isEnabled() { 68 | return this != DISABLED; 69 | } 70 | 71 | /** 72 | * Returns the next saturation tooltip mode available. 73 | * 74 | * @return the next available saturation tooltip mode 75 | */ 76 | public SaturationTooltipMode next() { 77 | var v = values(); 78 | if (v.length == this.ordinal() + 1) 79 | return v[0]; 80 | return v[this.ordinal() + 1]; 81 | } 82 | 83 | public @NotNull String getName() { 84 | return this.name().toLowerCase(); 85 | } 86 | 87 | /** 88 | * Gets the saturation tooltip mode from its identifier. 89 | * 90 | * @param id the identifier of the saturation tooltip mode 91 | * @return the saturation tooltip mode if found, else empty 92 | */ 93 | public static @NotNull Optional byId(@NotNull String id) { 94 | return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); 95 | } 96 | 97 | public static class SaturationArgumentType implements ArgumentType { 98 | private static final SimpleCommandExceptionType UNKNOWN_VALUE = new SimpleCommandExceptionType( 99 | Text.translatable("advancedtooltips.command.error.unknown_saturation_tooltip_mode")); 100 | private static final List VALUES = List.of(values()); 101 | 102 | private SaturationArgumentType() { 103 | } 104 | 105 | public static SaturationArgumentType saturationTooltipMode() { 106 | return new SaturationArgumentType(); 107 | } 108 | 109 | public static SaturationTooltipMode getSaturationTooltipMode(final CommandContext context, final String name) { 110 | return context.getArgument(name, SaturationTooltipMode.class); 111 | } 112 | 113 | @Override 114 | public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { 115 | VALUES.stream().map(SaturationTooltipMode::getName) 116 | .filter(s -> s.startsWith(builder.getRemainingLowerCase())) 117 | .forEach(builder::suggest); 118 | return builder.buildFuture(); 119 | } 120 | 121 | @Override 122 | public Collection getExamples() { 123 | return VALUES.stream().map(SaturationTooltipMode::getName).collect(Collectors.toList()); 124 | } 125 | 126 | @Override 127 | public SaturationTooltipMode parse(StringReader reader) throws CommandSyntaxException { 128 | var value = reader.readString(); 129 | return VALUES.stream().filter(s -> s.name().equalsIgnoreCase(value)).findFirst().orElseThrow(() -> UNKNOWN_VALUE.createWithContext(reader)); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/SignTooltipMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips; 19 | 20 | import com.mojang.brigadier.StringReader; 21 | import com.mojang.brigadier.arguments.ArgumentType; 22 | import com.mojang.brigadier.context.CommandContext; 23 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 24 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; 25 | import com.mojang.brigadier.suggestion.Suggestions; 26 | import com.mojang.brigadier.suggestion.SuggestionsBuilder; 27 | import com.mojang.serialization.DataResult; 28 | import com.mojang.serialization.DynamicOps; 29 | import com.mojang.serialization.codecs.PrimitiveCodec; 30 | import net.minecraft.text.Text; 31 | import org.jetbrains.annotations.NotNull; 32 | 33 | import java.util.Arrays; 34 | import java.util.Collection; 35 | import java.util.List; 36 | import java.util.Optional; 37 | import java.util.concurrent.CompletableFuture; 38 | import java.util.stream.Collectors; 39 | 40 | /** 41 | * Represents the different tooltip modes for signs. 42 | */ 43 | public enum SignTooltipMode { 44 | DISABLED, 45 | FAST, 46 | FANCY; 47 | 48 | public static final PrimitiveCodec CODEC = new PrimitiveCodec() { 49 | @Override 50 | public DataResult read(final DynamicOps ops, final T input) { 51 | return ops.getStringValue(input).map(id -> byId(id).orElse(DISABLED)); 52 | } 53 | 54 | @Override 55 | public T write(final DynamicOps ops, final SignTooltipMode value) { 56 | return ops.createString(value.getName()); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "SignTooltipMode"; 62 | } 63 | }; 64 | 65 | public boolean isEnabled() { 66 | return this != DISABLED; 67 | } 68 | 69 | /** 70 | * Returns the next sign tooltip mode available. 71 | * 72 | * @return the next available sign tooltip mode 73 | */ 74 | public SignTooltipMode next() { 75 | var v = values(); 76 | if (v.length == this.ordinal() + 1) 77 | return v[0]; 78 | return v[this.ordinal() + 1]; 79 | } 80 | 81 | public @NotNull String getName() { 82 | return this.name().toLowerCase(); 83 | } 84 | 85 | /** 86 | * Gets the sign tooltip mode from its identifier. 87 | * 88 | * @param id the identifier of the sign tooltip mode 89 | * @return the sign tooltip mode if found, else empty 90 | */ 91 | public static @NotNull Optional byId(@NotNull String id) { 92 | return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); 93 | } 94 | 95 | public static class SignArgumentType implements ArgumentType { 96 | private static final SimpleCommandExceptionType UNKNOWN_VALUE = new SimpleCommandExceptionType( 97 | Text.translatable("advancedtooltips.command.error.unknown_sign_tooltip_mode")); 98 | private static final List VALUES = List.of(values()); 99 | 100 | private SignArgumentType() { 101 | } 102 | 103 | public static SignArgumentType signTooltipMode() { 104 | return new SignArgumentType(); 105 | } 106 | 107 | public static SignTooltipMode getSignTooltipMode(final CommandContext context, final String name) { 108 | return context.getArgument(name, SignTooltipMode.class); 109 | } 110 | 111 | @Override 112 | public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { 113 | VALUES.stream().map(SignTooltipMode::getName) 114 | .filter(s -> s.startsWith(builder.getRemainingLowerCase())) 115 | .forEach(builder::suggest); 116 | return builder.buildFuture(); 117 | } 118 | 119 | @Override 120 | public Collection getExamples() { 121 | return VALUES.stream().map(SignTooltipMode::getName).collect(Collectors.toList()); 122 | } 123 | 124 | @Override 125 | public SignTooltipMode parse(StringReader reader) throws CommandSyntaxException { 126 | var value = reader.readString(); 127 | return VALUES.stream().filter(s -> s.name().equalsIgnoreCase(value)).findFirst().orElseThrow(() -> UNKNOWN_VALUE.createWithContext(reader)); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/api/AdvancedTooltipsEntrypoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.api; 19 | 20 | import net.fabricmc.api.EnvType; 21 | import net.fabricmc.api.Environment; 22 | 23 | /** 24 | * Represents the Advanced Tooltips entrypoint, useful for using our API stuff. 25 | */ 26 | @Environment(EnvType.CLIENT) 27 | public interface AdvancedTooltipsEntrypoint { 28 | void onAdvancedTooltipsInitialized(); 29 | } 30 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/api/InventoryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.api; 19 | 20 | import net.fabricmc.api.EnvType; 21 | import net.fabricmc.api.Environment; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import net.minecraft.util.DyeColor; 25 | import org.jetbrains.annotations.Nullable; 26 | 27 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 28 | 29 | import java.util.List; 30 | 31 | /** 32 | * Provides an inventory context for the given item stack. 33 | */ 34 | @Environment(EnvType.CLIENT) 35 | @FunctionalInterface 36 | public interface InventoryProvider { 37 | /** 38 | * Returns the inventory context of the given item stack. 39 | * 40 | * @param stack the item stack 41 | * @return {@code null} if no inventory context could be created, otherwise an inventory context 42 | */ 43 | @Nullable InventoryProvider.Context getInventoryContext(ItemStack stack, @Nullable AdvancedTooltipsConfig.StorageContainerConfig config); 44 | 45 | static @Nullable InventoryProvider.Context searchInventoryContextOf(ItemStack stack, @Nullable AdvancedTooltipsConfig.StorageContainerConfig config) { 46 | return InventoryProviderManager.getInventoryContext(stack, config); 47 | } 48 | 49 | /** 50 | * Registers an inventory provider, can optionally be mapped to specific items. 51 | * 52 | * @param provider the inventory provider to register 53 | * @param items if non-empty, the inventory provider will be only registered for those items 54 | */ 55 | static void register(InventoryProvider provider, Item... items) { 56 | if (items.length != 0) { 57 | for (var item : items) { 58 | InventoryProviderManager.MAPPED_PROVIDERS.put(item, provider); 59 | } 60 | } else { 61 | InventoryProviderManager.PROVIDERS.add(provider); 62 | } 63 | } 64 | 65 | record Context(List inventory, @Nullable DyeColor color) { 66 | int getColumns() { 67 | return this.inventory.size() % 3 == 0 ? this.inventory.size() / 3 : this.inventory.size(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/api/InventoryProviderManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.api; 19 | 20 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; 21 | import net.fabricmc.api.EnvType; 22 | import net.fabricmc.api.Environment; 23 | import net.minecraft.item.Item; 24 | import net.minecraft.item.ItemStack; 25 | import org.jetbrains.annotations.ApiStatus; 26 | import org.jetbrains.annotations.Nullable; 27 | 28 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.Map; 33 | 34 | @Environment(EnvType.CLIENT) 35 | @ApiStatus.Internal 36 | final class InventoryProviderManager { 37 | static final Map MAPPED_PROVIDERS = new Object2ObjectOpenHashMap<>(); 38 | static final List PROVIDERS = new ArrayList<>(); 39 | 40 | static @Nullable InventoryProvider.Context getInventoryContext(ItemStack stack, @Nullable AdvancedTooltipsConfig.StorageContainerConfig config) { 41 | // We first search for providers that are specifically mapped to the given item. 42 | var mappedProvider = MAPPED_PROVIDERS.get(stack.getItem()); 43 | if (mappedProvider != null) { 44 | InventoryProvider.Context context = mappedProvider.getInventoryContext(stack, config); 45 | if (context != null) { 46 | return context; 47 | } 48 | } 49 | 50 | // Otherwise, we search for the one who provides the biggest inventory for the given item (most likely to be the most complete one) 51 | // Note: inventory compacting happens in the inventory tooltip component directly. 52 | InventoryProvider.Context context = null; 53 | for (var provider : PROVIDERS) { 54 | var currentContext = provider.getInventoryContext(stack, config); 55 | 56 | if (currentContext != null) { 57 | if (context == null || currentContext.inventory().size() > context.inventory().size()) { 58 | context = currentContext; 59 | } 60 | } 61 | } 62 | 63 | return context; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/ArmorStandItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipData; 21 | import net.minecraft.item.ArmorStandItem; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import org.spongepowered.asm.mixin.Mixin; 25 | 26 | import com.github.reviversmc.advancedtooltips.tooltip.ArmorStandTooltipComponent; 27 | 28 | import java.util.Optional; 29 | 30 | @Mixin(ArmorStandItem.class) 31 | public class ArmorStandItemMixin extends Item { 32 | public ArmorStandItemMixin(Item.Settings settings) { 33 | super(settings); 34 | } 35 | 36 | @Override 37 | public Optional getTooltipData(ItemStack stack) { 38 | return ArmorStandTooltipComponent.of(stack.getOrCreateNbt()).or(() -> super.getTooltipData(stack)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/BannerPatternItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.block.entity.BannerPattern; 21 | import net.minecraft.client.item.TooltipData; 22 | import net.minecraft.item.BannerPatternItem; 23 | import net.minecraft.item.Item; 24 | import net.minecraft.item.ItemStack; 25 | import net.minecraft.tag.TagKey; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | import org.spongepowered.asm.mixin.Shadow; 28 | 29 | import com.github.reviversmc.advancedtooltips.tooltip.BannerTooltipComponent; 30 | 31 | import java.util.Optional; 32 | 33 | @Mixin(BannerPatternItem.class) 34 | public abstract class BannerPatternItemMixin extends Item { 35 | @Shadow 36 | public abstract TagKey getPattern(); 37 | 38 | public BannerPatternItemMixin(Settings settings) { 39 | super(settings); 40 | } 41 | 42 | @Override 43 | public Optional getTooltipData(ItemStack stack) { 44 | return BannerTooltipComponent.of(this.getPattern()).or(() -> super.getTooltipData(stack)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/BlockItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.block.*; 21 | import net.minecraft.client.gui.screen.Screen; 22 | import net.minecraft.client.item.TooltipContext; 23 | import net.minecraft.client.item.TooltipData; 24 | import net.minecraft.entity.effect.StatusEffectInstance; 25 | import net.minecraft.item.BlockItem; 26 | import net.minecraft.item.Item; 27 | import net.minecraft.item.ItemStack; 28 | import net.minecraft.text.Text; 29 | import net.minecraft.world.World; 30 | import org.spongepowered.asm.mixin.Mixin; 31 | import org.spongepowered.asm.mixin.Shadow; 32 | import org.spongepowered.asm.mixin.injection.At; 33 | import org.spongepowered.asm.mixin.injection.Inject; 34 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 35 | 36 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 37 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 38 | import com.github.reviversmc.advancedtooltips.api.InventoryProvider; 39 | import com.github.reviversmc.advancedtooltips.tooltip.*; 40 | 41 | import java.util.ArrayList; 42 | import java.util.List; 43 | import java.util.Optional; 44 | 45 | @Mixin(BlockItem.class) 46 | public abstract class BlockItemMixin extends Item { 47 | @Shadow 48 | public abstract Block getBlock(); 49 | 50 | public BlockItemMixin(Settings settings) { 51 | super(settings); 52 | } 53 | 54 | @Override 55 | public Optional getTooltipData(ItemStack stack) { 56 | var config = AdvancedTooltips.getConfig(); 57 | var containersConfig = config.getContainersConfig(); 58 | var effectsConfig = config.getEffectsConfig(); 59 | 60 | if (effectsConfig.hasBeacon() && this.getBlock() instanceof BeaconBlock) { 61 | var blockEntityTag = BlockItem.getBlockEntityNbtFromStack(stack); 62 | var effectsList = new ArrayList(); 63 | var primary = AdvancedTooltips.getRawEffectFromTag(blockEntityTag, "Primary"); 64 | var secondary = AdvancedTooltips.getRawEffectFromTag(blockEntityTag, "Secondary"); 65 | 66 | if (primary != null && primary.equals(secondary)) { 67 | primary = new StatusEffectInstance(primary.getEffectType(), 200, 1); 68 | secondary = null; 69 | } 70 | if (primary != null) 71 | effectsList.add(primary); 72 | if (secondary != null) 73 | effectsList.add(secondary); 74 | 75 | return Optional.of(new StatusEffectTooltipComponent(effectsList, 1F)); 76 | } else if (this.getBlock() instanceof BeehiveBlock) { 77 | var data = BeesTooltipComponent.of(stack); 78 | if (data.isPresent()) return data; 79 | } else if (this.getBlock() instanceof CampfireBlock) { 80 | var data = CampfireTooltipComponent.of(stack); 81 | if (data.isPresent()) return data; 82 | } else if (this.getBlock() instanceof JukeboxBlock) { 83 | var data = JukeboxTooltipComponent.of(stack); 84 | if (data.isPresent()) return data; 85 | } else if (this.getBlock() instanceof SpawnerBlock) { 86 | var data = SpawnEntityTooltipComponent.ofMobSpawner(stack); 87 | if (data.isPresent()) return data; 88 | } else { 89 | AdvancedTooltipsConfig.StorageContainerConfig currentBlockConfig = containersConfig.forBlock(this.getBlock()); 90 | InventoryProvider.Context context = InventoryProvider.searchInventoryContextOf(stack, currentBlockConfig); 91 | 92 | if (currentBlockConfig == null) { 93 | currentBlockConfig = containersConfig.getStorageConfig(); 94 | } 95 | 96 | if (context != null) { 97 | return InventoryTooltipComponent.of(stack, currentBlockConfig.isCompact(), context); 98 | } 99 | } 100 | 101 | return super.getTooltipData(stack); 102 | } 103 | 104 | @Inject(method = "appendTooltip", at = @At("HEAD"), cancellable = true) 105 | private void onAppendTooltip(ItemStack stack, World world, List tooltip, TooltipContext context, CallbackInfo ci) { 106 | if (this.getBlock() instanceof ShulkerBoxBlock && !Screen.hasControlDown()) { 107 | AdvancedTooltips.appendBlockItemTooltip(stack, this.getBlock(), tooltip); 108 | ci.cancel(); 109 | } 110 | } 111 | 112 | @Inject(method = "appendTooltip", at = @At("TAIL")) 113 | private void onAppendTooltipEnd(ItemStack stack, World world, List tooltip, TooltipContext context, CallbackInfo ci) { 114 | AdvancedTooltips.appendBlockItemTooltip(stack, this.getBlock(), tooltip); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/CameraAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.render.Camera; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.gen.Accessor; 23 | 24 | @Mixin(Camera.class) 25 | public interface CameraAccessor { 26 | @Accessor("yaw") 27 | void setYaw(float yaw); 28 | 29 | } -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/EntityAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.entity.Entity; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.gen.Accessor; 23 | 24 | @Mixin(Entity.class) 25 | public interface EntityAccessor { 26 | @Accessor("touchingWater") 27 | void setTouchingWater(boolean touchingWater); 28 | 29 | @Accessor 30 | boolean getHasVisualFire(); 31 | } 32 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/EntityBucketItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipData; 21 | import net.minecraft.entity.EntityType; 22 | import net.minecraft.item.EntityBucketItem; 23 | import net.minecraft.item.Item; 24 | import net.minecraft.item.ItemStack; 25 | import org.spongepowered.asm.mixin.Final; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | import org.spongepowered.asm.mixin.Shadow; 28 | 29 | import com.github.reviversmc.advancedtooltips.tooltip.EntityBucketTooltipComponent; 30 | 31 | import java.util.Optional; 32 | 33 | @Mixin(EntityBucketItem.class) 34 | public abstract class EntityBucketItemMixin extends Item { 35 | @Shadow 36 | @Final 37 | private EntityType entityType; 38 | 39 | public EntityBucketItemMixin(Settings settings) { 40 | super(settings); 41 | } 42 | 43 | @Override 44 | public Optional getTooltipData(ItemStack stack) { 45 | return EntityBucketTooltipComponent.of(this.entityType, stack.getOrCreateNbt()).or(() -> super.getTooltipData(stack)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/FilledMapItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipData; 21 | import net.minecraft.item.FilledMapItem; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import org.spongepowered.asm.mixin.Mixin; 25 | 26 | import com.github.reviversmc.advancedtooltips.tooltip.MapTooltipComponent; 27 | 28 | import java.util.Optional; 29 | 30 | @Mixin(FilledMapItem.class) 31 | public abstract class FilledMapItemMixin extends Item { 32 | 33 | public FilledMapItemMixin(Settings settings) { 34 | super(settings); 35 | } 36 | 37 | @Override 38 | public Optional getTooltipData(ItemStack stack) { 39 | return MapTooltipComponent.of(stack).or(() -> super.getTooltipData(stack)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/ItemEntityAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.entity.ItemEntity; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.Mutable; 23 | import org.spongepowered.asm.mixin.gen.Accessor; 24 | 25 | @Mixin(ItemEntity.class) 26 | public interface ItemEntityAccessor { 27 | @Accessor 28 | void setItemAge(int age); 29 | 30 | @Mutable 31 | @Accessor 32 | void setUniqueOffset(float uniqueOffset); 33 | } 34 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/ItemStackMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; 21 | import net.minecraft.client.item.TooltipContext; 22 | import net.minecraft.client.item.TooltipData; 23 | import net.minecraft.entity.effect.StatusEffect; 24 | import net.minecraft.entity.effect.StatusEffectInstance; 25 | import net.minecraft.entity.player.PlayerEntity; 26 | import net.minecraft.item.*; 27 | import net.minecraft.nbt.NbtCompound; 28 | import net.minecraft.nbt.NbtElement; 29 | import net.minecraft.potion.PotionUtil; 30 | import net.minecraft.text.Text; 31 | import net.minecraft.util.Formatting; 32 | import net.minecraft.util.dynamic.GlobalPos; 33 | import net.minecraft.util.math.BlockPos; 34 | import org.jetbrains.annotations.Nullable; 35 | import org.spongepowered.asm.mixin.Mixin; 36 | import org.spongepowered.asm.mixin.Shadow; 37 | import org.spongepowered.asm.mixin.Unique; 38 | import org.spongepowered.asm.mixin.injection.At; 39 | import org.spongepowered.asm.mixin.injection.Inject; 40 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 41 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 42 | 43 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 44 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 45 | import com.github.reviversmc.advancedtooltips.tooltip.*; 46 | 47 | import java.util.ArrayList; 48 | import java.util.List; 49 | import java.util.Optional; 50 | 51 | @Mixin(ItemStack.class) 52 | public abstract class ItemStackMixin { 53 | @Shadow 54 | public abstract int getRepairCost(); 55 | 56 | @Shadow 57 | public abstract Item getItem(); 58 | 59 | @Shadow 60 | @Nullable 61 | public abstract NbtCompound getNbt(); 62 | 63 | @Unique 64 | private final ThreadLocal> advancedtooltips$tooltipList = new ThreadLocal<>(); 65 | 66 | @Inject( 67 | method = "getTooltip", 68 | at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;hasCustomName()Z"), 69 | locals = LocalCapture.CAPTURE_FAILHARD 70 | ) 71 | private void onGetTooltipBeing(PlayerEntity player, TooltipContext context, CallbackInfoReturnable> cir, List list) { 72 | this.advancedtooltips$tooltipList.set(list); 73 | } 74 | 75 | @Inject( 76 | method = "getTooltip", 77 | at = @At(value = "RETURN") 78 | ) 79 | private void onGetTooltip(PlayerEntity player, TooltipContext context, CallbackInfoReturnable> cir) { 80 | var tooltip = this.advancedtooltips$tooltipList.get(); 81 | AdvancedTooltipsConfig.AdvancedConfig advancedTooltipsConfig = AdvancedTooltips.getConfig().getAdvancedConfig(); 82 | 83 | if (advancedTooltipsConfig.hasLodestoneCoords() && this.getItem() instanceof CompassItem && CompassItem.hasLodestone((ItemStack) (Object) this)) { 84 | var nbt = this.getNbt(); 85 | assert nbt != null; // Should not be null since hasLodestone returns true. 86 | GlobalPos globalPos = CompassItem.getLodestonePosition(nbt); 87 | 88 | if (globalPos != null) { 89 | BlockPos pos = globalPos.getPos(); 90 | var posText = Text.literal(String.format("X: %d, Y: %d, Z: %d", pos.getX(), pos.getY(), pos.getZ())) 91 | .formatted(Formatting.GOLD); 92 | 93 | tooltip.add(Text.translatable("advancedtooltips.tooltip.lodestone_compass.target", posText).formatted(Formatting.GRAY)); 94 | tooltip.add(Text.translatable("advancedtooltips.tooltip.lodestone_compass.dimension", 95 | Text.literal(globalPos.getDimension().getValue().toString()).formatted(Formatting.GOLD)) 96 | .formatted(Formatting.GRAY)); 97 | } 98 | } 99 | 100 | int repairCost; 101 | if (advancedTooltipsConfig.hasRepairCost() && (repairCost = this.getRepairCost()) != 0) { 102 | tooltip.add(Text.translatable("advancedtooltips.tooltip.repair_cost", repairCost) 103 | .formatted(Formatting.GRAY)); 104 | } 105 | } 106 | 107 | @Inject(method = "getTooltipData", at = @At("RETURN"), cancellable = true) 108 | private void getTooltipData(CallbackInfoReturnable> info) { 109 | // Data is the plural and datum is the singular actually, but no one cares 110 | var datas = new ArrayList(); 111 | info.getReturnValue().ifPresent(datas::add); 112 | 113 | var config = AdvancedTooltips.getConfig(); 114 | var stack = (ItemStack) (Object) this; 115 | 116 | if (stack.isFood()) { 117 | var comp = stack.getItem().getFoodComponent(); 118 | 119 | if (config.getFoodConfig().isEnabled()) { 120 | datas.add(new FoodTooltipComponent(comp)); 121 | } 122 | 123 | if (config.getEffectsConfig().hasPotions()) { 124 | if (stack.isIn(AdvancedTooltips.HIDDEN_EFFECTS_TAG) 125 | || AdvancedTooltips.hiddenEffectsItems.contains(stack.getItem())) { 126 | datas.add(new StatusEffectTooltipComponent()); 127 | } else { 128 | if (comp.getStatusEffects().size() > 0) { 129 | datas.add(new StatusEffectTooltipComponent(comp.getStatusEffects())); 130 | } else if (stack.getItem() instanceof SuspiciousStewItem) { 131 | var nbt = stack.getNbt(); 132 | if (nbt != null && nbt.contains(SuspiciousStewItem.EFFECTS_KEY, NbtElement.LIST_TYPE)) { 133 | var effects = new ArrayList(); 134 | var effectsNbt = nbt.getList(SuspiciousStewItem.EFFECTS_KEY, NbtElement.COMPOUND_TYPE); 135 | 136 | for (int i = 0; i < effectsNbt.size(); ++i) { 137 | int duration = 160; 138 | var effectNbt = effectsNbt.getCompound(i); 139 | if (effectNbt.contains(SuspiciousStewItem.EFFECT_DURATION_KEY, NbtElement.INT_TYPE)) { 140 | duration = effectNbt.getInt(SuspiciousStewItem.EFFECT_DURATION_KEY); 141 | } 142 | 143 | var statusEffect = StatusEffect.byRawId(effectNbt.getByte(SuspiciousStewItem.EFFECT_ID_KEY)); 144 | if (statusEffect != null) { 145 | effects.add(new StatusEffectInstance(statusEffect, duration)); 146 | } 147 | } 148 | 149 | datas.add(new StatusEffectTooltipComponent(effects, 1.f)); 150 | } 151 | } else { 152 | datas.add(new StatusEffectTooltipComponent(PotionUtil.getPotionEffects(stack), 1.f)); 153 | } 154 | } 155 | } 156 | } 157 | 158 | if (stack.getItem() instanceof ArmorItem armor && config.hasArmor()) { 159 | int prot = armor.getMaterial().getProtectionAmount(armor.getSlotType()); 160 | datas.add(new ArmorTooltipComponent(prot)); 161 | } 162 | 163 | if (datas.size() == 1) { 164 | info.setReturnValue(Optional.of(datas.get(0))); 165 | } else if (datas.size() > 1) { 166 | var comp = new CompoundTooltipComponent(); 167 | for (var data : datas) { 168 | if (data instanceof ConvertibleTooltipData convertibleTooltipData) { 169 | comp.addComponent(convertibleTooltipData.getComponent()); 170 | } else { 171 | comp.addComponent(TooltipComponentCallback.EVENT.invoker().getComponent(data)); 172 | } 173 | } 174 | info.setReturnValue(Optional.of(comp)); 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/LingeringPotionItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipContext; 21 | import net.minecraft.item.ItemStack; 22 | import net.minecraft.item.LingeringPotionItem; 23 | import net.minecraft.text.Text; 24 | import net.minecraft.world.World; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.injection.At; 27 | import org.spongepowered.asm.mixin.injection.Inject; 28 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 29 | 30 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 31 | 32 | import java.util.List; 33 | 34 | @Mixin(LingeringPotionItem.class) 35 | public class LingeringPotionItemMixin { 36 | 37 | @Inject(at = @At("HEAD"), method = "appendTooltip", cancellable = true) 38 | public void appendTooltip(ItemStack stack, World world, List tooltip, TooltipContext context, CallbackInfo info) { 39 | if (AdvancedTooltips.getConfig().getEffectsConfig().hasPotions()) info.cancel(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/PotionItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipContext; 21 | import net.minecraft.client.item.TooltipData; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import net.minecraft.item.PotionItem; 25 | import net.minecraft.potion.PotionUtil; 26 | import net.minecraft.text.Text; 27 | import net.minecraft.world.World; 28 | import org.jetbrains.annotations.Nullable; 29 | import org.spongepowered.asm.mixin.Mixin; 30 | import org.spongepowered.asm.mixin.Unique; 31 | import org.spongepowered.asm.mixin.injection.At; 32 | import org.spongepowered.asm.mixin.injection.Inject; 33 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 34 | 35 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 36 | import com.github.reviversmc.advancedtooltips.tooltip.StatusEffectTooltipComponent; 37 | 38 | import java.util.List; 39 | import java.util.Optional; 40 | 41 | @Mixin(PotionItem.class) 42 | public abstract class PotionItemMixin extends Item { 43 | @Unique 44 | private final ThreadLocal advancedtooltips$oldTooltipLength = new ThreadLocal<>(); // ThreadLocal as REI workaround 45 | 46 | public PotionItemMixin(Settings settings) { 47 | super(settings); 48 | } 49 | 50 | @Inject(method = "appendTooltip", at = @At("HEAD")) 51 | private void onAppendTooltipPre(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context, CallbackInfo ci) { 52 | this.advancedtooltips$oldTooltipLength.set(tooltip.size()); 53 | } 54 | 55 | @Inject(method = "appendTooltip", at = @At("RETURN")) 56 | private void onAppendTooltipPost(ItemStack stack, World world, List tooltip, TooltipContext context, CallbackInfo info) { 57 | if (AdvancedTooltips.getConfig().getEffectsConfig().hasPotions()) { 58 | AdvancedTooltips.removeVanillaTooltips(tooltip, this.advancedtooltips$oldTooltipLength.get()); 59 | } 60 | } 61 | 62 | @Override 63 | public Optional getTooltipData(ItemStack stack) { 64 | if (!AdvancedTooltips.getConfig().getEffectsConfig().hasPotions()) return super.getTooltipData(stack); 65 | return Optional.of(new StatusEffectTooltipComponent(PotionUtil.getPotionEffects(stack), 1.f)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/SignItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.block.Block; 21 | import net.minecraft.client.item.TooltipData; 22 | import net.minecraft.item.ItemStack; 23 | import net.minecraft.item.SignItem; 24 | import net.minecraft.item.WallStandingBlockItem; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | 27 | import com.github.reviversmc.advancedtooltips.tooltip.SignTooltipComponent; 28 | 29 | import java.util.Optional; 30 | 31 | @Mixin(SignItem.class) 32 | public class SignItemMixin extends WallStandingBlockItem { 33 | public SignItemMixin(Block standingBlock, Block wallBlock, Settings settings) { 34 | super(standingBlock, wallBlock, settings); 35 | } 36 | 37 | @Override 38 | public Optional getTooltipData(ItemStack stack) { 39 | return SignTooltipComponent.fromItemStack(stack).or(() -> super.getTooltipData(stack)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/SpawnEggItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipData; 21 | import net.minecraft.entity.EntityType; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import net.minecraft.item.SpawnEggItem; 25 | import org.spongepowered.asm.mixin.Final; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | import org.spongepowered.asm.mixin.Shadow; 28 | 29 | import com.github.reviversmc.advancedtooltips.tooltip.SpawnEntityTooltipComponent; 30 | 31 | import java.util.Optional; 32 | 33 | @Mixin(SpawnEggItem.class) 34 | public class SpawnEggItemMixin extends Item { 35 | @Shadow 36 | @Final 37 | private EntityType type; 38 | 39 | public SpawnEggItemMixin(Settings settings) { 40 | super(settings); 41 | } 42 | 43 | @Override 44 | public Optional getTooltipData(ItemStack stack) { 45 | return SpawnEntityTooltipComponent.of(this.type, stack.getOrCreateNbt()).or(() -> super.getTooltipData(stack)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/SpectralArrowItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipData; 21 | import net.minecraft.entity.effect.StatusEffectInstance; 22 | import net.minecraft.entity.effect.StatusEffects; 23 | import net.minecraft.item.ArrowItem; 24 | import net.minecraft.item.ItemStack; 25 | import net.minecraft.item.SpectralArrowItem; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | 28 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 29 | import com.github.reviversmc.advancedtooltips.tooltip.StatusEffectTooltipComponent; 30 | 31 | import java.util.Collections; 32 | import java.util.Optional; 33 | 34 | @Mixin(SpectralArrowItem.class) 35 | public class SpectralArrowItemMixin extends ArrowItem { 36 | public SpectralArrowItemMixin(Settings settings) { 37 | super(settings); 38 | } 39 | 40 | @Override 41 | public Optional getTooltipData(ItemStack stack) { 42 | if (!AdvancedTooltips.getConfig().getEffectsConfig().hasSpectralArrow()) return super.getTooltipData(stack); 43 | return Optional.of(new StatusEffectTooltipComponent(Collections.singletonList(new StatusEffectInstance(StatusEffects.GLOWING, 200, 0)), 1.f)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/TippedArrowItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.client.item.TooltipContext; 21 | import net.minecraft.client.item.TooltipData; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | import net.minecraft.item.TippedArrowItem; 25 | import net.minecraft.potion.PotionUtil; 26 | import net.minecraft.text.Text; 27 | import net.minecraft.world.World; 28 | import org.jetbrains.annotations.Nullable; 29 | import org.spongepowered.asm.mixin.Mixin; 30 | import org.spongepowered.asm.mixin.Unique; 31 | import org.spongepowered.asm.mixin.injection.At; 32 | import org.spongepowered.asm.mixin.injection.Inject; 33 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 34 | 35 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 36 | import com.github.reviversmc.advancedtooltips.tooltip.StatusEffectTooltipComponent; 37 | 38 | import java.util.List; 39 | import java.util.Optional; 40 | 41 | @Mixin(TippedArrowItem.class) 42 | public abstract class TippedArrowItemMixin extends Item { 43 | @Unique 44 | private final ThreadLocal advancedtooltips$oldTooltipLength = new ThreadLocal<>(); // ThreadLocal as REI workaround 45 | 46 | public TippedArrowItemMixin(Settings settings) { 47 | super(settings); 48 | } 49 | 50 | @Inject(method = "appendTooltip", at = @At("HEAD")) 51 | private void onAppendTooltipPre(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context, CallbackInfo ci) { 52 | this.advancedtooltips$oldTooltipLength.set(tooltip.size()); 53 | } 54 | 55 | @Inject(method = "appendTooltip", at = @At("RETURN")) 56 | private void onAppendTooltipPost(ItemStack stack, World world, List tooltip, TooltipContext context, CallbackInfo info) { 57 | if (AdvancedTooltips.getConfig().getEffectsConfig().hasTippedArrows()) { 58 | AdvancedTooltips.removeVanillaTooltips(tooltip, this.advancedtooltips$oldTooltipLength.get()); 59 | } 60 | } 61 | 62 | @Override 63 | public Optional getTooltipData(ItemStack stack) { 64 | if (!AdvancedTooltips.getConfig().getEffectsConfig().hasTippedArrows()) return super.getTooltipData(stack); 65 | return Optional.of(new StatusEffectTooltipComponent(PotionUtil.getPotionEffects(stack), 0.125F)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/mixin/WitherEntityAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.mixin; 19 | 20 | import net.minecraft.entity.boss.WitherEntity; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.gen.Accessor; 23 | 24 | @Mixin(WitherEntity.class) 25 | public interface WitherEntityAccessor { 26 | @Accessor 27 | float[] getSideHeadYaws(); 28 | } 29 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/ArmorStandTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.MinecraftClient; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.gui.screen.Screen; 23 | import net.minecraft.client.item.TooltipData; 24 | import net.minecraft.client.render.item.ItemRenderer; 25 | import net.minecraft.client.util.math.MatrixStack; 26 | import net.minecraft.entity.Entity; 27 | import net.minecraft.entity.EntityType; 28 | import net.minecraft.nbt.NbtCompound; 29 | 30 | import java.util.Optional; 31 | 32 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 33 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 34 | import com.github.reviversmc.advancedtooltips.mixin.EntityAccessor; 35 | 36 | /** 37 | * Represents an armor stand tooltip. Displays an armor stand and its armor. 38 | */ 39 | public class ArmorStandTooltipComponent extends EntityTooltipComponent { 40 | private final Entity entity; 41 | 42 | public ArmorStandTooltipComponent(AdvancedTooltipsConfig.EntityConfig config, Entity entity) { 43 | super(config); 44 | this.entity = entity; 45 | } 46 | 47 | public static Optional of(NbtCompound itemNbt) { 48 | var entitiesConfig = AdvancedTooltips.getConfig().getEntitiesConfig(); 49 | var entityType = EntityType.ARMOR_STAND; 50 | if (!entitiesConfig.getArmorStandConfig().isEnabled()) 51 | return Optional.empty(); 52 | 53 | var client = MinecraftClient.getInstance(); 54 | var entity = entityType.create(client.world); 55 | assert entity != null; 56 | adjustEntity(entity, itemNbt, entitiesConfig); 57 | var itemEntityNbt = itemNbt.getCompound("EntityTag").copy(); 58 | var entityTag = entity.writeNbt(new NbtCompound()); 59 | var uuid = entity.getUuid(); 60 | entityTag.copyFrom(itemEntityNbt); 61 | entity.setUuid(uuid); 62 | entity.readNbt(entityTag); 63 | return Optional.of(new ArmorStandTooltipComponent(entitiesConfig.getArmorStandConfig(), entity)); 64 | } 65 | 66 | @Override 67 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 68 | if (this.shouldRender()) { 69 | matrices.push(); 70 | matrices.translate(30, 0, z); 71 | ((EntityAccessor) this.entity).setTouchingWater(true); 72 | this.entity.setVelocity(1.f, 1.f, 1.f); 73 | this.renderEntity(matrices, x + 20, y + 12, this.entity, 0, this.config.shouldSpin(), true, 180.f); 74 | matrices.pop(); 75 | } 76 | } 77 | 78 | @Override 79 | public int getHeight() { 80 | return super.getHeight() + 16; 81 | } 82 | 83 | @Override 84 | public int getWidth(TextRenderer textRenderer) { 85 | return 128; 86 | } 87 | 88 | @Override 89 | protected boolean shouldRender() { 90 | return this.entity != null; 91 | } 92 | 93 | @Override 94 | protected boolean shouldRenderCustomNames() { 95 | return this.entity.hasCustomName() && (this.config.shouldAlwaysShowName() || Screen.hasControlDown()); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/ArmorTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.mojang.blaze3d.systems.RenderSystem; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.gui.DrawableHelper; 23 | import net.minecraft.client.gui.hud.InGameHud; 24 | import net.minecraft.client.gui.tooltip.TooltipComponent; 25 | import net.minecraft.client.render.item.ItemRenderer; 26 | import net.minecraft.client.util.math.MatrixStack; 27 | 28 | public class ArmorTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 29 | private final int prot; 30 | 31 | public ArmorTooltipComponent(int prot) { 32 | this.prot = prot; 33 | } 34 | 35 | @Override 36 | public TooltipComponent getComponent() { 37 | return this; 38 | } 39 | 40 | @Override 41 | public int getHeight() { 42 | return 11; 43 | } 44 | 45 | @Override 46 | public int getWidth(TextRenderer textRenderer) { 47 | return this.prot / 2 * 9; 48 | } 49 | 50 | @Override 51 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 52 | RenderSystem.setShaderTexture(0, InGameHud.GUI_ICONS_TEXTURE); 53 | for (int i = 0; i < this.prot / 2; i++) { 54 | DrawableHelper.drawTexture(matrices, x + i * 9, y, 34, 9, 9, 9, 256, 256); 55 | } 56 | if (this.prot % 2 == 1) { 57 | DrawableHelper.drawTexture(matrices, x + this.prot / 2 * 9, y, 25, 9, 9, 9, 256, 256); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/BannerTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 21 | import com.google.common.collect.ImmutableList; 22 | import com.mojang.blaze3d.lighting.DiffuseLighting; 23 | 24 | import net.minecraft.block.entity.BannerBlockEntity; 25 | import net.minecraft.block.entity.BannerPattern; 26 | import net.minecraft.client.MinecraftClient; 27 | import net.minecraft.client.font.TextRenderer; 28 | import net.minecraft.client.gui.tooltip.TooltipComponent; 29 | import net.minecraft.client.item.TooltipData; 30 | import net.minecraft.client.model.ModelPart; 31 | import net.minecraft.client.render.LightmapTextureManager; 32 | import net.minecraft.client.render.OverlayTexture; 33 | import net.minecraft.client.render.block.entity.BannerBlockEntityRenderer; 34 | import net.minecraft.client.render.entity.model.EntityModelLayers; 35 | import net.minecraft.client.render.item.ItemRenderer; 36 | import net.minecraft.client.render.model.ModelLoader; 37 | import net.minecraft.client.util.math.MatrixStack; 38 | import net.minecraft.nbt.NbtList; 39 | import net.minecraft.tag.TagKey; 40 | import net.minecraft.util.DyeColor; 41 | import net.minecraft.util.registry.Registry; 42 | 43 | import java.util.Optional; 44 | 45 | public class BannerTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 46 | private final MinecraftClient client = MinecraftClient.getInstance(); 47 | private final NbtList pattern; 48 | private final ModelPart bannerField; 49 | 50 | private BannerTooltipComponent(NbtList pattern) { 51 | this.pattern = pattern; 52 | this.bannerField = this.client.getEntityModelLoader().getModelPart(EntityModelLayers.BANNER).getChild("flag"); 53 | } 54 | 55 | public static Optional of(TagKey pattern) { 56 | if (!AdvancedTooltips.getConfig().hasBannerPattern()) 57 | return Optional.empty(); 58 | var patternList = Registry.BANNER_PATTERN.getTag(pattern).map(ImmutableList::copyOf).orElse(ImmutableList.of()); 59 | var patterns = new BannerPattern.Patterns(); 60 | 61 | for (var p : patternList) { 62 | patterns.add(p, DyeColor.WHITE); 63 | } 64 | 65 | return Optional.of(new BannerTooltipComponent(patterns.toNbt())); 66 | } 67 | 68 | @Override 69 | public TooltipComponent getComponent() { 70 | return this; 71 | } 72 | 73 | @Override 74 | public int getHeight() { 75 | return 32; 76 | } 77 | 78 | @Override 79 | public int getWidth(TextRenderer textRenderer) { 80 | return 16; 81 | } 82 | 83 | @Override 84 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 85 | DiffuseLighting.setupFlatGuiLighting(); 86 | matrices.push(); 87 | matrices.translate(x + 8, y + 8, z); 88 | matrices.push(); 89 | matrices.translate(0.5, 16, 0); 90 | matrices.scale(6, -6, 1); 91 | matrices.scale(2, -2, -2); 92 | var immediate = this.client.getBufferBuilders().getEntityVertexConsumers(); 93 | this.bannerField.pitch = 0.f; 94 | this.bannerField.pivotY = -32.f; 95 | var list = BannerBlockEntity.getPatternsFromNbt(DyeColor.GRAY, this.pattern); 96 | BannerBlockEntityRenderer.renderCanvas(matrices, immediate, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV, 97 | this.bannerField, ModelLoader.BANNER_BASE, true, list); 98 | matrices.pop(); 99 | immediate.draw(); 100 | matrices.pop(); 101 | DiffuseLighting.setup3DGuiLighting(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/BeesTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.mojang.blaze3d.systems.RenderSystem; 21 | import net.minecraft.block.BeehiveBlock; 22 | import net.minecraft.block.entity.BeehiveBlockEntity; 23 | import net.minecraft.client.font.TextRenderer; 24 | import net.minecraft.client.gui.DrawableHelper; 25 | import net.minecraft.client.gui.screen.Screen; 26 | import net.minecraft.client.item.TooltipData; 27 | import net.minecraft.client.render.item.ItemRenderer; 28 | import net.minecraft.client.util.math.MatrixStack; 29 | import net.minecraft.entity.Entity; 30 | import net.minecraft.entity.EntityType; 31 | import net.minecraft.item.BlockItem; 32 | import net.minecraft.item.ItemStack; 33 | import net.minecraft.nbt.NbtCompound; 34 | import net.minecraft.nbt.NbtElement; 35 | import net.minecraft.nbt.NbtInt; 36 | import net.minecraft.nbt.NbtList; 37 | import net.minecraft.nbt.NbtString; 38 | import net.minecraft.util.Identifier; 39 | 40 | import java.util.ArrayList; 41 | import java.util.List; 42 | import java.util.Optional; 43 | import java.util.function.Function; 44 | 45 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 46 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 47 | 48 | /** 49 | * Represents a tooltip component which displays bees from a beehive. 50 | */ 51 | public class BeesTooltipComponent extends EntityTooltipComponent { 52 | private static final Identifier HONEY_LEVEL_TEXTURE = new Identifier(AdvancedTooltips.NAMESPACE, "textures/tooltips/honey_level.png"); 53 | 54 | private final List bees = new ArrayList<>(); 55 | private final int honeyLevel; 56 | 57 | public BeesTooltipComponent(AdvancedTooltipsConfig.BeeEntityConfig config, int honeyLevel, NbtList bees) { 58 | super(config); 59 | this.honeyLevel = honeyLevel; 60 | 61 | bees.stream().map(nbt -> (NbtCompound) nbt).forEach(nbt -> { 62 | var bee = nbt.getCompound("EntityData"); 63 | bee.remove("UUID"); 64 | bee.remove("Passengers"); 65 | bee.remove("Leash"); 66 | var entity = EntityType.loadEntityWithPassengers(bee, this.client.world, Function.identity()); 67 | if (entity != null) { 68 | this.bees.add(new Bee(nbt.getInt("TicksInHive"), entity)); 69 | } 70 | }); 71 | } 72 | 73 | public static Optional of(ItemStack stack) { 74 | var config = AdvancedTooltips.getConfig().getEntitiesConfig().getBeeConfig(); 75 | if (!config.isEnabled() && !config.shouldShowHoney()) 76 | return Optional.empty(); 77 | 78 | int honeyLevel = 0; 79 | 80 | var stateNbt = stack.getSubNbt(BlockItem.BLOCK_STATE_TAG_KEY); 81 | if (stateNbt != null) { 82 | NbtElement honeyLevelNbt = stateNbt.get(BeehiveBlock.HONEY_LEVEL.getName()); 83 | 84 | if (honeyLevelNbt instanceof NbtInt nbtInt) { 85 | honeyLevel = nbtInt.intValue(); 86 | } else if (honeyLevelNbt instanceof NbtString nbtString) { 87 | try { 88 | honeyLevel = Integer.parseInt(nbtString.asString()); 89 | } catch (NumberFormatException e) { 90 | // ignored 91 | } 92 | } 93 | } 94 | 95 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 96 | if ((nbt == null || !nbt.contains(BeehiveBlockEntity.BEES_KEY, NbtElement.LIST_TYPE)) && !config.shouldShowHoney()) 97 | return Optional.empty(); 98 | 99 | var bees = nbt == null || !config.isEnabled() ? new NbtList() : nbt.getList(BeehiveBlockEntity.BEES_KEY, NbtElement.COMPOUND_TYPE); 100 | if (!bees.isEmpty() || config.shouldShowHoney()) 101 | return Optional.of(new BeesTooltipComponent(config, honeyLevel, bees)); 102 | 103 | return Optional.empty(); 104 | } 105 | 106 | @Override 107 | public int getHeight() { 108 | if (this.bees.isEmpty()) { 109 | return this.config.shouldShowHoney() ? 12 : 0; 110 | } else { 111 | return (this.shouldRenderCustomNames() ? 32 : 24) + (this.config.shouldShowHoney() ? 16 : 0); 112 | } 113 | } 114 | 115 | @Override 116 | public int getWidth(TextRenderer textRenderer) { 117 | return Math.max(this.bees.size() * 26, (this.config.shouldShowHoney() ? 52 : 0)); 118 | } 119 | 120 | @Override 121 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 122 | matrices.push(); 123 | 124 | if (!this.bees.isEmpty()) { 125 | matrices.translate(2, 4, z); 126 | 127 | int xOffset = x; 128 | for (var bee : this.bees) { 129 | this.renderEntity(matrices, xOffset, y + (this.shouldRenderCustomNames() ? 8 : 0), bee.bee(), bee.ticksInHive(), 130 | this.config.shouldSpin(), true); 131 | xOffset += 26; 132 | } 133 | } 134 | 135 | if (config.shouldShowHoney()) { 136 | matrices.translate(x, y + (this.bees.isEmpty() ? 0 : (this.shouldRenderCustomNames() ? 32 : 24)), 0); 137 | matrices.scale(2, 2, 1); 138 | 139 | RenderSystem.setShaderTexture(0, HONEY_LEVEL_TEXTURE); 140 | DrawableHelper.drawTexture(matrices, 0, 0, 0, 0, 0, 26, 5, 32, 16); 141 | 142 | if (honeyLevel != 0) { 143 | DrawableHelper.drawTexture(matrices, 0, 0, z, 0, 5, Math.min(25, honeyLevel * 5 + 1), 6, 32, 16); 144 | } 145 | } 146 | 147 | matrices.pop(); 148 | } 149 | 150 | @Override 151 | protected boolean shouldRender() { 152 | return !this.bees.isEmpty(); 153 | } 154 | 155 | @Override 156 | protected boolean shouldRenderCustomNames() { 157 | return this.bees.stream().map(bee -> bee.bee().hasCustomName()).reduce(false, (first, second) -> first || second) 158 | && (this.config.shouldAlwaysShowName() || Screen.hasControlDown()); 159 | } 160 | 161 | record Bee(int ticksInHive, Entity bee) { 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/CampfireTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 21 | import com.mojang.blaze3d.systems.RenderSystem; 22 | 23 | import net.minecraft.client.MinecraftClient; 24 | import net.minecraft.client.font.TextRenderer; 25 | import net.minecraft.client.gui.DrawableHelper; 26 | import net.minecraft.client.gui.tooltip.TooltipComponent; 27 | import net.minecraft.client.item.TooltipData; 28 | import net.minecraft.client.render.item.ItemRenderer; 29 | import net.minecraft.client.util.math.MatrixStack; 30 | import net.minecraft.inventory.Inventories; 31 | import net.minecraft.item.BlockItem; 32 | import net.minecraft.item.ItemStack; 33 | import net.minecraft.util.Identifier; 34 | import net.minecraft.util.collection.DefaultedList; 35 | import net.minecraft.util.registry.Registry; 36 | 37 | import java.util.Optional; 38 | 39 | /** 40 | * Represents a campfire tooltip. Displays a campfire inventory and the flame if lit. 41 | */ 42 | public class CampfireTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 43 | private static final Identifier ATLAS_TEXTURE = new Identifier("textures/atlas/blocks.png"); 44 | 45 | private final DefaultedList inventory; 46 | private final Identifier fireTexture; 47 | 48 | public CampfireTooltipComponent(DefaultedList inventory, Identifier fireTexture) { 49 | this.inventory = inventory; 50 | this.fireTexture = fireTexture; 51 | } 52 | 53 | public static Optional of(ItemStack stack) { 54 | if (!AdvancedTooltips.getConfig().getContainersConfig().isCampfireEnabled()) 55 | return Optional.empty(); 56 | 57 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 58 | if (nbt == null) 59 | return Optional.empty(); 60 | 61 | var inventory = DefaultedList.ofSize(4, ItemStack.EMPTY); 62 | Inventories.readNbt(nbt, inventory); 63 | 64 | boolean empty = true; 65 | for (var item : inventory) { 66 | if (!item.isEmpty()) { 67 | empty = false; 68 | break; 69 | } 70 | } 71 | 72 | if (empty) 73 | return Optional.empty(); 74 | 75 | var itemId = Registry.ITEM.getId(stack.getItem()); 76 | var fireId = new Identifier(itemId.getNamespace(), "block/" + itemId.getPath() + "_fire"); 77 | 78 | var stateNbt = stack.getSubNbt(BlockItem.BLOCK_STATE_TAG_KEY); 79 | if (stateNbt != null && stateNbt.contains("lit")) { 80 | if (stateNbt.get("lit").asString().equals("false")) 81 | fireId = null; 82 | } 83 | 84 | return Optional.of(new CampfireTooltipComponent(inventory, fireId)); 85 | } 86 | 87 | @Override 88 | public TooltipComponent getComponent() { 89 | return this; 90 | } 91 | 92 | @Override 93 | public int getHeight() { 94 | return 3 * 18 + 2; 95 | } 96 | 97 | @Override 98 | public int getWidth(TextRenderer textRenderer) { 99 | return 3 * 18 + 2; 100 | } 101 | 102 | @Override 103 | public void drawItems(TextRenderer textRenderer, int xOffset, int yOffset, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 104 | int x = 1 + 18 * 2; 105 | int y = 1 + 18 * 2; 106 | 107 | for (int i = 0; i < this.inventory.size(); i++) { 108 | var stack = this.inventory.get(i); 109 | 110 | InventoryTooltipComponent.drawSlot(matrices, x + xOffset - 1, y + yOffset - 1, z, null); 111 | itemRenderer.renderInGuiWithOverrides(stack, xOffset + x, yOffset + y); 112 | itemRenderer.renderGuiItemOverlay(textRenderer, stack, xOffset + x, yOffset + y); 113 | 114 | if (i == 1) 115 | y -= 18 * 2; 116 | else if (i == 0) 117 | x -= 18 * 2; 118 | else if (i == 2) 119 | x += 18 * 2; 120 | } 121 | 122 | if (this.fireTexture != null) { 123 | RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f); 124 | 125 | var sprite = MinecraftClient.getInstance().getSpriteAtlas(ATLAS_TEXTURE).apply(this.fireTexture); 126 | if (sprite != null) 127 | DrawableHelper.drawSprite(matrices, xOffset + 19, yOffset + 19, z, 16, 16, sprite); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/CompoundTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.google.common.collect.Lists; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.gui.tooltip.TooltipComponent; 23 | import net.minecraft.client.render.VertexConsumerProvider.Immediate; 24 | import net.minecraft.client.render.item.ItemRenderer; 25 | import net.minecraft.client.util.math.MatrixStack; 26 | import net.minecraft.util.math.Matrix4f; 27 | 28 | import java.util.List; 29 | 30 | public class CompoundTooltipComponent implements TooltipComponent, ConvertibleTooltipData { 31 | private final List components = Lists.newArrayList(); 32 | 33 | public void addComponent(TooltipComponent component) { 34 | components.add(component); 35 | } 36 | 37 | @Override 38 | public TooltipComponent getComponent() { 39 | return this; 40 | } 41 | 42 | @Override 43 | public int getHeight() { 44 | int height = 0; 45 | for (var comp : components) { 46 | height += comp.getHeight(); 47 | } 48 | return height; 49 | } 50 | 51 | @Override 52 | public int getWidth(TextRenderer textRenderer) { 53 | int width = 0; 54 | for (var comp : components) { 55 | if (comp.getWidth(textRenderer) > width) { 56 | width = comp.getWidth(textRenderer); 57 | } 58 | } 59 | return width; 60 | } 61 | 62 | @Override 63 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 64 | int yOff = 0; 65 | for (var comp : components) { 66 | comp.drawItems(textRenderer, x, y + yOff, matrices, itemRenderer, z); 67 | yOff += comp.getHeight(); 68 | } 69 | } 70 | 71 | @Override 72 | public void drawText(TextRenderer textRenderer, int x, int y, Matrix4f matrix4f, Immediate immediate) { 73 | int yOff = 0; 74 | for (var comp : components) { 75 | comp.drawText(textRenderer, x, y + yOff, matrix4f, immediate); 76 | yOff += comp.getHeight(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/ConvertibleTooltipData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.gui.tooltip.TooltipComponent; 21 | import net.minecraft.client.item.TooltipData; 22 | 23 | public interface ConvertibleTooltipData extends TooltipData { 24 | TooltipComponent getComponent(); 25 | } 26 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/EntityBucketTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.MinecraftClient; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.item.TooltipData; 23 | import net.minecraft.client.render.item.ItemRenderer; 24 | import net.minecraft.client.util.math.MatrixStack; 25 | import net.minecraft.entity.Entity; 26 | import net.minecraft.entity.EntityType; 27 | import net.minecraft.nbt.NbtCompound; 28 | 29 | import java.util.Optional; 30 | 31 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 32 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 33 | import com.github.reviversmc.advancedtooltips.mixin.EntityAccessor; 34 | 35 | /** 36 | * Represents a tooltip component which displays bees from a beehive. 37 | */ 38 | public class EntityBucketTooltipComponent extends EntityTooltipComponent { 39 | private final Entity entity; 40 | 41 | private EntityBucketTooltipComponent(AdvancedTooltipsConfig.EntityConfig config, Entity entity) { 42 | super(config); 43 | this.entity = entity; 44 | } 45 | 46 | public static Optional of(EntityType type, NbtCompound itemNbt) { 47 | var entitiesConfig = AdvancedTooltips.getConfig().getEntitiesConfig(); 48 | if (!entitiesConfig.getFishBucketConfig().isEnabled()) 49 | return Optional.empty(); 50 | 51 | var client = MinecraftClient.getInstance(); 52 | var entity = type.create(client.world); 53 | if (entity != null) { 54 | EntityType.loadFromEntityNbt(client.world, null, entity, itemNbt); 55 | adjustEntity(entity, itemNbt, entitiesConfig); 56 | return Optional.of(new EntityBucketTooltipComponent(entitiesConfig.getFishBucketConfig(), entity)); 57 | } 58 | return Optional.empty(); 59 | } 60 | 61 | @Override 62 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 63 | if (this.shouldRender()) { 64 | matrices.push(); 65 | matrices.translate(2, 2, z); 66 | ((EntityAccessor) this.entity).setTouchingWater(true); 67 | this.entity.setVelocity(1.f, 1.f, 1.f); 68 | this.renderEntity(matrices, x + 16, y, this.entity, 0, this.config.shouldSpin(), false, 90.f); 69 | matrices.pop(); 70 | } 71 | } 72 | 73 | @Override 74 | protected boolean shouldRender() { 75 | return this.entity != null; 76 | } 77 | 78 | @Override 79 | protected boolean shouldRenderCustomNames() { 80 | return false; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/EntityTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 21 | import com.github.reviversmc.advancedtooltips.mixin.CameraAccessor; 22 | import com.github.reviversmc.advancedtooltips.mixin.EntityAccessor; 23 | import com.github.reviversmc.advancedtooltips.mixin.ItemEntityAccessor; 24 | import com.github.reviversmc.advancedtooltips.mixin.WitherEntityAccessor; 25 | import com.mojang.blaze3d.lighting.DiffuseLighting; 26 | 27 | import net.minecraft.client.MinecraftClient; 28 | import net.minecraft.client.font.TextRenderer; 29 | import net.minecraft.client.gui.screen.Screen; 30 | import net.minecraft.client.gui.tooltip.TooltipComponent; 31 | import net.minecraft.client.render.LightmapTextureManager; 32 | import net.minecraft.client.util.math.MatrixStack; 33 | import net.minecraft.entity.Bucketable; 34 | import net.minecraft.entity.Entity; 35 | import net.minecraft.entity.ItemEntity; 36 | import net.minecraft.entity.LivingEntity; 37 | import net.minecraft.entity.decoration.EndCrystalEntity; 38 | import net.minecraft.entity.passive.GoatEntity; 39 | import net.minecraft.entity.passive.PufferfishEntity; 40 | import net.minecraft.entity.passive.SquidEntity; 41 | import net.minecraft.entity.passive.TropicalFishEntity; 42 | import net.minecraft.nbt.NbtCompound; 43 | import net.minecraft.nbt.NbtElement; 44 | import net.minecraft.util.math.Vec3f; 45 | 46 | /** 47 | * Represents a tooltip component for entities. 48 | */ 49 | public abstract class EntityTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 50 | protected final MinecraftClient client = MinecraftClient.getInstance(); 51 | protected final C config; 52 | 53 | protected EntityTooltipComponent(C config) { 54 | this.config = config; 55 | } 56 | 57 | @Override 58 | public TooltipComponent getComponent() { 59 | return this; 60 | } 61 | 62 | @Override 63 | public int getHeight() { 64 | return !this.shouldRender() ? 0 : (this.shouldRenderCustomNames() ? 32 : 24); 65 | } 66 | 67 | @Override 68 | public int getWidth(TextRenderer textRenderer) { 69 | return this.shouldRender() ? 24 : 0; 70 | } 71 | 72 | protected void renderEntity(MatrixStack matrices, int x, int y, Entity entity, int ageOffset, boolean spin, boolean allowCustomName) { 73 | this.renderEntity(matrices, x, y, entity, ageOffset, spin, allowCustomName, 180.f); 74 | } 75 | 76 | protected void renderEntity(MatrixStack matrices, int x, int y, Entity entity, int ageOffset, boolean spin, boolean allowCustomName, float defaultYaw) { 77 | float size = 24; 78 | if (Math.max(entity.getWidth(), entity.getHeight()) > 1.0) { 79 | size /= Math.max(entity.getWidth(), entity.getHeight()); 80 | } 81 | DiffuseLighting.setupFlatGuiLighting(); 82 | matrices.push(); 83 | int yOffset = 16; 84 | if (entity instanceof SquidEntity) { 85 | size = 16; 86 | yOffset = 2; 87 | } else if (entity instanceof ItemEntity) { 88 | size = 48; 89 | yOffset = 28; 90 | } 91 | if (entity instanceof LivingEntity living && living.isBaby()) { 92 | size /= 1.7; 93 | } 94 | matrices.translate(x + 10, y + yOffset, 1050); 95 | matrices.scale(1f, 1f, -1); 96 | matrices.translate(0, 0, 1000); 97 | matrices.scale(size, size, size); 98 | 99 | var quaternion = Vec3f.POSITIVE_Z.getDegreesQuaternion(180.f); 100 | var quaternion2 = Vec3f.POSITIVE_X.getDegreesQuaternion(-10.f); 101 | quaternion.hamiltonProduct(quaternion2); 102 | matrices.multiply(quaternion); 103 | 104 | if (this.client.cameraEntity != null) { 105 | entity.setPos(this.client.cameraEntity.getX(), this.client.cameraEntity.getY(), this.client.cameraEntity.getZ()); 106 | } 107 | this.setupAngles(entity, this.client.player.age, ageOffset, spin, defaultYaw); 108 | 109 | var entityRenderDispatcher = this.client.getEntityRenderDispatcher(); 110 | quaternion2.conjugate(); 111 | ((CameraAccessor) entityRenderDispatcher.camera).setYaw(0f); 112 | entity.setFireTicks(((EntityAccessor) entity).getHasVisualFire() ? 1 : entity.getFireTicks()); 113 | entityRenderDispatcher.setRotation(quaternion2); 114 | 115 | entityRenderDispatcher.setRenderShadows(false); 116 | 117 | var immediate = this.client.getBufferBuilders().getEntityVertexConsumers(); 118 | entity.setCustomNameVisible(allowCustomName && entity.hasCustomName() && (this.config.shouldAlwaysShowName() || Screen.hasControlDown())); 119 | 120 | entityRenderDispatcher.render(entity, 0, 0, 0, 0.f, 1.f, matrices, immediate, 121 | LightmapTextureManager.MAX_LIGHT_COORDINATE 122 | ); 123 | immediate.draw(); 124 | 125 | entityRenderDispatcher.setRenderShadows(true); 126 | matrices.pop(); 127 | DiffuseLighting.setup3DGuiLighting(); 128 | } 129 | 130 | protected void setupAngles(Entity entity, int age, int ageOffset, boolean spin, float defaultYaw) { 131 | entity.age = age + ageOffset; 132 | 133 | float yaw = spin ? (float) (((System.currentTimeMillis() / 10) + ageOffset) % 360) : defaultYaw; 134 | entity.setYaw(yaw); 135 | entity.setHeadYaw(yaw); 136 | entity.setPitch(0.f); 137 | if (entity instanceof LivingEntity living) { 138 | if (living instanceof GoatEntity) living.headYaw = yaw; 139 | else if (living instanceof WitherEntityAccessor wither) { 140 | wither.getSideHeadYaws()[0] = wither.getSideHeadYaws()[1] = yaw; 141 | } 142 | living.bodyYaw = yaw; 143 | } else if (entity instanceof ItemEntityAccessor itemEntity) { 144 | itemEntity.setItemAge(entity.age); 145 | itemEntity.setUniqueOffset(0.f); 146 | } else if (entity instanceof EndCrystalEntity endCrystal) { 147 | endCrystal.endCrystalAge = endCrystal.age; 148 | } 149 | } 150 | 151 | protected abstract boolean shouldRender(); 152 | 153 | protected abstract boolean shouldRenderCustomNames(); 154 | 155 | protected static void adjustEntity(Entity entity, NbtCompound itemNbt, AdvancedTooltipsConfig.EntitiesConfig config) { 156 | if (entity instanceof Bucketable bucketable) { 157 | bucketable.copyDataFromNbt(itemNbt); 158 | if (entity instanceof PufferfishEntity pufferfish) { 159 | pufferfish.setPuffState(config.getPufferFishPuffState()); 160 | } else if (entity instanceof TropicalFishEntity tropicalFish) { 161 | if (itemNbt.contains("BucketVariantTag", NbtElement.INT_TYPE)) { 162 | tropicalFish.setVariant(itemNbt.getInt("BucketVariantTag")); 163 | } 164 | } 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/FoodTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 21 | import com.github.reviversmc.advancedtooltips.SaturationTooltipMode; 22 | import com.mojang.blaze3d.systems.RenderSystem; 23 | 24 | import net.minecraft.client.font.TextRenderer; 25 | import net.minecraft.client.gui.DrawableHelper; 26 | import net.minecraft.client.gui.hud.InGameHud; 27 | import net.minecraft.client.gui.tooltip.TooltipComponent; 28 | import net.minecraft.client.render.item.ItemRenderer; 29 | import net.minecraft.client.util.math.MatrixStack; 30 | import net.minecraft.item.FoodComponent; 31 | 32 | public record FoodTooltipComponent(FoodComponent component) implements ConvertibleTooltipData, TooltipComponent { 33 | @Override 34 | public TooltipComponent getComponent() { 35 | return this; 36 | } 37 | 38 | @Override 39 | public int getHeight() { 40 | var foodConfig = AdvancedTooltips.getConfig().getFoodConfig(); 41 | 42 | int height = 11; 43 | if (foodConfig.hasHunger() && foodConfig.getSaturationMode() == SaturationTooltipMode.SEPARATED) 44 | height += 11; 45 | return height; 46 | } 47 | 48 | @Override 49 | public int getWidth(TextRenderer textRenderer) { 50 | return Math.max(this.component.getHunger() / 2 * 9, (int) (this.component.getHunger() * this.component.getSaturationModifier() * 9)); 51 | } 52 | 53 | @Override 54 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 55 | var foodConfig = AdvancedTooltips.getConfig().getFoodConfig(); 56 | 57 | RenderSystem.setShaderTexture(0, InGameHud.GUI_ICONS_TEXTURE); 58 | int saturationY = y; 59 | if (foodConfig.getSaturationMode() == SaturationTooltipMode.SEPARATED && foodConfig.hasHunger()) saturationY += 11; 60 | 61 | // Draw hunger outline. 62 | if (foodConfig.hasHunger()) { 63 | for (int i = 0; i < (this.component.getHunger() + 1) / 2; i++) { 64 | DrawableHelper.drawTexture(matrices, x + i * 9, y, 16, 27, 9, 9, 256, 256); 65 | } 66 | } 67 | 68 | // Draw saturation outline. 69 | float saturation = this.component.getHunger() * this.component.getSaturationModifier(); 70 | if (foodConfig.getSaturationMode().isEnabled()) { 71 | RenderSystem.setShaderColor(159 / 255.f, 134 / 255.f, 9 / 255.f, 1.f); 72 | for (int i = 0; i < saturation; i++) { 73 | int width = 9; 74 | if (saturation - i < 1f) { 75 | width = Math.round(width * (saturation - i)); 76 | } 77 | DrawableHelper.drawTexture(matrices, x + i * 9, saturationY, 25, 27, width, 9, 256, 256); 78 | } 79 | } 80 | 81 | // Draw hunger bars. 82 | RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f); 83 | if (foodConfig.hasHunger()) { 84 | for (int i = 0; i < this.component.getHunger() / 2; i++) { 85 | DrawableHelper.drawTexture(matrices, x + i * 9, y, 52, 27, 9, 9, 256, 256); 86 | } 87 | if (this.component.getHunger() % 2 == 1) { 88 | DrawableHelper.drawTexture(matrices, x + this.component.getHunger() / 2 * 9, y, 61, 27, 9, 9, 256, 256); 89 | } 90 | } 91 | 92 | // Draw saturation bar if separate (or alone). 93 | if (foodConfig.getSaturationMode() == SaturationTooltipMode.SEPARATED || !foodConfig.hasHunger()) { 94 | RenderSystem.setShaderColor(229 / 255.f, 204 / 255.f, 209 / 255.f, 1.f); 95 | int intSaturation = Math.max(1, this.getSaturation()); 96 | if (saturation * 2 - intSaturation > 0.2) 97 | intSaturation++; 98 | for (int i = 0; i < intSaturation / 2; i++) { 99 | DrawableHelper.drawTexture(matrices, x + i * 9, saturationY, 52, 27, 9, 9, 256, 256); 100 | } 101 | if (intSaturation % 2 == 1) { 102 | DrawableHelper.drawTexture(matrices, x + this.getSaturation() / 2 * 9, saturationY, 61, 27, 9, 9, 256, 256); 103 | } 104 | RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f); 105 | } 106 | } 107 | 108 | private int getSaturation() { 109 | return (int) (this.component.getHunger() * this.component.getSaturationModifier() * 2.f); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/InventoryTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.api.InventoryProvider; 21 | import com.mojang.blaze3d.systems.RenderSystem; 22 | 23 | import net.minecraft.client.font.TextRenderer; 24 | import net.minecraft.client.gui.DrawableHelper; 25 | import net.minecraft.client.gui.tooltip.TooltipComponent; 26 | import net.minecraft.client.item.TooltipData; 27 | import net.minecraft.client.render.item.ItemRenderer; 28 | import net.minecraft.client.util.math.MatrixStack; 29 | import net.minecraft.item.BlockItem; 30 | import net.minecraft.item.ItemStack; 31 | import net.minecraft.util.DyeColor; 32 | import org.jetbrains.annotations.Nullable; 33 | 34 | import java.util.ArrayList; 35 | import java.util.List; 36 | import java.util.Optional; 37 | 38 | public class InventoryTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 39 | private final List inventory; 40 | private final int columns; 41 | private final DyeColor color; 42 | 43 | public InventoryTooltipComponent(List inventory, int columns, @Nullable DyeColor color) { 44 | this.inventory = inventory; 45 | this.columns = columns == 0 ? inventory.size() / 3 : columns; 46 | this.color = color; 47 | } 48 | 49 | public static Optional of(ItemStack stack, boolean compact, @Nullable InventoryProvider.Context context) { 50 | if (context == null) { 51 | return Optional.empty(); 52 | } 53 | 54 | List inventory = context.inventory(); 55 | var blockEntityNbt = BlockItem.getBlockEntityNbtFromStack(stack); 56 | if (blockEntityNbt == null) 57 | return Optional.empty(); 58 | 59 | if (inventory.stream().allMatch(ItemStack::isEmpty)) 60 | return Optional.empty(); 61 | 62 | int columns = Math.min(inventory.size() % 3 == 0 ? inventory.size() / 3 : inventory.size(), 9); 63 | 64 | if (compact) { 65 | var compactedInventory = new ArrayList(); 66 | inventory.forEach(invStack -> { 67 | if (invStack.isEmpty()) 68 | return; 69 | compactedInventory.stream().filter(other -> ItemStack.canCombine(other, invStack)) 70 | .findFirst() 71 | .ifPresentOrElse( 72 | s -> s.increment(invStack.getCount()), 73 | () -> compactedInventory.add(invStack) 74 | ); 75 | }); 76 | 77 | inventory = compactedInventory; 78 | columns = 9; 79 | } 80 | 81 | return Optional.of(new InventoryTooltipComponent(inventory, columns, context.color())); 82 | } 83 | 84 | @Override 85 | public TooltipComponent getComponent() { 86 | return this; 87 | } 88 | 89 | @Override 90 | public int getHeight() { 91 | int rows = this.inventory.size() / this.getColumns(); 92 | if (this.inventory.size() % this.getColumns() != 0) 93 | rows++; 94 | return 18 * rows + 3; 95 | } 96 | 97 | @Override 98 | public int getWidth(TextRenderer textRenderer) { 99 | return this.getColumns() * 18; 100 | } 101 | 102 | @Override 103 | public void drawItems(TextRenderer textRenderer, int xOffset, int yOffset, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 104 | int x = 1; 105 | int y = 1; 106 | int lines = this.getColumns(); 107 | 108 | for (var stack : this.inventory) { 109 | drawSlot(matrices, x + xOffset - 1, y + yOffset - 1, z, this.color == null ? null : color.getColorComponents()); 110 | itemRenderer.renderInGuiWithOverrides(stack, xOffset + x, yOffset + y); 111 | itemRenderer.renderGuiItemOverlay(textRenderer, stack, xOffset + x, yOffset + y); 112 | x += 18; 113 | if (x >= 18 * lines) { 114 | x = 1; 115 | y += 18; 116 | } 117 | } 118 | } 119 | 120 | public static void drawSlot(MatrixStack matrices, int x, int y, int z, float[] color) { 121 | if (color == null) 122 | color = new float[]{1.f, 1.f, 1.f}; 123 | RenderSystem.setShaderColor(color[0], color[1], color[2], 1.f); 124 | RenderSystem.setShaderTexture(0, DrawableHelper.STATS_ICON_TEXTURE); 125 | DrawableHelper.drawTexture(matrices, x, y, z, 0.f, 0.f, 18, 18, 128, 128); 126 | } 127 | 128 | protected int getColumns() { 129 | return this.columns; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/JukeboxTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.font.TextRenderer; 21 | import net.minecraft.client.gui.tooltip.TooltipComponent; 22 | import net.minecraft.client.item.TooltipData; 23 | import net.minecraft.client.render.LightmapTextureManager; 24 | import net.minecraft.client.render.VertexConsumerProvider; 25 | import net.minecraft.client.render.item.ItemRenderer; 26 | import net.minecraft.client.util.math.MatrixStack; 27 | import net.minecraft.item.BlockItem; 28 | import net.minecraft.item.ItemStack; 29 | import net.minecraft.item.MusicDiscItem; 30 | import net.minecraft.util.collection.DefaultedList; 31 | import net.minecraft.util.math.Matrix4f; 32 | 33 | import java.util.Optional; 34 | 35 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 36 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 37 | import com.github.reviversmc.advancedtooltips.JukeboxTooltipMode; 38 | 39 | /** 40 | * Represents a jukebox tooltip component. Displays the inserted disc description and an inventory slot with the disc in fancy mode. 41 | */ 42 | public class JukeboxTooltipComponent extends InventoryTooltipComponent { 43 | private final AdvancedTooltipsConfig config = AdvancedTooltips.getConfig(); 44 | private final MusicDiscItem disc; 45 | 46 | public JukeboxTooltipComponent(ItemStack discStack) { 47 | super(DefaultedList.ofSize(1, discStack), 1, null); 48 | this.disc = (MusicDiscItem) discStack.getItem(); 49 | } 50 | 51 | public static Optional of(ItemStack stack) { 52 | if (!AdvancedTooltips.getConfig().getJukeboxTooltipMode().isEnabled()) return Optional.empty(); 53 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 54 | if (nbt != null && nbt.contains("RecordItem")) { 55 | var discStack = ItemStack.fromNbt(nbt.getCompound("RecordItem")); 56 | if (discStack.getItem() instanceof MusicDiscItem) 57 | return Optional.of(new JukeboxTooltipComponent(discStack)); 58 | } 59 | return Optional.empty(); 60 | } 61 | 62 | @Override 63 | public TooltipComponent getComponent() { 64 | return this; 65 | } 66 | 67 | @Override 68 | public int getHeight() { 69 | int height = 10; 70 | if (this.config.getJukeboxTooltipMode() == JukeboxTooltipMode.FANCY) 71 | height += 20; 72 | return height; 73 | } 74 | 75 | @Override 76 | public int getWidth(TextRenderer textRenderer) { 77 | return textRenderer.getWidth(this.disc.getDescription()); 78 | } 79 | 80 | @Override 81 | public void drawText(TextRenderer textRenderer, int x, int y, Matrix4f matrix4f, VertexConsumerProvider.Immediate immediate) { 82 | textRenderer.draw(this.disc.getDescription(), 83 | x, y, 11184810, true, matrix4f, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 84 | } 85 | 86 | @Override 87 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 88 | if (this.config.getJukeboxTooltipMode() == JukeboxTooltipMode.FANCY) 89 | super.drawItems(textRenderer, x, y + 10, matrices, itemRenderer, z); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/MapTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.MinecraftClient; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.gui.tooltip.TooltipComponent; 23 | import net.minecraft.client.item.TooltipData; 24 | import net.minecraft.client.render.LightmapTextureManager; 25 | import net.minecraft.client.render.item.ItemRenderer; 26 | import net.minecraft.client.util.math.MatrixStack; 27 | import net.minecraft.item.FilledMapItem; 28 | import net.minecraft.item.ItemStack; 29 | 30 | import java.util.Optional; 31 | 32 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 33 | 34 | public class MapTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 35 | private final MinecraftClient client = MinecraftClient.getInstance(); 36 | public int map; 37 | 38 | public MapTooltipComponent(int map) { 39 | this.map = map; 40 | } 41 | 42 | public static Optional of(ItemStack stack) { 43 | if (!AdvancedTooltips.getConfig().getFilledMapConfig().isEnabled()) return Optional.empty(); 44 | var map = FilledMapItem.getMapId(stack); 45 | return map == null ? Optional.empty() : Optional.of(new MapTooltipComponent(map)); 46 | } 47 | 48 | @Override 49 | public TooltipComponent getComponent() { 50 | return this; 51 | } 52 | 53 | @Override 54 | public int getHeight() { 55 | return 128 + 2; 56 | } 57 | 58 | @Override 59 | public int getWidth(TextRenderer textRenderer) { 60 | return 128; 61 | } 62 | 63 | @Override 64 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 65 | var vertices = this.client.getBufferBuilders().getEntityVertexConsumers(); 66 | var map = this.client.gameRenderer.getMapRenderer(); 67 | var state = FilledMapItem.getMapState(this.map, this.client.world); 68 | if (state == null) return; 69 | matrices.push(); 70 | matrices.translate(x, y, z); 71 | matrices.scale(1, 1, 0); 72 | map.render(matrices, vertices, this.map, state, !AdvancedTooltips.getConfig().getFilledMapConfig().shouldShowPlayerIcon(), 73 | LightmapTextureManager.MAX_LIGHT_COORDINATE); 74 | vertices.draw(); 75 | matrices.pop(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/SignTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 21 | import com.github.reviversmc.advancedtooltips.SignTooltipMode; 22 | import com.mojang.blaze3d.lighting.DiffuseLighting; 23 | import com.mojang.blaze3d.texture.NativeImage; 24 | 25 | import net.minecraft.client.MinecraftClient; 26 | import net.minecraft.client.font.TextRenderer; 27 | import net.minecraft.client.gui.tooltip.TooltipComponent; 28 | import net.minecraft.client.item.TooltipData; 29 | import net.minecraft.client.render.LightmapTextureManager; 30 | import net.minecraft.client.render.OverlayTexture; 31 | import net.minecraft.client.render.TexturedRenderLayers; 32 | import net.minecraft.client.render.VertexConsumerProvider; 33 | import net.minecraft.client.render.block.entity.SignBlockEntityRenderer; 34 | import net.minecraft.client.render.item.ItemRenderer; 35 | import net.minecraft.client.util.math.MatrixStack; 36 | import net.minecraft.item.BlockItem; 37 | import net.minecraft.item.ItemStack; 38 | import net.minecraft.item.SignItem; 39 | import net.minecraft.nbt.NbtCompound; 40 | import net.minecraft.text.OrderedText; 41 | import net.minecraft.text.Text; 42 | import net.minecraft.util.DyeColor; 43 | import net.minecraft.util.SignType; 44 | import net.minecraft.util.math.Matrix4f; 45 | 46 | import java.util.Arrays; 47 | import java.util.Comparator; 48 | import java.util.Optional; 49 | 50 | public class SignTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 51 | private final MinecraftClient client = MinecraftClient.getInstance(); 52 | private final SignTooltipMode tooltipMode = AdvancedTooltips.getConfig().getSignTooltipMode(); 53 | private final SignType type; 54 | private final OrderedText[] text; 55 | private final DyeColor color; 56 | private final boolean glowingText; 57 | private final SignBlockEntityRenderer.SignModel model; 58 | 59 | public SignTooltipComponent(SignType type, OrderedText[] text, DyeColor color, boolean glowingText) { 60 | this.type = type; 61 | this.text = text; 62 | this.color = color; 63 | this.glowingText = glowingText; 64 | this.model = SignBlockEntityRenderer.createSignModel(this.client.getEntityModelLoader(), this.type); 65 | } 66 | 67 | public static Optional fromItemStack(ItemStack stack) { 68 | if (!AdvancedTooltips.getConfig().getSignTooltipMode().isEnabled()) 69 | return Optional.empty(); 70 | 71 | if (stack.getItem() instanceof SignItem signItem) { 72 | var block = signItem.getBlock(); 73 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 74 | if (nbt != null) return Optional.of(fromTag(SignBlockEntityRenderer.getSignType(block), nbt)); 75 | } 76 | return Optional.empty(); 77 | } 78 | 79 | public static SignTooltipComponent fromTag(SignType type, NbtCompound nbt) { 80 | var color = DyeColor.byName(nbt.getString("Color"), DyeColor.BLACK); 81 | 82 | var lines = new OrderedText[4]; 83 | for (int i = 0; i < 4; ++i) { 84 | var serialized = nbt.getString("Text" + (i + 1)); 85 | var text = Text.Serializer.fromJson(serialized.isEmpty() ? "\"\"" : serialized).asOrderedText(); 86 | lines[i] = text; 87 | } 88 | 89 | boolean glowingText = nbt.getBoolean("GlowingText"); 90 | 91 | return new SignTooltipComponent(type, lines, color, glowingText); 92 | } 93 | 94 | @Override 95 | public TooltipComponent getComponent() { 96 | return this; 97 | } 98 | 99 | @Override 100 | public int getHeight() { 101 | if (this.tooltipMode == SignTooltipMode.FANCY) 102 | return 52; 103 | return this.text.length * 10; 104 | } 105 | 106 | @Override 107 | public int getWidth(TextRenderer textRenderer) { 108 | if (this.tooltipMode == SignTooltipMode.FANCY) 109 | return 94; 110 | return Arrays.stream(this.text).map(textRenderer::getWidth).max(Comparator.naturalOrder()).orElse(94); 111 | } 112 | 113 | @Override 114 | public void drawText(TextRenderer textRenderer, int x, int y, Matrix4f matrix4f, VertexConsumerProvider.Immediate immediate) { 115 | if (this.tooltipMode != SignTooltipMode.FAST) 116 | return; 117 | 118 | int signColor = this.color.getSignColor(); 119 | 120 | if (glowingText) { 121 | int outlineColor; 122 | if (this.color == DyeColor.BLACK) { 123 | outlineColor = -988212; 124 | } else { 125 | int r = (int) (NativeImage.getRed(signColor) * 0.4); 126 | int g = (int) (NativeImage.getGreen(signColor) * 0.4); 127 | int b = (int) (NativeImage.getBlue(signColor) * 0.4); 128 | 129 | outlineColor = NativeImage.getAbgrColor(0, b, g, r); 130 | } 131 | 132 | for (var text : this.text) { 133 | textRenderer.drawWithOutline(text, x, y, signColor, outlineColor, matrix4f, immediate, LightmapTextureManager.MAX_LIGHT_COORDINATE); 134 | y += 10; 135 | } 136 | } else { 137 | for (var text : this.text) { 138 | textRenderer.draw(text, x, y, signColor, true, matrix4f, immediate, false, 139 | 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 140 | y += 10; 141 | } 142 | } 143 | } 144 | 145 | @Override 146 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 147 | if (this.tooltipMode != SignTooltipMode.FANCY) 148 | return; 149 | 150 | DiffuseLighting.setupFlatGuiLighting(); 151 | matrices.push(); 152 | matrices.translate(x + 2, y, z); 153 | 154 | matrices.push(); 155 | matrices.translate(45, 56, 0); 156 | matrices.scale(65, 65, -65); 157 | var immediate = this.client.getBufferBuilders().getEntityVertexConsumers(); 158 | var spriteIdentifier = TexturedRenderLayers.getSignTextureId(this.type); 159 | var vertexConsumer = spriteIdentifier.getVertexConsumer(immediate, this.model::getLayer); 160 | this.model.stick.visible = false; 161 | this.model.root.visible = true; 162 | this.model.root.render(matrices, vertexConsumer, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV); 163 | immediate.draw(); 164 | matrices.pop(); 165 | 166 | matrices.translate(0, 4, 10); 167 | 168 | for (int i = 0; i < this.text.length; i++) { 169 | var text = this.text[i]; 170 | textRenderer.draw(matrices, text, 45 - textRenderer.getWidth(text) / 2.f, i * 10, this.color.getSignColor()); 171 | y += textRenderer.fontHeight + 2; 172 | } 173 | matrices.pop(); 174 | 175 | DiffuseLighting.setup3DGuiLighting(); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/SpawnEntityTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import net.minecraft.client.MinecraftClient; 21 | import net.minecraft.client.font.TextRenderer; 22 | import net.minecraft.client.gui.screen.Screen; 23 | import net.minecraft.client.item.TooltipData; 24 | import net.minecraft.client.render.item.ItemRenderer; 25 | import net.minecraft.client.util.math.MatrixStack; 26 | import net.minecraft.entity.Entity; 27 | import net.minecraft.entity.EntityType; 28 | import net.minecraft.item.BlockItem; 29 | import net.minecraft.item.ItemStack; 30 | import net.minecraft.nbt.NbtCompound; 31 | import net.minecraft.nbt.NbtElement; 32 | import net.minecraft.util.math.BlockPos; 33 | import net.minecraft.world.MobSpawnerLogic; 34 | import net.minecraft.world.World; 35 | 36 | import java.util.Optional; 37 | 38 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 39 | import com.github.reviversmc.advancedtooltips.AdvancedTooltipsConfig; 40 | import com.github.reviversmc.advancedtooltips.mixin.EntityAccessor; 41 | 42 | public class SpawnEntityTooltipComponent extends EntityTooltipComponent { 43 | private final Entity entity; 44 | 45 | public SpawnEntityTooltipComponent(AdvancedTooltipsConfig.EntityConfig config, Entity entity) { 46 | super(config); 47 | this.entity = entity; 48 | } 49 | 50 | public static Optional of(EntityType entityType, NbtCompound itemNbt) { 51 | var entitiesConfig = AdvancedTooltips.getConfig().getEntitiesConfig(); 52 | if (!entitiesConfig.getSpawnEggConfig().isEnabled() || entityType == null) 53 | return Optional.empty(); 54 | 55 | var client = MinecraftClient.getInstance(); 56 | var entity = entityType.create(client.world); 57 | if (entity != null) { 58 | adjustEntity(entity, itemNbt, entitiesConfig); 59 | var itemEntityNbt = itemNbt.getCompound("EntityTag").copy(); 60 | 61 | if (!itemEntityNbt.contains("VillagerData")) { 62 | var villagerData = new NbtCompound(); 63 | villagerData.putString("profession", "minecraft:none"); 64 | villagerData.putInt("level", 1); 65 | villagerData.putString("type", "minecraft:plains"); 66 | itemEntityNbt.put("VillagerData", villagerData); 67 | } 68 | 69 | if (itemEntityNbt.contains(Entity.ID_KEY, NbtElement.STRING_TYPE)) { // The spawn egg specifies its own entity type. 70 | var id = itemEntityNbt.getString(Entity.ID_KEY); 71 | if (id.startsWith("minecraft:")) { 72 | id = id.substring(10); 73 | } 74 | if (id.replaceAll("[^a-z0-9/._-]", "").matches(id)) { 75 | itemEntityNbt.putString(Entity.ID_KEY, id); 76 | Optional> specifiedEntityType = EntityType.fromNbt(itemEntityNbt); 77 | if (specifiedEntityType.isPresent()) { 78 | var actualEntity = specifiedEntityType.get().create(client.world); 79 | if (actualEntity != null) { 80 | entity = actualEntity; 81 | adjustEntity(entity, itemNbt, entitiesConfig); 82 | } 83 | } 84 | } 85 | } 86 | 87 | var entityTag = entity.writeNbt(new NbtCompound()); 88 | var uuid = entity.getUuid(); 89 | entityTag.copyFrom(itemEntityNbt); 90 | entity.setUuid(uuid); 91 | entity.readNbt(entityTag); 92 | return Optional.of(new SpawnEntityTooltipComponent(entitiesConfig.getSpawnEggConfig(), entity)); 93 | } 94 | 95 | return Optional.empty(); 96 | } 97 | 98 | public static Optional ofMobSpawner(ItemStack stack) { 99 | var entitiesConfig = AdvancedTooltips.getConfig().getEntitiesConfig(); 100 | if (!entitiesConfig.getMobSpawnerConfig().isEnabled()) 101 | return Optional.empty(); 102 | 103 | var nbt = BlockItem.getBlockEntityNbtFromStack(stack); 104 | if (nbt == null) 105 | return Optional.empty(); 106 | 107 | var client = MinecraftClient.getInstance(); 108 | 109 | var logic = new MobSpawnerLogic() { 110 | @Override 111 | public void sendStatus(World world, BlockPos pos, int eventType) { 112 | } 113 | }; 114 | logic.readNbt(client.world, client.player.getBlockPos(), nbt); 115 | 116 | var entity = logic.getRenderedEntity(client.world); 117 | if (entity != null) { 118 | return Optional.of(new SpawnEntityTooltipComponent(entitiesConfig.getMobSpawnerConfig(), entity)); 119 | } 120 | 121 | return Optional.empty(); 122 | } 123 | 124 | @Override 125 | public int getHeight() { 126 | return super.getHeight() + 36; 127 | } 128 | 129 | @Override 130 | public int getWidth(TextRenderer textRenderer) { 131 | return 128; 132 | } 133 | 134 | @Override 135 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 136 | if (this.shouldRender()) { 137 | matrices.push(); 138 | matrices.translate(30, 0, z); 139 | ((EntityAccessor) this.entity).setTouchingWater(true); 140 | this.entity.setVelocity(1.f, 1.f, 1.f); 141 | this.renderEntity(matrices, x + 20, y + 20, this.entity, 0, this.config.shouldSpin(), true, 90.f); 142 | matrices.pop(); 143 | } 144 | } 145 | 146 | @Override 147 | protected boolean shouldRender() { 148 | return this.entity != null; 149 | } 150 | 151 | @Override 152 | protected boolean shouldRenderCustomNames() { 153 | return this.entity.hasCustomName() && (this.config.shouldAlwaysShowName() || Screen.hasControlDown()); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/com/github/reviversmc/advancedtooltips/tooltip/StatusEffectTooltipComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package com.github.reviversmc.advancedtooltips.tooltip; 19 | 20 | import com.github.reviversmc.advancedtooltips.AdvancedTooltips; 21 | import com.github.reviversmc.advancedtooltips.HiddenEffectMode; 22 | import com.google.common.collect.Lists; 23 | import com.mojang.blaze3d.systems.RenderSystem; 24 | import com.mojang.datafixers.util.Pair; 25 | import it.unimi.dsi.fastutil.floats.FloatArrayList; 26 | import it.unimi.dsi.fastutil.floats.FloatList; 27 | import net.minecraft.client.MinecraftClient; 28 | import net.minecraft.client.font.TextRenderer; 29 | import net.minecraft.client.gui.DrawableHelper; 30 | import net.minecraft.client.gui.tooltip.TooltipComponent; 31 | import net.minecraft.client.render.LightmapTextureManager; 32 | import net.minecraft.client.render.VertexConsumerProvider.Immediate; 33 | import net.minecraft.client.render.item.ItemRenderer; 34 | import net.minecraft.client.resource.language.I18n; 35 | import net.minecraft.client.texture.StatusEffectSpriteManager; 36 | import net.minecraft.client.util.math.MatrixStack; 37 | import net.minecraft.entity.effect.StatusEffect; 38 | import net.minecraft.entity.effect.StatusEffectInstance; 39 | import net.minecraft.entity.effect.StatusEffectUtil; 40 | import net.minecraft.text.MutableText; 41 | import net.minecraft.text.Text; 42 | import net.minecraft.util.Identifier; 43 | import net.minecraft.util.math.Matrix4f; 44 | 45 | import java.util.List; 46 | 47 | public class StatusEffectTooltipComponent implements ConvertibleTooltipData, TooltipComponent { 48 | private static final Identifier MYSTERY_TEXTURE = new Identifier(AdvancedTooltips.NAMESPACE, "textures/mob_effects/mystery.png"); 49 | private List list = Lists.newArrayList(); 50 | private final FloatList chances = new FloatArrayList(); 51 | private boolean hidden = false; 52 | private float multiplier; 53 | 54 | public StatusEffectTooltipComponent(List list, float multiplier) { 55 | this.list = list; 56 | this.multiplier = multiplier; 57 | } 58 | 59 | public StatusEffectTooltipComponent(List> list) { 60 | for (var pair : list) { 61 | this.list.add(pair.getFirst()); 62 | this.chances.add(pair.getSecond().floatValue()); 63 | } 64 | this.multiplier = 1.f; 65 | } 66 | 67 | public StatusEffectTooltipComponent() { 68 | this.hidden = true; 69 | } 70 | 71 | private Text getHiddenText() { 72 | var effectsConfig = AdvancedTooltips.getConfig().getEffectsConfig(); 73 | boolean hiddenMotion = effectsConfig.hasHiddenMotion(); 74 | HiddenEffectMode hiddenEffectMode = effectsConfig.getHiddenEffectMode(); 75 | 76 | return hiddenEffectMode.stylize(Text.literal(hiddenEffectMode.getText(true, hiddenMotion)), hiddenMotion); 77 | } 78 | 79 | private Text getHiddenTime() { 80 | var effectsConfig = AdvancedTooltips.getConfig().getEffectsConfig(); 81 | boolean hiddenMotion = effectsConfig.hasHiddenMotion(); 82 | HiddenEffectMode hiddenEffectMode = effectsConfig.getHiddenEffectMode(); 83 | 84 | String timeColon = hiddenEffectMode == HiddenEffectMode.ENCHANTMENT && hiddenMotion ? "i" : ":"; 85 | 86 | MutableText minutes = hiddenEffectMode.stylize(Text.literal(hiddenEffectMode.getText(false, hiddenMotion)), hiddenMotion); 87 | Text seconds = minutes.copy(); 88 | 89 | return Text.empty().append(minutes) 90 | .append(hiddenEffectMode.stylize(Text.literal(timeColon), false)) 91 | .append(seconds); 92 | } 93 | 94 | @Override 95 | public TooltipComponent getComponent() { 96 | return this; 97 | } 98 | 99 | @Override 100 | public int getHeight() { 101 | if (this.hidden) { 102 | return 20; 103 | } 104 | return this.list.size() * 20; 105 | } 106 | 107 | @Override 108 | public int getWidth(TextRenderer textRenderer) { 109 | if (this.hidden) { 110 | return 26 + textRenderer.getWidth(this.getHiddenText()); 111 | } 112 | 113 | int max = 64; 114 | for (int i = 0; i < list.size(); i++) { 115 | StatusEffectInstance statusEffectInstance = list.get(i); 116 | String statusEffectName = I18n.translate(statusEffectInstance.getEffectType().getTranslationKey()); 117 | if (statusEffectInstance.getAmplifier() >= 1 && statusEffectInstance.getAmplifier() <= 9) { 118 | statusEffectName = statusEffectName + ' ' + I18n.translate("enchantment.level." + (statusEffectInstance.getAmplifier() + 1)); 119 | } 120 | if (statusEffectInstance.getDuration() > 1) { 121 | String duration = StatusEffectUtil.durationToString(statusEffectInstance, multiplier); 122 | if (this.chances.size() > i && this.chances.getFloat(i) < 1f) { 123 | duration += " - " + (int) (this.chances.getFloat(i) * 100f) + "%"; 124 | } 125 | max = Math.max(max, 26 + textRenderer.getWidth(duration)); 126 | } else if (this.chances.size() > i && this.chances.getFloat(i) < 1f) { 127 | String string2 = (int) (this.chances.getFloat(i) * 100f) + "%"; 128 | max = Math.max(max, 26 + textRenderer.getWidth(string2)); 129 | } 130 | max = Math.max(max, 26 + textRenderer.getWidth(statusEffectName)); 131 | } 132 | return max; 133 | } 134 | 135 | @Override 136 | public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { 137 | if (this.hidden) { 138 | RenderSystem.setShaderTexture(0, MYSTERY_TEXTURE); 139 | DrawableHelper.drawTexture(matrices, x, y, 0, 0, 18, 18, 18, 18); 140 | } else { 141 | MinecraftClient client = MinecraftClient.getInstance(); 142 | StatusEffectSpriteManager statusEffectSpriteManager = client.getStatusEffectSpriteManager(); 143 | for (int i = 0; i < list.size(); i++) { 144 | StatusEffectInstance statusEffectInstance = list.get(i); 145 | StatusEffect statusEffect = statusEffectInstance.getEffectType(); 146 | var sprite = statusEffectSpriteManager.getSprite(statusEffect); 147 | RenderSystem.setShaderTexture(0, sprite.getAtlas().getId()); 148 | DrawableHelper.drawSprite(matrices, x, y + i * 20, z, 18, 18, sprite); 149 | } 150 | } 151 | } 152 | 153 | @Override 154 | public void drawText(TextRenderer textRenderer, int x, int y, Matrix4f model, Immediate immediate) { 155 | if (this.hidden) { 156 | textRenderer.draw(this.getHiddenText(), x + 24, y, 8355711, true, 157 | model, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 158 | textRenderer.draw(this.getHiddenTime(), x + 24, y + 10, 8355711, true, 159 | model, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 160 | } else { 161 | for (int i = 0; i < list.size(); i++) { 162 | StatusEffectInstance statusEffectInstance = list.get(i); 163 | String statusEffectName = I18n.translate(statusEffectInstance.getEffectType().getTranslationKey()); 164 | if (statusEffectInstance.getAmplifier() >= 1 && statusEffectInstance.getAmplifier() <= 9) { 165 | statusEffectName = statusEffectName + ' ' + I18n.translate("enchantment.level." + (statusEffectInstance.getAmplifier() + 1)); 166 | } 167 | int off = 0; 168 | if (statusEffectInstance.getDuration() <= 1) { 169 | off += 5; 170 | } 171 | Integer color = statusEffectInstance.getEffectType().getType().getFormatting().getColorValue(); 172 | textRenderer.draw(statusEffectName, x + 24, y + i * 20 + off, color != null ? color : 16777215, 173 | true, model, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 174 | if (statusEffectInstance.getDuration() > 1) { 175 | String duration = StatusEffectUtil.durationToString(statusEffectInstance, multiplier); 176 | if (this.chances.size() > i && this.chances.getFloat(i) < 1f) { 177 | duration += " - " + (int) (this.chances.getFloat(i) * 100f) + "%"; 178 | } 179 | textRenderer.draw(duration, x + 24, y + i * 20 + 10, 8355711, true, 180 | model, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 181 | } else if (this.chances.size() > i && this.chances.getFloat(i) < 1f) { 182 | String chance = (int) (this.chances.getFloat(i) * 100f) + "%"; 183 | textRenderer.draw(chance, x + 24, y + i * 20 + 10, 8355711, true, 184 | model, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); 185 | } 186 | } 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/io/github/queerbric/inspecio/api/InspecioEntrypoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.github.queerbric.inspecio.api; 19 | 20 | import net.fabricmc.api.EnvType; 21 | import net.fabricmc.api.Environment; 22 | 23 | /** 24 | * Represents the Inspecio entrypoint, useful to use the API stuff of Inspecio. 25 | */ 26 | @Environment(EnvType.CLIENT) 27 | @Deprecated 28 | public interface InspecioEntrypoint { 29 | void onInspecioInitialized(); 30 | } 31 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/java/io/github/queerbric/inspecio/api/InventoryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2022 LambdAurora , Emi 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.github.queerbric.inspecio.api; 19 | 20 | import net.fabricmc.api.EnvType; 21 | import net.fabricmc.api.Environment; 22 | 23 | /** 24 | * Provides an inventory context for the given item stack. 25 | */ 26 | @Environment(EnvType.CLIENT) 27 | @FunctionalInterface 28 | @Deprecated 29 | public interface InventoryProvider extends com.github.reviversmc.advancedtooltips.api.InventoryProvider {} 30 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/advancedtooltips.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "com.github.reviversmc.advancedtooltips.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "client": [ 6 | "ArmorStandItemMixin", 7 | "BannerPatternItemMixin", 8 | "BlockItemMixin", 9 | "CameraAccessor", 10 | "EntityAccessor", 11 | "EntityBucketItemMixin", 12 | "FilledMapItemMixin", 13 | "ItemEntityAccessor", 14 | "ItemStackMixin", 15 | "LingeringPotionItemMixin", 16 | "PotionItemMixin", 17 | "SignItemMixin", 18 | "SpawnEggItemMixin", 19 | "SpectralArrowItemMixin", 20 | "TippedArrowItemMixin", 21 | "WitherEntityAccessor" 22 | ], 23 | "injectors": { 24 | "defaultRequire": 1 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/de_de.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Unbekannter Plattenspieler Tooltip modus", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Unbekannter Sättigungs Tooltip modus", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Unbekannter Schild Tooltip modus", 5 | 6 | "advancedtooltips.config.reloading": "Konfiguration wird neu geladen...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Dimension: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Ziel: %s", 10 | "advancedtooltips.tooltip.loot_table": "Beutetabelle: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Verzauberungskosten: %d" 12 | } 13 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Unknown jukebox tooltip mode", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Unknown saturation tooltip mode", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Unknown sign tooltip mode", 5 | 6 | "advancedtooltips.config.reloading": "Reloading configuration...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Dimension: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Target: %s", 10 | "advancedtooltips.tooltip.loot_table": "Loot Table: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Repair Cost: %d" 12 | } -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/fr_ca.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Mode d'info-bulle de jukebox inconnu", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Mode d'info-bulle de saturation inconnu", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Mode d'info-bulle de panneau inconnu", 5 | 6 | "advancedtooltips.config.reloading": "Rechargement de la configuration...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Dimension: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Pointe vers: %s", 10 | "advancedtooltips.tooltip.loot_table": "Table de butin: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Coût de réparation: %d" 12 | } -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/fr_fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Mode d'info-bulle de jukebox inconnu", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Mode d'info-bulle de saturation inconnu", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Mode d'info-bulle de panneau inconnu", 5 | 6 | "advancedtooltips.config.reloading": "Rechargement de la configuration...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Dimension: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Pointe vers: %s", 10 | "advancedtooltips.tooltip.loot_table": "Table de butin: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Coût de réparation: %d" 12 | } -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/ko_kr.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "알 수 없는 쥬크 박스 툴팁 모드", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "알 수 없는 포화도 툴팁 모드", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "알 수 없는 표지판 툴팁 모드", 5 | 6 | "advancedtooltips.config.reloading": "환경설정 다시 불러오는 중...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "차원: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "대상: %s", 10 | "advancedtooltips.tooltip.loot_table": "루트 테이블: %s", 11 | "advancedtooltips.tooltip.repair_cost": "수리 비용: %d" 12 | } 13 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/ru_ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Неизвестный режим подсказки проигрывателя", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Неизвестный режим подсказки насыщения", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Неизвестный режим подсказки таблички", 5 | 6 | "advancedtooltips.config.reloading": "Обновление настроек...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Измерение: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Цель: %s", 10 | "advancedtooltips.tooltip.loot_table": "Таблица добычи: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Стоимость починки: %d" 12 | } 13 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/tr_tr.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "Bilinmeyen müzik kutusu bilgi çubuğu modu", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "Bilinmeyen doygunluk bilgi çubuğu modu", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "Bilinmeyen tabela bilgi çubuğu modu", 5 | 6 | "advancedtooltips.config.reloading": "Ayarlama yeniden yükleniyor...", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "Boyut: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "Hedef: %s", 10 | "advancedtooltips.tooltip.loot_table": "Yağma Tablosu: %s", 11 | "advancedtooltips.tooltip.repair_cost": "Tamir Ücreti: %d" 12 | } 13 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "advancedtooltips.command.error.unknown_jukebox_tooltip_mode": "未知的唱片机提示框模式", 3 | "advancedtooltips.command.error.unknown_saturation_tooltip_mode": "未知的饱和度提示框模式", 4 | "advancedtooltips.command.error.unknown_sign_tooltip_mode": "未知的告示牌提示框模式", 5 | 6 | "advancedtooltips.config.reloading": "重载配置中……", 7 | 8 | "advancedtooltips.tooltip.lodestone_compass.dimension": "维度: %s", 9 | "advancedtooltips.tooltip.lodestone_compass.target": "目标: %s", 10 | "advancedtooltips.tooltip.loot_table": "战利品表: %s", 11 | "advancedtooltips.tooltip.repair_cost": "修复所需经验值: %d" 12 | } 13 | -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/textures/mob_effects/mystery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/advancedtooltips-core/src/main/resources/assets/advancedtooltips/textures/mob_effects/mystery.png -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/assets/advancedtooltips/textures/tooltips/honey_level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/advancedtooltips-core/src/main/resources/assets/advancedtooltips/textures/tooltips/honey_level.png -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/data/inspecio/tags/items/hidden_effects.json: -------------------------------------------------------------------------------- 1 | { 2 | "replace": false, 3 | "values": [ 4 | "minecraft:suspicious_stew" 5 | ] 6 | } -------------------------------------------------------------------------------- /advancedtooltips-core/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "advanced-tooltips-core", 4 | "version": "${version}", 5 | "name": "Advanced Tooltips Core", 6 | "description": "Cross Minecraft version compatible components of Advanced Tooltips", 7 | "environment": "client", 8 | "mixins": [ 9 | "advancedtooltips.mixins.json" 10 | ], 11 | "depends": { 12 | "minecraft": ">=1.19", 13 | "fabricloader": ">=0.12.12", 14 | "fabric-command-api-v2": "*", 15 | "fabric-rendering-v1": "*", 16 | "fabric-resource-loader-v0": "*" 17 | }, 18 | "custom": { 19 | "modmenu": { 20 | "badges": ["library"], 21 | "parent": { 22 | "id": "advanced-tooltips" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/banner.png -------------------------------------------------------------------------------- /assets/banner.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/banner.xcf -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/icon.png -------------------------------------------------------------------------------- /assets/icon.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/icon.xcf -------------------------------------------------------------------------------- /assets/preview-images/armor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/armor.png -------------------------------------------------------------------------------- /assets/preview-images/armor_stand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/armor_stand.png -------------------------------------------------------------------------------- /assets/preview-images/banner_pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/banner_pattern.png -------------------------------------------------------------------------------- /assets/preview-images/beacon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/beacon.png -------------------------------------------------------------------------------- /assets/preview-images/beehive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/beehive.png -------------------------------------------------------------------------------- /assets/preview-images/bucket_of_axolotl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/bucket_of_axolotl.png -------------------------------------------------------------------------------- /assets/preview-images/bucket_of_tropical_fish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/bucket_of_tropical_fish.png -------------------------------------------------------------------------------- /assets/preview-images/campfire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/campfire.png -------------------------------------------------------------------------------- /assets/preview-images/colored_shulker_box_tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/colored_shulker_box_tooltip.png -------------------------------------------------------------------------------- /assets/preview-images/compact_shulker_box_tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/compact_shulker_box_tooltip.png -------------------------------------------------------------------------------- /assets/preview-images/filled_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/filled_map.png -------------------------------------------------------------------------------- /assets/preview-images/fox_spawn_egg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/fox_spawn_egg.png -------------------------------------------------------------------------------- /assets/preview-images/golden_carrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/golden_carrot.png -------------------------------------------------------------------------------- /assets/preview-images/jukebox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/jukebox.png -------------------------------------------------------------------------------- /assets/preview-images/lodestone_compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/lodestone_compass.png -------------------------------------------------------------------------------- /assets/preview-images/loot_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/loot_table.png -------------------------------------------------------------------------------- /assets/preview-images/potion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/potion.png -------------------------------------------------------------------------------- /assets/preview-images/repair_cost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/repair_cost.png -------------------------------------------------------------------------------- /assets/preview-images/sign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/sign.png -------------------------------------------------------------------------------- /assets/preview-images/simple_shulker_box_tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/simple_shulker_box_tooltip.png -------------------------------------------------------------------------------- /assets/preview-images/suspicious_stew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/assets/preview-images/suspicious_stew.png -------------------------------------------------------------------------------- /common.gradle: -------------------------------------------------------------------------------- 1 | group = project.maven_group as Object 2 | 3 | repositories { 4 | // Add repositories to retrieve artifacts from in here. 5 | // You should only use this when depending on other mods because 6 | // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. 7 | // See https://docs.gradle.org/current/userguide/declaring_repositories.html 8 | // for more information about repositories. 9 | mavenLocal() 10 | if (project.use_third_party_mods == "true") { 11 | maven { 12 | name = "Modrinth" 13 | url = "https://api.modrinth.com/maven" 14 | content { 15 | includeGroup "maven.modrinth" 16 | } 17 | } 18 | maven { 19 | url = "https://cursemaven.com" 20 | content { 21 | includeGroup "curse.maven" 22 | } 23 | } 24 | } 25 | maven { 26 | name = "TerraformersMC" 27 | url = "https://maven.terraformersmc.com/releases" 28 | } 29 | maven { 30 | url = "https://maven.shedaniel.me/" 31 | } 32 | mavenCentral() 33 | } 34 | 35 | dependencies { 36 | modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" 37 | 38 | compileOnly "com.github.spotbugs:spotbugs:${project.spotbugs_version}" 39 | } 40 | 41 | 42 | tasks.withType(JavaCompile).configureEach { 43 | // ensure that the encoding is set to UTF-8, no matter what the system default is 44 | // this fixes some edge cases with special characters not displaying correctly 45 | // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html 46 | // If Javadoc is generated, this must be specified in that task too. 47 | it.options.encoding = "UTF-8" 48 | } 49 | 50 | test { 51 | useJUnitPlatform() 52 | } 53 | 54 | 55 | processResources { 56 | filesMatching("fabric.mod.json") { 57 | expand project.properties 58 | } 59 | } 60 | 61 | 62 | java { 63 | // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 64 | // if it is present. 65 | // If you remove this line, sources will not be generated. 66 | withSourcesJar() 67 | } 68 | 69 | jar { 70 | from "LICENSE" 71 | } 72 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx2G 3 | 4 | # Mod properties 5 | mod_version=1.6.0 6 | maven_group=com.github.reviversmc 7 | archives_base_name=advancedtooltips 8 | 9 | # Global Dependencies 10 | fabric_loader_version = 0.14.8 11 | spotbugs_version = 4.7.0 12 | 13 | # Module Dependencies 14 | # 1.19 15 | minecraft_version_1_19 = 1.19.1 16 | quilt_mappings_1_19 = 2 17 | fabric_api_version_1_19 = 0.58.5+1.19.1 18 | modmenu_version_1_19 = 4.0.5 19 | cloth_config_version_1_19 = 7.0.73 20 | 21 | 22 | # If true, third-party mods will be loaded during runtime in the developer run configurations 23 | use_third_party_mods = true 24 | # 1.19 25 | lazydfu_version_1_19 = 0.1.3 26 | sodium_version_1_19 = mc1.19-0.4.2 27 | joml_version_sodium_1_19 = 1.10.4 28 | # lithium_version = mc1.19-0.8.1 29 | starlight_version_1_19 = 1.1.1+1.19 30 | smoothboot_version_1_19 = 1.19-1.7.1 31 | no_fade_version_1_19 = 3550935 32 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReviversMC/advanced-tooltips/e4e6cc2dc88186e3785a514131312f4bb6bc5670/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-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | -------------------------------------------------------------------------------- /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% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name 'Fabric' 5 | url 'https://maven.fabricmc.net/' 6 | } 7 | maven { 8 | name 'Quilt' 9 | url 'https://maven.quiltmc.org/repository/release' 10 | } 11 | gradlePluginPortal() 12 | } 13 | } 14 | 15 | rootProject.name = 'advancedtooltips' 16 | 17 | include 'advancedtooltips-core' 18 | include 'advancedtooltips-1.19' 19 | --------------------------------------------------------------------------------