Compare commits

..
306 Commits
Author SHA1 Message Date
ZekerZhayard ebea66d261 Fix: relax render patch failures and correct RenderType patching (#381) 2026-06-21 13:42:48 +08:00
ZekerZhayard 06832661c0 Fix release republish and R2 upload 2026-06-18 20:41:00 +08:00
ZekerZhayard fff855f1b0 Minecraft 26.2 (#380) 2026-06-18 16:32:03 +08:00
ZekerZhayard 055cd711b3 Move actions/checkout from composite actions to workflow level 2026-05-21 14:42:44 +08:00
ZekerZhayard 0212d4d2f1 ignore all build directories but keep .github/actions/build 2026-05-21 13:09:26 +08:00
ZekerZhayard 756336e533 Fix actions 2026-05-21 13:04:43 +08:00
ZekerZhayard 8b5d440ed7 15.0 (#378) 2026-05-21 11:31:52 +08:00
ZekerZhayard faebfc9bb1 Support 26.1 (#368) 2026-03-25 23:10:09 +08:00
ZekerZhayard 08033b0502 Fix an issue where incorrect skins were loaded in multiplayer mode. (#364)
* Fix an issue where incorrect skins were loaded in multiplayer mode.

* Restore the mistakenly deleted GAME_PROFILE_ID.
2026-03-09 13:31:52 +08:00
ZekerZhayard 4cffdc3eb6 Fix crash on forge 1.20.4. (#360) 2025-12-23 00:18:17 +08:00
ZekerZhayard 73beb4c29e Support 1.21.11 (#359)
* Support 1.21.11

* Update supported versions
2025-12-14 23:23:34 +08:00
ZekerZhayard 73c31593f2 Fix #351 (#352)
* Fix #351

* a -> .1
2025-10-20 23:31:46 +08:00
ZekerZhayard 59a515ba61 Support 1.21.10. (#348) 2025-10-10 20:54:07 +09:00
ZekerZhayard 1f3d19ac6e Support 1.21.9. (#347) 2025-10-07 08:31:05 +09:00
33 1fbe258365 Update build.properties 2025-08-08 23:41:52 +08:00
33 d4cc4740d3 Update build.properties 2025-08-08 23:25:24 +08:00
ZekerZhayard d0d71b8557 Support 1.21.8. Split GameProfileLoader and MojangAPILoader. (#343) 2025-08-08 23:24:20 +08:00
ZekerZhayard 1a15951791 Support 1.21.6. (#341) 2025-06-21 21:54:07 +08:00
33 a195b42bc4 Update build.properties 2025-06-12 23:30:03 +08:00
ZekerZhayard 5d2f945d45 Support 1.21.5 (#334) 2025-03-26 20:06:21 +08:00
ZekerZhayard 6bf959de49 Fix repeated player skull texture download attempts during RenderTick on downloading failure. (#331) 2025-02-08 15:18:05 +08:00
ZekerZhayard 2f26a07dc9 Fix local profile cache. (#327) 2025-01-24 14:27:55 +08:00
33 5764d81d6d Update build.properties 2025-01-16 18:09:29 +08:00
ZekerZhayard 8080aa7ab5 Fix rendering lag when skull's username is empty. (#324) 2025-01-12 00:10:00 +08:00
8Mi_Yile 4d0ebcc1f7 Update common.yml (#323) 2025-01-12 00:08:29 +08:00
ZekerZhayard 1cb4cf40b0 1.21.4 (#321)
* 1.21.4

* Disable making the source jar.
2024-12-23 21:43:38 +08:00
cewno a9b2484b3e 更新与 Mojang API Wiki 相关的地址 (#320) 2024-12-20 12:13:03 +08:00
ZekerZhayard 8e63429293 Fix IllegalAccessError. (#317) 2024-11-12 21:36:24 +08:00
8Mi_Yile aa68af31e5 [skip ci] 修复缺少括号引起的执行问题 (#316)
手生了 还把括号搞丢了 太草了
2024-11-12 12:33:00 +08:00
8Mi_Yile bab30e4f0a 修复版本号问题和Quilt标签 (#312)
* [skip ci] fix cannot get minecraft versions

* [skip ci] fix cannot auto add tag `Quilt`
2024-11-08 13:14:45 +08:00
ZekerZhayard 571d61118d Fix #314 (#315) 2024-11-08 08:33:39 +08:00
33 5d3326c333 feat: 14.21 2024-11-06 10:49:15 +08:00
ZekerZhayard b2095998e5 1.21.2 (#311) 2024-10-30 12:31:15 +08:00
ZekerZhayard cdf2fbe644 24w33a (#310) 2024-09-27 20:29:27 +08:00
xand fa0f820143 Bump Fabric and ForgeV3 (Forge & Neoforge) versions to 1.21.1 (#306)
* Bump Fabric and Forge/Neoforge compatibility to 1.21.1

* Bump version to 14.21

* Fix version in build.properties
2024-08-10 21:07:12 +08:00
8Mi_Yile 23f08a3a64 support upload add tag NeoForge (#298)
* Update common.yml

* Update common.yml

* Update common.yml

* Update common.yml

* Update common.yml
2024-08-10 20:50:16 +08:00
ZekerZhayard 3e4b06f5d1 Fix NullPointerException (#299) 2024-08-10 20:49:09 +08:00
33 18d31bed8f feat: 1.21 2024-07-03 00:14:19 +08:00
ZekerZhayard 64490f1d18 Support 1.21. (#297) 2024-07-02 22:43:35 +08:00
33 cd1922844c feat: bump version to 14.19.3 2023-12-21 22:57:00 +08:00
ZekerZhayard 4185e5bb5f Fix #286 (#287) 2023-12-21 22:28:03 +08:00
ZekerZhayard 7fd5ff84ee Fix #284 (#285) 2023-12-18 21:04:28 +08:00
33 d2772697f3 feat: remove forceIgnoreHttpsCertificate for security 2023-12-15 17:39:36 +08:00
ZekerZhayard 0ffa9ef137 23w42a (#281) 2023-12-12 00:04:05 +08:00
33 f4b5954dad feat: version 14.19 2023-12-12 00:03:41 +08:00
8Mi_Yile 009895c018 fix: issues: report-bug: CSL.log is requried (#280)
* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml
2023-12-06 19:12:30 +08:00
33 c273dc396e feat: fix upload 2023-11-01 13:39:37 +08:00
33 6cb37301b6 feat: add cloudflare r2 2023-11-01 12:12:56 +08:00
33 e9e1955fad feat: change version to 14.18.3 2023-10-19 15:28:59 +08:00
33 933f64b810 feat: fix method not found in 1.8-1.12.2 2023-10-19 15:28:08 +08:00
33 e839362f09 feat: fix build 2023-10-16 20:31:19 +08:00
ZekerZhayard 220bddbebb Fix #272 (#273) 2023-10-15 14:51:50 +08:00
33 00c931d434 feat: fix MinecraftCapes 2023-10-11 12:29:02 +08:00
33 119892489f feat: rename enum AuthlibField 2023-10-10 13:58:32 +08:00
ZekerZhayard 9a55a4c615 Adapting to Authlib changes (#269) 2023-10-10 13:54:23 +08:00
33 1ed98534c9 feat: version 14.18 2023-10-09 19:35:03 +08:00
ZekerZhayard b8ca913848 Support 1.20.2. (#266) 2023-09-28 20:49:25 +08:00
33 d5ae6226ae feat: update Java version in action 2023-07-14 01:06:39 +08:00
33 f274278419 feat: update README.md 2023-07-14 01:04:24 +08:00
33 f6f043fc7c feat: remove illegal EOF 2023-07-14 01:04:24 +08:00
33 9571e367df feat: tweak into multi line output 2023-07-14 01:04:24 +08:00
33 48efe58d52 feat: use multiple version in action 2023-07-14 01:04:24 +08:00
33 16520f72a4 feat: add multiple version in release 2023-07-14 01:04:24 +08:00
33 fd08f65af3 feat: cherry pick from 14-develop 2023-07-14 01:03:51 +08:00
33 83799da6ae feat: cheery pick from 14-develop 2023-07-14 01:01:10 +08:00
33 54d24a2800 fix: mod version in action 2023-07-14 00:59:31 +08:00
33 f2698b4ccf fix: GitHub pre-release in action 2023-07-14 00:59:31 +08:00
33 4a344ed653 fix: CurseForge and Modrinth upload 2023-07-14 00:59:31 +08:00
33 7074c8509d fix: CurseForge and Modrinth upload 2023-07-14 00:59:31 +08:00
33 10950a21ee fix: CurseForge upload 2023-07-14 00:59:31 +08:00
33 9889e05a81 feat: remove GitHub release action 2023-07-14 00:59:31 +08:00
8Mi_Yile e65ab7a9ea Update common.yml (#258) 2023-07-13 15:22:53 +08:00
33 a4f30a4bf1 fix: curseforge and modrinth release 2023-06-28 13:56:20 +08:00
33 68ac9f67df fix: use correct environment in upload task 2023-06-27 14:46:01 +08:00
33 647532629e fix: pull request won't run upload 2023-06-27 14:31:43 +08:00
33 71befeb300 fix: publish snapshot and canary to Tencent COS 2023-06-27 14:26:14 +08:00
8Mi_Yileandgithub-actions[bot] 8db9bf3de6 Add: common.yaml: CI Build Sync to Github Pre-Release (#256)
* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-27 13:49:59 +08:00
8Mi_Yileandgithub-actions[bot] 0c9a4033c4 add: common.yml: use matrix to multi-process upload file (#252)
* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-12 11:14:27 +08:00
ZekerZhayard d8d955224d Fix crash when the URL of skull profiles is not valid. (#255)
* Fix crash when the URL of skull profiles is not valid.

* Fix crash when the URL of skull profiles is not valid.
2023-05-07 16:38:36 +08:00
ZekerZhayard 8c0cdfb7b5 Support Fabric 23w16a. (#253) 2023-04-23 20:13:11 +08:00
33 919b69aaad Fix: GitHub Action Release 2023-04-17 21:57:55 +08:00
8Mi_Yileandgithub-actions[bot] 4de06aae50 issues-template: add option / common.yml: add support github release (#251)
* Auto Sync From

* Auto Sync From8MiYile/15-develop.zip

* Auto Sync From 8MiYile / 15-develop

* Auto Sync From 8MiYile / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-17 21:45:32 +08:00
ZekerZhayard f3f80a1f00 Merge remote-tracking branch 'origin/14-develop' into 15-develop 2023-03-18 21:42:57 +08:00
ZekerZhayard f5b1989453 Fix: Skull textures not loading when using local skins. 2023-03-18 11:07:34 +08:00
ZekerZhayard 85923855d8 Support 1.19.4. Remove Vanilla 1.19.3. 2023-03-15 23:34:05 +08:00
ZekerZhayard 755f7647ed Remove: all vanilla editions 2023-01-29 22:52:21 +08:00
33 c2dad72690 Add: 15-develop 2023-01-29 16:03:22 +08:00
8Mi_Yile c8e96c11cd Add Github Issue Template's options in Report Bug (#242)
* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml
2023-01-28 12:42:38 +08:00
33 32e3e2e5a2 Add: GameProfile cache for Mojang API 2023-01-26 19:34:58 +08:00
33 b7b5e9d6c8 Add: LogManager 2023-01-26 18:51:38 +08:00
ZekerZhayard dfa7db1731 Fix: Modrinth release for Fabric edition 2023-01-26 16:26:08 +08:00
33 b645fd1665 Fix: Modrinth release 2023-01-26 15:39:37 +08:00
33 28fc81cb9a Fix: release build 2023-01-26 15:21:26 +08:00
33 bb0a47de4b Release: 14.15.2 2023-01-26 14:46:52 +08:00
33 d09b1d9807 Tweak: log file format 2023-01-24 18:43:17 +08:00
33 c207bdfc0e Fix: build action 2023-01-13 15:43:38 +08:00
33 69d35a69b7 Tweak: release build action 2023-01-13 15:22:29 +08:00
8Mi_Yile d767f40d32 添加 Issue Template (#238) 2023-01-13 15:12:40 +08:00
ZekerZhayard 5329a27d1a Fix: #199 2023-01-12 22:12:40 +08:00
33 ddefe00ac0 Add: more cape 2023-01-12 00:09:57 +08:00
33 dd4b706827 Add: support WynntilsAPI cape 2023-01-11 22:06:58 +08:00
33 84072c62f3 Add: support OptiFine cape 2023-01-11 18:51:44 +08:00
33 2d00e12f0a Update: README.md 2023-01-07 04:33:22 +08:00
33 b2b56f5be5 Add: GitHub Action for Pull Request 2023-01-07 01:24:12 +08:00
33 43c8ceb21e Add: show Quilt loader in CurseForge and Modrinth 2023-01-07 01:09:08 +08:00
33 a0ad239770 Release: 14.15.1 2023-01-07 00:26:22 +08:00
ZekerZhayard c8f0f7e283 Fix: loadSkin not being remapped 2023-01-07 00:20:17 +08:00
33 bfbd6ee31a Update: README.md 2023-01-05 15:28:27 +08:00
33 f8f3caad39 Fix: trigger release action by tag 2023-01-04 17:15:40 +08:00
33 bd409ae169 Tweak: trigger release action by tag 2023-01-04 17:11:43 +08:00
33 82f0aad9ff Release: 14.15 2023-01-04 16:37:33 +08:00
33 f2fce38137 Fix: pass secrets to reuse workflow 2023-01-04 16:27:28 +08:00
33 7d19f3114c Add: GitHub Action Test 2023-01-04 16:15:47 +08:00
33 d7a1e0f31f Update: certificate 2023-01-04 15:56:11 +08:00
33 201210f567 Fix: GitHub Action 2023-01-04 15:40:53 +08:00
33 26ed002689 Fix: GitHub Action 2023-01-04 15:39:55 +08:00
33 7d7e5c9060 Update: reuse GitHub Action workflow 2023-01-04 15:37:43 +08:00
33 81bf422250 Add: environment in GitHub Action 2023-01-04 15:12:17 +08:00
33 776e31e158 Fix: cos beta build upload 2023-01-04 14:50:30 +08:00
33 4a92223158 Fix: GitHub Action 2023-01-04 14:38:43 +08:00
33 264aacc8c0 Add: upload beta to cos 2023-01-04 14:34:46 +08:00
33 0b000731b5 Remove: Circle CI 2023-01-04 13:57:39 +08:00
33 f0012b58df Tweak: GitHub Action 2023-01-04 13:50:38 +08:00
33 013c22ae95 Add: GitHub Action 2023-01-04 13:43:08 +08:00
33 01d02a27b0 Update: circle ci version 2.1 2023-01-04 12:01:48 +08:00
33 077551e161 Tweak: only build release branch in circle ci 2023-01-04 12:01:48 +08:00
ZekerZhayard bd642d0106 Don't use ClassWriter.COMPUTE_FRAME anymore. (#234) 2023-01-02 14:21:51 +08:00
ZekerZhayard fbec7ce6bb Support 1.19.3. Remove Vanilla 1.19.2. (#231) 2022-12-12 02:26:22 +08:00
33 ea1b25a38f Tweak: add debug argument to Gradle 2022-12-07 21:24:51 +08:00
33 62018a3e8b Tweak: use Gradle Wrapper 2022-12-07 19:52:11 +08:00
ZekerZhayard f38a8ddcef Refactor SkinManager (#230) 2022-12-07 19:38:24 +08:00
33 63251c9f5e Add: a switch for printing to standard output 2022-11-24 21:42:45 +08:00
33 e94f4b0e99 Release: 14.14 2022-10-19 11:35:43 +08:00
33 5ee2eee382 Add: LICENSE 2022-08-27 10:42:38 +08:00
ZekerZhayard 3063de7ff0 Support 1.19.2. Remove Vanilla 1.19.1. (#220) 2022-08-17 10:47:26 +08:00
33 583bf1fe6a Tweak: calculate correct hash for base64 texture 2022-07-29 02:29:15 +08:00
33 a3de21497d Fix: MinecraftCapesAPI 2022-07-29 02:15:19 +08:00
33 51aec265be Tweak: LegacyLoader UUID fallback logic 2022-07-29 01:14:50 +08:00
33 52caeb3bdc Tweak: compatible with authlib 3.11.50 2022-07-29 00:07:04 +08:00
33 a3fa4e47c6 Fix: MinecraftCapesAPI load profile only with existing UUID 2022-07-29 00:05:51 +08:00
33 e1cde0afc7 Tweak: correct MinecraftCapesAPI name 2022-07-28 11:04:27 +08:00
33 3f379f3cbe Tweak: register MinecraftCapesAPI 2022-07-28 11:03:27 +08:00
33 f50640139a Add: MinecraftCapesAPI 2022-07-28 10:59:54 +08:00
ZekerZhayard 46b8635e10 Support 1.19.1. Remove Vanilla 1.19. (#218) 2022-07-28 09:24:44 +08:00
33 02b24229f3 Update: LittleSkin root url 2022-07-28 08:44:30 +08:00
33 941b421d86 Fix: CDN cache wasn't be updated correctly 2022-07-28 08:43:41 +08:00
33 a67ed507ec Fix: CurseForge metadata json 2022-07-27 20:32:55 +08:00
33 851fa81f31 Tweak: change log level in build 2022-07-27 19:47:12 +08:00
33 5bb16ededa Fix: CurseForge uploading 2022-07-27 19:31:32 +08:00
33 1e5bfcd1e7 Fix: Minecraft version getting logic 2022-07-27 17:23:50 +08:00
ZekerZhayard 1b85fa8ff9 Convert all build scripts to buildSrc. (#216) 2022-07-20 23:11:48 +08:00
33 e1e5319bdb Add: detail.json with detailed downloading information 2022-07-19 22:22:14 +08:00
33 187be47e88 Add: Custom Gradle Plugin in buildSrc 2022-07-19 20:40:53 +08:00
ZekerZhayard b2f8d2cc38 Support 1.19, Remove Vanilla 1.17.1 (#211) 2022-06-09 10:00:10 +08:00
ZekerZhayard 8b641e0227 Support Fabric 22w14a. (#208) 2022-04-14 19:52:11 +08:00
ZekerZhayard c90cea3721 Remove transformers of SkullTileEntity (#207)
* Bump to 14.14

* Remove transformers of SkullTileEntity
2022-04-01 13:56:20 +08:00
33 b0c11d11c6 Fix curseforge and modrinth release 2022-03-17 11:07:25 +08:00
33 c77ac58f6d Release CustomSkinLoader 14.13 2022-03-17 10:41:59 +08:00
ZekerZhayard 16fadc56b4 Support Forge/Fabric/Vanilla 1.18.2. Remove Vanilla 1.18.1. (#206) 2022-03-03 17:31:20 +08:00
33 fc6c43bac9 Fix standalone elytra url (#204) 2022-02-22 17:38:53 +08:00
ZekerZhayard b6fc1610bc Fix skull not loading if not need to judge type. (#201) 2022-01-24 13:58:06 +08:00
ZekerZhayard c7d04976e6 Fix skin type judgement from cache. (#200)
Signed-off-by: ZekerZhayard <[email protected]>
2022-01-09 21:58:59 +08:00
ZekerZhayard 0eaf1960bf Support Fabric/Forge/Vanilla 1.18.1. (#196)
* Support Fabric and Vanilla 1.18.

Signed-off-by: ZekerZhayard <[email protected]>

* Support Fabric and Vanilla 1.18.

Signed-off-by: ZekerZhayard <[email protected]>

* Support Fabric, Forge and Vanilla 1.18.1.

Signed-off-by: ZekerZhayard <[email protected]>
2021-12-11 16:27:36 +08:00
ZekerZhayard cff5846e7f Fix NPE if type is null. (#195)
* Fix NPE if type is null.

Signed-off-by: ZekerZhayard <[email protected]>

* Forge does not support Java 18 for now.

Signed-off-by: ZekerZhayard <[email protected]>
2021-11-28 02:17:38 +08:00
ZekerZhayard c8fb6e216e Finish loader names for Modrinth. (#193)
Signed-off-by: ZekerZhayard <[email protected]>
2021-11-12 19:14:07 +08:00
ZekerZhayard a5d466e0a7 Added support for automatic upload to CurseForge and Modrinth. (#190)
* Added support for automatic upload to CurseForge and Modrinth.

Signed-off-by: ZekerZhayard <[email protected]>

* Fix defining environment variable in circle ci.

Signed-off-by: ZekerZhayard <[email protected]>

* Fix defining environment variable in circle ci.

Signed-off-by: ZekerZhayard <[email protected]>

* Finish fixing defining environment.

Signed-off-by: ZekerZhayard <[email protected]>
2021-11-04 14:55:59 +08:00
Uriel 31fffa5d23 support tlauncher (#188)
* support tlauncher

* it works

* Update README.md

* simplify things

* undo wildcard

* facepalm

* update tlauncher info
2021-11-04 14:52:05 +08:00
ZekerZhayard 7e9f7fa498 Compatible with fabric-loader-0.12.x in development environment. (#189)
Signed-off-by: ZekerZhayard <[email protected]>
2021-10-16 01:41:54 +08:00
ZekerZhayard f51b55be6e Fix compatible with OptiFine 1.17.1. (#186) 2021-10-03 18:06:58 +08:00
ZekerZhayard 584c7b7518 Improve skin loading logic. (#180) 2021-09-24 11:19:06 +08:00
ZekerZhayard 51c8900562 Support Forge 1.17.1. (#177) 2021-07-25 15:48:50 +08:00
ZekerZhayard ab7aebb753 Support Vanilla and Fabric 1.17.1. Remove Vanilla 1.17. (#175) 2021-07-07 00:21:36 +08:00
ZekerZhayard dc5ecfb576 Support Vanilla and Fabric 1.17. Remove Vanilla 1.15.2. (#171)
* Support Fabric 1.17-rc2.

* Support Vanilla and Fabric 1.17. Remove Vanilla 1.15.2.
2021-06-09 14:55:20 +08:00
ZekerZhayard 04899ff676 Support Fabric 1.17-pre1. (#170) 2021-05-29 18:53:27 +08:00
ZekerZhayard 4df8ce38d6 Fix CustomSkinAPIPlus loading incorrectly. Fix unable to complete config with default value. (#168) 2021-05-25 12:55:42 +08:00
ZekerZhayard 3e001c4cdf Fix elytra can not be rendered when the cape doesn't contain elytra. (#160)
* Fix elytra can not be rendered when the cape doesn't contain elytra.

* Fix typo.

* Streamline IFakeThreadDownloadImageData.

* Fix wrong arguments.

* Add compatible with other custom player model mods, such as tr7zw/FirstPersonModel
2021-05-07 17:15:45 +08:00
ZekerZhayard d5dea652ff Induce users to download the pre-release version. (#164)
* Induce users to download the pre-release version.

* Add contact us.

* Some versions of forge-1.13.2 is not compatible because of the strong limitation of CoreMods-0.3.0.
2021-05-07 17:10:01 +08:00
ZekerZhayard 2a4226527d Prevent authlib-injector from modifying urls. (#159) 2021-05-01 22:46:02 +08:00
ZekerZhayard 6c9494970f Enhanced default skin loaders. (#157)
* Enhance ICustomSkinLoaderPlugin.

* Support auto update config file per snapshot. Fix crash with forge 1.14.2 ~ 1.15.2.

* ElyByAPI should check root now.

* Remove unnecessary packages, add some deprecated loaders.

* Reformat imports.

* Move forge stuffs to another commit.

* Fix config updating incorrectly.
2021-04-24 10:33:18 +08:00
ZekerZhayard c84f506af1 Fix crash with forge 1.14.2~1.16.2. Upgrade forge maven. (#158)
* Fix crash with forge 1.14.2~1.16.2. Upgrade forge maven.

* Update forge maven url.
2021-04-23 22:07:53 +08:00
ZekerZhayard a0e31ed883 Change Mixin priority to prevent potential Mixin conflict. (#154) 2021-04-22 11:03:06 +08:00
ZekerZhayard 8befcb32d8 No longer remove any elements in SkinManager. (#151) 2021-03-27 19:32:00 +08:00
ZekerZhayard fb50a3db6d Support Fabric 21w10a. (#148) 2021-03-13 19:47:18 +08:00
ZekerZhayard 4daacd18e8 Make it easier to build the development environment. (Phase 2) (#147)
* Make it easier to build the development environment. (Phase 2)

* Provide sources jar.

* Add development guide.

* Improve development guide.
2021-03-13 19:46:51 +08:00
ZekerZhayard 98681e8251 Remove updateGameProfile transformer. (#143)
* Add an option to control updateGameProfile transformer.

* Remove unnecessary FrameNodes
2021-02-08 11:37:04 +08:00
ZekerZhayard ea5d890992 Support 1.16.5. Remove 1.16.4 Vanilla. (#141) 2021-01-17 01:57:36 +08:00
ZekerZhayard f5135872cc Fix rendering transparent capes for Forge 1.15+. (#140) 2021-01-12 22:59:14 +08:00
ZekerZhayard 5d736dd4b5 Fix sign jar. (#137) 2021-01-04 15:29:34 +08:00
ZekerZhayard 1b2a4dc260 Make it easier to build the development environment. (#133)
* Fix the warning about removing duplicate source roots when open the project with Intellij IDEA.

* Add Gradle wrapper.

* CustomSkinLoader can be loaded in Forge development environment now.

* CustomSkinLoader can be loaded in Fabric development environment now.
2021-01-03 02:53:57 +08:00
ZekerZhayard 855131d1aa Fix DefaultFMLPlatform can't be loaded when other FML platform being used. (#132) 2020-12-20 01:02:07 +08:00
ZekerZhayard 581a2dddea Change the ordinal of FMLLoadingPlugin to fix the crash with BetterFps before Minecraft 1.10.2. (#131)
Clean up codes.
2020-12-15 21:17:10 +08:00
ZekerZhayard a1b52eb7ac Fix version.json parser, compatible with 20w45a. (#128) 2020-11-05 21:54:43 +08:00
Alexander Xia 0ed371fdc1 Remove GitHub maven temporarily 2020-11-05 18:08:26 +08:00
ZekerZhayard ee7e57cf78 Support 1.16.4. Remove 1.16.3 Vanilla. (#127) 2020-11-05 11:53:12 +08:00
ZekerZhayard 90ed224dd8 Fix ResourceLocation characters limitation for Minecraft 1.13+ (#126) 2020-11-05 11:52:49 +08:00
ZekerZhayard a65445e989 Make sure the mod being absent on the other network side does not cause the client to display the server as incompatible after forge-1.13.2-25.0.107. (#124) 2020-11-05 11:52:36 +08:00
ZekerZhayard da79597a16 Fix crash on launch with forge-1.16.3-34.1.27. (#122) 2020-10-27 21:52:29 +08:00
ZekerZhayard 9c6102a813 Fix incorrect method descriptions. (#119) 2020-09-29 21:19:15 +08:00
ZekerZhayard 573c5e4a20 Fabric and vanilla jars can be signed now. (#118) 2020-09-27 16:57:36 +08:00
ZekerZhayard 12441cc379 Fix rendering transparent skins and capes for 19w41a+. (#117)
* Support 1.16.3. Remove 1.16.2 Vanilla.

* Fix rendering transparent skins and capes for 19w41a+.
2020-09-20 21:12:14 +08:00
ZekerZhayard 7df6336b56 Support 1.16.3. Remove 1.16.2 Vanilla. (#116) 2020-09-11 22:55:26 +08:00
ZekerZhayard 2dd69e08da Fix InvalidMixinException before 1.15-snapshot. (#115) 2020-09-02 12:30:25 +08:00
ZekerZhayard 67fbcf5cec Fix crashes caused by incorrect stack frames. (#114) 2020-09-02 12:29:54 +08:00
ZekerZhayard f898831276 Prepare for compatibility with 1.7.10. (#113) 2020-08-29 17:20:44 +08:00
ZekerZhayard 83042f45bd Allow APortingCore to load CustomSkinLoader. (#112) 2020-08-24 11:52:23 +08:00
ZekerZhayard dc6d135699 Add the function to print the System and Java version to the log file. (#111) 2020-08-21 12:51:59 +08:00
Alexander Xia f42496e04c Tweak cache config 2020-08-16 22:18:25 +08:00
Alexander Xia f003d57ddf Tweak thread pool 2020-08-16 21:55:06 +08:00
Alexander Xia b64700b9fb Add forceDisableCache 2020-08-16 21:07:22 +08:00
ZekerZhayard f64af50a07 Improve downloading http textures. (#108) 2020-08-16 19:50:19 +08:00
Alexander XiaandZekerZhayard a8c8edaf20 Support 1.16.2 Fabric, Forge and Vanilla. Remove 1.16.1 Vanilla. (#107)
* Support 1.16.2 Fabric, Forge and Vanilla. Remove 1.16.1 Vanilla.

* Delete build.properties

* Create build.properties

Co-authored-by: ZekerZhayard <[email protected]>
2020-08-13 16:22:16 +08:00
Alexander Xia 5ebee1f1e0 Bump 14.12 2020-07-06 23:01:40 +08:00
Alexander Xia 1eb8db550f Fix custom launchwrapper 2020-07-06 22:57:31 +08:00
Alexander Xia 52a232f982 Update custom launchwrapper version 2020-07-06 22:54:49 +08:00
ZekerZhayard eeebc30b58 Apply custom launchwrapper. (#102) 2020-07-02 01:08:24 +08:00
Evan Goode 46bccadca2 Escape URLs, for usernames with spaces (#100) 2020-07-01 22:47:47 +08:00
ZekerZhayard d7f207177c Apply ModSystemTweaker when another tweaker being applied. (#101) 2020-07-01 22:47:40 +08:00
ZekerZhayard 339e30247a Add "launchermeta" to "latest.json". (#99) 2020-06-30 23:45:37 +08:00
ZekerZhayard ba8d86789d Support Vanilla 1.8.9, 1.12.2, 1.15.2, 1.16.1. (#98)
* Support Vanilla 1.8.9, 1.12.2, 1.15.2, 1.16.1.

* Move vanilla specific version folders to "Vanilla" folder.

* Fix launchwrapper dependency.

* Update profile.

* Move customskinloader.fabric.mixin to customskinloader.mixin
2020-06-29 01:33:53 +08:00
ZekerZhayard a9f19cfc8d Allow users to customize the size of thread pools. (#86)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2

* Fix lag spike while loading player skull textures.

* Allow users to customize the size of thread pools.

* Use the old scheme about loading skulls to avoid blocking the thread pool when "enableUpdateSkull" is true.

* Fix merge.
2020-06-29 00:57:42 +08:00
ZekerZhayard 8b1400ef0d Support Forge 1.16.x. (#97)
* Support Forge 1.16.x.

* Add Minecraft versions.
2020-06-29 00:56:41 +08:00
Steven Qiu 82c2e80e76 Update LittleSkin's API Root (#96) 2020-06-23 21:16:20 +08:00
ZekerZhayard 8146773354 Fix legacy model auto judge for 1.15.x (#93) 2020-05-21 10:30:45 +08:00
Alexander Xia 5ac6aa1865 Fix legacy model auto judge
Thanks to @ZekerZhayard
2020-05-21 02:37:51 +08:00
Alexander Xia dab8e3dd22 Fix legacy model auto judge 2020-05-20 18:38:31 +08:00
ZekerZhayard fdceb08a2c Fix skull loading lag for Minecraft 1.13.2 or older version. (#91) 2020-05-15 22:51:04 +08:00
ZekerZhayard ad846f37a2 Support Fabric 20w17a. (#90) 2020-05-12 17:07:30 +08:00
ZekerZhayard b8ce13606b Fix SkullTileEntityTransformer. (#88) 2020-04-17 20:19:23 +08:00
Steven Qiu 2fbd3965e0 Update LittleSkin's API root (#87) 2020-04-17 11:21:54 +08:00
Alexander Xia a714670b9a Fix GitHub publish in pull request 2020-03-29 22:57:28 +08:00
Alexander Xia c5460624e3 Fix typo 2020-03-29 19:56:52 +08:00
Alexander Xia 9f63a770c3 Fix concurrent issue 2020-03-26 10:22:20 +08:00
ZekerZhayard 4d234762d2 Fix lag spike while loading player skull textures. (#84)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2

* Fix lag spike while loading player skull textures.
2020-03-25 11:58:01 +08:00
Alexander Xia 730b565c59 Fix transform script 2020-03-25 10:54:31 +08:00
Alexander Xia 4d12d70bf0 Fix skull loading lag
#79
2020-03-25 10:17:28 +08:00
Alexander Xia 42adcb5b27 Add thread pool to load skull
#79
2020-03-24 11:46:11 +08:00
Alexander Xia 77ddcc8bf5 Add GitHub Packages 2020-03-11 17:26:28 +08:00
Alexander Xia d46adaac5e Tweak transformer to avoid repeated modification 2020-03-04 15:51:54 +08:00
Alexander Xia a6666b53a1 Fix UniSkinAPI elytra 2020-02-22 03:05:38 +08:00
ZekerZhayard 958860ecce Support Forge & Fabric 1.15.2 (#78)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2
2020-01-24 16:56:26 +08:00
ZekerZhayard 6fab945eb1 Support Forge for Minecraft 1.15.x (#77) 2019-12-18 15:07:46 +08:00
ZekerZhayard e19b9d860f Support Fabric for Minecraft 1.15.x (#75)
* Support Fabric for Minecraft 1.15.x

* Remove unused imports
2019-12-11 18:53:57 +08:00
ZekerZhayard 7adb0f9ef7 Fix PlayerTab for 1.14+ in Fabric. (#72) 2019-12-10 12:52:55 +08:00
Alexander Xia 1bb130bb87 Add latest.json 2019-12-10 03:10:26 +08:00
Alexander Xia 779e25f837 Init CustomSkinLoader earlier 2019-12-09 23:47:29 +08:00
Alexander Xia 3a2d8f9caf Fix PlayerTab in 1.14+ again 2019-12-09 23:20:52 +08:00
Alexander Xia 0c91fb3975 Fix PlayerTab in 1.14+ 2019-12-09 23:10:27 +08:00
Alexander Xia 290cbb63d8 Support UUID in Legacy Loader
Update copyright statement
#65 #66
2019-10-03 15:30:46 +08:00
Alexander Xia 100e661ac5 Add 1.14.4 vanilla 2019-09-20 22:07:58 +08:00
Alexander Xia c490631f2c Fix spelling mistake 2019-09-20 16:33:04 +08:00
Alexander Xia c519d09be4 Fix content type which causes 415 2019-09-20 11:44:07 +08:00
Alexander Xia e5a31ae49e Add custom Yggdrasil api & sessionserver root 2019-09-18 22:50:04 +08:00
Alexander Xia 68615ba724 Add custom Yggdrasil root 2019-09-18 22:15:58 +08:00
Alexander Xia 10e57fe349 Bump 14.11 2019-08-27 17:55:49 +08:00
Alexander Xia 9f70ad0159 Update upload url 2019-06-25 15:24:14 +08:00
ZekerZhayard 0d5538a110 Support for forge 1.14.2 (#59)
* Support for forge 1.14.2

* Delete unnecessary code.
2019-06-25 14:38:40 +08:00
Alexander Xia 27efbbfeb0 Fix addScheduledTask method not found 2019-06-24 20:07:48 +08:00
Alexander Xia 7fad8c602d Add 1.14.2 forge suport 2019-06-24 19:52:02 +08:00
Alexander Xia 29a0952bc4 Fix compatibility with ModLauncher 1.1 (#57) 2019-06-15 17:37:48 +08:00
Alexander Xia b7107b7172 Remove 1.13.2 vanilla 2019-05-24 00:06:35 +08:00
Alexander Xia 2adbc25f69 Fix gradle upload 2019-05-23 23:47:33 +08:00
ZekerZhayard 3bee9281ec Fix remapJar (#55) 2019-05-23 23:35:56 +08:00
ZekerZhayard 917f9f650b Support Fabric for 1.14.1 (#53)
* Fix ClassCastException

* Support Fabric for 1.14.1

* Support Fabric for 1.14.1

* Use mapping file instead of hard code
2019-05-22 23:47:59 +08:00
LionZXY edf6e241e4 Add GlitchlessAPI (#51)
* Add GlitchlessAPI

* Fix build and move GlitchlessSkin to down
2019-05-10 16:20:39 +08:00
Alexander Xia d2c65f00c9 Remove meaningless log 2019-04-26 13:59:08 +08:00
Alexander Xia 95ee345441 Fix 1.14 skin load 2019-04-26 13:56:22 +08:00
Alexander Xia 3ade4867d4 Add 1.14 to settings.gradle 2019-04-26 10:36:20 +08:00
Alexander Xia 2d1951774d Add 1.14 support 2019-04-26 10:34:31 +08:00
ZekerZhayard cc3616a074 Add CSLPluginsLoader (#48)
* Add CSLPluginsLoader

* Remove plugin loader. Add some events.

* Use ServiceLoader to load plugins

* Remove PluginClassLoader.
2019-03-08 13:38:44 +08:00
xfl03 42c48c5c2e Bump 14.10a 2019-03-05 19:33:09 +08:00
xfl03 030daf12a2 Fix 1.8 forge support 2019-03-04 20:12:13 +08:00
xfl03 88763d64ef Bump 14.10 2019-03-03 12:20:28 +08:00
xfl03 4f2b5edf84 Fix incorrect response code judgement 2019-03-03 11:53:48 +08:00
xfl03 cbe07b9003 Fix http redirect to https 2019-03-03 11:34:54 +08:00
xfl03 b2867a0dbf Add support for 1.13.2 forge 2019-03-02 12:26:53 +08:00
xfl03 65dacd8527 Fix javascript cannot expand 2019-03-01 20:31:23 +08:00
xfl03 d2d425e96e Remove 1.13 & 1.13.1 in settings.gradle 2019-03-01 20:10:50 +08:00
xfl03 0762e3e339 Remove support for vanilla 1.13 & 1.13.1 2019-03-01 20:08:22 +08:00
xfl03 4cb1e348bb Try to support 1.13 forge 2019-03-01 14:59:02 +08:00
Alexander Xia 7bbfd19bfd Fix no content cache 2019-02-06 00:39:17 +08:00
Alexander Xia be8b80bd55 Tweak CircleCI Docker Image 2019-01-05 00:20:22 +08:00
Alexander Xia 47de6d3a89 Add workaround for #42 2019-01-05 00:12:42 +08:00
Alexander Xia f78a3b2565 Add disable cape feature 2018-11-26 15:16:07 +08:00
Alexander Xia 016249c6ca Fix version display again 2018-11-25 02:33:12 +08:00
Alexander Xia 860edd2e1a Fix version display 2018-11-25 02:13:55 +08:00
Alexander Xia 3e6e444857 Fix gradle script buid again 2018-11-25 02:08:54 +08:00
Alexander Xia d67b7c6296 Fix gradle script buid again 2018-11-25 02:04:36 +08:00
Alexander Xia 94f6044c9a Fix gradle script build error 2018-11-25 01:53:28 +08:00
Alexander Xia 6b3531964e Tweak version json name 2018-11-25 01:44:06 +08:00
Alexander Xia fbd06f147a Modify gradle script 2018-11-24 01:38:49 +08:00
Alexander Xia e3020dad00 Add Upload Version json to COS 2018-11-23 03:23:17 +08:00
Alexander Xia 49fb976a2c Fix COS upload path 2018-11-23 02:48:19 +08:00
Alexander Xia 78bc4b5f7e Try to upload file to COS 2018-11-23 02:43:30 +08:00
Alexander Xia 7a3dc4f9c2 Support for 1.13.2 2018-11-02 14:48:07 +08:00
Alexander Xia 2087f7bb94 Tweak: Change Profile.json mirror 2018-09-23 23:44:25 +08:00
Alexander Xia e95edb16ac Add: Vanilla Support for 1.13.1 2018-09-23 23:00:34 +08:00
Alexander Xia 3b07b5ccca Update config version checker
Update config output
Add enableCape in config
2018-09-02 15:57:08 +08:00
xfl03 a3fb3cd770 Fix Build 2018-08-26 07:16:37 +08:00
xfl03 b7b59c0b85 Support ModLauncher 2018-08-26 07:04:25 +08:00
Alexander Xia db6b54732e Update MCP map to stable 2018-08-22 03:42:50 +08:00
Alexander Xia 09e3b81552 Fix path for ForgePlugin.log 2018-08-20 19:23:47 +08:00
Alexander Xia 2f494d295e Update Forge Version 2018-08-13 05:15:32 +08:00
Alexander Xia e8e3a72ae7 Add Fingerprint Violation 2018-08-13 05:11:47 +08:00
Alexander Xia ca8bd4e83d Add Profile.json for vanilla edition
Remove CustomSkinAPIPlusPrivacy
Fix typo in ReadMe
Update mcp map
2018-08-11 07:34:13 +08:00
Alexander Xia d789119c8f Get Ready for Forge 1.13 2018-07-26 20:50:41 +08:00
Alexander Xia bfd1b41ecc Update ReadMe
Thanks for @HeartyYF
2018-07-26 13:19:33 +08:00
200 changed files with 11285 additions and 47913 deletions

No files matched your search

-36
View File
@@ -1,36 +0,0 @@
# Java Gradle CircleCI 2.0 configuration file
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
- restore_cache:
keys:
- gradle-cache
# Gradle Wrapper
# - run: sudo chmod +x gradlew
# - run: ./gradlew --version
# - run: ./gradlew clean build
# Gradle
- run: gradle --version
- run: gradle clean build
- store_artifacts:
path: ./build/libs
- save_cache:
paths:
- ~/.gradle
key: gradle-cache
+8
View File
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Telegram
url: https://t.me/customskinloader
about: Community chat for CustomSkinLoader users.
- name: QQ Group
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
about: Chinese community chat for CustomSkinLoader users.
+126
View File
@@ -0,0 +1,126 @@
name: Report Bug
description: Report a bug and help us improve CustomSkinLoader
labels: [ bug ]
title: "[Bug] "
body:
- type: markdown
attributes:
value: |
Here is the Report Bug issue for CustomSkinLoader
With a red asterisk for the mandatory items
Please keep the work order content neat and tidy, do not paste the contents of the log file directly onto the work order, it will look very messy and unattractive work orders
- type: textarea
id: description
attributes:
label: Describe the bug
description: |
A clear and concise description of what the issue is.
Provide as much information as possible, videos, crash reports, etc.
DO NOT PASTE A CRASH REPORT HERE!!!
validations:
required: true
- type: textarea
id: reproducing
attributes:
label: Steps to reproduce
description: How do you trigger this bug?
render: bash
value: |
1.
2.
3.
validations:
required: true
- type: input
id: crash-report
attributes:
label: Link to crash-report if applicable
description: |
The files are in the folder `<minecraft-directory>/crash-reports`
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: csl-log
validations:
required: true
attributes:
label: Link to CustomSkinLoader.log if applicable
description: |
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: latest-log
attributes:
label: Link to latest.log if applicable
description: |
The path to the file is `<minecraft-directory>/logs/latest.log`.
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: forge-log
attributes:
label: "[Only Forge User] Link to Forge Log if applicable"
description: |
The path to the file is `<minecraft-directory>/logs/debug.log` or `<minecraft-directory>/logs/fml-client-latest.log`.
if your mod loader isn't `Forge`, URL can set empty
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: mod-version
attributes:
label: Mod Version
placeholder: "Ex: 14.16"
validations:
required: true
- type: input
id: mc-version
attributes:
label: Minecraft Version
placeholder: "Ex: 1.19.4"
validations:
required: true
- type: input
id: mc-launcher-version
attributes:
label: Minecraft Launcher Name and Version
placeholder: "Ex: HMCL v3.5.4.232"
description: |
If you don't know the version of the game, you can just fill in the name of the game launcher
- type: dropdown
id: loader-type
attributes:
label: Mod Loader
options:
- Quilt
- Fabric
- Forge
- <without mod loader>
validations:
required: true
- type: dropdown
id: operating-systems
attributes:
label: Operating System
options:
- Windows
- Linux
- macOS
- Other
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: Before submitting a bug report
options:
- label: |
This bug wasn't already reported (I have searched bug reports on GitHub).
required: true
- label: |
This is a valid bug (I am able to reproduce this on the latest dev build).
required: true
- label: |
This problem is triggered in the latest version of the mod (if not the latest please upgrade the mod first)
required: true
+127
View File
@@ -0,0 +1,127 @@
name: 提交问题
description: 报告问题以帮助我们改进CustomSkinLoader
labels: [ bug ]
title: "[Bug] "
body:
- type: markdown
attributes:
value: |
你好,这里是 `CustomSkinLoader`
标注红色星号的为必填项
以及,保持工单干净整洁,不要直接将日志内容粘贴到工单上,比如粘贴到描述内是不行的
- type: textarea
id: description
attributes:
label: 描述问题
description: |
简单的描述问题, 并提供类似图片、视频,以更好的报告错误(如果可以)
!注意:请不要在这里放日志文件或崩溃报告文件的内容
validations:
required: true
- type: textarea
id: reproducing
attributes:
label: 复现步骤
description: 请问你是如何触发这个问题的
render: bash
value: |
1.
2.
3.
validations:
required: true
- type: input
id: crash-report
attributes:
label: 崩溃报告查看地址
description: |
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
客户端若无崩溃则直接填写 `客户端无崩溃`
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: csl-log
validations:
required: true
attributes:
label: CustomSkinLoader.log 查看地址
description: |
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: latest-log
attributes:
label: latest.log 查看地址
description: |
文件路径:`<游戏路径>/logs/latest.log`.
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: forge-log
attributes:
label: "[仅Forge用户] Forge Log 查看地址"
description: |
文件路径:`<游戏路径>/logs/debug.log` 或者 `<游戏路径>/logs/fml-client-latest.log`.
若没有使用 `Forge` 加载器的,可以不填写
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: mod-version
attributes:
label: 模组版本
placeholder: "示例: 14.16"
validations:
required: true
- type: input
id: mc-version
attributes:
label: Minecraft游戏版本
placeholder: "示例: 1.19.4"
validations:
required: true
- type: input
id: mc-launcher-version
attributes:
label: Minecraft启动器 名称 及 版本
placeholder: "示例: HMCL v3.5.4.232"
description: |
若不知道游戏版本 可以只填写游戏启动器的名称
validations:
required: true
- type: dropdown
id: loader-type
attributes:
label: 模组加载器
options:
- Quilt
- Fabric
- Forge
- 不使用加载器
validations:
required: true
- type: dropdown
id: operating-systems
attributes:
label: 操作系统
options:
- Windows
- Linux
- macOS
- 其他操作系统
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: 在提交错误报告之前,有没有做到...
options:
- label: |
先尝试搜索issues里面, 查看并确认打开或关闭的工单, 是否搜索不到
required: true
- label: |
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
required: true
- label: |
这个问题是在最新的mod版本触发(若不是最新的请先升级mod)
required: true
@@ -0,0 +1,22 @@
name: Suggestion
description: Suggest a new feature or change for CustomSkinLoader.
labels: [ enhancement ]
body:
- type: textarea
id: description
attributes:
label: Describe the feature
description: A clear and concise description of what the feature/change is.
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: Before submitting a suggestion
options:
- label: |
This feature doesn't already exist in the client. (I have checked every module and their settings on the **latest dev build**)
required: true
- label: |
This wasn't already suggested. (I have searched suggestions on GitHub and read the FAQ)
required: true
@@ -0,0 +1,22 @@
name: 反馈或建议
description: 给CustomSkinLoader这个模组提个建议
labels: [ enhancement ]
body:
- type: textarea
id: description
attributes:
label: 描述一下
description: 简单描述一下该功能/变化是什么。
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: 在提交反馈或建议之前,请先确认...
options:
- label: |
你要提交的反馈或者建议不存在于本模组的最新开发版下.
required: true
- label: |
以及在issues或者Wiki内搜索过, 并且无结果
required: true
+55
View File
@@ -0,0 +1,55 @@
# Composite action: setup JDK, build with Gradle, upload artifact
name: Build
description: Build project with Gradle and upload artifact
inputs:
artifact-name:
description: Artifact name for upload
required: true
outputs:
mod_name:
description: Display name of the mod
value: ${{ steps.info.outputs.mod_name }}
edition:
description: Target mod loader edition
value: ${{ steps.info.outputs.edition }}
short_version:
description: Shortened version identifier
value: ${{ steps.info.outputs.short_version }}
loaders:
description: List of supported mod loaders
value: ${{ steps.info.outputs.loaders }}
game_versions:
description: List of compatible Minecraft game versions
value: ${{ steps.info.outputs.game_versions }}
java:
description: List of compatible Java versions
value: ${{ steps.info.outputs.java }}
runs:
using: composite
steps:
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '25'
cache: gradle
- name: Build with Gradle
shell: pwsh
run: |
./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }}
./gradlew --stop
- name: Generate metadata JSONs
if: github.event_name != 'pull_request'
shell: pwsh
id: info
run: ./.github/scripts/Get-PublishInfo.ps1 -ArtifactDir 'Bootstrap/build/libs' -Type '${{ github.event_name }}'
- uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-name }}
path: Bootstrap/build/libs/
if-no-files-found: error
@@ -0,0 +1,56 @@
name: Publish to Object Storage
description: >-
Upload build artifacts to an S3-compatible object store (AWS S3, Cloudflare
R2, MinIO, etc.). Requires the AWS CLI to be pre-installed on the runner.
inputs:
artifact-path:
description: Path to the directory containing build artifacts.
required: true
endpoint-url:
description: S3-compatible endpoint URL.
required: true
bucket:
description: S3 bucket name.
required: true
access-key-id:
description: S3-compatible access key ID.
required: true
secret-access-key:
description: S3-compatible secret access key.
required: true
region:
description: AWS region (use 'auto' for Cloudflare R2).
required: false
default: 'auto'
target-path:
description: Key prefix in the bucket (e.g., 'mods').
required: false
default: ''
files:
description: Glob pattern for files to upload.
required: false
default: '*'
runs:
using: composite
steps:
- name: Validate artifact path
shell: pwsh
run: |
$path = "${{ inputs.artifact-path }}"
if (-not (Test-Path -LiteralPath $path)) {
throw "Artifact path not found: $path"
}
- name: Upload to object storage
shell: pwsh
env:
AWS_ACCESS_KEY_ID: ${{ inputs.access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.secret-access-key }}
AWS_DEFAULT_REGION: ${{ inputs.region }}
run: |
$ErrorActionPreference = "Stop"
Get-ChildItem -Path "${{ inputs.artifact-path }}" -Filter "${{ inputs.files }}" | ForEach-Object {
aws s3 cp "$($_.FullName)" "s3://${{ inputs.bucket }}/${{ inputs.target-path }}$($_.Name)" --endpoint-url "${{ inputs.endpoint-url }}"
}
@@ -0,0 +1,51 @@
name: Publish to GitHub Release
description: Upload build artifacts to a GitHub Release. Requires contents:write permission at the workflow level.
inputs:
artifact-path:
description: Path to the directory containing build artifacts.
required: true
tag-name:
description: Git tag for the release.
required: true
token:
description: GitHub token with contents:write permission.
required: true
files:
description: Glob pattern(s) for files to upload (passed to gh release create).
required: false
default: '*'
notes-file:
description: Path to file containing release body text.
required: false
prerelease:
description: Mark as a pre-release (true/false).
required: false
default: 'false'
generate-notes:
description: Auto-generate release notes from merged commits (true/false).
required: false
default: 'false'
runs:
using: composite
steps:
- name: Validate artifact path
shell: pwsh
run: |
$path = "${{ inputs.artifact-path }}"
if (-not (Test-Path -LiteralPath $path)) {
throw "Artifact path not found: $path"
}
- name: Create GitHub Release
shell: pwsh
env:
GH_TOKEN: ${{ inputs.token }}
run: |
$ErrorActionPreference = "Stop"
$tag = '${{ inputs.tag-name }}'
gh release delete "$tag" --yes --cleanup-tag
gh release create "$tag" '${{ inputs.artifact-path }}/${{ inputs.files }}' --title "CustomSkinLoader $tag" `
$(if('${{ inputs.prerelease }}' -eq 'true') { '--prerelease' }) `
$(if('${{ inputs.notes-file }}') { '--notes-file'; '${{ inputs.notes-file }}' } elseif ('${{ inputs.generate-notes }}' -eq 'true') { '--generate-notes' })
+68
View File
@@ -0,0 +1,68 @@
param(
[string]$ArtifactDir = '',
[string]$Type = ''
)
$ErrorActionPreference = "Stop"
# ---- Output build.info.json to GITHUB_OUTPUT ----
$info = Get-Content "build.info.json" -Raw | ConvertFrom-Json
$info.PSObject.Properties | ForEach-Object {
$name = $_.Name
$value = $_.Value
if ($value -is [array]) {
"$name<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$value | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
} else {
"$name=$value" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
}
# ---- Generate metadata JSONs ----
if (-not $ArtifactDir) { return }
if (-not (Test-Path -LiteralPath $ArtifactDir)) { throw "ArtifactDir not found: $ArtifactDir" }
$jar = Get-ChildItem -Path $ArtifactDir -Filter "*.jar" | Where-Object { $_.Name -notlike "*-sources.jar" } | Select-Object -First 1
if (-not $jar) { throw "No jar found in $ArtifactDir" }
$JarFilename = $jar.Name
$version = $info.mod_version
$isSnapshot = ($Type -ne "release")
$shortVersion = if ($isSnapshot) { "$version-s$env:GITHUB_RUN_NUMBER" } else { $version }
"short_version=$shortVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$mcVersionList = $info.game_versions | ForEach-Object {
$parts = $_ -split '\.'
"$($parts[0]).$($parts[1])"
} | Sort-Object -Unique | Sort-Object {
$v = $_ -split '\.'
[int]$v[0] * 100000 + [int]$v[1]
}
$suffix = if ($isSnapshot) { "-beta" } else { "" }
$jarKey = "mods/$JarFilename"
$baseUrl = "https://csl.3-3.dev"
@{
version = $shortVersion
downloads = @{ Universal = "$baseUrl/$jarKey" }
launchermeta = @{}
} | ConvertTo-Json -Depth 10 | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline
$details = [ordered]@{}
foreach ($mcVer in $mcVersionList) {
$details[$mcVer] = @{
Fabric = "$baseUrl/$jarKey"
Forge = "$baseUrl/$jarKey"
NeoForge = "$baseUrl/$jarKey"
Quilt = "$baseUrl/$jarKey"
}
}
@{
version = $shortVersion
timestamp = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
details = $details
} | ConvertTo-Json -Depth 10 | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline
+83
View File
@@ -0,0 +1,83 @@
name: Beta
on:
push:
branches: [15-develop]
permissions:
contents: write
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/build
with:
artifact-name: CustomSkinLoader-Beta-${{ github.run_number }}
publish-release:
name: Publish to GitHub Release
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: CustomSkinLoader-Beta-${{ github.run_number }}
path: artifact
- name: Generate release body
shell: pwsh
run: |
@"
Build Time / 构建时间 : $((Get-Date).ToUniversalTime().AddHours(8).ToString("yyyy.MM.dd HH:mm"))
Auto build from branch $env:GITHUB_REF_NAME
[How to use?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
"@ | Set-Content -Path ci-build-body.md -NoNewline
- uses: ./.github/actions/publish-release
with:
artifact-path: artifact
tag-name: CI-Build
token: ${{ secrets.GITHUB_TOKEN }}
files: '*.jar'
prerelease: 'true'
notes-file: ci-build-body.md
publish-object-storage:
name: Publish to Object Storage
needs: build
runs-on: windows-latest
environment: Build
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: CustomSkinLoader-Beta-${{ github.run_number }}
path: artifact
- name: Upload jar to R2
uses: ./.github/actions/publish-object-storage
with:
artifact-path: artifact
endpoint-url: ${{ secrets.R2_BASE_URL }}
bucket: ${{ secrets.R2_BUCKET }}
access-key-id: ${{ secrets.R2_SECRET_ID }}
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
target-path: mods/
files: '*.jar'
- name: Upload JSONs to R2
uses: ./.github/actions/publish-object-storage
with:
artifact-path: artifact
endpoint-url: ${{ secrets.R2_BASE_URL }}
bucket: ${{ secrets.R2_BUCKET }}
access-key-id: ${{ secrets.R2_SECRET_ID }}
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
files: '*.json'
+16
View File
@@ -0,0 +1,16 @@
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [15-develop]
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/build
with:
artifact-name: CustomSkinLoader-PR-${{ github.run_number }}
+117
View File
@@ -0,0 +1,117 @@
name: Release
on:
release:
types: [released]
permissions:
contents: write
jobs:
build:
name: Build
runs-on: windows-latest
outputs:
mod_name: ${{ steps.build.outputs.mod_name }}
edition: ${{ steps.build.outputs.edition }}
short_version: ${{ steps.build.outputs.short_version }}
loaders: ${{ steps.build.outputs.loaders }}
game_versions: ${{ steps.build.outputs.game_versions }}
java: ${{ steps.build.outputs.java }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/build
id: build
with:
artifact-name: CustomSkinLoader-Release-${{ github.run_number }}
publish-release:
name: Publish to GitHub Release
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: CustomSkinLoader-Release-${{ github.run_number }}
path: artifact
- uses: ./.github/actions/publish-release
with:
artifact-path: artifact
tag-name: ${{ github.event.release.tag_name }}
token: ${{ secrets.GITHUB_TOKEN }}
files: '*.jar'
generate-notes: 'true'
publish-object-storage:
name: Publish to Object Storage
needs: build
runs-on: windows-latest
environment: Build
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: CustomSkinLoader-Release-${{ github.run_number }}
path: artifact
- name: Upload jar to R2
uses: ./.github/actions/publish-object-storage
with:
artifact-path: artifact
endpoint-url: ${{ secrets.R2_BASE_URL }}
bucket: ${{ secrets.R2_BUCKET }}
access-key-id: ${{ secrets.R2_SECRET_ID }}
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
target-path: mods/
files: '*.jar'
- name: Upload JSONs to R2
uses: ./.github/actions/publish-object-storage
with:
artifact-path: artifact
endpoint-url: ${{ secrets.R2_BASE_URL }}
bucket: ${{ secrets.R2_BUCKET }}
access-key-id: ${{ secrets.R2_SECRET_ID }}
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
files: '*.json'
publish-mod-sites:
name: Publish to Mod Sites
needs: build
runs-on: windows-latest
environment: Build
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: CustomSkinLoader-Release-${{ github.run_number }}
path: artifact
- uses: Kir-Antipov/[email protected]
with:
modrinth-id: idMHQ4n2
modrinth-featured: true
modrinth-unfeature-mode: subset
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 286924
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
name: ${{ needs.build.outputs.mod_name }}_${{ needs.build.outputs.edition }}_${{ needs.build.outputs.short_version }}
version: ${{ needs.build.outputs.short_version }}-${{ needs.build.outputs.edition }}
version-type: release
loaders: |
${{ needs.build.outputs.loaders }}
game-versions: |
${{ needs.build.outputs.game_versions }}
game-version-filter: releases
java: |
${{ needs.build.outputs.java }}
retry-attempts: 2
retry-delay: 10000
fail-mode: fail
files: |
artifact/*.jar
+35 -26
View File
@@ -1,32 +1,41 @@
# Java
*.class
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
!.github/actions/build
.kotlin
# Mobile Tools for Java (J2ME)
.mtj.tmp/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
# Package Files #
*.jar
*.war
*.ear
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
# VSCode
### VS Code ###
.vscode/
# eclipse
*/.classpath
.classpath
*/.project
.project
.settings/
# gradle
.gradle/
build/
# IDEA
.idea/
*.iml
out/
### Mac OS ###
.DS_Store
-2
View File
@@ -1,2 +0,0 @@
/build/
/src/main/
-44420
View File
File diff suppressed because it is too large. Load diff
-7
View File
@@ -1,7 +0,0 @@
minecraft_version=1.13
minecraft_full_versions=1.13
#forge gradle needs forge version
forge_mc_version=1.12.2
forge_version=14.23.3.2655
mappings_version=snapshot_20180505
srg_notch_map=1.13.srg
+6
View File
@@ -0,0 +1,6 @@
dependencies {
implementation 'org.ow2.asm:asm:9.9.1'
implementation 'org.ow2.asm:asm-commons:9.9.1'
implementation 'org.ow2.asm:asm-tree:9.9.1'
}
@@ -0,0 +1,17 @@
package customskinloader.bootstrap;
import java.nio.file.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class BootstrapLogger {
public static final Logger LOGGER = LogManager.getLogger("CustomSkinLoader Bootstrap");
private BootstrapLogger() {
}
public static String formatPath(Path path) {
return path == null ? "<unknown>" : path.toAbsolutePath().normalize().toString();
}
}
@@ -0,0 +1,411 @@
package customskinloader.bootstrap.installer;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import customskinloader.bootstrap.mapping.Mappings;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.Remapper;
final class BytecodeRemapper extends Remapper {
private final Map<String, String> classMappings = new HashMap<>();
private final Map<String, String> inverseClassMappings = new HashMap<>();
private final Map<String, String> fieldMappings = new HashMap<>();
private final Map<String, String> methodMappings = new HashMap<>();
private final Map<String, ClassInheritance> classInheritance = new HashMap<>();
private final Set<String> missingClassInheritance = new HashSet<>();
BytecodeRemapper(Mappings mappings) {
for (Mappings.ClassMapping classMapping : mappings.getClassMappings()) {
this.classMappings.put(classMapping.getSourceName(), classMapping.getTargetName());
this.inverseClassMappings.put(classMapping.getTargetName(), classMapping.getSourceName());
for (Mappings.FieldMapping fieldMapping : classMapping.getFieldMappings()) {
this.fieldMappings.put(this.fieldKey(classMapping.getSourceName(), fieldMapping.getSourceName()), fieldMapping.getTargetName());
}
for (Mappings.MethodMapping methodMapping : classMapping.getMethodMappings()) {
this.methodMappings.put(this.methodKey(classMapping.getSourceName(), methodMapping.getSourceName(), methodMapping.getSourceDescriptor()), methodMapping.getTargetName());
}
}
}
public void addClassInheritance(byte[] classBytes) {
ClassReader classReader = new ClassReader(classBytes);
this.classInheritance.put(classReader.getClassName(), this.readClassInheritance(classReader, false));
}
public byte[] remapClass(byte[] classBytes) throws Exception {
ClassReader classReader = new ClassReader(classBytes);
ClassWriter classWriter = new ClassWriter(0);
ClassVisitor classRemapper = (ClassVisitor) findClassRemapper().getConstructor(ClassVisitor.class, Remapper.class).newInstance(classWriter, this);
classReader.accept(classRemapper, ClassReader.EXPAND_FRAMES);
return classWriter.toByteArray();
}
private static Class<?> findClassRemapper() throws Exception {
try {
return Class.forName("org.objectweb.asm.commons.ClassRemapper");
} catch (ClassNotFoundException e) {
return Class.forName("org.objectweb.asm.commons.RemappingClassAdapter");
}
}
public String toClassEntryName(byte[] classBytes) {
return new ClassReader(classBytes).getClassName() + ".class";
}
@Override
public String map(String internalName) {
String mappedName = this.classMappings.get(internalName);
return mappedName == null ? internalName : mappedName;
}
@Override
public String mapFieldName(String owner, String name, String descriptor) {
String mappedName = this.fieldMappings.get(this.fieldKey(owner, name));
if (mappedName != null) {
return mappedName;
}
if (this.hasDeclaredField(owner, name, descriptor)) {
return name;
}
mappedName = this.findInheritedFieldMapping(owner, name, descriptor, new HashSet<>());
return mappedName == null ? name : mappedName;
}
@Override
public String mapMethodName(String owner, String name, String descriptor) {
String mappedName = this.methodMappings.get(this.methodKey(owner, name, descriptor));
if (mappedName != null || name.charAt(0) == '<') {
return mappedName == null ? name : mappedName;
}
Integer declaredAccess = this.getDeclaredMethodAccess(owner, name, descriptor);
if (declaredAccess != null && this.blocksInheritedMethodMapping(declaredAccess)) {
return name;
}
mappedName = this.findInheritedMethodMapping(owner, name, descriptor, new HashSet<>());
return mappedName == null ? name : mappedName;
}
private String findInheritedMethodMapping(String owner, String name, String descriptor, Set<String> visitedOwners) {
if (owner == null || !visitedOwners.add(owner)) {
return null;
}
ClassInheritance inheritance = this.resolveClassInheritance(owner);
if (inheritance == null) {
return null;
}
String mappedName = this.findMethodMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
for (String interfaceName : inheritance.interfaces) {
mappedName = this.findMethodMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
}
return null;
}
private String findInheritedFieldMapping(String owner, String name, String descriptor, Set<String> visitedOwners) {
if (owner == null || !visitedOwners.add(owner)) {
return null;
}
ClassInheritance inheritance = this.resolveClassInheritance(owner);
if (inheritance == null) {
return null;
}
for (String interfaceName : inheritance.interfaces) {
String mappedName = this.findFieldMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
}
return this.findFieldMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
}
private String findFieldMappingInHierarchy(String owner, String name, String descriptor, Set<String> visitedOwners) {
if (owner == null || !visitedOwners.add(owner)) {
return null;
}
ClassInheritance inheritance = this.resolveClassInheritance(owner);
String mappedName = this.fieldMappings.get(this.fieldKey(owner, name));
if (mappedName != null) {
return mappedName;
}
if (inheritance == null || inheritance.hasDeclaredField(name, descriptor)) {
return null;
}
for (String interfaceName : inheritance.interfaces) {
mappedName = this.findFieldMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
}
return this.findFieldMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
}
private String findMethodMappingInHierarchy(String owner, String name, String descriptor, Set<String> visitedOwners) {
if (owner == null || !visitedOwners.add(owner)) {
return null;
}
ClassInheritance inheritance = this.resolveClassInheritance(owner);
Integer declaredAccess = inheritance == null ? null : inheritance.getDeclaredMethodAccess(name, descriptor);
String mappedName = this.methodMappings.get(this.methodKey(owner, name, descriptor));
if (mappedName != null && (declaredAccess == null || !this.blocksInheritedMethodMapping(declaredAccess))) {
return mappedName;
}
if (inheritance == null) {
return null;
}
mappedName = this.findMethodMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
for (String interfaceName : inheritance.interfaces) {
mappedName = this.findMethodMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
if (mappedName != null) {
return mappedName;
}
}
return null;
}
private ClassInheritance resolveClassInheritance(String sourceName) {
ClassInheritance inheritance = this.classInheritance.get(sourceName);
if (inheritance != null || sourceName.startsWith("java/") || this.missingClassInheritance.contains(sourceName)) {
return inheritance;
}
inheritance = this.loadClassInheritance(sourceName);
if (inheritance == null) {
this.missingClassInheritance.add(sourceName);
return null;
}
this.classInheritance.put(sourceName, inheritance);
return inheritance;
}
private ClassInheritance loadClassInheritance(String sourceName) {
String targetName = this.map(sourceName);
InputStream inputStream = this.getResourceAsStream(targetName + ".class");
if (inputStream == null) {
return null;
}
try {
try (InputStream classInputStream = inputStream) {
return this.readClassInheritance(new ClassReader(classInputStream), true);
}
} catch (IOException ignored) {
return null;
}
}
private ClassInheritance readClassInheritance(final ClassReader classReader, final boolean unmapNames) {
final Set<String> declaredFields = new HashSet<>();
final Map<String, Integer> declaredMethods = new HashMap<>();
classReader.accept(new ClassVisitor(getASMVersion()) {
@Override
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
String normalizedDescriptor = unmapNames ? BytecodeRemapper.this.unmapDescriptor(descriptor) : descriptor;
declaredFields.add(BytecodeRemapper.this.fieldSignatureKey(name, normalizedDescriptor));
return null;
}
@Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
String normalizedDescriptor = unmapNames ? BytecodeRemapper.this.unmapDescriptor(descriptor) : descriptor;
declaredMethods.put(BytecodeRemapper.this.methodSignatureKey(name, normalizedDescriptor), access);
return null;
}
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return new ClassInheritance(
unmapNames ? this.unmapClassName(classReader.getSuperName()) : classReader.getSuperName(),
unmapNames ? this.unmapClassNames(classReader.getInterfaces()) : classReader.getInterfaces(),
declaredFields,
declaredMethods
);
}
private static int asmVersion = 0;
private static int getASMVersion() {
if (asmVersion != 0) {
return asmVersion;
}
asmVersion = Opcodes.ASM4;
int versionIdx = 5;
while (true) {
try {
Field asmField = Opcodes.class.getField("ASM" + versionIdx);
asmVersion = (int) asmField.get(null);
versionIdx++;
} catch (NoSuchFieldException | IllegalAccessException e) {
break;
}
}
return asmVersion;
}
private InputStream getResourceAsStream(String resourceName) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (contextClassLoader != null) {
InputStream inputStream = contextClassLoader.getResourceAsStream(resourceName);
if (inputStream != null) {
return inputStream;
}
}
ClassLoader ownClassLoader = NestedJarRemapper.class.getClassLoader();
if (ownClassLoader == null) {
return ClassLoader.getSystemResourceAsStream(resourceName);
}
return ownClassLoader.getResourceAsStream(resourceName);
}
private String[] unmapClassNames(String[] classNames) {
if (classNames == null || classNames.length == 0) {
return new String[0];
}
String[] unmappedClassNames = new String[classNames.length];
for (int i = 0; i < classNames.length; i++) {
unmappedClassNames[i] = this.unmapClassName(classNames[i]);
}
return unmappedClassNames;
}
private String unmapClassName(String className) {
String unmappedName = this.inverseClassMappings.get(className);
return unmappedName == null ? className : unmappedName;
}
private String unmapDescriptor(String descriptor) {
StringBuilder remappedDescriptor = null;
int copyStart = 0;
for (int i = 0; i < descriptor.length(); i++) {
if (descriptor.charAt(i) != 'L') {
continue;
}
int classNameEnd = descriptor.indexOf(';', i);
if (classNameEnd < 0) {
return descriptor;
}
String className = descriptor.substring(i + 1, classNameEnd);
String unmappedName = this.unmapClassName(className);
if (!className.equals(unmappedName)) {
if (remappedDescriptor == null) {
remappedDescriptor = new StringBuilder(descriptor.length());
}
remappedDescriptor.append(descriptor, copyStart, i + 1);
remappedDescriptor.append(unmappedName);
copyStart = classNameEnd;
}
i = classNameEnd;
}
if (remappedDescriptor == null) {
return descriptor;
}
remappedDescriptor.append(descriptor, copyStart, descriptor.length());
return remappedDescriptor.toString();
}
private Integer getDeclaredMethodAccess(String owner, String name, String descriptor) {
ClassInheritance inheritance = this.resolveClassInheritance(owner);
return inheritance == null ? null : inheritance.getDeclaredMethodAccess(name, descriptor);
}
private boolean hasDeclaredField(String owner, String name, String descriptor) {
ClassInheritance inheritance = this.resolveClassInheritance(owner);
return inheritance != null && inheritance.hasDeclaredField(name, descriptor);
}
private boolean blocksInheritedMethodMapping(int access) {
return (access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC)) != 0;
}
private String fieldKey(String owner, String name) {
return owner + '#' + name;
}
private String methodKey(String owner, String name, String descriptor) {
return owner + '#' + name + descriptor;
}
private String fieldSignatureKey(String name, String descriptor) {
return name + descriptor;
}
private String methodSignatureKey(String name, String descriptor) {
return name + descriptor;
}
private static final class ClassInheritance {
private final String superName;
private final List<String> interfaces;
private final Set<String> declaredFields;
private final Map<String, Integer> declaredMethods;
ClassInheritance(String superName, String[] interfaces, Set<String> declaredFields, Map<String, Integer> declaredMethods) {
this.superName = superName;
if (interfaces == null || interfaces.length == 0) {
this.interfaces = Collections.emptyList();
} else {
this.interfaces = Collections.unmodifiableList(Arrays.asList(interfaces.clone()));
}
this.declaredFields = Collections.unmodifiableSet(new HashSet<>(declaredFields));
this.declaredMethods = Collections.unmodifiableMap(new HashMap<>(declaredMethods));
}
boolean hasDeclaredField(String name, String descriptor) {
return this.declaredFields.contains(name + descriptor);
}
Integer getDeclaredMethodAccess(String name, String descriptor) {
return this.declaredMethods.get(name + descriptor);
}
}
}
@@ -0,0 +1,46 @@
package customskinloader.bootstrap.installer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.mapping.Parser;
import org.apache.logging.log4j.Logger;
public final class CommonJarInstaller {
private static final String COMMON_JAR = "CustomSkinLoader-Common.jar";
private static final String MAPPING_RESOURCE = "/customskinloader/mapping.xml";
private static final Parser TSRG_PARSER = new Parser();
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private CommonJarInstaller() {
}
public static Path releaseCommonJar(Path gameDirectory, String mappingType) throws Exception {
InputStream mappingStream = CommonJarInstaller.class.getResourceAsStream(MAPPING_RESOURCE);
if (mappingStream == null) {
throw new IOException("Could not find bundled mapping resource " + MAPPING_RESOURCE);
}
try (InputStream mappingInputStream = mappingStream) {
Path coreDirectory = gameDirectory.resolve("CustomSkinLoader").resolve("Core");
Files.createDirectories(coreDirectory);
Path jarPath = coreDirectory.resolve(COMMON_JAR);
LOGGER.info("Releasing CustomSkinLoader Common jar to " + BootstrapLogger.formatPath(jarPath));
String resourceName = "/META-INF/jar-jar/" + COMMON_JAR;
InputStream jarStream = CommonJarInstaller.class.getResourceAsStream(resourceName);
if (jarStream == null) {
throw new IOException("Could not find bundled jar resource " + resourceName);
}
try (InputStream jarInputStream = jarStream; OutputStream outputStream = Files.newOutputStream(jarPath)) {
new NestedJarRemapper(TSRG_PARSER.parse(mappingInputStream, mappingType)).remapJar(jarInputStream, outputStream);
}
return jarPath;
}
}
}
@@ -0,0 +1,144 @@
package customskinloader.bootstrap.installer;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.mapping.Mappings;
import org.apache.logging.log4j.Logger;
final class NestedJarRemapper {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private final BytecodeRemapper remapper;
NestedJarRemapper(Mappings mappings) {
this.remapper = new BytecodeRemapper(mappings);
}
public void remapJar(InputStream inputStream, OutputStream outputStream) throws Exception {
List<JarEntryData> entries = new ArrayList<>();
Manifest manifest;
try (JarInputStream jarInputStream = new JarInputStream(inputStream)) {
manifest = jarInputStream.getManifest();
JarEntry entry;
while ((entry = jarInputStream.getNextJarEntry()) != null) {
if (entry.isDirectory() || this.isSignatureEntry(entry.getName())) {
continue;
}
byte[] entryBytes = this.readAllBytes(jarInputStream);
entries.add(new JarEntryData(entry.getName(), entry.getTime(), entryBytes));
if (entry.getName().endsWith(".class")) {
this.remapper.addClassInheritance(entryBytes);
}
}
}
LOGGER.debug("Read " + entries.size() + " entries from nested CustomSkinLoader Common jar");
try (JarOutputStream jarOutputStream = manifest == null
? new JarOutputStream(outputStream)
: new JarOutputStream(outputStream, this.copyManifest(manifest))) {
for (JarEntryData entry : entries) {
byte[] entryBytes = entry.bytes;
if (entry.name.endsWith(".class")) {
entryBytes = this.remapper.remapClass(entryBytes);
this.writeEntry(jarOutputStream, this.toRemappedClassEntryName(entry.name, entryBytes), entry.time, entryBytes);
continue;
}
this.writeEntry(jarOutputStream, entry.name, entry.time, entryBytes);
}
jarOutputStream.finish();
}
LOGGER.debug("Remapped " + entries.size() + " entries from nested CustomSkinLoader Common jar");
}
private Manifest copyManifest(Manifest manifest) {
Manifest copiedManifest = new Manifest();
copiedManifest.getMainAttributes().putAll(manifest.getMainAttributes());
for (Map.Entry<String, Attributes> entry : manifest.getEntries().entrySet()) {
Attributes copiedAttributes = new Attributes();
copiedAttributes.putAll(entry.getValue());
copiedManifest.getEntries().put(entry.getKey(), copiedAttributes);
}
return copiedManifest;
}
private boolean isSignatureEntry(String entryName) {
String upperCaseEntryName = entryName.toUpperCase();
return upperCaseEntryName.startsWith("META-INF/")
&& (upperCaseEntryName.endsWith(".SF") || upperCaseEntryName.endsWith(".DSA") || upperCaseEntryName.endsWith(".RSA") || upperCaseEntryName.endsWith(".EC"));
}
private String toRemappedClassEntryName(String sourceEntryName, byte[] remappedClassBytes) {
String classEntryName = this.remapper.toClassEntryName(remappedClassBytes);
String versionedPrefix = this.getMultiReleaseVersionedPrefix(sourceEntryName);
return versionedPrefix == null ? classEntryName : versionedPrefix + classEntryName;
}
private String getMultiReleaseVersionedPrefix(String entryName) {
String prefix = "META-INF/versions/";
if (!entryName.startsWith(prefix)) {
return null;
}
int versionEnd = entryName.indexOf('/', prefix.length());
if (versionEnd < 0) {
return null;
}
return entryName.substring(0, versionEnd + 1);
}
private byte[] readAllBytes(InputStream inputStream) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[8192];
int readBytes;
while ((readBytes = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, readBytes);
}
return outputStream.toByteArray();
}
private void writeEntry(JarOutputStream jarOutputStream, String entryName, long sourceEntryTime, byte[] entryBytes) throws IOException {
JarEntry jarEntry = new JarEntry(entryName);
if (sourceEntryTime >= 0L) {
jarEntry.setTime(sourceEntryTime);
}
jarOutputStream.putNextEntry(jarEntry);
jarOutputStream.write(entryBytes);
jarOutputStream.closeEntry();
}
private static final class JarEntryData {
private final String name;
private final long time;
private final byte[] bytes;
JarEntryData(String name, long time, byte[] bytes) {
this.name = name;
this.time = time;
this.bytes = bytes;
}
}
}
@@ -0,0 +1,31 @@
package customskinloader.bootstrap.mapping;
import java.io.IOException;
import java.io.InputStream;
public final class Loader {
private static final String MAPPING_RESOURCE = "/customskinloader/mapping.xml";
private Loader() {
}
public static Mappings load(ClassLoader classLoader, String mappingType) {
if (mappingType == null || mappingType.trim().isEmpty()) {
return Mappings.EMPTY;
}
InputStream resourceStream = classLoader.getResourceAsStream(MAPPING_RESOURCE.substring(1));
if (resourceStream == null) {
resourceStream = Loader.class.getResourceAsStream(MAPPING_RESOURCE);
}
if (resourceStream == null) {
throw new IllegalStateException("Could not find bundled mapping resource " + MAPPING_RESOURCE);
}
try (InputStream inputStream = resourceStream) {
return new Parser().parse(inputStream, mappingType);
} catch (IOException exception) {
throw new IllegalStateException("Failed to parse bundled mapping resource " + MAPPING_RESOURCE, exception);
}
}
}
@@ -0,0 +1,262 @@
package customskinloader.bootstrap.mapping;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class Mappings {
public static final Mappings EMPTY = new Mappings(Collections.emptyList());
private static final Pattern CLASS_NAME_IN_DESCRIPTOR = Pattern.compile("L([^;]+);");
private final List<ClassMapping> classMappings;
private final Map<String, ClassMapping> classMappingsBySourceName;
private final Map<String, ClassMapping> classMappingsByTargetName;
private final Map<String, FieldMapping> fieldMappingsBySourceKey;
private final Map<String, FieldMapping> fieldMappingsByTargetKey;
private final Map<String, MethodMapping> methodMappingsBySourceKey;
private final Map<String, MethodMapping> methodMappingsByTargetKey;
public Mappings(List<ClassMapping> classMappings) {
List<ClassMapping> copiedClassMappings = Collections.unmodifiableList(new ArrayList<>(classMappings));
Map<String, ClassMapping> sourceIndex = new LinkedHashMap<>();
Map<String, ClassMapping> targetIndex = new LinkedHashMap<>();
Map<String, String> sourceToTargetClassNames = new LinkedHashMap<>();
Map<String, String> targetToSourceClassNames = new LinkedHashMap<>();
for (ClassMapping classMapping : copiedClassMappings) {
String normalizedSourceName = normalizeClassName(classMapping.getSourceName());
String normalizedTargetName = normalizeClassName(classMapping.getTargetName());
sourceIndex.put(normalizedSourceName, classMapping);
targetIndex.put(normalizedTargetName, classMapping);
sourceToTargetClassNames.put(normalizedSourceName, normalizedTargetName);
targetToSourceClassNames.put(normalizedTargetName, normalizedSourceName);
}
Map<String, FieldMapping> sourceFieldIndex = new LinkedHashMap<>();
Map<String, FieldMapping> targetFieldIndex = new LinkedHashMap<>();
Map<String, MethodMapping> sourceMethodIndex = new LinkedHashMap<>();
Map<String, MethodMapping> targetMethodIndex = new LinkedHashMap<>();
for (ClassMapping classMapping : copiedClassMappings) {
String normalizedSourceOwner = normalizeClassName(classMapping.getSourceName());
String normalizedTargetOwner = normalizeClassName(classMapping.getTargetName());
for (FieldMapping fieldMapping : classMapping.getFieldMappings()) {
sourceFieldIndex.put(fieldKey(normalizedSourceOwner, fieldMapping.getSourceName()), fieldMapping);
targetFieldIndex.put(fieldKey(normalizedTargetOwner, fieldMapping.getTargetName()), fieldMapping);
}
for (MethodMapping methodMapping : classMapping.getMethodMappings()) {
sourceMethodIndex.put(methodKey(normalizedSourceOwner, methodMapping.getSourceName(), methodMapping.getSourceDescriptor()), methodMapping);
targetMethodIndex.put(
methodKey(
normalizedTargetOwner,
methodMapping.getTargetName(),
remapDescriptor(methodMapping.getSourceDescriptor(), sourceToTargetClassNames)
),
methodMapping
);
}
}
this.classMappings = copiedClassMappings;
this.classMappingsBySourceName = Collections.unmodifiableMap(sourceIndex);
this.classMappingsByTargetName = Collections.unmodifiableMap(targetIndex);
this.fieldMappingsBySourceKey = Collections.unmodifiableMap(sourceFieldIndex);
this.fieldMappingsByTargetKey = Collections.unmodifiableMap(targetFieldIndex);
this.methodMappingsBySourceKey = Collections.unmodifiableMap(sourceMethodIndex);
this.methodMappingsByTargetKey = Collections.unmodifiableMap(targetMethodIndex);
}
public List<ClassMapping> getClassMappings() {
return this.classMappings;
}
public ClassMapping getClassMappingBySourceName(String sourceName) {
return this.classMappingsBySourceName.get(normalizeClassName(sourceName));
}
public ClassMapping getClassMappingByTargetName(String targetName) {
return this.classMappingsByTargetName.get(normalizeClassName(targetName));
}
public String remapClassName(String sourceName) {
ClassMapping classMapping = this.getClassMappingBySourceName(sourceName);
return classMapping == null ? normalizeClassName(sourceName) : normalizeClassName(classMapping.getTargetName());
}
public String unmapClassName(String targetName) {
ClassMapping classMapping = this.getClassMappingByTargetName(targetName);
return classMapping == null ? normalizeClassName(targetName) : normalizeClassName(classMapping.getSourceName());
}
public String remapFieldName(String sourceOwner, String sourceName) {
FieldMapping fieldMapping = this.fieldMappingsBySourceKey.get(fieldKey(normalizeClassName(sourceOwner), sourceName));
return fieldMapping == null ? sourceName : fieldMapping.getTargetName();
}
public String unmapFieldName(String targetOwner, String targetName) {
FieldMapping fieldMapping = this.fieldMappingsByTargetKey.get(fieldKey(normalizeClassName(targetOwner), targetName));
return fieldMapping == null ? targetName : fieldMapping.getSourceName();
}
public String remapMethodName(String sourceOwner, String sourceName, String sourceDescriptor) {
MethodMapping methodMapping = this.methodMappingsBySourceKey.get(methodKey(normalizeClassName(sourceOwner), sourceName, sourceDescriptor));
return methodMapping == null ? sourceName : methodMapping.getTargetName();
}
public String unmapMethodName(String targetOwner, String targetName, String targetDescriptor) {
MethodMapping methodMapping = this.methodMappingsByTargetKey.get(methodKey(normalizeClassName(targetOwner), targetName, targetDescriptor));
return methodMapping == null ? targetName : methodMapping.getSourceName();
}
public String remapMethodDescriptor(String sourceDescriptor) {
return remapDescriptor(sourceDescriptor, true);
}
public String unmapMethodDescriptor(String targetDescriptor) {
return remapDescriptor(targetDescriptor, false);
}
private String remapDescriptor(String descriptor, boolean sourceToTarget) {
if (descriptor == null || descriptor.isEmpty()) {
return descriptor;
}
Matcher matcher = CLASS_NAME_IN_DESCRIPTOR.matcher(descriptor);
StringBuffer stringBuffer = new StringBuffer();
while (matcher.find()) {
String className = matcher.group(1);
String mappedName = sourceToTarget ? this.remapClassName(className) : this.unmapClassName(className);
matcher.appendReplacement(stringBuffer, "L" + Matcher.quoteReplacement(mappedName) + ";");
}
matcher.appendTail(stringBuffer);
return stringBuffer.toString();
}
private static String remapDescriptor(String descriptor, Map<String, String> classNameMappings) {
if (descriptor == null || descriptor.isEmpty()) {
return descriptor;
}
Matcher matcher = CLASS_NAME_IN_DESCRIPTOR.matcher(descriptor);
StringBuffer stringBuffer = new StringBuffer();
while (matcher.find()) {
String className = matcher.group(1);
String mappedName = classNameMappings.get(className);
if (mappedName == null) {
mappedName = className;
}
matcher.appendReplacement(stringBuffer, "L" + Matcher.quoteReplacement(mappedName) + ";");
}
matcher.appendTail(stringBuffer);
return stringBuffer.toString();
}
private static String normalizeClassName(String className) {
return className == null ? null : className.replace('.', '/');
}
private static String fieldKey(String owner, String name) {
return owner + '#' + name;
}
private static String methodKey(String owner, String name, String descriptor) {
return owner + '#' + name + descriptor;
}
public static final class ClassMapping {
private final String sourceName;
private final String targetName;
private final List<FieldMapping> fieldMappings = new ArrayList<>();
private final List<MethodMapping> methodMappings = new ArrayList<>();
public ClassMapping(String sourceName, String targetName) {
this.sourceName = sourceName;
this.targetName = targetName;
}
public String getSourceName() {
return this.sourceName;
}
public String getTargetName() {
return this.targetName;
}
public List<FieldMapping> getFieldMappings() {
return Collections.unmodifiableList(this.fieldMappings);
}
public List<MethodMapping> getMethodMappings() {
return Collections.unmodifiableList(this.methodMappings);
}
void addFieldMapping(FieldMapping fieldMapping) {
this.fieldMappings.add(fieldMapping);
}
void addMethodMapping(MethodMapping methodMapping) {
this.methodMappings.add(methodMapping);
}
}
public static final class FieldMapping {
private final ClassMapping owner;
private final String sourceName;
private final String targetName;
public FieldMapping(ClassMapping owner, String sourceName, String targetName) {
this.owner = owner;
this.sourceName = sourceName;
this.targetName = targetName;
}
public ClassMapping getOwner() {
return this.owner;
}
public String getSourceName() {
return this.sourceName;
}
public String getTargetName() {
return this.targetName;
}
}
public static final class MethodMapping {
private final ClassMapping owner;
private final String sourceName;
private final String sourceDescriptor;
private final String targetName;
public MethodMapping(ClassMapping owner, String sourceName, String sourceDescriptor, String targetName) {
this.owner = owner;
this.sourceName = sourceName;
this.sourceDescriptor = sourceDescriptor;
this.targetName = targetName;
}
public ClassMapping getOwner() {
return this.owner;
}
public String getSourceName() {
return this.sourceName;
}
public String getSourceDescriptor() {
return this.sourceDescriptor;
}
public String getTargetName() {
return this.targetName;
}
}
}
@@ -0,0 +1,96 @@
package customskinloader.bootstrap.mapping;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import customskinloader.bootstrap.util.RangeMatcher;
import customskinloader.bootstrap.util.XmlUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public final class Parser {
public Mappings parse(InputStream inputStream, String mappingType) throws IOException {
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
Document document = XmlUtils.parseDocument(reader, "customskinloader mapping.xml");
return this.buildMappings(document, mappingType, VersionMetadataReader.PROTOCOL_VERSION, VersionMetadataReader.WORLD_VERSION);
}
private Mappings buildMappings(Document document, String mappingType, int protocolVersion, int worldVersion) {
List<Mappings.ClassMapping> classMappings = new ArrayList<>();
List<Element> classElements = XmlUtils.childElements(document.getDocumentElement(), "class");
for (Element classElement : classElements) {
String canonicalClassName = XmlUtils.requiredAttribute(classElement, "name");
String mappedClassName = this.selectMappedValue(XmlUtils.childElements(classElement, "name"), mappingType, protocolVersion, worldVersion);
if (mappedClassName == null) {
mappedClassName = canonicalClassName;
}
Mappings.ClassMapping classMapping = new Mappings.ClassMapping(canonicalClassName, mappedClassName);
boolean includeClassMapping = !canonicalClassName.equals(mappedClassName);
for (Element fieldElement : XmlUtils.childElements(classElement, "field")) {
String canonicalFieldName = XmlUtils.requiredAttribute(fieldElement, "name");
String mappedFieldName = this.selectMappedValue(XmlUtils.childElements(fieldElement, "name"), mappingType, protocolVersion, worldVersion);
if (mappedFieldName == null || canonicalFieldName.equals(mappedFieldName)) {
continue;
}
classMapping.addFieldMapping(new Mappings.FieldMapping(classMapping, canonicalFieldName, mappedFieldName));
includeClassMapping = true;
}
for (Element methodElement : XmlUtils.childElements(classElement, "method")) {
String canonicalMethodSignature = XmlUtils.requiredAttribute(methodElement, "name");
int descriptorIndex = canonicalMethodSignature.indexOf('(');
if (descriptorIndex < 0) {
throw new IllegalArgumentException("Method mapping name must include a descriptor: " + canonicalMethodSignature);
}
String canonicalMethodName = canonicalMethodSignature.substring(0, descriptorIndex);
String canonicalMethodDescriptor = canonicalMethodSignature.substring(descriptorIndex);
String mappedMethodName = this.selectMappedValue(XmlUtils.childElements(methodElement, "name"), mappingType, protocolVersion, worldVersion);
if (mappedMethodName == null || canonicalMethodName.equals(mappedMethodName)) {
continue;
}
classMapping.addMethodMapping(new Mappings.MethodMapping(classMapping, canonicalMethodName, canonicalMethodDescriptor, mappedMethodName));
includeClassMapping = true;
}
if (includeClassMapping) {
classMappings.add(classMapping);
}
}
return new Mappings(classMappings);
}
private String selectMappedValue(List<Element> nameElements, String mappingType, int protocolVersion, int worldVersion) {
String selectedValue = null;
for (Element nameElement : nameElements) {
if (!mappingType.equals(nameElement.getAttribute("type"))) {
continue;
}
if (!RangeMatcher.matches(nameElement.getAttribute("version"), protocolVersion, worldVersion)) {
continue;
}
String currentValue = nameElement.getTextContent() == null ? null : nameElement.getTextContent().trim();
if (currentValue == null || currentValue.isEmpty()) {
continue;
}
if (selectedValue != null && !selectedValue.equals(currentValue)) {
throw new IllegalArgumentException("Found multiple values for type \"" + mappingType + "\", protocol version " + protocolVersion + " and world version" + worldVersion + ": " + selectedValue + " vs " + currentValue);
}
selectedValue = currentValue;
}
return selectedValue;
}
}
@@ -0,0 +1,112 @@
package customskinloader.bootstrap.mapping;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodNode;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public final class VersionMetadataReader {
private static final String VERSION_JSON = "version.json";
private static final String NETWORK_PROTOCOL_VERSION_FIELD = "NETWORK_PROTOCOL_VERSION";
private static final String[] VERSION_KEYS = {"protocol_version", "world_version"};
private static final int[] VERSIONS = {0, 0};
static {
initializeVersions();
}
public static final int PROTOCOL_VERSION = VERSIONS[0];
public static final int WORLD_VERSION = VERSIONS[1];
private VersionMetadataReader() {
}
private static void initializeVersions() {
InputStream resourceStream = ClassLoader.getSystemClassLoader().getResourceAsStream(VERSION_JSON);
if (resourceStream == null) {
readProtocolVersionFromRealmsSharedConstants();
return;
}
try (InputStream inputStream = resourceStream; InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
JsonElement rootElement = new JsonParser().parse(reader);
if (rootElement == null || !rootElement.isJsonObject()) {
return;
}
JsonObject rootObject = rootElement.getAsJsonObject();
for (int i = 0; i < VERSION_KEYS.length; i++) {
JsonElement versionElement = rootObject.get(VERSION_KEYS[i]);
if (versionElement != null && !versionElement.isJsonNull()) {
VERSIONS[i] = versionElement.getAsInt();
}
}
} catch (Exception ignored) {
}
}
private static void readProtocolVersionFromRealmsSharedConstants() {
InputStream resourceStream = ClassLoader.getSystemClassLoader().getResourceAsStream("net/minecraft/realms/RealmsSharedConstants.class");
if (resourceStream == null) {
return;
}
ClassNode classNode = new ClassNode();
try (InputStream inputStream = resourceStream) {
ClassReader classReader = new ClassReader(inputStream);
classReader.accept(classNode, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
} catch (IOException ignored) {
}
for (FieldNode fieldNode : classNode.fields) {
if (NETWORK_PROTOCOL_VERSION_FIELD.equals(fieldNode.name) && fieldNode.value instanceof Integer) {
VERSIONS[0] = (int) fieldNode.value;
return;
}
}
for (MethodNode methodNode : classNode.methods) {
if (!"<clinit>".equals(methodNode.name)) {
continue;
}
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (instruction.getOpcode() != Opcodes.PUTSTATIC) {
continue;
}
FieldInsnNode fieldInsnNode = (FieldInsnNode) instruction;
if (classNode.name.equals(fieldInsnNode.owner) && NETWORK_PROTOCOL_VERSION_FIELD.equals(fieldInsnNode.name) && "I".equals(fieldInsnNode.desc)) {
instruction = instruction.getPrevious();
int opcode = instruction.getOpcode();
if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) {
VERSIONS[0] = opcode - Opcodes.ICONST_0;
} else if (opcode >= Opcodes.BIPUSH && opcode <= Opcodes.SIPUSH) {
VERSIONS[0] = ((IntInsnNode) instruction).operand;
} else if (opcode == Opcodes.LDC) {
Object constant = ((LdcInsnNode) instruction).cst;
if (constant instanceof Integer) {
VERSIONS[0] = (int) constant;
}
}
break;
}
}
}
}
}
@@ -0,0 +1,110 @@
package customskinloader.bootstrap.transformer;
import customskinloader.bootstrap.mapping.Mappings;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
public final class ClassTransformationContext {
private final String internalClassName;
private final ClassNode currentClassNode;
private final Mappings mappings;
private ClassTransformationContext(String internalClassName, ClassNode currentClassNode, Mappings mappings) {
this.internalClassName = internalClassName;
this.currentClassNode = currentClassNode;
this.mappings = mappings == null ? Mappings.EMPTY : mappings;
}
public static ClassTransformationContext create(String className, ClassNode classNode, Mappings mappings) {
if (classNode == null) {
throw new IllegalArgumentException("Class node must not be null");
}
return new ClassTransformationContext(normalizeInternalClassName(className, classNode), classNode, mappings);
}
public String getInternalClassName() {
return this.internalClassName;
}
public ClassNode getCurrentClassNode() {
return this.currentClassNode;
}
public Mappings getMappings() {
return this.mappings;
}
public String remapClassName(String sourceName) {
return this.mappings.remapClassName(sourceName);
}
public String unmapClassName(String targetName) {
return this.mappings.unmapClassName(targetName);
}
public String remapFieldName(String sourceOwner, String sourceName) {
return this.mappings.remapFieldName(sourceOwner, sourceName);
}
public String unmapFieldName(String targetOwner, String targetName) {
return this.mappings.unmapFieldName(targetOwner, targetName);
}
public String remapMethodName(String sourceOwner, String sourceName, String sourceDescriptor) {
return this.mappings.remapMethodName(sourceOwner, sourceName, sourceDescriptor);
}
public String unmapMethodName(String targetOwner, String targetName, String targetDescriptor) {
return this.mappings.unmapMethodName(targetOwner, targetName, targetDescriptor);
}
public String remapMethodDescriptor(String sourceDescriptor) {
return this.mappings.remapMethodDescriptor(sourceDescriptor);
}
public String unmapMethodDescriptor(String targetDescriptor) {
return this.mappings.unmapMethodDescriptor(targetDescriptor);
}
public boolean isTarget(String canonicalName) {
return this.getInternalClassName().equals(this.remapClassName(canonicalName));
}
public MethodNode findMethod(String owner, String name, String desc) {
String mappedDesc = this.remapMethodDescriptor(desc);
String mappedName = "<init>".equals(name) ? name : this.remapMethodName(owner, name, desc);
for (MethodNode methodNode : this.getCurrentClassNode().methods) {
if (mappedName.equals(methodNode.name) && mappedDesc.equals(methodNode.desc)) {
return methodNode;
}
}
return null;
}
public FieldNode findField(String owner, String name) {
String mappedName = this.remapFieldName(owner, name);
for (FieldNode fieldNode : this.getCurrentClassNode().fields) {
if (mappedName.equals(fieldNode.name)) {
return fieldNode;
}
}
return null;
}
private static String normalizeInternalClassName(String className, ClassNode classNode) {
if (className != null && !className.trim().isEmpty()) {
return normalizeInternalClassName(className);
}
if (classNode == null || classNode.name == null || classNode.name.trim().isEmpty()) {
throw new IllegalArgumentException("Class name must be available from either the context or the ClassNode");
}
return normalizeInternalClassName(classNode.name);
}
private static String normalizeInternalClassName(String className) {
return className.replace('.', '/');
}
}
@@ -0,0 +1,46 @@
package customskinloader.bootstrap.transformer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
public final class ClassTransformationReport {
private final ClassTransformationContext context;
private final List<String> appliedTransformerNames;
private volatile byte[] transformedBytecode;
public ClassTransformationReport(ClassTransformationContext context, List<String> appliedTransformerNames) {
this.context = context;
this.appliedTransformerNames = Collections.unmodifiableList(new ArrayList<>(appliedTransformerNames));
}
public ClassTransformationContext getContext() {
return this.context;
}
public byte[] getTransformedBytecode() {
if (this.transformedBytecode == null) {
if (this.getTransformedClassNode() == null) {
throw new IllegalStateException("Transformed bytecode is not available without a transformed ClassNode");
}
this.transformedBytecode = TransformerBootstrapSupport.toByteArray(this.getTransformedClassNode());
}
return this.transformedBytecode.clone();
}
public ClassNode getTransformedClassNode() {
return this.context.getCurrentClassNode();
}
public List<String> getAppliedTransformerNames() {
return this.appliedTransformerNames;
}
public boolean isModified() {
return !this.appliedTransformerNames.isEmpty();
}
}
@@ -0,0 +1,51 @@
package customskinloader.bootstrap.transformer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import customskinloader.bootstrap.mapping.Mappings;
public final class ClassTransformerRegistry {
private static final Comparator<TargetedClassTransformer> TRANSFORMER_ORDER = (left, right) -> {
// Higher-priority transformers run first so low-priority patches can react to earlier changes.
int priorityOrder = Integer.compare(right.getPriority(), left.getPriority());
if (priorityOrder != 0) {
return priorityOrder;
}
return left.getName().compareTo(right.getName());
};
private final CopyOnWriteArrayList<TargetedClassTransformer> transformers = new CopyOnWriteArrayList<>();
public void register(TargetedClassTransformer transformer) {
this.transformers.add(transformer);
this.sortTransformers();
}
public List<TargetedClassTransformer> getTransformers() {
return Collections.unmodifiableList(new ArrayList<>(this.transformers));
}
public List<TargetedClassTransformer> getApplicableTransformers(String className, Mappings mappings) {
List<TargetedClassTransformer> applicableTransformers = new ArrayList<>();
for (TargetedClassTransformer transformer : this.transformers) {
if (transformer.supports(className, mappings)) {
applicableTransformers.add(transformer);
}
}
return Collections.unmodifiableList(applicableTransformers);
}
private void sortTransformers() {
List<TargetedClassTransformer> sortedTransformers = new ArrayList<>(this.transformers);
Collections.sort(sortedTransformers, TRANSFORMER_ORDER);
this.transformers.clear();
this.transformers.addAll(sortedTransformers);
}
}
@@ -0,0 +1,46 @@
package customskinloader.bootstrap.transformer;
import java.util.ArrayList;
import java.util.List;
import customskinloader.bootstrap.BootstrapLogger;
import org.apache.logging.log4j.Logger;
public final class RuntimeClassTransformerEngine {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private final ClassTransformerRegistry registry;
public RuntimeClassTransformerEngine(ClassTransformerRegistry registry) {
this.registry = registry;
}
public ClassTransformationReport transform(ClassTransformationContext context) {
List<String> appliedTransformers = new ArrayList<>();
for (TargetedClassTransformer transformer : this.registry.getApplicableTransformers(context.getInternalClassName(), context.getMappings())) {
if (!this.applyTransformer(transformer, context)) {
LOGGER.debug("Skipped transformer " + transformer.getName() + " for " + context.getInternalClassName());
continue;
}
appliedTransformers.add(transformer.getName());
LOGGER.debug("Applied transformer " + transformer.getName() + " to " + context.getInternalClassName());
}
if (!appliedTransformers.isEmpty()) {
LOGGER.info("Transformed " + context.getInternalClassName() + " with " + appliedTransformers);
}
return new ClassTransformationReport(context, appliedTransformers);
}
private boolean applyTransformer(TargetedClassTransformer transformer, ClassTransformationContext context) {
try {
return transformer.transform(context);
} catch (Exception exception) {
String message = "Failed to transform " + context.getInternalClassName() + " with " + transformer.getName();
LOGGER.error(message, exception);
throw new IllegalStateException(message, exception);
}
}
}
@@ -0,0 +1,46 @@
package customskinloader.bootstrap.transformer;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
public abstract class TargetedClassTransformer {
private final String name;
private final int priority;
private final Set<String> targetClassNames;
protected TargetedClassTransformer(String name, int priority, String... targetClassNames) {
this.name = name;
this.priority = priority;
this.targetClassNames = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(targetClassNames)));
}
public final String getName() {
return this.name;
}
public final int getPriority() {
return this.priority;
}
public boolean supports(String className, customskinloader.bootstrap.mapping.Mappings mappings) {
if (this.targetClassNames.isEmpty()) {
return false;
}
for (String targetClassName : this.targetClassNames) {
if (className.equals(mappings.remapClassName(targetClassName))) {
return true;
}
}
return false;
}
public Set<String> getTargetClassNames() {
return this.targetClassNames;
}
public abstract boolean transform(ClassTransformationContext context) throws Exception;
}
@@ -0,0 +1,135 @@
package customskinloader.bootstrap.transformer;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.ServiceLoader;
import java.util.Set;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.mapping.Loader;
import customskinloader.bootstrap.mapping.Mappings;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
public final class TransformerBootstrapSupport {
private static final Field[] CLASS_NODE_FIELDS = ClassNode.class.getFields();
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private final Object lock = new Object();
private final Class<?> serviceLoaderAnchor;
private final String mappingType;
private final ClassTransformerRegistry registry = new ClassTransformerRegistry();
private final RuntimeClassTransformerEngine transformerEngine = new RuntimeClassTransformerEngine(this.registry);
private volatile boolean transformersLoaded;
private volatile Mappings mappings;
public TransformerBootstrapSupport(Class<?> serviceLoaderAnchor, String mappingType) {
if (serviceLoaderAnchor == null) {
throw new IllegalArgumentException("Service loader anchor must not be null");
}
this.serviceLoaderAnchor = serviceLoaderAnchor;
this.mappingType = mappingType;
}
public void ensureTransformersLoaded() {
if (this.transformersLoaded) {
return;
}
synchronized (this.lock) {
if (this.transformersLoaded) {
return;
}
// Discover platform-contributed targeted transformers lazily through the shared service contract.
ServiceLoader<TargetedClassTransformer> serviceLoader = ServiceLoader.load(TargetedClassTransformer.class, this.serviceLoaderAnchor.getClassLoader());
int transformerCount = 0;
for (TargetedClassTransformer transformer : serviceLoader) {
this.registry.register(transformer);
transformerCount++;
LOGGER.debug("Registered transformer " + transformer.getName()
+ " with priority " + transformer.getPriority()
+ " and targets " + transformer.getTargetClassNames());
}
this.transformersLoaded = true;
LOGGER.info("Loaded " + transformerCount + " CustomSkinLoader bootstrap transformer(s) for " + this.mappingType + " mappings");
}
}
public Set<String> collectTargetClassNames() {
this.ensureTransformersLoaded();
Mappings loadedMappings = this.getMappings();
Set<String> targetClassNames = new LinkedHashSet<>();
for (TargetedClassTransformer transformer : this.registry.getTransformers()) {
for (String targetClassName : transformer.getTargetClassNames()) {
targetClassNames.add(loadedMappings.remapClassName(targetClassName));
}
}
LOGGER.info("Collected " + targetClassNames.size() + " CustomSkinLoader bootstrap target class(es) for " + this.mappingType + " mappings");
return Collections.unmodifiableSet(targetClassNames);
}
public boolean hasApplicableTransformers(String internalClassName) {
this.ensureTransformersLoaded();
return !this.registry.getApplicableTransformers(internalClassName, this.getMappings()).isEmpty();
}
public ClassTransformationReport transformClassNode(String internalClassName, ClassNode inputClassNode) {
this.ensureTransformersLoaded();
ClassTransformationContext context = ClassTransformationContext.create(internalClassName, inputClassNode, this.getMappings());
return this.transformerEngine.transform(context);
}
public Mappings getMappings() {
Mappings loadedMappings = this.mappings;
if (loadedMappings != null) {
return loadedMappings;
}
synchronized (this.lock) {
loadedMappings = this.mappings;
if (loadedMappings == null) {
LOGGER.info("Loading CustomSkinLoader bootstrap mappings for " + this.mappingType);
loadedMappings = Loader.load(this.serviceLoaderAnchor.getClassLoader(), this.mappingType);
this.mappings = loadedMappings;
LOGGER.info("Loaded " + loadedMappings.getClassMappings().size() + " CustomSkinLoader bootstrap class mapping(s) for " + this.mappingType);
}
}
return loadedMappings;
}
public static byte[] toByteArray(ClassNode classNode) {
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classNode.accept(classWriter);
return classWriter.toByteArray();
}
public static ClassNode toClassNode(byte[] classBytecode) {
ClassReader classReader = new ClassReader(classBytecode);
ClassNode classNode = new ClassNode();
classReader.accept(classNode, 0);
return classNode;
}
public static void copyClassNode(ClassNode source, ClassNode target) {
try {
for (Field field : CLASS_NODE_FIELDS) {
if (!Modifier.isStatic(field.getModifiers())) {
field.set(target, field.get(source));
}
}
} catch (IllegalAccessException exception) {
throw new IllegalStateException("Failed to copy transformed ClassNode state", exception);
}
}
}
@@ -0,0 +1,47 @@
package customskinloader.bootstrap.transformer.patch;
import customskinloader.bootstrap.transformer.ClassTransformationContext;
public final class InterfacePatch extends PatchSupport {
public InterfacePatch() {
super(
"customskinloader:interface-patch", 1000,
targets(
HTTP_TEXTURE_PROCESSOR, "[,553]", // 19w37a- (1.14.4-)
RESOURCE, "",
RESOURCE_MANAGER, "",
NATIVE_IMAGE, "[404,]", // 1.13.2+
IDENTIFIER, ""
)
);
}
@Override
public boolean transform(ClassTransformationContext context) {
boolean modified = false;
if (context.isTarget(HTTP_TEXTURE_PROCESSOR)) {
modified |= this.requireModified("http-texture-processor.interface", this.addInterface(context.getCurrentClassNode(), FAKE_HTTP_TEXTURE_PROCESSOR));
}
if (context.isTarget(RESOURCE)) {
boolean resourceModified = false;
resourceModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V1);
resourceModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V2);
modified |= this.requireModified("resource.interfaces", resourceModified);
}
if (context.isTarget(RESOURCE_MANAGER)) {
boolean resourceManagerModified = false;
resourceManagerModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V1);
resourceManagerModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V2);
modified |= this.requireModified("resource-manager.interfaces", resourceManagerModified);
}
if (context.isTarget(NATIVE_IMAGE)) {
modified |= this.requireModified("native-image.interface", this.addInterface(context.getCurrentClassNode(), FAKE_NATIVE_IMAGE));
}
if (context.isTarget(IDENTIFIER)) {
modified |= this.requireModified("identifier.patch", this.makeMethodPublicNonFinal(context.findMethod(IDENTIFIER, "<init>", "(" + objectDesc(STRING) + objectDesc(STRING) + ")V")));
}
return modified;
}
}
@@ -0,0 +1,267 @@
package customskinloader.bootstrap.transformer.patch;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BooleanSupplier;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.mapping.VersionMetadataReader;
import customskinloader.bootstrap.transformer.TargetedClassTransformer;
import customskinloader.bootstrap.util.RangeMatcher;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InnerClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
abstract class PatchSupport extends TargetedClassTransformer implements Opcodes {
private static final String IGNORE_PATCH_FAILURE_PROPERTY = "customskinloader.ignorePatchFailure";
private static final Logger LOGGER = BootstrapLogger.LOGGER;
protected static final String BOOLEAN = "java/lang/Boolean";
protected static final String OBJECT = "java/lang/Object";
protected static final String STRING = "java/lang/String";
protected static final String CALL_SITE = "java/lang/invoke/CallSite";
protected static final String LAMBDA_METAFACTORY = "java/lang/invoke/LambdaMetafactory";
protected static final String METHOD_HANDLE = "java/lang/invoke/MethodHandle";
protected static final String METHOD_HANDLES_LOOKUP = "java/lang/invoke/MethodHandles$Lookup";
protected static final String METHOD_TYPE = "java/lang/invoke/MethodType";
protected static final String FILE = "java/io/File";
protected static final String INPUT_STREAM = "java/io/InputStream";
protected static final String PATH = "java/nio/file/Path";
protected static final String RUNNABLE = "java/lang/Runnable";
protected static final String MAP = "java/util/Map";
protected static final String UUID = "java/util/UUID";
protected static final String COMPLETABLE_FUTURE = "java/util/concurrent/CompletableFuture";
protected static final String EXECUTOR = "java/util/concurrent/Executor";
protected static final String EXECUTOR_SERVICE = "java/util/concurrent/ExecutorService";
protected static final String FUTURE = "java/util/concurrent/Future";
protected static final String FUNCTION = "java/util/function/Function";
protected static final String SUPPLIER = "java/util/function/Supplier";
protected static final String FUNCTION4 = "com/mojang/datafixers/util/Function4";
protected static final String NATIVE_IMAGE = "com/mojang/blaze3d/platform/NativeImage";
protected static final String POSE_STACK = "com/mojang/blaze3d/vertex/PoseStack";
protected static final String MINECRAFT = "net/minecraft/client/Minecraft";
protected static final String GUI_GRAPHICS = "net/minecraft/client/gui/GuiGraphics";
protected static final String GUI_GRAPHICS_EXTRACTOR = "net/minecraft/client/gui/GuiGraphicsExtractor";
protected static final String PLAYER_TAB_OVERLAY = "net/minecraft/client/gui/components/PlayerTabOverlay";
protected static final String CLIENT_PACKET_LISTENER = "net/minecraft/client/multiplayer/ClientPacketListener";
protected static final String HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/FakeHttpTextureProcessor"; // net/minecraft/client/renderer/HttpTextureProcessor
protected static final String MULTI_BUFFER_SOURCE = "net/minecraft/client/renderer/MultiBufferSource";
protected static final String SUBMIT_NODE_COLLECTOR = "net/minecraft/client/renderer/SubmitNodeCollector";
protected static final String MODEL_PART = "net/minecraft/client/model/geom/ModelPart";
protected static final String ABSTRACT_CLIENT_PLAYER = "net/minecraft/client/player/AbstractClientPlayer";
protected static final String CAPE_LAYER = "net/minecraft/client/renderer/entity/layers/CapeLayer";
protected static final String AVATAR_RENDER_STATE = "net/minecraft/client/renderer/entity/state/AvatarRenderState";
protected static final String PLAYER_RENDER_STATE = "net/minecraft/client/renderer/entity/state/PlayerRenderState";
protected static final String PLAYER_RENDERER = "net/minecraft/client/renderer/entity/player/PlayerRenderer";
protected static final String RENDER_TYPE = "net/minecraft/client/renderer/rendertype/RenderType";
protected static final String RENDER_TYPES = "net/minecraft/client/renderer/rendertype/RenderTypes";
protected static final String SKIN_MANAGER = "net/minecraft/client/resources/SkinManager";
protected static final String SKIN_MANAGER_1 = "net/minecraft/client/resources/SkinManager$1";
protected static final String SKIN_MANAGER_3 = "net/minecraft/client/resources/SkinManager$3";
protected static final String SKIN_MANAGER_CACHE_KEY = "net/minecraft/client/resources/SkinManager$CacheKey";
protected static final String SKIN_MANAGER_SKIN_TEXTURE_CALLBACK = "net/minecraft/client/resources/SkinManager$SkinTextureCallback";
protected static final String SKIN_MANAGER_TEXTURE_CACHE = "net/minecraft/client/resources/SkinManager$TextureCache";
protected static final String SKIN_MANAGER_TEXTURE_INFO = "net/minecraft/client/resources/SkinManager$TextureInfo";
protected static final String SKIN_TEXTURE_DOWNLOADER = "net/minecraft/client/renderer/texture/SkinTextureDownloader";
protected static final String TEXTURE_MANAGER = "net/minecraft/client/renderer/texture/TextureManager";
protected static final String HTTP_TEXTURE = "net/minecraft/client/renderer/texture/HttpTexture";
protected static final String CLIENT_ASSET_DOWNLOADED_TEXTURE = "net/minecraft/core/ClientAsset$DownloadedTexture";
protected static final String IDENTIFIER = "net/minecraft/resources/Identifier";
protected static final String SERVICES = "net/minecraft/server/Services";
protected static final String RESOURCE = "net/minecraft/server/packs/resources/Resource";
protected static final String RESOURCE_MANAGER = "net/minecraft/server/packs/resources/ResourceManager";
protected static final String OBJECTIVE = "net/minecraft/world/scores/Objective";
protected static final String SCOREBOARD = "net/minecraft/world/scores/Scoreboard";
protected static final String FAKE_HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/IFakeHttpTextureProcessor";
protected static final String FAKE_I_RESOURCE_V1 = "customskinloader/fake/itf/IFakeIResource$V1";
protected static final String FAKE_I_RESOURCE_V2 = "customskinloader/fake/itf/IFakeIResource$V2";
protected static final String FAKE_I_RESOURCE_MANAGER_V1 = "customskinloader/fake/itf/IFakeIResourceManager$V1";
protected static final String FAKE_I_RESOURCE_MANAGER_V2 = "customskinloader/fake/itf/IFakeIResourceManager$V2";
protected static final String FAKE_NATIVE_IMAGE = "customskinloader/fake/itf/IFakeNativeImage";
protected static final String FAKE_SKIN_BUFFER = "customskinloader/fake/FakeSkinBuffer";
protected static final String FAKE_SKIN_MANAGER = "customskinloader/fake/FakeSkinManager";
protected static final String FAKE_CACHE_KEY = "customskinloader/fake/FakeSkinManager$FakeCacheKey";
protected static final String FAKE_HTTP_TEXTURE_V1 = "customskinloader/fake/texture/FakeHttpTexture$V1";
protected static final String FAKE_HTTP_TEXTURE_V2 = "customskinloader/fake/texture/FakeHttpTexture$V2";
protected static final String MINECRAFT_PROFILE_TEXTURE = "com/mojang/authlib/minecraft/MinecraftProfileTexture";
protected static final String MINECRAFT_PROFILE_TEXTURE_TYPE = "com/mojang/authlib/minecraft/MinecraftProfileTexture$Type";
protected static final String MINECRAFT_SESSION_SERVICE = "com/mojang/authlib/minecraft/MinecraftSessionService";
protected static final String MINECRAFT_PROFILE_TEXTURES = "com/mojang/authlib/minecraft/MinecraftProfileTextures";
protected static final String GAME_PROFILE = "com/mojang/authlib/GameProfile";
protected static final String PROPERTY = "com/mojang/authlib/properties/Property";
protected static String objectDesc(String internalName) {
return "L" + internalName + ";";
}
private final int protocolVersion;
private final int worldVersion;
protected PatchSupport(String name, int priority, Map<String, String> targetClassNames) {
this(name, priority, VersionMetadataReader.PROTOCOL_VERSION, VersionMetadataReader.WORLD_VERSION, targetClassNames);
}
private PatchSupport(String name, int priority, int protocolVersion, int worldVersion, Map<String, String> targetClassNames) {
super(name, priority, filterTargetClassNames(targetClassNames, protocolVersion, worldVersion));
this.protocolVersion = protocolVersion;
this.worldVersion = worldVersion;
}
protected static Map<String, String> targets(String... targetClassNameProtocolRanges) {
if (targetClassNameProtocolRanges.length % 2 != 0) {
throw new IllegalArgumentException("Target class names must be paired with protocol ranges");
}
Map<String, String> targets = new LinkedHashMap<>();
for (int index = 0; index < targetClassNameProtocolRanges.length; index += 2) {
targets.put(targetClassNameProtocolRanges[index], targetClassNameProtocolRanges[index + 1]);
}
return Collections.unmodifiableMap(targets);
}
private static String[] filterTargetClassNames(Map<String, String> targetClassNames, int protocolVersion, int worldVersion) {
List<String> filteredTargetClassNames = new ArrayList<>();
for (Map.Entry<String, String> entry : targetClassNames.entrySet()) {
if (RangeMatcher.matches(entry.getValue(), protocolVersion, worldVersion)) {
filteredTargetClassNames.add(entry.getKey());
}
}
return filteredTargetClassNames.toArray(new String[0]);
}
protected boolean addInterface(ClassNode classNode, String interfaceName) {
if (!classNode.interfaces.contains(interfaceName)) {
classNode.interfaces.add(interfaceName);
}
return true;
}
protected boolean makeClassPublicNonFinal(ClassNode classNode) {
boolean modified = false;
int access = makePublicNonFinal(classNode.access);
if (classNode.access != access) {
classNode.access = access;
modified = true;
}
modified |= this.makeInnerClassPublicNonFinal(classNode, classNode.name);
return modified;
}
protected boolean makeInnerClassPublicNonFinal(ClassNode classNode, String innerName) {
boolean modified = false;
for (InnerClassNode innerClassNode : classNode.innerClasses) {
if (!innerName.equals(innerClassNode.name)) {
continue;
}
innerClassNode.access = makePublicNonFinal(innerClassNode.access);
modified = true;
}
return modified;
}
protected boolean makeMethodPublicNonFinal(MethodNode methodNode) {
if (methodNode == null) {
return false;
}
methodNode.access = makePublicNonFinal(methodNode.access);
return true;
}
protected boolean makeFieldPublicNonFinal(FieldNode fieldNode) {
if (fieldNode == null) {
return false;
}
fieldNode.access = makePublicNonFinal(fieldNode.access);
return true;
}
private static int makePublicNonFinal(int access) {
return (access & ~(ACC_PRIVATE | ACC_PROTECTED | ACC_FINAL)) | ACC_PUBLIC;
}
protected boolean matches(String range) {
return RangeMatcher.matches(range, this.protocolVersion, this.worldVersion);
}
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation) {
return applyIfMatches(range, label, operation, true);
}
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation, boolean required) {
if (!this.matches(range)) {
return false;
}
return this.requireModified(label, operation.getAsBoolean(), required);
}
protected boolean requireModified(String label, boolean modified) {
return this.requireModified(label, modified, true);
}
protected boolean requireModified(String label, boolean modified, boolean required) {
if (modified) {
return true;
}
String message = "Patch '" + this.getName() + ":" + label + "' matched protocol " + this.protocolVersion
+ " but did not modify any bytecode. If you want to force CustomSkinLoader to ignore this patch failure, add -D"
+ IGNORE_PATCH_FAILURE_PROPERTY + "=true to the JVM arguments.";
if ("false".equalsIgnoreCase(System.getProperty(IGNORE_PATCH_FAILURE_PROPERTY))) {
throw new IllegalStateException(message);
}
if (!required || Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
LOGGER.warn(message);
return false;
}
throw new IllegalStateException(message);
}
protected InsnList clone(InsnList source) {
InsnList copy = new InsnList();
for (AbstractInsnNode abstractInsnNode : source) {
copy.add(abstractInsnNode.clone(null));
}
return copy;
}
protected AbstractInsnNode findPreviousTypeInstruction(AbstractInsnNode instruction, int opcode, String type) {
AbstractInsnNode current = instruction == null ? null : instruction.getPrevious();
while (current != null) {
if (current.getOpcode() == opcode && current instanceof TypeInsnNode && type.equals(((TypeInsnNode) current).desc)) {
return current;
}
current = current.getPrevious();
}
return null;
}
protected AbstractInsnNode nextRealInstruction(AbstractInsnNode instruction) {
AbstractInsnNode current = instruction == null ? null : instruction.getNext();
while (current != null && current.getOpcode() < 0) {
current = current.getNext();
}
return current;
}
protected static void methodNodeSet(MethodNode methodNode, AbstractInsnNode oldInstruction, AbstractInsnNode newInstruction) {
methodNode.instructions.set(oldInstruction, newInstruction);
}
}
@@ -0,0 +1,168 @@
package customskinloader.bootstrap.transformer.patch;
import customskinloader.bootstrap.transformer.ClassTransformationContext;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
public final class RenderPatch extends PatchSupport {
public RenderPatch() {
super(
"customskinloader:render-patch", 1000,
targets(
PLAYER_TAB_OVERLAY, "",
CAPE_LAYER, "[556,]", // 19w39a+ (1.15+)
PLAYER_RENDERER, "[556,767],[801,803],[0x40000001,0x400000CC]" // 19w39a ~ 1.21.1 (1.15 ~ 1.21.1)
)
);
}
@Override
public boolean transform(ClassTransformationContext context) {
boolean modified = false;
if (context.isTarget(PLAYER_TAB_OVERLAY)) {
modified |= this.requireModified("player-tab-overlay", this.patchPlayerTabOverlay(context));
}
if (context.isTarget(CAPE_LAYER)) {
modified |= this.requireModified("cape-layer", this.patchCapeLayer(context), false);
}
if (context.isTarget(PLAYER_RENDERER)) {
modified |= this.requireModified("player-renderer", this.patchPlayerRenderer(context), false);
}
return modified;
}
private boolean patchPlayerTabOverlay(ClassTransformationContext context) {
boolean modified = false;
// 20w16a- (1.15.2-)
modified |= this.applyIfMatches("[,712]", "player-tab-overlay.render.v1", () -> replaceMinecraftLocalServerCheck(
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
));
// 20w17a ~ 23w14a (1.16 ~ 1.19.4)
modified |= this.applyIfMatches("[713,762],[801,803],[0x40000001,0x40000082]", "player-tab-overlay.render.v2", () -> replaceMinecraftLocalServerCheck(
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(POSE_STACK) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
));
// 23w16a ~ 26.1-snapshot-11 (1.20 ~ 1.21.11)
modified |= this.applyIfMatches("[763,774],[0x40000083,0x40000129]", "player-tab-overlay.render.v3", () -> replaceMinecraftLocalServerCheck(
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(GUI_GRAPHICS) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
));
// 26.1-pre-1 ~ 26.2-snapshot-6 (26.1 ~ 26.1.2)
modified |= this.applyIfMatches("775,[0x4000012A,0x40000138]", "player-tab-overlay.extract-render-state.v1", () -> replaceMinecraftLocalServerCheck(
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
));
// 26.2-snapshot-7+ (26.2+)
modified |= this.applyIfMatches("[776,800],[804,0x40000000],[0x40000139,]", "player-tab-overlay.extract-render-state.v2", () -> replaceMinecraftLocalServerCheck(
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), CLIENT_PACKET_LISTENER, "onlineMode"
));
return modified;
}
private boolean replaceMinecraftLocalServerCheck(ClassTransformationContext context, MethodNode methodNode, String owner, String name) {
if (methodNode == null) {
return false;
}
boolean modified = false;
String remappedOwner = context.remapClassName(owner);
String remappedName = context.remapMethodName(owner, name, "()Z");
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!remappedOwner.equals(methodInsnNode.owner) || !remappedName.equals(methodInsnNode.name) || !"()Z".equals(methodInsnNode.desc)) {
continue;
}
InsnList replacement = new InsnList();
replacement.add(new InsnNode(POP));
replacement.add(new InsnNode(ICONST_1));
methodNode.instructions.insertBefore(instruction, replacement);
methodNode.instructions.remove(instruction);
modified = true;
}
return modified;
}
private boolean patchCapeLayer(ClassTransformationContext context) {
boolean modified = false;
// 19w39a ~ 19w44a
modified |= this.applyIfMatches("[556,560]", "cape-layer.render.v1", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFFF)V"),
RENDER_TYPE
), false);
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "cape-layer.render.v2", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFF)V"),
RENDER_TYPE
), false);
// 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8)
modified |= this.applyIfMatches("[768,772],[0x400000CD,0x40000103]", "cape-layer.render.v3", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(PLAYER_RENDER_STATE) + "FF)V"),
RENDER_TYPE
), false);
// 25w31a ~ 25w42a (1.21.9 ~ 1.21.10)
modified |= this.applyIfMatches("773,[0x40000104,0x40000112]", "cape-layer.submit.v1", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
RENDER_TYPE
), false);
// 25w43a+ (1.21.11+)
modified |= this.applyIfMatches("[774,800],[804,0x40000000],[0x40000113,]", "cape-layer.submit.v2", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
RENDER_TYPES
), false);
return modified;
}
private boolean patchPlayerRenderer(ClassTransformationContext context) {
boolean modified = false;
// 19w39a ~ 19w44a
modified |= this.applyIfMatches("[556,560]", "player-renderer.render-hand.v1", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
RENDER_TYPE
), false);
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "player-renderer.render-hand.v2", () -> replaceEntitySolidWithTranslucent(
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
RENDER_TYPE
), false);
return modified;
}
private boolean replaceEntitySolidWithTranslucent(ClassTransformationContext context, MethodNode methodNode, String owner) {
if (methodNode == null) {
return false;
}
boolean modified = false;
String remappedOwner = context.remapClassName(owner);
String desc = "(" + objectDesc(IDENTIFIER) + ")" + objectDesc(RENDER_TYPE);
String remappedDesc = context.remapMethodDescriptor(desc);
String originalName = context.remapMethodName(owner, "entitySolid", desc);
String replacementName = context.remapMethodName(owner, "entityTranslucent", desc);
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!remappedOwner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !remappedDesc.equals(methodInsnNode.desc)) {
continue;
}
methodNode.instructions.insertBefore(instruction, new InsnNode(DUP));
methodNode.instructions.insert(instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
methodNode.instructions.insert(instruction, new InsnNode(POP));
modified = true;
}
return modified;
}
}
@@ -0,0 +1,523 @@
package customskinloader.bootstrap.transformer.patch;
import java.util.function.Predicate;
import customskinloader.bootstrap.transformer.ClassTransformationContext;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
public final class SkinManagerPatch extends PatchSupport {
public SkinManagerPatch() {
super(
"customskinloader:skin-manager-patch", 1000,
targets(
SKIN_MANAGER, "",
SKIN_MANAGER_1, "[764,800],[804,0x40000000],[0x40000090,]", // 23w31a+ (1.20.2+)
SKIN_MANAGER_3, "[,340]", // 1.12.2-
SKIN_MANAGER_CACHE_KEY, "[764,800],[804,0x40000000],[0x40000090,]", // 23w31a+ (1.20.2+)
SKIN_MANAGER_TEXTURE_CACHE, "[764,800],[804,0x40000000],[0x40000090,]" // 23w31a+ (1.20.2+)
)
);
}
@Override
public boolean transform(ClassTransformationContext context) {
boolean modified = false;
if (context.isTarget(SKIN_MANAGER)) {
// 23w31a+ (1.20.2+)
modified |= this.applyIfMatches("[764,800],[804,0x40000000],[0x40000090,]", "skin-manager.cache-key-inner-class", () -> makeInnerClassPublicNonFinal(context.getCurrentClassNode(), context.remapClassName(SKIN_MANAGER_CACHE_KEY)));
modified |= this.requireModified("skin-manager", this.patchSkinManager(context));
}
if (context.isTarget(SKIN_MANAGER_1)) {
modified |= this.requireModified("skin-manager-1", this.patchSkinManagerLoader(context));
}
if (context.isTarget(SKIN_MANAGER_3)) {
MethodNode getUserProfile = context.findMethod(SKIN_MANAGER_3, "run", "()V");
modified |= this.requireModified("skin-manager-3", getUserProfile != null && this.replaceGetTexturesWithFakeUserProfile(getUserProfile));
}
if (context.isTarget(SKIN_MANAGER_CACHE_KEY)) {
modified |= this.requireModified("skin-manager-cache-key", this.patchSkinManagerCacheKeyClass(context));
}
if (context.isTarget(SKIN_MANAGER_TEXTURE_CACHE)) {
modified |= this.requireModified("skin-manager-texture-cache", this.patchSkinManagerTextureCache(context));
}
return modified;
}
private boolean patchSkinManager(ClassTransformationContext context) {
boolean modified = false;
modified |= this.injectSkinManagerConstructors(context);
// 1.20.1-
modified |= this.applyIfMatches("[,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.v1", () -> patchLegacySkinManager(context));
// 23w42a+ (1.20.3+)
modified |= this.applyIfMatches("[765,800],[804,0x40000000],[0x4000009D,]", "skin-manager.v2", () -> patchSkinManagerCacheKey(context));
return modified;
}
private boolean patchSkinManagerCacheKeyClass(ClassTransformationContext context) {
boolean modified = this.makeClassPublicNonFinal(context.getCurrentClassNode());
modified |= this.makeMethodPublicNonFinal(context.findMethod(SKIN_MANAGER_CACHE_KEY, "<init>", "(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V"));
return modified;
}
private boolean injectSkinManagerConstructors(ClassTransformationContext context) {
boolean modified = false;
// 1.20.1-
modified |= this.applyIfMatches("[,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.<init>.v1", () -> injectSetSkinCacheDir(
context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(FILE) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")V", 2, objectDesc(FILE)
));
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
modified |= this.applyIfMatches("[764,768],[0x40000090,0x400000DD]", "skin-manager.<init>.v2", () -> injectSetSkinCacheDir(
context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 2, objectDesc(PATH)
));
// 24w46a ~ 25w33a (1.21.4 ~ 1.21.8)
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x40000106]", "skin-manager.<init>.v3", () -> injectSetSkinCacheDir(
context, "(" + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
));
// 25w34a ~ 25w34b
modified |= this.applyIfMatches("[0x40000107,0x40000108]", "skin-manager.<init>.v4", () -> injectSetSkinCacheDir(
context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
));
// 25w35a+ (1.21.9+)
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000109,]", "skin-manager.<init>.v5", () -> injectSetSkinCacheDir(
context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(SKIN_TEXTURE_DOWNLOADER) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
));
return modified;
}
private boolean injectSetSkinCacheDir(ClassTransformationContext context, String constructorDesc, int localIndex, String argumentDesc) {
MethodNode methodNode = context.findMethod(SKIN_MANAGER, "<init>", constructorDesc);
if (methodNode == null) {
return false;
}
boolean modified = false;
String remappedArgumentDesc = context.remapMethodDescriptor("(" + argumentDesc + ")V");
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (instruction.getOpcode() != RETURN) {
continue;
}
InsnList injection = new InsnList();
injection.add(new VarInsnNode(ALOAD, localIndex));
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "setSkinCacheDir", remappedArgumentDesc, false));
methodNode.instructions.insertBefore(instruction, injection);
modified = true;
}
return modified;
}
private boolean patchLegacySkinManager(ClassTransformationContext context) {
boolean modified = false;
modified |= this.requireModified("skin-manager.v1.register-texture", this.patchLegacySkinManagerRegisterTexture(context));
modified |= this.requireModified("skin-manager.v1.register-skins", this.patchLegacySkinManagerRegisterSkins(context));
modified |= this.requireModified("skin-manager.v1.get-insecure-skin-information", this.patchLegacySkinManagerGetInsecureSkinInformation(context));
// 1.13.2 ~ 1.20.1
modified |= this.applyIfMatches("[404,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.v1.lambda-register-skins-4", () -> patchLegacySkinManagerGetUserProfile(context));
return modified;
}
private boolean patchLegacySkinManagerRegisterTexture(ClassTransformationContext context) {
MethodNode registerTexture = context.findMethod(SKIN_MANAGER, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")" + objectDesc(IDENTIFIER));
if (registerTexture == null) {
return false;
}
InsnList insnList = new InsnList();
insnList.add(new VarInsnNode(ALOAD, 2));
return this.patchCreateThreadDownloadImageData(context, registerTexture, insnList);
}
private boolean patchLegacySkinManagerRegisterSkins(ClassTransformationContext context) {
MethodNode registerSkins = context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V");
if (registerSkins == null) {
return false;
}
boolean modified = false;
// 19w37a- (1.14.4-)
modified |= this.applyIfMatches("[,553]", "skin-manager.register-skins.v1", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR_SERVICE, "submit", "(" + objectDesc(RUNNABLE) + ")" + objectDesc(FUTURE), true));
// 19w38a ~ 1.18-exp7 (1.15 ~ 1.17.1)
modified |= this.applyIfMatches("[554,756],[801,803],[0x40000001,0x4000002F]+[2205,2831]", "skin-manager.register-skins.v2", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR, "execute", "(" + objectDesc(RUNNABLE) + ")V", false));
// 21w37a ~ 1.20.1 (1.18 ~ 1.20.1)
modified |= this.applyIfMatches("[757,763],[0x40000029,0x4000008E]+[2834,3465]", "skin-manager.register-skins.v3", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR_SERVICE, "execute", "(" + objectDesc(RUNNABLE) + ")V", false));
return modified;
}
private boolean patchLegacySkinManagerGetInsecureSkinInformation(ClassTransformationContext context) {
MethodNode loadSkinFromCache = context.findMethod(SKIN_MANAGER, "getInsecureSkinInformation", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP));
if (loadSkinFromCache == null) {
return false;
}
return this.replaceLoadSkinFromCacheMethod(loadSkinFromCache);
}
private boolean patchLegacySkinManagerGetUserProfile(ClassTransformationContext context) {
MethodNode getUserProfile = context.findMethod(SKIN_MANAGER, "lambda$registerSkins$4", "(" + objectDesc(GAME_PROFILE) + "Z" + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")V");
if (getUserProfile == null) {
return false;
}
return this.replaceGetTexturesWithFakeUserProfile(getUserProfile);
}
private boolean patchSkinManagerCacheKey(ClassTransformationContext context) {
boolean modified = false;
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
modified |= this.applyIfMatches("[765,772],[0x4000009D,0x40000106]", "skin-manager.cache-key.v1", () -> {
MethodNode getOrLoad = context.findMethod(SKIN_MANAGER, "getOrLoad", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE));
return getOrLoad != null && redirectCacheKeyConstruction(context, getOrLoad);
});
// 25w34a+ (1.21.9+)
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000107,]", "skin-manager.cache-key.v2", () -> {
MethodNode get = context.findMethod(SKIN_MANAGER, "get", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE));
return get != null && redirectCacheKeyConstruction(context, get);
});
return modified;
}
private boolean patchSkinManagerLoader(ClassTransformationContext context) {
boolean modified = false;
MethodNode load = context.findMethod(SKIN_MANAGER_1, "load", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(COMPLETABLE_FUTURE));
modified |= this.requireModified("skin-manager-1.executor", load != null && this.replaceCompletableFutureExecutor(load));
modified |= this.patchSkinManagerLoaderLambda(context);
return modified;
}
private boolean patchSkinManagerLoaderLambda(ClassTransformationContext context) {
boolean modified = false;
// 23w31a ~ 23w41a (1.20.2)
modified |= this.applyIfMatches("764,[0x40000090,0x4000009C]", "skin-manager-1.lambda-load-0.v1", () -> {
MethodNode oldLambda = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_TEXTURE_INFO));
return oldLambda != null && replaceGetTexturesWithFakeSkinCache(oldLambda);
});
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
modified |= this.applyIfMatches("[765,772],[0x4000009D,0x40000106]", "skin-manager-1.lambda-load-0.v2", () -> {
MethodNode lambdaWithSession = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES));
return lambdaWithSession != null && replaceUnpackTexturesWithFakeSkinCache(context, lambdaWithSession);
});
// 25w34a+ (1.21.9+)
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000107,]", "skin-manager-1.lambda-load-0.v3", () -> {
MethodNode lambdaWithServices = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(SERVICES) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES));
return lambdaWithServices != null && replaceUnpackTexturesWithFakeSkinCache(context, lambdaWithServices);
});
return modified;
}
private boolean patchSkinManagerTextureCache(ClassTransformationContext context) {
MethodNode registerTexture = context.findMethod(SKIN_MANAGER_TEXTURE_CACHE, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE));
if (registerTexture == null) {
return false;
}
String fieldName = context.remapFieldName(SKIN_MANAGER_TEXTURE_CACHE, "type");
InsnList loadType = new InsnList();
loadType.add(new VarInsnNode(ALOAD, 0));
loadType.add(new FieldInsnNode(GETFIELD, context.remapClassName(SKIN_MANAGER_TEXTURE_CACHE), fieldName, objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE)));
boolean modified = false;
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
modified |= this.applyIfMatches("[764,768],[0x40000090,0x400000DD]", "skin-manager-texture-cache.http-texture", () -> redirectHttpTextureConstructorToFake(
context, registerTexture, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
loadType
));
// 24w46a ~ 25w34b (1.21.4 ~ 1.21.8)
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x40000108]", "skin-manager-texture-cache.skin-texture-downloader.v1", () -> redirectSkinTextureDownloaderToFake(
context, registerTexture, INVOKESTATIC
));
// 25w35a+ (1.21.9+)
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000109,]", "skin-manager-texture-cache.skin-texture-downloader.v2", () -> redirectSkinTextureDownloaderToFake(
context, registerTexture, INVOKEVIRTUAL
));
return modified;
}
private boolean patchCreateThreadDownloadImageData(ClassTransformationContext context, MethodNode methodNode, InsnList loadTextureType) {
boolean modified = false;
// 19w37a- (1.14.4-)
modified |= this.applyIfMatches("[,553]", "skin-manager.http-texture.v1", () -> redirectHttpTextureConstructorToFake(
context, methodNode, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + ")V"),
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
loadTextureType
));
// 19w38a ~ 1.20.1 (1.15 ~ 1.20.1)
modified |= this.applyIfMatches("[554,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.http-texture.v2", () -> redirectHttpTextureConstructorToFake(
context, methodNode, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
loadTextureType
));
return modified;
}
private boolean redirectHttpTextureConstructorToFake(ClassTransformationContext context, MethodNode methodNode, String originalDesc, String replacementDesc, InsnList loadTextureType) {
if (methodNode == null) {
return false;
}
boolean modified = false;
String originalOwner = context.remapClassName(HTTP_TEXTURE);
String replacementOwner = context.remapClassName(FAKE_HTTP_TEXTURE_V1);
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (methodInsnNode.getOpcode() != INVOKESPECIAL || !originalOwner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !originalDesc.equals(methodInsnNode.desc)) {
continue;
}
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, originalOwner);
if (!(newNode instanceof TypeInsnNode)) {
continue;
}
((TypeInsnNode) newNode).desc = replacementOwner;
InsnList injection = new InsnList();
injection.add(new VarInsnNode(ALOAD, 1));
injection.add(this.clone(loadTextureType));
methodNode.instructions.insertBefore(methodInsnNode, injection);
methodInsnNode.owner = replacementOwner;
methodInsnNode.desc = replacementDesc;
modified = true;
}
return modified;
}
private boolean redirectSkinTextureDownloaderToFake(ClassTransformationContext context, MethodNode methodNode, int opcode) {
if (methodNode == null) {
return false;
}
boolean modified = false;
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
String desc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
String name = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin", "(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION4) + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE));
String functionDesc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + objectDesc(BOOLEAN) + ")" + objectDesc(COMPLETABLE_FUTURE));
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (methodInsnNode.getOpcode() != opcode || !owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
continue;
}
InsnList injection = new InsnList();
if (opcode == INVOKESTATIC) {
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, "", functionDesc, insnNode -> insnNode.getOpcode() == ASTORE, H_INVOKESTATIC)) {
continue;
}
} else {
String skinManagerOwner = context.remapClassName(SKIN_MANAGER);
String fieldName = context.remapFieldName(SKIN_MANAGER, "skinTextureDownloader");
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, objectDesc(owner), functionDesc, insnNode -> {
if (insnNode.getOpcode() == GETFIELD) {
FieldInsnNode fieldInsnNode = (FieldInsnNode) insnNode;
return skinManagerOwner.equals(fieldInsnNode.owner) && fieldName.equals(fieldInsnNode.name) && objectDesc(owner).equals(fieldInsnNode.desc);
}
return false;
}, H_INVOKEVIRTUAL)) {
continue;
}
}
injection.add(new VarInsnNode(ALOAD, 1));
methodNode.instructions.insertBefore(methodInsnNode, injection);
methodNodeSet(methodNode, methodInsnNode, new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "downloadAndRegisterSkin", replacementDesc, false));
modified = true;
}
return modified;
}
private boolean replaceSkinTextureDownloaderReceiver(MethodNode methodNode, MethodInsnNode invoke, String owner, String name, String desc, String ownerDesc, String functionDesc, Predicate<AbstractInsnNode> predicate, int handleTag) {
AbstractInsnNode current = invoke.getPrevious();
while (current != null) {
if (predicate.test(current)) {
methodNode.instructions.insert(current, new InvokeDynamicInsnNode(
"apply", "(" + ownerDesc + ")" + objectDesc(FUNCTION4),
new Handle(H_INVOKESTATIC, LAMBDA_METAFACTORY, "metafactory", "(" + objectDesc(METHOD_HANDLES_LOOKUP) + objectDesc(STRING) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_HANDLE) + objectDesc(METHOD_TYPE) + ")" + objectDesc(CALL_SITE), false),
Type.getType("(" + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + ")" + objectDesc(OBJECT)),
new Handle(handleTag, owner, name, desc, false),
Type.getType(functionDesc)
));
return true;
}
current = current.getPrevious();
}
return false;
}
private boolean replaceExecutorProfileLoadAtInvocation(MethodNode methodNode, String owner, String name, String desc, boolean pushNullReturn) {
boolean modified = false;
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
continue;
}
InsnList replacement = new InsnList();
replacement.add(new InsnNode(SWAP));
replacement.add(new InsnNode(POP));
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(RUNNABLE) + ")V", false));
if (pushNullReturn) {
replacement.add(new InsnNode(ACONST_NULL));
}
methodNode.instructions.insertBefore(instruction, replacement);
methodNode.instructions.remove(instruction);
modified = true;
}
return modified;
}
private boolean replaceLoadSkinFromCacheMethod(MethodNode methodNode) {
methodNode.instructions.clear();
methodNode.tryCatchBlocks.clear();
methodNode.instructions.add(new VarInsnNode(ALOAD, 1));
methodNode.instructions.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP), false));
methodNode.instructions.add(new InsnNode(ARETURN));
methodNode.maxLocals = Math.max(methodNode.maxLocals, 2);
return true;
}
private boolean replaceGetTexturesWithFakeUserProfile(MethodNode methodNode) {
boolean modified = false;
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"getTextures".equals(methodInsnNode.name) || !("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
continue;
}
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "getUserProfile", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
modified = true;
}
return modified;
}
private boolean redirectCacheKeyConstruction(ClassTransformationContext context, MethodNode methodNode) {
boolean modified = false;
String owner = context.remapClassName(SKIN_MANAGER_CACHE_KEY);
String desc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V");
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_CACHE_KEY));
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!owner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
continue;
}
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, owner);
AbstractInsnNode dupNode = this.nextRealInstruction(newNode);
if (newNode == null || dupNode == null || dupNode.getOpcode() != DUP) {
continue;
}
methodNode.instructions.remove(newNode);
methodNode.instructions.remove(dupNode);
InsnList replacement = new InsnList();
replacement.add(new VarInsnNode(ALOAD, 1));
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_CACHE_KEY, "createFakeCacheKey", replacementDesc, false));
methodNode.instructions.insertBefore(methodInsnNode, replacement);
methodNode.instructions.remove(methodInsnNode);
modified = true;
}
return modified;
}
private boolean replaceCompletableFutureExecutor(MethodNode methodNode) {
boolean modified = false;
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!COMPLETABLE_FUTURE.equals(methodInsnNode.owner)) {
continue;
}
if (("supplyAsync".equals(methodInsnNode.name) && ("(" + objectDesc(SUPPLIER) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc))
|| ("thenComposeAsync".equals(methodInsnNode.name) && ("(" + objectDesc(FUNCTION) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc))) {
InsnList replacement = new InsnList();
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(EXECUTOR) + ")" + objectDesc(EXECUTOR), false));
methodNode.instructions.insertBefore(instruction, replacement);
modified = true;
}
}
return modified;
}
private boolean replaceGetTexturesWithFakeSkinCache(MethodNode methodNode) {
boolean modified = false;
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"getTextures".equals(methodInsnNode.name) || !("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
continue;
}
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
modified = true;
}
return modified;
}
private boolean replaceUnpackTexturesWithFakeSkinCache(ClassTransformationContext context, MethodNode methodNode) {
boolean modified = false;
String desc = context.remapMethodDescriptor("(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(PROPERTY) + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(OBJECT));
String returnType = context.remapClassName(MINECRAFT_PROFILE_TEXTURES);
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"unpackTextures".equals(methodInsnNode.name) || !("(" + objectDesc(PROPERTY) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)).equals(methodInsnNode.desc)) {
continue;
}
InsnList replacement = new InsnList();
replacement.add(new VarInsnNode(ALOAD, 0));
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", desc, false));
replacement.add(new TypeInsnNode(CHECKCAST, returnType));
methodNode.instructions.insertBefore(instruction, replacement);
methodNode.instructions.remove(instruction);
modified = true;
}
return modified;
}
}
@@ -0,0 +1,177 @@
package customskinloader.bootstrap.transformer.patch;
import customskinloader.bootstrap.transformer.ClassTransformationContext;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public final class SkinTexturePatch extends PatchSupport {
public SkinTexturePatch() {
super(
"customskinloader:skin-texture-patch", 1000,
targets(
HTTP_TEXTURE, "[,768],[801,803],[0x40000001,0x400000DD]", // 24w45a- (1.21.3-)
SKIN_TEXTURE_DOWNLOADER, "[769,800],[804,0x40000000],[0x400000DE,]" // 24w46a+ (1.21.4+)
)
);
}
@Override
public boolean transform(ClassTransformationContext context) {
boolean modified = false;
if (context.isTarget(HTTP_TEXTURE)) {
// 24w45a- (1.21.3-)
modified |= this.applyIfMatches("[,768],[801,803],[0x40000001,0x400000DD]", "http-texture.uploaded", () -> this.makeFieldPublicNonFinal(context.findField(HTTP_TEXTURE, "uploaded")));
// 19w38a ~ 24w45a (1.15 ~ 1.21.3)
modified |= this.applyIfMatches("[554,768],[801,803],[0x40000001,0x400000DD]", "http-texture.patch", () -> this.patchHttpTexture(context));
}
if (context.isTarget(SKIN_TEXTURE_DOWNLOADER)) {
modified |= this.requireModified("skin-texture-downloader.patch", this.patchSkinTextureDownloader(context));
}
return modified;
}
private boolean patchHttpTexture(ClassTransformationContext context) {
return this.replaceHttpTextureProcessLegacySkin(
context, context.findMethod(HTTP_TEXTURE, "load", "(" + objectDesc(INPUT_STREAM) + ")" + objectDesc(NATIVE_IMAGE))
);
}
private boolean patchSkinTextureDownloader(ClassTransformationContext context) {
boolean modified = false;
modified |= this.requireModified("skin-texture-downloader.then-compose", this.replaceThenComposeTextureFunction(
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin", "(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE))
));
// 24w46a+ (1.21.4+)
modified |= this.applyIfMatches("[769,800],[804,0x40000000],[0x400000DE,]", "skin-texture-downloader.process-legacy-skin", () -> replaceSkinTextureDownloaderProcessLegacySkin(context));
return modified;
}
private boolean replaceThenComposeTextureFunction(ClassTransformationContext context, MethodNode methodNode) {
if (methodNode == null) {
return false;
}
boolean modified = false;
int locationLocal = (methodNode.access & ACC_STATIC) == 0 ? 1 : 0;
int booleanLocal = locationLocal + 3;
String remappedHookDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION) + objectDesc(IDENTIFIER) + "Z)" + objectDesc(FUNCTION));
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!COMPLETABLE_FUTURE.equals(methodInsnNode.owner) || !"thenCompose".equals(methodInsnNode.name) || !("(" + objectDesc(FUNCTION) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc)) {
continue;
}
InsnList injection = new InsnList();
injection.add(new VarInsnNode(ALOAD, locationLocal));
injection.add(new VarInsnNode(ILOAD, booleanLocal));
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "createTexture", remappedHookDesc, false));
methodNode.instructions.insertBefore(instruction, injection);
modified = true;
}
return modified;
}
private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context) {
boolean modified = false;
// 24w46a ~ 25w37a (1.21.4 ~ 1.21.8)
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x4000010C]", "skin-texture-downloader.process-legacy-skin.v1", () -> replaceSkinTextureDownloaderProcessLegacySkin(
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(NATIVE_IMAGE))
));
// 1.21.9-pre1+ (1.21.9+)
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x4000010D,]", "skin-texture-downloader.process-legacy-skin.v2", () -> replaceSkinTextureDownloaderProcessLegacySkin(
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(CLIENT_ASSET_DOWNLOADED_TEXTURE) + "Z)" + objectDesc(NATIVE_IMAGE))
));
return modified;
}
private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context, MethodNode methodNode) {
if (methodNode == null) {
return false;
}
boolean modified = false;
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
String originalDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
String originalName = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (methodInsnNode.getOpcode() != INVOKESTATIC || !owner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !originalDesc.equals(methodInsnNode.desc)) {
continue;
}
methodNodeSet(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", originalDesc, false));
modified = true;
}
return modified;
}
private boolean replaceHttpTextureProcessLegacySkin(ClassTransformationContext context, MethodNode load) {
if (load == null) {
return false;
}
boolean modified = false;
String owner = context.remapClassName(HTTP_TEXTURE);
String originalName = context.remapMethodName(HTTP_TEXTURE, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
String imageDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(RUNNABLE) + objectDesc(FUNCTION) + ")" + objectDesc(NATIVE_IMAGE));
String processTaskField = context.remapFieldName(HTTP_TEXTURE, "onDownloaded");
for (AbstractInsnNode instruction : load.instructions.toArray()) {
if (!(instruction instanceof MethodInsnNode)) {
continue;
}
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (!owner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !imageDesc.equals(methodInsnNode.desc)) {
continue;
}
boolean staticProcessLegacySkin = methodInsnNode.getOpcode() == INVOKESTATIC;
InsnList injection = new InsnList();
int implementationHandleTag;
String functionFactoryDesc;
if (staticProcessLegacySkin) {
injection.add(new VarInsnNode(ALOAD, 0));
injection.add(new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
implementationHandleTag = H_INVOKESTATIC;
functionFactoryDesc = "()" + objectDesc(FUNCTION);
} else {
injection.add(new InsnNode(SWAP));
injection.add(new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
injection.add(new VarInsnNode(ALOAD, 0));
implementationHandleTag = H_INVOKEVIRTUAL;
functionFactoryDesc = "(" + objectDesc(owner) + ")" + objectDesc(FUNCTION);
}
injection.add(new InvokeDynamicInsnNode(
"apply", functionFactoryDesc,
new Handle(H_INVOKESTATIC, LAMBDA_METAFACTORY, "metafactory", "(" + objectDesc(METHOD_HANDLES_LOOKUP) + objectDesc(STRING) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_HANDLE) + objectDesc(METHOD_TYPE) + ")" + objectDesc(CALL_SITE), false),
Type.getType("(" + objectDesc(OBJECT) + ")" + objectDesc(OBJECT)),
new Handle(implementationHandleTag, owner, originalName, imageDesc, false),
Type.getType(imageDesc)
));
load.instructions.insertBefore(instruction, injection);
methodNodeSet(load, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", replacementDesc, false));
modified = true;
}
return modified;
}
}
@@ -0,0 +1,43 @@
package customskinloader.bootstrap.util;
import java.lang.reflect.Field;
import java.nio.file.Path;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.installer.CommonJarInstaller;
import org.apache.logging.log4j.Logger;
/**
* Shared setup for Forge-style mods-folder locators that expose the released jar as a synthetic mod.
*/
public final class ModLocatorUtils {
public static final String LOCATOR_NAME = "customskinloader-locator";
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private ModLocatorUtils() {
}
public static void initialize(Object locator, Class<?> locatorType, Path gameDirectory, String mappingType) {
try {
Path runtimeDirectory = resolveRuntimeDirectory(gameDirectory);
LOGGER.info("Initializing " + LOCATOR_NAME + " for " + mappingType + " mappings in " + BootstrapLogger.formatPath(gameDirectory));
setModFolder(locator, locatorType, runtimeDirectory);
Path commonJar = CommonJarInstaller.releaseCommonJar(gameDirectory, mappingType);
LOGGER.info("Initialized " + LOCATOR_NAME + " with mod folder " + BootstrapLogger.formatPath(runtimeDirectory)
+ " and Common jar " + BootstrapLogger.formatPath(commonJar));
} catch (Exception exception) {
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
}
}
private static Path resolveRuntimeDirectory(Path gameDirectory) {
return gameDirectory.resolve("CustomSkinLoader").resolve("Core");
}
private static void setModFolder(Object locator, Class<?> locatorType, Path modFolder) throws NoSuchFieldException, IllegalAccessException {
Field field = locatorType.getDeclaredField("modFolder");
field.setAccessible(true);
field.set(locator, modFolder);
}
}
@@ -0,0 +1,99 @@
package customskinloader.bootstrap.util;
import java.util.ArrayList;
import java.util.List;
/**
* Shared matcher for protocol and ordinal range expressions.
*/
public final class RangeMatcher {
private RangeMatcher() {
}
public static boolean matches(String expression, int protocolVersion, int worldVersion) {
if (expression == null || expression.trim().isEmpty()) {
return true;
}
String protocolRange = "";
String worldRange = "";
int index = expression.indexOf("+");
if (index >= 0) {
protocolRange = expression.substring(0, index);
worldRange = expression.substring(index + 1);
} else {
protocolRange = expression;
}
return matches(protocolRange, protocolVersion) && matches(worldRange, worldVersion);
}
private static boolean matches(String expression, int value) {
if (expression == null || expression.trim().isEmpty()) {
return true;
}
for (String token : splitTokens(expression)) {
String trimmedToken = token.trim();
if (trimmedToken.isEmpty()) {
continue;
}
if (trimmedToken.startsWith("[") && trimmedToken.endsWith("]")) {
int commaIndex = trimmedToken.indexOf(',');
if (commaIndex < 0) {
throw new IllegalArgumentException("Invalid range token: " + trimmedToken);
}
String leftPart = trimmedToken.substring(1, commaIndex).trim();
String rightPart = trimmedToken.substring(commaIndex + 1, trimmedToken.length() - 1).trim();
int lowerBound = leftPart.isEmpty() ? 0 : parseNumber(leftPart);
int upperBound = rightPart.isEmpty() ? Integer.MAX_VALUE : parseNumber(rightPart);
if (value >= lowerBound && value <= upperBound) {
return true;
}
continue;
}
if (value == parseNumber(trimmedToken)) {
return true;
}
}
return false;
}
private static List<String> splitTokens(String expression) {
List<String> tokens = new ArrayList<>();
StringBuilder currentToken = new StringBuilder();
int bracketDepth = 0;
for (int index = 0; index < expression.length(); index++) {
char currentChar = expression.charAt(index);
if (currentChar == '[') {
bracketDepth++;
} else if (currentChar == ']') {
bracketDepth--;
}
if (currentChar == ',' && bracketDepth == 0) {
tokens.add(currentToken.toString());
currentToken.setLength(0);
continue;
}
currentToken.append(currentChar);
}
tokens.add(currentToken.toString());
return tokens;
}
private static int parseNumber(String token) {
String trimmedToken = token.trim();
if (trimmedToken.startsWith("0x")) {
return Integer.parseInt(trimmedToken.substring(2), 16);
}
return Integer.parseInt(trimmedToken, 10);
}
}
@@ -0,0 +1,75 @@
package customskinloader.bootstrap.util;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Small DOM helpers shared by mapping and patch XML parsers.
*/
public final class XmlUtils {
private XmlUtils() {
}
public static Document parseDocument(Reader reader, String documentDescription) throws IOException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
factory.setExpandEntityReferences(false);
factory.setIgnoringComments(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(reader));
document.getDocumentElement().normalize();
return document;
} catch (ParserConfigurationException exception) {
throw new IOException("Failed to configure XML parser for " + documentDescription, exception);
} catch (SAXException exception) {
throw new IOException("Failed to parse " + documentDescription, exception);
}
}
public static String requiredAttribute(Element element, String attributeName) {
String value = element.getAttribute(attributeName);
if (value.trim().isEmpty()) {
throw new IllegalArgumentException("Missing required attribute '" + attributeName + "' on <" + element.getTagName() + ">");
}
return value.trim();
}
public static List<Element> childElements(Element parentElement, String requiredTagName) {
if (parentElement == null) {
return Collections.emptyList();
}
List<Element> elements = new ArrayList<>();
NodeList childNodes = parentElement.getChildNodes();
for (int index = 0; index < childNodes.getLength(); index++) {
Node currentNode = childNodes.item(index);
if (currentNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element currentElement = (Element) currentNode;
if (requiredTagName == null || requiredTagName.equals(currentElement.getTagName())) {
elements.add(currentElement);
}
}
return elements;
}
}
@@ -33,4 +33,4 @@ GPLv3: http://www.gnu.org/licenses/gpl.html
其他 - 有用的链接
源代码: https://github.com/xfl03/MCCustomSkinLoader
发布页面: http://www.mcbbs.net/thread-269807-1-1.html
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
@@ -0,0 +1,4 @@
customskinloader.bootstrap.transformer.patch.InterfacePatch
customskinloader.bootstrap.transformer.patch.RenderPatch
customskinloader.bootstrap.transformer.patch.SkinManagerPatch
customskinloader.bootstrap.transformer.patch.SkinTexturePatch
@@ -0,0 +1,457 @@
<?xml version='1.0' encoding='utf-8'?>
<mapping>
<class name="com/mojang/blaze3d/platform/NativeImage">
<name type="srg" version="[404,754]">net/minecraft/client/renderer/texture/NativeImage</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1011</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="copyFrom(Lcom/mojang/blaze3d/platform/NativeImage;)V">
<name type="srg" version="[404,754]">func_195703_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_85054_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4317</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="copyRect(IIIIIIZZ)V">
<name type="srg" version="[404,754]">func_195699_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_85025_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4304</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="fillRect(IIIII)V">
<name type="srg" version="[404,754]">func_195715_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_84997_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4326</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getHeight()I">
<name type="srg" version="[404,754]">func_195714_b</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_85084_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4323</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getPixelRGBA(II)I">
<name type="srg" version="[404,754]">func_195709_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_84985_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4315</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getWidth()I">
<name type="srg" version="[404,754]">func_195702_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_84982_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4307</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="read(Ljava/io/InputStream;)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="srg" version="[404,754]">func_195713_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_85058_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4309</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="setPixelRGBA(III)V">
<name type="srg" version="[404,754]">func_195700_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_84988_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4305</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
</class>
<class name="com/mojang/blaze3d/vertex/PoseStack">
<name type="srg" version="[404,754]">com/mojang/blaze3d/matrix/MatrixStack</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_4587</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="customskinloader/fake/itf/FakeHttpTextureProcessor"> <!-- net/minecraft/client/renderer/HttpTextureProcessor -->
<name type="srg" version="[,553]">net/minecraft/client/renderer/IImageBuffer</name> <!-- 19w37a- (1.14.4-) -->
<name type="intermediary" version="[441,553]">net/minecraft/class_760</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
<method name="onTextureDownloaded()V">
<name type="srg" version="[,553]">func_152634_a</name> <!-- 19w37a- (1.14.4-) -->
<name type="intermediary" version="[441,553]">method_3238</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
</method>
<method name="process(Lcom/mojang/blaze3d/platform/NativeImage;)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="srg" version="[404,553]">func_195786_a</name> <!-- 1.13.2 ~ 19w37a (1.13.2 ~ 1.14.4) -->
<name type="intermediary" version="[441,553]">method_3237</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
</method>
<method name="process(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;">
<name type="srg" version="[,340]">func_78432_a</name> <!-- 1.12.2- -->
</method>
</class>
<class name="customskinloader/fake/itf/IFakeIResource$V1">
<method name="getInputStream()Ljava/io/InputStream;">
<name type="srg" version="[,340]">func_110527_b</name> <!-- 1.12.2- -->
<name type="srg" version="[404,754]">func_199027_b</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,758]">m_6679_</name> <!-- 1.17.1 ~ 1.18.2 -->
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14482</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
</method>
</class>
<class name="customskinloader/fake/itf/IFakeIResource$V2">
<method name="open()Ljava/io/InputStream;">
<name type="srg" version="[759,765]">m_215507_</name> <!-- 1.19 ~ 1.20.4 -->
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14482</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
</method>
</class>
<class name="customskinloader/fake/itf/IFakeIResourceManager$V1">
<method name="getResource(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/Resource;">
<name type="srg" version="[,340]">func_110536_a</name> <!-- 1.12.2- -->
<name type="srg" version="[404,754]">func_199002_a</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,758]">m_142591_</name> <!-- 1.17.1 ~ 1.18.2 -->
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14486</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
</method>
</class>
<class name="customskinloader/fake/itf/IFakeIResourceManager$V2">
<method name="getResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional;">
<name type="srg" version="[759,765]">m_213713_</name> <!-- 1.19 ~ 1.20.4 -->
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14486</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
</method>
</class>
<class name="customskinloader/fake/itf/IFakeNativeImage">
<method name="getPixel(II)I">
<name type="intermediary" version="[768,774],[0x400000CD,0x4000011E]">method_61940</name> <!-- 24w33a ~ 1.21.11 (1.21.2 ~ 1.21.11) -->
</method>
<method name="setPixel(III)V">
<name type="intermediary" version="[768,774],[0x400000CD,0x4000011E]">method_61941</name> <!-- 24w33a ~ 1.21.11 (1.21.2 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/Minecraft">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_310</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<field name="gameDirectory">
<name type="srg" version="[,754]">field_71412_D</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">f_91069_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">field_1697</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</field>
<method name="getCurrentServer()Lnet/minecraft/client/multiplayer/ServerData;">
<name type="srg" version="[,754]">func_147104_D</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_91089_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1558</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getInstance()Lnet/minecraft/client/Minecraft;">
<name type="srg" version="[,754]">func_71410_x</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_91087_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1551</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getResourceManager()Lnet/minecraft/server/packs/resources/ResourceManager;">
<name type="srg" version="[,340]">func_110442_L</name> <!-- 1.12.2- -->
<name type="srg" version="[404,754]">func_195551_G</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_91098_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1478</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getSkinManager()Lnet/minecraft/client/resources/SkinManager;">
<name type="srg" version="[,754]">func_152342_ad</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_91109_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1582</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="getTextureManager()Lnet/minecraft/client/renderer/texture/TextureManager;">
<name type="srg" version="[,754]">func_110434_K</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_91097_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1531</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="isLocalServer()Z">
<name type="srg" version="[,754]">func_71387_A</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_91090_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1542</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/gui/GuiGraphics">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_332</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/gui/GuiGraphicsExtractor" />
<class name="net/minecraft/client/gui/components/PlayerTabOverlay">
<name type="srg" version="[,754]">net/minecraft/client/gui/GuiPlayerTabOverlay</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_355</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V" />
<method name="render(ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
<name type="srg" version="[,578]">func_175249_a</name> <!-- 1.15.2- -->
<name type="intermediary" version="[441,712]">method_1919</name> <!-- 18w43b ~ 20w16a (1.14 ~ 1.15.2) -->
</method>
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
<name type="srg" version="[736,754]">func_238523_a_</name> <!-- 1.16.1 ~ 1.16.5 -->
<name type="srg" version="[756,762]">m_94544_</name> <!-- 1.17.1 ~ 1.19.4 -->
<name type="intermediary" version="[713,762],[801,803],[0x40000001,0x40000082]">method_1919</name> <!-- 20w17a ~ 23w14a (1.16 ~ 1.19.4) -->
</method>
<method name="render(Lnet/minecraft/client/gui/GuiGraphics;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
<name type="srg" version="[763,765]">m_280406_</name> <!-- 1.20 ~ 1.20.4 -->
<name type="intermediary" version="[763,774],[0x40000083,0x4000011E]">method_1919</name> <!-- 23w16a ~ 1.21.11 (1.20 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/model/geom/ModelPart">
<name type="srg" version="[,754]">net/minecraft/client/renderer/model/ModelRenderer</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_630</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/multiplayer/ClientPacketListener">
<name type="srg" version="[,404]">net/minecraft/client/network/NetHandlerPlayClient</name> <!-- 1.13.2- -->
<name type="srg" version="[485,754]">net/minecraft/client/network/play/ClientPlayNetHandler</name> <!-- 1.14.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_634</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="onlineMode()Z" />
</class>
<class name="net/minecraft/client/multiplayer/ServerData">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_642</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<field name="ip">
<name type="srg" version="[,754]">field_78845_b</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">f_105363_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">field_3761</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</field>
</class>
<class name="net/minecraft/client/player/AbstractClientPlayer">
<name type="srg" version="[,404]">net/minecraft/client/entity/AbstractClientPlayer</name> <!-- 1.13.2- -->
<name type="srg" version="[485,754]">net/minecraft/client/entity/player/AbstractClientPlayerEntity</name> <!-- 1.14.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_742</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/MultiBufferSource">
<name type="srg" version="[,754]">net/minecraft/client/renderer/IRenderTypeBuffer</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_4597</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/SubmitNodeCollector">
<name type="intermediary" version="[773,774],[0x40000104,0x4000011E]">net/minecraft/class_11659</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/entity/layers/CapeLayer">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_972</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V">
<name type="srg" version="[573,754]">func_225628_a_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_6494_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[573,767],[801,803],[0x40000001,0x400000CC]">method_4177</name> <!-- 1.15 ~ 1.21.1 -->
</method>
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFFF)V">
<name type="intermediary" version="[556,560]">method_4177</name> <!-- 19w39a ~ 19w44a -->
</method>
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V">
<name type="intermediary" version="[768,772],[0x400000CD,0x40000103]">method_4177</name> <!-- 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8) -->
</method>
<method name="submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V">
<name type="intermediary" version="[773,774],[0x40000104,0x4000011E]">method_4177</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/renderer/entity/player/PlayerRenderer">
<name type="srg" version="[,754]">net/minecraft/client/renderer/entity/PlayerRenderer</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1007</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/client/model/geom/ModelPart;Lnet/minecraft/client/model/geom/ModelPart;)V">
<name type="srg" version="[573,754]">func_229145_a_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_117775_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[573,767],[801,803],[0x40000001,0x400000CC]">method_23205</name> <!-- 1.15 ~ 1.21.1 -->
</method>
<method name="renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/client/model/geom/ModelPart;Lnet/minecraft/client/model/geom/ModelPart;)V">
<name type="intermediary" version="[556,560]">method_23205</name> <!-- 19w39a ~ 19w44a -->
</method>
</class>
<class name="net/minecraft/client/renderer/entity/state/AvatarRenderState">
<name type="intermediary" version="773,774,[0x40000104,0x4000011E]">net/minecraft/class_10055</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/entity/state/PlayerRenderState">
<name type="intermediary" version="[768,772],[0x400000CD,0x40000103]">net/minecraft/class_10055</name> <!-- 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8) -->
</class>
<class name="net/minecraft/client/renderer/rendertype/RenderType">
<name type="srg" version="[573,773]">net/minecraft/client/renderer/RenderType</name> <!-- 1.15 ~ 1.21.10 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1921</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<name type="official" version="[764,773]">net/minecraft/client/renderer/RenderType</name> <!-- 1.20.2 ~ 1.21.10 -->
<method name="entitySolid(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
<name type="srg" version="[573,754]">func_228634_a_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_110446_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[558,773],[801,803],[0x40000001,0x40000112]">method_23572</name> <!-- 19w41a ~ 25w42a (1.15 ~ 1.21.10) -->
</method>
<method name="entityTranslucent(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
<name type="srg" version="[573,754]">func_228644_e_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_110473_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[558,773],[801,803],[0x40000001,0x40000112]">method_23580</name> <!-- 19w41a ~ 25w42a (1.15 ~ 1.21.10) -->
</method>
</class>
<class name="net/minecraft/client/renderer/rendertype/RenderTypes">
<name type="intermediary" version="774,[0x40000113,0x4000011E]">net/minecraft/class_12249</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
<method name="entitySolid(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
<name type="intermediary" version="774,[0x40000113,0x4000011E]">method_75982</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
</method>
<method name="entityTranslucent(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
<name type="intermediary" version="774,[0x40000113,0x4000011E]">method_76000</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/renderer/texture/AbstractTexture">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1044</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/texture/HttpTexture">
<name type="srg" version="[,340]">net/minecraft/client/renderer/ThreadDownloadImageData</name> <!-- 1.12.2- -->
<name type="srg" version="404">net/minecraft/client/renderer/texture/ThreadDownloadImageData</name> <!-- 1.13.2 -->
<name type="srg" version="[485,754]">net/minecraft/client/renderer/texture/DownloadingTexture</name> <!-- 1.14.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,768],[801,803],[0x40000001,0x400000DD]">net/minecraft/class_1046</name> <!-- 18w43b ~ 24w45a (1.14 ~ 1.21.3) -->
<field name="onDownloaded">
<name type="srg" version="[573,754]">field_229155_i_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">f_117997_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[554,774],[801,803],[0x40000001,0x4000011E]">field_20843</name> <!-- 19w38a ~ 1.21.11 (1.15 ~ 1.21.11) -->
</field>
<field name="uploaded">
<name type="srg" version="[,754]">field_110559_g</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">f_117999_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,768],[801,803],[0x40000001,0x400000DD]">field_5215</name> <!-- 18w43b ~ 24w45a (1.14 ~ 1.21.3) -->
</field>
<method name="load(Ljava/io/InputStream;)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="srg" version="[404,754]">func_229159_a_</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_118018_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_22795</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="processLegacySkin(Lcom/mojang/blaze3d/platform/NativeImage;)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="srg" version="[404,754]">func_229163_c_</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_118032_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_22798</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
<method name="upload(Ljava/awt/image/BufferedImage;)V">
<name type="srg" version="[,340]">func_147641_a</name> <!-- 1.12.2- -->
</method>
</class>
<class name="net/minecraft/client/renderer/texture/ReloadableTexture">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10537</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/texture/SimpleTexture">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1049</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="loadContents(Lnet/minecraft/server/packs/resources/ResourceManager;)Lnet/minecraft/client/renderer/texture/TextureContents;">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65809</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/renderer/texture/SkinTextureDownloader">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10538</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
<method name="downloadAndRegisterSkin(Lnet/minecraft/resources/Identifier;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture;">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65861</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</method>
<method name="lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Ljava/lang/String;Z)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="intermediary" version="[769,772],[0x400000DE,0x4000010C]">method_65866</name> <!-- 24w46a ~ 25w37a (1.21.4 ~ 1.21.8) -->
</method>
<method name="lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Lnet/minecraft/core/ClientAsset$DownloadedTexture;Z)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="intermediary" version="773,774,[0x4000010D,0x4000011E]">method_65866</name> <!-- 1.21.9-pre1 ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</method>
<method name="processLegacySkin(Lcom/mojang/blaze3d/platform/NativeImage;Ljava/lang/String;)Lcom/mojang/blaze3d/platform/NativeImage;">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65863</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/renderer/texture/TextureContents">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10539</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/renderer/texture/TextureManager">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1060</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="register(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V">
<name type="srg" version="[573,754]">func_229263_a_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,765]">m_118495_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[556,774],[801,803],[0x40000001,0x4000011E]">method_4616</name> <!-- 19w39a ~ 1.21.11 (1.15 ~ 1.21.11) -->
</method>
<method name="registerAndLoad(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/renderer/texture/ReloadableTexture;)V">
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65876</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/resources/SkinManager">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1071</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<field name="skinTextureDownloader">
<name type="intermediary" version="773,774,[0x40000109,0x4000011E]">field_62487</name> <!-- 25w35a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</field>
<method name="get(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;">
<name type="intermediary" version="773,774,[0x40000107,0x4000011E]">method_52863</name> <!-- 25w34a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</method>
<method name="getInsecureSkinInformation(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;">
<name type="srg" version="[,754]">func_152788_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,763]">m_118815_</name> <!-- 1.17.1 ~ 1.20.1 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4654</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</method>
<method name="getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;">
<name type="srg" version="764,765">m_293351_</name> <!-- 1.20.2 ~ 1.20.4 -->
<name type="intermediary" version="[764,772],[0x40000090,0x40000106]">method_52863</name> <!-- 23w31a ~ 25w33a (1.20.2 ~ 1.21.8) -->
</method>
<method name="lambda$registerSkins$4(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V">
<name type="srg" version="[404,498]">func_210275_a</name> <!-- 1.13.2 ~ 1.14.4 -->
<name type="srg" version="[573,754]">func_229293_a_</name> <!-- 1.15 ~ 1.16.5 -->
<name type="srg" version="[756,763]">m_118821_</name> <!-- 1.17.1 ~ 1.20.1 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4653</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</method>
<method name="registerSkins(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V">
<name type="srg" version="[,754]">func_152790_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,763]">m_118817_</name> <!-- 1.17.1 ~ 1.20.1 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4652</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</method>
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/resources/Identifier;">
<name type="srg" version="[,754]">func_152792_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,763]">m_118825_</name> <!-- 1.17.1 ~ 1.20.1 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4656</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</method>
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/Identifier;">
<name type="srg" version="[,754]">func_152789_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,763]">m_118828_</name> <!-- 1.17.1 ~ 1.20.1 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4651</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</method>
</class>
<class name="net/minecraft/client/resources/SkinManager$1">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1071$1</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="lambda$load$0(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;">
<name type="srg" version="764">m_293645_</name> <!-- 1.20.2 -->
<name type="intermediary" version="764,[0x40000090,0x4000009C]">method_52867</name> <!-- 23w31a ~ 23w41a (1.20.2) -->
</method>
<method name="lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;">
<name type="srg" version="765">m_304063_</name> <!-- 1.20.3 ~ 1.20.4 -->
<name type="intermediary" version="[765,772],[0x4000009D,0x40000106]">method_54647</name> <!-- 23w42a ~ 25w33a (1.20.3 ~ 1.21.8) -->
</method>
<method name="lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lnet/minecraft/server/Services;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;">
<name type="intermediary" version="773,774,[0x40000107,0x4000011E]">method_54647</name> <!-- 25w34a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
</method>
<method name="load(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;">
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">method_52868</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/resources/SkinManager$CacheKey">
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">net/minecraft/class_1071$class_8686</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
</class>
<class name="net/minecraft/client/resources/SkinManager$SkinTextureCallback">
<name type="srg" version="[,404]">net/minecraft/client/resources/SkinManager$SkinAvailableCallback</name> <!-- 1.13.2- -->
<name type="srg" version="[485,754]">net/minecraft/client/resources/SkinManager$ISkinAvailableCallback</name> <!-- 1.14.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">net/minecraft/class_1071$class_1072</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
</class>
<class name="net/minecraft/client/resources/SkinManager$TextureCache">
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">net/minecraft/class_1071$class_8687</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
<field name="type">
<name type="srg" version="764,765">f_291290_</name> <!-- 1.20.2 ~ 1.20.4 -->
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">field_45641</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
</field>
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;">
<name type="srg" version="764,765">m_294542_</name> <!-- 1.20.2 ~ 1.20.4 -->
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">method_52873</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/client/resources/SkinManager$TextureInfo">
<name type="intermediary" version="764,[0x40000090,0x4000009C]">net/minecraft/class_1071$class_8688</name> <!-- 23w31a ~ 23w41a (1.20.2) -->
</class>
<class name="net/minecraft/client/resources/metadata/texture/TextureMetadataSection">
<name type="srg" version="[,754]">net/minecraft/client/resources/data/TextureMetadataSection</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1084</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/core/ClientAsset$DownloadedTexture">
<name type="intermediary" version="[765,774],[0x4000009C,0x4000011E]">net/minecraft/class_12079$class_12080</name> <!-- 23w41a ~ 1.21.11 (1.20.3 ~ 1.21.11) -->
</class>
<class name="net/minecraft/resources/Identifier">
<name type="srg" version="[,754]">net/minecraft/util/ResourceLocation</name> <!-- 1.16.5- -->
<name type="srg" version="[756,773]">net/minecraft/resources/ResourceLocation</name> <!-- 1.17.1 ~ 1.21.10 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_2960</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<name type="official" version="[764,773]">net/minecraft/resources/ResourceLocation</name> <!-- 1.20.2 ~ 1.21.10 -->
</class>
<class name="net/minecraft/server/Services">
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_7497</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/server/packs/resources/Resource">
<name type="srg" version="[,340]">net/minecraft/client/resources/IResource</name> <!-- 1.12.2- -->
<name type="srg" version="[404,754]">net/minecraft/resources/IResource</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3298</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="open()Ljava/io/InputStream;">
<name type="srg" version="[,754]">func_199027_b</name> <!-- 1.16.5- -->
<name type="srg" version="[756,758]">m_6679_</name> <!-- 1.17.1 ~ 1.18.2 -->
<name type="srg" version="[759,765]">m_215507_</name> <!-- 1.19 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_14482</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/server/packs/resources/ResourceManager">
<name type="srg" version="[,340]">net/minecraft/client/resources/IResourceManager</name> <!-- 1.12.2- -->
<name type="srg" version="[404,754]">net/minecraft/resources/IResourceManager</name> <!-- 1.13.2 ~ 1.16.5 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3300</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="getResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional;">
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14486</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
</method>
<method name="getResource(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/Resource;">
<name type="srg" version="[,754]">func_199002_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,758]">m_142591_</name> <!-- 1.17.1 ~ 1.18.2 -->
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14486</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
</method>
</class>
<class name="net/minecraft/util/StringUtil">
<name type="srg" version="[,754]">net/minecraft/util/StringUtils</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3544</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
<method name="stripColor(Ljava/lang/String;)Ljava/lang/String;">
<name type="srg" version="[,754]">func_76338_a</name> <!-- 1.16.5- -->
<name type="srg" version="[756,765]">m_14406_</name> <!-- 1.17.1 ~ 1.20.4 -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_15440</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</method>
</class>
<class name="net/minecraft/world/scores/Objective">
<name type="srg" version="[,754]">net/minecraft/scoreboard/ScoreObjective</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_266</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
<class name="net/minecraft/world/scores/Scoreboard">
<name type="srg" version="[,754]">net/minecraft/scoreboard/Scoreboard</name> <!-- 1.16.5- -->
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_269</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
</class>
</mapping>
+4
View File
@@ -0,0 +1,4 @@
manifestLibraries {
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.fabricmc.fabric-loader/${fabric_v1_version}.json"
}
@@ -0,0 +1,47 @@
package customskinloader.bootstrap.fabric.v1;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
public final class MixinConfigPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
TransformerBootstrap.initialize();
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
// This is the last stable point before postInitialise/validation, so reflected target injection is still visible downstream.
TransformerBootstrap.applyPendingMixinTargets(this);
}
@Override
public List<String> getMixins() {
return Collections.emptyList();
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
TransformerBootstrap.transformTargetClass(targetClassName, targetClass);
}
}
@@ -0,0 +1,187 @@
package customskinloader.bootstrap.fabric.v1;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.installer.CommonJarInstaller;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.impl.launch.FabricLauncherBase;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.asm.mixin.transformer.ClassInfo;
import org.spongepowered.asm.mixin.transformer.Config;
final class TransformerBootstrap {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "intermediary");
private static final Object LOCK = new Object();
private static final List<PendingMixinTarget> PENDING_MIXIN_TARGETS = new ArrayList<>();
private static final String DUMMY_MIXIN = "customskinloader.bootstrap.fabric.v1.mixin.DummyMixin";
private TransformerBootstrap() {
}
public static void initialize() {
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Fabric");
releaseRuntimeArtifacts();
int targetCount = 0;
for (String targetClassName : SUPPORT.collectTargetClassNames()) {
registerMixinTarget(DUMMY_MIXIN, targetClassName.replace('/', '.'));
targetCount++;
}
LOGGER.info("Initialized CustomSkinLoader Bootstrap for Fabric with " + targetCount + " reflected Mixin target(s)");
}
private static void releaseRuntimeArtifacts() {
try {
Path commonJar = CommonJarInstaller.releaseCommonJar(FabricLoader.getInstance().getGameDir(), "intermediary");
FabricLauncherBase.getLauncher().addToClassPath(commonJar, "customskinloader.");
LOGGER.info("Added CustomSkinLoader Common jar to Fabric class path: " + BootstrapLogger.formatPath(commonJar));
} catch (Exception exception) {
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
}
}
public static void registerMixinTarget(String mixinClassName, String targetClassName) {
synchronized (LOCK) {
PENDING_MIXIN_TARGETS.add(new PendingMixinTarget(mixinClassName, targetClassName));
LOGGER.debug("Queued Fabric Mixin target " + targetClassName + " for " + mixinClassName);
}
}
public static void applyPendingMixinTargets(IMixinConfigPlugin plugin) {
synchronized (LOCK) {
if (PENDING_MIXIN_TARGETS.isEmpty()) {
return;
}
try {
IMixinConfig mixinConfig = findOwningMixinConfig(plugin);
int appliedTargetCount = 0;
Iterator<PendingMixinTarget> iterator = PENDING_MIXIN_TARGETS.iterator();
while (iterator.hasNext()) {
PendingMixinTarget pendingTarget = iterator.next();
applyMixinTarget(mixinConfig, pendingTarget.mixinClassName, pendingTarget.targetClassName);
iterator.remove();
appliedTargetCount++;
}
LOGGER.info("Applied " + appliedTargetCount + " reflected Fabric Mixin target(s)");
} catch (ReflectiveOperationException exception) {
LOGGER.error("Failed to append reflected targets to the current Fabric mixin config", exception);
throw new IllegalStateException("Failed to append reflected targets to the current Fabric mixin config", exception);
}
}
}
public static void transformTargetClass(String targetClassName, ClassNode targetClass) {
ClassTransformationReport report = SUPPORT.transformClassNode(targetClassName, targetClass);
ClassNode transformedNode = report.getTransformedClassNode();
if (transformedNode != targetClass) {
TransformerBootstrapSupport.copyClassNode(transformedNode, targetClass);
}
if (report.isModified()) {
LOGGER.info("Transformed Fabric target " + targetClassName + " with " + report.getAppliedTransformerNames());
}
}
private static IMixinConfig findOwningMixinConfig(IMixinConfigPlugin plugin) throws ReflectiveOperationException {
Field allConfigsField = Config.class.getDeclaredField("allConfigs");
allConfigsField.setAccessible(true);
for (Object configHandle : ((Map<?, ?>) allConfigsField.get(null)).values()) {
IMixinConfig mixinConfig = ((Config) configHandle).getConfig();
if (mixinConfig.getPlugin() == plugin) {
return mixinConfig;
}
}
throw new IllegalStateException("Could not find the owning MixinConfig for " + plugin.getClass().getName());
}
@SuppressWarnings("unchecked")
private static void applyMixinTarget(IMixinConfig mixinConfig, String mixinClassName, String targetClassName) throws ReflectiveOperationException {
IMixinInfo mixinInfo = findMixinInfo(mixinConfig, mixinClassName);
String targetBinaryName = targetClassName.replace('/', '.');
String targetInternalName = targetClassName.replace('.', '/');
List<String> targetClassNames = (List<String>) getField(mixinInfo, "targetClassNames");
if (targetClassNames.contains(targetInternalName)) {
return;
}
ClassInfo targetClassInfo = ClassInfo.forName(targetInternalName);
if (targetClassInfo == null) {
throw new IllegalStateException("Could not resolve target ClassInfo for " + targetInternalName);
}
Method addMixin = ClassInfo.class.getDeclaredMethod("addMixin", Class.forName("org.spongepowered.asm.mixin.transformer.MixinInfo"));
addMixin.setAccessible(true);
addMixin.invoke(targetClassInfo, mixinInfo);
List<ClassInfo> targetClasses = (List<ClassInfo>) getField(mixinInfo, "targetClasses");
targetClasses.add(targetClassInfo);
targetClassNames.add(targetInternalName);
Map<String, List<Object>> mixinMapping = (Map<String, List<Object>>) getField(mixinConfig, "mixinMapping");
List<Object> mappedMixins = mixinMapping.computeIfAbsent(targetBinaryName, k -> new ArrayList<>());
if (!mappedMixins.contains(mixinInfo)) {
mappedMixins.add(mixinInfo);
}
((Set<String>) getField(mixinConfig, "unhandledTargets")).add(targetBinaryName);
}
@SuppressWarnings("unchecked")
private static IMixinInfo findMixinInfo(IMixinConfig mixinConfig, String mixinClassName) throws ReflectiveOperationException {
for (IMixinInfo mixinInfo : (List<IMixinInfo>) getField(mixinConfig, "mixins")) {
String currentMixinName = mixinInfo.getClassName();
if (mixinClassName.equals(currentMixinName)) {
return mixinInfo;
}
}
throw new IllegalStateException("Could not find mixin " + mixinClassName + " in the current config");
}
private static Object getField(Object instance, String fieldName) throws ReflectiveOperationException {
Field field = findField(instance.getClass(), fieldName);
field.setAccessible(true);
return field.get(instance);
}
private static Field findField(Class<?> type, String fieldName) throws NoSuchFieldException {
Class<?> currentType = type;
while (currentType != null) {
try {
return currentType.getDeclaredField(fieldName);
} catch (NoSuchFieldException exception) {
currentType = currentType.getSuperclass();
}
}
throw new NoSuchFieldException(fieldName);
}
private static final class PendingMixinTarget {
private final String mixinClassName;
private final String targetClassName;
private PendingMixinTarget(String mixinClassName, String targetClassName) {
this.mixinClassName = mixinClassName;
this.targetClassName = targetClassName;
}
}
}
@@ -0,0 +1,9 @@
package customskinloader.bootstrap.fabric.v1.mixin;
import org.spongepowered.asm.mixin.Mixin;
// This placeholder mixin exists solely to provide a stable MixinInfo that we can retarget reflectively.
@Mixin(targets = "net.minecraft.client.main.Main")
public abstract class DummyMixin {
}
@@ -0,0 +1,12 @@
{
"required": true,
"package": "customskinloader.bootstrap.fabric.v1.mixin",
"plugin": "customskinloader.bootstrap.fabric.v1.MixinConfigPlugin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"DummyMixin"
],
"injectors": {
"defaultRequire": 1
}
}
@@ -0,0 +1,20 @@
{
"schemaVersion": 1,
"id": "customskinloader-bootstrap",
"version": "${modFullVersion}",
"name": "CustomSkinLoader Bootstrap",
"description": "Custom Skin Loader for Minecraft",
"authors": ["xfl03", "JLChnToZ", "ZekerZhayard"],
"contact": {
"homepage": "https://github.com/xfl03/MCCustomSkinLoader",
"issues": "https://github.com/xfl03/MCCustomSkinLoader/issues",
"sources": "https://github.com/xfl03/MCCustomSkinLoader"
},
"license": "GPL-3.0-only",
"environment": "client",
"mixins": [
"customskinloader.bootstrap.fabric.v1.mixins.json"
]
}
+4
View File
@@ -0,0 +1,4 @@
manifestLibraries {
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraftforge/${forge_v1_version}.json"
}
@@ -0,0 +1,17 @@
package customskinloader.bootstrap.forge.v1;
import java.util.Map;
import net.minecraftforge.fml.relauncher.IFMLCallHook;
public class CallHook implements IFMLCallHook {
@Override
public void injectData(Map<String, Object> data) {
TransformerBootstrap.injectData(data);
}
@Override
public Void call() {
return null;
}
}
@@ -0,0 +1,15 @@
package customskinloader.bootstrap.forge.v1;
import net.minecraft.launchwrapper.IClassTransformer;
public final class ClassTransformerAdapter implements IClassTransformer {
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
if (basicClass == null) {
return null;
}
String className = transformedName != null && !transformedName.isEmpty() ? transformedName : name;
return TransformerBootstrap.transform(className.replace('.', '/'), basicClass);
}
}
@@ -1,14 +1,16 @@
package customskinloader.forge;
import java.util.Map;
package customskinloader.bootstrap.forge.v1;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
public class ForgePlugin implements IFMLLoadingPlugin {
import java.util.Map;
@IFMLLoadingPlugin.Name("CustomSkinLoaderBootstrap")
@IFMLLoadingPlugin.SortingIndex(1010)
@IFMLLoadingPlugin.TransformerExclusions("customskinloader.bootstrap.")
public final class LoadingPlugin implements IFMLLoadingPlugin {
@Override
public String[] getASMTransformerClass() {
return new String[] {TransformerManager.class.getName()};
return new String[] { "customskinloader.bootstrap.forge.v1.ClassTransformerAdapter" };
}
@Override
@@ -18,16 +20,16 @@ public class ForgePlugin implements IFMLLoadingPlugin {
@Override
public String getSetupClass() {
return null;
return "customskinloader.bootstrap.forge.v1.CallHook";
}
@Override
public void injectData(Map<String, Object> data) {
}
@Override
public String getAccessTransformerClass() {
return null;
}
}
}
@@ -0,0 +1,68 @@
package customskinloader.bootstrap.forge.v1;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.installer.CommonJarInstaller;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
final class TransformerBootstrap {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "srg");
private TransformerBootstrap() {
}
public static void injectData(Map<String, Object> data) {
try {
Path runtimeDirectory = resolveRuntimeDirectory(data);
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Forge v1 in " + BootstrapLogger.formatPath(runtimeDirectory));
Path commonJar = CommonJarInstaller.releaseCommonJar(runtimeDirectory, "srg");
resolveLaunchClassLoader(data).addURL(commonJar.toUri().toURL());
LOGGER.info("Added CustomSkinLoader Common jar to LaunchClassLoader: " + BootstrapLogger.formatPath(commonJar));
} catch (Exception exception) {
LOGGER.error("Failed to prepare CustomSkinLoader runtime jars", exception);
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime jars", exception);
}
}
public static byte[] transform(String className, byte[] classBytecode) {
SUPPORT.ensureTransformersLoaded();
if (!SUPPORT.hasApplicableTransformers(className)) {
return classBytecode;
}
ClassNode classNode = TransformerBootstrapSupport.toClassNode(classBytecode);
ClassTransformationReport report = SUPPORT.transformClassNode(className, classNode);
if (report.isModified()) {
LOGGER.info("Transformed Forge v1 target " + className + " with " + report.getAppliedTransformerNames());
}
return report.isModified() ? report.getTransformedBytecode() : classBytecode;
}
private static Path resolveRuntimeDirectory(Map<String, Object> data) {
Object mcLocation = data.get("mcLocation");
if (mcLocation instanceof File) {
return ((File) mcLocation).toPath();
}
return Paths.get(".");
}
private static LaunchClassLoader resolveLaunchClassLoader(Map<String, Object> data) {
Object classLoader = data.get("classLoader");
if (classLoader instanceof LaunchClassLoader) {
return (LaunchClassLoader) classLoader;
}
throw new IllegalStateException("Forge did not provide a LaunchClassLoader in injectData");
}
}
+4
View File
@@ -0,0 +1,4 @@
manifestLibraries {
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraftforge/${forge_v2_version}.json"
}
@@ -0,0 +1,17 @@
package customskinloader.bootstrap.forge.v2;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator;
import customskinloader.bootstrap.util.ModLocatorUtils;
public final class CommonModLocator extends ModsFolderLocator {
public CommonModLocator() {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "srg");
}
@Override
public String name() {
return ModLocatorUtils.LOCATOR_NAME;
}
}
@@ -0,0 +1,61 @@
package customskinloader.bootstrap.forge.v2;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Set;
import cpw.mods.modlauncher.api.IEnvironment;
import cpw.mods.modlauncher.api.ITransformationService;
import cpw.mods.modlauncher.api.ITransformer;
import customskinloader.bootstrap.BootstrapLogger;
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
import org.apache.logging.log4j.Logger;
public final class TransformationService implements ITransformationService {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
@Override
public String name() {
return "customskinloader-bootstrap";
}
@Override
public void initialize(IEnvironment environment) {
LOGGER.info("Initializing CustomSkinLoader Bootstrap transformation service");
try {
List<Path> extraLocators = ModDirTransformerDiscoverer.getExtraLocators();
Path servicePath = Paths.get(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath().normalize();
if (!extraLocators.contains(servicePath)) {
extraLocators.add(servicePath);
LOGGER.info("Registered CustomSkinLoader Bootstrap service path as Forge extra locator: " + BootstrapLogger.formatPath(servicePath));
}
} catch (NoSuchMethodError e) { // 1.13.2-25.0.216 ~ 1.14.4-28.1.64
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
LOGGER.info("Using context ClassLoader fallback for legacy Forge transformation discovery");
} catch (NoClassDefFoundError ignored) { // NeoForge
LOGGER.debug("Skipping Forge ModDirTransformerDiscoverer setup on NeoForge");
} catch (URISyntaxException e) {
LOGGER.error("Unable to resolve CustomSkinLoader bootstrap service path", e);
throw new IllegalStateException("Unable to resolve CustomSkinLoader bootstrap service path", e);
}
}
@Override
public void beginScanning(IEnvironment environment) {
}
@Override
public void onLoad(IEnvironment environment, Set<String> otherServices) {
LOGGER.info("Loaded CustomSkinLoader Bootstrap transformation service with " + otherServices.size() + " other service(s)");
}
@Override
public List<ITransformer> transformers() {
List<ITransformer> transformers = TransformerBootstrap.buildTransformers();
LOGGER.info("Provided " + transformers.size() + " CustomSkinLoader ModLauncher transformer(s)");
return transformers;
}
}
@@ -0,0 +1,85 @@
package customskinloader.bootstrap.forge.v2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.ITransformer;
import cpw.mods.modlauncher.api.ITransformerVotingContext;
import cpw.mods.modlauncher.api.TransformerVoteResult;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
final class TransformerBootstrap {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class,
Launcher.INSTANCE.environment().findLaunchHandler("forgeclient")
.map(handle -> handle.getClass().getName().startsWith("net.neoforged.")).orElse(false) ? "official" : "srg");
private TransformerBootstrap() {
}
public static List<ITransformer> buildTransformers() {
List<ITransformer> transformers = new ArrayList<>();
for (String targetClassName : SUPPORT.collectTargetClassNames()) {
transformers.add(new ModLauncherClassTransformer(targetClassName));
LOGGER.debug("Created ModLauncher transformer for " + targetClassName);
}
return Collections.unmodifiableList(transformers);
}
private static ClassNode transformClassNode(String internalClassName, ClassNode inputClassNode) {
ClassTransformationReport report = SUPPORT.transformClassNode(internalClassName, inputClassNode);
if (!report.isModified() || report.getTransformedClassNode() == null) {
return inputClassNode;
}
LOGGER.info("Transformed ModLauncher target " + internalClassName + " with " + report.getAppliedTransformerNames());
return report.getTransformedClassNode();
}
private static final class ModLauncherClassTransformer implements ITransformer<ClassNode> {
private final String targetClassName;
private final Set<ITransformer.Target> targets;
private ModLauncherClassTransformer(String targetClassName) {
this.targetClassName = targetClassName;
Set<ITransformer.Target> transformerTargets = new LinkedHashSet<>();
transformerTargets.add(ITransformer.Target.targetClass(targetClassName));
this.targets = Collections.unmodifiableSet(transformerTargets);
}
@Override
public ClassNode transform(ClassNode input, ITransformerVotingContext context) {
return transformClassNode(this.targetClassName, input);
}
@Override
public TransformerVoteResult castVote(ITransformerVotingContext context) {
return TransformerVoteResult.YES;
}
@Override
public Set<ITransformer.Target> targets() {
return this.targets;
}
// NeoForge
public cpw.mods.modlauncher.api.TargetType getTargetType() {
return cpw.mods.modlauncher.api.TargetType.CLASS;
}
@Override
public String[] labels() {
return new String[] {"customskinloader:" + this.targetClassName.replace('/', '.')};
}
}
}
@@ -0,0 +1 @@
customskinloader.bootstrap.forge.v2.TransformationService
@@ -0,0 +1 @@
customskinloader.bootstrap.forge.v2.CommonModLocator
@@ -0,0 +1 @@
customskinloader.bootstrap.forge.v2.CommonModLocator
+4
View File
@@ -0,0 +1,4 @@
manifestLibraries {
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.neoforged/${neoforge_v1_version}.json"
}
@@ -0,0 +1,15 @@
package customskinloader.bootstrap.neoforge.v1;
import customskinloader.bootstrap.util.ModLocatorUtils;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.fml.loading.moddiscovery.ModsFolderLocator;
public final class CommonModLocator extends ModsFolderLocator {
public CommonModLocator() {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
}
public String name() {
return ModLocatorUtils.LOCATOR_NAME;
}
}
@@ -0,0 +1 @@
customskinloader.bootstrap.neoforge.v1.CommonModLocator
+4
View File
@@ -0,0 +1,4 @@
manifestLibraries {
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.neoforged/${neoforge_v2_version}.json"
}
@@ -0,0 +1,16 @@
package customskinloader.bootstrap.neoforge.v2;
import customskinloader.bootstrap.BootstrapLogger;
import net.neoforged.neoforgespi.transformation.ClassProcessorProvider;
import org.apache.logging.log4j.Logger;
public final class ClassProcessorProviderImpl implements ClassProcessorProvider {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
@Override
public void createProcessors(Context context, Collector collector) {
// Always register the bridge processor so late transformer registrations can still be observed.
LOGGER.info("Registering CustomSkinLoader Bootstrap NeoForge class processor");
collector.add(TransformerBootstrap.createProcessor());
}
}
@@ -0,0 +1,15 @@
package customskinloader.bootstrap.neoforge.v2;
import customskinloader.bootstrap.util.ModLocatorUtils;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.fml.loading.moddiscovery.locators.ModsFolderLocator;
public final class CommonModLocator extends ModsFolderLocator {
public CommonModLocator() {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
}
public String name() {
return ModLocatorUtils.LOCATOR_NAME;
}
}
@@ -0,0 +1,72 @@
package customskinloader.bootstrap.neoforge.v2;
import java.util.Collections;
import java.util.Set;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import net.neoforged.neoforgespi.transformation.ClassProcessor;
import net.neoforged.neoforgespi.transformation.ClassProcessorIds;
import net.neoforged.neoforgespi.transformation.ProcessorName;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
final class TransformerBootstrap {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "official");
private static final ProcessorName PROCESSOR_NAME = new ProcessorName("customskinloader", "bootstrap");
private TransformerBootstrap() {
}
public static ClassProcessor createProcessor() {
SUPPORT.ensureTransformersLoaded();
LOGGER.info("Created CustomSkinLoader Bootstrap NeoForge class processor");
return new BootstrapClassProcessor();
}
private static ClassTransformationReport transformClassNode(String internalClassName, ClassNode inputClassNode) {
return SUPPORT.transformClassNode(internalClassName, inputClassNode);
}
private static final class BootstrapClassProcessor implements ClassProcessor {
@Override
public ProcessorName name() {
return PROCESSOR_NAME;
}
@Override
public Set<ProcessorName> runsAfter() {
// Run after the default simple-processor group so the shared framework sees post-Mixin bytecode.
return Collections.singleton(ClassProcessorIds.SIMPLE_PROCESSORS_GROUP);
}
@Override
public boolean handlesClass(SelectionContext context) {
// The shared framework currently targets concrete classes only, so we skip synthetic empty definitions.
return !context.empty() && SUPPORT.hasApplicableTransformers(context.type().getInternalName());
}
@Override
public ComputeFlags processClass(TransformationContext context) {
ClassTransformationReport report = transformClassNode(context.type().getInternalName(), context.node());
if (!report.isModified()) {
return ComputeFlags.NO_REWRITE;
}
TransformerBootstrapSupport.copyClassNode(report.getTransformedClassNode(), context.node());
for (String transformerName : report.getAppliedTransformerNames()) {
context.audit("customskinloader.bootstrap", transformerName);
}
LOGGER.info("Transformed NeoForge target " + context.type().getInternalName() + " with " + report.getAppliedTransformerNames());
return ComputeFlags.COMPUTE_FRAMES;
}
@Override
public OrderingHint orderingHint() {
return OrderingHint.LATE;
}
}
}
@@ -0,0 +1 @@
customskinloader.bootstrap.neoforge.v2.CommonModLocator
@@ -0,0 +1 @@
customskinloader.bootstrap.neoforge.v2.ClassProcessorProviderImpl
+48
View File
@@ -0,0 +1,48 @@
def bootstrapCoreProject = project(':Bootstrap:Core')
def commonJarTask = project(':Common').tasks.named('jar')
subprojects {
dependencies {
compileOnly project(':Dummy:Bootstrap')
if (project != bootstrapCoreProject) compileOnly bootstrapCoreProject
}
}
jar {
archiveBaseName = rootProject.ext.releaseArchiveBaseName
archiveVersion = rootProject.ext.modFullVersion
manifest {
attributes(
"Automatic-Module-Name" : "customskinloader.bootstrap",
"Specification-Title" : "CustomSkinLoader",
"Specification-Vendor" : "xfl03",
"Specification-Version" : "1",
"Implementation-Title" : "CustomSkinLoader",
"Implementation-Version" : rootProject.ext.modFullVersion,
"Implementation-Vendor" : "xfl03",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"FMLCorePlugin" : "customskinloader.bootstrap.forge.v1.LoadingPlugin"
)
}
// Build child module outputs before bundling them into the Bootstrap artifact.
dependsOn subprojects.collect { bundledProject ->
bundledProject.tasks.named('classes')
}
dependsOn commonJarTask
// Package all leaf child module outputs into the Bootstrap jar.
from({
subprojects.collect { bundledProject ->
bundledProject.sourceSets.main.output
}
})
into('META-INF/jar-jar') {
// Bundle the runtime payload with Bridge so Bridge owns releasing the Universal jar.
from(commonJarTask.flatMap { it.archiveFile })
rename { 'CustomSkinLoader-Common.jar' }
}
}
+103
View File
@@ -0,0 +1,103 @@
# Contributing to CustomSkinLoader Universal
Thanks for helping improve CustomSkinLoader. This branch is the Universal generation: one installable Bootstrap jar carries the shared Common runtime, remaps it for the active Minecraft mapping namespace, and applies loader-specific patches at launch time. A successful Java compile is useful, but changes that touch runtime loading, mappings, or transformers also need in-game verification.
## Requirements
- Git.
- A Java 25 JDK. Set `JAVA_HOME` if Java 25 is not the default `java` on your `PATH`.
- The Gradle wrapper from this repository.
- Local Minecraft test instances for the loaders and versions affected by your change.
The build uses Java 25 tooling, while project sources are compiled for Java 8 compatibility unless a module explicitly provides multi-release sources such as `Common/src/main/java21`.
## Build
Use the wrapper instead of a system Gradle installation.
Windows:
```powershell
.\gradlew.bat clean build --stacktrace
```
Linux/macOS:
```bash
./gradlew clean build --stacktrace
```
The user-facing mod artifact is:
```text
Bootstrap/build/libs/CustomSkinLoader_Universal-<version>.jar
```
`Common/build/libs/Common-<version>.jar` is bundled into the Universal jar as `META-INF/jar-jar/CustomSkinLoader-Common.jar`. Do not publish or ask users to install the Common jar directly.
## Project Layout
- `Common`: shared CustomSkinLoader runtime, configuration, skin API loaders, cache, logging, and texture utilities.
- `Common/src/main/java21`: Java 21+ multi-release overrides for runtime behavior that benefits from newer JVM APIs.
- `Bootstrap`: assembles the installable Universal jar.
- `Bootstrap/Core`: runtime installer, remapper, mapping reader, transformer registry, and shared patch logic.
- `Bootstrap/FabricV1`: Fabric and Quilt-compatible bootstrap integration.
- `Bootstrap/ForgeV1`: legacy Forge coremod bootstrap.
- `Bootstrap/ForgeV2`: Forge ModLauncher bootstrap.
- `Bootstrap/NeoForgeV1` and `Bootstrap/NeoForgeV2`: NeoForge discovery and transformation bootstrap.
- `Dummy/Bootstrap` and `Dummy/Common`: compile-time stubs for Minecraft and loader APIs. Keep these minimal; they are not runtime implementations.
- `buildSrc`: local Gradle plugin code, including manifest library resolution from launcher metadata.
- `.github/workflows` and `.github/scripts`: CI, release, metadata, and publishing automation.
## Development Guidelines
- Keep changes scoped to the loader, mapping range, API loader, or Common behavior being modified.
- Preserve compatibility across the supported Minecraft and loader matrix unless the change is intentionally narrowing support.
- Prefer small, explicit compatibility branches over broad reflection or version checks when the affected API surface is known.
- Treat `Bootstrap/Core/src/main/resources/customskinloader/mapping.xml` and transformer patches as runtime-critical code. Document why a mapping range or target class changed.
- Do not edit generated Gradle output under `build/`, `.gradle/`, IDE metadata, or files generated by a local Minecraft test run.
- Keep `Dummy` classes limited to the members needed for compilation. Runtime behavior belongs in `Common` or `Bootstrap`, not in stubs.
- Update `README.md`, issue templates, or release metadata when a user-visible feature, supported loader, supported version, or install path changes.
- Follow the existing Java style in nearby files. The codebase intentionally avoids adding large abstractions where a focused compatibility patch is clearer.
## Testing Checklist
Before opening a pull request, run the relevant parts of this checklist:
1. Run `.\gradlew.bat clean build --stacktrace` on Windows, or `./gradlew clean build --stacktrace` on Linux/macOS.
2. Install only `Bootstrap/build/libs/CustomSkinLoader_Universal-<version>.jar` into a clean Minecraft instance.
3. If you changed `Common`, confirm the runtime payload is regenerated under `.minecraft/CustomSkinLoader/Core/CustomSkinLoader-Common.jar`.
4. If you changed `Bootstrap`, mappings, service descriptors, or transformer patches, test at least one Forge or NeoForge instance and one Fabric or Quilt-compatible instance.
5. If you changed a version range or mapping entry, test the oldest and newest Minecraft versions covered by that range.
6. Check `.minecraft/CustomSkinLoader/CustomSkinLoader.log` for loader, remapper, transformer, and skin loading errors.
7. For skin API, cache, or network changes, test a normal online profile and a cache/local-profile fallback path when possible.
There is currently no standalone test suite that replaces in-game compatibility testing.
## Pull Requests
Please include:
- A short summary of the behavior change.
- The Minecraft versions and loaders you tested.
- Any relevant `CustomSkinLoader.log` snippets for bootstrap, remapping, or skin loading issues.
- Screenshots or reproduction steps for visible texture/rendering fixes.
- Notes about compatibility risk when changing mappings, ASM patches, service descriptors, or build packaging.
Keep pull requests focused. If a cleanup is unrelated to the bug or feature, send it separately so compatibility regressions are easier to review.
## CI and Publishing
Pull requests run the shared GitHub Actions build on `windows-latest` with PowerShell and Java 25. This is a CI choice; local builds should remain portable across Windows, Linux, and macOS.
Publishing jobs generate the Universal jar plus metadata files from `gradle.properties`. Beta builds publish moving beta metadata, release builds publish release metadata and upload to distribution platforms. Object-storage upload is optional and is skipped when the required secrets are not configured.
To generate publish metadata locally without uploading, first build the project, then run:
```powershell
.\.github\scripts\publish-artifacts.ps1 -Channel Beta -LatestJsonName latest-beta.json -DetailJsonName detail-beta.json -SkipObjectStorage
```
## License
By contributing, you agree that your contribution will be distributed under the repository license. Source code is licensed under GPL-3.0-only; see `LICENSE`.
+27
View File
@@ -0,0 +1,27 @@
dependencies {
compileOnly project(':Dummy:Common')
}
sourceSets {
java21 {
java.srcDir('src/main/java21')
compileClasspath += sourceSets.main.output
}
}
tasks.named(sourceSets.java21.compileJavaTaskName, JavaCompile) {
dependsOn tasks.named('compileJava')
}
jar {
dependsOn tasks.named(sourceSets.java21.classesTaskName)
manifest {
attributes('Multi-Release': 'true')
}
into('META-INF/versions/21') {
from(sourceSets.java21.output)
}
}
-10
View File
@@ -1,10 +0,0 @@
{
"name": "CustomSkinLoader",
"version": "${modVersion}",
"fullVersion": "${modFullVersion}",
"mcVersion": "${mcVersion}",
"mcFullVersions": "${mcFullVersions}",
"forgeVersion": "${forgeVersion}",
"gitVersion": "${gitVersion}",
"buildUrl": "${buildUrl}"
}
@@ -1,178 +0,0 @@
package customskinloader;
import java.io.File;
import java.util.Map;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import customskinloader.config.Config;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.*;
import customskinloader.profile.DynamicSkullManager;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.ProfileCache;
import customskinloader.profile.UserProfile;
import customskinloader.utils.MinecraftUtil;
/**
* Custom skin loader mod for Minecraft.
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2018
* @version @MOD_FULL_VERSION@
*/
public class CustomSkinLoader {
public static final String CustomSkinLoader_VERSION="@MOD_VERSION@";
public static final String CustomSkinLoader_FULL_VERSION="@MOD_FULL_VERSION@";
public static final File DATA_DIR=new File(MinecraftUtil.getMinecraftDataDir(),"CustomSkinLoader"),
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
SkinSiteProfile.createMojangAPI("Mojang"),
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://littleskin.cn/"),
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
//OneSkin has been removed temporarily
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
//Minecrack could not load skin correctly
//SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null),
SkinSiteProfile.createElyByAPI("ElyBy"),
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")};
public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create();
public static final Logger logger=initLogger();
public static final Config config=Config.loadConfig0();
private static final ProfileCache profileCache=new ProfileCache();
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
//For User Skin
public static Map<Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile){
String username=gameProfile.getName();
String credential=MinecraftUtil.getCredential(gameProfile);
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
if(username==null){
logger.warning("Could not load profile: username is null.");
return Maps.newHashMap();
}
String tempName=Thread.currentThread().getName();
Thread.currentThread().setName(username);//Change Thread Name
UserProfile profile;
if(profileCache.isReady(credential)){
logger.info("Cached profile will be used.");
profile=profileCache.getProfile(credential);
if(profile==null){
logger.warning("(!Cached Profile is empty!) Expiry:"+profileCache.getExpiry(credential));
if(profileCache.isExpired(credential))//force load
profile=loadProfile0(gameProfile);
}
else
logger.info(profile.toString(profileCache.getExpiry(credential)));
}else{
profileCache.setLoading(credential, true);
profile=loadProfile0(gameProfile);
}
Thread.currentThread().setName(tempName);
return ModelManager0.fromUserProfile(profile);
}
//Core
public static UserProfile loadProfile0(GameProfile gameProfile){
String username=gameProfile.getName();
String credential=MinecraftUtil.getCredential(gameProfile);
profileCache.setLoading(credential, true);
logger.info("Loading "+username+"'s profile.");
if(config.loadlist==null||config.loadlist.isEmpty()){
logger.info("LoadList is Empty.");
return null;
}
UserProfile profile0=new UserProfile();
for(int i=0;i<config.loadlist.size();i++){
SkinSiteProfile ssp=config.loadlist.get(i);
logger.info((i+1)+"/"+config.loadlist.size()+" Try to load profile from '"+ssp.name+"'.");
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if(loader==null){
logger.info("Type '"+ssp.type+"' is not defined.");
continue;
}
UserProfile profile=null;
try{
profile=loader.loadProfile(ssp, gameProfile);
}catch(Exception e){
logger.warning("Exception occurs while loading.");
logger.warning(e);
if(e.getCause()!=null) {
logger.warning("Caused By:");
logger.warning(e.getCause());
}
}
if(profile==null)
continue;
if(!config.forceLoadAllTextures){
profile0=profile;
break;
}
profile0.mix(profile);
if(profile0.isFull())
break;
}
if(!profile0.isEmpty()){
logger.info(username+"'s profile loaded.");
profileCache.updateCache(credential, profile0);
profileCache.setLoading(credential, false);
logger.info(profile0.toString(profileCache.getExpiry(credential)));
return profile0;
}
logger.info(username+"'s profile not found in load list.");
if(config.enableLocalProfileCache){
UserProfile profile=profileCache.getLocalProfile(credential);
if(profile==null)
logger.info(username+"'s LocalProfile not found.");
else{
profileCache.updateCache(credential, profile, false);
profileCache.setLoading(credential, false);
logger.info(username+"'s LocalProfile will be used.");
logger.info(profile.toString(profileCache.getExpiry(credential)));
return profile;
}
}
profileCache.setLoading(credential, false);
return null;
}
//For Skull
public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
String username=gameProfile.getName();
String credential=MinecraftUtil.getCredential(gameProfile);
if(username == null || credential == null)
return dynamicSkullManager.getTexture(gameProfile);
if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){
UserProfile profile=profileCache.getProfile(credential);
return ModelManager0.fromUserProfile(profile);
}
//profileCache.setLoading(username, true);
Thread loadThread=new Thread(){
public void run(){
loadProfile0(gameProfile);//Load in thread
}
};
loadThread.setName(username+"'s skull");
loadThread.start();
return Maps.newHashMap();
}
private static Logger initLogger() {
Logger logger=new Logger(LOG_FILE);
logger.info("CustomSkinLoader "+CustomSkinLoader_FULL_VERSION);
logger.info("DataDir: "+DATA_DIR.getAbsolutePath());
logger.info("Minecraft: "+MinecraftUtil.getMinecraftMainVersion()+"("+MinecraftUtil.getMinecraftVersionText()+")");
return logger;
}
}
-101
View File
@@ -1,101 +0,0 @@
package customskinloader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Logger {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public enum Level{
DEBUG("DEBUG",false),
INFO("INFO",true),
WARNING("WARNING",true);
String name;
boolean display;
Level(String name,boolean display){
this.name=name;
this.display=display;
}
public String getName(){
return name;
}
public boolean display(){
return display;
}
}
private BufferedWriter writer=null;
public Logger(){
//Logger isn't created.
}
public Logger(String logFile) {
this(new File(logFile));
}
public Logger(File logFile){
try {
if(!logFile.getParentFile().exists()){
logFile.getParentFile().mkdirs();
}
if(!logFile.exists())
logFile.createNewFile();
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(logFile), "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
}
public void close(){
if(writer!=null){
try {
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void log(Level level,String msg){
if(!level.display()&&writer==null)
return;
String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
if(level.display())
System.out.println(sb);
if(writer==null)
return;
try {
String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
writer.write(sb2);
writer.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
public void debug(String msg){
log(Level.DEBUG,msg);
}
public void info(String msg){
log(Level.INFO,msg);
}
public void info(String format, Object... objs){
info(String.format(format, objs));
}
public void warning(String msg){
log(Level.WARNING,msg);
}
public void warning(String format, Object... objs){
warning(String.format(format, objs));
}
public void warning(Throwable e){
log(Level.WARNING,"Exception: "+e.toString());
StackTraceElement[] stes=e.getStackTrace();
for(StackTraceElement ste : stes){
log(Level.WARNING,ste.toString());
}
}
}
@@ -1,195 +0,0 @@
package customskinloader.config;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.FileUtils;
import customskinloader.CustomSkinLoader;
import customskinloader.loader.ProfileLoader;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Config {
//Program
public String version;
public List<SkinSiteProfile> loadlist;
//Function
public boolean enableDynamicSkull=true;
public boolean enableTransparentSkin=true;
public boolean ignoreHttpsCertificate=false;
public boolean forceLoadAllTextures=false;
//Cache
public int cacheExpiry=30;
public boolean enableUpdateSkull=false;
public boolean enableLocalProfileCache=false;
public boolean enableCacheAutoClean=false;
//Init config
public Config(SkinSiteProfile[] loadlist){
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
this.loadlist=Arrays.asList(loadlist);
}
public static Config loadConfig0() {
Config config=loadConfig();
//LoadList null checker
if(config.loadlist==null){
config.loadlist=new ArrayList<SkinSiteProfile>();
}else{
for(int i=0;i<config.loadlist.size();i++){
if(config.loadlist.get(i)==null)
config.loadlist.remove(i--);
}
}
//Init program
config.loadExtraList();
config.initLocalFolder();
if(config.ignoreHttpsCertificate)
HttpUtil0.ignoreHttpsCertificate();
if(config.enableCacheAutoClean && !config.enableLocalProfileCache){
try{
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
CustomSkinLoader.logger.info("Successfully cleaned cache.");
}catch(Exception e){
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: "+e.toString());
}
}
//Output config
CustomSkinLoader.logger.info("EnableDynamicSkull:"+config.enableDynamicSkull+
", EnableTranSkin:"+config.enableTransparentSkin+
", IgnoreHttpsCertificate:"+config.ignoreHttpsCertificate+
", CacheExpiry:"+config.cacheExpiry+
", EnableUpdateSkull:"+config.enableUpdateSkull+
", EnableLocalProfileCache:"+config.enableLocalProfileCache+
", EnableCacheAutoClean:"+config.enableCacheAutoClean+
", LoadList:"+(config.loadlist==null?0:config.loadlist.size()));
//Check config version
float floatVersion=0f;
float configVersion=0f;
try{
floatVersion=Float.parseFloat(CustomSkinLoader.CustomSkinLoader_VERSION);
configVersion=Float.parseFloat(config.version);
if(configVersion==15.1f)//To avoid some bug
configVersion=14.6f;
}catch (Exception e){
CustomSkinLoader.logger.warning("Exception occurs while parsing version: "+e.toString());
}
if(config.version==null || configVersion==0f || floatVersion > configVersion){
CustomSkinLoader.logger.info("Config File is out of date: "+config.version);
config.version=CustomSkinLoader.CustomSkinLoader_VERSION;
writeConfig(config,true);
}
return config;
}
private static Config loadConfig() {
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
if(!CustomSkinLoader.CONFIG_FILE.exists()){
CustomSkinLoader.logger.info("Config file not found, use default instead.");
return initConfig();
}
try {
CustomSkinLoader.logger.info("Try to load config.");
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
CustomSkinLoader.logger.info("Successfully load config.");
return config;
}catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json");
if(brokenFile.exists())
brokenFile.delete();
CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile);
return initConfig();
}
}
private void loadExtraList(){
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
if(!listAddition.isDirectory()){
listAddition.mkdirs();
return;
}
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
File[] files=listAddition.listFiles();
for(File file: files != null ? files : new File[0]){
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
continue;
try {
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
String json=FileUtils.readFileToString(file, "UTF-8");
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
CustomSkinLoader.logger.info("Successfully load Extra List.");
file.delete();
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if(loader==null){
CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined.");
continue;
}
boolean duplicate=false;
for(SkinSiteProfile ssp0:this.loadlist){
if(!ssp0.type.equalsIgnoreCase(ssp.type))
continue;
if(loader.compare(ssp0, ssp)){
duplicate=true;
break;
}
}
if(!duplicate){
adds.add(ssp);
CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")");
}else{
CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")");
}
}catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
}
}
if(adds.size()!=0){
adds.addAll(this.loadlist);
this.loadlist=adds;
writeConfig(this,true);
}
}
private void initLocalFolder(){
for(SkinSiteProfile ssp:this.loadlist){
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if(loader==null)
continue;
loader.initLocalFolder(ssp);
}
}
private static Config initConfig() {
Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST);
writeConfig(config,false);
return config;
}
private static void writeConfig(Config config,boolean update){
String json=CustomSkinLoader.GSON.toJson(config);
if(CustomSkinLoader.CONFIG_FILE.exists())
CustomSkinLoader.CONFIG_FILE.delete();
try {
CustomSkinLoader.CONFIG_FILE.createNewFile();
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
} catch (Exception e) {
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
}
}
}
@@ -1,65 +0,0 @@
package customskinloader.config;
import customskinloader.loader.jsonapi.CustomSkinAPIPlus.CustomSkinAPIPlusPrivacy;
public class SkinSiteProfile {
public String name;
public String type;
public String userAgent;
public String root;
public CustomSkinAPIPlusPrivacy privacy;
public Boolean checkPNG;//Not suitable for local skin
public String skin;
public String model;
public String cape;
public String elytra;
public static SkinSiteProfile createMojangAPI(String name){
SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name;
ssp.type="MojangAPI";
return ssp;
}
public static SkinSiteProfile createCustomSkinAPI(String name,String root){
SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name;
ssp.type="CustomSkinAPI";
ssp.root=root;
return ssp;
}
public static SkinSiteProfile creatCustomSkinAPIPlus(String name,String root){
SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name;
ssp.type="CustomSkinAPIPlus";
ssp.root=root;
ssp.privacy=new CustomSkinAPIPlusPrivacy();
return ssp;
}
public static SkinSiteProfile createUniSkinAPI(String name,String root){
SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name;
ssp.type="UniSkinAPI";
ssp.root=root;
return ssp;
}
public static SkinSiteProfile createLegacy(String name,String skin,String cape,String elytra){
SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name;
ssp.type="Legacy";
ssp.checkPNG=false;
ssp.skin=skin;
ssp.model="default";
ssp.cape=cape;
ssp.elytra=elytra;
return ssp;
}
public static SkinSiteProfile createElyByAPI(String name) {
SkinSiteProfile ssp = new SkinSiteProfile();
ssp.name = name;
ssp.type = "ElyByAPI";
return ssp;
}
}
@@ -1,87 +0,0 @@
package customskinloader.fake;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import customskinloader.CustomSkinLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
public class FakeClientPlayer {
//For Legacy Skin
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
ITextureObject ito = textman.getTexture(resourceLocationIn);
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
//if Legacy Skin for username not loaded yet
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
UUID offlineUUID = EntityPlayer.getOfflineUUID(username);
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
//Load Default Skin
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
textman.loadTexture(resourceLocationIn, defaultSkinObj);
//Load Skin from SkinManager
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
}
if (ito instanceof ThreadDownloadImageData)
return (ThreadDownloadImageData) ito;
else
return null;
}
public static ResourceLocation getLocationSkin(String username) {
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
}
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
public static class LegacyBuffer implements SkinAvailableCallback {
ResourceLocation resourceLocationIn;
boolean loaded = false;
public LegacyBuffer(ResourceLocation resourceLocationIn) {
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
this.resourceLocationIn = resourceLocationIn;
}
@Override
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
if (typeIn != Type.SKIN || loaded)
return;
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
ITextureObject ito = textman.getTexture(location);
if (ito == null)
ito = textureCache.get(location);
if (ito == null)
return;
loaded = true;
textman.loadTexture(resourceLocationIn, ito);
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
ito.toString() + " (" + location + ")");
}
}
}
@@ -1,151 +0,0 @@
package customskinloader.fake;
import customskinloader.CustomSkinLoader;
import customskinloader.fake.texture.FakeBufferedImage;
import customskinloader.fake.texture.FakeImage;
import customskinloader.fake.texture.FakeNativeImage;
import java.awt.image.BufferedImage;
public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer {
private int ratio = 1;
private FakeImage image = null;
//parseUserSkin for 1.13+
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
if (image == null)
return null;
FakeImage img = parseUserSkin(new FakeNativeImage(image));
if (img instanceof FakeNativeImage)
return ((FakeNativeImage) img).getImage();
CustomSkinLoader.logger.warning("Failed to parseUserSkin(func_195786_a).");
return null;
}
//parseUserSkin for 1.12.2-
public BufferedImage parseUserSkin(BufferedImage image) {
if (image == null)
return null;
FakeImage img = parseUserSkin(new FakeBufferedImage(image));
if (img instanceof FakeBufferedImage)
return ((FakeBufferedImage) img).getImage();
CustomSkinLoader.logger.warning("Failed to parseUserSkin.");
return null;
}
public FakeImage parseUserSkin(FakeImage image) {
if (image == null) return null;
this.ratio = image.getWidth() / 64;
if (image.getHeight() != image.getWidth()) {//Single Layer
//Create a new image and copy origin image data
FakeImage img = image.createImage(64 * ratio, 64 * ratio);
img.copyImageData(image); image.close(); image = img;
image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
//Right Leg -> Left Leg
image.copyArea( 4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
image.copyArea( 8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
image.copyArea( 0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
image.copyArea( 4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
image.copyArea( 8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
//Right Arm -> Left Arm
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
image.copyArea(48 * ratio, 20 * ratio,-16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
}
this.image = image;
setAreaDueToConfig( 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
setAreaDueToConfig( 0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
setAreaTransparent( 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
setAreaTransparent( 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
return image;
}
/**
* Judge the type of skin
* Must be called after parseUserSkin
*
* @return type of skin (slim / default)
* @since 14.9
*/
public String judgeType() {
if (this.image == null)
return null;
if (((image.getRGBA(55, 20) & B) >>> 24) == 0)//if (55,20) is transparent
return "slim";
return "default";
}
/* 2^24-1
* 00000000 11111111 11111111 11111111 */
private static final int A = 16777215;
private static final int WHITE = getARGB(255, 255, 255, 255);
private static final int BLACK = getARGB(255, 0, 0, 0);
private boolean isFilled(int x0, int y0, int x1, int y1) {
int data = image.getRGBA(x0, y0);
if (data != WHITE && data != BLACK)
return false;
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
if (image.getRGBA(x, y) != data)
return false;
return true;
}
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
if (!isFilled(x0, y0, x1, y1))
return;
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
image.setRGBA(x, y, image.getRGBA(x,y) & A);
}
/* -2^24
* 00000001 00000000 00000000 00000000 ->
* 11111110 11111111 11111111 11111111 ->
* 11111111 00000000 00000000 00000000 */
private static final int B = -16777216;
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
image.setRGBA(x, y, image.getRGBA(x,y) | B);
}
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
setAreaTransparent(x0, y0, x1, y1);
else
setAreaOpaque(x0, y0, x1, y1);
}
public void skinAvailable() {
//A callback when skin loaded, nothing to do
}
private static int getARGB(int a, int r, int g, int b) {
return (a << 24) | (r << 16) | (g << 8) | b;
}
}
@@ -1,119 +0,0 @@
package customskinloader.fake;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import customskinloader.CustomSkinLoader;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpTextureUtil.HttpTextureInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
import net.minecraft.util.ResourceLocation;
public class FakeSkinManager{
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
private final TextureManager textureManager;
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
this.textureManager=textureManagerInstance;
HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType){
return this.loadSkin(profileTexture, textureType, null);
}
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback){
HttpTextureInfo info=HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash);
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
if (itextureobject != null)//Have already loaded
makeCallback(skinAvailableCallback,textureType, resourcelocation, profileTexture);
else{
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
if(skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
FakeClientPlayer.textureCache.put(resourcelocation,threaddownloadimagedata);
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
}
return resourcelocation;
}
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
THREAD_POOL.submit(new Runnable(){
public void run(){
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
public void run(){
for(Type type:Type.values())
if(map.containsKey(type))
FakeSkinManager.this.loadSkin(map.get(type), type, skinAvailableCallback);
}
});
}
});
}
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile){
return CustomSkinLoader.loadProfileFromCache(profile);
}
private static void makeCallback(SkinAvailableCallback callback,Type type, ResourceLocation location, MinecraftProfileTexture texture){
if(callback!=null)
callback.skinAvailable(type, location, texture);
}
private class BaseBuffer implements IImageBuffer{
private IImageBuffer buffer;
private SkinAvailableCallback callback;
private Type type;
private ResourceLocation location;
private MinecraftProfileTexture texture;
public BaseBuffer(SkinAvailableCallback callback,Type type,ResourceLocation location,MinecraftProfileTexture texture){
this.buffer=(type==Type.SKIN?new FakeSkinBuffer():null);
this.callback=callback;
this.type=type;
this.location=location;
this.texture=texture;
}
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image){
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
}
public BufferedImage parseUserSkin(BufferedImage image){
return buffer==null?image:buffer.parseUserSkin(image);
}
public void skinAvailable(){
if (buffer != null){
buffer.skinAvailable();
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
//Auto judge skin type
Map<String, String> metadata = Maps.newHashMap();
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
}
}
FakeSkinManager.makeCallback(callback,type, location, texture);
}
}
}
@@ -1,105 +0,0 @@
package customskinloader.loader;
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import com.mojang.authlib.GameProfile;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.jsonapi.*;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpUtil0;
import customskinloader.utils.HttpRequestUtil.HttpRequest;
import customskinloader.utils.HttpRequestUtil.HttpResponce;
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
public interface IJsonAPI {
String toJsonUrl(String root, String username);
String getPayload(SkinSiteProfile ssp);
UserProfile toUserProfile(String root, String json, boolean local);
String getName();
}
public static class ErrorProfile{
public int errno;
public String msg;
}
public enum Type{
CustomSkinAPI(new CustomSkinAPI()),
CustomSkinAPIPlus(new CustomSkinAPIPlus()),
UniSkinAPI(new UniSkinAPI()),
ElyByAPI(new ElyByAPI());
public IJsonAPI jsonAPI;
Type(IJsonAPI jsonAPI){
this.jsonAPI=jsonAPI;
}
}
private Type type;
public JsonAPILoader(Type type){
this.type=type;
}
@Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
String username=gameProfile.getName();
if(StringUtils.isEmpty(ssp.root) && type!=Type.ElyByAPI){
CustomSkinLoader.logger.info("Root not defined.");
return null;
}
boolean local = HttpUtil0.isLocal(ssp.root);
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
String json;
if(local){
File jsonFile = new File(CustomSkinLoader.DATA_DIR, jsonUrl);
if(!jsonFile.exists()){
CustomSkinLoader.logger.info("Profile File not found.");
return null;
}
json=IOUtils.toString(new FileInputStream(jsonFile), "UTF-8");
}else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
json=responce.content;
}
if(json==null||json.equals("")){
CustomSkinLoader.logger.info("Profile not found.");
return null;
}
ErrorProfile profile=CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class);
if(profile.errno!=0){
CustomSkinLoader.logger.info("Error "+profile.errno+": "+profile.msg);
return null;
}
UserProfile p=type.jsonAPI.toUserProfile(ssp.root, json, local);
if(p==null||p.isEmpty()){
CustomSkinLoader.logger.info("Both skin and cape not found.");
return null;
}else{
return p;
}
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return !StringUtils.isNoneEmpty(ssp0.root) || ssp0.root.equalsIgnoreCase(ssp1.root);
}
@Override
public String getName() {
return type.jsonAPI.getName();
}
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public void initLocalFolder(SkinSiteProfile ssp) {
if(HttpUtil0.isLocal(ssp.root)){
File f=new File(ssp.root);
if(!f.exists())
f.mkdirs();
}
}
}
@@ -1,95 +0,0 @@
package customskinloader.loader;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import com.mojang.authlib.GameProfile;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpRequestUtil.HttpRequest;
import customskinloader.utils.HttpRequestUtil.HttpResponce;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0;
public class LegacyLoader implements ProfileLoader.IProfileLoader {
public static final String USERNAME_PLACEHOLDER="{USERNAME}";
@Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
String username=gameProfile.getName();
UserProfile profile=new UserProfile();
if(StringUtils.isNoneEmpty(ssp.skin)){
String skin=ssp.skin.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.skin)){
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
if(skinFile.exists()&&skinFile.isFile())
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
}else{
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success)
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
}
profile.model=profile.hasSkinUrl()?ssp.model:null;
}
if(StringUtils.isNoneEmpty(ssp.cape)){
String cape=ssp.cape.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.cape)){
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
if(capeFile.exists()&&capeFile.isFile())
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
}else{
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success)
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
}
}
if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){
String elytra=ssp.elytra.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.elytra)){
File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra);
if(elytraFile.exists()&&elytraFile.isFile())
profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
}else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success)
profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra);
}
}
if(profile.isEmpty()){
CustomSkinLoader.logger.info("Both skin and cape not found.");
return null;
}
return profile;
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return (!StringUtils.isNoneEmpty(ssp0.skin) || ssp0.skin.equalsIgnoreCase(ssp1.skin)) || (!StringUtils.isNoneEmpty(ssp0.cape) || ssp0.cape.equalsIgnoreCase(ssp1.cape));
}
@Override
public String getName() {
return "Legacy";
}
@Override
public void initLocalFolder(SkinSiteProfile ssp) {
if(HttpUtil0.isLocal(ssp.skin))
initFolder(ssp.skin);
if(HttpUtil0.isLocal(ssp.cape))
initFolder(ssp.cape);
if(HttpUtil0.isLocal(ssp.elytra))
initFolder(ssp.elytra);
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private void initFolder(String target){
String file=target.replace(USERNAME_PLACEHOLDER, "init");
File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile();
if(folder!=null&&!folder.exists())
folder.mkdirs();
}
}
@@ -1,121 +0,0 @@
package customskinloader.loader;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
import com.mojang.util.UUIDTypeAdapter;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpRequestUtil.HttpRequest;
import customskinloader.utils.HttpRequestUtil.HttpResponce;
import customskinloader.utils.MinecraftUtil;
public class MojangAPILoader implements ProfileLoader.IProfileLoader {
public static final MinecraftSessionService defaultSessionService=MinecraftUtil.getSessionService();
@Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=getTextures(gameProfile);
if(!map.isEmpty()){
CustomSkinLoader.logger.info("Default profile will be used.");
return ModelManager0.toUserProfile(map);
}
String username=gameProfile.getName();
GameProfile newGameProfile=loadGameProfile(username);
if(newGameProfile==null){
CustomSkinLoader.logger.info("Profile not found.("+username+"'s profile not found.)");
return null;
}
newGameProfile=fillGameProfile(newGameProfile);
map=getTextures(newGameProfile);
if(!map.isEmpty()){
gameProfile.getProperties().putAll(newGameProfile.getProperties());
return ModelManager0.toUserProfile(map);
}
CustomSkinLoader.logger.info("Profile not found.("+username+" doesn't have skin/cape.)");
return null;
}
//Username -> UUID
public static GameProfile loadGameProfile(String username) {
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0));
if(StringUtils.isEmpty(responce.content))
return null;
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
GameProfile gameProfile=gson.fromJson(responce.content, GameProfile.class);
if(gameProfile.getId()==null)
return null;
return new GameProfile(gameProfile.getId(),gameProfile.getName());
}
//UUID -> Profile
public static GameProfile fillGameProfile(GameProfile profile) {
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
HttpResponce responce = HttpRequestUtil.makeHttpRequest(
new HttpRequest("https://sessionserver.mojang.com/session/minecraft/profile/"
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
if(StringUtils.isEmpty(responce.content))
return profile;
Gson gson=new GsonBuilder()
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
.create();
MinecraftProfilePropertiesResponse propertiesResponce=gson.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
GameProfile newGameProfile=new GameProfile(propertiesResponce.getId(),propertiesResponce.getName());
newGameProfile.getProperties().putAll(propertiesResponce.getProperties());
return newGameProfile;
}
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
if(gameProfile==null)
return Maps.newHashMap();
Property textureProperty=Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
if (textureProperty==null)
return Maps.newHashMap();
String value=textureProperty.getValue();
if(StringUtils.isBlank(value))
return Maps.newHashMap();
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
MinecraftTexturesPayload result=gson.fromJson(json,MinecraftTexturesPayload.class);
if (result==null||result.getTextures()==null)
return Maps.newHashMap();
return result.getTextures();
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return true;
}
@Override
public String getName() {
return "MojangAPI";
}
@Override
public void initLocalFolder(SkinSiteProfile ssp) {
}
}
@@ -1,35 +0,0 @@
package customskinloader.loader;
import java.util.HashMap;
import com.mojang.authlib.GameProfile;
import customskinloader.config.SkinSiteProfile;
import customskinloader.profile.UserProfile;
public class ProfileLoader {
private static final IProfileLoader[] DEFAULT_LOADERS={
new MojangAPILoader(),
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI),
new JsonAPILoader(JsonAPILoader.Type.ElyByAPI),
new LegacyLoader()};
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
private static HashMap<String, IProfileLoader> initLoaders() {
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
for(IProfileLoader loader:DEFAULT_LOADERS){
loaders.put(loader.getName().toLowerCase(), loader);
}
return loaders;
}
public interface IProfileLoader {
UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
String getName();
void initLocalFolder(SkinSiteProfile ssp);
}
}
@@ -1,90 +0,0 @@
package customskinloader.loader.jsonapi;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader.IJsonAPI;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.ModelManager0.Model;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
public class CustomSkinAPI implements IJsonAPI {
private static final String TEXTURES="textures/";
private static final String SUFFIX=".json";
@Override
public String toJsonUrl(String root, String username) {
return root + username + SUFFIX;
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
UserProfile p=new UserProfile();
if(StringUtils.isNotBlank(profile.skin)){
p.skinUrl=root+TEXTURES+profile.skin;
if(local)
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
}
if(StringUtils.isNotBlank(profile.cape)){
p.capeUrl=root+TEXTURES+profile.cape;
if(local)
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
}
if(StringUtils.isNotBlank(profile.elytra)){
p.elytraUrl=root+TEXTURES+profile.elytra;
if(local)
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
}
Map<String,String> textures=new LinkedHashMap<String,String>();
if(profile.skins!=null)
textures.putAll(profile.skins);
if(profile.textures!=null)
textures.putAll(profile.textures);
if(textures.isEmpty())
return p;
boolean hasSkin=false;
for(String model:textures.keySet()){
Model enumModel=ModelManager0.getEnumModel(model);
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
continue;
if(ModelManager0.isSkin(enumModel))
if(hasSkin)
continue;
else
hasSkin=true;
String url=root+TEXTURES+textures.get(model);
if(local)
url=HttpTextureUtil.getLocalFakeUrl(url);
p.put(enumModel, url);
}
return p;
}
private class CustomSkinAPIProfile{
public String username;
public LinkedHashMap<String,String> textures;
public LinkedHashMap<String,String> skins;
public String skin;
public String cape;
public String elytra;
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "CustomSkinAPI";
}
}
@@ -1,82 +0,0 @@
package customskinloader.loader.jsonapi;
import java.io.File;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import com.google.gson.Gson;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.loader.JsonAPILoader.IJsonAPI;
import customskinloader.profile.UserProfile;
import customskinloader.utils.MinecraftUtil;
public class CustomSkinAPIPlus implements IJsonAPI {
private static String clientID=null;
public CustomSkinAPIPlus(){
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
if(clientIDFile.isFile())
try{
clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
}catch(Exception e){
e.printStackTrace();
}
if(clientID==null){
clientID=UUID.randomUUID().toString();
try {
FileUtils.write(clientIDFile, clientID, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public String toJsonUrl(String root, String username) {
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toJsonUrl(root, username);
}
@Override
public String getPayload(SkinSiteProfile ssp) {
if(ssp.privacy==null)
ssp.privacy=new CustomSkinAPIPlusPrivacy();
return new Gson().toJson(new CustomSkinAPIPlusPayload(ssp.privacy));
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toUserProfile(root, json, local);
}
@Override
public String getName() {
return "CustomSKinAPIPlus";
}
public static class CustomSkinAPIPlusPayload{
public String gameVersion;//minecraft version
public String modVersion;//mod version
public String serverAddress;//ip:port
public String clientID;//Minecraft Client ID
public CustomSkinAPIPlusPayload(CustomSkinAPIPlusPrivacy privacy){
if(privacy.gameVersion)
gameVersion=MinecraftUtil.getMinecraftMainVersion();
if(privacy.modVersion)
modVersion=CustomSkinLoader.CustomSkinLoader_VERSION;
if(privacy.serverAddress)
serverAddress=MinecraftUtil.isLanServer()?null:MinecraftUtil.getStandardServerAddress();
if(privacy.clientID)
clientID=CustomSkinAPIPlus.clientID;
}
}
public static class CustomSkinAPIPlusPrivacy{
public boolean gameVersion=true;
public boolean modVersion=true;
public boolean serverAddress=true;
public boolean clientID=true;
}
}
@@ -1,50 +0,0 @@
package customskinloader.loader.jsonapi;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.MinecraftUtil;
import java.net.URI;
import java.util.Map;
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
@Override
public String toJsonUrl(String root, String username) {
return "http://skinsystem.ely.by/textures/" + username + "?version=2&minecraft_version=" + MinecraftUtil.getMinecraftMainVersion();
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
Map<Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<Type, MinecraftProfileTexture>>() {
}.getType());
if (!result.containsKey(Type.SKIN))
return null;
//Check URL
try {
URI uri = new URI(result.get(Type.SKIN).getUrl());
if (!uri.getHost().endsWith("ely.by"))
return null;
} catch (Exception e) {
return null;
}
return ModelManager0.toUserProfile(result);
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "ElyByAPI";
}
}
@@ -1,80 +0,0 @@
package customskinloader.loader.jsonapi;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader.IJsonAPI;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.profile.ModelManager0.Model;
import customskinloader.utils.HttpTextureUtil;
public class UniSkinAPI implements IJsonAPI {
private static final String TEXTURES="textures/";
private static final String SUFFIX=".json";
@Override
public String toJsonUrl(String root, String username) {
return root + username + SUFFIX;
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
UserProfile p=new UserProfile();
if(StringUtils.isNotBlank(profile.cape)){
p.capeUrl=root+TEXTURES+profile.cape;
if(local)
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
}
if(profile.skins==null||profile.skins.isEmpty())
return p;
if(profile.model_preference==null||profile.model_preference.isEmpty())
return p;
boolean hasSkin=false;
for(String model:profile.model_preference){
Model enumModel=ModelManager0.getEnumModel(model);
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
continue;
if(ModelManager0.isSkin(enumModel))
if(hasSkin)
continue;
else
hasSkin=true;
String url=root+TEXTURES+profile.skins.get(model);
if(local)
url=HttpTextureUtil.getLocalFakeUrl(url);
p.put(enumModel, url);
}
return p;
}
/**
* Json profile for UniSkinAPI
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
* @author RecursiveG
*/
private class UniSkinAPIProfile{
public String player_name;
public long last_update;
public List<String> model_preference;
public Map<String,String> skins;
public String cape;
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "UniSkinAPI";
}
}
@@ -1,159 +0,0 @@
package customskinloader.profile;
import java.io.File;
import java.util.*;
import com.google.common.collect.Lists;
import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.properties.Property;
import com.mojang.util.UUIDTypeAdapter;
import customskinloader.CustomSkinLoader;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpRequestUtil.HttpRequest;
import customskinloader.utils.HttpRequestUtil.HttpResponce;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0;
public class DynamicSkullManager {
public static class SkullTexture{
public Map<Type,MinecraftProfileTexture> textures;
public String index;//Index File
public ArrayList<String> skins;
public int interval;
public boolean fromZero;
//For program
public long startTime;
public int period;
}
private Map<GameProfile,SkullTexture> dynamicTextures=new HashMap<GameProfile,SkullTexture>();
private Map<GameProfile,Map<Type,MinecraftProfileTexture>> staticTextures=new HashMap<GameProfile,Map<Type,MinecraftProfileTexture>>();
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
private void parseGameProfile(GameProfile profile){
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
if (textureProperty==null){
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return;
}
String value=textureProperty.getValue();
if(StringUtils.isBlank(value)){
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return;
}
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
SkullTexture result=gson.fromJson(json,SkullTexture.class);
if(result==null){
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return;
}
staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
if(StringUtils.isNotEmpty(result.index)){
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
try{
String index=FileUtils.readFileToString(indexFile, "UTF-8");
if(StringUtils.isNotEmpty(index)){
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
if(skins != null && skins.length != 0)
result.skins = Lists.newArrayList(skins);
}
}catch(Exception e){
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
}
}
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
return;
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
for(int i=0;i<result.skins.size();i++){//check and cache skins
String skin=result.skins.get(i);
if(HttpUtil0.isLocal(skin)){
//Local Skin
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
if(skinFile.isFile()&&skinFile.length()>0){
//Skin found
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
result.skins.set(i, fakeUrl);
}else{
//Could not find skin
result.skins.remove(i--);
}
}else{
//Online Skin
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
if(!responce.success){
//Could not load skin
result.skins.remove(i--);
}
}
}
if(result.skins.isEmpty()){//Nothing loaded
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
return;
}
result.interval=Math.max(result.interval, 50);
if(result.fromZero)
result.startTime=System.currentTimeMillis();
result.period=result.interval*result.skins.size();
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
dynamicTextures.put(profile, result);
staticTextures.remove(profile);
}
//Support local skin for skull
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
MinecraftProfileTexture skin=textures.get(Type.SKIN);
String skinUrl=skin.getUrl();
if(!HttpUtil0.isLocal(skinUrl))
return textures;
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
if(!skinFile.isFile())
return Maps.newHashMap();
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
return textures;
}
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
if(staticTextures.get(profile)!=null)
return staticTextures.get(profile);
if(loadingList.contains(profile))
return Maps.newHashMap();
if(dynamicTextures.containsKey(profile)){
SkullTexture texture=dynamicTextures.get(profile);
long time=System.currentTimeMillis()-texture.startTime;
int index=(int)Math.floor((time%texture.period)/texture.interval);
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
return map;
}
loadingList.add(profile);
Thread loadThread=new Thread(){
public void run(){
parseGameProfile(profile);//Load in thread
loadingList.remove(profile);
}
};
loadThread.setName("Skull "+profile.hashCode());
loadThread.start();
return Maps.newHashMap();
}
}
@@ -1,121 +0,0 @@
package customskinloader.profile;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Maps;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
/**
* Model Manager for 1.8 and higher.
* A manager to check if model is available.
* It is the only class in package 'customskinloader' which has differences in different Minecraft version.
* @since 13.1
*/
public class ModelManager0 {
public enum Model{
SKIN_DEFAULT,
SKIN_SLIM,
CAPE,
ELYTRA
}
private static HashMap<String,Model> models=new HashMap<String,Model>();
private static Type typeElytra=null;
static{
for(Type type:Type.values()){
if(type.ordinal()==2)//ELYTRA
typeElytra=type;
}
models.put("default", Model.SKIN_DEFAULT);
models.put("slim", Model.SKIN_SLIM);
models.put("cape", Model.CAPE);
if(typeElytra!=null)
models.put("elytra", Model.ELYTRA);
}
/**
* Get enum for the model.
* @param model - string model
* @since 14.5
*/
public static Model getEnumModel(String model){
return models.get(model);
}
/**
* Check if model is skin.
* @since 14.5
* */
public static boolean isSkin(Model model){
return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM;
}
/**
* Check if elytra is supported.
* @since 14.5
*/
public static boolean isElytraSupported(){
return typeElytra!=null;
}
/**
* Parse hashMapProfile to UserProfile
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
* @return profile - UserProfile instance
* @since 13.1
*/
public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile){
UserProfile userProfile=new UserProfile();
if(profile==null)
return userProfile;
MinecraftProfileTexture skin = profile.get(Type.SKIN);
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
userProfile.model= skin==null?null:skin.getMetadata("model");
if(StringUtils.isEmpty(userProfile.model))
userProfile.model="default";
MinecraftProfileTexture cape = profile.get(Type.CAPE);
userProfile.capeUrl= cape==null?null:cape.getUrl();
return userProfile;
}
/**
* Parse UserProfile to hashMapProfile
* @param profile - UserProfile instance
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
* @since 13.1
*/
public static Map<Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile){
Map<Type, MinecraftProfileTexture> map=Maps.newHashMap();
if(profile==null)
return map;
if(profile.skinUrl!=null){
Map<String,String> metadata = null;
if("slim".equals(profile.model) || "auto".equals(profile.model)){
metadata = Maps.newHashMap();
metadata.put("model", profile.model);
}
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
}
if(profile.capeUrl!=null)
map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null));
if(typeElytra!=null && profile.elytraUrl!=null)
map.put(typeElytra, getProfileTexture(profile.elytraUrl,null));
return map;
}
/**
* Parse url to MinecraftProfileTexture
*
* @param url - textureUrl
* metadata - metadata
* @return MinecraftProfileTexture
* @since 14.5
*/
public static MinecraftProfileTexture getProfileTexture(String url,Map<String,String> metadata){
return new MinecraftProfileTexture(url,metadata);
}
}
@@ -1,213 +0,0 @@
package customskinloader.utils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import customskinloader.CustomSkinLoader;
public class HttpRequestUtil {
public static class HttpRequest{
public String url;
public String userAgent=null;
public String payload=null;
public boolean loadContent=true;
public boolean checkPNG=false;
public int cacheTime=600;//-1=No Cache 0=Always Cache t=Default Cache Time(second)
public File cacheFile=null;//Default Cache File
public HttpRequest(String url){
this.url=url;
}
public HttpRequest setUserAgent(String userAgent){
this.userAgent=userAgent;
return this;
}
public HttpRequest setPayload(String payload){
this.payload=payload;
return this;
}
public HttpRequest setLoadContent(boolean loadContent){
this.loadContent=loadContent;
return this;
}
public HttpRequest setCheckPNG(boolean checkPNG){
this.checkPNG=checkPNG;
return this;
}
public HttpRequest setCacheTime(int cacheTime){
this.cacheTime=cacheTime;
return this;
}
public HttpRequest setCacheFile(File cacheFile){
this.cacheFile=cacheFile;
return this;
}
}
public static class HttpResponce{
public String content=null;
public int responceCode=-1;
public boolean success=false;
public boolean fromCache=false;
}
public static class CacheInfo{
public String url;
public String etag=null;
public long lastModified=-1;//ms
public long expire=-1;//UNIX timestamp
}
public static final File CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"caches");
public static HttpResponce makeHttpRequest(HttpRequest request){
try{
CustomSkinLoader.logger.debug("Try to request '"+request.url+(request.userAgent==null?"'.":"' with user agent '"+request.userAgent+"'."));
//Check Cache
if(StringUtils.isNotEmpty(request.payload))
request.cacheTime=-1;//No Cache
File cacheInfoFile=null;
CacheInfo cacheInfo=new CacheInfo();
if(request.cacheFile==null && request.cacheTime>=0){
String hash=DigestUtils.sha1Hex(request.url);
request.cacheFile=new File(CACHE_DIR,hash);
cacheInfoFile=new File(CACHE_DIR,hash+".json");
}
if(request.cacheTime==0 && request.cacheFile.isFile())
return loadFromCache(request,new HttpResponce());
if(cacheInfoFile!=null&&cacheInfoFile.isFile()){
String json=FileUtils.readFileToString(cacheInfoFile, "UTF-8");
if(StringUtils.isNotEmpty(json))
cacheInfo=CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
if(cacheInfo==null)
cacheInfo=new CacheInfo();
if(cacheInfo.expire>=TimeUtil.getCurrentUnixTimestamp())
return loadFromCache(request,new HttpResponce(),cacheInfo.expire);
}
//Init Connection
String url=new URI(request.url).toASCIIString();
if(!url.equalsIgnoreCase(request.url))
CustomSkinLoader.logger.debug("Encoded URL: "+url);
HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection();
c.setReadTimeout(1000 * 10);
c.setConnectTimeout(1000 * 10);
c.setDoInput(true);
c.setUseCaches(false);
c.setInstanceFollowRedirects(true);
//Make Connection
if(cacheInfo.lastModified>=0)
c.setIfModifiedSince(cacheInfo.lastModified);
if(cacheInfo.etag!=null)
c.setRequestProperty("If-None-Match",cacheInfo.etag);
c.setRequestProperty("Accept-Encoding","gzip");
if(request.userAgent!=null)
c.setRequestProperty("User-Agent",request.userAgent);
if(StringUtils.isNotEmpty(request.payload)){
CustomSkinLoader.logger.info("Payload: "+request.payload);
c.setDoOutput(true);
OutputStream os=c.getOutputStream();
IOUtils.write(request.payload, os, "UTF-8");
IOUtils.closeQuietly(os);
}
c.connect();
//Check Connection
HttpResponce responce=new HttpResponce();
responce.responceCode=c.getResponseCode();
int res=c.getResponseCode()/100;
if(res==4||res==5){//Failed
CustomSkinLoader.logger.debug("Failed to request (Response Code: "+c.getResponseCode()+")");
return responce;
}
responce.success=true;
CustomSkinLoader.logger.debug("Successfully request (Response Code: "+c.getResponseCode()+" , Content Length: "+c.getContentLength()+")");
if(responce.responceCode==HttpURLConnection.HTTP_NOT_MODIFIED)
return loadFromCache(request,responce);
//Load Content
InputStream is="gzip".equals(c.getContentEncoding())?new GZIPInputStream(c.getInputStream()):c.getInputStream();
byte [] bytes = IOUtils.toByteArray(is);
if(request.checkPNG&&(bytes.length<=4||bytes[1]!=(byte)'P'||bytes[2]!=(byte)'N'||bytes[3]!=(byte)'G')){
CustomSkinLoader.logger.debug("Failed to request (Not Standard PNG)");
responce.success=false;
return responce;
}
if(request.cacheFile!=null){
FileUtils.writeByteArrayToFile(request.cacheFile, bytes);
if(cacheInfoFile!=null){
cacheInfo.url=request.url;
cacheInfo.etag=c.getHeaderField("ETag");
cacheInfo.lastModified=c.getLastModified();
cacheInfo.expire=getExpire(c,request.cacheTime);
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo), "UTF-8");
}
CustomSkinLoader.logger.debug("Saved to cache (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+cacheInfo.expire+")");
}
if(!request.loadContent)
return responce;
responce.content=new String(bytes, "UTF-8");
CustomSkinLoader.logger.debug("Content: "+responce.content);
return responce;
}catch(Exception e){
CustomSkinLoader.logger.debug("Failed to request (Exception: "+e.toString()+")");
return loadFromCache(request,new HttpResponce());
}
}
public static File getCacheFile(String hash){
return new File(CACHE_DIR,hash);
}
private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce){
return loadFromCache(request,responce,0);
}
private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce,long expireTime){
if(request.cacheFile==null||!request.cacheFile.isFile())
return responce;
CustomSkinLoader.logger.debug("Cache file found (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+expireTime+"')");
responce.fromCache=true;
responce.success=true;
if(!request.loadContent)
return responce;
CustomSkinLoader.logger.info("Try to load from cache '"+request.cacheFile.getAbsolutePath()+"'.");
try {
responce.content=FileUtils.readFileToString(request.cacheFile, "UTF-8");
CustomSkinLoader.logger.debug("Successfully load from cache");
CustomSkinLoader.logger.debug("Content: "+responce.content);
} catch (IOException e) {
CustomSkinLoader.logger.debug("Failed to load from cache (Exception: "+e.toString()+")");
responce.success=false;
}
return responce;
}
private final static Pattern MAX_AGE_PATTERN = Pattern.compile(".*?max-age=(\\d+).*?");
private static long getExpire(HttpURLConnection connection,int cacheTime){
String cacheControl=connection.getHeaderField("Cache-Control");
if(StringUtils.isNotEmpty(cacheControl)){
Matcher m=MAX_AGE_PATTERN.matcher(cacheControl);
if(m.matches())
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
}
long expires=connection.getExpiration();
if(expires>0)
return expires/1000;
return TimeUtil.getUnixTimestampRandomDelay(cacheTime==0 ? 86400 : cacheTime);
}
}
@@ -1,83 +0,0 @@
package customskinloader.utils;
import java.io.File;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import customskinloader.CustomSkinLoader;
public class HttpTextureUtil {
public static class HttpTextureInfo{
public String url="";
public File cacheFile;
public String hash;
}
private static final String
LEGACY_MARK="(LEGACY)",
LOCAL_MARK="(LOCAL)",
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
public static File defaultCacheDir;
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void cleanCacheDir(){
if(defaultCacheDir!=null){
defaultCacheDir.delete();
defaultCacheDir.mkdirs();
}
}
public static File getCacheDir(){
return defaultCacheDir==null?new File(MinecraftUtil.getMinecraftDataDir(),"assets/skins"):defaultCacheDir;
}
public static HttpTextureInfo toHttpTextureInfo(String fakeUrl){
HttpTextureInfo info=new HttpTextureInfo();
if(fakeUrl.startsWith("http")){
info.url=fakeUrl;
info.hash=FilenameUtils.getBaseName(fakeUrl);
info.cacheFile=getCacheFile(info.hash);
return info;
}
if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){
fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, "");
String[] t=fakeUrl.split(",",2);
if(t.length!=2)
return info;
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,t[1]);
info.hash=t[0];
return info;
}
if(fakeUrl.startsWith(LOCAL_MARK)){
fakeUrl=fakeUrl.replace(LOCAL_MARK, "");
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl);
info.hash=FilenameUtils.getBaseName(fakeUrl);
return info;
}
if(fakeUrl.startsWith(LEGACY_MARK)){
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
info.url=fakeUrl;
info.hash=DigestUtils.sha1Hex(info.url);
info.cacheFile = HttpRequestUtil.getCacheFile(info.hash);
return info;
}
return info;
}
public static String getLegacyFakeUrl(String url){
return LEGACY_MARK+url;
}
public static String getLocalFakeUrl(String path){
return LOCAL_MARK+path;
}
public static String getLocalLegacyFakeUrl(String path,String hash){
return LOCAL_LEGACY_MARK+hash+","+path;
}
public static String getHash(String url,long size,long lastModified){
return DigestUtils.sha1Hex(size+url+lastModified);
}
public static File getCacheFile(String hash){
return getCacheFile(defaultCacheDir,hash);
}
public static File getCacheFile(File cacheDir,String hash){
return new File(new File(cacheDir,hash.length()>2?hash.substring(0,2):"xx"), hash);
}
}
@@ -1,79 +0,0 @@
package customskinloader.utils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.StringUtils;
public class HttpUtil0 {
public static boolean isLocal(String url){
return url != null && !url.startsWith("http");
}
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
public static void ignoreHttpsCertificate(){
HostnameVerifier doNotVerify = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
public void checkClientTrusted(X509Certificate[] chain, String authType){}
public void checkServerTrusted(X509Certificate[] chain, String authType){}
}};
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String parseAddress(String address) {
if(StringUtils.isEmpty(address))
return null;
String[] addresses=address.split(":");
InetAddress add;
try {
add = InetAddress.getByName(addresses[0]);
} catch (UnknownHostException e) {
e.printStackTrace();
return null;
}
return add.getHostAddress()+(addresses.length==2 ? addresses[1] : "25565");
}
public static boolean isLanServer(String standardAddress){
if(StringUtils.isEmpty(standardAddress))
return true;
String[] addresses=standardAddress.split(":");
int numIp=getNumIp(addresses[0]);
return numIp==0||numIp==getNumIp("127.0.0.1")||
(numIp>=getNumIp("192.168.0.0")&&numIp<=getNumIp("192.168.255.255"))||
(numIp>=getNumIp("10.0.0.0")&&numIp<=getNumIp("10.255.255.255"))||
(numIp>=getNumIp("172.16.0.0")&&numIp<=getNumIp("172.31.255.255"));
}
public static int getNumIp(String ip){
int num=0;
String[] ips=ip.split("\\.");
if(ips.length!=4)
return 0;
for(int i=0;i<4;i++)
num+=Integer.parseInt(ips[i])*(256^(3-i));
return num;
}
}
@@ -1,34 +0,0 @@
package customskinloader.utils;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.LinkedList;
public class JavaUtil {
public static URL[] getClasspath() {
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
//Java 8-
//Use URLClassLoader Directly
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
return ucl.getURLs();
} else {
//Java 9+
//It uses APPClassLoader instead of URLClassLoader
//Get Classpath from properties and parse it to URL array
String classpath = System.getProperty("java.class.path");
String[] elements = classpath.split(File.pathSeparator);
if (elements.length == 0)
return new URL[0];
LinkedList<URL> urls = new LinkedList<URL>();
for (String ele : elements) {
try {
urls.add(new URL(ele));
} catch (Exception ignored) {
}
}
return (URL[]) urls.toArray();
}
}
}
@@ -1,128 +0,0 @@
package customskinloader.utils;
import java.io.File;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import net.minecraft.client.renderer.texture.TextureManager;
/**
* @author Alexander Xia
* @since 13.6
*
*/
public class MinecraftUtil {
public static File getMinecraftDataDir(){
return net.minecraft.client.Minecraft.getMinecraft().mcDataDir;
}
public static MinecraftSessionService getSessionService(){
return net.minecraft.client.Minecraft.getMinecraft().getSessionService();
}
public static TextureManager getTextureManager(){
return net.minecraft.client.Minecraft.getMinecraft().getTextureManager();
}
private static ArrayList<String> minecraftVersion=new ArrayList<String>();
private static String minecraftMainVersion=null;
private final static Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile(".*?(\\d+\\.\\d+[\\.]?\\d*).*?");
public static ArrayList<String> getMinecraftVersions(){
if(minecraftVersion!=null&&!minecraftVersion.isEmpty())
return minecraftVersion;
testProbe();
return minecraftVersion;
}
public static String getMinecraftVersionText(){
StringBuilder sb=new StringBuilder();
for(String version:getMinecraftVersions())
sb.append(version).append(" ");
return StringUtils.trim(sb.toString());
}
public static String getMinecraftMainVersion(){
if(minecraftMainVersion!=null)
return minecraftMainVersion;
for(String version:getMinecraftVersions()){
Matcher m = null;
try{
m=MINECRAFT_VERSION_PATTERN.matcher(version);
}catch(Exception e){
e.printStackTrace();
}
if(m==null || !m.matches())
continue;
minecraftMainVersion=m.group(m.groupCount());
break;
}
return minecraftMainVersion;
}
// (domain|ip)(:port)
public static String getServerAddress(){
net.minecraft.client.multiplayer.ServerData data=net.minecraft.client.Minecraft.getMinecraft().getCurrentServerData();
if(data==null)//Single Player
return null;
return data.serverIP;
}
// ip:port
public static String getStandardServerAddress(){
return HttpUtil0.parseAddress(getServerAddress());
}
public static boolean isLanServer(){
return HttpUtil0.isLanServer(getStandardServerAddress());
}
public static String getCurrentUsername(){
return net.minecraft.client.Minecraft.getMinecraft().getSession().getProfile().getName();
}
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
private static void testProbe(){
minecraftVersion.clear();
URL urls[] = JavaUtil.getClasspath();
for(URL url:urls){
Matcher m = null;
try{
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
}
if(m==null || !m.matches())
continue;
minecraftVersion.add(m.group(2));
}
}
public static boolean isCoreFile(URL url){
Matcher m;
try{
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
return false;
}
return m.matches();
}
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
public static boolean isLibraryFile(URL url){
Matcher m;
try{
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
return false;
}
return m.matches();
}
public static String getCredential(GameProfile profile) {
return (profile==null || profile.hashCode()==0) ? null :
(profile.getId()==null ? profile.getName() : String.format("%s-%s", profile.getName(),profile.getId()));
}
}
@@ -1,57 +0,0 @@
package net.minecraft.client.renderer.texture;
/**
* Empty stack for NativeImage
*/
public class NativeImage {
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
}
/**
* getWidth
*/
public int func_195702_a() {
return 0;
}
/**
* getHeight
*/
public int func_195714_b() {
return 0;
}
/**
* copyImage image
*/
public void func_195703_a(NativeImage p_195703_1_) {
}
/**
* fillAreaRGBA x0 y0 weight height rgba
*/
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
}
/**
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
*/
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
}
/**
* getPixelRGBA x y
*/
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
return 0;
}
/**
* setPixelRGBA x y rgba
*/
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
}
public void close() {
}
}
@@ -0,0 +1,236 @@
package customskinloader;
import java.io.File;
import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.config.Config;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.GameProfileLoader;
import customskinloader.loader.ProfileLoader;
import customskinloader.log.LogManager;
import customskinloader.log.Logger;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.ProfileCache;
import customskinloader.profile.UserProfile;
import customskinloader.utils.MinecraftUtil;
import customskinloader.utils.TextureUtil;
import customskinloader.utils.ThreadPoolFactory;
/**
* Custom skin loader mod for Minecraft.
*
* @author Jeremy Lam [JLChnToZ] 2013-2014 & Alexander Xia [xfl03] 2014-2023
* @version @MOD_FULL_VERSION@
*/
public class CustomSkinLoader {
public static final String CustomSkinLoader_VERSION = "@MOD_VERSION@";
public static final String CustomSkinLoader_FULL_VERSION = "@MOD_FULL_VERSION@";
public static final int CustomSkinLoader_BUILD_NUMBER = Integer.parseInt("@MOD_BUILD_NUMBER@");
public static final File
DATA_DIR = new File(MinecraftUtil.getMinecraftDataDir(), "CustomSkinLoader"),
LOG_FILE = new File(DATA_DIR, "CustomSkinLoader.log"),
CONFIG_FILE = new File(DATA_DIR, "CustomSkinLoader.json");
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final Logger logger = initLogger();
public static final Config config = initConfig();
private static final ProfileCache profileCache = new ProfileCache();
public static final ExecutorService THREAD_POOL = ThreadPoolFactory.create(config.threadPoolSize, false);
public static final ExecutorService PROFILE_THREAD_POOL = ThreadPoolFactory.create(config.loadlist.size() * config.threadPoolSize, true);
public static void loadProfileTextures(Runnable runnable) {
THREAD_POOL.execute(runnable);
}
//For User Skin
public static UserProfile loadProfile(GameProfile gameProfile) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username + " <" + TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile) + ">"); // Change Thread Name
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
if (username == null || username.isEmpty() || username.equals(" ")) {
return ModelManager0.toUserProfile(GameProfileLoader.getTextures(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(gameProfile)));
}
UserProfile profile;
if (profileCache.isReady(credential)) {
logger.info("Cached profile will be used.");
profile = profileCache.getProfile(credential);
if (profile == null) {
logger.warning("(Cached Profile is empty!) Expiry: " + profileCache.getExpiry(credential));
if (profileCache.isExpired(credential)) { // force load
profile = loadProfile0(gameProfile, false);
}
} else {
logger.info(profile.toString(profileCache.getExpiry(credential)));
}
} else {
profileCache.setLoading(credential, true);
profile = loadProfile0(gameProfile, false);
}
Thread.currentThread().setName(tempName);
return profile == null ? new UserProfile() : profile;
}
//Core
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
profileCache.setLoading(credential, true);
long time = System.currentTimeMillis();
logger.info("Loading " + username + "'s profile.");
if (config.loadlist == null || config.loadlist.isEmpty()) {
logger.info("LoadList is Empty.");
return null;
}
int size = config.loadlist.size();
LinkedList<CompletableFuture<UserProfile>> profileGetters = new LinkedList<>();
UserProfile profile0 = new UserProfile();
for (int i = 0; i < size; i++) {
SkinSiteProfile ssp = config.loadlist.get(i);
logger.info((i + 1) + "/" + size + " Try to load profile from '" + ssp.name + "'.");
if (ssp.type == null) {
logger.info("The type of '" + ssp.name + "' is null.");
continue;
}
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if (loader == null) {
logger.info("Type '" + ssp.type + "' is not defined.");
continue;
}
profileGetters.add(CompletableFuture.supplyAsync(() -> {
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username + " <" + TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile) + "> (" + ssp.name + ")"); // Change Thread Name
UserProfile profile = null;
try {
profile = loader.loadProfile(ssp, gameProfile);
} catch (Exception e) {
logger.warning("Exception occurs while loading.");
logger.warning(e);
if (e.getCause() != null) {
logger.warning("Caused By:");
logger.warning(e.getCause());
}
}
Thread.currentThread().setName(tempName);
return profile;
}, PROFILE_THREAD_POOL));
}
for (CompletableFuture<UserProfile> profileGetter : profileGetters) {
UserProfile profile = profileGetter.join();
if (profile == null) {
continue;
}
profile0.mix(profile);
if (isSkull && !profile0.hasSkinUrl()) {
continue;
}
if (!config.forceLoadAllTextures) {
break;
}
if (profile0.isFull()) {
break;
}
}
if (!profile0.isEmpty()) {
logger.info(username + "'s profile loaded. (" + (System.currentTimeMillis() - time) + "ms)");
if (!config.enableCape) {
profile0.capeUrl = null;
}
profileCache.updateCache(credential, profile0);
profileCache.setLoading(credential, false);
logger.info(profile0.toString(profileCache.getExpiry(credential)));
return profile0;
}
logger.info(username + "'s profile not found in load list. (" + (System.currentTimeMillis() - time) + "ms)");
if (config.enableLocalProfileCache) {
UserProfile profile = profileCache.getLocalProfile(credential);
if (profile == null || profile.equals(UserProfile.NULL)) {
logger.info(username + "'s LocalProfile not found.");
} else {
profileCache.updateCache(credential, profile, false);
profileCache.setLoading(credential, false);
logger.info(username + "'s LocalProfile will be used.");
logger.info(profile.toString(profileCache.getExpiry(credential)));
return profile;
}
}
profileCache.setLoading(credential, false);
return null;
}
public final static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> INCOMPLETED = ImmutableMap.of();
//For Skull
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
String credential = MinecraftUtil.getCredential(gameProfile);
//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
//Authlib 3.11.50 makes empty username to " "
if (username == null || username.isEmpty() || username.equals(" ") || credential == null) {
return GameProfileLoader.getTextures(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(gameProfile));
}
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
UserProfile profile = profileCache.getProfile(credential);
return ModelManager0.fromUserProfile(profile);
}
if (!profileCache.isLoading(credential)) {
profileCache.setLoading(credential, true);
Runnable loadThread = () -> {
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username + "'s skull");
loadProfile0(gameProfile, true);//Load in thread
Thread.currentThread().setName(tempName);
};
if (config.forceUpdateSkull) {
new Thread(loadThread).start();
} else {
THREAD_POOL.execute(loadThread);
}
}
return INCOMPLETED;
}
private static Logger initLogger() {
LogManager.setLogFile(LOG_FILE.toPath());
Logger logger = LogManager.getLogger("Core");
logger.info("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
logger.info("Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
logger.info("Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
return logger;
}
/**
* Create <code>Config</code> object.
* To use <code>logger</code>, please make sure call this function after <code>initLogger</code>.
*
* @return <code>Config</code>
*/
private static Config initConfig() {
Config config = Config.loadConfig0();
logger.enableLogStdOut = config.enableLogStdOut;
return config;
}
}
@@ -0,0 +1,258 @@
package customskinloader.config;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import customskinloader.CustomSkinLoader;
import customskinloader.loader.ProfileLoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.plugin.PluginLoader;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.Version;
import org.apache.commons.io.FileUtils;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Config {
//Program
public String version;
public int buildNumber;
public List<SkinSiteProfile> loadlist;
//Function
public boolean enableTransparentSkin = true;
public boolean forceLoadAllTextures = true;
public boolean enableCape = true;
public int threadPoolSize = 8;
/**
* Can logger write message to standard output(System.out).
* Because standard output won't write to latest.log after Forge 1.17,
* printing to standard output is meaningless,
* which makes this switch default value is <code>false</code>.
* @since 14.15
*/
public boolean enableLogStdOut = false;
//Profile Cache
public int cacheExpiry = 30;
public boolean forceUpdateSkull = false;
public boolean enableLocalProfileCache = false;
//Network Cache
public boolean enableCacheAutoClean = false;
public boolean forceDisableCache = false;
// Used by Gson to create an instance with default value.
public Config() {
this(new ArrayList<>());
}
//Init config
public Config(List<SkinSiteProfile> loadlist) {
this.version = CustomSkinLoader.CustomSkinLoader_VERSION;
this.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
this.loadlist = loadlist;
}
public static Config loadConfig0() {
Config config = loadConfig();
//LoadList null checker
if (config.loadlist == null) {
config.loadlist = new ArrayList<>();
} else {
for (int i = 0; i < config.loadlist.size(); i++) {
if (config.loadlist.get(i) == null)
config.loadlist.remove(i--);
}
}
//Init program
config.loadExtraList();
config.updateLoadlist();
config.initLocalFolder();
config.threadPoolSize = Math.max(config.threadPoolSize, 2);
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
try {
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
CustomSkinLoader.logger.info("Successfully cleaned cache.");
} catch (Exception e) {
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: " + e);
}
}
//Check config version
Version configVersion = Version.of(config.version);
if (CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER == 0 // Custom builds
|| configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0
|| config.buildNumber < CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER) {
CustomSkinLoader.logger.info("Config File is out of date: " + config.version +
", build number: " + config.buildNumber);
config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
config.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
}
writeConfig(config, true);
//Output config
for (Field field : config.getClass().getDeclaredFields()) {
try {
Object value = field.get(config);
CustomSkinLoader.logger.info(field.getName() + " : " + value);
} catch (Exception ignored) {
}
}
return config;
}
private static Config loadConfig() {
CustomSkinLoader.logger.info("Config File: " + CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
if (!CustomSkinLoader.CONFIG_FILE.exists()) {
CustomSkinLoader.logger.info("Config file not found, use default instead.");
return initConfig();
}
try {
CustomSkinLoader.logger.info("Try to load config.");
String json = FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
Config config = Objects.requireNonNull(CustomSkinLoader.GSON.fromJson(json, Config.class));
CustomSkinLoader.logger.info("Successfully load config.");
return config;
} catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load config, use default instead.(" + e + ")");
createBrokenFile(CustomSkinLoader.CONFIG_FILE);
return initConfig();
}
}
private void loadExtraList() {
File listAddition = new File(CustomSkinLoader.DATA_DIR, "ExtraList");
if (!listAddition.isDirectory()) {
listAddition.mkdirs();
return;
}
List<SkinSiteProfile> adds = new ArrayList<>();
File[] files = listAddition.listFiles();
for (File file : files != null ? files : new File[0]) {
if (!file.getName().toLowerCase().endsWith(".json") && !file.getName().toLowerCase().endsWith(".txt"))
continue;
try {
CustomSkinLoader.logger.info("Try to load Extra List.(" + file.getName() + ")");
String json = FileUtils.readFileToString(file, "UTF-8");
SkinSiteProfile ssp = CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
CustomSkinLoader.logger.info("Successfully load Extra List.");
if (ssp.type != null) {
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if (loader == null) {
CustomSkinLoader.logger.info("Extra List will be ignored: Type '" + ssp.type +
"' is not defined.");
continue;
}
boolean duplicate = false;
for (SkinSiteProfile ssp0 : this.loadlist) {
if (!ssp0.type.equalsIgnoreCase(ssp.type))
continue;
if (loader.compare(ssp0, ssp)) {
duplicate = true;
break;
}
}
if (!duplicate) {
adds.add(ssp);
CustomSkinLoader.logger.info("Successfully apply Extra List.(" + ssp.name + ")");
} else {
CustomSkinLoader.logger.info("Extra List will be ignored: Duplicate.(" + ssp.name + ")");
}
file.delete();
} else {
CustomSkinLoader.logger.info("Extra List is invalid: Type is not defined.(" +
file.getName() + ")");
createBrokenFile(file);
}
} catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load Extra List.(" + e + ")");
createBrokenFile(file);
}
}
if (adds.size() != 0) {
adds.addAll(this.loadlist);
this.loadlist = adds;
}
}
private void updateLoadlist() {
PluginLoader.PLUGINS.stream()
.map(ICustomSkinLoaderPlugin::getDefaultProfiles)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.forEach(profile -> this.loadlist.stream()
.filter(ssp -> profile.getName().equals(ssp.name))
.forEach(profile::updateSkinSiteProfile));
}
private void initLocalFolder() {
for (SkinSiteProfile ssp : this.loadlist) {
if (ssp.type == null)
continue;
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if (loader == null)
continue;
loader.init(ssp);
}
}
private static void createBrokenFile(File file) {
try {
File brokenFile = new File(file.getParentFile(), file.getName() + ".broken");
if (brokenFile.exists()) {
brokenFile.delete();
}
file.renameTo(brokenFile);
} catch (Exception e) {
CustomSkinLoader.logger.warning("Failed to create broken file. (" + file.getName() + ")");
CustomSkinLoader.logger.warning(e);
}
}
// The config file does not exist or was broken.
private static Config initConfig() {
List<ICustomSkinLoaderPlugin.IDefaultProfile> profiles = new ArrayList<>();
for (ICustomSkinLoaderPlugin plugin : PluginLoader.PLUGINS) {
List<ICustomSkinLoaderPlugin.IDefaultProfile> defaultProfiles = plugin.getDefaultProfiles();
if (defaultProfiles != null) {
profiles.addAll(defaultProfiles);
}
}
profiles.sort(Comparator.comparingInt(ICustomSkinLoaderPlugin.IDefaultProfile::getPriority));
List<SkinSiteProfile> loadlist = new ArrayList<>();
for (ICustomSkinLoaderPlugin.IDefaultProfile profile : profiles) {
SkinSiteProfile ssp = new SkinSiteProfile();
ssp.name = profile.getName();
profile.updateSkinSiteProfile(ssp);
loadlist.add(ssp);
}
Config config = new Config(loadlist);
writeConfig(config, false);
return config;
}
private static void writeConfig(Config config, boolean update) {
String json = CustomSkinLoader.GSON.toJson(config);
if (CustomSkinLoader.CONFIG_FILE.exists())
CustomSkinLoader.CONFIG_FILE.delete();
try {
CustomSkinLoader.CONFIG_FILE.createNewFile();
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
CustomSkinLoader.logger.info("Successfully " + (update ? "update" : "create") + " config.");
} catch (Exception e) {
CustomSkinLoader.logger.info("Failed to " + (update ? "update" : "create") + " config.(" + e + ")");
}
}
}
@@ -0,0 +1,44 @@
package customskinloader.config;
import java.lang.reflect.Field;
public class SkinSiteProfile {
//Common
public String name;
public String type;
public String userAgent;
//Mojang API
public String apiRoot;
public String sessionRoot;
//Json API
public String root;
//Legacy
public Boolean checkPNG;//Not suitable for local skin
public String skin;
public String model;
public String cape;
public String elytra;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("{ ");
Field[] fields = SkinSiteProfile.class.getDeclaredFields();
boolean first = true;
for (Field field : fields) {
try {
Object value = field.get(this);
if (value == null) continue;
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append("\"").append(field.getName()).append("\": \"").append(value).append("\"");
} catch (Exception ignored) { }
}
return sb.append(" }").toString();
}
}
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff. Show more