Compare commits

..
55 Commits
Author SHA1 Message Date
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
168 changed files with 2336 additions and 2295 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Telegram
url: https://t.me/customskinloader
about: Gugugu
- name: QQ
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
about: Gugugu
+124
View File
@@ -0,0 +1,124 @@
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
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
+125
View File
@@ -0,0 +1,125 @@
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
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
+1 -1
View File
@@ -7,7 +7,7 @@ on:
jobs:
build-beta:
name: Build Beta
uses: xfl03/MCCustomSkinLoader/.github/workflows/common.yml@14-develop
uses: ./.github/workflows/common.yml
with:
type: Beta
publish-task: uploadBeta
+1 -1
View File
@@ -7,7 +7,7 @@ on:
jobs:
build-canary:
name: Build Canary
uses: xfl03/MCCustomSkinLoader/.github/workflows/common.yml@15-develop
uses: ./.github/workflows/common.yml
with:
type: Canary
publish-task: uploadCanary
+162 -8
View File
@@ -6,12 +6,16 @@ on:
required: true
type: string
publish-task:
required: true
required: false
type: string
is-snapshot:
required: false
type: boolean
default: true
jobs:
build-common:
name: Build Common
name: Build
runs-on: ubuntu-latest
environment: Build
steps:
@@ -29,23 +33,173 @@ jobs:
name: Build
env:
KEY_PASS: ${{ secrets.KEY_PASS }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
echo Snapshot: $IS_SNAPSHOT
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew clean build --stacktrace
-
name: Publish
uses: actions/upload-artifact@v3
name: Publish to Github Artifact
with:
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
path: build/libs
Upload:
if: inputs.publish-task
needs: build-common
continue-on-error: true
environment: Build
strategy:
matrix:
website: [CurseForge_Modrinth]
modtype: [Fabric,Forge-Active,Forge-Legacy]
include:
-
website: TencentCOS
modtype: All
# -
# website: GitHub-Release
# modtype: All
-
website: GitHub-PreRelease
modtype: All
name: ${{ matrix.website }} (${{ matrix.modtype}})
runs-on: ubuntu-latest
steps:
-
name: Checkout Git Repository
uses: actions/checkout@v3
-
uses: actions/download-artifact@v3
name: Download Artifact Zips
with:
path: build
-
name: Preparation Folder
run: |
rsync -avz "build/$(ls build|grep "CustomSkinLoader")/" build/libs/
ls -lh build
-
if: ${{ matrix.modtype != 'All' }}
name: Checking and setting the environment
id: cslenv
run: |
output="$(ls build/libs | grep -v "sources")"
if [[ "${{ matrix.modtype }}" == "Forge"* ]]; then
modloader="Forge"
path=$(echo ${{ matrix.modtype }} | sed "s#-#/#")
else
modloader=${{ matrix.modtype }}
path=${{ matrix.modtype }}
fi
echo "path=$path" >> $GITHUB_OUTPUT
echo "modloader=$modloader" >> $GITHUB_OUTPUT
echo "filename=$(echo "$output"|grep $(echo ${{ matrix.modtype }}|sed "s#-##") )" >> $GITHUB_OUTPUT
echo "version=$(grep "version=" build.properties | grep -v "#" | sed "s/version=//")" >> $GITHUB_OUTPUT
echo "edition=$(echo ${{ matrix.modtype }} | sed "s/-//")" >> $GITHUB_OUTPUT
echo "minecraft_vers<<EOF" >> $GITHUB_OUTPUT
grep "minecraft_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/minecraft_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "java_vers<<EOF" >> $GITHUB_OUTPUT
grep "java_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/java_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
-
if: startsWith(matrix.website, 'GitHub-')
name: Settings more strings to Environment
id: cslenv-github
run: |
#展开
echo "buildtime=$(TZ=Asia/Shanghai date "+%Y.%m.%d %H:%M")" >> $GITHUB_OUTPUT
echo "pathlist="$(find build/libs -type f|grep -v "sources"|grep -v "json")"" >> $GITHUB_OUTPUT
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Delete
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: CI-Build
deleteOnlyFromDrafts: false
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Set CI-Build Text
run: |
cat > build/ci-build.md << 'EOF'
Build Time / 构建时间 : ${{ steps.cslenv-github.outputs.buildtime }}
自动同步分支 ${{ github.ref_name }} 的代码,以保持最新
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
<br>
[如何使用 / How to uses?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
EOF
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Upload Tag
uses: richardsimko/[email protected]
with:
tag_name: CI-Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Publish
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: CustomSkinLoader CI-Build
tag_name: CI-Build
prerelease: true
body_path: build/ci-build.md
files: build/libs/*
#iles: "${{ steps.cslenv-github.outputs.pathlist }}"
-
if: ${{ matrix.website == 'GitHub-Release' && inputs.type == 'Release' }}
uses: softprops/action-gh-release@v1
name: 【GitHub Release】 Publish
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: CustomSkinLoader ${{ github.ref }}
tag_name: ${{ github.ref }}
#generate_release_notes: true
files: ${{ steps.cslenv-github.outputs.pathlist }}
-
if: ${{ matrix.website == 'TencentCOS' }}
name: 【TencentCOS】 Publish
env:
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew ${{ inputs.publish-task }} --info --stacktrace
# ./gradlew publishGprPublicationToGitHubPackagesRepository
-
uses: actions/upload-artifact@v3
if: ${{ matrix.website == 'CurseForge_Modrinth' && inputs.type == 'Release' }}
name: 【CurseForge & Modrinth】 Publish
uses: Kir-Antipov/[email protected]
with:
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
path: build/libs
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: CustomSkinLoader_${{ steps.cslenv.outputs.edition }}_${{ steps.cslenv.outputs.version }}
version: ${{ steps.cslenv.outputs.version }}-${{ steps.cslenv.outputs.edition }}
version-type: release
loaders: ${{ steps.cslenv.outputs.modloader }}
game-versions: |
${{ steps.cslenv.outputs.minecraft_vers }}
game-version-filter: releases
java: |
${{ steps.cslenv.outputs.java_vers }}
retry-attempts: 2
retry-delay: 10000
fail-mode: fail
files: |
build/libs/${{ steps.cslenv.outputs.filename }}
+17
View File
@@ -0,0 +1,17 @@
name: Pull Request
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- '14-develop'
- '15-develop'
jobs:
build-pull-request:
name: Build Pull Request
uses: ./.github/workflows/common.yml
with:
type: PullRequest
+4 -4
View File
@@ -1,14 +1,14 @@
name: Release
on:
push:
tags:
- '*'
release:
types: [released]
jobs:
build-release:
name: Build Release
uses: xfl03/MCCustomSkinLoader/.github/workflows/common.yml@14-develop
uses: ./.github/workflows/common.yml
with:
type: Release
publish-task: upload
is-snapshot: false
secrets: inherit
+10 -13
View File
@@ -13,7 +13,7 @@ There are the available versions in different environments below:
| | Forge | Fabric |
|:-----------------------:|:-----------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------:|
| Runtime Environment | forge-1.8-11.14.0.1237 ~ 1.13.2-25.0.22<br/> forge-1.13.2-25.0.42 ~ latest | fabric-loader-0.4.3+build.134 ~ latest<br/> Minecraft 18w43b ~ latest<br/> *fabric-api is not required* |
| Development Environment | ForgeGradle-2.1-SNAPSHOT ~ latest<br/> forge-1.8-11.14.3.1503 ~ 1.12.2-14.23.5.2855<br/> forge-1.13.2-25.0.198 ~ latest | fabric-loom-(?) ~ latest<br/> fabric-loader-0.12.0 ~ latest<br/> Minecraft 18w49a ~ latest<br/> *fabric-api is not required* |
| Development Environment | ForgeGradle-2.1-SNAPSHOT ~ latest<br/> forge-1.8-11.14.3.1503 ~ 1.12.2-14.23.5.2860<br/> forge-1.13.2-25.0.198 ~ latest | fabric-loom-(?) ~ latest<br/> fabric-loader-0.12.0 ~ latest<br/> Minecraft 18w49a ~ latest<br/> *fabric-api is not required* |
### Preliminary steps for testing local builds
1. Create a new empty minecraft development environment.
@@ -31,7 +31,7 @@ There are the available versions in different environments below:
Forge 1.17.1 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeActive/${version}
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
```
*`${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually*
*`${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually*
1. Create a pom file in the same folder:
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeLegacy-${version}.pom`
```xml
@@ -40,7 +40,7 @@ There are the available versions in different environments below:
<modelVersion>4.0.0</modelVersion>
<groupId>mods</groupId>
<artifactId>CustomSkinLoader_ForgeLegacy</artifactId>
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
<version>${version}</version>
</project>
```
@@ -51,7 +51,7 @@ There are the available versions in different environments below:
<modelVersion>4.0.0</modelVersion>
<groupId>mods</groupId>
<artifactId>CustomSkinLoader_ForgeActive</artifactId>
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
<version>${version}</version>
</project>
```
@@ -62,7 +62,7 @@ There are the available versions in different environments below:
<modelVersion>4.0.0</modelVersion>
<groupId>mods</groupId>
<artifactId>CustomSkinLoader_Fabric</artifactId>
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
<version>${version}</version>
</project>
```
@@ -71,25 +71,22 @@ There are the available versions in different environments below:
1. Add below contents to `build.gradle`:
```gradle
dependencies {
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00"
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00"
}
minecraft {
clientRunArgs += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker", "--username", "<Your username>"]
}
```
1. Run `./gradlew setupDecompWorkspace eclipse` command.
1. Due to the run configurations which generated by ForgeGradle 2 has not been compatible with IntelliJ IDEA 2020 and above, we recommend to install [Eclipser](https://plugins.jetbrains.com/plugin/7153-eclipser) plugin. It can convert Eclipse run configurations to IDEA. (Right click to `*.launch` file in project folder, then select `Convert with Eclipser`, then a new IDEA run configuration will be created.)
1. For IDEA, open `Run/Debug Configurations` dialog, change classpath of module to the name contains `.main`.
1. Add `--tweakClass customskinloader.forge.ForgeDevTweaker --username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
1. Run `./gradlew setupDecompWorkspace` command.
1. Then you can debug the mod in IDE or through `./gradlew runClient` command.
### For ForgeGradle 3.x ~ 5.x ( forge-1.12.2-14.23.5.2851 ~ latest )
1. Add below contents to `build.gradle`:
```gradle
dependencies {
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
}
minecraft {
@@ -107,7 +104,7 @@ There are the available versions in different environments below:
1. Add below contents to `build.gradle`:
```gradle
dependencies {
modImplementation "mods:CustomSkinLoader_Fabric:14.15-SNAPSHOT-00"
modImplementation "mods:CustomSkinLoader_Fabric:15.0-SNAPSHOT-00"
}
tasks.runClient {
@@ -1,119 +0,0 @@
package customskinloader.loader.jsonapi;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import org.apache.commons.lang3.StringUtils;
public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
public static class LittleSkin extends JsonAPILoader.DefaultProfile {
public LittleSkin(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "LittleSkin"; }
@Override public int getPriority() { return 200; }
@Override public String getRoot() { return "https://littleskin.cn/csl/"; }
}
public static class BlessingSkin extends JsonAPILoader.DefaultProfile {
public BlessingSkin(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "BlessingSkin"; }
@Override public int getPriority() { return 300; }
@Override public String getRoot() { return "https://skin.prinzeugen.net/"; }
}
// // OneSkin has been removed temporarily
// public static class OneSkin extends JsonAPILoader.DefaultProfile {
// public OneSkin(JsonAPILoader loader) { super(loader); }
// @Override public String getName() { return "OneSkin"; }
// @Override public int getPriority() { return 500; }
// @Override public String getRoot() { return "http://fleey.cn/skin/skin_user/skin_json.php/"; }
// }
private static final String TEXTURES="textures/";
private static final String SUFFIX=".json";
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList(new LittleSkin(loader), new BlessingSkin(loader));
}
@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<>();
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()){
ModelManager0.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 static 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,93 +0,0 @@
package customskinloader.loader.jsonapi;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import org.apache.commons.lang3.StringUtils;
public class UniSkinAPI implements JsonAPILoader.IJsonAPI {
public static class SkinMe extends JsonAPILoader.DefaultProfile {
public SkinMe(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "SkinMe"; }
@Override public int getPriority() { return 500; }
@Override public String getRoot() { return "http://www.skinme.cc/uniskin/"; }
}
private static final String TEXTURES="textures/";
private static final String SUFFIX=".json";
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList(new SkinMe(loader));
}
@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){
ModelManager0.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,160 +0,0 @@
package customskinloader.profile;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
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 ConcurrentHashMap<>();
private Map<GameProfile, Map<Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
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();
}
}
@@ -8,7 +8,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
@@ -18,6 +18,8 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.config.Config;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.ProfileLoader;
import customskinloader.log.LogManager;
import customskinloader.log.Logger;
import customskinloader.profile.DynamicSkullManager;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.ProfileCache;
@@ -47,8 +49,7 @@ public class CustomSkinLoader {
private static final ProfileCache profileCache = new ProfileCache();
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
public static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
//Correct thread name in thread pool
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
@@ -69,26 +70,28 @@ public class CustomSkinLoader {
THREAD_POOL.execute(runnable);
}
public static void loadProfileLazily(
GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
public static Object loadProfileLazily(GameProfile gameProfile, Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> function) {
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.");
consumer.accept(Maps.newHashMap());
return;
return function.apply(Maps.newHashMap());
}
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username); // Change Thread Name
if (profileCache.isLoading(credential)) {
profileCache.putLoader(credential, consumer);
profileCache.putLoader(credential, function);
Thread.currentThread().setName(tempName);
return;
return function.apply(Maps.newHashMap());
}
consumer.accept(loadProfile(gameProfile));
Object result = function.apply(loadProfile(gameProfile));
Thread.currentThread().setName(tempName);
profileCache.getLastLoader(credential).ifPresent(c -> loadProfileLazily(gameProfile, c));
Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> func = profileCache.getLastLoader(credential);
if (func != null) {
result = loadProfileLazily(gameProfile, func);
}
return result;
}
//For User Skin
@@ -192,8 +195,7 @@ public class CustomSkinLoader {
}
//For Skull
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(
final GameProfile gameProfile) {
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
String username = gameProfile.getName();
String credential = MinecraftUtil.getCredential(gameProfile);
@@ -224,15 +226,13 @@ public class CustomSkinLoader {
}
private static Logger initLogger() {
Logger logger = new Logger(LOG_FILE);
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("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;
}
@@ -0,0 +1,8 @@
package customskinloader;
/**
* @deprecated From 14.16, use <code>customskinloader.log.Logger</code> instead.
*/
@Deprecated
public class Logger extends customskinloader.log.Logger {
}
@@ -2,11 +2,7 @@ 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 java.util.*;
import customskinloader.CustomSkinLoader;
import customskinloader.loader.ProfileLoader;
@@ -29,9 +25,9 @@ public class Config {
public boolean enableDynamicSkull = true;
public boolean enableTransparentSkin = true;
public boolean forceIgnoreHttpsCertificate = false;
public boolean forceLoadAllTextures = false;
public boolean forceLoadAllTextures = true;
public boolean enableCape = true;
public int threadPoolSize = 3;
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,
@@ -233,7 +229,7 @@ public class Config {
profiles.addAll(defaultProfiles);
}
}
profiles.sort((c1, c2) -> Integer.compare(c1.getPriority(), c2.getPriority()));
profiles.sort(Comparator.comparingInt(ICustomSkinLoaderPlugin.IDefaultProfile::getPriority));
List<SkinSiteProfile> loadlist = new ArrayList<>();
for (ICustomSkinLoaderPlugin.IDefaultProfile profile : profiles) {
@@ -30,14 +30,15 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
image = resetImageFormat(image, 22, 0, 46, 22);
return image;
}
} catch (IOException | NoSuchElementException ignored) { }
} catch (IOException | NoSuchElementException ignored) {
}
return null;
}
private int loaded = 0;
private double ratioX = -1;
private double ratioY = -1;
private ResourceLocation location;
private final ResourceLocation location;
private String type = null;
public FakeCapeBuffer(ResourceLocation location) {
@@ -47,11 +48,19 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
@Override
public FakeImage parseUserSkin(FakeImage image) {
if (image == null) return null;
this.image = image;
if (isOptiFineCape(image)) {
//OptiFine cape should be converted to standard cape
this.image = convertOptiFineCape(image);
//OptiFine cape contains elytra texture
//this.type = "elytra";//But its elytra texture doesn't work
} else {
this.image = image;
}
// When resource packs were changed, the elytra image needs to be reloaded, and here will be entered again
// The first cape which find elytra texture is outdated will reload it
if (this.loaded == loadedGlobal) {
elytraImage = loadElytra(image);
elytraImage = loadElytra(this.image);
}
this.loaded = loadedGlobal;
if (elytraImage != null) {
@@ -126,15 +135,16 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
/**
* Traverse every elytra pixel
* @param predicate the predicate with x and y
* @param returnValue if the condition flag equals the condition, then return this value
*
* @param predicate the predicate with x and y
* @param returnValue if the condition flag equals the condition, then return this value
* @param defaultReturnValue otherwise return this value
*/
private <R> R withElytraPixels(BiPredicate<Integer, Integer> predicate, R returnValue, R defaultReturnValue) {
int startX = (int) Math.ceil(22 * ratioX), endX = (int) Math.ceil(46 * ratioX);
int startY = (int) Math.ceil(0 * ratioY), endY = (int) Math.ceil(22 * ratioY);
int startY = (int) Math.ceil(0 * ratioY), endY = (int) Math.ceil(22 * ratioY);
int excludeX0 = (int) Math.ceil(24 * ratioX), excludeX1 = (int) Math.ceil(44 * ratioX);
int excludeY = (int) Math.ceil(2 * ratioY);
int excludeY = (int) Math.ceil(2 * ratioY);
for (int x = startX; x < endX; ++x) {
for (int y = startY; y < endY; ++y) {
if (y < excludeY && (x < excludeX0 || x >= excludeX1)) continue;
@@ -167,24 +177,27 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
/**
* Scale image
* @param image the image to scale.
*
* @param image the image to scale.
* @param closeOldImage whether close old image
* @param scaleWidth width enlargement ratio
* @param scaleHeight height enlargement ratio
* @param ratioX the ratio of 64 of the old image width
* @param ratioY the ratio of 32 of the old image height
* @param width the width after scaling.
* @param height the height after scaling.
* @param startX the x where start to copy.
* @param startY the y where start to copy.
* @param endX the x where end to copy.
* @param endY the y where end to copy.
* @param scaleWidth width enlargement ratio
* @param scaleHeight height enlargement ratio
* @param ratioX the ratio of 64 of the old image width
* @param ratioY the ratio of 32 of the old image height
* @param width the width after scaling.
* @param height the height after scaling.
* @param startX the x where start to copy.
* @param startY the y where start to copy.
* @param endX the x where end to copy.
* @param endY the y where end to copy.
* @return the image after scaling.
*/
private static FakeImage scaleImage(FakeImage image, boolean closeOldImage, double scaleWidth, double scaleHeight, double ratioX, double ratioY, int width, int height, int startX, int startY, int endX, int endY) {
FakeImage newImage = image.createImage(width, height);
startX = (int) (startX * ratioX); endX = (int) (endX * ratioX);
startY = (int) (startY * ratioY); endY = (int) (endY * ratioY);
startX = (int) (startX * ratioX);
endX = (int) (endX * ratioX);
startY = (int) (startY * ratioY);
endY = (int) (endY * ratioY);
int x0 = (int) (startX * scaleWidth), x1 = (int) ((startX + 1) * scaleWidth), dx0 = x1 - x0;
for (int x = startX; x < endX; ++x) {
@@ -196,12 +209,61 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
newImage.setRGBA(x0 + dx, y0 + dy, rgba);
}
}
y0 = y1; y1 = (int) ((y + 2) * scaleHeight); dy0 = y1 - y0;
y0 = y1;
y1 = (int) ((y + 2) * scaleHeight);
dy0 = y1 - y0;
}
x0 = x1; x1 = (int) ((x + 2) * scaleWidth); dx0 = x1 - x0;
x0 = x1;
x1 = (int) ((x + 2) * scaleWidth);
dx0 = x1 - x0;
}
if (closeOldImage)
image.close();
return newImage;
}
/**
* Judge OptiFine cape.
* OptiFine cape is 46*22 or 92*44 pixels.
* <a href="https://optifine.net/capes/Notch.png">46*22 example</a>
* <a href="https://optifine.net/capes/OptiFineCape.png">92*44 example</a>
*
* @param image cape image
* @return true if is OptiFine cape
* @since 14.16
*/
private static boolean isOptiFineCape(FakeImage image) {
int ratio = image.getWidth() / 46;
return image.getHeight() == 22 * ratio && image.getWidth() == 46 * ratio;
}
/**
* Convert OptiFine cape to standard cape
*
* @param image OptiFine cape image
* @return standard cape image
* @since 14.16
*/
private static FakeImage convertOptiFineCape(FakeImage image) {
int ratio = image.getWidth() / 46;
FakeImage newImage = image.createImage(64 * ratio, 32 * ratio);
copyImageData(image, newImage);
return newImage;
}
/**
* Copy image data to another image
*
* @param from from image
* @param to to image
*/
private static void copyImageData(FakeImage from, FakeImage to) {
int width = Math.min(from.getWidth(), to.getWidth());
int height = Math.min(from.getHeight(), to.getHeight());
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
to.setRGBA(x, y, from.getRGBA(x, y));
}
}
}
}
@@ -8,12 +8,14 @@ import customskinloader.utils.HttpTextureUtil;
import net.minecraft.util.ResourceLocation;
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
private HttpTextureUtil.HttpTextureInfo info;
private final HttpTextureUtil.HttpTextureInfo info;
private final Map<String, String> metadata;
private ResourceLocation resourceLocation;
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
super(url, metadata);
this.info = HttpTextureUtil.toHttpTextureInfo(url);
this.metadata = metadata;
}
public void setResourceLocation(ResourceLocation resourceLocation) {
@@ -29,9 +31,15 @@ public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
return this.info.url;
}
public void setModule(String module) {
if (this.metadata != null) {
this.metadata.put("module", module);
}
}
@Override
public String getHash() {
return this.info.hash;
return this.info.hash == null ? super.getHash() : this.info.hash;
}
public File getCacheFile() {
@@ -2,38 +2,63 @@ package customskinloader.fake;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Iterator;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property;
import customskinloader.CustomSkinLoader;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.MinecraftUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
import net.minecraft.util.ResourceLocation;
public class FakeSkinManager {
private final TextureManager textureManager;
private final static Map<ResourceLocation, MinecraftProfileTexture> MODEL_CACHE = new ConcurrentHashMap<>();
private final Map<ResourceLocation, MinecraftProfileTexture> modelCache = new ConcurrentHashMap<>();
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
this.textureManager = textureManagerInstance;
/**
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
*/
public static void setSkinCacheDir(File skinCacheDirectory) {
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
}
/**
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
*/
public static void setSkinCacheDir(Path skinCacheDirectory) {
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
}
private static CacheLoader<Object, ?> cacheLoader;
/**
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
*/
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
return cacheLoader = loader;
}
/**
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
*/
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey) throws Exception {
return cacheLoader.load(cacheKey);
}
/**
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
*/
public static ResourceLocation setResourceLocation(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
if (profileTexture instanceof FakeMinecraftProfileTexture) {
@@ -43,29 +68,29 @@ public class FakeSkinManager {
}
/**
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
* <p>
* {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture);} -> {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, this.fakeManager.getModelCache(profileTexture, resourcelocation));}
* <p>
*/
public static MinecraftProfileTexture getModelCache(MinecraftProfileTexture profileTexture, FakeSkinManager fakeManager, ResourceLocation location) {
return fakeManager.modelCache.getOrDefault(location, profileTexture);
public static MinecraftProfileTexture getModelCache(MinecraftProfileTexture profileTexture, ResourceLocation location) {
return MODEL_CACHE.getOrDefault(location, profileTexture);
}
/**
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
*/
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, FakeSkinManager fakeManager, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
Object[] params = list.toArray();
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
ResourceLocation resourcelocation = fakeProfileTexture.getResourceLocation();
if (fakeProfileTexture.getResourceLocation() != null) {
params[0] = ((FakeMinecraftProfileTexture) profileTexture).getCacheFile();
params[0] = fakeProfileTexture.getCacheFile();
if (params[params.length - 2] instanceof Boolean) {
params[params.length - 2] = true;
}
params[params.length - 1] = fakeManager.new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture);
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, resourcelocation, fakeProfileTexture);
}
}
return params;
@@ -74,7 +99,7 @@ public class FakeSkinManager {
private final static String KEY = "CustomSkinLoaderInfo";
/**
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinAvailableCallback, boolean)}
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
@@ -82,9 +107,31 @@ public class FakeSkinManager {
// This is a hack.
((Multimap) profile.getProperties()).put(KEY, m);
runnable.run();
return null;
}));
}
/**
* 23w31a+
* Invoked from net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.SkinManager$CacheKey, GameProfile)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object[] loadProfileTextures(ImmutableList<Object> list, GameProfile profile) {
Object[] params = list.toArray();
if (!profile.getProperties().containsKey(SKULL_KEY)) {
final Supplier<?> supplier = (Supplier<?>) params[0];
params[0] = (Supplier<?>) () -> CustomSkinLoader.loadProfileLazily(profile, m -> {
// This is a hack.
((Multimap) profile.getProperties()).put(KEY, m);
return supplier.get();
});
params[1] = CustomSkinLoader.THREAD_POOL;
} else {
params[1] = Minecraft.getMinecraft();
}
return params;
}
/**
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
*/
@@ -106,74 +153,80 @@ public class FakeSkinManager {
}
}
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = CustomSkinLoader.loadProfileFromCache(profile);
for (Iterator<Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture> entry = it.next();
MinecraftProfileTexture texture = entry.getValue();
if (shouldJudgeType(texture)) {
texture = this.modelCache.get(MinecraftUtil.getSkinManager().loadSkin(texture, entry.getKey()));
if (texture == null) { // remove texture if was not loaded before
it.remove();
} else {
map.put(entry.getKey(), texture);
}
}
}
return map;
private final static String SKULL_KEY = "CSL$IsSkull";
/**
* 23w31a+
* Invoked from {@link SkinManager#getInsecureSkin(GameProfile)}
*/
public static void setSkullType(GameProfile profile) {
profile.getProperties().removeAll(SKULL_KEY);
profile.getProperties().put(SKULL_KEY, new Property(SKULL_KEY, "true"));
}
private static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
if (callback != null)
callback.skinAvailable(type, location, texture);
/**
* 23w31a+
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(GameProfile)
*/
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
if (profile.getProperties().containsKey(SKULL_KEY)) {
profile.getProperties().removeAll(SKULL_KEY);
return CustomSkinLoader.loadProfileFromCache(profile);
} else {
return getUserProfile(sessionService, profile, requireSecure);
}
}
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
return CustomSkinLoader.loadProfileFromCache(profile);
}
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
return texture != null && "auto".equals(texture.getMetadata("model"));
}
private class BaseBuffer implements IImageBuffer {
private static class BaseBuffer implements IImageBuffer {
private IImageBuffer buffer;
private SkinManager.SkinAvailableCallback callback;
private MinecraftProfileTexture.Type type;
private ResourceLocation location;
private MinecraftProfileTexture texture;
private final Runnable callback;
private final ResourceLocation location;
private final FakeMinecraftProfileTexture texture;
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
public BaseBuffer(Runnable callback, MinecraftProfileTexture.Type type, ResourceLocation location, FakeMinecraftProfileTexture texture) {
switch (type) {
case SKIN: this.buffer = new FakeSkinBuffer(); break;
case CAPE: this.buffer = new FakeCapeBuffer(location); break;
}
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) {
@Override
public NativeImage func_195786_a(NativeImage image) {
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
}
@Override
public BufferedImage parseUserSkin(BufferedImage image) {
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
}
@Override
public void skinAvailable() {
if (buffer != null) {
buffer.skinAvailable();
if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) {
//Auto judge skin type
Map<String, String> metadata = Maps.newHashMap();
String type = ((FakeSkinBuffer) buffer).judgeType();
metadata.put("model", type);
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
FakeSkinManager.this.modelCache.put(location, texture);
texture.setModule(type);
MODEL_CACHE.put(location, texture);
}
}
FakeSkinManager.makeCallback(callback, type, location, texture);
if (this.callback != null) {
this.callback.run();
}
}
}
}
@@ -0,0 +1,10 @@
package customskinloader.fake.itf;
import net.minecraft.client.renderer.IImageBuffer;
public interface IFakeIImageBuffer extends Runnable {
@Override
default void run() {
((IImageBuffer) this).skinAvailable();
}
}
@@ -4,7 +4,7 @@ import java.io.InputStream;
import net.minecraft.client.resources.IResource;
/** {@link net.minecraft.client.resources.IResource} is no longer an interface since 22w14a */
/** {@link IResource} is no longer an interface since 22w14a */
public interface IFakeIResource {
// 1.13.2 ~ 22w13a
interface V1 {
@@ -22,7 +22,21 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
String toJsonUrl(String root, String username);
String getPayload(SkinSiteProfile ssp);
default String getPayload(SkinSiteProfile ssp) {
return null;
}
/**
* get JSON API payload, which will make a POST request
*
* @param ssp skin site profile
* @param username username
* @return JSON payload
* @since 14.16
*/
default String getPayload(SkinSiteProfile ssp, String username) {
return getPayload(ssp);
}
UserProfile toUserProfile(String root, String json, boolean local);
@@ -93,8 +107,15 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
}
json = IOUtils.toString(Files.newInputStream(jsonFile.toPath()), StandardCharsets.UTF_8);
} else {
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(this.jsonAPI.getPayload(ssp)));
json = responce.content;
try {
HttpRequestUtil.HttpResponce responce = HttpRequestUtil
.makeHttpRequest(new HttpRequestUtil.HttpRequest(jsonUrl).setCacheTime(90)
.setUserAgent(ssp.userAgent).setPayload(this.jsonAPI.getPayload(ssp, username)));
json = responce.content;
} catch (ProfileNotFoundException ignored) {
CustomSkinLoader.logger.info("Profile not found.");
return null;
}
}
if (json == null || json.equals("")) {
CustomSkinLoader.logger.info("Profile not found.");
@@ -135,4 +156,11 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
f.mkdirs();
}
}
/**
* When getting payload, this exception can end skin loading
* @since 14.16
*/
public static class ProfileNotFoundException extends RuntimeException {
}
}
@@ -1,11 +1,11 @@
package customskinloader.loader;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
@@ -24,7 +24,12 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
@Override
public List<IDefaultProfile> getDefaultProfiles() {
return Collections.singletonList(new LocalSkin(this));
return Lists.newArrayList(new LocalSkin(this),
getCapeProfile(this, "OptiFine", "https://optifine.net/capes/{USERNAME}.png", 810),
getCapeProfile(this, "CloakPlus", "http://161.35.130.99/capes/{USERNAME}.png", 840),
getCapeProfile(this, "LabyMod", "https://dl.labymod.net/capes/{STANDARD_UUID}", 850),
getCapeProfile(this, "Cosmetica", "https://api.cosmetica.cc/get/cloak?username={USERNAME}&uuid={STANDARD_UUID}&nothirdparty", 860)
);
}
public abstract static class DefaultProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
@@ -75,7 +80,7 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
@Override
public int getPriority() {
return 600;
return 710;
}
@Override
@@ -94,18 +99,48 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
}
}
// // Minecrack could not load skin correctly
// public static class Minecrack extends LegacyLoader.DefaultProfile {
// public Minecrack(LegacyLoader loader) { super(loader); }
// @Override public String getName() { return "Minecrack"; }
// @Override public int getPriority() { return 600; }
// @Override public String getSkinRoot() { return "http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png"; }
// @Override public String getCapeRoot() { return "http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png"; }
// @Override public String getElytraRoot() { return null; }
// }
/**
* Get cape Profile¬
*
* @since 14.16
*/
public static LegacyLoader.DefaultProfile getCapeProfile(LegacyLoader loader, String name, String capeRoot, int priority) {
return new DefaultProfile(loader) {
@Override
public String getSkinRoot() {
return null;
}
@Override
public String getCapeRoot() {
return capeRoot;
}
@Override
public String getElytraRoot() {
return null;
}
@Override
public String getName() {
return name;
}
@Override
public int getPriority() {
return priority;
}
};
}
public static final String USERNAME_PLACEHOLDER = "{USERNAME}";
public static final String UUID_PLACEHOLDER = "{UUID}";
/**
* Mojang UUID with -
*
* @since 14.16
*/
public static final String STANDARD_UUID_PLACEHOLDER = "{STANDARD_UUID}";
@Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
@@ -187,14 +222,15 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
private String expandURL(String url, String username) {
String t = url.replace(USERNAME_PLACEHOLDER, username);
if (!t.contains(UUID_PLACEHOLDER)) {
if (!t.contains(UUID_PLACEHOLDER) && !t.contains(STANDARD_UUID_PLACEHOLDER)) {
return t;
}
String uuid = MojangAPILoader.getMojangUuidByUsername(username);
String uuid = MojangAPILoader.getMojangUuidByUsername(username, true);
//If Mojang uuid not found, won't load the texture
if (uuid == null) {
return null;
}
return t.replace(UUID_PLACEHOLDER, uuid);
String styledUuid = uuid.replace("-", "");
return t.replace(UUID_PLACEHOLDER, styledUuid).replace(STANDARD_UUID_PLACEHOLDER, uuid);
}
}
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -24,7 +25,7 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpRequestUtil;
import org.apache.commons.codec.Charsets;
import customskinloader.utils.TextureUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
@@ -93,7 +94,7 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
return ModelManager0.toUserProfile(map);
}
String username = gameProfile.getName();
GameProfile newGameProfile = loadGameProfile(ssp.apiRoot, username);
GameProfile newGameProfile = loadGameProfileCached(ssp.apiRoot, username);
if (newGameProfile == null) {
CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)");
return null;
@@ -108,15 +109,18 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
return null;
}
private static final Map<String, GameProfile> gameProfileCache = new ConcurrentHashMap<>();
public static GameProfile loadGameProfileCached(String apiRoot, String username) {
return gameProfileCache.computeIfAbsent(apiRoot + " " + username, ignored -> loadGameProfile(apiRoot, username));
}
//Username -> UUID
public static GameProfile loadGameProfile(String apiRoot, String username) {
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft")
.setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username)))
);
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft").setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username))));
if (StringUtils.isEmpty(responce.content)) {
return null;
}
@@ -137,33 +141,30 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
* Get Mojang UUID by username.
*
* @param username username to query
* @param standard if - in UUID
* @return UUID in Mojang API style string. Returns {@code null} if username not found in Mojang API.
*/
public static String getMojangUuidByUsername(String username) {
GameProfile profile = loadGameProfile(getMojangApiRoot(), username);
public static String getMojangUuidByUsername(String username, boolean standard) {
GameProfile profile = loadGameProfileCached(getMojangApiRoot(), username);
if (profile == null) {
return null;
}
return UUIDTypeAdapter.fromUUID(profile.getId());
UUID id = profile.getId();
return standard ? id.toString() : TextureUtil.fromUUID(id);
}
//UUID -> Profile
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/"
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.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();
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());
GameProfile newGameProfile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(propertiesResponce), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(propertiesResponce));
newGameProfile.getProperties().putAll(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(propertiesResponce));
return newGameProfile;
}
@@ -176,23 +177,23 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
if (textureProperty == null) {
return Maps.newHashMap();
}
String value = textureProperty.getValue();
String value = TextureUtil.AuthlibField.PROPERTY_VALUE_FIELD.get(textureProperty);
if (StringUtils.isBlank(value)) {
return Maps.newHashMap();
}
String json = new String(Base64.decodeBase64(value), StandardCharsets.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) {
if (result == null || TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result) == null) {
return Maps.newHashMap();
}
return result.getTextures();
return TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) ||
(!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) || (!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
}
@Override
@@ -0,0 +1,144 @@
package customskinloader.loader.jsonapi;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import customskinloader.CustomSkinLoader;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import org.apache.commons.lang3.StringUtils;
public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
public static class LittleSkin extends JsonAPILoader.DefaultProfile {
public LittleSkin(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "LittleSkin";
}
@Override
public int getPriority() {
return 200;
}
@Override
public String getRoot() {
return "https://littleskin.cn/csl/";
}
}
public static class BlessingSkin extends JsonAPILoader.DefaultProfile {
public BlessingSkin(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "BlessingSkin";
}
@Override
public int getPriority() {
return 300;
}
@Override
public String getRoot() {
return "https://skin.prinzeugen.net/";
}
}
// // OneSkin has been removed temporarily
// public static class OneSkin extends JsonAPILoader.DefaultProfile {
// public OneSkin(JsonAPILoader loader) { super(loader); }
// @Override public String getName() { return "OneSkin"; }
// @Override public int getPriority() { return 500; }
// @Override public String getRoot() { return "http://fleey.cn/skin/skin_user/skin_json.php/"; }
// }
private static final String TEXTURES = "textures/";
private static final String SUFFIX = ".json";
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList(new LittleSkin(loader), new BlessingSkin(loader));
}
@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<>();
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()) {
ModelManager0.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 static 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 getName() {
return "CustomSkinAPI";
}
}
@@ -7,7 +7,6 @@ import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
@@ -16,17 +15,45 @@ import customskinloader.profile.UserProfile;
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
public static class ElyBy extends JsonAPILoader.DefaultProfile {
public ElyBy(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "ElyBy"; }
@Override public int getPriority() { return 400; }
@Override public String getRoot() { return "http://skinsystem.ely.by/textures/"; }
public ElyBy(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "ElyBy";
}
@Override
public int getPriority() {
return 400;
}
@Override
public String getRoot() {
return "http://skinsystem.ely.by/textures/";
}
}
public static class TLauncher extends JsonAPILoader.DefaultProfile {
public TLauncher(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "TLauncher"; }
@Override public int getPriority() { return 550; }
@Override public String getRoot() { return "https://auth.tlauncher.org/skin/profile/texture/login/"; }
public TLauncher(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "TLauncher";
}
@Override
public int getPriority() {
return 550;
}
@Override
public String getRoot() {
return "https://auth.tlauncher.org/skin/profile/texture/login/";
}
}
@Override
@@ -41,15 +68,11 @@ public class ElyByAPI implements JsonAPILoader.IJsonAPI {
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>() { }.getType());
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>() {
}.getType());
return ModelManager0.toUserProfile(result);
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "ElyByAPI";
@@ -6,7 +6,6 @@ import java.util.Map;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
@@ -15,10 +14,24 @@ import customskinloader.profile.UserProfile;
public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
public static class GlitchlessGames extends JsonAPILoader.DefaultProfile {
public GlitchlessGames(JsonAPILoader loader) { super(loader); }
@Override public String getName() { return "GlitchlessGames"; }
@Override public int getPriority() { return 700; }
@Override public String getRoot() { return "https://games.glitchless.ru/api/minecraft/users/profiles/textures/?nickname="; }
public GlitchlessGames(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "GlitchlessGames";
}
@Override
public int getPriority() {
return 700;
}
@Override
public String getRoot() {
return "https://games.glitchless.ru/api/minecraft/users/profiles/textures/?nickname=";
}
}
@Override
@@ -40,11 +53,6 @@ public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
return ModelManager0.toUserProfile(result.textures);
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "GlitchlessAPI";
@@ -2,22 +2,14 @@ package customskinloader.loader.jsonapi;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.CustomSkinLoader;
import customskinloader.Logger;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.loader.MojangAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import customskinloader.utils.TextureUtil;
import java.io.File;
import java.util.List;
import java.util.Map;
public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
@@ -38,7 +30,7 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
@Override
public String getRoot() {
return "https://minecraftcapes.net/profile/";
return "https://api.minecraftcapes.net/profile/";
}
}
@@ -49,7 +41,7 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
@Override
public String toJsonUrl(String root, String username) {
String uuid = MojangAPILoader.getMojangUuidByUsername(username);
String uuid = MojangAPILoader.getMojangUuidByUsername(username, false);
//If uuid cannot be found, we won't load profile in this API.
if (uuid == null) {
return null;
@@ -65,32 +57,12 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
return null;
}
String capeBase64 = result.textures.cape;
byte[] capeBytes = Base64.decodeBase64(capeBase64);
String hash = HttpTextureUtil.getHash(capeBytes);
File cacheFile = HttpTextureUtil.getCacheFile(hash);
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
//Save base64 image to cache file
try {
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
} catch (Exception e) {
CustomSkinLoader.logger.warning("Error parsing base64 image: " + capeBase64);
return null;
}
UserProfile profile = new UserProfile();
profile.capeUrl = fakeUrl;
profile.capeUrl = TextureUtil.parseBase64Texture(result.textures.cape);
return profile;
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "MinecraftCapesAPI";
@@ -0,0 +1,105 @@
package customskinloader.loader.jsonapi;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import customskinloader.CustomSkinLoader;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import org.apache.commons.lang3.StringUtils;
public class UniSkinAPI implements JsonAPILoader.IJsonAPI {
public static class SkinMe extends JsonAPILoader.DefaultProfile {
public SkinMe(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "SkinMe";
}
@Override
public int getPriority() {
return 500;
}
@Override
public String getRoot() {
return "http://www.skinme.cc/uniskin/";
}
}
private static final String TEXTURES = "textures/";
private static final String SUFFIX = ".json";
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList(new SkinMe(loader));
}
@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) {
ModelManager0.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
* <a href="https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22">Source Code</a>
*
* @author RecursiveG
*/
private static 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 getName() {
return "UniSkinAPI";
}
}
@@ -0,0 +1,110 @@
package customskinloader.loader.jsonapi;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.loader.MojangAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.profile.UserProfile;
import customskinloader.utils.TextureUtil;
import java.util.List;
/**
* Wynntils cape API
* <a href="https://wynntils.com/">Home</a>
* Test player: Cael
*
* @since 14.16
*/
public class WynntilsAPI implements JsonAPILoader.IJsonAPI {
public static class Wynntils extends JsonAPILoader.DefaultProfile {
public Wynntils(JsonAPILoader loader) {
super(loader);
}
@Override
public String getName() {
return "Wynntils";
}
@Override
public int getPriority() {
return 820;
}
@Override
public String getRoot() {
return "https://athena.wynntils.com/user/getInfo";
}
}
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList(new Wynntils(loader));
}
@Override
public String toJsonUrl(String root, String username) {
return root;
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
WynntilsApiResponse result = new Gson().fromJson(json, WynntilsApiResponse.class);
if (result.user == null || result.user.cosmetics == null || result.user.cosmetics.texture == null) {
return null;
}
UserProfile profile = new UserProfile();
String fakeUrl = TextureUtil.parseBase64Texture(result.user.cosmetics.texture);
if (result.user.cosmetics.hasCape) {
profile.capeUrl = fakeUrl;
} else if (result.user.cosmetics.hasElytra) {
profile.elytraUrl = fakeUrl;
} else {
CustomSkinLoader.logger.warning("Illegal response found in Wynntils");
return null;
}
return profile;
}
@Override
public String getPayload(SkinSiteProfile ssp, String username) {
WynntilsApiRequest req = new WynntilsApiRequest();
req.uuid = MojangAPILoader.getMojangUuidByUsername(username, true);
if (req.uuid == null) {
throw new JsonAPILoader.ProfileNotFoundException();
}
return new Gson().toJson(req);
}
@Override
public String getName() {
return "WynntilsAPI";
}
public static class WynntilsApiRequest {
public String uuid;
}
public static class WynntilsApiResponse {
public User user;
public static class User {
public String accountType;
public Cosmetics cosmetics;
public static class Cosmetics {
public boolean hasCape;
public boolean hasElytra;
public boolean hasEars;
public String texture;
}
}
}
}
@@ -0,0 +1,44 @@
package customskinloader.log;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @since 14.16
*/
public class LogManager {
private static Path logFile;
private static Writer logWriter;
private static final Map<String, Logger> loggers = new ConcurrentHashMap<>();
public static void setLogFile(Path logFile) {
//Not updated
if (logFile == null || logFile.equals(LogManager.logFile)) {
return;
}
LogManager.logFile = logFile;
try {
//Close previous writer
if (logWriter != null) {
logWriter.close();
}
//Set new writer
Files.createDirectories(logFile.getParent());
logWriter = Files.newBufferedWriter(logFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE);
loggers.forEach((k, v) -> v.setWriter(logWriter));
} catch (Exception e) {
e.printStackTrace();
}
}
public static Logger getLogger(String loggerName) {
return loggers.computeIfAbsent(loggerName,
it -> new Logger(logWriter, "CustomSkinLoader " + loggerName));
}
}
@@ -1,15 +1,18 @@
package customskinloader;
package customskinloader.log;
import java.io.BufferedWriter;
import java.io.File;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.annotation.Nullable;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* the Logger
* Moved from <code>customskinloader.Logger</code>
*
* @since 14.16
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Logger {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -47,7 +50,11 @@ public class Logger {
}
}
private BufferedWriter writer = null;
private Writer writer = null;
public void setWriter(Writer writer) {
this.writer = writer;
}
public Logger() {
//Logger isn't created.
@@ -58,6 +65,16 @@ public class Logger {
}
public Logger(File logFile) {
this(logFile, "Unknown");
}
/**
* Create Logger with File
*
* @since 14.16
*/
public Logger(File logFile, String loggerName) {
this.loggerName = loggerName;
try {
if (!logFile.getParentFile().exists()) {
logFile.getParentFile().mkdirs();
@@ -75,6 +92,23 @@ public class Logger {
}
}
/**
* Create Logger with special Writer
*
* @since 14.16
*/
public Logger(@Nullable Writer writer, String loggerName) {
this.loggerName = loggerName;
this.writer = writer;
}
/**
* Logger name in log
*
* @since 14.16
*/
String loggerName;
public void close() {
if (writer != null) {
try {
@@ -102,7 +136,8 @@ public class Logger {
}
//Format, print and write
String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
String sb = String.format("[%s] [%s/%s] [%s]: %s",
DATE_FORMAT.format(new Date()), Thread.currentThread().getName(), level.getName(), loggerName, msg);
if (canPrintToStdOut(level)) {
System.out.println(sb);
}
@@ -110,8 +145,8 @@ public class Logger {
return;
}
try {
String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
writer.write(sb2);
String sb2 = String.format("%s\r\n", sb);
writer.write(sb2);//Writer.write has lock
writer.flush();
} catch (Exception e) {
e.printStackTrace();
@@ -24,7 +24,8 @@ public class PluginLoader {
new JsonAPILoader(new UniSkinAPI()),
new JsonAPILoader(new ElyByAPI()),
new JsonAPILoader(new GlitchlessAPI()),
new JsonAPILoader(new MinecraftCapesAPI())
new JsonAPILoader(new MinecraftCapesAPI()),
new JsonAPILoader(new WynntilsAPI()),
};
public static final ArrayList<ICustomSkinLoaderPlugin> PLUGINS = loadPlugins();
@@ -0,0 +1,157 @@
package customskinloader.profile;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
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.properties.Property;
import com.mojang.util.UUIDTypeAdapter;
import customskinloader.CustomSkinLoader;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0;
import customskinloader.utils.TextureUtil;
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;
public class DynamicSkullManager {
public static class SkullTexture {
public Map<MinecraftProfileTexture.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 ConcurrentHashMap<>();
private Map<GameProfile, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
private List<GameProfile> loadingList = Lists.newArrayList();
private void parseGameProfile(GameProfile profile) {
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
if (textureProperty == null) {
staticTextures.put(profile, Maps.newHashMap());
return;
}
String value = TextureUtil.AuthlibField.PROPERTY_VALUE_FIELD.get(textureProperty);
if (StringUtils.isBlank(value)) {
staticTextures.put(profile, Maps.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.newHashMap());
return;
}
staticTextures.put(profile, (result.textures == null || !result.textures.containsKey(MinecraftProfileTexture.Type.SKIN)) ? Maps.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
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.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<MinecraftProfileTexture.Type, MinecraftProfileTexture> parseTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
MinecraftProfileTexture skin = textures.get(MinecraftProfileTexture.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(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
return textures;
}
public Map<MinecraftProfileTexture.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<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
map.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
return map;
}
loadingList.add(profile);
Thread loadThread = new Thread(() -> {
parseGameProfile(profile);//Load in thread
loadingList.remove(profile);
});
loadThread.setName("Skull " + profile.hashCode());
loadThread.start();
return Maps.newHashMap();
}
}
@@ -3,10 +3,9 @@ package customskinloader.profile;
import java.io.File;
import java.util.Deque;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.function.Consumer;
import java.util.function.Function;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.CustomSkinLoader;
@@ -18,7 +17,7 @@ public class ProfileCache {
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
private Map<String, Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>>> profileLoaders = new ConcurrentHashMap<>();
private Map<String, Deque<Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?>>> profileLoaders = new ConcurrentHashMap<>();
@SuppressWarnings("ResultOfMethodCallIgnored")
public ProfileCache(){
@@ -53,12 +52,12 @@ public class ProfileCache {
return localProfiles.get(username.toLowerCase());
return loadLocalProfile(username);
}
public Optional<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> getLastLoader(String username) {
Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> deque = this.profileLoaders.get(username);
public Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> getLastLoader(String username) {
Deque<Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?>> deque = this.profileLoaders.get(username);
if (deque != null) {
return Optional.ofNullable(deque.pollLast());
return deque.pollLast();
}
return Optional.empty();
return null;
}
public void setLoading(String username,boolean loading){
@@ -75,7 +74,7 @@ public class ProfileCache {
return;
saveLocalProfile(username,profile);
}
public void putLoader(String username, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> loader) {
public void putLoader(String username, Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> loader) {
this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>());
this.profileLoaders.get(username).offerLast(loader);
}
@@ -161,6 +161,7 @@ public class HttpRequestUtil {
}
if (StringUtils.isNotEmpty(request.payload)) {
CustomSkinLoader.logger.info("Payload: " + request.payload);
c.setRequestMethod("POST");
c.setRequestProperty("Content-Type", "application/json");
c.setDoOutput(true);
OutputStream os = c.getOutputStream();
@@ -0,0 +1,73 @@
package customskinloader.utils;
import java.io.File;
import java.lang.reflect.Field;
import java.util.UUID;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
import customskinloader.CustomSkinLoader;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
public class TextureUtil {
/**
* Save and get fake url of base64 texture
*
* @param base64 texture in base64 string
* @return base64 fake url
* @since 14.16
*/
public static String parseBase64Texture(String base64) {
byte[] capeBytes = Base64.decodeBase64(base64);
String hash = HttpTextureUtil.getHash(capeBytes);
File cacheFile = HttpTextureUtil.getCacheFile(hash);
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
//Save base64 image to cache file
try {
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
return fakeUrl;
} catch (Exception e) {
CustomSkinLoader.logger.warning("Error parsing base64 image: " + base64);
return null;
}
}
// Some of the classes in Authlib used after Minecraft 23w31a were changed to record classes,
// resulting in changes to method names, so reflection is used here to be compatible with these changes.
public enum AuthlibField {
PROPERTY_VALUE_FIELD(Property.class, "value"),
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID(MinecraftProfilePropertiesResponse.class, "id"),
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME(MinecraftProfilePropertiesResponse.class, "name"),
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES(MinecraftProfilePropertiesResponse.class, "properties"),
MINECRAFT_TEXTURES_PAYLOAD_TEXTURES(MinecraftTexturesPayload.class, "textures");
private final Field field;
AuthlibField(Class<?> clazz, String name) {
try {
this.field = clazz.getDeclaredField(name);
this.field.setAccessible(true);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
@SuppressWarnings("unchecked")
public <T> T get(Object o) {
try {
return (T) this.field.get(o);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
}
public static String fromUUID(UUID value) {
return value.toString().replace("-", "");
}
}
@@ -2,17 +2,13 @@ package net.minecraft.client.renderer;
import java.awt.image.BufferedImage;
import customskinloader.fake.itf.IFakeIImageBuffer;
import net.minecraft.client.renderer.texture.NativeImage;
public interface IImageBuffer extends Runnable {
public interface IImageBuffer extends IFakeIImageBuffer {
BufferedImage parseUserSkin(BufferedImage image);
NativeImage func_195786_a(NativeImage image);
void skinAvailable();
@Override
default void run() {
this.skinAvailable();
}
}
File renamed without changes.
File renamed without changes.
+5 -5
View File
@@ -15,7 +15,6 @@ net/minecraft/client/Minecraft net/minecraft/class_310
getSkinManager ()Lnet/minecraft/client/resources/SkinManager; method_1582
getTextureManager ()Lnet/minecraft/client/renderer/texture/TextureManager; method_1531
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/class_530
net/minecraft/client/multiplayer/ServerData net/minecraft/class_642
serverIP field_3761
net/minecraft/client/renderer/RenderType net/minecraft/class_1921
@@ -49,12 +48,13 @@ net/minecraft/client/resources/IResourceManager net/minecraft/class_3300
getResource (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/resources/IResource; method_14486
net/minecraft/client/resources/SkinManager net/minecraft/class_1071
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V method_4652
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; method_4651
net/minecraft/client/resources/SkinManager$3 net/minecraft/class_1071$3
field_152801_c field_152801_c
field_152802_d field_152802_d
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; method_4656
net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686
profile ()Lcom/mojang/authlib/GameProfile; comp_1631
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071$class_8687
net/minecraft/resources/IResource net/minecraft/class_3298
net/minecraft/resources/IResourceManager net/minecraft/class_3300
net/minecraft/util/ResourceLocation net/minecraft/class_2960
+19 -12
View File
@@ -1,16 +1,9 @@
jar {
exclude 'customskinloader/tweaker/**'
exclude 'net/minecraft/client/renderer/RenderType.class'
exclude 'net/minecraft/client/renderer/texture/**'
exclude 'net/minecraft/client/resources/**'
exclude 'net/minecraft/resources/**'
exclude 'Profile.json'
}
sourceJar {
exclude 'customskinloader/tweaker/**'
exclude 'net/**'
exclude 'Profile.json'
}
repositories {
@@ -18,6 +11,10 @@ repositories {
name = "fabric"
url = "https://maven.fabricmc.net/"
}
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public/"
}
}
dependencies {
@@ -29,7 +26,18 @@ import customskinloader.gradle.util.RemapUtil
import customskinloader.gradle.util.SourceUtil
import groovy.json.JsonSlurper
SourceUtil.addDependencies project, project(":Common"), project(":Vanilla/Common")
apply plugin: 'org.spongepowered.mixin'
apply from: rootProject.file("buildSrc/patch.gradle")
patchMixin()
mixin {
add sourceSets.main, "mixins.customskinloader.refmap.json"
reobfSrgFile = "build/mixin.srg"
reobfNotchSrgFile = "build/mixin.srg"
}
SourceUtil.addDependencies project, project(":Common")
RemapUtil.remapSources project
// Resolve snapshot versions
@@ -49,11 +57,10 @@ tasks.publishModrinth.doFirst {
// https://github.com/MinecraftForge/ForgeGradle/blob/fc67182a61926f0bdb0d12da5fba7f4322f64d86/src/main/java/net/minecraftforge/gradle/common/BasePlugin.java#L229
jsonSlurper.parse(plugin.cacheFile("McManifest.json")).versions.each { version ->
if (version.type == "snapshot") {
// If the first version is a snapshot, assume the target release version is the same as the assets version.
// If the first version is a snapshot, since Mojang no longer provides the target version for snapshots,
// we assume that new snapshots will not be supported until the next release.
if (currentRelease == null) {
currentRelease = jsonSlurper.parse(new URL(version.url)).assets.with {
it.toString().split($/\./$).with { "${it[0]}.${it[1]}" }
}
return
}
} else if (version.type == "release") {
currentRelease = version.id.with {
+2 -2
View File
@@ -1,6 +1,6 @@
minecraft_version=1.14
minecraft_full_versions=1.14-Snapshot,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15-Snapshot,1.15,1.15.1,1.15.2,1.16-Snapshot,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17-Snapshot,1.17,1.17.1,1.18-Snapshot,1.18,1.18.1,1.18.2,1.19-Snapshot,1.19,1.19.1,1.19.2,1.19.3
java_full_versions=8,9,10,11,12,13,14,15,16,17,18
minecraft_full_versions=1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21
#forge gradle needs forge version
forge_mc_version=1.12.2
forge_version=14.23.5.2768
+14 -12
View File
@@ -2,20 +2,17 @@ com/mojang/blaze3d/matrix/MatrixStack net/minecraft/class_4587
net/minecraft/client/Minecraft net/minecraft/class_310
isIntegratedServerRunning ()Z method_1542
net/minecraft/client/entity/AbstractClientPlayer net/minecraft/class_742
getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; method_3120
getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; method_3124
net/minecraft/client/gui/Gui net/minecraft/class_332
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/class_530
renderPlayerlist (Lnet/minecraft/client/gui/Gui;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V method_1919
net/minecraft/client/model/ModelRenderer net/minecraft/class_630
net/minecraft/client/renderer/IImageBuffer net/minecraft/class_760
net/minecraft/client/renderer/IRenderTypeBuffer net/minecraft/class_4597
net/minecraft/client/renderer/RenderType net/minecraft/class_1921
getEntitySolid (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType; method_23572
net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/class_1046
bufferedImage field_110560_d
textureUploaded field_5215
processTask field_20843
loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; method_22795
processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; method_22798
@@ -27,20 +24,25 @@ net/minecraft/client/renderer/entity/layers/LayerCape net/minecraft/class_972
doRenderLayer (Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V method_4177
net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011
net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060
net/minecraft/client/resources/PlayerSkin net/minecraft/class_8685
net/minecraft/client/resources/SkinManager net/minecraft/class_1071
func_210275_a (Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4653
func_229297_b_ (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655
func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V method_4655
getInsecureSkin (Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin; method_52862
getOrLoad (Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture; method_52863
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V method_4652
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; method_4651
loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; method_4654
net/minecraft/client/resources/SkinManager$3 net/minecraft/class_1071$3
run ()V run
net/minecraft/client/resources/SkinManager$3$1 net/minecraft/class_1071$3$1
field_152803_a field_152803_a
field_152804_b field_152804_b
run ()V run
net/minecraft/client/resources/SkinManager$1 net/minecraft/class_1071$1
lambda$load$0 (Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo; method_52867
load (Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture; method_52868
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/class_1071$class_8686
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/class_1071$class_8687
type field_45641
registerTexture (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture; method_52873
net/minecraft/client/resources/SkinManager$TextureInfo net/minecraft/class_1071$class_8688
net/minecraft/scoreboard/ScoreObjective net/minecraft/class_266
net/minecraft/scoreboard/Scoreboard net/minecraft/class_269
net/minecraft/util/ResourceLocation net/minecraft/class_2960
@@ -35,13 +35,6 @@ public class DevEnvRemapper extends SimpleRemapper {
Lists.newArrayList("customskinloader.fake.itf.FakeInterfaceManager")
)
);
remappedClasses.put(
"net.minecraft.class_1060",
new AbstractMap.SimpleEntry<>(
Lists.newArrayList("customskinloader.fake.itf.IFakeTextureManager$V1", "customskinloader.fake.itf.IFakeTextureManager$V2"),
Lists.newArrayList("customskinloader.fake.itf.FakeInterfaceManager")
)
);
remappedClasses.put(
"net.minecraft.class_3298",
new AbstractMap.SimpleEntry<>(
@@ -1,27 +1,28 @@
package customskinloader.fabric;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Paths;
import java.util.List;
import java.util.Set;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import customskinloader.Logger;
import customskinloader.log.LogManager;
import customskinloader.log.Logger;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
public class MixinConfigPlugin implements IMixinConfigPlugin {
public static Logger logger = new Logger(new File("./CustomSkinLoader/FabricPlugin.log"));
public static Logger logger = LogManager.getLogger("Fabric");
private long world_version;
private long protocol_version;
@Override
public void onLoad(String mixinPackage) {
LogManager.setLogFile(Paths.get("./CustomSkinLoader/CustomSkinLoader.log"));
URL versionJson = this.getClass().getResource("/version.json");
if (versionJson != null) {
logger.info("\"version.json\": " + versionJson.toString());
@@ -54,13 +55,17 @@ public class MixinConfigPlugin implements IMixinConfigPlugin {
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
boolean result = true;
if (mixinClassName.endsWith(".MixinThreadDownloadImageDataV2")) {
result = (this.world_version >= 2205 && this.world_version <= 2722) && ((this.protocol_version >= 554 && this.protocol_version <= 754) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x40000022)); // 19w38a ~ 1.17-rc1
} else if (mixinClassName.endsWith(".MixinSkinManager$V2")) {
result = this.world_version >= 2205 && this.protocol_version >= 554; // 19w38a+
if (mixinClassName.endsWith(".MixinIImageBuffer")) {
result = this.world_version <= 2204 && this.protocol_version <= 553; // 18w43b ~ 19w37a
} else if (mixinClassName.endsWith(".MixinLayerCape") || mixinClassName.endsWith(".MixinRenderPlayer")) {
result = this.world_version >= 2210 && this.protocol_version >= 558; // 19w41a+
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageDataV3")) {
} else if (mixinClassName.endsWith(".MixinSkinManager$V1")) {
result = this.world_version <= 3465 && (this.protocol_version <= 763 || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x4000008E)); // 18w43b ~ 1.20.1
} else if (mixinClassName.endsWith(".MixinSkinManager$V2") || mixinClassName.endsWith(".MixinSkinManager$1") || mixinClassName.endsWith(".MixinSkinManager$TextureCache")) {
result = this.world_version >= 3567 && ((this.protocol_version > 763 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000090); // 23w31a+
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V1")) {
result = (this.world_version >= 2205 && this.world_version <= 2722) && ((this.protocol_version >= 554 && this.protocol_version <= 754) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x40000022)); // 19w38a ~ 1.17-rc1
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V2")) {
result = this.world_version >= 2723 && ((this.protocol_version >= 755 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000023); // 1.17-rc2+
}
logger.info("target: " + targetClassName + ", mixin: " + mixinClassName + ", result: " + result);
@@ -11,8 +11,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public abstract class MixinGuiPlayerTabOverlay {
@Redirect(
method = {
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V",
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V"
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V", // 20w16a-
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V", // 20w17a ~ 23w14a
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(Lnet/minecraft/client/gui/Gui;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V" // 23w16a+
},
at = @At(
value = "INVOKE",
@@ -0,0 +1,10 @@
package customskinloader.mixin;
import customskinloader.fake.itf.IFakeIImageBuffer;
import net.minecraft.client.renderer.IImageBuffer;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(IImageBuffer.class)
public interface MixinIImageBuffer extends IFakeIImageBuffer {
}
@@ -0,0 +1,47 @@
package customskinloader.mixin;
import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import customskinloader.fake.FakeSkinManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.resources.SkinManager$1;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
@Mixin(SkinManager$1.class)
public abstract class MixinSkinManager$1 {
@ModifyArgs(
method = "Lnet/minecraft/client/resources/SkinManager$1;load(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;",
remap = false
)
)
private void modifyArgs_load(Args args, SkinManager.CacheKey cacheKey) {
Object[] argsArr = new Object[args.size()];
for (int i = 0; i < argsArr.length; i++) {
argsArr[i] = args.get(i);
}
args.setAll(FakeSkinManager.loadProfileTextures(ImmutableList.copyOf(argsArr), cacheKey.profile()));
}
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager$1;lambda$load$0(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;getTextures(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;",
remap = false
)
)
private static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> redirect_lambda$load$0(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
return FakeSkinManager.loadSkinFromCache(sessionService, profile, requireSecure);
}
}
@@ -0,0 +1,47 @@
package customskinloader.mixin;
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.fake.FakeSkinManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
@Mixin(SkinManager.TextureCache.class)
public abstract class MixinSkinManager$TextureCache {
@Shadow
private MinecraftProfileTexture.Type type;
@ModifyVariable(
method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;",
at = @At(
value = "STORE",
ordinal = 0
),
ordinal = 0
)
private ResourceLocation modifyVariable_registerTexture(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
return FakeSkinManager.setResourceLocation(resourceLocation, profileTexture);
}
@ModifyArgs(
method = "Lnet/minecraft/client/resources/SkinManager$TextureCache;registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;ZLjava/lang/Runnable;)V"
)
)
private void modifyArgs_registerTexture(Args args, MinecraftProfileTexture profileTexture) {
Object[] argsArr = new Object[args.size()];
for (int i = 0; i < argsArr.length; i++) {
argsArr[i] = args.get(i);
}
argsArr = FakeSkinManager.createThreadDownloadImageData(ImmutableList.copyOf(argsArr), profileTexture, this.type);
args.setAll(argsArr);
}
}
@@ -0,0 +1,257 @@
package customskinloader.mixin;
import java.io.File;
import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import customskinloader.fake.FakeSkinManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
@SuppressWarnings("target")
public abstract class MixinSkinManager {
// 18w43b ~ 1.20.1
@Mixin(SkinManager.class)
public abstract static class V1 {
@Inject(
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V",
at = @At("RETURN")
)
private void inject_init(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService, CallbackInfo callbackInfo) {
FakeSkinManager.setSkinCacheDir(skinCacheDirectory);
}
@ModifyVariable(
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
at = @At(
value = "STORE",
ordinal = 0
),
ordinal = 0
)
private ResourceLocation modifyVariable_loadSkin(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
return FakeSkinManager.setResourceLocation(resourceLocation, profileTexture);
}
@ModifyArg(
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;skinAvailable(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V"
)
)
private MinecraftProfileTexture modifyArg_loadSkin(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
return FakeSkinManager.getModelCache(profileTexture, location);
}
// 18w43b ~ 19w37a
@Group(
name = "modifyArgs_loadSkin",
min = 1
)
@ModifyArgs(
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/IImageBuffer;)V"
)
)
private void modifyArgs_loadSkin_0(Args args, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
Object[] argsArr = new Object[args.size()];
for (int i = 0; i < argsArr.length; i++) {
argsArr[i] = args.get(i);
}
argsArr = FakeSkinManager.createThreadDownloadImageData(ImmutableList.copyOf(argsArr), profileTexture, textureType);
args.setAll(argsArr);
}
// 19w38a ~ 1.20.1
@Group(
name = "modifyArgs_loadSkin",
min = 1
)
@ModifyArgs(
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;<init>(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;ZLjava/lang/Runnable;)V"
)
)
private void modifyArgs_loadSkin_1(Args args, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
this.modifyArgs_loadSkin_0(args, profileTexture, textureType, skinAvailableCallback);
}
// 18w43b ~ 19w37a
@Group(
name = "redirect_loadProfileTextures",
min = 1
)
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/ExecutorService;submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;",
remap = false
)
)
private Future<?> redirect_loadProfileTextures_0(ExecutorService executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
FakeSkinManager.loadProfileTextures(task, profile);
return null;
}
// 19w38a ~ 1.18-exp7
@Group(
name = "redirect_loadProfileTextures",
min = 1
)
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/Executor;execute(Ljava/lang/Runnable;)V",
remap = false
)
)
private void redirect_loadProfileTextures_1(Executor executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
FakeSkinManager.loadProfileTextures(task, profile);
}
// 21w37a ~ 1.20.1
@Group(
name = "redirect_loadProfileTextures",
min = 1
)
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/ExecutorService;execute(Ljava/lang/Runnable;)V",
remap = false
)
)
private void redirect_loadProfileTextures_2(ExecutorService executor, Runnable task, GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
FakeSkinManager.loadProfileTextures(task, profile);
}
@Inject(
method = "Lnet/minecraft/client/resources/SkinManager;loadSkinFromCache(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;",
at = @At("HEAD"),
cancellable = true
)
private void inject_loadSkinFromCache(GameProfile profile, CallbackInfoReturnable<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> callbackInfoReturnable) {
callbackInfoReturnable.setReturnValue(FakeSkinManager.loadSkinFromCache(profile));
}
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;func_210275_a(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;getTextures(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;",
remap = false
)
)
private Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> redirect_func_210275_a(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
return FakeSkinManager.getUserProfile(sessionService, profile, requireSecure);
}
// 18w43b ~ 19w37a
@Group(
name = "loadElytraTexture",
min = 1
)
@Inject(
method = "Lnet/minecraft/client/resources/SkinManager;func_210276_a(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
at = @At(
value = "INVOKE",
target = "Ljava/util/Map;containsKey(Ljava/lang/Object;)Z",
ordinal = 0,
remap = false
)
)
private void inject_func_210276_a(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback, CallbackInfo callbackInfo) {
FakeSkinManager.loadElytraTexture((SkinManager) (Object) this, map, skinAvailableCallback);
}
// 19w38a ~ 1.20.1
@Group(
name = "loadElytraTexture",
min = 1
)
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;func_210276_a(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V",
at = @At(
value = "INVOKE",
target = "Lcom/google/common/collect/ImmutableList;of(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;",
remap = false
)
)
private ImmutableList<MinecraftProfileTexture.Type> redirect_func_229297_b_(Object e1, Object e2) {
return ImmutableList.copyOf(MinecraftProfileTexture.Type.values());
}
}
// 23w31a+
@Mixin(SkinManager.class)
public abstract static class V2 {
@Inject(
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V",
at = @At("RETURN")
)
private void inject_init(TextureManager textureManager, Path path, MinecraftSessionService minecraftSessionService, Executor executor, CallbackInfo callbackInfo) {
FakeSkinManager.setSkinCacheDir(path);
}
@ModifyArg(
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V",
at = @At(
value = "INVOKE",
target = "Lcom/google/common/cache/CacheBuilder;build(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;",
remap = false
)
)
private CacheLoader<Object, ?> modifyArg_init(CacheLoader<Object, ?> cacheLoader) {
return FakeSkinManager.setCacheLoader(cacheLoader);
}
@Inject(
method = "Lnet/minecraft/client/resources/SkinManager;getInsecureSkin(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin;",
at = @At("HEAD")
)
private void inject_getInsecureSkin(GameProfile profile, CallbackInfoReturnable<?> callbackInfoReturnable) {
FakeSkinManager.setSkullType(profile);
}
@Redirect(
method = "Lnet/minecraft/client/resources/SkinManager;getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;",
at = @At(
value = "INVOKE",
target = "Lcom/google/common/cache/LoadingCache;getUnchecked(Ljava/lang/Object;)Ljava/lang/Object;",
remap = false
)
)
private Object redirect_getOrLoad(LoadingCache<?, ?> loadingCache, Object cacheKey) throws Exception {
return FakeSkinManager.loadCache(loadingCache, cacheKey);
}
}
}
@@ -0,0 +1,57 @@
package customskinloader.mixin;
import customskinloader.fake.FakeSkinBuffer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.NativeImage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@SuppressWarnings("target")
public abstract class MixinThreadDownloadImageData {
@Mixin(ThreadDownloadImageData.class) // 19w38a ~ 1.17-rc1
public abstract static class V1 {
@Final
@Shadow
private Runnable processTask;
@Shadow
private static NativeImage processLegacySkin(NativeImage nativeImageIn) {
return null;
}
@Redirect(
method = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;loadTexture(Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;processLegacySkin(Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;"
)
)
private NativeImage redirect_loadTexture(NativeImage image) {
return FakeSkinBuffer.processLegacySkin(image, this.processTask, MixinThreadDownloadImageData.V1::processLegacySkin);
}
}
@Mixin(ThreadDownloadImageData.class) // 1.17-rc2+
public abstract static class V2 {
@Final
@Shadow
private Runnable processTask;
@Shadow
abstract NativeImage processLegacySkin(NativeImage nativeImageIn);
@Redirect(
method = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;loadTexture(Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;processLegacySkin(Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;"
)
)
private NativeImage redirect_loadTexture(ThreadDownloadImageData _this, NativeImage image) {
return FakeSkinBuffer.processLegacySkin(image, this.processTask, this::processLegacySkin);
}
}
}
@@ -0,0 +1,4 @@
package net.minecraft.client.resources;
public class SkinManager$1 {
}
@@ -0,0 +1,32 @@
package net.minecraft.client.resources;
import java.io.File;
import java.util.Map;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
public class SkinManager {
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) { }
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) { return null; }
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final MinecraftProfileTexture.Type textureType, final SkinManager.SkinAvailableCallback skinAvailableCallback) { return null; }
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) { }
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) { return null; }
public interface SkinAvailableCallback {
void skinAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
}
public static class TextureCache {
}
public static class CacheKey {
public GameProfile profile() {
return null;
}
}
}
File renamed without changes.
@@ -4,16 +4,18 @@
"package": "customskinloader.mixin",
"client": [
"MixinGuiPlayerTabOverlay",
"MixinIImageBuffer",
"MixinIResource",
"MixinIResourceManager",
"MixinLayerCape",
"MixinMinecraft",
"MixinRenderPlayer",
"MixinSkinManager",
"MixinSkinManager$1",
"MixinSkinManager$TextureCache",
"MixinSkinManager$V1",
"MixinSkinManager$V2",
"MixinThreadDownloadImageDataV2",
"MixinThreadDownloadImageDataV3"
"MixinThreadDownloadImageData$V1",
"MixinThreadDownloadImageData$V2"
],
"refmap": "mixins.customskinloader.refmap.json",
"plugin": "customskinloader.fabric.MixinConfigPlugin",
+4 -4
View File
@@ -15,7 +15,6 @@ net/minecraft/client/Minecraft net/minecraft/client/Minecraft
getSkinManager ()Lnet/minecraft/client/resources/SkinManager; m_91109_
getTextureManager ()Lnet/minecraft/client/renderer/texture/TextureManager; m_91097_
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/client/gui/components/PlayerTabOverlay
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/client/gui/spectator/PlayerMenuItem
net/minecraft/client/multiplayer/ServerData net/minecraft/client/multiplayer/ServerData
serverIP f_105363_
net/minecraft/client/renderer/RenderType net/minecraft/client/renderer/RenderType
@@ -50,11 +49,12 @@ net/minecraft/client/resources/IResourceManager net/minecraft/server/packs/resou
net/minecraft/client/resources/SkinManager net/minecraft/client/resources/SkinManager
loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V m_118817_
loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; m_118825_
net/minecraft/client/resources/SkinManager$3 net/minecraft/client/resources/SkinManager$3
field_152801_c field_152801_c
field_152802_d field_152802_d
net/minecraft/client/resources/SkinManager$1 net/minecraft/client/resources/SkinManager$1
net/minecraft/client/resources/SkinManager$CacheKey net/minecraft/client/resources/SkinManager$CacheKey
profile ()Lcom/mojang/authlib/GameProfile; f_290972_
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/client/resources/SkinManager$SkinTextureCallback
skinAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V m_118856_
net/minecraft/client/resources/SkinManager$TextureCache net/minecraft/client/resources/SkinManager$TextureCache
net/minecraft/resources/IResource net/minecraft/server/packs/resources/Resource
net/minecraft/resources/IResourceManager net/minecraft/server/packs/resources/ResourceManager
net/minecraft/util/ResourceLocation net/minecraft/resources/ResourceLocation
-3
View File
@@ -6,10 +6,7 @@ jar {
])
}
exclude 'net/minecraft/client/renderer/RenderType.class'
exclude 'net/minecraft/client/renderer/texture/**'
exclude 'net/minecraft/client/resources/**'
exclude 'net/minecraft/resources/**'
}
sourceJar {
exclude 'com/**'
+2 -2
View File
@@ -1,6 +1,6 @@
minecraft_version=1.17.1
minecraft_full_versions=1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3
java_full_versions=16,17,18
minecraft_full_versions=1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2
java_full_versions=16,17,18,19,20,21
#forge gradle needs forge version
forge_mc_version=1.12.2
forge_version=14.23.5.2768
@@ -35,27 +35,26 @@ function initializeCoreMod() {
'name': 'net/minecraft/client/resources/SkinManager'
},
'transformer': function (cn) {
cn.fields.removeIf(function (fn) {
return fn.name.equals("fakeManager") && fn.desc.equals("Lcustomskinloader/fake/FakeSkinManager;");
});
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
cn.methods.forEach(function (mn) {
if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")) {
if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")) { // 1.20.1-
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.RETURN) {
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 3));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESPECIAL, "customskinloader/fake/FakeSkinManager", "<init>", "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/io/File;)V", false));
}
}
} else if (checkName(mn.name, "m_118828_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/ResourceLocation;")) {
} else if (checkName(mn.name, "<init>") && mn.desc.equals("(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/nio/file/Path;Lcom/mojang/authlib/minecraft/MinecraftSessionService;Ljava/util/concurrent/Executor;)V")) { // 1.20.2+
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.RETURN) {
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkinCacheDir", "(Ljava/nio/file/Path;)V", false));
} else if (node.getOpcode() === Opcodes.INVOKEVIRTUAL && node.owner.equals("com/google/common/cache/CacheBuilder") && checkName(node.name, "build") && node.desc.equals("(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;")) {
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setCacheLoader", "(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/CacheLoader;", false));
}
}
} else if (checkName(mn.name, "m_118828_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/ResourceLocation;")) { // 1.20.1-
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if ((node.getOpcode() === Opcodes.INVOKESPECIAL && node.owner.equals("net/minecraft/resources/ResourceLocation") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/lang/String;)V")) // 1.19-
@@ -65,10 +64,8 @@ function initializeCoreMod() {
}
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("net/minecraft/client/resources/SkinManager$SkinTextureCallback") && checkName(node.name, "onSkinTextureAvailable") && node.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V")) {
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 5));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcustomskinloader/fake/FakeSkinManager;Lnet/minecraft/resources/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "getModelCache", "(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lnet/minecraft/resources/ResourceLocation;)Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;", false));
}
if (node.getOpcode() === Opcodes.INVOKESPECIAL && (node.owner.equals("net/minecraft/client/renderer/texture/HttpTexture") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/resources/ResourceLocation;ZLjava/lang/Runnable;)V"))) {
@@ -81,12 +78,9 @@ function initializeCoreMod() {
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 3));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcustomskinloader/fake/FakeSkinManager;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)[Ljava/lang/Object;", false));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)[Ljava/lang/Object;", false));
for (var i = 0; i < args.length; i++) {
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
@@ -102,7 +96,7 @@ function initializeCoreMod() {
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
}
}
} else if (checkName(mn.name, "m_118817_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V")) {
} else if (checkName(mn.name, "m_118817_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V")) { // 1.20.1-
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKEINTERFACE
@@ -114,7 +108,7 @@ function initializeCoreMod() {
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Ljava/lang/Runnable;Lcom/mojang/authlib/GameProfile;)V", false));
}
}
} else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) {
} else if (checkName(mn.name, "m_118821_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "getTextures") && node.desc.equals("(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;")) {
@@ -122,7 +116,7 @@ function initializeCoreMod() {
break;
}
}
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) {
} else if (checkName(mn.name, "m_174849_") && mn.desc.equals("(Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V")) { // 1.20.1-
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("com/google/common/collect/ImmutableList") && checkName(node.name, "of") && node.desc.equals("(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;")) {
@@ -131,13 +125,64 @@ function initializeCoreMod() {
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "copyOf", "([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;"))
}
}
} else if (checkName(mn.name, "m_118815_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")) {
} else if (checkName(mn.name, "m_118815_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")) { // 1.20.1-
var first = mn.instructions.getFirst();
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.insertBefore(first, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
mn.instructions.insertBefore(first, new InsnNode(Opcodes.ARETURN));
} else if (checkName(mn.name, "m_293307_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/PlayerSkin;")) { // 1.20.2+
var first = mn.instructions.getFirst();
mn.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setSkullType", "(Lcom/mojang/authlib/GameProfile;)V", false));
} else if (checkName(mn.name, "m_293351_") && mn.desc.equals("(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;")) { // 1.20.2+
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/google/common/cache/LoadingCache") && checkName(node.name, "getUnchecked") && node.desc.equals("(Ljava/lang/Object;)Ljava/lang/Object;")) {
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadCache", "(Lcom/google/common/cache/LoadingCache;Ljava/lang/Object;)Ljava/lang/Object;", false));
}
}
}
});
return cn;
}
},
'SkinManager$1Transformer': { // 1.20.2+
'target': {
'type': 'CLASS',
'name': 'net/minecraft/client/resources/SkinManager$1'
},
'transformer': function (cn) {
cn.methods.forEach(function (mn) {
if (checkName(mn.name, "load") && mn.desc.equals("(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;")) {
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKESTATIC && node.owner.equals("java/util/concurrent/CompletableFuture") && checkName(node.name, "supplyAsync") && node.desc.equals("(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) {
var s = "(";
var args = Type.getType(node.desc).getArgumentTypes();
for (var i = 0; i < args.length; i++) {
s = s + "Ljava/lang/Object;";
}
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/resources/SkinManager$CacheKey", mapName("f_290972_"), "()Lcom/mojang/authlib/GameProfile;", false));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadProfileTextures", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/GameProfile;)[Ljava/lang/Object;", false));
for (var i = 0; i < args.length; i++) {
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.AALOAD));
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, args[i].getInternalName()));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
}
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
}
}
} else if (checkName(mn.name, "m_293645_") && mn.desc.equals("(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;")) {
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKEINTERFACE && node.owner.equals("com/mojang/authlib/minecraft/MinecraftSessionService") && checkName(node.name, "getTextures") && node.desc.equals("(Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;")) {
mn.instructions.set(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache", "(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;Z)Ljava/util/Map;", false));
}
}
}
});
return cn;
@@ -197,6 +242,51 @@ function initializeCoreMod() {
}
},
'SkinManager$TextureCacheTransformer': { // 1.20.2+
'target': {
'type': 'METHOD',
'class': 'net/minecraft/client/resources/SkinManager$TextureCache',
'methodName': 'm_294542_',
'methodDesc': '(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;'
},
'transformer': function (mn) {
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
var node = iterator.next();
if (node.getOpcode() === Opcodes.INVOKEVIRTUAL && node.owner.equals("net/minecraft/client/resources/SkinManager$TextureCache") && checkName(node.name, "m_293729_") && node.desc.equals("(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;")) {
mn.instructions.insert(node, node = new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insert(node, node = new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "setResourceLocation", "(Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Lnet/minecraft/resources/ResourceLocation;", false));
} else if (node.getOpcode() === Opcodes.INVOKESPECIAL && (node.owner.equals("net/minecraft/client/renderer/texture/HttpTexture") && checkName(node.name, "<init>") && node.desc.equals("(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/resources/ResourceLocation;ZLjava/lang/Runnable;)V"))) {
var s = "(";
var args = Type.getType(node.desc).getArgumentTypes();
for (var i = 0; i < args.length; i++) {
s = s + "Ljava/lang/Object;";
}
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/google/common/collect/ImmutableList", "of", s + ")Lcom/google/common/collect/ImmutableList;", false));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager$TextureCache", mapName("f_291290_"), "Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;"));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinManager", "createThreadDownloadImageData", "(Lcom/google/common/collect/ImmutableList;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)[Ljava/lang/Object;", false));
for (var i = 0; i < args.length; i++) {
mn.instructions.insertBefore(node, new InsnNode(Opcodes.DUP));
mn.instructions.insertBefore(node, new IntInsnNode(Opcodes.BIPUSH, i));
mn.instructions.insertBefore(node, new InsnNode(Opcodes.AALOAD));
if (args[i].getInternalName().equals("Z")) {
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Boolean"));
mn.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false));
} else {
mn.instructions.insertBefore(node, new TypeInsnNode(Opcodes.CHECKCAST, args[i].getInternalName()));
}
mn.instructions.insertBefore(node, new InsnNode(Opcodes.SWAP));
}
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
}
}
return mn;
}
},
'HttpTextureTransformer': {
'target': {
'type': 'METHOD',
Loaded 100 of 168 files, more files were not shown because too many files have changed in this diff. Show more