mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
93
Commits
v14.15.2
...
15-develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5830503dfc | ||
|
|
f334a61faa | ||
|
|
873705c4fb | ||
|
|
ebea66d261 | ||
|
|
06832661c0 | ||
|
|
fff855f1b0 | ||
|
|
055cd711b3 | ||
|
|
0212d4d2f1 | ||
|
|
756336e533 | ||
|
|
8b5d440ed7 | ||
|
|
faebfc9bb1 | ||
|
|
08033b0502 | ||
|
|
4cffdc3eb6 | ||
|
|
73beb4c29e | ||
|
|
73c31593f2 | ||
|
|
59a515ba61 | ||
|
|
1f3d19ac6e | ||
|
|
1fbe258365 | ||
|
|
d4cc4740d3 | ||
|
|
d0d71b8557 | ||
|
|
1a15951791 | ||
|
|
a195b42bc4 | ||
|
|
5d2f945d45 | ||
|
|
6bf959de49 | ||
|
|
2f26a07dc9 | ||
|
|
5764d81d6d | ||
|
|
8080aa7ab5 | ||
|
|
4d0ebcc1f7 | ||
|
|
1cb4cf40b0 | ||
|
|
a9b2484b3e | ||
|
|
8e63429293 | ||
|
|
aa68af31e5 | ||
|
|
bab30e4f0a | ||
|
|
571d61118d | ||
|
|
5d3326c333 | ||
|
|
b2095998e5 | ||
|
|
cdf2fbe644 | ||
|
|
fa0f820143 | ||
|
|
23f08a3a64 | ||
|
|
3e4b06f5d1 | ||
|
|
18d31bed8f | ||
|
|
64490f1d18 | ||
|
|
cd1922844c | ||
|
|
4185e5bb5f | ||
|
|
7fd5ff84ee | ||
|
|
d2772697f3 | ||
|
|
0ffa9ef137 | ||
|
|
f4b5954dad | ||
|
|
009895c018 | ||
|
|
c273dc396e | ||
|
|
6cb37301b6 | ||
|
|
e9e1955fad | ||
|
|
933f64b810 | ||
|
|
e839362f09 | ||
|
|
220bddbebb | ||
|
|
00c931d434 | ||
|
|
119892489f | ||
|
|
9a55a4c615 | ||
|
|
1ed98534c9 | ||
|
|
b8ca913848 | ||
|
|
d5ae6226ae | ||
|
|
f274278419 | ||
|
|
f6f043fc7c | ||
|
|
9571e367df | ||
|
|
48efe58d52 | ||
|
|
16520f72a4 | ||
|
|
fd08f65af3 | ||
|
|
83799da6ae | ||
|
|
54d24a2800 | ||
|
|
f2698b4ccf | ||
|
|
4a344ed653 | ||
|
|
7074c8509d | ||
|
|
10950a21ee | ||
|
|
9889e05a81 | ||
|
|
e65ab7a9ea | ||
|
|
a4f30a4bf1 | ||
|
|
68ac9f67df | ||
|
|
647532629e | ||
|
|
71befeb300 | ||
|
|
8db9bf3de6 | ||
|
|
0c9a4033c4 | ||
|
|
d8d955224d | ||
|
|
8c0cdfb7b5 | ||
|
|
919b69aaad | ||
|
|
4de06aae50 | ||
|
|
f3f80a1f00 | ||
|
|
f5b1989453 | ||
|
|
85923855d8 | ||
|
|
755f7647ed | ||
|
|
c2dad72690 | ||
|
|
c8e96c11cd | ||
|
|
32e3e2e5a2 | ||
|
|
b7b5e9d6c8 |
No files matched your search
@@ -2,7 +2,7 @@ blank_issues_enabled: false
|
|||||||
contact_links:
|
contact_links:
|
||||||
- name: Telegram
|
- name: Telegram
|
||||||
url: https://t.me/customskinloader
|
url: https://t.me/customskinloader
|
||||||
about: Gugugu
|
about: Community chat for CustomSkinLoader users.
|
||||||
- name: QQ
|
- name: QQ Group
|
||||||
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
|
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
|
||||||
about: Gugugu
|
about: Chinese community chat for CustomSkinLoader users.
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
name: Report Bug
|
name: Report Bug
|
||||||
description: Report a bug and help us improve CustomSkinLoader
|
description: Report a bug and help us improve CustomSkinLoader
|
||||||
labels: [ bug ]
|
labels: [ bug ]
|
||||||
|
title: "[Bug] "
|
||||||
body:
|
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
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
attributes:
|
attributes:
|
||||||
@@ -18,6 +25,10 @@ body:
|
|||||||
label: Steps to reproduce
|
label: Steps to reproduce
|
||||||
description: How do you trigger this bug?
|
description: How do you trigger this bug?
|
||||||
render: bash
|
render: bash
|
||||||
|
value: |
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
@@ -27,27 +38,55 @@ body:
|
|||||||
description: |
|
description: |
|
||||||
The files are in the folder `<minecraft-directory>/crash-reports`
|
The files are in the folder `<minecraft-directory>/crash-reports`
|
||||||
[Generate URL](https://mclo.gs)
|
[Generate URL](https://mclo.gs)
|
||||||
placeholder: "https://"
|
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||||
- type: input
|
- type: input
|
||||||
id: csl-log
|
id: csl-log
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: Link to CustomSkinLoader.log if applicable
|
label: Link to CustomSkinLoader.log if applicable
|
||||||
description: |
|
description: |
|
||||||
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
|
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||||
[Generate URL](https://mclo.gs)
|
[Generate URL](https://mclo.gs)
|
||||||
placeholder: "https://"
|
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
|
- type: input
|
||||||
id: mod-version
|
id: mod-version
|
||||||
attributes:
|
attributes:
|
||||||
label: Mod Version
|
label: Mod Version
|
||||||
|
placeholder: "Ex: 14.16"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
id: mc-version
|
id: mc-version
|
||||||
attributes:
|
attributes:
|
||||||
label: Minecraft Version
|
label: Minecraft Version
|
||||||
|
placeholder: "Ex: 1.19.4"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
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
|
- type: dropdown
|
||||||
id: loader-type
|
id: loader-type
|
||||||
attributes:
|
attributes:
|
||||||
@@ -56,7 +95,7 @@ body:
|
|||||||
- Quilt
|
- Quilt
|
||||||
- Fabric
|
- Fabric
|
||||||
- Forge
|
- Forge
|
||||||
- <without loader>
|
- <without mod loader>
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
@@ -81,3 +120,7 @@ body:
|
|||||||
- label: |
|
- label: |
|
||||||
This is a valid bug (I am able to reproduce this on the latest dev build).
|
This is a valid bug (I am able to reproduce this on the latest dev build).
|
||||||
required: true
|
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
|
||||||
|
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
name: 提交问题
|
name: 提交问题
|
||||||
description: 报告问题以帮助我们改进CustomSkinLoader
|
description: 报告问题以帮助我们改进CustomSkinLoader
|
||||||
labels: [ bug ]
|
labels: [ bug ]
|
||||||
|
title: "[Bug] "
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
你好,这里是 `CustomSkinLoader`
|
||||||
|
标注红色星号的为必填项
|
||||||
|
以及,保持工单干净整洁,不要直接将日志内容粘贴到工单上,比如粘贴到描述内是不行的
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
attributes:
|
attributes:
|
||||||
@@ -17,6 +24,10 @@ body:
|
|||||||
label: 复现步骤
|
label: 复现步骤
|
||||||
description: 请问你是如何触发这个问题的
|
description: 请问你是如何触发这个问题的
|
||||||
render: bash
|
render: bash
|
||||||
|
value: |
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
@@ -25,26 +36,57 @@ body:
|
|||||||
label: 崩溃报告查看地址
|
label: 崩溃报告查看地址
|
||||||
description: |
|
description: |
|
||||||
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
|
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
|
||||||
|
客户端若无崩溃则直接填写 `客户端无崩溃`
|
||||||
[生成连接](https://mclo.gs)
|
[生成连接](https://mclo.gs)
|
||||||
placeholder: "https://"
|
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||||
- type: input
|
- type: input
|
||||||
id: csl-log
|
id: csl-log
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: CustomSkinLoader.log 查看地址
|
label: CustomSkinLoader.log 查看地址
|
||||||
description: |
|
description: |
|
||||||
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
|
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||||
[生成连接](https://mclo.gs)
|
[生成连接](https://mclo.gs)
|
||||||
placeholder: "https://"
|
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
|
- type: input
|
||||||
id: mod-version
|
id: mod-version
|
||||||
attributes:
|
attributes:
|
||||||
label: 模组版本
|
label: 模组版本
|
||||||
|
placeholder: "示例: 14.16"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
id: mc-version
|
id: mc-version
|
||||||
attributes:
|
attributes:
|
||||||
label: Minecraft游戏版本
|
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:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
@@ -80,3 +122,6 @@ body:
|
|||||||
- label: |
|
- label: |
|
||||||
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
|
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
|
||||||
required: true
|
required: true
|
||||||
|
- label: |
|
||||||
|
这个问题是在最新的mod版本触发(若不是最新的请先升级mod)
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Composite action: setup JDK, build with Gradle, upload artifact
|
||||||
|
name: Build
|
||||||
|
description: Build project with Gradle and upload artifact
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
artifact-name:
|
||||||
|
description: Artifact name for upload
|
||||||
|
required: true
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
mod_name:
|
||||||
|
description: Display name of the mod
|
||||||
|
value: ${{ steps.info.outputs.mod_name }}
|
||||||
|
edition:
|
||||||
|
description: Target mod loader edition
|
||||||
|
value: ${{ steps.info.outputs.edition }}
|
||||||
|
short_version:
|
||||||
|
description: Shortened version identifier
|
||||||
|
value: ${{ steps.info.outputs.short_version }}
|
||||||
|
loaders:
|
||||||
|
description: List of supported mod loaders
|
||||||
|
value: ${{ steps.info.outputs.loaders }}
|
||||||
|
game_versions:
|
||||||
|
description: List of compatible Minecraft game versions
|
||||||
|
value: ${{ steps.info.outputs.game_versions }}
|
||||||
|
java:
|
||||||
|
description: List of compatible Java versions
|
||||||
|
value: ${{ steps.info.outputs.java }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-java@v6
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '25'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Build with Gradle
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }}
|
||||||
|
./gradlew --stop
|
||||||
|
|
||||||
|
- name: Generate metadata JSONs
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
shell: pwsh
|
||||||
|
id: info
|
||||||
|
run: ./.github/scripts/Get-PublishInfo.ps1 -ArtifactDir 'Bootstrap/build/libs' -Type '${{ github.event_name }}'
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: ${{ inputs.artifact-name }}
|
||||||
|
path: Bootstrap/build/libs/
|
||||||
|
if-no-files-found: error
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
name: Publish to Object Storage
|
||||||
|
description: >-
|
||||||
|
Upload build artifacts to an S3-compatible object store (AWS S3, Cloudflare
|
||||||
|
R2, MinIO, etc.). Requires the AWS CLI to be pre-installed on the runner.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
artifact-path:
|
||||||
|
description: Path to the directory containing build artifacts.
|
||||||
|
required: true
|
||||||
|
endpoint-url:
|
||||||
|
description: S3-compatible endpoint URL.
|
||||||
|
required: true
|
||||||
|
bucket:
|
||||||
|
description: S3 bucket name.
|
||||||
|
required: true
|
||||||
|
access-key-id:
|
||||||
|
description: S3-compatible access key ID.
|
||||||
|
required: true
|
||||||
|
secret-access-key:
|
||||||
|
description: S3-compatible secret access key.
|
||||||
|
required: true
|
||||||
|
region:
|
||||||
|
description: AWS region (use 'auto' for Cloudflare R2).
|
||||||
|
required: false
|
||||||
|
default: 'auto'
|
||||||
|
target-path:
|
||||||
|
description: Key prefix in the bucket (e.g., 'mods').
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
files:
|
||||||
|
description: Glob pattern for files to upload.
|
||||||
|
required: false
|
||||||
|
default: '*'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Validate artifact path
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$path = "${{ inputs.artifact-path }}"
|
||||||
|
if (-not (Test-Path -LiteralPath $path)) {
|
||||||
|
throw "Artifact path not found: $path"
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Upload to object storage
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ inputs.access-key-id }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ inputs.secret-access-key }}
|
||||||
|
AWS_DEFAULT_REGION: ${{ inputs.region }}
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
Get-ChildItem -Path "${{ inputs.artifact-path }}" -Filter "${{ inputs.files }}" | ForEach-Object {
|
||||||
|
aws s3 cp "$($_.FullName)" "s3://${{ inputs.bucket }}/${{ inputs.target-path }}$($_.Name)" --endpoint-url "${{ inputs.endpoint-url }}"
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
name: Publish to GitHub Release
|
||||||
|
description: Upload build artifacts to a GitHub Release. Requires contents:write permission at the workflow level.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
artifact-path:
|
||||||
|
description: Path to the directory containing build artifacts.
|
||||||
|
required: true
|
||||||
|
tag-name:
|
||||||
|
description: Git tag for the release.
|
||||||
|
required: true
|
||||||
|
token:
|
||||||
|
description: GitHub token with contents:write permission.
|
||||||
|
required: true
|
||||||
|
files:
|
||||||
|
description: Glob pattern(s) for files to upload (passed to gh release create).
|
||||||
|
required: false
|
||||||
|
default: '*'
|
||||||
|
notes-file:
|
||||||
|
description: Path to file containing release body text.
|
||||||
|
required: false
|
||||||
|
prerelease:
|
||||||
|
description: Mark as a pre-release (true/false).
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
generate-notes:
|
||||||
|
description: Auto-generate release notes from merged commits (true/false).
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Validate artifact path
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$path = "${{ inputs.artifact-path }}"
|
||||||
|
if (-not (Test-Path -LiteralPath $path)) {
|
||||||
|
throw "Artifact path not found: $path"
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ inputs.token }}
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$tag = '${{ inputs.tag-name }}'
|
||||||
|
gh release delete "$tag" --yes --cleanup-tag
|
||||||
|
gh release create "$tag" '${{ inputs.artifact-path }}/${{ inputs.files }}' --title "CustomSkinLoader $tag" `
|
||||||
|
$(if('${{ inputs.prerelease }}' -eq 'true') { '--prerelease' }) `
|
||||||
|
$(if('${{ inputs.notes-file }}') { '--notes-file'; '${{ inputs.notes-file }}' } elseif ('${{ inputs.generate-notes }}' -eq 'true') { '--generate-notes' })
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
param(
|
||||||
|
[string]$ArtifactDir = '',
|
||||||
|
[string]$Type = ''
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
# ---- Output build.info.json to GITHUB_OUTPUT ----
|
||||||
|
$info = Get-Content "build.info.json" -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
|
$info.PSObject.Properties | ForEach-Object {
|
||||||
|
$name = $_.Name
|
||||||
|
$value = $_.Value
|
||||||
|
if ($value -is [array]) {
|
||||||
|
"$name<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||||
|
$value | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||||
|
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||||
|
} else {
|
||||||
|
"$name=$value" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---- Generate metadata JSONs ----
|
||||||
|
if (-not $ArtifactDir) { return }
|
||||||
|
if (-not (Test-Path -LiteralPath $ArtifactDir)) { throw "ArtifactDir not found: $ArtifactDir" }
|
||||||
|
|
||||||
|
$jar = Get-ChildItem -Path $ArtifactDir -Filter "*.jar" | Where-Object { $_.Name -notlike "*-sources.jar" } | Select-Object -First 1
|
||||||
|
if (-not $jar) { throw "No jar found in $ArtifactDir" }
|
||||||
|
$JarFilename = $jar.Name
|
||||||
|
|
||||||
|
$version = $info.mod_version
|
||||||
|
$isSnapshot = ($Type -ne "release")
|
||||||
|
$shortVersion = if ($isSnapshot) { "$version-s$env:GITHUB_RUN_NUMBER" } else { $version }
|
||||||
|
|
||||||
|
"short_version=$shortVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
||||||
|
|
||||||
|
$mcVersionList = $info.game_versions | ForEach-Object {
|
||||||
|
$parts = $_ -split '\.'
|
||||||
|
"$($parts[0]).$($parts[1])"
|
||||||
|
} | Sort-Object -Unique | Sort-Object {
|
||||||
|
$v = $_ -split '\.'
|
||||||
|
[int]$v[0] * 100000 + [int]$v[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
$suffix = if ($isSnapshot) { "-beta" } else { "" }
|
||||||
|
$jarKey = "mods/$JarFilename"
|
||||||
|
$baseUrl = "https://csl.3-3.dev"
|
||||||
|
|
||||||
|
@{
|
||||||
|
version = $shortVersion
|
||||||
|
downloads = @{ Universal = "$baseUrl/$jarKey" }
|
||||||
|
launchermeta = @{}
|
||||||
|
} | ConvertTo-Json -Depth 10 | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline
|
||||||
|
|
||||||
|
$details = [ordered]@{}
|
||||||
|
foreach ($mcVer in $mcVersionList) {
|
||||||
|
$details[$mcVer] = @{
|
||||||
|
Fabric = "$baseUrl/$jarKey"
|
||||||
|
Forge = "$baseUrl/$jarKey"
|
||||||
|
NeoForge = "$baseUrl/$jarKey"
|
||||||
|
Quilt = "$baseUrl/$jarKey"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@{
|
||||||
|
version = $shortVersion
|
||||||
|
timestamp = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
|
||||||
|
details = $details
|
||||||
|
} | ConvertTo-Json -Depth 10 | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline
|
||||||
@@ -1,14 +1,83 @@
|
|||||||
name: Beta
|
name: Beta
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [15-develop]
|
||||||
- '14-develop'
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-beta:
|
build:
|
||||||
name: Build Beta
|
name: Build
|
||||||
uses: ./.github/workflows/common.yml
|
runs-on: windows-latest
|
||||||
with:
|
steps:
|
||||||
type: Beta
|
- uses: actions/checkout@v7
|
||||||
publish-task: uploadBeta
|
|
||||||
secrets: inherit
|
- uses: ./.github/actions/build
|
||||||
|
with:
|
||||||
|
artifact-name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||||
|
|
||||||
|
publish-release:
|
||||||
|
name: Publish to GitHub Release
|
||||||
|
needs: build
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- name: Generate release body
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
@"
|
||||||
|
Build Time / 构建时间 : $((Get-Date).ToUniversalTime().AddHours(8).ToString("yyyy.MM.dd HH:mm"))
|
||||||
|
Auto build from branch $env:GITHUB_REF_NAME
|
||||||
|
|
||||||
|
[How to use?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
|
||||||
|
"@ | Set-Content -Path ci-build-body.md -NoNewline
|
||||||
|
|
||||||
|
- uses: ./.github/actions/publish-release
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
tag-name: CI-Build
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: '*.jar'
|
||||||
|
prerelease: 'true'
|
||||||
|
notes-file: ci-build-body.md
|
||||||
|
|
||||||
|
publish-object-storage:
|
||||||
|
name: Publish to Object Storage
|
||||||
|
needs: build
|
||||||
|
runs-on: windows-latest
|
||||||
|
environment: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- name: Upload jar to R2
|
||||||
|
uses: ./.github/actions/publish-object-storage
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||||
|
bucket: ${{ secrets.R2_BUCKET }}
|
||||||
|
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
target-path: mods/
|
||||||
|
files: '*.jar'
|
||||||
|
|
||||||
|
- name: Upload JSONs to R2
|
||||||
|
uses: ./.github/actions/publish-object-storage
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||||
|
bucket: ${{ secrets.R2_BUCKET }}
|
||||||
|
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
files: '*.json'
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
name: Canary
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '15-develop'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-canary:
|
|
||||||
name: Build Canary
|
|
||||||
uses: ./.github/workflows/common.yml
|
|
||||||
with:
|
|
||||||
type: Canary
|
|
||||||
publish-task: uploadCanary
|
|
||||||
secrets: inherit
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
name: Common
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
type:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
publish-task:
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
is-snapshot:
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-common:
|
|
||||||
name: Build Common
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment: Build
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
-
|
|
||||||
name: Set up JDK
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '8'
|
|
||||||
cache: 'gradle'
|
|
||||||
-
|
|
||||||
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
|
|
||||||
if: ${{ inputs.publish-task }}
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
|
|
||||||
path: build/libs
|
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
name: Pull Request
|
name: Pull Request
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types: [opened, synchronize, reopened]
|
||||||
- opened
|
branches: [15-develop]
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
branches:
|
|
||||||
- '14-develop'
|
|
||||||
- '15-develop'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-pull-request:
|
build:
|
||||||
name: Build Pull Request
|
name: Build
|
||||||
uses: ./.github/workflows/common.yml
|
runs-on: windows-latest
|
||||||
with:
|
steps:
|
||||||
type: PullRequest
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: ./.github/actions/build
|
||||||
|
with:
|
||||||
|
artifact-name: CustomSkinLoader-PR-${{ github.run_number }}
|
||||||
+114
-11
@@ -1,15 +1,118 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
push:
|
release:
|
||||||
tags:
|
types: [released]
|
||||||
- '*'
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release:
|
build:
|
||||||
name: Build Release
|
name: Build
|
||||||
uses: ./.github/workflows/common.yml
|
runs-on: windows-latest
|
||||||
with:
|
outputs:
|
||||||
type: Release
|
mod_name: ${{ steps.build.outputs.mod_name }}
|
||||||
publish-task: upload
|
edition: ${{ steps.build.outputs.edition }}
|
||||||
is-snapshot: false
|
short_version: ${{ steps.build.outputs.short_version }}
|
||||||
secrets: inherit
|
loaders: ${{ steps.build.outputs.loaders }}
|
||||||
|
game_versions: ${{ steps.build.outputs.game_versions }}
|
||||||
|
java: ${{ steps.build.outputs.java }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: ./.github/actions/build
|
||||||
|
id: build
|
||||||
|
with:
|
||||||
|
artifact-name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||||
|
|
||||||
|
publish-release:
|
||||||
|
name: Publish to GitHub Release
|
||||||
|
needs: build
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- uses: ./.github/actions/publish-release
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
tag-name: ${{ github.event.release.tag_name }}
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: '*.jar'
|
||||||
|
generate-notes: 'true'
|
||||||
|
|
||||||
|
publish-object-storage:
|
||||||
|
name: Publish to Object Storage
|
||||||
|
needs: build
|
||||||
|
runs-on: windows-latest
|
||||||
|
environment: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- name: Upload jar to R2
|
||||||
|
uses: ./.github/actions/publish-object-storage
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||||
|
bucket: ${{ secrets.R2_BUCKET }}
|
||||||
|
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
target-path: mods/
|
||||||
|
files: '*.jar'
|
||||||
|
|
||||||
|
- name: Upload JSONs to R2
|
||||||
|
uses: ./.github/actions/publish-object-storage
|
||||||
|
with:
|
||||||
|
artifact-path: artifact
|
||||||
|
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||||
|
bucket: ${{ secrets.R2_BUCKET }}
|
||||||
|
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
files: '*.json'
|
||||||
|
|
||||||
|
publish-mod-sites:
|
||||||
|
name: Publish to Mod Sites
|
||||||
|
needs: build
|
||||||
|
runs-on: windows-latest
|
||||||
|
environment: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- uses: Kir-Antipov/mc-publish@v3
|
||||||
|
with:
|
||||||
|
modrinth-id: idMHQ4n2
|
||||||
|
modrinth-featured: true
|
||||||
|
modrinth-unfeature-mode: subset
|
||||||
|
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
curseforge-id: 286924
|
||||||
|
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||||
|
name: ${{ needs.build.outputs.mod_name }}_${{ needs.build.outputs.edition }}_${{ needs.build.outputs.short_version }}
|
||||||
|
version: ${{ needs.build.outputs.short_version }}-${{ needs.build.outputs.edition }}
|
||||||
|
version-type: release
|
||||||
|
loaders: |
|
||||||
|
${{ needs.build.outputs.loaders }}
|
||||||
|
game-versions: |
|
||||||
|
${{ needs.build.outputs.game_versions }}
|
||||||
|
environment: client
|
||||||
|
game-version-filter: releases
|
||||||
|
java: |
|
||||||
|
${{ needs.build.outputs.java }}
|
||||||
|
retry-attempts: 2
|
||||||
|
retry-delay: 10000
|
||||||
|
fail-mode: fail
|
||||||
|
files: |
|
||||||
|
artifact/*.jar
|
||||||
+34
-29
@@ -1,36 +1,41 @@
|
|||||||
# Java
|
.gradle
|
||||||
*.class
|
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
|
||||||
.mtj.tmp/
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
|
|
||||||
# VSCode
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
# eclipse
|
|
||||||
bin/
|
|
||||||
*/.classpath
|
|
||||||
.classpath
|
|
||||||
*/.project
|
|
||||||
.project
|
|
||||||
.settings/
|
|
||||||
*.launch
|
|
||||||
|
|
||||||
# gradle
|
|
||||||
.gradle/
|
|
||||||
build/
|
build/
|
||||||
logs/
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
run/
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
!.github/actions/build
|
||||||
|
.kotlin
|
||||||
|
|
||||||
# IDEA
|
### IntelliJ IDEA ###
|
||||||
.idea/
|
.idea
|
||||||
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
|
||||||
out/
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
#mac OS
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.ow2.asm:asm:9.9.1'
|
||||||
|
implementation 'org.ow2.asm:asm-commons:9.9.1'
|
||||||
|
implementation 'org.ow2.asm:asm-tree:9.9.1'
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package customskinloader.bootstrap;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public final class BootstrapLogger {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger("CustomSkinLoader Bootstrap");
|
||||||
|
|
||||||
|
private BootstrapLogger() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatPath(Path path) {
|
||||||
|
return path == null ? "<unknown>" : path.toAbsolutePath().normalize().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package customskinloader.bootstrap;
|
||||||
|
|
||||||
|
public final class ModLoaderInfo {
|
||||||
|
public static final String NAME_PROPERTY = "customskinloader.modLoader.name";
|
||||||
|
public static final String VERSION_PROPERTY = "customskinloader.modLoader.version";
|
||||||
|
|
||||||
|
private ModLoaderInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void publish(String name, String version) {
|
||||||
|
if (name == null || name.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Mod loader name must not be empty");
|
||||||
|
}
|
||||||
|
if (version == null || version.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Mod loader version must not be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.setProperty(NAME_PROPERTY, name);
|
||||||
|
System.setProperty(VERSION_PROPERTY, version);
|
||||||
|
BootstrapLogger.LOGGER.info("Detected mod loader " + name + " " + version);
|
||||||
|
}
|
||||||
|
}
|
||||||
+411
@@ -0,0 +1,411 @@
|
|||||||
|
package customskinloader.bootstrap.installer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.mapping.Mappings;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.ClassVisitor;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.FieldVisitor;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
|
||||||
|
final class BytecodeRemapper extends Remapper {
|
||||||
|
private final Map<String, String> classMappings = new HashMap<>();
|
||||||
|
private final Map<String, String> inverseClassMappings = new HashMap<>();
|
||||||
|
private final Map<String, String> fieldMappings = new HashMap<>();
|
||||||
|
private final Map<String, String> methodMappings = new HashMap<>();
|
||||||
|
private final Map<String, ClassInheritance> classInheritance = new HashMap<>();
|
||||||
|
private final Set<String> missingClassInheritance = new HashSet<>();
|
||||||
|
|
||||||
|
BytecodeRemapper(Mappings mappings) {
|
||||||
|
for (Mappings.ClassMapping classMapping : mappings.getClassMappings()) {
|
||||||
|
this.classMappings.put(classMapping.getSourceName(), classMapping.getTargetName());
|
||||||
|
this.inverseClassMappings.put(classMapping.getTargetName(), classMapping.getSourceName());
|
||||||
|
|
||||||
|
for (Mappings.FieldMapping fieldMapping : classMapping.getFieldMappings()) {
|
||||||
|
this.fieldMappings.put(this.fieldKey(classMapping.getSourceName(), fieldMapping.getSourceName()), fieldMapping.getTargetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Mappings.MethodMapping methodMapping : classMapping.getMethodMappings()) {
|
||||||
|
this.methodMappings.put(this.methodKey(classMapping.getSourceName(), methodMapping.getSourceName(), methodMapping.getSourceDescriptor()), methodMapping.getTargetName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClassInheritance(byte[] classBytes) {
|
||||||
|
ClassReader classReader = new ClassReader(classBytes);
|
||||||
|
this.classInheritance.put(classReader.getClassName(), this.readClassInheritance(classReader, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] remapClass(byte[] classBytes) throws Exception {
|
||||||
|
ClassReader classReader = new ClassReader(classBytes);
|
||||||
|
ClassWriter classWriter = new ClassWriter(0);
|
||||||
|
ClassVisitor classRemapper = (ClassVisitor) findClassRemapper().getConstructor(ClassVisitor.class, Remapper.class).newInstance(classWriter, this);
|
||||||
|
classReader.accept(classRemapper, ClassReader.EXPAND_FRAMES);
|
||||||
|
return classWriter.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Class<?> findClassRemapper() throws Exception {
|
||||||
|
try {
|
||||||
|
return Class.forName("org.objectweb.asm.commons.ClassRemapper");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return Class.forName("org.objectweb.asm.commons.RemappingClassAdapter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toClassEntryName(byte[] classBytes) {
|
||||||
|
return new ClassReader(classBytes).getClassName() + ".class";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String map(String internalName) {
|
||||||
|
String mappedName = this.classMappings.get(internalName);
|
||||||
|
return mappedName == null ? internalName : mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String mapFieldName(String owner, String name, String descriptor) {
|
||||||
|
String mappedName = this.fieldMappings.get(this.fieldKey(owner, name));
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasDeclaredField(owner, name, descriptor)) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappedName = this.findInheritedFieldMapping(owner, name, descriptor, new HashSet<>());
|
||||||
|
return mappedName == null ? name : mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String mapMethodName(String owner, String name, String descriptor) {
|
||||||
|
String mappedName = this.methodMappings.get(this.methodKey(owner, name, descriptor));
|
||||||
|
if (mappedName != null || name.charAt(0) == '<') {
|
||||||
|
return mappedName == null ? name : mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer declaredAccess = this.getDeclaredMethodAccess(owner, name, descriptor);
|
||||||
|
if (declaredAccess != null && this.blocksInheritedMethodMapping(declaredAccess)) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappedName = this.findInheritedMethodMapping(owner, name, descriptor, new HashSet<>());
|
||||||
|
return mappedName == null ? name : mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findInheritedMethodMapping(String owner, String name, String descriptor, Set<String> visitedOwners) {
|
||||||
|
if (owner == null || !visitedOwners.add(owner)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
if (inheritance == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String mappedName = this.findMethodMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String interfaceName : inheritance.interfaces) {
|
||||||
|
mappedName = this.findMethodMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findInheritedFieldMapping(String owner, String name, String descriptor, Set<String> visitedOwners) {
|
||||||
|
if (owner == null || !visitedOwners.add(owner)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
if (inheritance == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String interfaceName : inheritance.interfaces) {
|
||||||
|
String mappedName = this.findFieldMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.findFieldMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findFieldMappingInHierarchy(String owner, String name, String descriptor, Set<String> visitedOwners) {
|
||||||
|
if (owner == null || !visitedOwners.add(owner)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
String mappedName = this.fieldMappings.get(this.fieldKey(owner, name));
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
if (inheritance == null || inheritance.hasDeclaredField(name, descriptor)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String interfaceName : inheritance.interfaces) {
|
||||||
|
mappedName = this.findFieldMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.findFieldMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findMethodMappingInHierarchy(String owner, String name, String descriptor, Set<String> visitedOwners) {
|
||||||
|
if (owner == null || !visitedOwners.add(owner)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
Integer declaredAccess = inheritance == null ? null : inheritance.getDeclaredMethodAccess(name, descriptor);
|
||||||
|
String mappedName = this.methodMappings.get(this.methodKey(owner, name, descriptor));
|
||||||
|
if (mappedName != null && (declaredAccess == null || !this.blocksInheritedMethodMapping(declaredAccess))) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
if (inheritance == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappedName = this.findMethodMappingInHierarchy(inheritance.superName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String interfaceName : inheritance.interfaces) {
|
||||||
|
mappedName = this.findMethodMappingInHierarchy(interfaceName, name, descriptor, visitedOwners);
|
||||||
|
if (mappedName != null) {
|
||||||
|
return mappedName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassInheritance resolveClassInheritance(String sourceName) {
|
||||||
|
ClassInheritance inheritance = this.classInheritance.get(sourceName);
|
||||||
|
if (inheritance != null || sourceName.startsWith("java/") || this.missingClassInheritance.contains(sourceName)) {
|
||||||
|
return inheritance;
|
||||||
|
}
|
||||||
|
|
||||||
|
inheritance = this.loadClassInheritance(sourceName);
|
||||||
|
if (inheritance == null) {
|
||||||
|
this.missingClassInheritance.add(sourceName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.classInheritance.put(sourceName, inheritance);
|
||||||
|
return inheritance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassInheritance loadClassInheritance(String sourceName) {
|
||||||
|
String targetName = this.map(sourceName);
|
||||||
|
InputStream inputStream = this.getResourceAsStream(targetName + ".class");
|
||||||
|
if (inputStream == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
try (InputStream classInputStream = inputStream) {
|
||||||
|
return this.readClassInheritance(new ClassReader(classInputStream), true);
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassInheritance readClassInheritance(final ClassReader classReader, final boolean unmapNames) {
|
||||||
|
final Set<String> declaredFields = new HashSet<>();
|
||||||
|
final Map<String, Integer> declaredMethods = new HashMap<>();
|
||||||
|
classReader.accept(new ClassVisitor(getASMVersion()) {
|
||||||
|
@Override
|
||||||
|
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
|
||||||
|
String normalizedDescriptor = unmapNames ? BytecodeRemapper.this.unmapDescriptor(descriptor) : descriptor;
|
||||||
|
declaredFields.add(BytecodeRemapper.this.fieldSignatureKey(name, normalizedDescriptor));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||||
|
String normalizedDescriptor = unmapNames ? BytecodeRemapper.this.unmapDescriptor(descriptor) : descriptor;
|
||||||
|
declaredMethods.put(BytecodeRemapper.this.methodSignatureKey(name, normalizedDescriptor), access);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||||
|
|
||||||
|
return new ClassInheritance(
|
||||||
|
unmapNames ? this.unmapClassName(classReader.getSuperName()) : classReader.getSuperName(),
|
||||||
|
unmapNames ? this.unmapClassNames(classReader.getInterfaces()) : classReader.getInterfaces(),
|
||||||
|
declaredFields,
|
||||||
|
declaredMethods
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int asmVersion = 0;
|
||||||
|
private static int getASMVersion() {
|
||||||
|
if (asmVersion != 0) {
|
||||||
|
return asmVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
asmVersion = Opcodes.ASM4;
|
||||||
|
int versionIdx = 5;
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
Field asmField = Opcodes.class.getField("ASM" + versionIdx);
|
||||||
|
asmVersion = (int) asmField.get(null);
|
||||||
|
versionIdx++;
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return asmVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream getResourceAsStream(String resourceName) {
|
||||||
|
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
if (contextClassLoader != null) {
|
||||||
|
InputStream inputStream = contextClassLoader.getResourceAsStream(resourceName);
|
||||||
|
if (inputStream != null) {
|
||||||
|
return inputStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassLoader ownClassLoader = NestedJarRemapper.class.getClassLoader();
|
||||||
|
if (ownClassLoader == null) {
|
||||||
|
return ClassLoader.getSystemResourceAsStream(resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ownClassLoader.getResourceAsStream(resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] unmapClassNames(String[] classNames) {
|
||||||
|
if (classNames == null || classNames.length == 0) {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] unmappedClassNames = new String[classNames.length];
|
||||||
|
for (int i = 0; i < classNames.length; i++) {
|
||||||
|
unmappedClassNames[i] = this.unmapClassName(classNames[i]);
|
||||||
|
}
|
||||||
|
return unmappedClassNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String unmapClassName(String className) {
|
||||||
|
String unmappedName = this.inverseClassMappings.get(className);
|
||||||
|
return unmappedName == null ? className : unmappedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String unmapDescriptor(String descriptor) {
|
||||||
|
StringBuilder remappedDescriptor = null;
|
||||||
|
int copyStart = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < descriptor.length(); i++) {
|
||||||
|
if (descriptor.charAt(i) != 'L') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int classNameEnd = descriptor.indexOf(';', i);
|
||||||
|
if (classNameEnd < 0) {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
String className = descriptor.substring(i + 1, classNameEnd);
|
||||||
|
String unmappedName = this.unmapClassName(className);
|
||||||
|
if (!className.equals(unmappedName)) {
|
||||||
|
if (remappedDescriptor == null) {
|
||||||
|
remappedDescriptor = new StringBuilder(descriptor.length());
|
||||||
|
}
|
||||||
|
remappedDescriptor.append(descriptor, copyStart, i + 1);
|
||||||
|
remappedDescriptor.append(unmappedName);
|
||||||
|
copyStart = classNameEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = classNameEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remappedDescriptor == null) {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
remappedDescriptor.append(descriptor, copyStart, descriptor.length());
|
||||||
|
return remappedDescriptor.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getDeclaredMethodAccess(String owner, String name, String descriptor) {
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
return inheritance == null ? null : inheritance.getDeclaredMethodAccess(name, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasDeclaredField(String owner, String name, String descriptor) {
|
||||||
|
ClassInheritance inheritance = this.resolveClassInheritance(owner);
|
||||||
|
return inheritance != null && inheritance.hasDeclaredField(name, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean blocksInheritedMethodMapping(int access) {
|
||||||
|
return (access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fieldKey(String owner, String name) {
|
||||||
|
return owner + '#' + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String methodKey(String owner, String name, String descriptor) {
|
||||||
|
return owner + '#' + name + descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fieldSignatureKey(String name, String descriptor) {
|
||||||
|
return name + descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String methodSignatureKey(String name, String descriptor) {
|
||||||
|
return name + descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class ClassInheritance {
|
||||||
|
private final String superName;
|
||||||
|
private final List<String> interfaces;
|
||||||
|
private final Set<String> declaredFields;
|
||||||
|
private final Map<String, Integer> declaredMethods;
|
||||||
|
|
||||||
|
ClassInheritance(String superName, String[] interfaces, Set<String> declaredFields, Map<String, Integer> declaredMethods) {
|
||||||
|
this.superName = superName;
|
||||||
|
if (interfaces == null || interfaces.length == 0) {
|
||||||
|
this.interfaces = Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
this.interfaces = Collections.unmodifiableList(Arrays.asList(interfaces.clone()));
|
||||||
|
}
|
||||||
|
this.declaredFields = Collections.unmodifiableSet(new HashSet<>(declaredFields));
|
||||||
|
this.declaredMethods = Collections.unmodifiableMap(new HashMap<>(declaredMethods));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasDeclaredField(String name, String descriptor) {
|
||||||
|
return this.declaredFields.contains(name + descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer getDeclaredMethodAccess(String name, String descriptor) {
|
||||||
|
return this.declaredMethods.get(name + descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package customskinloader.bootstrap.installer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.mapping.Parser;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public final class CommonJarInstaller {
|
||||||
|
private static final String COMMON_JAR = "CustomSkinLoader-Common.jar";
|
||||||
|
private static final String MAPPING_RESOURCE = "/customskinloader/mapping.xml";
|
||||||
|
private static final Parser TSRG_PARSER = new Parser();
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
private CommonJarInstaller() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path releaseCommonJar(Path gameDirectory, String mappingType) throws Exception {
|
||||||
|
InputStream mappingStream = CommonJarInstaller.class.getResourceAsStream(MAPPING_RESOURCE);
|
||||||
|
if (mappingStream == null) {
|
||||||
|
throw new IOException("Could not find bundled mapping resource " + MAPPING_RESOURCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream mappingInputStream = mappingStream) {
|
||||||
|
Path coreDirectory = gameDirectory.resolve("CustomSkinLoader").resolve("Core");
|
||||||
|
Files.createDirectories(coreDirectory);
|
||||||
|
|
||||||
|
Path jarPath = coreDirectory.resolve(COMMON_JAR);
|
||||||
|
LOGGER.info("Releasing CustomSkinLoader Common jar to " + BootstrapLogger.formatPath(jarPath));
|
||||||
|
String resourceName = "/META-INF/jar-jar/" + COMMON_JAR;
|
||||||
|
InputStream jarStream = CommonJarInstaller.class.getResourceAsStream(resourceName);
|
||||||
|
if (jarStream == null) {
|
||||||
|
throw new IOException("Could not find bundled jar resource " + resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream jarInputStream = jarStream; OutputStream outputStream = Files.newOutputStream(jarPath)) {
|
||||||
|
new NestedJarRemapper(TSRG_PARSER.parse(mappingInputStream, mappingType)).remapJar(jarInputStream, outputStream);
|
||||||
|
}
|
||||||
|
return jarPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+144
@@ -0,0 +1,144 @@
|
|||||||
|
package customskinloader.bootstrap.installer;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.jar.Attributes;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarInputStream;
|
||||||
|
import java.util.jar.JarOutputStream;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.mapping.Mappings;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
final class NestedJarRemapper {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
private final BytecodeRemapper remapper;
|
||||||
|
|
||||||
|
NestedJarRemapper(Mappings mappings) {
|
||||||
|
this.remapper = new BytecodeRemapper(mappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remapJar(InputStream inputStream, OutputStream outputStream) throws Exception {
|
||||||
|
List<JarEntryData> entries = new ArrayList<>();
|
||||||
|
Manifest manifest;
|
||||||
|
|
||||||
|
try (JarInputStream jarInputStream = new JarInputStream(inputStream)) {
|
||||||
|
manifest = jarInputStream.getManifest();
|
||||||
|
|
||||||
|
JarEntry entry;
|
||||||
|
while ((entry = jarInputStream.getNextJarEntry()) != null) {
|
||||||
|
if (entry.isDirectory() || this.isSignatureEntry(entry.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] entryBytes = this.readAllBytes(jarInputStream);
|
||||||
|
entries.add(new JarEntryData(entry.getName(), entry.getTime(), entryBytes));
|
||||||
|
if (entry.getName().endsWith(".class")) {
|
||||||
|
this.remapper.addClassInheritance(entryBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug("Read " + entries.size() + " entries from nested CustomSkinLoader Common jar");
|
||||||
|
|
||||||
|
try (JarOutputStream jarOutputStream = manifest == null
|
||||||
|
? new JarOutputStream(outputStream)
|
||||||
|
: new JarOutputStream(outputStream, this.copyManifest(manifest))) {
|
||||||
|
for (JarEntryData entry : entries) {
|
||||||
|
byte[] entryBytes = entry.bytes;
|
||||||
|
if (entry.name.endsWith(".class")) {
|
||||||
|
entryBytes = this.remapper.remapClass(entryBytes);
|
||||||
|
this.writeEntry(jarOutputStream, this.toRemappedClassEntryName(entry.name, entryBytes), entry.time, entryBytes);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.writeEntry(jarOutputStream, entry.name, entry.time, entryBytes);
|
||||||
|
}
|
||||||
|
jarOutputStream.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug("Remapped " + entries.size() + " entries from nested CustomSkinLoader Common jar");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Manifest copyManifest(Manifest manifest) {
|
||||||
|
Manifest copiedManifest = new Manifest();
|
||||||
|
copiedManifest.getMainAttributes().putAll(manifest.getMainAttributes());
|
||||||
|
|
||||||
|
for (Map.Entry<String, Attributes> entry : manifest.getEntries().entrySet()) {
|
||||||
|
Attributes copiedAttributes = new Attributes();
|
||||||
|
copiedAttributes.putAll(entry.getValue());
|
||||||
|
copiedManifest.getEntries().put(entry.getKey(), copiedAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return copiedManifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSignatureEntry(String entryName) {
|
||||||
|
String upperCaseEntryName = entryName.toUpperCase();
|
||||||
|
return upperCaseEntryName.startsWith("META-INF/")
|
||||||
|
&& (upperCaseEntryName.endsWith(".SF") || upperCaseEntryName.endsWith(".DSA") || upperCaseEntryName.endsWith(".RSA") || upperCaseEntryName.endsWith(".EC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toRemappedClassEntryName(String sourceEntryName, byte[] remappedClassBytes) {
|
||||||
|
String classEntryName = this.remapper.toClassEntryName(remappedClassBytes);
|
||||||
|
String versionedPrefix = this.getMultiReleaseVersionedPrefix(sourceEntryName);
|
||||||
|
return versionedPrefix == null ? classEntryName : versionedPrefix + classEntryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMultiReleaseVersionedPrefix(String entryName) {
|
||||||
|
String prefix = "META-INF/versions/";
|
||||||
|
if (!entryName.startsWith(prefix)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int versionEnd = entryName.indexOf('/', prefix.length());
|
||||||
|
if (versionEnd < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return entryName.substring(0, versionEnd + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] readAllBytes(InputStream inputStream) throws IOException {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int readBytes;
|
||||||
|
|
||||||
|
while ((readBytes = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, readBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeEntry(JarOutputStream jarOutputStream, String entryName, long sourceEntryTime, byte[] entryBytes) throws IOException {
|
||||||
|
JarEntry jarEntry = new JarEntry(entryName);
|
||||||
|
if (sourceEntryTime >= 0L) {
|
||||||
|
jarEntry.setTime(sourceEntryTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
jarOutputStream.putNextEntry(jarEntry);
|
||||||
|
jarOutputStream.write(entryBytes);
|
||||||
|
jarOutputStream.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class JarEntryData {
|
||||||
|
private final String name;
|
||||||
|
private final long time;
|
||||||
|
private final byte[] bytes;
|
||||||
|
|
||||||
|
JarEntryData(String name, long time, byte[] bytes) {
|
||||||
|
this.name = name;
|
||||||
|
this.time = time;
|
||||||
|
this.bytes = bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package customskinloader.bootstrap.mapping;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public final class Loader {
|
||||||
|
private static final String MAPPING_RESOURCE = "/customskinloader/mapping.xml";
|
||||||
|
|
||||||
|
private Loader() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mappings load(ClassLoader classLoader, String mappingType) {
|
||||||
|
if (mappingType == null || mappingType.trim().isEmpty()) {
|
||||||
|
return Mappings.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputStream resourceStream = classLoader.getResourceAsStream(MAPPING_RESOURCE.substring(1));
|
||||||
|
if (resourceStream == null) {
|
||||||
|
resourceStream = Loader.class.getResourceAsStream(MAPPING_RESOURCE);
|
||||||
|
}
|
||||||
|
if (resourceStream == null) {
|
||||||
|
throw new IllegalStateException("Could not find bundled mapping resource " + MAPPING_RESOURCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream inputStream = resourceStream) {
|
||||||
|
return new Parser().parse(inputStream, mappingType);
|
||||||
|
} catch (IOException exception) {
|
||||||
|
throw new IllegalStateException("Failed to parse bundled mapping resource " + MAPPING_RESOURCE, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
package customskinloader.bootstrap.mapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public final class Mappings {
|
||||||
|
public static final Mappings EMPTY = new Mappings(Collections.emptyList());
|
||||||
|
|
||||||
|
private static final Pattern CLASS_NAME_IN_DESCRIPTOR = Pattern.compile("L([^;]+);");
|
||||||
|
|
||||||
|
private final List<ClassMapping> classMappings;
|
||||||
|
private final Map<String, ClassMapping> classMappingsBySourceName;
|
||||||
|
private final Map<String, ClassMapping> classMappingsByTargetName;
|
||||||
|
private final Map<String, FieldMapping> fieldMappingsBySourceKey;
|
||||||
|
private final Map<String, FieldMapping> fieldMappingsByTargetKey;
|
||||||
|
private final Map<String, MethodMapping> methodMappingsBySourceKey;
|
||||||
|
private final Map<String, MethodMapping> methodMappingsByTargetKey;
|
||||||
|
|
||||||
|
public Mappings(List<ClassMapping> classMappings) {
|
||||||
|
List<ClassMapping> copiedClassMappings = Collections.unmodifiableList(new ArrayList<>(classMappings));
|
||||||
|
Map<String, ClassMapping> sourceIndex = new LinkedHashMap<>();
|
||||||
|
Map<String, ClassMapping> targetIndex = new LinkedHashMap<>();
|
||||||
|
Map<String, String> sourceToTargetClassNames = new LinkedHashMap<>();
|
||||||
|
Map<String, String> targetToSourceClassNames = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (ClassMapping classMapping : copiedClassMappings) {
|
||||||
|
String normalizedSourceName = normalizeClassName(classMapping.getSourceName());
|
||||||
|
String normalizedTargetName = normalizeClassName(classMapping.getTargetName());
|
||||||
|
sourceIndex.put(normalizedSourceName, classMapping);
|
||||||
|
targetIndex.put(normalizedTargetName, classMapping);
|
||||||
|
sourceToTargetClassNames.put(normalizedSourceName, normalizedTargetName);
|
||||||
|
targetToSourceClassNames.put(normalizedTargetName, normalizedSourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, FieldMapping> sourceFieldIndex = new LinkedHashMap<>();
|
||||||
|
Map<String, FieldMapping> targetFieldIndex = new LinkedHashMap<>();
|
||||||
|
Map<String, MethodMapping> sourceMethodIndex = new LinkedHashMap<>();
|
||||||
|
Map<String, MethodMapping> targetMethodIndex = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (ClassMapping classMapping : copiedClassMappings) {
|
||||||
|
String normalizedSourceOwner = normalizeClassName(classMapping.getSourceName());
|
||||||
|
String normalizedTargetOwner = normalizeClassName(classMapping.getTargetName());
|
||||||
|
|
||||||
|
for (FieldMapping fieldMapping : classMapping.getFieldMappings()) {
|
||||||
|
sourceFieldIndex.put(fieldKey(normalizedSourceOwner, fieldMapping.getSourceName()), fieldMapping);
|
||||||
|
targetFieldIndex.put(fieldKey(normalizedTargetOwner, fieldMapping.getTargetName()), fieldMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MethodMapping methodMapping : classMapping.getMethodMappings()) {
|
||||||
|
sourceMethodIndex.put(methodKey(normalizedSourceOwner, methodMapping.getSourceName(), methodMapping.getSourceDescriptor()), methodMapping);
|
||||||
|
targetMethodIndex.put(
|
||||||
|
methodKey(
|
||||||
|
normalizedTargetOwner,
|
||||||
|
methodMapping.getTargetName(),
|
||||||
|
remapDescriptor(methodMapping.getSourceDescriptor(), sourceToTargetClassNames)
|
||||||
|
),
|
||||||
|
methodMapping
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.classMappings = copiedClassMappings;
|
||||||
|
this.classMappingsBySourceName = Collections.unmodifiableMap(sourceIndex);
|
||||||
|
this.classMappingsByTargetName = Collections.unmodifiableMap(targetIndex);
|
||||||
|
this.fieldMappingsBySourceKey = Collections.unmodifiableMap(sourceFieldIndex);
|
||||||
|
this.fieldMappingsByTargetKey = Collections.unmodifiableMap(targetFieldIndex);
|
||||||
|
this.methodMappingsBySourceKey = Collections.unmodifiableMap(sourceMethodIndex);
|
||||||
|
this.methodMappingsByTargetKey = Collections.unmodifiableMap(targetMethodIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClassMapping> getClassMappings() {
|
||||||
|
return this.classMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassMapping getClassMappingBySourceName(String sourceName) {
|
||||||
|
return this.classMappingsBySourceName.get(normalizeClassName(sourceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassMapping getClassMappingByTargetName(String targetName) {
|
||||||
|
return this.classMappingsByTargetName.get(normalizeClassName(targetName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapClassName(String sourceName) {
|
||||||
|
ClassMapping classMapping = this.getClassMappingBySourceName(sourceName);
|
||||||
|
return classMapping == null ? normalizeClassName(sourceName) : normalizeClassName(classMapping.getTargetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapClassName(String targetName) {
|
||||||
|
ClassMapping classMapping = this.getClassMappingByTargetName(targetName);
|
||||||
|
return classMapping == null ? normalizeClassName(targetName) : normalizeClassName(classMapping.getSourceName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapFieldName(String sourceOwner, String sourceName) {
|
||||||
|
FieldMapping fieldMapping = this.fieldMappingsBySourceKey.get(fieldKey(normalizeClassName(sourceOwner), sourceName));
|
||||||
|
return fieldMapping == null ? sourceName : fieldMapping.getTargetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapFieldName(String targetOwner, String targetName) {
|
||||||
|
FieldMapping fieldMapping = this.fieldMappingsByTargetKey.get(fieldKey(normalizeClassName(targetOwner), targetName));
|
||||||
|
return fieldMapping == null ? targetName : fieldMapping.getSourceName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapMethodName(String sourceOwner, String sourceName, String sourceDescriptor) {
|
||||||
|
MethodMapping methodMapping = this.methodMappingsBySourceKey.get(methodKey(normalizeClassName(sourceOwner), sourceName, sourceDescriptor));
|
||||||
|
return methodMapping == null ? sourceName : methodMapping.getTargetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapMethodName(String targetOwner, String targetName, String targetDescriptor) {
|
||||||
|
MethodMapping methodMapping = this.methodMappingsByTargetKey.get(methodKey(normalizeClassName(targetOwner), targetName, targetDescriptor));
|
||||||
|
return methodMapping == null ? targetName : methodMapping.getSourceName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapMethodDescriptor(String sourceDescriptor) {
|
||||||
|
return remapDescriptor(sourceDescriptor, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapMethodDescriptor(String targetDescriptor) {
|
||||||
|
return remapDescriptor(targetDescriptor, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String remapDescriptor(String descriptor, boolean sourceToTarget) {
|
||||||
|
if (descriptor == null || descriptor.isEmpty()) {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher matcher = CLASS_NAME_IN_DESCRIPTOR.matcher(descriptor);
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
while (matcher.find()) {
|
||||||
|
String className = matcher.group(1);
|
||||||
|
String mappedName = sourceToTarget ? this.remapClassName(className) : this.unmapClassName(className);
|
||||||
|
matcher.appendReplacement(stringBuffer, "L" + Matcher.quoteReplacement(mappedName) + ";");
|
||||||
|
}
|
||||||
|
matcher.appendTail(stringBuffer);
|
||||||
|
return stringBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String remapDescriptor(String descriptor, Map<String, String> classNameMappings) {
|
||||||
|
if (descriptor == null || descriptor.isEmpty()) {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher matcher = CLASS_NAME_IN_DESCRIPTOR.matcher(descriptor);
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
while (matcher.find()) {
|
||||||
|
String className = matcher.group(1);
|
||||||
|
String mappedName = classNameMappings.get(className);
|
||||||
|
if (mappedName == null) {
|
||||||
|
mappedName = className;
|
||||||
|
}
|
||||||
|
matcher.appendReplacement(stringBuffer, "L" + Matcher.quoteReplacement(mappedName) + ";");
|
||||||
|
}
|
||||||
|
matcher.appendTail(stringBuffer);
|
||||||
|
return stringBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizeClassName(String className) {
|
||||||
|
return className == null ? null : className.replace('.', '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String fieldKey(String owner, String name) {
|
||||||
|
return owner + '#' + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String methodKey(String owner, String name, String descriptor) {
|
||||||
|
return owner + '#' + name + descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ClassMapping {
|
||||||
|
private final String sourceName;
|
||||||
|
private final String targetName;
|
||||||
|
private final List<FieldMapping> fieldMappings = new ArrayList<>();
|
||||||
|
private final List<MethodMapping> methodMappings = new ArrayList<>();
|
||||||
|
|
||||||
|
public ClassMapping(String sourceName, String targetName) {
|
||||||
|
this.sourceName = sourceName;
|
||||||
|
this.targetName = targetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceName() {
|
||||||
|
return this.sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTargetName() {
|
||||||
|
return this.targetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FieldMapping> getFieldMappings() {
|
||||||
|
return Collections.unmodifiableList(this.fieldMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MethodMapping> getMethodMappings() {
|
||||||
|
return Collections.unmodifiableList(this.methodMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addFieldMapping(FieldMapping fieldMapping) {
|
||||||
|
this.fieldMappings.add(fieldMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addMethodMapping(MethodMapping methodMapping) {
|
||||||
|
this.methodMappings.add(methodMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class FieldMapping {
|
||||||
|
private final ClassMapping owner;
|
||||||
|
private final String sourceName;
|
||||||
|
private final String targetName;
|
||||||
|
|
||||||
|
public FieldMapping(ClassMapping owner, String sourceName, String targetName) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.sourceName = sourceName;
|
||||||
|
this.targetName = targetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassMapping getOwner() {
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceName() {
|
||||||
|
return this.sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTargetName() {
|
||||||
|
return this.targetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class MethodMapping {
|
||||||
|
private final ClassMapping owner;
|
||||||
|
private final String sourceName;
|
||||||
|
private final String sourceDescriptor;
|
||||||
|
private final String targetName;
|
||||||
|
|
||||||
|
public MethodMapping(ClassMapping owner, String sourceName, String sourceDescriptor, String targetName) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.sourceName = sourceName;
|
||||||
|
this.sourceDescriptor = sourceDescriptor;
|
||||||
|
this.targetName = targetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassMapping getOwner() {
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceName() {
|
||||||
|
return this.sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceDescriptor() {
|
||||||
|
return this.sourceDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTargetName() {
|
||||||
|
return this.targetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package customskinloader.bootstrap.mapping;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.util.RangeMatcher;
|
||||||
|
import customskinloader.bootstrap.util.XmlUtils;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
public final class Parser {
|
||||||
|
public Mappings parse(InputStream inputStream, String mappingType) throws IOException {
|
||||||
|
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||||
|
Document document = XmlUtils.parseDocument(reader, "customskinloader mapping.xml");
|
||||||
|
return this.buildMappings(document, mappingType, VersionMetadataReader.PROTOCOL_VERSION, VersionMetadataReader.WORLD_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mappings buildMappings(Document document, String mappingType, int protocolVersion, int worldVersion) {
|
||||||
|
List<Mappings.ClassMapping> classMappings = new ArrayList<>();
|
||||||
|
List<Element> classElements = XmlUtils.childElements(document.getDocumentElement(), "class");
|
||||||
|
for (Element classElement : classElements) {
|
||||||
|
String canonicalClassName = XmlUtils.requiredAttribute(classElement, "name");
|
||||||
|
String mappedClassName = this.selectMappedValue(XmlUtils.childElements(classElement, "name"), mappingType, protocolVersion, worldVersion);
|
||||||
|
if (mappedClassName == null) {
|
||||||
|
mappedClassName = canonicalClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mappings.ClassMapping classMapping = new Mappings.ClassMapping(canonicalClassName, mappedClassName);
|
||||||
|
boolean includeClassMapping = !canonicalClassName.equals(mappedClassName);
|
||||||
|
|
||||||
|
for (Element fieldElement : XmlUtils.childElements(classElement, "field")) {
|
||||||
|
String canonicalFieldName = XmlUtils.requiredAttribute(fieldElement, "name");
|
||||||
|
String mappedFieldName = this.selectMappedValue(XmlUtils.childElements(fieldElement, "name"), mappingType, protocolVersion, worldVersion);
|
||||||
|
if (mappedFieldName == null || canonicalFieldName.equals(mappedFieldName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
classMapping.addFieldMapping(new Mappings.FieldMapping(classMapping, canonicalFieldName, mappedFieldName));
|
||||||
|
includeClassMapping = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Element methodElement : XmlUtils.childElements(classElement, "method")) {
|
||||||
|
String canonicalMethodSignature = XmlUtils.requiredAttribute(methodElement, "name");
|
||||||
|
int descriptorIndex = canonicalMethodSignature.indexOf('(');
|
||||||
|
if (descriptorIndex < 0) {
|
||||||
|
throw new IllegalArgumentException("Method mapping name must include a descriptor: " + canonicalMethodSignature);
|
||||||
|
}
|
||||||
|
|
||||||
|
String canonicalMethodName = canonicalMethodSignature.substring(0, descriptorIndex);
|
||||||
|
String canonicalMethodDescriptor = canonicalMethodSignature.substring(descriptorIndex);
|
||||||
|
String mappedMethodName = this.selectMappedValue(XmlUtils.childElements(methodElement, "name"), mappingType, protocolVersion, worldVersion);
|
||||||
|
if (mappedMethodName == null || canonicalMethodName.equals(mappedMethodName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
classMapping.addMethodMapping(new Mappings.MethodMapping(classMapping, canonicalMethodName, canonicalMethodDescriptor, mappedMethodName));
|
||||||
|
includeClassMapping = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeClassMapping) {
|
||||||
|
classMappings.add(classMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Mappings(classMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String selectMappedValue(List<Element> nameElements, String mappingType, int protocolVersion, int worldVersion) {
|
||||||
|
String selectedValue = null;
|
||||||
|
for (Element nameElement : nameElements) {
|
||||||
|
if (!mappingType.equals(nameElement.getAttribute("type"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!RangeMatcher.matches(nameElement.getAttribute("version"), protocolVersion, worldVersion)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentValue = nameElement.getTextContent() == null ? null : nameElement.getTextContent().trim();
|
||||||
|
if (currentValue == null || currentValue.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedValue != null && !selectedValue.equals(currentValue)) {
|
||||||
|
throw new IllegalArgumentException("Found multiple values for type \"" + mappingType + "\", protocol version " + protocolVersion + " and world version" + worldVersion + ": " + selectedValue + " vs " + currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedValue = currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
package customskinloader.bootstrap.mapping;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.IntInsnNode;
|
||||||
|
import org.objectweb.asm.tree.LdcInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public final class VersionMetadataReader {
|
||||||
|
private static final String VERSION_JSON = "version.json";
|
||||||
|
private static final String NETWORK_PROTOCOL_VERSION_FIELD = "NETWORK_PROTOCOL_VERSION";
|
||||||
|
private static final String[] VERSION_KEYS = {"protocol_version", "world_version"};
|
||||||
|
private static final int[] VERSIONS = {0, 0};
|
||||||
|
|
||||||
|
static {
|
||||||
|
initializeVersions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int PROTOCOL_VERSION = VERSIONS[0];
|
||||||
|
public static final int WORLD_VERSION = VERSIONS[1];
|
||||||
|
|
||||||
|
private VersionMetadataReader() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initializeVersions() {
|
||||||
|
InputStream resourceStream = ClassLoader.getSystemClassLoader().getResourceAsStream(VERSION_JSON);
|
||||||
|
if (resourceStream == null) {
|
||||||
|
readProtocolVersionFromRealmsSharedConstants();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream inputStream = resourceStream; InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
|
||||||
|
JsonElement rootElement = new JsonParser().parse(reader);
|
||||||
|
if (rootElement == null || !rootElement.isJsonObject()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject rootObject = rootElement.getAsJsonObject();
|
||||||
|
for (int i = 0; i < VERSION_KEYS.length; i++) {
|
||||||
|
JsonElement versionElement = rootObject.get(VERSION_KEYS[i]);
|
||||||
|
if (versionElement != null && !versionElement.isJsonNull()) {
|
||||||
|
VERSIONS[i] = versionElement.getAsInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readProtocolVersionFromRealmsSharedConstants() {
|
||||||
|
InputStream resourceStream = ClassLoader.getSystemClassLoader().getResourceAsStream("net/minecraft/realms/RealmsSharedConstants.class");
|
||||||
|
if (resourceStream == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassNode classNode = new ClassNode();
|
||||||
|
try (InputStream inputStream = resourceStream) {
|
||||||
|
ClassReader classReader = new ClassReader(inputStream);
|
||||||
|
classReader.accept(classNode, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (FieldNode fieldNode : classNode.fields) {
|
||||||
|
if (NETWORK_PROTOCOL_VERSION_FIELD.equals(fieldNode.name) && fieldNode.value instanceof Integer) {
|
||||||
|
VERSIONS[0] = (int) fieldNode.value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MethodNode methodNode : classNode.methods) {
|
||||||
|
if (!"<clinit>".equals(methodNode.name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (instruction.getOpcode() != Opcodes.PUTSTATIC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldInsnNode fieldInsnNode = (FieldInsnNode) instruction;
|
||||||
|
if (classNode.name.equals(fieldInsnNode.owner) && NETWORK_PROTOCOL_VERSION_FIELD.equals(fieldInsnNode.name) && "I".equals(fieldInsnNode.desc)) {
|
||||||
|
instruction = instruction.getPrevious();
|
||||||
|
int opcode = instruction.getOpcode();
|
||||||
|
if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) {
|
||||||
|
VERSIONS[0] = opcode - Opcodes.ICONST_0;
|
||||||
|
} else if (opcode >= Opcodes.BIPUSH && opcode <= Opcodes.SIPUSH) {
|
||||||
|
VERSIONS[0] = ((IntInsnNode) instruction).operand;
|
||||||
|
} else if (opcode == Opcodes.LDC) {
|
||||||
|
Object constant = ((LdcInsnNode) instruction).cst;
|
||||||
|
if (constant instanceof Integer) {
|
||||||
|
VERSIONS[0] = (int) constant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.mapping.Mappings;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
public final class ClassTransformationContext {
|
||||||
|
private final String internalClassName;
|
||||||
|
private final ClassNode currentClassNode;
|
||||||
|
private final Mappings mappings;
|
||||||
|
|
||||||
|
private ClassTransformationContext(String internalClassName, ClassNode currentClassNode, Mappings mappings) {
|
||||||
|
this.internalClassName = internalClassName;
|
||||||
|
this.currentClassNode = currentClassNode;
|
||||||
|
this.mappings = mappings == null ? Mappings.EMPTY : mappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClassTransformationContext create(String className, ClassNode classNode, Mappings mappings) {
|
||||||
|
if (classNode == null) {
|
||||||
|
throw new IllegalArgumentException("Class node must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ClassTransformationContext(normalizeInternalClassName(className, classNode), classNode, mappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInternalClassName() {
|
||||||
|
return this.internalClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassNode getCurrentClassNode() {
|
||||||
|
return this.currentClassNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mappings getMappings() {
|
||||||
|
return this.mappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapClassName(String sourceName) {
|
||||||
|
return this.mappings.remapClassName(sourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapClassName(String targetName) {
|
||||||
|
return this.mappings.unmapClassName(targetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapFieldName(String sourceOwner, String sourceName) {
|
||||||
|
return this.mappings.remapFieldName(sourceOwner, sourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapFieldName(String targetOwner, String targetName) {
|
||||||
|
return this.mappings.unmapFieldName(targetOwner, targetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapMethodName(String sourceOwner, String sourceName, String sourceDescriptor) {
|
||||||
|
return this.mappings.remapMethodName(sourceOwner, sourceName, sourceDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapMethodName(String targetOwner, String targetName, String targetDescriptor) {
|
||||||
|
return this.mappings.unmapMethodName(targetOwner, targetName, targetDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String remapMethodDescriptor(String sourceDescriptor) {
|
||||||
|
return this.mappings.remapMethodDescriptor(sourceDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unmapMethodDescriptor(String targetDescriptor) {
|
||||||
|
return this.mappings.unmapMethodDescriptor(targetDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodNode findMethod(String owner, String name, String desc) {
|
||||||
|
String mappedDesc = this.remapMethodDescriptor(desc);
|
||||||
|
String mappedName = "<init>".equals(name) ? name : this.remapMethodName(owner, name, desc);
|
||||||
|
for (MethodNode methodNode : this.getCurrentClassNode().methods) {
|
||||||
|
if (mappedName.equals(methodNode.name) && mappedDesc.equals(methodNode.desc)) {
|
||||||
|
return methodNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldNode findField(String owner, String name) {
|
||||||
|
String mappedName = this.remapFieldName(owner, name);
|
||||||
|
for (FieldNode fieldNode : this.getCurrentClassNode().fields) {
|
||||||
|
if (mappedName.equals(fieldNode.name)) {
|
||||||
|
return fieldNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizeInternalClassName(String className, ClassNode classNode) {
|
||||||
|
if (className != null && !className.trim().isEmpty()) {
|
||||||
|
return normalizeInternalClassName(className);
|
||||||
|
}
|
||||||
|
if (classNode == null || classNode.name == null || classNode.name.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Class name must be available from either the context or the ClassNode");
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizeInternalClassName(classNode.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizeInternalClassName(String className) {
|
||||||
|
return className.replace('.', '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
public final class ClassTransformationReport {
|
||||||
|
private final String internalClassName;
|
||||||
|
private final ClassNode transformedClassNode;
|
||||||
|
private final byte[] originalBytecode;
|
||||||
|
private final List<String> appliedRuleNames;
|
||||||
|
private volatile byte[] transformedBytecode;
|
||||||
|
|
||||||
|
ClassTransformationReport(String internalClassName, ClassNode transformedClassNode, byte[] originalBytecode, List<String> appliedRuleNames) {
|
||||||
|
this.internalClassName = internalClassName;
|
||||||
|
this.transformedClassNode = transformedClassNode;
|
||||||
|
this.originalBytecode = originalBytecode;
|
||||||
|
this.appliedRuleNames = Collections.unmodifiableList(new ArrayList<>(appliedRuleNames));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getTransformedBytecode() {
|
||||||
|
if (!this.isModified() && this.originalBytecode != null) {
|
||||||
|
return this.originalBytecode.clone();
|
||||||
|
}
|
||||||
|
if (this.transformedBytecode == null) {
|
||||||
|
if (this.transformedClassNode == null) {
|
||||||
|
throw new IllegalStateException("Transformed bytecode is not available without a ClassNode");
|
||||||
|
}
|
||||||
|
this.transformedBytecode = TransformerBootstrapSupport.toByteArray(this.transformedClassNode);
|
||||||
|
}
|
||||||
|
return this.transformedBytecode.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassNode getTransformedClassNode() {
|
||||||
|
return this.transformedClassNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAppliedRuleNames() {
|
||||||
|
return this.appliedRuleNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isModified() {
|
||||||
|
return !this.appliedRuleNames.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
public final class RuntimeVersion {
|
||||||
|
private final int protocolVersion;
|
||||||
|
private final int worldVersion;
|
||||||
|
|
||||||
|
public RuntimeVersion(int protocolVersion, int worldVersion) {
|
||||||
|
this.protocolVersion = protocolVersion;
|
||||||
|
this.worldVersion = worldVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProtocolVersion() {
|
||||||
|
return this.protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWorldVersion() {
|
||||||
|
return this.worldVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "protocol=" + this.protocolVersion + ", world=" + this.worldVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
public interface TransformationObserver {
|
||||||
|
void ruleApplied(String ruleId, String internalClassName);
|
||||||
|
|
||||||
|
void optionalRuleSkipped(String message);
|
||||||
|
|
||||||
|
void classTransformed(String internalClassName, Iterable<String> ruleIds);
|
||||||
|
}
|
||||||
+175
@@ -0,0 +1,175 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.mapping.Mappings;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
public final class TransformationPlan {
|
||||||
|
private static final String IGNORE_PATCH_FAILURE_PROPERTY = "customskinloader.ignorePatchFailure";
|
||||||
|
private static final Comparator<TransformationRule> RULE_ORDER = (left, right) -> {
|
||||||
|
// Higher-priority transformers run first so low-priority patches can react to earlier changes.
|
||||||
|
int priorityOrder = Integer.compare(right.getPriority(), left.getPriority());
|
||||||
|
if (priorityOrder != 0) {
|
||||||
|
return priorityOrder;
|
||||||
|
}
|
||||||
|
int groupOrder = left.getGroupName().compareTo(right.getGroupName());
|
||||||
|
if (groupOrder != 0) {
|
||||||
|
return groupOrder;
|
||||||
|
}
|
||||||
|
int declarationOrder = Integer.compare(left.getDeclarationOrder(), right.getDeclarationOrder());
|
||||||
|
return declarationOrder != 0 ? declarationOrder : left.getId().compareTo(right.getId());
|
||||||
|
};
|
||||||
|
|
||||||
|
private final RuntimeVersion runtimeVersion;
|
||||||
|
private final Mappings mappings;
|
||||||
|
private final TransformationObserver observer;
|
||||||
|
private final Map<String, List<TransformationRule>> rulesByTargetClass;
|
||||||
|
private final Set<String> targetClassNames;
|
||||||
|
private final int declaredRuleCount;
|
||||||
|
private final int activeRuleCount;
|
||||||
|
|
||||||
|
public TransformationPlan(Iterable<TransformationRuleProvider> providers, RuntimeVersion runtimeVersion, Mappings mappings, TransformationObserver observer) {
|
||||||
|
if (providers == null || runtimeVersion == null || mappings == null || observer == null) {
|
||||||
|
throw new IllegalArgumentException("Transformation plan inputs must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.runtimeVersion = runtimeVersion;
|
||||||
|
this.mappings = mappings;
|
||||||
|
this.observer = observer;
|
||||||
|
|
||||||
|
Map<String, List<TransformationRule>> mutableRulesByTarget = new LinkedHashMap<>();
|
||||||
|
Set<String> ruleIds = new HashSet<>();
|
||||||
|
Set<String> activeVariants = new HashSet<>();
|
||||||
|
int declaredRules = 0;
|
||||||
|
int activeRules = 0;
|
||||||
|
for (TransformationRuleProvider provider : providers) {
|
||||||
|
if (provider == null) {
|
||||||
|
throw new IllegalStateException("Transformation rule provider must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TransformationRule> rules = provider.getTransformationRules();
|
||||||
|
if (rules == null) {
|
||||||
|
throw new IllegalStateException("Transformation rule provider " + provider.getClass().getName() + " returned null");
|
||||||
|
}
|
||||||
|
for (TransformationRule rule : rules) {
|
||||||
|
declaredRules++;
|
||||||
|
if (rule == null) {
|
||||||
|
throw new IllegalStateException("Transformation rule provider " + provider.getClass().getName() + " returned a null rule");
|
||||||
|
}
|
||||||
|
if (!ruleIds.add(rule.getId())) {
|
||||||
|
throw new IllegalStateException("Duplicate transformation rule id: " + rule.getId());
|
||||||
|
}
|
||||||
|
if (!rule.getVersionSelector().matches(runtimeVersion)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String mappedTargetClassName = mappings.remapClassName(rule.getTargetClassName()).replace('.', '/');
|
||||||
|
if (rule.getVariantGroup() != null && !activeVariants.add(mappedTargetClassName + "@" + rule.getVariantGroup())) {
|
||||||
|
throw new IllegalStateException("Multiple variants from transformation rule group " + rule.getVariantGroup()
|
||||||
|
+ " are active for " + mappedTargetClassName + " at " + runtimeVersion);
|
||||||
|
}
|
||||||
|
mutableRulesByTarget.computeIfAbsent(mappedTargetClassName, ignored -> new ArrayList<>()).add(rule);
|
||||||
|
activeRules++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<TransformationRule>> compiledRulesByTarget = new LinkedHashMap<>();
|
||||||
|
for (Map.Entry<String, List<TransformationRule>> entry : mutableRulesByTarget.entrySet()) {
|
||||||
|
List<TransformationRule> sortedRules = new ArrayList<>(entry.getValue());
|
||||||
|
Collections.sort(sortedRules, RULE_ORDER);
|
||||||
|
compiledRulesByTarget.put(entry.getKey(), Collections.unmodifiableList(sortedRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rulesByTargetClass = Collections.unmodifiableMap(compiledRulesByTarget);
|
||||||
|
this.targetClassNames = Collections.unmodifiableSet(new LinkedHashSet<>(compiledRulesByTarget.keySet()));
|
||||||
|
this.declaredRuleCount = declaredRules;
|
||||||
|
this.activeRuleCount = activeRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getTargetClassNames() {
|
||||||
|
return this.targetClassNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDeclaredRuleCount() {
|
||||||
|
return this.declaredRuleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getActiveRuleCount() {
|
||||||
|
return this.activeRuleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassTransformationReport transform(String className, byte[] classBytecode) {
|
||||||
|
if (classBytecode == null) {
|
||||||
|
throw new IllegalArgumentException("Class bytecode must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
String internalClassName = className == null ? "" : className.replace('.', '/');
|
||||||
|
List<TransformationRule> rules = this.rulesByTargetClass.get(internalClassName);
|
||||||
|
if (rules == null) {
|
||||||
|
return new ClassTransformationReport(internalClassName, null, classBytecode, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassNode classNode = new ClassNode();
|
||||||
|
// Expanded frames are required to derive the stack map frames of inserted branch targets
|
||||||
|
// without loading any class (see FrameCapture). The writer compresses them again.
|
||||||
|
new ClassReader(classBytecode).accept(classNode, ClassReader.EXPAND_FRAMES);
|
||||||
|
return this.transform(internalClassName, classNode, classBytecode, rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassTransformationReport transform(String className, ClassNode classNode) {
|
||||||
|
if (classNode == null) {
|
||||||
|
throw new IllegalArgumentException("Class node must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
String internalClassName = className == null || className.trim().isEmpty() ? classNode.name : className.replace('.', '/');
|
||||||
|
List<TransformationRule> rules = this.rulesByTargetClass.get(internalClassName);
|
||||||
|
if (rules == null) {
|
||||||
|
return new ClassTransformationReport(internalClassName, classNode, null, Collections.emptyList());
|
||||||
|
}
|
||||||
|
return this.transform(internalClassName, classNode, null, rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClassTransformationReport transform(String internalClassName, ClassNode classNode, byte[] originalBytecode, List<TransformationRule> rules) {
|
||||||
|
ClassTransformationContext context = ClassTransformationContext.create(internalClassName, classNode, this.mappings);
|
||||||
|
List<String> appliedRules = new ArrayList<>();
|
||||||
|
for (TransformationRule rule : rules) {
|
||||||
|
boolean modified;
|
||||||
|
try {
|
||||||
|
modified = rule.getOperation().apply(context);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
String message = "Failed to apply transformation rule " + rule.getId() + " to " + internalClassName;
|
||||||
|
throw new IllegalStateException(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modified) {
|
||||||
|
String message = "Transformation rule '" + rule.getId() + "' selected " + internalClassName + " for "
|
||||||
|
+ this.runtimeVersion + " but did not modify any bytecode. If you want to force CustomSkinLoader to ignore this patch failure, add -D"
|
||||||
|
+ IGNORE_PATCH_FAILURE_PROPERTY + "=true to the JVM arguments.";
|
||||||
|
String failureSetting = System.getProperty(IGNORE_PATCH_FAILURE_PROPERTY);
|
||||||
|
if ("false".equalsIgnoreCase(failureSetting) || (rule.isRequired() && !Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY))) {
|
||||||
|
throw new IllegalStateException(message);
|
||||||
|
}
|
||||||
|
this.observer.optionalRuleSkipped(message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
appliedRules.add(rule.getId());
|
||||||
|
this.observer.ruleApplied(rule.getId(), internalClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!appliedRules.isEmpty()) {
|
||||||
|
this.observer.classTransformed(internalClassName, appliedRules);
|
||||||
|
}
|
||||||
|
return new ClassTransformationReport(internalClassName, classNode, originalBytecode, appliedRules);
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
public final class TransformationRule {
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Operation {
|
||||||
|
boolean apply(ClassTransformationContext context) throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String groupName;
|
||||||
|
private final String name;
|
||||||
|
private final int priority;
|
||||||
|
private final int declarationOrder;
|
||||||
|
private final String variantGroup;
|
||||||
|
private final String targetClassName;
|
||||||
|
private final VersionSelector versionSelector;
|
||||||
|
private final boolean required;
|
||||||
|
private final Operation operation;
|
||||||
|
|
||||||
|
public TransformationRule(String groupName, String name, int priority, int declarationOrder, String targetClassName, String versionExpression, boolean required, Operation operation) {
|
||||||
|
if (groupName == null || groupName.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Transformation rule group name must not be empty");
|
||||||
|
}
|
||||||
|
if (name == null || name.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Transformation rule name must not be empty");
|
||||||
|
}
|
||||||
|
if (targetClassName == null || targetClassName.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Transformation rule target class must not be empty");
|
||||||
|
}
|
||||||
|
if (operation == null) {
|
||||||
|
throw new IllegalArgumentException("Transformation rule operation must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.name = name;
|
||||||
|
this.priority = priority;
|
||||||
|
this.declarationOrder = declarationOrder;
|
||||||
|
int variantMarker = name.lastIndexOf(".v");
|
||||||
|
boolean numberedVariant = variantMarker > 0 && variantMarker + 2 < name.length();
|
||||||
|
for (int index = variantMarker + 2; numberedVariant && index < name.length(); index++) {
|
||||||
|
numberedVariant = Character.isDigit(name.charAt(index));
|
||||||
|
}
|
||||||
|
this.variantGroup = numberedVariant ? groupName + "/" + name.substring(0, variantMarker) : null;
|
||||||
|
this.targetClassName = targetClassName.replace('.', '/');
|
||||||
|
this.versionSelector = new VersionSelector(versionExpression);
|
||||||
|
this.required = required;
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return this.groupName + "/" + this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return this.priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return this.groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDeclarationOrder() {
|
||||||
|
return this.declarationOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVariantGroup() {
|
||||||
|
return this.variantGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTargetClassName() {
|
||||||
|
return this.targetClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionSelector getVersionSelector() {
|
||||||
|
return this.versionSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRequired() {
|
||||||
|
return this.required;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operation getOperation() {
|
||||||
|
return this.operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TransformationRuleProvider {
|
||||||
|
List<TransformationRule> getTransformationRules();
|
||||||
|
}
|
||||||
+91
@@ -0,0 +1,91 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.mapping.Loader;
|
||||||
|
import customskinloader.bootstrap.mapping.Mappings;
|
||||||
|
import customskinloader.bootstrap.mapping.VersionMetadataReader;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
public final class TransformerBootstrapSupport {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
private final Object lock = new Object();
|
||||||
|
private final Class<?> serviceLoaderAnchor;
|
||||||
|
private final String mappingType;
|
||||||
|
private volatile TransformationPlan transformationPlan;
|
||||||
|
|
||||||
|
public TransformerBootstrapSupport(Class<?> serviceLoaderAnchor, String mappingType) {
|
||||||
|
if (serviceLoaderAnchor == null) {
|
||||||
|
throw new IllegalArgumentException("Service loader anchor must not be null");
|
||||||
|
}
|
||||||
|
this.serviceLoaderAnchor = serviceLoaderAnchor;
|
||||||
|
this.mappingType = mappingType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getTargetClassNames() {
|
||||||
|
return this.getTransformationPlan().getTargetClassNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassTransformationReport transform(String internalClassName, byte[] classBytecode) {
|
||||||
|
return this.getTransformationPlan().transform(internalClassName, classBytecode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassTransformationReport transform(String internalClassName, ClassNode inputClassNode) {
|
||||||
|
return this.getTransformationPlan().transform(internalClassName, inputClassNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TransformationPlan getTransformationPlan() {
|
||||||
|
TransformationPlan loadedPlan = this.transformationPlan;
|
||||||
|
if (loadedPlan != null) {
|
||||||
|
return loadedPlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this.lock) {
|
||||||
|
loadedPlan = this.transformationPlan;
|
||||||
|
if (loadedPlan == null) {
|
||||||
|
LOGGER.info("Compiling CustomSkinLoader transformation plan for " + this.mappingType + " mappings");
|
||||||
|
Mappings mappings = Loader.load(this.serviceLoaderAnchor.getClassLoader(), this.mappingType);
|
||||||
|
// Discover platform-contributed targeted transformers lazily through the shared service contract.
|
||||||
|
ServiceLoader<TransformationRuleProvider> providers = ServiceLoader.load(
|
||||||
|
TransformationRuleProvider.class, this.serviceLoaderAnchor.getClassLoader());
|
||||||
|
loadedPlan = new TransformationPlan(
|
||||||
|
providers,
|
||||||
|
new RuntimeVersion(VersionMetadataReader.PROTOCOL_VERSION, VersionMetadataReader.WORLD_VERSION),
|
||||||
|
mappings,
|
||||||
|
new TransformationObserver() {
|
||||||
|
@Override
|
||||||
|
public void ruleApplied(String ruleId, String internalClassName) {
|
||||||
|
LOGGER.debug("Applied transformation rule " + ruleId + " to " + internalClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void optionalRuleSkipped(String message) {
|
||||||
|
LOGGER.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void classTransformed(String internalClassName, Iterable<String> ruleIds) {
|
||||||
|
LOGGER.info("Transformed " + internalClassName + " with " + ruleIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.transformationPlan = loadedPlan;
|
||||||
|
LOGGER.info("Compiled " + loadedPlan.getActiveRuleCount() + " of " + loadedPlan.getDeclaredRuleCount()
|
||||||
|
+ " transformation rule(s) for " + loadedPlan.getTargetClassNames().size() + " target class(es)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loadedPlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] toByteArray(ClassNode classNode) {
|
||||||
|
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||||
|
classNode.accept(classWriter);
|
||||||
|
return classWriter.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package customskinloader.bootstrap.transformer;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.util.RangeMatcher;
|
||||||
|
|
||||||
|
public final class VersionSelector {
|
||||||
|
private final String expression;
|
||||||
|
|
||||||
|
public VersionSelector(String expression) {
|
||||||
|
this.expression = expression == null ? "" : expression.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean matches(RuntimeVersion version) {
|
||||||
|
return RangeMatcher.matches(this.expression, version.getProtocolVersion(), version.getWorldVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.expression.isEmpty() ? "*" : this.expression;
|
||||||
|
}
|
||||||
|
}
|
||||||
+97
@@ -0,0 +1,97 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.commons.AnalyzerAdapter;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FrameNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the operand stack / local variable state around a given instruction without loading any
|
||||||
|
* class. Only usable when the method already carries expanded (F_NEW) stack map frames, which is
|
||||||
|
* the case for the byte array based transformation paths. Platforms that recompute frames (e.g.
|
||||||
|
* ModLauncher) hand over compressed frames; callers must then fall back to letting the platform
|
||||||
|
* compute the frames.
|
||||||
|
*/
|
||||||
|
final class FrameCapture {
|
||||||
|
final Object[] localsBefore;
|
||||||
|
final Object[] stackBefore;
|
||||||
|
final Object[] localsAfter;
|
||||||
|
final Object[] stackAfter;
|
||||||
|
|
||||||
|
private FrameCapture(Object[] localsBefore, Object[] stackBefore, Object[] localsAfter, Object[] stackAfter) {
|
||||||
|
this.localsBefore = localsBefore;
|
||||||
|
this.stackBefore = stackBefore;
|
||||||
|
this.localsAfter = localsAfter;
|
||||||
|
this.stackAfter = stackAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FrameCapture capture(String owner, MethodNode methodNode, AbstractInsnNode target) {
|
||||||
|
if (!hasExpandedFrames(methodNode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnalyzerAdapter analyzer = new AnalyzerAdapter(owner, methodNode.access, methodNode.name, methodNode.desc, null);
|
||||||
|
for (AbstractInsnNode instruction = methodNode.instructions.getFirst(); instruction != null; instruction = instruction.getNext()) {
|
||||||
|
if (instruction == target) {
|
||||||
|
Object[] localsBefore = toFrameTypes(analyzer.locals);
|
||||||
|
Object[] stackBefore = toFrameTypes(analyzer.stack);
|
||||||
|
if (localsBefore == null || stackBefore == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
instruction.accept(analyzer);
|
||||||
|
|
||||||
|
Object[] localsAfter = toFrameTypes(analyzer.locals);
|
||||||
|
Object[] stackAfter = toFrameTypes(analyzer.stack);
|
||||||
|
if (localsAfter == null || stackAfter == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FrameCapture(localsBefore, stackBefore, localsAfter, stackAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
instruction.accept(analyzer);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasExpandedFrames(MethodNode methodNode) {
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions) {
|
||||||
|
if (instruction instanceof FrameNode && ((FrameNode) instruction).type != Opcodes.F_NEW) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the slot based lists maintained by {@link AnalyzerAdapter} into the expanded frame
|
||||||
|
* format expected by {@link FrameNode}. Long and double values occupy two slots but only one
|
||||||
|
* frame entry, so the implicit {@code TOP} following them must be dropped.
|
||||||
|
*/
|
||||||
|
private static Object[] toFrameTypes(List<Object> slots) {
|
||||||
|
if (slots == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Object> types = new ArrayList<>(slots.size());
|
||||||
|
for (int index = 0; index < slots.size(); index++) {
|
||||||
|
Object slot = slots.get(index);
|
||||||
|
if (!(slot instanceof String) && !(slot instanceof Integer)) {
|
||||||
|
// Uninitialized types are represented by analyzer owned labels that cannot be mapped
|
||||||
|
// back to labels of the method being transformed.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
types.add(slot);
|
||||||
|
if (slot instanceof Integer && (slot.equals(Opcodes.LONG) || slot.equals(Opcodes.DOUBLE))) {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return types.toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
public final class InterfacePatch extends PatchSupport {
|
||||||
|
public InterfacePatch() {
|
||||||
|
super("customskinloader:interface-patch", 1000);
|
||||||
|
|
||||||
|
// 19w37a- (1.14.4-)
|
||||||
|
this.rule("http-texture-processor.interface", HTTP_TEXTURE_PROCESSOR, "[,553]", context ->
|
||||||
|
this.addInterface(context.getCurrentClassNode(), FAKE_HTTP_TEXTURE_PROCESSOR));
|
||||||
|
|
||||||
|
this.rule("resource.interfaces", RESOURCE, "", context ->
|
||||||
|
this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V1) | this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V2));
|
||||||
|
|
||||||
|
this.rule("resource-manager.interfaces", RESOURCE_MANAGER, "", context ->
|
||||||
|
this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V1) | this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V2));
|
||||||
|
|
||||||
|
// 1.13.2+
|
||||||
|
this.rule("native-image.interface", NATIVE_IMAGE, "[404,]", context ->
|
||||||
|
this.addInterface(context.getCurrentClassNode(), FAKE_NATIVE_IMAGE));
|
||||||
|
|
||||||
|
this.rule("identifier.constructor", IDENTIFIER, "", context ->
|
||||||
|
this.makeMethodPublicNonFinal(context.findMethod(IDENTIFIER, "<init>", "(" + objectDesc(STRING) + objectDesc(STRING) + ")V")));
|
||||||
|
}
|
||||||
|
}
|
||||||
+251
@@ -0,0 +1,251 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformationRule;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformationRuleProvider;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.FrameNode;
|
||||||
|
import org.objectweb.asm.tree.InnerClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.JumpInsnNode;
|
||||||
|
import org.objectweb.asm.tree.LabelNode;
|
||||||
|
import org.objectweb.asm.tree.LdcInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.TypeInsnNode;
|
||||||
|
|
||||||
|
abstract class PatchSupport implements TransformationRuleProvider, Opcodes {
|
||||||
|
|
||||||
|
protected static final String BOOLEAN = "java/lang/Boolean";
|
||||||
|
protected static final String OBJECT = "java/lang/Object";
|
||||||
|
protected static final String RUNNABLE = "java/lang/Runnable";
|
||||||
|
protected static final String STRING = "java/lang/String";
|
||||||
|
protected static final String CALL_SITE = "java/lang/invoke/CallSite";
|
||||||
|
protected static final String LAMBDA_METAFACTORY = "java/lang/invoke/LambdaMetafactory";
|
||||||
|
protected static final String METHOD_HANDLE = "java/lang/invoke/MethodHandle";
|
||||||
|
protected static final String METHOD_HANDLES_LOOKUP = "java/lang/invoke/MethodHandles$Lookup";
|
||||||
|
protected static final String METHOD_TYPE = "java/lang/invoke/MethodType";
|
||||||
|
protected static final String FILE = "java/io/File";
|
||||||
|
protected static final String INPUT_STREAM = "java/io/InputStream";
|
||||||
|
protected static final String PATH = "java/nio/file/Path";
|
||||||
|
protected static final String MAP = "java/util/Map";
|
||||||
|
protected static final String OBJECTS = "java/util/Objects";
|
||||||
|
protected static final String UUID = "java/util/UUID";
|
||||||
|
protected static final String COMPLETABLE_FUTURE = "java/util/concurrent/CompletableFuture";
|
||||||
|
protected static final String EXECUTOR = "java/util/concurrent/Executor";
|
||||||
|
protected static final String EXECUTOR_SERVICE = "java/util/concurrent/ExecutorService";
|
||||||
|
protected static final String FUTURE = "java/util/concurrent/Future";
|
||||||
|
protected static final String FUNCTION = "java/util/function/Function";
|
||||||
|
protected static final String SUPPLIER = "java/util/function/Supplier";
|
||||||
|
protected static final String FUNCTION4 = "com/mojang/datafixers/util/Function4";
|
||||||
|
|
||||||
|
protected static final String NATIVE_IMAGE = "com/mojang/blaze3d/platform/NativeImage";
|
||||||
|
protected static final String POSE_STACK = "com/mojang/blaze3d/vertex/PoseStack";
|
||||||
|
|
||||||
|
protected static final String MINECRAFT = "net/minecraft/client/Minecraft";
|
||||||
|
protected static final String GUI_GRAPHICS = "net/minecraft/client/gui/GuiGraphics";
|
||||||
|
protected static final String GUI_GRAPHICS_EXTRACTOR = "net/minecraft/client/gui/GuiGraphicsExtractor";
|
||||||
|
protected static final String PLAYER_TAB_OVERLAY = "net/minecraft/client/gui/components/PlayerTabOverlay";
|
||||||
|
protected static final String CLIENT_PACKET_LISTENER = "net/minecraft/client/multiplayer/ClientPacketListener";
|
||||||
|
protected static final String HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/FakeHttpTextureProcessor"; // net/minecraft/client/renderer/HttpTextureProcessor
|
||||||
|
protected static final String MULTI_BUFFER_SOURCE = "net/minecraft/client/renderer/MultiBufferSource";
|
||||||
|
protected static final String SUBMIT_NODE_COLLECTOR = "net/minecraft/client/renderer/SubmitNodeCollector";
|
||||||
|
protected static final String MODEL_PART = "net/minecraft/client/model/geom/ModelPart";
|
||||||
|
protected static final String ABSTRACT_CLIENT_PLAYER = "net/minecraft/client/player/AbstractClientPlayer";
|
||||||
|
protected static final String CAPE_LAYER = "net/minecraft/client/renderer/entity/layers/CapeLayer";
|
||||||
|
protected static final String AVATAR_RENDER_STATE = "net/minecraft/client/renderer/entity/state/AvatarRenderState";
|
||||||
|
protected static final String PLAYER_RENDER_STATE = "net/minecraft/client/renderer/entity/state/PlayerRenderState";
|
||||||
|
protected static final String PLAYER_RENDERER = "net/minecraft/client/renderer/entity/player/PlayerRenderer";
|
||||||
|
protected static final String RENDER_TYPE = "net/minecraft/client/renderer/rendertype/RenderType";
|
||||||
|
protected static final String RENDER_TYPES = "net/minecraft/client/renderer/rendertype/RenderTypes";
|
||||||
|
protected static final String SKIN_MANAGER = "net/minecraft/client/resources/SkinManager";
|
||||||
|
protected static final String SKIN_MANAGER_1 = "net/minecraft/client/resources/SkinManager$1";
|
||||||
|
protected static final String SKIN_MANAGER_3 = "net/minecraft/client/resources/SkinManager$3";
|
||||||
|
protected static final String SKIN_MANAGER_CACHE_KEY = "net/minecraft/client/resources/SkinManager$CacheKey";
|
||||||
|
protected static final String SKIN_MANAGER_SKIN_TEXTURE_CALLBACK = "net/minecraft/client/resources/SkinManager$SkinTextureCallback";
|
||||||
|
protected static final String SKIN_MANAGER_TEXTURE_CACHE = "net/minecraft/client/resources/SkinManager$TextureCache";
|
||||||
|
protected static final String SKIN_MANAGER_TEXTURE_INFO = "net/minecraft/client/resources/SkinManager$TextureInfo";
|
||||||
|
protected static final String SKIN_TEXTURE_DOWNLOADER = "net/minecraft/client/renderer/texture/SkinTextureDownloader";
|
||||||
|
protected static final String TEXTURE_MANAGER = "net/minecraft/client/renderer/texture/TextureManager";
|
||||||
|
protected static final String HTTP_TEXTURE = "net/minecraft/client/renderer/texture/HttpTexture";
|
||||||
|
protected static final String CLIENT_ASSET_DOWNLOADED_TEXTURE = "net/minecraft/core/ClientAsset$DownloadedTexture";
|
||||||
|
protected static final String IDENTIFIER = "net/minecraft/resources/Identifier";
|
||||||
|
protected static final String SERVICES = "net/minecraft/server/Services";
|
||||||
|
protected static final String RESOURCE = "net/minecraft/server/packs/resources/Resource";
|
||||||
|
protected static final String RESOURCE_MANAGER = "net/minecraft/server/packs/resources/ResourceManager";
|
||||||
|
protected static final String OBJECTIVE = "net/minecraft/world/scores/Objective";
|
||||||
|
protected static final String SCOREBOARD = "net/minecraft/world/scores/Scoreboard";
|
||||||
|
|
||||||
|
protected static final String FAKE_HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/IFakeHttpTextureProcessor";
|
||||||
|
protected static final String FAKE_I_RESOURCE_V1 = "customskinloader/fake/itf/IFakeIResource$V1";
|
||||||
|
protected static final String FAKE_I_RESOURCE_V2 = "customskinloader/fake/itf/IFakeIResource$V2";
|
||||||
|
protected static final String FAKE_I_RESOURCE_MANAGER_V1 = "customskinloader/fake/itf/IFakeIResourceManager$V1";
|
||||||
|
protected static final String FAKE_I_RESOURCE_MANAGER_V2 = "customskinloader/fake/itf/IFakeIResourceManager$V2";
|
||||||
|
protected static final String FAKE_NATIVE_IMAGE = "customskinloader/fake/itf/IFakeNativeImage";
|
||||||
|
|
||||||
|
protected static final String FAKE_SKIN_BUFFER = "customskinloader/fake/FakeSkinBuffer";
|
||||||
|
protected static final String FAKE_SKIN_MANAGER = "customskinloader/fake/FakeSkinManager";
|
||||||
|
protected static final String FAKE_CACHE_KEY = "customskinloader/fake/FakeSkinManager$FakeCacheKey";
|
||||||
|
protected static final String FAKE_HTTP_TEXTURE_V1 = "customskinloader/fake/texture/FakeHttpTexture$V1";
|
||||||
|
protected static final String FAKE_HTTP_TEXTURE_V2 = "customskinloader/fake/texture/FakeHttpTexture$V2";
|
||||||
|
|
||||||
|
protected static final String MINECRAFT_PROFILE_TEXTURE = "com/mojang/authlib/minecraft/MinecraftProfileTexture";
|
||||||
|
protected static final String MINECRAFT_PROFILE_TEXTURE_TYPE = "com/mojang/authlib/minecraft/MinecraftProfileTexture$Type";
|
||||||
|
protected static final String MINECRAFT_SESSION_SERVICE = "com/mojang/authlib/minecraft/MinecraftSessionService";
|
||||||
|
protected static final String MINECRAFT_PROFILE_TEXTURES = "com/mojang/authlib/minecraft/MinecraftProfileTextures";
|
||||||
|
protected static final String SESSION_SERVICE = "com/mojang/authlib/minecraft/SessionService";
|
||||||
|
protected static final String GAME_PROFILE = "com/mojang/authlib/GameProfile";
|
||||||
|
protected static final String PROPERTY = "com/mojang/authlib/properties/Property";
|
||||||
|
|
||||||
|
protected static String objectDesc(String internalName) {
|
||||||
|
return "L" + internalName + ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String groupName;
|
||||||
|
private final int priority;
|
||||||
|
private final List<TransformationRule> rules = new ArrayList<>();
|
||||||
|
|
||||||
|
protected PatchSupport(String groupName, int priority) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void rule(String name, String targetClassName, String versionExpression, TransformationRule.Operation operation) {
|
||||||
|
this.rules.add(new TransformationRule(this.groupName, name, this.priority, this.rules.size(), targetClassName, versionExpression, true, operation));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void optionalRule(String name, String targetClassName, String versionExpression, TransformationRule.Operation operation) {
|
||||||
|
this.rules.add(new TransformationRule(this.groupName, name, this.priority, this.rules.size(), targetClassName, versionExpression, false, operation));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final List<TransformationRule> getTransformationRules() {
|
||||||
|
return Collections.unmodifiableList(new ArrayList<>(this.rules));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean addInterface(ClassNode classNode, String interfaceName) {
|
||||||
|
if (!classNode.interfaces.contains(interfaceName)) {
|
||||||
|
classNode.interfaces.add(interfaceName);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean makeClassPublicNonFinal(ClassNode classNode) {
|
||||||
|
boolean modified = false;
|
||||||
|
int access = makePublicNonFinal(classNode.access);
|
||||||
|
if (classNode.access != access) {
|
||||||
|
classNode.access = access;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
modified |= this.makeInnerClassPublicNonFinal(classNode, classNode.name);
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean makeInnerClassPublicNonFinal(ClassNode classNode, String innerName) {
|
||||||
|
boolean modified = false;
|
||||||
|
for (InnerClassNode innerClassNode : classNode.innerClasses) {
|
||||||
|
if (!innerName.equals(innerClassNode.name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
innerClassNode.access = makePublicNonFinal(innerClassNode.access);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean makeMethodPublicNonFinal(MethodNode methodNode) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
methodNode.access = makePublicNonFinal(methodNode.access);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean makeFieldPublicNonFinal(FieldNode fieldNode) {
|
||||||
|
if (fieldNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fieldNode.access = makePublicNonFinal(fieldNode.access);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int makePublicNonFinal(int access) {
|
||||||
|
return (access & ~(ACC_PRIVATE | ACC_PROTECTED | ACC_FINAL)) | ACC_PUBLIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InsnList clone(InsnList source) {
|
||||||
|
InsnList copy = new InsnList();
|
||||||
|
for (AbstractInsnNode abstractInsnNode : source) {
|
||||||
|
copy.add(abstractInsnNode.clone(null));
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractInsnNode findPreviousTypeInstruction(AbstractInsnNode instruction, int opcode, String type) {
|
||||||
|
AbstractInsnNode current = instruction == null ? null : instruction.getPrevious();
|
||||||
|
while (current != null) {
|
||||||
|
if (current.getOpcode() == opcode && current instanceof TypeInsnNode && type.equals(((TypeInsnNode) current).desc)) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
current = current.getPrevious();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractInsnNode nextRealInstruction(AbstractInsnNode instruction) {
|
||||||
|
AbstractInsnNode current = instruction == null ? null : instruction.getNext();
|
||||||
|
while (current != null && current.getOpcode() < 0) {
|
||||||
|
current = current.getNext();
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void replaceInstructionSafely(ClassTransformationContext context, MethodNode methodNode, AbstractInsnNode original, AbstractInsnNode replacement) {
|
||||||
|
this.replaceInstructionSafely(context, methodNode, new InsnNode(ICONST_1), IFNE, original, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void replaceInstructionSafely(ClassTransformationContext context, MethodNode methodNode, AbstractInsnNode condition, int jumpOpcode, AbstractInsnNode original, AbstractInsnNode replacement) {
|
||||||
|
LabelNode label0 = new LabelNode();
|
||||||
|
LabelNode label1 = new LabelNode();
|
||||||
|
|
||||||
|
InsnList before = new InsnList();
|
||||||
|
before.add(condition);
|
||||||
|
before.add(new JumpInsnNode(jumpOpcode, label0));
|
||||||
|
before.add(new LdcInsnNode("Modified by CustomSkinLoader."));
|
||||||
|
before.add(new InsnNode(POP));
|
||||||
|
|
||||||
|
methodNode.instructions.insertBefore(original, before);
|
||||||
|
|
||||||
|
// The original instruction is kept as dead code so later Mixin / coremod transformations
|
||||||
|
// can still locate it. Both branch targets therefore need a real stack map frame: the
|
||||||
|
// replacement starts with the state the original instruction would have seen, and the
|
||||||
|
// merge point continues with the state the original instruction would have produced.
|
||||||
|
FrameCapture frames = FrameCapture.capture(context.getInternalClassName(), methodNode, original);
|
||||||
|
if (frames == null) {
|
||||||
|
BootstrapLogger.LOGGER.debug("Could not derive stack map frames for " + methodNode.name + methodNode.desc + "; the inserted branch targets carry no frame");
|
||||||
|
}
|
||||||
|
|
||||||
|
InsnList after = new InsnList();
|
||||||
|
after.add(new JumpInsnNode(GOTO, label1));
|
||||||
|
after.add(label0);
|
||||||
|
if (frames != null) {
|
||||||
|
after.add(new FrameNode(F_NEW, frames.localsBefore.length, frames.localsBefore, frames.stackBefore.length, frames.stackBefore));
|
||||||
|
}
|
||||||
|
after.add(replacement);
|
||||||
|
after.add(label1);
|
||||||
|
if (frames != null) {
|
||||||
|
after.add(new FrameNode(F_NEW, frames.localsAfter.length, frames.localsAfter, frames.stackAfter.length, frames.stackAfter));
|
||||||
|
}
|
||||||
|
|
||||||
|
methodNode.instructions.insert(original, after);
|
||||||
|
}
|
||||||
|
}
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
public final class RenderPatch extends PatchSupport {
|
||||||
|
public RenderPatch() {
|
||||||
|
super("customskinloader:render-patch", 1000);
|
||||||
|
|
||||||
|
// 20w16a- (1.15.2-)
|
||||||
|
this.rule("player-tab-overlay.render.v1", PLAYER_TAB_OVERLAY, "[,712]", context ->
|
||||||
|
this.replaceLocalServerCheck(
|
||||||
|
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"),
|
||||||
|
MINECRAFT, "isLocalServer"));
|
||||||
|
// 20w17a ~ 23w14a (1.16 ~ 1.19.4)
|
||||||
|
this.rule("player-tab-overlay.render.v2", PLAYER_TAB_OVERLAY, "[713,762],[801,803],[0x40000001,0x40000082]", context ->
|
||||||
|
this.replaceLocalServerCheck(
|
||||||
|
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(POSE_STACK) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"),
|
||||||
|
MINECRAFT, "isLocalServer"));
|
||||||
|
// 23w16a ~ 26.1-snapshot-11 (1.20 ~ 1.21.11)
|
||||||
|
this.rule("player-tab-overlay.render.v3", PLAYER_TAB_OVERLAY, "[763,774],[0x40000083,0x40000129]", context ->
|
||||||
|
this.replaceLocalServerCheck(
|
||||||
|
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(GUI_GRAPHICS) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"),
|
||||||
|
MINECRAFT, "isLocalServer"));
|
||||||
|
// 26.1-pre-1 ~ 26.2-snapshot-6 (26.1 ~ 26.1.2)
|
||||||
|
this.rule("player-tab-overlay.extract-render-state.v1", PLAYER_TAB_OVERLAY, "775,[0x4000012A,0x40000138]", context ->
|
||||||
|
this.replaceLocalServerCheck(
|
||||||
|
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"),
|
||||||
|
MINECRAFT, "isLocalServer"));
|
||||||
|
// 26.2-snapshot-7+ (26.2+)
|
||||||
|
this.rule("player-tab-overlay.extract-render-state.v2", PLAYER_TAB_OVERLAY, "[776,800],[804,0x40000000],[0x40000139,]", context ->
|
||||||
|
this.replaceLocalServerCheck(
|
||||||
|
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"),
|
||||||
|
CLIENT_PACKET_LISTENER, "onlineMode"));
|
||||||
|
|
||||||
|
// 19w39a ~ 19w44a
|
||||||
|
this.optionalRule("cape-layer.render.v1", CAPE_LAYER, "[556,560]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFFF)V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
|
||||||
|
this.optionalRule("cape-layer.render.v2", CAPE_LAYER, "[561,767],[801,803],[0x40000001,0x400000CC]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFF)V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
// 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8)
|
||||||
|
this.optionalRule("cape-layer.render.v3", CAPE_LAYER, "[768,772],[0x400000CD,0x40000103]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(PLAYER_RENDER_STATE) + "FF)V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
// 25w31a ~ 25w42a (1.21.9 ~ 1.21.10)
|
||||||
|
this.optionalRule("cape-layer.submit.v1", CAPE_LAYER, "773,[0x40000104,0x40000112]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
// 25w43a+ (1.21.11+)
|
||||||
|
this.optionalRule("cape-layer.submit.v2", CAPE_LAYER, "[774,800],[804,0x40000000],[0x40000113,]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
|
||||||
|
RENDER_TYPES));
|
||||||
|
|
||||||
|
// 19w39a ~ 19w44a
|
||||||
|
this.optionalRule("player-renderer.render-hand.v1", PLAYER_RENDERER, "[556,560]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
|
||||||
|
this.optionalRule("player-renderer.render-hand.v2", PLAYER_RENDERER, "[561,767],[801,803],[0x40000001,0x400000CC]", context ->
|
||||||
|
this.replaceEntitySolidWithTranslucent(
|
||||||
|
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
|
||||||
|
RENDER_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceLocalServerCheck(ClassTransformationContext context, MethodNode methodNode, String owner, String name) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String remappedOwner = context.remapClassName(owner);
|
||||||
|
String remappedName = context.remapMethodName(owner, name, "()Z");
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (remappedOwner.equals(methodInsnNode.owner) && remappedName.equals(methodInsnNode.name) && "()Z".equals(methodInsnNode.desc)) {
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, OBJECTS, "nonNull", "(" + objectDesc(OBJECT) + ")Z"));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceEntitySolidWithTranslucent(ClassTransformationContext context, MethodNode methodNode, String owner) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String remappedOwner = context.remapClassName(owner);
|
||||||
|
String desc = "(" + objectDesc(IDENTIFIER) + ")" + objectDesc(RENDER_TYPE);
|
||||||
|
String remappedDesc = context.remapMethodDescriptor(desc);
|
||||||
|
String originalName = context.remapMethodName(owner, "entitySolid", desc);
|
||||||
|
String replacementName = context.remapMethodName(owner, "entityTranslucent", desc);
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (remappedOwner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && remappedDesc.equals(methodInsnNode.desc)) {
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
+437
@@ -0,0 +1,437 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||||
|
import org.objectweb.asm.Handle;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FrameNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.TypeInsnNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
public final class SkinManagerPatch extends PatchSupport {
|
||||||
|
public SkinManagerPatch() {
|
||||||
|
super("customskinloader:skin-manager-patch", 1000);
|
||||||
|
|
||||||
|
// 23w31a+ (1.20.2+)
|
||||||
|
this.rule("skin-manager.cache-key-inner-class", SKIN_MANAGER, "[764,800],[804,0x40000000],[0x40000090,]", context ->
|
||||||
|
this.makeInnerClassPublicNonFinal(context.getCurrentClassNode(), context.remapClassName(SKIN_MANAGER_CACHE_KEY)));
|
||||||
|
|
||||||
|
// 1.20.1-
|
||||||
|
this.rule("skin-manager.constructor.v1", SKIN_MANAGER, "[,763],[801,803],[0x40000001,0x4000008E]", context ->
|
||||||
|
this.injectSetSkinCacheDir(context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(FILE) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")V", 2, objectDesc(FILE)));
|
||||||
|
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
|
||||||
|
this.rule("skin-manager.constructor.v2", SKIN_MANAGER, "[764,768],[0x40000090,0x400000DD]", context ->
|
||||||
|
this.injectSetSkinCacheDir(context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 2, objectDesc(PATH)));
|
||||||
|
// 24w46a ~ 25w33a (1.21.4 ~ 1.21.8)
|
||||||
|
this.rule("skin-manager.constructor.v3", SKIN_MANAGER, "[769,772],[0x400000DE,0x40000106]", context ->
|
||||||
|
this.injectSetSkinCacheDir(context, "(" + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)));
|
||||||
|
// 25w34a ~ 25w34b
|
||||||
|
this.rule("skin-manager.constructor.v4", SKIN_MANAGER, "[0x40000107,0x40000108]", context ->
|
||||||
|
this.injectSetSkinCacheDir(context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)));
|
||||||
|
// 25w35a+ (1.21.9+)
|
||||||
|
this.rule("skin-manager.constructor.v5", SKIN_MANAGER, "[773,800],[804,0x40000000],[0x40000109,]", context ->
|
||||||
|
this.injectSetSkinCacheDir(context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(SKIN_TEXTURE_DOWNLOADER) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)));
|
||||||
|
|
||||||
|
// 19w37a- (1.14.4-)
|
||||||
|
this.rule("skin-manager.register-texture.v1", SKIN_MANAGER, "[,553]", context -> {
|
||||||
|
InsnList loadTextureType = new InsnList();
|
||||||
|
loadTextureType.add(new VarInsnNode(ALOAD, 2));
|
||||||
|
return this.redirectHttpTextureConstructorToFake(
|
||||||
|
context,
|
||||||
|
context.findMethod(SKIN_MANAGER, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")" + objectDesc(IDENTIFIER)),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + ")V"),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||||
|
loadTextureType
|
||||||
|
);
|
||||||
|
});
|
||||||
|
// 19w38a ~ 1.20.1 (1.15 ~ 1.20.1)
|
||||||
|
this.rule("skin-manager.register-texture.v2", SKIN_MANAGER, "[554,763],[801,803],[0x40000001,0x4000008E]", context -> {
|
||||||
|
InsnList loadTextureType = new InsnList();
|
||||||
|
loadTextureType.add(new VarInsnNode(ALOAD, 2));
|
||||||
|
return this.redirectHttpTextureConstructorToFake(
|
||||||
|
context,
|
||||||
|
context.findMethod(SKIN_MANAGER, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")" + objectDesc(IDENTIFIER)),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||||
|
loadTextureType
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 19w37a- (1.14.4-)
|
||||||
|
this.rule("skin-manager.register-skins.v1", SKIN_MANAGER, "[,553]", context ->
|
||||||
|
this.replaceExecutorProfileLoadAtInvocation(
|
||||||
|
context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
|
||||||
|
EXECUTOR_SERVICE, "submit", "(" + objectDesc(RUNNABLE) + ")" + objectDesc(FUTURE)));
|
||||||
|
// 19w38a ~ 1.18-exp7 (1.15 ~ 1.17.1)
|
||||||
|
this.rule("skin-manager.register-skins.v2", SKIN_MANAGER, "[554,756],[801,803],[0x40000001,0x4000002F]+[2205,2831]", context ->
|
||||||
|
this.replaceExecutorProfileLoadAtInvocation(
|
||||||
|
context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
|
||||||
|
EXECUTOR, "execute", "(" + objectDesc(RUNNABLE) + ")V"));
|
||||||
|
// 21w37a ~ 1.20.1 (1.18 ~ 1.20.1)
|
||||||
|
this.rule("skin-manager.register-skins.v3", SKIN_MANAGER, "[757,763],[0x40000029,0x4000008E]+[2834,3465]", context ->
|
||||||
|
this.replaceExecutorProfileLoadAtInvocation(
|
||||||
|
context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
|
||||||
|
EXECUTOR_SERVICE, "execute", "(" + objectDesc(RUNNABLE) + ")V"));
|
||||||
|
|
||||||
|
this.rule("skin-manager.get-insecure-skin-information", SKIN_MANAGER, "[,763],[801,803],[0x40000001,0x4000008E]", context -> {
|
||||||
|
MethodNode methodNode = context.findMethod(SKIN_MANAGER, "getInsecureSkinInformation", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP));
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
injection.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP), false));
|
||||||
|
injection.add(new InsnNode(ARETURN));
|
||||||
|
injection.add(new FrameNode(F_SAME, 0, null, 0, null));
|
||||||
|
methodNode.instructions.insert(injection);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 1.13.2 ~ 1.20.1
|
||||||
|
this.rule("skin-manager.lambda-register-skins-4", SKIN_MANAGER, "[404,763],[801,803],[0x40000001,0x4000008E]", context ->
|
||||||
|
this.replaceGetTexturesWithFakeUserProfile(context, context.findMethod(SKIN_MANAGER, "lambda$registerSkins$4",
|
||||||
|
"(" + objectDesc(GAME_PROFILE) + "Z" + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")V")));
|
||||||
|
|
||||||
|
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
|
||||||
|
this.rule("skin-manager.cache-key.v1", SKIN_MANAGER, "[765,772],[0x4000009D,0x40000106]", context ->
|
||||||
|
this.redirectCacheKeyConstruction(context, context.findMethod(SKIN_MANAGER, "getOrLoad", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE))));
|
||||||
|
// 25w34a+ (1.21.9+)
|
||||||
|
this.rule("skin-manager.cache-key.v2", SKIN_MANAGER, "[773,800],[804,0x40000000],[0x40000107,]", context ->
|
||||||
|
this.redirectCacheKeyConstruction(context, context.findMethod(SKIN_MANAGER, "get", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE))));
|
||||||
|
|
||||||
|
// 23w31a+ (1.20.2+)
|
||||||
|
this.rule("skin-manager-1.executor", SKIN_MANAGER_1, "[764,800],[804,0x40000000],[0x40000090,]", context -> {
|
||||||
|
MethodNode methodNode = context.findMethod(SKIN_MANAGER_1, "load", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean modified = false;
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (COMPLETABLE_FUTURE.equals(methodInsnNode.owner)
|
||||||
|
&& (("supplyAsync".equals(methodInsnNode.name) && ("(" + objectDesc(SUPPLIER) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc))
|
||||||
|
|| ("thenComposeAsync".equals(methodInsnNode.name) && ("(" + objectDesc(FUNCTION) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc)))) {
|
||||||
|
methodNode.instructions.insertBefore(instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(EXECUTOR) + ")" + objectDesc(EXECUTOR), false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 23w31a ~ 23w41a (1.20.2)
|
||||||
|
this.rule("skin-manager-1.lambda-load-0.v1", SKIN_MANAGER_1, "764,[0x40000090,0x4000009C]", context -> {
|
||||||
|
MethodNode methodNode = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_TEXTURE_INFO));
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean modified = false;
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) && "getTextures".equals(methodInsnNode.name)
|
||||||
|
&& ("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
|
||||||
|
this.rule("skin-manager-1.lambda-load-0.v2", SKIN_MANAGER_1, "[765,772],[0x4000009D,0x40000106]", context ->
|
||||||
|
this.replaceUnpackTexturesWithFakeSkinCache(context, context.findMethod(SKIN_MANAGER_1, "lambda$load$0",
|
||||||
|
"(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)), MINECRAFT_SESSION_SERVICE));
|
||||||
|
// 25w34a ~ 26.3-snapshot-1 (1.21.9 ~ 26.2)
|
||||||
|
this.rule("skin-manager-1.lambda-load-0.v3", SKIN_MANAGER_1, "[773,776],[0x40000107,0x40000143]", context ->
|
||||||
|
this.replaceUnpackTexturesWithFakeSkinCache(context, context.findMethod(SKIN_MANAGER_1, "lambda$load$0",
|
||||||
|
"(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(SERVICES) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)), MINECRAFT_SESSION_SERVICE));
|
||||||
|
// 26.3-snapshot-2+ (26.3+)
|
||||||
|
this.rule("skin-manager-1.lambda-load-0.v4", SKIN_MANAGER_1, "[777,800],[804,0x40000000],[0x40000144,]", context ->
|
||||||
|
this.replaceUnpackTexturesWithFakeSkinCache(context, context.findMethod(SKIN_MANAGER_1, "lambda$load$0",
|
||||||
|
"(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(SERVICES) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)), SESSION_SERVICE));
|
||||||
|
|
||||||
|
// 1.12.2-
|
||||||
|
this.rule("skin-manager-3.get-user-profile", SKIN_MANAGER_3, "[,340]", context ->
|
||||||
|
this.replaceGetTexturesWithFakeUserProfile(context, context.findMethod(SKIN_MANAGER_3, "run", "()V")));
|
||||||
|
|
||||||
|
// 23w31a+ (1.20.2+)
|
||||||
|
this.rule("skin-manager-cache-key.access", SKIN_MANAGER_CACHE_KEY, "[764,800],[804,0x40000000],[0x40000090,]", context -> {
|
||||||
|
boolean modified = this.makeClassPublicNonFinal(context.getCurrentClassNode());
|
||||||
|
modified |= this.makeMethodPublicNonFinal(context.findMethod(SKIN_MANAGER_CACHE_KEY, "<init>", "(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V"));
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
|
||||||
|
this.rule("skin-manager-texture-cache.http-texture", SKIN_MANAGER_TEXTURE_CACHE, "[764,768],[0x40000090,0x400000DD]", context -> {
|
||||||
|
InsnList loadType = new InsnList();
|
||||||
|
loadType.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
loadType.add(new FieldInsnNode(GETFIELD, context.remapClassName(SKIN_MANAGER_TEXTURE_CACHE), context.remapFieldName(SKIN_MANAGER_TEXTURE_CACHE, "type"), objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE)));
|
||||||
|
return this.redirectHttpTextureConstructorToFake(
|
||||||
|
context,
|
||||||
|
context.findMethod(SKIN_MANAGER_TEXTURE_CACHE, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE)),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
|
||||||
|
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||||
|
loadType
|
||||||
|
);
|
||||||
|
});
|
||||||
|
// 24w46a ~ 25w34b (1.21.4 ~ 1.21.8)
|
||||||
|
this.rule("skin-manager-texture-cache.skin-texture-downloader.v1", SKIN_MANAGER_TEXTURE_CACHE, "[769,772],[0x400000DE,0x40000108]", context ->
|
||||||
|
this.redirectSkinTextureDownloaderToFake(context, context.findMethod(SKIN_MANAGER_TEXTURE_CACHE, "registerTexture",
|
||||||
|
"(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE)), INVOKESTATIC));
|
||||||
|
// 25w35a+ (1.21.9+)
|
||||||
|
this.rule("skin-manager-texture-cache.skin-texture-downloader.v2", SKIN_MANAGER_TEXTURE_CACHE, "[773,800],[804,0x40000000],[0x40000109,]", context ->
|
||||||
|
this.redirectSkinTextureDownloaderToFake(context, context.findMethod(SKIN_MANAGER_TEXTURE_CACHE, "registerTexture",
|
||||||
|
"(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE)), INVOKEVIRTUAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean injectSetSkinCacheDir(ClassTransformationContext context, String constructorDesc, int localIndex, String argumentDesc) {
|
||||||
|
MethodNode methodNode = context.findMethod(SKIN_MANAGER, "<init>", constructorDesc);
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String remappedArgumentDesc = context.remapMethodDescriptor("(" + argumentDesc + ")V");
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (instruction.getOpcode() != RETURN) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
injection.add(new VarInsnNode(ALOAD, localIndex));
|
||||||
|
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "setSkinCacheDir", remappedArgumentDesc, false));
|
||||||
|
methodNode.instructions.insertBefore(instruction, injection);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean redirectHttpTextureConstructorToFake(ClassTransformationContext context, MethodNode methodNode, String originalDesc, String replacementDesc, InsnList loadTextureType) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String originalOwner = context.remapClassName(HTTP_TEXTURE);
|
||||||
|
String replacementOwner = context.remapClassName(FAKE_HTTP_TEXTURE_V1);
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (methodInsnNode.getOpcode() != INVOKESPECIAL || !originalOwner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !originalDesc.equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, originalOwner);
|
||||||
|
if (!(newNode instanceof TypeInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
((TypeInsnNode) newNode).desc = replacementOwner;
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
injection.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
injection.add(this.clone(loadTextureType));
|
||||||
|
methodNode.instructions.insertBefore(methodInsnNode, injection);
|
||||||
|
methodInsnNode.owner = replacementOwner;
|
||||||
|
methodInsnNode.desc = replacementDesc;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean redirectSkinTextureDownloaderToFake(ClassTransformationContext context, MethodNode methodNode, int opcode) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
|
||||||
|
String desc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
String name = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin", "(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION4) + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
String functionDesc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + objectDesc(BOOLEAN) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (methodInsnNode.getOpcode() != opcode || !owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
if (opcode == INVOKESTATIC) {
|
||||||
|
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, "", functionDesc, insnNode -> insnNode.getOpcode() == ASTORE, H_INVOKESTATIC)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String skinManagerOwner = context.remapClassName(SKIN_MANAGER);
|
||||||
|
String fieldName = context.remapFieldName(SKIN_MANAGER, "skinTextureDownloader");
|
||||||
|
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, objectDesc(owner), functionDesc, insnNode -> {
|
||||||
|
if (insnNode.getOpcode() == GETFIELD) {
|
||||||
|
FieldInsnNode fieldInsnNode = (FieldInsnNode) insnNode;
|
||||||
|
return skinManagerOwner.equals(fieldInsnNode.owner) && fieldName.equals(fieldInsnNode.name) && objectDesc(owner).equals(fieldInsnNode.desc);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, H_INVOKEVIRTUAL)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
injection.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
methodNode.instructions.insertBefore(methodInsnNode, injection);
|
||||||
|
methodNode.instructions.set(methodInsnNode, new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "downloadAndRegisterSkin", replacementDesc, false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceSkinTextureDownloaderReceiver(MethodNode methodNode, MethodInsnNode invoke, String owner, String name, String desc, String ownerDesc, String functionDesc, Predicate<AbstractInsnNode> predicate, int handleTag) {
|
||||||
|
AbstractInsnNode current = invoke.getPrevious();
|
||||||
|
while (current != null) {
|
||||||
|
if (predicate.test(current)) {
|
||||||
|
methodNode.instructions.insert(current, new InvokeDynamicInsnNode(
|
||||||
|
"apply", "(" + ownerDesc + ")" + objectDesc(FUNCTION4),
|
||||||
|
new Handle(H_INVOKESTATIC, LAMBDA_METAFACTORY, "metafactory", "(" + objectDesc(METHOD_HANDLES_LOOKUP) + objectDesc(STRING) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_HANDLE) + objectDesc(METHOD_TYPE) + ")" + objectDesc(CALL_SITE), false),
|
||||||
|
Type.getType("(" + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + ")" + objectDesc(OBJECT)),
|
||||||
|
new Handle(handleTag, owner, name, desc, false),
|
||||||
|
Type.getType(functionDesc)
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
current = current.getPrevious();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceExecutorProfileLoadAtInvocation(ClassTransformationContext context, MethodNode methodNode, String owner, String name, String desc) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, methodInsnNode = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(OBJECT) + objectDesc(RUNNABLE) + ")V", false));
|
||||||
|
if (!desc.endsWith("V")) {
|
||||||
|
methodNode.instructions.insert(methodInsnNode, new InsnNode(ACONST_NULL));
|
||||||
|
}
|
||||||
|
modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceGetTexturesWithFakeUserProfile(ClassTransformationContext context, MethodNode methodNode) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"getTextures".equals(methodInsnNode.name) || !("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "getUserProfile", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean redirectCacheKeyConstruction(ClassTransformationContext context, MethodNode methodNode) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String owner = context.remapClassName(SKIN_MANAGER_CACHE_KEY);
|
||||||
|
String desc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V");
|
||||||
|
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_CACHE_KEY));
|
||||||
|
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!owner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, owner);
|
||||||
|
AbstractInsnNode dupNode = this.nextRealInstruction(newNode);
|
||||||
|
if (newNode == null || dupNode == null || dupNode.getOpcode() != DUP) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
methodNode.instructions.remove(newNode);
|
||||||
|
methodNode.instructions.remove(dupNode);
|
||||||
|
|
||||||
|
InsnList replacement = new InsnList();
|
||||||
|
replacement.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_CACHE_KEY, "createFakeCacheKey", replacementDesc, false));
|
||||||
|
methodNode.instructions.insertBefore(methodInsnNode, replacement);
|
||||||
|
methodNode.instructions.remove(methodInsnNode);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceUnpackTexturesWithFakeSkinCache(ClassTransformationContext context, MethodNode methodNode, String owner) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String desc = context.remapMethodDescriptor("(" + objectDesc(OBJECT) + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(OBJECT));
|
||||||
|
String returnType = context.remapClassName(MINECRAFT_PROFILE_TEXTURES);
|
||||||
|
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!owner.equals(methodInsnNode.owner) || !"unpackTextures".equals(methodInsnNode.name) || !("(" + objectDesc(PROPERTY) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)).equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsnList insnList = new InsnList();
|
||||||
|
insnList.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
insnList.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", desc, false));
|
||||||
|
insnList.add(new TypeInsnNode(CHECKCAST, returnType));
|
||||||
|
methodNode.instructions.insert(instruction, insnList);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
+129
@@ -0,0 +1,129 @@
|
|||||||
|
package customskinloader.bootstrap.transformer.patch;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
public final class SkinTexturePatch extends PatchSupport {
|
||||||
|
public SkinTexturePatch() {
|
||||||
|
super("customskinloader:skin-texture-patch", 1000);
|
||||||
|
|
||||||
|
// 24w45a- (1.21.3-)
|
||||||
|
this.rule("http-texture.uploaded", HTTP_TEXTURE, "[,768],[801,803],[0x40000001,0x400000DD]", context ->
|
||||||
|
this.makeFieldPublicNonFinal(context.findField(HTTP_TEXTURE, "uploaded")));
|
||||||
|
|
||||||
|
// 19w38a ~ 24w45a (1.15 ~ 1.21.3)
|
||||||
|
this.rule("http-texture.process-legacy-skin", HTTP_TEXTURE, "[554,768],[801,803],[0x40000001,0x400000DD]", context -> {
|
||||||
|
MethodNode load = context.findMethod(HTTP_TEXTURE, "load", "(" + objectDesc(INPUT_STREAM) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
if (load == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String owner = context.remapClassName(HTTP_TEXTURE);
|
||||||
|
String originalName = context.remapMethodName(HTTP_TEXTURE, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
String imageDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
String conditionDesc = context.remapMethodDescriptor("(" + objectDesc(RUNNABLE) + ")Z");
|
||||||
|
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(RUNNABLE) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
String processTaskField = context.remapFieldName(HTTP_TEXTURE, "onDownloaded");
|
||||||
|
for (AbstractInsnNode instruction : load.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!owner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !imageDesc.equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
load.instructions.insertBefore(instruction, new VarInsnNode(ALOAD, 0));
|
||||||
|
load.instructions.insertBefore(instruction, new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
|
||||||
|
MethodInsnNode processLegacySkin = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", replacementDesc, false);
|
||||||
|
this.replaceInstructionSafely(context, load, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "shouldProcessLegacySkin", conditionDesc, false), IFNE, instruction, processLegacySkin);
|
||||||
|
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
if (methodInsnNode.getOpcode() == INVOKESTATIC) {
|
||||||
|
injection.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
} else {
|
||||||
|
injection.add(new InsnNode(SWAP));
|
||||||
|
}
|
||||||
|
injection.add(new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
|
||||||
|
load.instructions.insertBefore(processLegacySkin, injection);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 24w46a+ (1.21.4+)
|
||||||
|
this.rule("skin-texture-downloader.then-compose", SKIN_TEXTURE_DOWNLOADER, "[769,800],[804,0x40000000],[0x400000DE,]", context -> {
|
||||||
|
MethodNode methodNode = context.findMethod(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin",
|
||||||
|
"(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
int locationLocal = (methodNode.access & ACC_STATIC) == 0 ? 1 : 0;
|
||||||
|
int booleanLocal = locationLocal + 3;
|
||||||
|
String remappedHookDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION) + objectDesc(IDENTIFIER) + "Z)" + objectDesc(FUNCTION));
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (!COMPLETABLE_FUTURE.equals(methodInsnNode.owner) || !"thenCompose".equals(methodInsnNode.name)
|
||||||
|
|| !("(" + objectDesc(FUNCTION) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsnList injection = new InsnList();
|
||||||
|
injection.add(new VarInsnNode(ALOAD, locationLocal));
|
||||||
|
injection.add(new VarInsnNode(ILOAD, booleanLocal));
|
||||||
|
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "createTexture", remappedHookDesc, false));
|
||||||
|
methodNode.instructions.insertBefore(instruction, injection);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 24w46a ~ 25w37a (1.21.4 ~ 1.21.8)
|
||||||
|
this.rule("skin-texture-downloader.process-legacy-skin.v1", SKIN_TEXTURE_DOWNLOADER, "[769,772],[0x400000DE,0x4000010C]", context ->
|
||||||
|
this.replaceSkinTextureDownloaderProcessLegacySkin(
|
||||||
|
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0",
|
||||||
|
"(" + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(NATIVE_IMAGE))));
|
||||||
|
// 1.21.9-pre1+ (1.21.9+)
|
||||||
|
this.rule("skin-texture-downloader.process-legacy-skin.v2", SKIN_TEXTURE_DOWNLOADER, "[773,800],[804,0x40000000],[0x4000010D,]", context ->
|
||||||
|
this.replaceSkinTextureDownloaderProcessLegacySkin(
|
||||||
|
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0",
|
||||||
|
"(" + objectDesc(PATH) + objectDesc(CLIENT_ASSET_DOWNLOADED_TEXTURE) + "Z)" + objectDesc(NATIVE_IMAGE))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context, MethodNode methodNode) {
|
||||||
|
if (methodNode == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
|
||||||
|
String originalDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
String originalName = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
|
||||||
|
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||||
|
if (!(instruction instanceof MethodInsnNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||||
|
if (methodInsnNode.getOpcode() == INVOKESTATIC && owner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && originalDesc.equals(methodInsnNode.desc)) {
|
||||||
|
this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", originalDesc, false));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package customskinloader.bootstrap.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.installer.CommonJarInstaller;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared setup for Forge-style mods-folder locators that expose the released jar as a synthetic mod.
|
||||||
|
*/
|
||||||
|
public final class ModLocatorUtils {
|
||||||
|
public static final String LOCATOR_NAME = "customskinloader-locator";
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
private ModLocatorUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initialize(Object locator, Class<?> locatorType, Path gameDirectory, String mappingType) {
|
||||||
|
try {
|
||||||
|
Path runtimeDirectory = resolveRuntimeDirectory(gameDirectory);
|
||||||
|
LOGGER.info("Initializing " + LOCATOR_NAME + " for " + mappingType + " mappings in " + BootstrapLogger.formatPath(gameDirectory));
|
||||||
|
setModFolder(locator, locatorType, runtimeDirectory);
|
||||||
|
Path commonJar = CommonJarInstaller.releaseCommonJar(gameDirectory, mappingType);
|
||||||
|
LOGGER.info("Initialized " + LOCATOR_NAME + " with mod folder " + BootstrapLogger.formatPath(runtimeDirectory)
|
||||||
|
+ " and Common jar " + BootstrapLogger.formatPath(commonJar));
|
||||||
|
} catch (Exception exception) {
|
||||||
|
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
|
||||||
|
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path resolveRuntimeDirectory(Path gameDirectory) {
|
||||||
|
return gameDirectory.resolve("CustomSkinLoader").resolve("Core");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setModFolder(Object locator, Class<?> locatorType, Path modFolder) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
Field field = locatorType.getDeclaredField("modFolder");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(locator, modFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package customskinloader.bootstrap.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared matcher for protocol and ordinal range expressions.
|
||||||
|
*/
|
||||||
|
public final class RangeMatcher {
|
||||||
|
private RangeMatcher() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean matches(String expression, int protocolVersion, int worldVersion) {
|
||||||
|
if (expression == null || expression.trim().isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String protocolRange = "";
|
||||||
|
String worldRange = "";
|
||||||
|
int index = expression.indexOf("+");
|
||||||
|
if (index >= 0) {
|
||||||
|
protocolRange = expression.substring(0, index);
|
||||||
|
worldRange = expression.substring(index + 1);
|
||||||
|
} else {
|
||||||
|
protocolRange = expression;
|
||||||
|
}
|
||||||
|
return matches(protocolRange, protocolVersion) && matches(worldRange, worldVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean matches(String expression, int value) {
|
||||||
|
if (expression == null || expression.trim().isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String token : splitTokens(expression)) {
|
||||||
|
String trimmedToken = token.trim();
|
||||||
|
if (trimmedToken.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trimmedToken.startsWith("[") && trimmedToken.endsWith("]")) {
|
||||||
|
int commaIndex = trimmedToken.indexOf(',');
|
||||||
|
if (commaIndex < 0) {
|
||||||
|
throw new IllegalArgumentException("Invalid range token: " + trimmedToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
String leftPart = trimmedToken.substring(1, commaIndex).trim();
|
||||||
|
String rightPart = trimmedToken.substring(commaIndex + 1, trimmedToken.length() - 1).trim();
|
||||||
|
int lowerBound = leftPart.isEmpty() ? 0 : parseNumber(leftPart);
|
||||||
|
int upperBound = rightPart.isEmpty() ? Integer.MAX_VALUE : parseNumber(rightPart);
|
||||||
|
if (value >= lowerBound && value <= upperBound) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == parseNumber(trimmedToken)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> splitTokens(String expression) {
|
||||||
|
List<String> tokens = new ArrayList<>();
|
||||||
|
StringBuilder currentToken = new StringBuilder();
|
||||||
|
int bracketDepth = 0;
|
||||||
|
|
||||||
|
for (int index = 0; index < expression.length(); index++) {
|
||||||
|
char currentChar = expression.charAt(index);
|
||||||
|
if (currentChar == '[') {
|
||||||
|
bracketDepth++;
|
||||||
|
} else if (currentChar == ']') {
|
||||||
|
bracketDepth--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentChar == ',' && bracketDepth == 0) {
|
||||||
|
tokens.add(currentToken.toString());
|
||||||
|
currentToken.setLength(0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentToken.append(currentChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
tokens.add(currentToken.toString());
|
||||||
|
return tokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseNumber(String token) {
|
||||||
|
String trimmedToken = token.trim();
|
||||||
|
if (trimmedToken.startsWith("0x")) {
|
||||||
|
return Integer.parseInt(trimmedToken.substring(2), 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(trimmedToken, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package customskinloader.bootstrap.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
|
||||||
|
public class ReflectionUtils {
|
||||||
|
private static final Map<String, Class<?>> CLASSES = new ConcurrentHashMap<>();
|
||||||
|
private static final Map<Pair<Class<?>, String>, Field> FIELDS = new ConcurrentHashMap<>();
|
||||||
|
private static final Map<Triple<Class<?>, String, List<Class<?>>>, Method> METHODS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static Class<?> findClass(String className) {
|
||||||
|
return CLASSES.computeIfAbsent(className, k -> {
|
||||||
|
try {
|
||||||
|
return Class.forName(k);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field findField(Class<?> clazz, String fieldName) {
|
||||||
|
return FIELDS.computeIfAbsent(Pair.of(clazz, fieldName), k -> {
|
||||||
|
try {
|
||||||
|
Field f = k.getLeft().getDeclaredField(k.getRight());
|
||||||
|
f.setAccessible(true);
|
||||||
|
return f;
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Method findMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
||||||
|
return METHODS.computeIfAbsent(Triple.of(clazz, methodName, Arrays.asList(parameterTypes)), k -> {
|
||||||
|
try {
|
||||||
|
Method m = k.getLeft().getDeclaredMethod(k.getMiddle(), k.getRight().toArray(new Class<?>[0]));
|
||||||
|
m.setAccessible(true);
|
||||||
|
return m;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package customskinloader.bootstrap.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.XMLConstants;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small DOM helpers shared by mapping and patch XML parsers.
|
||||||
|
*/
|
||||||
|
public final class XmlUtils {
|
||||||
|
private XmlUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Document parseDocument(Reader reader, String documentDescription) throws IOException {
|
||||||
|
try {
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||||
|
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||||
|
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
|
||||||
|
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
|
||||||
|
factory.setExpandEntityReferences(false);
|
||||||
|
factory.setIgnoringComments(true);
|
||||||
|
|
||||||
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
Document document = builder.parse(new InputSource(reader));
|
||||||
|
document.getDocumentElement().normalize();
|
||||||
|
return document;
|
||||||
|
} catch (ParserConfigurationException exception) {
|
||||||
|
throw new IOException("Failed to configure XML parser for " + documentDescription, exception);
|
||||||
|
} catch (SAXException exception) {
|
||||||
|
throw new IOException("Failed to parse " + documentDescription, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String requiredAttribute(Element element, String attributeName) {
|
||||||
|
String value = element.getAttribute(attributeName);
|
||||||
|
if (value.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Missing required attribute '" + attributeName + "' on <" + element.getTagName() + ">");
|
||||||
|
}
|
||||||
|
return value.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Element> childElements(Element parentElement, String requiredTagName) {
|
||||||
|
if (parentElement == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Element> elements = new ArrayList<>();
|
||||||
|
NodeList childNodes = parentElement.getChildNodes();
|
||||||
|
for (int index = 0; index < childNodes.getLength(); index++) {
|
||||||
|
Node currentNode = childNodes.item(index);
|
||||||
|
if (currentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Element currentElement = (Element) currentNode;
|
||||||
|
if (requiredTagName == null || requiredTagName.equals(currentElement.getTagName())) {
|
||||||
|
elements.add(currentElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+4
@@ -0,0 +1,4 @@
|
|||||||
|
customskinloader.bootstrap.transformer.patch.InterfacePatch
|
||||||
|
customskinloader.bootstrap.transformer.patch.RenderPatch
|
||||||
|
customskinloader.bootstrap.transformer.patch.SkinManagerPatch
|
||||||
|
customskinloader.bootstrap.transformer.patch.SkinTexturePatch
|
||||||
@@ -0,0 +1,457 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<mapping>
|
||||||
|
<class name="com/mojang/blaze3d/platform/NativeImage">
|
||||||
|
<name type="srg" version="[404,754]">net/minecraft/client/renderer/texture/NativeImage</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1011</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="copyFrom(Lcom/mojang/blaze3d/platform/NativeImage;)V">
|
||||||
|
<name type="srg" version="[404,754]">func_195703_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_85054_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4317</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="copyRect(IIIIIIZZ)V">
|
||||||
|
<name type="srg" version="[404,754]">func_195699_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_85025_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4304</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="fillRect(IIIII)V">
|
||||||
|
<name type="srg" version="[404,754]">func_195715_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_84997_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4326</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getHeight()I">
|
||||||
|
<name type="srg" version="[404,754]">func_195714_b</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_85084_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4323</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getPixelRGBA(II)I">
|
||||||
|
<name type="srg" version="[404,754]">func_195709_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_84985_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4315</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getWidth()I">
|
||||||
|
<name type="srg" version="[404,754]">func_195702_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_84982_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4307</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="read(Ljava/io/InputStream;)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="srg" version="[404,754]">func_195713_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_85058_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4309</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="setPixelRGBA(III)V">
|
||||||
|
<name type="srg" version="[404,754]">func_195700_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_84988_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_4305</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="com/mojang/blaze3d/vertex/PoseStack">
|
||||||
|
<name type="srg" version="[404,754]">com/mojang/blaze3d/matrix/MatrixStack</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_4587</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/FakeHttpTextureProcessor"> <!-- net/minecraft/client/renderer/HttpTextureProcessor -->
|
||||||
|
<name type="srg" version="[,553]">net/minecraft/client/renderer/IImageBuffer</name> <!-- 19w37a- (1.14.4-) -->
|
||||||
|
<name type="intermediary" version="[441,553]">net/minecraft/class_760</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
|
||||||
|
<method name="onTextureDownloaded()V">
|
||||||
|
<name type="srg" version="[,553]">func_152634_a</name> <!-- 19w37a- (1.14.4-) -->
|
||||||
|
<name type="intermediary" version="[441,553]">method_3238</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
|
||||||
|
</method>
|
||||||
|
<method name="process(Lcom/mojang/blaze3d/platform/NativeImage;)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="srg" version="[404,553]">func_195786_a</name> <!-- 1.13.2 ~ 19w37a (1.13.2 ~ 1.14.4) -->
|
||||||
|
<name type="intermediary" version="[441,553]">method_3237</name> <!-- 18w43b ~ 19w37a (1.14 ~ 1.14.4) -->
|
||||||
|
</method>
|
||||||
|
<method name="process(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;">
|
||||||
|
<name type="srg" version="[,340]">func_78432_a</name> <!-- 1.12.2- -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/IFakeIResource$V1">
|
||||||
|
<method name="getInputStream()Ljava/io/InputStream;">
|
||||||
|
<name type="srg" version="[,340]">func_110527_b</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="[404,754]">func_199027_b</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,758]">m_6679_</name> <!-- 1.17.1 ~ 1.18.2 -->
|
||||||
|
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14482</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/IFakeIResource$V2">
|
||||||
|
<method name="open()Ljava/io/InputStream;">
|
||||||
|
<name type="srg" version="[759,765]">m_215507_</name> <!-- 1.19 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14482</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/IFakeIResourceManager$V1">
|
||||||
|
<method name="getResource(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/Resource;">
|
||||||
|
<name type="srg" version="[,340]">func_110536_a</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="[404,754]">func_199002_a</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,758]">m_142591_</name> <!-- 1.17.1 ~ 1.18.2 -->
|
||||||
|
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14486</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/IFakeIResourceManager$V2">
|
||||||
|
<method name="getResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional;">
|
||||||
|
<name type="srg" version="[759,765]">m_213713_</name> <!-- 1.19 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14486</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="customskinloader/fake/itf/IFakeNativeImage">
|
||||||
|
<method name="getPixel(II)I">
|
||||||
|
<name type="intermediary" version="[768,774],[0x400000CD,0x4000011E]">method_61940</name> <!-- 24w33a ~ 1.21.11 (1.21.2 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="setPixel(III)V">
|
||||||
|
<name type="intermediary" version="[768,774],[0x400000CD,0x4000011E]">method_61941</name> <!-- 24w33a ~ 1.21.11 (1.21.2 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/Minecraft">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_310</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<field name="gameDirectory">
|
||||||
|
<name type="srg" version="[,754]">field_71412_D</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">f_91069_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">field_1697</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</field>
|
||||||
|
<method name="getCurrentServer()Lnet/minecraft/client/multiplayer/ServerData;">
|
||||||
|
<name type="srg" version="[,754]">func_147104_D</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_91089_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1558</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getInstance()Lnet/minecraft/client/Minecraft;">
|
||||||
|
<name type="srg" version="[,754]">func_71410_x</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_91087_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1551</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getResourceManager()Lnet/minecraft/server/packs/resources/ResourceManager;">
|
||||||
|
<name type="srg" version="[,340]">func_110442_L</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="[404,754]">func_195551_G</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_91098_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1478</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getSkinManager()Lnet/minecraft/client/resources/SkinManager;">
|
||||||
|
<name type="srg" version="[,754]">func_152342_ad</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_91109_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1582</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getTextureManager()Lnet/minecraft/client/renderer/texture/TextureManager;">
|
||||||
|
<name type="srg" version="[,754]">func_110434_K</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_91097_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1531</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="isLocalServer()Z">
|
||||||
|
<name type="srg" version="[,754]">func_71387_A</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_91090_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_1542</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/gui/GuiGraphics">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_332</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/gui/GuiGraphicsExtractor" />
|
||||||
|
<class name="net/minecraft/client/gui/components/PlayerTabOverlay">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/client/gui/GuiPlayerTabOverlay</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_355</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V" />
|
||||||
|
<method name="render(ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
|
||||||
|
<name type="srg" version="[,578]">func_175249_a</name> <!-- 1.15.2- -->
|
||||||
|
<name type="intermediary" version="[441,712]">method_1919</name> <!-- 18w43b ~ 20w16a (1.14 ~ 1.15.2) -->
|
||||||
|
</method>
|
||||||
|
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
|
||||||
|
<name type="srg" version="[736,754]">func_238523_a_</name> <!-- 1.16.1 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,762]">m_94544_</name> <!-- 1.17.1 ~ 1.19.4 -->
|
||||||
|
<name type="intermediary" version="[713,762],[801,803],[0x40000001,0x40000082]">method_1919</name> <!-- 20w17a ~ 23w14a (1.16 ~ 1.19.4) -->
|
||||||
|
</method>
|
||||||
|
<method name="render(Lnet/minecraft/client/gui/GuiGraphics;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V">
|
||||||
|
<name type="srg" version="[763,765]">m_280406_</name> <!-- 1.20 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[763,774],[0x40000083,0x4000011E]">method_1919</name> <!-- 23w16a ~ 1.21.11 (1.20 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/model/geom/ModelPart">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/client/renderer/model/ModelRenderer</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_630</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/multiplayer/ClientPacketListener">
|
||||||
|
<name type="srg" version="[,404]">net/minecraft/client/network/NetHandlerPlayClient</name> <!-- 1.13.2- -->
|
||||||
|
<name type="srg" version="[485,754]">net/minecraft/client/network/play/ClientPlayNetHandler</name> <!-- 1.14.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_634</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="onlineMode()Z" />
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/multiplayer/ServerData">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_642</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<field name="ip">
|
||||||
|
<name type="srg" version="[,754]">field_78845_b</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">f_105363_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">field_3761</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</field>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/player/AbstractClientPlayer">
|
||||||
|
<name type="srg" version="[,404]">net/minecraft/client/entity/AbstractClientPlayer</name> <!-- 1.13.2- -->
|
||||||
|
<name type="srg" version="[485,754]">net/minecraft/client/entity/player/AbstractClientPlayerEntity</name> <!-- 1.14.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_742</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/MultiBufferSource">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/client/renderer/IRenderTypeBuffer</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_4597</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/SubmitNodeCollector">
|
||||||
|
<name type="intermediary" version="[773,774],[0x40000104,0x4000011E]">net/minecraft/class_11659</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/entity/layers/CapeLayer">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_972</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V">
|
||||||
|
<name type="srg" version="[573,754]">func_225628_a_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_6494_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[573,767],[801,803],[0x40000001,0x400000CC]">method_4177</name> <!-- 1.15 ~ 1.21.1 -->
|
||||||
|
</method>
|
||||||
|
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFFF)V">
|
||||||
|
<name type="intermediary" version="[556,560]">method_4177</name> <!-- 19w39a ~ 19w44a -->
|
||||||
|
</method>
|
||||||
|
<method name="render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V">
|
||||||
|
<name type="intermediary" version="[768,772],[0x400000CD,0x40000103]">method_4177</name> <!-- 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8) -->
|
||||||
|
</method>
|
||||||
|
<method name="submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V">
|
||||||
|
<name type="intermediary" version="[773,774],[0x40000104,0x4000011E]">method_4177</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/entity/player/PlayerRenderer">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/client/renderer/entity/PlayerRenderer</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1007</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/client/model/geom/ModelPart;Lnet/minecraft/client/model/geom/ModelPart;)V">
|
||||||
|
<name type="srg" version="[573,754]">func_229145_a_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_117775_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[573,767],[801,803],[0x40000001,0x400000CC]">method_23205</name> <!-- 1.15 ~ 1.21.1 -->
|
||||||
|
</method>
|
||||||
|
<method name="renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/client/model/geom/ModelPart;Lnet/minecraft/client/model/geom/ModelPart;)V">
|
||||||
|
<name type="intermediary" version="[556,560]">method_23205</name> <!-- 19w39a ~ 19w44a -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/entity/state/AvatarRenderState">
|
||||||
|
<name type="intermediary" version="773,774,[0x40000104,0x4000011E]">net/minecraft/class_10055</name> <!-- 25w31a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/entity/state/PlayerRenderState">
|
||||||
|
<name type="intermediary" version="[768,772],[0x400000CD,0x40000103]">net/minecraft/class_10055</name> <!-- 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/rendertype/RenderType">
|
||||||
|
<name type="srg" version="[573,773]">net/minecraft/client/renderer/RenderType</name> <!-- 1.15 ~ 1.21.10 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1921</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<name type="official" version="[764,773]">net/minecraft/client/renderer/RenderType</name> <!-- 1.20.2 ~ 1.21.10 -->
|
||||||
|
<method name="entitySolid(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
|
||||||
|
<name type="srg" version="[573,754]">func_228634_a_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_110446_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[558,773],[801,803],[0x40000001,0x40000112]">method_23572</name> <!-- 19w41a ~ 25w42a (1.15 ~ 1.21.10) -->
|
||||||
|
</method>
|
||||||
|
<method name="entityTranslucent(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
|
||||||
|
<name type="srg" version="[573,754]">func_228644_e_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_110473_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[558,773],[801,803],[0x40000001,0x40000112]">method_23580</name> <!-- 19w41a ~ 25w42a (1.15 ~ 1.21.10) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/rendertype/RenderTypes">
|
||||||
|
<name type="intermediary" version="774,[0x40000113,0x4000011E]">net/minecraft/class_12249</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
|
||||||
|
<method name="entitySolid(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
|
||||||
|
<name type="intermediary" version="774,[0x40000113,0x4000011E]">method_75982</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="entityTranslucent(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;">
|
||||||
|
<name type="intermediary" version="774,[0x40000113,0x4000011E]">method_76000</name> <!-- 25w43a ~ 1.21.11 (1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/AbstractTexture">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1044</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/HttpTexture">
|
||||||
|
<name type="srg" version="[,340]">net/minecraft/client/renderer/ThreadDownloadImageData</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="404">net/minecraft/client/renderer/texture/ThreadDownloadImageData</name> <!-- 1.13.2 -->
|
||||||
|
<name type="srg" version="[485,754]">net/minecraft/client/renderer/texture/DownloadingTexture</name> <!-- 1.14.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,768],[801,803],[0x40000001,0x400000DD]">net/minecraft/class_1046</name> <!-- 18w43b ~ 24w45a (1.14 ~ 1.21.3) -->
|
||||||
|
<field name="onDownloaded">
|
||||||
|
<name type="srg" version="[573,754]">field_229155_i_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">f_117997_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[554,774],[801,803],[0x40000001,0x4000011E]">field_20843</name> <!-- 19w38a ~ 1.21.11 (1.15 ~ 1.21.11) -->
|
||||||
|
</field>
|
||||||
|
<field name="uploaded">
|
||||||
|
<name type="srg" version="[,754]">field_110559_g</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">f_117999_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,768],[801,803],[0x40000001,0x400000DD]">field_5215</name> <!-- 18w43b ~ 24w45a (1.14 ~ 1.21.3) -->
|
||||||
|
</field>
|
||||||
|
<method name="load(Ljava/io/InputStream;)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="srg" version="[404,754]">func_229159_a_</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_118018_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_22795</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="processLegacySkin(Lcom/mojang/blaze3d/platform/NativeImage;)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="srg" version="[404,754]">func_229163_c_</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_118032_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_22798</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="upload(Ljava/awt/image/BufferedImage;)V">
|
||||||
|
<name type="srg" version="[,340]">func_147641_a</name> <!-- 1.12.2- -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/ReloadableTexture">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10537</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/SimpleTexture">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1049</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="loadContents(Lnet/minecraft/server/packs/resources/ResourceManager;)Lnet/minecraft/client/renderer/texture/TextureContents;">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65809</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/SkinTextureDownloader">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10538</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
<method name="downloadAndRegisterSkin(Lnet/minecraft/resources/Identifier;Ljava/nio/file/Path;Ljava/lang/String;Z)Ljava/util/concurrent/CompletableFuture;">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65861</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Ljava/lang/String;Z)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="intermediary" version="[769,772],[0x400000DE,0x4000010C]">method_65866</name> <!-- 24w46a ~ 25w37a (1.21.4 ~ 1.21.8) -->
|
||||||
|
</method>
|
||||||
|
<method name="lambda$downloadAndRegisterSkin$0(Ljava/nio/file/Path;Lnet/minecraft/core/ClientAsset$DownloadedTexture;Z)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="intermediary" version="773,774,[0x4000010D,0x4000011E]">method_65866</name> <!-- 1.21.9-pre1 ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="processLegacySkin(Lcom/mojang/blaze3d/platform/NativeImage;Ljava/lang/String;)Lcom/mojang/blaze3d/platform/NativeImage;">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65863</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/TextureContents">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">net/minecraft/class_10539</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/renderer/texture/TextureManager">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1060</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="register(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V">
|
||||||
|
<name type="srg" version="[573,754]">func_229263_a_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,765]">m_118495_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[556,774],[801,803],[0x40000001,0x4000011E]">method_4616</name> <!-- 19w39a ~ 1.21.11 (1.15 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="registerAndLoad(Lnet/minecraft/resources/Identifier;Lnet/minecraft/client/renderer/texture/ReloadableTexture;)V">
|
||||||
|
<name type="intermediary" version="[769,774],[0x400000DE,0x4000011E]">method_65876</name> <!-- 24w46a ~ 1.21.11 (1.21.4 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1071</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<field name="skinTextureDownloader">
|
||||||
|
<name type="intermediary" version="773,774,[0x40000109,0x4000011E]">field_62487</name> <!-- 25w35a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</field>
|
||||||
|
<method name="get(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;">
|
||||||
|
<name type="intermediary" version="773,774,[0x40000107,0x4000011E]">method_52863</name> <!-- 25w34a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getInsecureSkinInformation(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;">
|
||||||
|
<name type="srg" version="[,754]">func_152788_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,763]">m_118815_</name> <!-- 1.17.1 ~ 1.20.1 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4654</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</method>
|
||||||
|
<method name="getOrLoad(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;">
|
||||||
|
<name type="srg" version="764,765">m_293351_</name> <!-- 1.20.2 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[764,772],[0x40000090,0x40000106]">method_52863</name> <!-- 23w31a ~ 25w33a (1.20.2 ~ 1.21.8) -->
|
||||||
|
</method>
|
||||||
|
<method name="lambda$registerSkins$4(Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)V">
|
||||||
|
<name type="srg" version="[404,498]">func_210275_a</name> <!-- 1.13.2 ~ 1.14.4 -->
|
||||||
|
<name type="srg" version="[573,754]">func_229293_a_</name> <!-- 1.15 ~ 1.16.5 -->
|
||||||
|
<name type="srg" version="[756,763]">m_118821_</name> <!-- 1.17.1 ~ 1.20.1 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4653</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</method>
|
||||||
|
<method name="registerSkins(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V">
|
||||||
|
<name type="srg" version="[,754]">func_152790_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,763]">m_118817_</name> <!-- 1.17.1 ~ 1.20.1 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4652</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</method>
|
||||||
|
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/resources/Identifier;">
|
||||||
|
<name type="srg" version="[,754]">func_152792_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,763]">m_118825_</name> <!-- 1.17.1 ~ 1.20.1 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4656</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</method>
|
||||||
|
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;)Lnet/minecraft/resources/Identifier;">
|
||||||
|
<name type="srg" version="[,754]">func_152789_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,763]">m_118828_</name> <!-- 1.17.1 ~ 1.20.1 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">method_4651</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager$1">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1071$1</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="lambda$load$0(Lcom/mojang/authlib/minecraft/MinecraftSessionService;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/client/resources/SkinManager$TextureInfo;">
|
||||||
|
<name type="srg" version="764">m_293645_</name> <!-- 1.20.2 -->
|
||||||
|
<name type="intermediary" version="764,[0x40000090,0x4000009C]">method_52867</name> <!-- 23w31a ~ 23w41a (1.20.2) -->
|
||||||
|
</method>
|
||||||
|
<method name="lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;">
|
||||||
|
<name type="srg" version="765">m_304063_</name> <!-- 1.20.3 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[765,772],[0x4000009D,0x40000106]">method_54647</name> <!-- 23w42a ~ 25w33a (1.20.3 ~ 1.21.8) -->
|
||||||
|
</method>
|
||||||
|
<method name="lambda$load$0(Lnet/minecraft/client/resources/SkinManager$CacheKey;Lnet/minecraft/server/Services;)Lcom/mojang/authlib/minecraft/MinecraftProfileTextures;">
|
||||||
|
<name type="intermediary" version="773,774,[0x40000107,0x4000011E]">method_54647</name> <!-- 25w34a ~ 1.21.11 (1.21.9 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="load(Lnet/minecraft/client/resources/SkinManager$CacheKey;)Ljava/util/concurrent/CompletableFuture;">
|
||||||
|
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">method_52868</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager$CacheKey">
|
||||||
|
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">net/minecraft/class_1071$class_8686</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager$SkinTextureCallback">
|
||||||
|
<name type="srg" version="[,404]">net/minecraft/client/resources/SkinManager$SkinAvailableCallback</name> <!-- 1.13.2- -->
|
||||||
|
<name type="srg" version="[485,754]">net/minecraft/client/resources/SkinManager$ISkinAvailableCallback</name> <!-- 1.14.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,763],[801,803],[0x40000001,0x4000008E]">net/minecraft/class_1071$class_1072</name> <!-- 18w43b ~ 1.20.1 (1.14 ~ 1.20.1) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager$TextureCache">
|
||||||
|
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">net/minecraft/class_1071$class_8687</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
|
||||||
|
<field name="type">
|
||||||
|
<name type="srg" version="764,765">f_291290_</name> <!-- 1.20.2 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">field_45641</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
|
||||||
|
</field>
|
||||||
|
<method name="registerTexture(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)Ljava/util/concurrent/CompletableFuture;">
|
||||||
|
<name type="srg" version="764,765">m_294542_</name> <!-- 1.20.2 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[764,774],[0x40000090,0x4000011E]">method_52873</name> <!-- 23w31a ~ 1.21.11 (1.20.2 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/SkinManager$TextureInfo">
|
||||||
|
<name type="intermediary" version="764,[0x40000090,0x4000009C]">net/minecraft/class_1071$class_8688</name> <!-- 23w31a ~ 23w41a (1.20.2) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/client/resources/metadata/texture/TextureMetadataSection">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/client/resources/data/TextureMetadataSection</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_1084</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/core/ClientAsset$DownloadedTexture">
|
||||||
|
<name type="intermediary" version="[765,774],[0x4000009C,0x4000011E]">net/minecraft/class_12079$class_12080</name> <!-- 23w41a ~ 1.21.11 (1.20.3 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/resources/Identifier">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/util/ResourceLocation</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,773]">net/minecraft/resources/ResourceLocation</name> <!-- 1.17.1 ~ 1.21.10 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_2960</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<name type="official" version="[764,773]">net/minecraft/resources/ResourceLocation</name> <!-- 1.20.2 ~ 1.21.10 -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/server/Services">
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_7497</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/server/packs/resources/Resource">
|
||||||
|
<name type="srg" version="[,340]">net/minecraft/client/resources/IResource</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="[404,754]">net/minecraft/resources/IResource</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3298</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="open()Ljava/io/InputStream;">
|
||||||
|
<name type="srg" version="[,754]">func_199027_b</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,758]">m_6679_</name> <!-- 1.17.1 ~ 1.18.2 -->
|
||||||
|
<name type="srg" version="[759,765]">m_215507_</name> <!-- 1.19 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_14482</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/server/packs/resources/ResourceManager">
|
||||||
|
<name type="srg" version="[,340]">net/minecraft/client/resources/IResourceManager</name> <!-- 1.12.2- -->
|
||||||
|
<name type="srg" version="[404,754]">net/minecraft/resources/IResourceManager</name> <!-- 1.13.2 ~ 1.16.5 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3300</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="getResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional;">
|
||||||
|
<name type="intermediary" version="[759,774],[0x4000004E,0x4000011E]">method_14486</name> <!-- 22w14a ~ 1.21.11 (1.19 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
<method name="getResource(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/server/packs/resources/Resource;">
|
||||||
|
<name type="srg" version="[,754]">func_199002_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,758]">m_142591_</name> <!-- 1.17.1 ~ 1.18.2 -->
|
||||||
|
<name type="intermediary" version="[441,758],[801,803],[0x40000001,0x4000004C]">method_14486</name> <!-- 18w43b ~ 22w13a (1.14 ~ 1.18.2) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/util/StringUtil">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/util/StringUtils</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_3544</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
<method name="stripColor(Ljava/lang/String;)Ljava/lang/String;">
|
||||||
|
<name type="srg" version="[,754]">func_76338_a</name> <!-- 1.16.5- -->
|
||||||
|
<name type="srg" version="[756,765]">m_14406_</name> <!-- 1.17.1 ~ 1.20.4 -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">method_15440</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/world/scores/Objective">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/scoreboard/ScoreObjective</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_266</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
<class name="net/minecraft/world/scores/Scoreboard">
|
||||||
|
<name type="srg" version="[,754]">net/minecraft/scoreboard/Scoreboard</name> <!-- 1.16.5- -->
|
||||||
|
<name type="intermediary" version="[441,774],[801,803],[0x40000001,0x4000011E]">net/minecraft/class_269</name> <!-- 18w43b ~ 1.21.11 (1.14 ~ 1.21.11) -->
|
||||||
|
</class>
|
||||||
|
</mapping>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
manifestLibraries {
|
||||||
|
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.fabricmc.fabric-loader/${fabric_v1_version}.json"
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.bootstrap.fabric.v1;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
|
||||||
|
public final class MixinConfigPlugin implements IMixinConfigPlugin {
|
||||||
|
private String mixinPackage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad(String mixinPackage) {
|
||||||
|
this.mixinPackage = mixinPackage + ".";
|
||||||
|
TransformerBootstrap.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRefMapperConfig() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||||
|
// This is the last stable point before postInitialise/validation, so reflected target injection is still visible downstream.
|
||||||
|
TransformerBootstrap.applyMixinTargets(this.mixinPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getMixins() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||||
|
TransformerBootstrap.transformTargetClass(targetClassName, targetClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+132
@@ -0,0 +1,132 @@
|
|||||||
|
package customskinloader.bootstrap.fabric.v1;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.ModLoaderInfo;
|
||||||
|
import customskinloader.bootstrap.installer.CommonJarInstaller;
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationReport;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
|
||||||
|
import customskinloader.bootstrap.util.ReflectionUtils;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.fabricmc.loader.impl.launch.FabricLauncherBase;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
import org.spongepowered.asm.mixin.transformer.ClassInfo;
|
||||||
|
import org.spongepowered.asm.mixin.transformer.Config;
|
||||||
|
|
||||||
|
final class TransformerBootstrap {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "intermediary");
|
||||||
|
private static final String DUMMY_MIXIN = "customskinloader.bootstrap.fabric.v1.mixin.DummyMixin";
|
||||||
|
|
||||||
|
private TransformerBootstrap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initialize() {
|
||||||
|
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Fabric");
|
||||||
|
ModLoaderInfo.publish("Fabric", FabricLoader.getInstance().getModContainer("fabricloader").map(m -> m.getMetadata().getVersion().getFriendlyString()).orElse("unknown"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
Path commonJar = CommonJarInstaller.releaseCommonJar(FabricLoader.getInstance().getGameDir(), "intermediary");
|
||||||
|
FabricLauncherBase.getLauncher().addToClassPath(commonJar, "customskinloader.");
|
||||||
|
LOGGER.info("Added CustomSkinLoader Common jar to Fabric class path: " + BootstrapLogger.formatPath(commonJar));
|
||||||
|
} catch (Exception exception) {
|
||||||
|
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
|
||||||
|
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static void applyMixinTargets(String mixinPackage) {
|
||||||
|
try {
|
||||||
|
IMixinConfig mixinConfig = null;
|
||||||
|
Field allConfigsField = ReflectionUtils.findField(Config.class, "allConfigs");
|
||||||
|
for (Object configHandle : ((Map<?, ?>) allConfigsField.get(null)).values()) {
|
||||||
|
IMixinConfig mixinConfig0 = ((Config) configHandle).getConfig();
|
||||||
|
if (mixinPackage.equals(mixinConfig0.getMixinPackage())) {
|
||||||
|
mixinConfig = mixinConfig0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mixinConfig == null) {
|
||||||
|
throw new IllegalStateException("Could not find the owning MixinConfig for " + mixinPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
int appliedTargetCount = 0;
|
||||||
|
Class<?> mixinConfigClass = ReflectionUtils.findClass("org.spongepowered.asm.mixin.transformer.MixinConfig");
|
||||||
|
Class<?> mixinInfoClass = ReflectionUtils.findClass("org.spongepowered.asm.mixin.transformer.MixinInfo");
|
||||||
|
|
||||||
|
Field mixinsField = ReflectionUtils.findField(mixinConfigClass, "mixins");
|
||||||
|
Field targetClassNamesField = ReflectionUtils.findField(mixinInfoClass, "targetClassNames");
|
||||||
|
Field targetClassesField = ReflectionUtils.findField(mixinInfoClass, "targetClasses");
|
||||||
|
Field mixinMappingField = ReflectionUtils.findField(mixinConfigClass, "mixinMapping");
|
||||||
|
Field unhandledTargetsField = ReflectionUtils.findField(mixinConfigClass, "unhandledTargets");
|
||||||
|
|
||||||
|
Method addMixinMethod = ReflectionUtils.findMethod(ClassInfo.class, "addMixin", mixinInfoClass);
|
||||||
|
|
||||||
|
for (String targetClassName : SUPPORT.getTargetClassNames()) {
|
||||||
|
boolean applied = false;
|
||||||
|
for (Object mixinInfo : (List<?>) mixinsField.get(mixinConfig)) {
|
||||||
|
String currentMixinName = ((IMixinInfo) mixinInfo).getClassName();
|
||||||
|
if (DUMMY_MIXIN.equals(currentMixinName)) {
|
||||||
|
String targetBinaryName = targetClassName.replace('/', '.');
|
||||||
|
String targetInternalName = targetClassName.replace('.', '/');
|
||||||
|
|
||||||
|
List<String> targetClassNames = (List<String>) targetClassNamesField.get(mixinInfo);
|
||||||
|
if (targetClassNames.contains(targetInternalName)) {
|
||||||
|
applied = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassInfo targetClassInfo = ClassInfo.forName(targetInternalName);
|
||||||
|
if (targetClassInfo == null) {
|
||||||
|
throw new IllegalStateException("Could not resolve target ClassInfo for " + targetInternalName);
|
||||||
|
}
|
||||||
|
|
||||||
|
addMixinMethod.invoke(targetClassInfo, mixinInfo);
|
||||||
|
List<ClassInfo> targetClasses = (List<ClassInfo>) targetClassesField.get(mixinInfo);
|
||||||
|
targetClasses.add(targetClassInfo);
|
||||||
|
targetClassNames.add(targetInternalName);
|
||||||
|
|
||||||
|
Map<String, List<Object>> mixinMapping = (Map<String, List<Object>>) mixinMappingField.get(mixinConfig);
|
||||||
|
List<Object> mappedMixins = mixinMapping.computeIfAbsent(targetBinaryName, k -> new ArrayList<>());
|
||||||
|
if (!mappedMixins.contains(mixinInfo)) {
|
||||||
|
mappedMixins.add(mixinInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
((Set<String>) unhandledTargetsField.get(mixinConfig)).add(targetBinaryName);
|
||||||
|
applied = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!applied) {
|
||||||
|
throw new IllegalStateException("Could not find mixin " + DUMMY_MIXIN + " in the current config");
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug("Applied Fabric Mixin target " + targetClassName);
|
||||||
|
appliedTargetCount++;
|
||||||
|
}
|
||||||
|
LOGGER.info("Applied " + appliedTargetCount + " reflected Fabric Mixin target(s)");
|
||||||
|
} catch (ReflectiveOperationException exception) {
|
||||||
|
LOGGER.error("Failed to append reflected targets to the current Fabric mixin config", exception);
|
||||||
|
throw new IllegalStateException("Failed to append reflected targets to the current Fabric mixin config", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void transformTargetClass(String targetClassName, ClassNode targetClass) {
|
||||||
|
ClassTransformationReport report = SUPPORT.transform(targetClassName, targetClass);
|
||||||
|
if (report.isModified()) {
|
||||||
|
LOGGER.info("Transformed Fabric target " + targetClassName + " with " + report.getAppliedRuleNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package customskinloader.bootstrap.fabric.v1.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
// This placeholder mixin exists solely to provide a stable MixinInfo that we can retarget reflectively.
|
||||||
|
@Mixin(targets = "net.minecraft.client.main.Main")
|
||||||
|
public abstract class DummyMixin {
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "customskinloader.bootstrap.fabric.v1.mixin",
|
||||||
|
"plugin": "customskinloader.bootstrap.fabric.v1.MixinConfigPlugin",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"mixins": [
|
||||||
|
"DummyMixin"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "customskinloader",
|
"id": "customskinloader-bootstrap",
|
||||||
"version": "${modFullVersion}",
|
"version": "${modFullVersion}",
|
||||||
|
|
||||||
"name": "CustomSkinLoader",
|
"name": "CustomSkinLoader Bootstrap",
|
||||||
"description": "Custom Skin Loader for Minecraft",
|
"description": "Custom Skin Loader for Minecraft",
|
||||||
"authors": ["xfl03", "JLChnToZ"],
|
"authors": ["xfl03", "JLChnToZ", "ZekerZhayard"],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://github.com/xfl03/MCCustomSkinLoader",
|
"homepage": "https://github.com/xfl03/MCCustomSkinLoader",
|
||||||
"issues": "https://github.com/xfl03/MCCustomSkinLoader/issues",
|
"issues": "https://github.com/xfl03/MCCustomSkinLoader/issues",
|
||||||
@@ -15,6 +15,6 @@
|
|||||||
|
|
||||||
"environment": "client",
|
"environment": "client",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"mixins.customskinloader.json"
|
"customskinloader.bootstrap.fabric.v1.mixins.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
manifestLibraries {
|
||||||
|
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraftforge/${forge_v1_version}.json"
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v1;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.relauncher.IFMLCallHook;
|
||||||
|
|
||||||
|
public class CallHook implements IFMLCallHook {
|
||||||
|
@Override
|
||||||
|
public void injectData(Map<String, Object> data) {
|
||||||
|
TransformerBootstrap.injectData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v1;
|
||||||
|
|
||||||
|
import net.minecraft.launchwrapper.IClassTransformer;
|
||||||
|
|
||||||
|
public final class ClassTransformerAdapter implements IClassTransformer {
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||||
|
if (basicClass == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String className = transformedName != null && !transformedName.isEmpty() ? transformedName : name;
|
||||||
|
return TransformerBootstrap.transform(className.replace('.', '/'), basicClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-10
@@ -1,16 +1,16 @@
|
|||||||
package customskinloader.forge;
|
package customskinloader.bootstrap.forge.v1;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
|
|
||||||
@IFMLLoadingPlugin.Name("CustomSkinLoader")
|
import java.util.Map;
|
||||||
@IFMLLoadingPlugin.SortingIndex(-10)
|
|
||||||
public class ForgePlugin implements IFMLLoadingPlugin {
|
|
||||||
|
|
||||||
|
@IFMLLoadingPlugin.Name("CustomSkinLoaderBootstrap")
|
||||||
|
@IFMLLoadingPlugin.SortingIndex(1010)
|
||||||
|
@IFMLLoadingPlugin.TransformerExclusions("customskinloader.bootstrap.")
|
||||||
|
public final class LoadingPlugin implements IFMLLoadingPlugin {
|
||||||
@Override
|
@Override
|
||||||
public String[] getASMTransformerClass() {
|
public String[] getASMTransformerClass() {
|
||||||
return new String[]{"customskinloader.forge.loader.LaunchWrapper"};//LaunchWrapper
|
return new String[] { "customskinloader.bootstrap.forge.v1.ClassTransformerAdapter" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -20,17 +20,16 @@ public class ForgePlugin implements IFMLLoadingPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSetupClass() {
|
public String getSetupClass() {
|
||||||
return null;
|
return "customskinloader.bootstrap.forge.v1.CallHook";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectData(Map<String, Object> data) {
|
public void injectData(Map<String, Object> data) {
|
||||||
TransformerManager.isDevelopmentEnvironment = !(boolean) data.get("runtimeDeobfuscationEnabled");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAccessTransformerClass() {
|
public String getAccessTransformerClass() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v1;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.ModLoaderInfo;
|
||||||
|
import customskinloader.bootstrap.installer.CommonJarInstaller;
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationReport;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
|
||||||
|
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||||
|
import net.minecraftforge.fml.relauncher.FMLInjectionData;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
final class TransformerBootstrap {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "srg");
|
||||||
|
|
||||||
|
private TransformerBootstrap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void injectData(Map<String, Object> data) {
|
||||||
|
try {
|
||||||
|
Object[] version = FMLInjectionData.data();
|
||||||
|
ModLoaderInfo.publish("Forge", version[0] + "." + version[1] + "." + version[2] + "." + version[3]);
|
||||||
|
|
||||||
|
Path runtimeDirectory = resolveRuntimeDirectory(data);
|
||||||
|
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Forge v1 in " + BootstrapLogger.formatPath(runtimeDirectory));
|
||||||
|
Path commonJar = CommonJarInstaller.releaseCommonJar(runtimeDirectory, "srg");
|
||||||
|
resolveLaunchClassLoader(data).addURL(commonJar.toUri().toURL());
|
||||||
|
LOGGER.info("Added CustomSkinLoader Common jar to LaunchClassLoader: " + BootstrapLogger.formatPath(commonJar));
|
||||||
|
} catch (Exception exception) {
|
||||||
|
LOGGER.error("Failed to prepare CustomSkinLoader runtime jars", exception);
|
||||||
|
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime jars", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] transform(String className, byte[] classBytecode) {
|
||||||
|
ClassTransformationReport report = SUPPORT.transform(className, classBytecode);
|
||||||
|
if (report.isModified()) {
|
||||||
|
LOGGER.info("Transformed Forge v1 target " + className + " with " + report.getAppliedRuleNames());
|
||||||
|
}
|
||||||
|
return report.isModified() ? report.getTransformedBytecode() : classBytecode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path resolveRuntimeDirectory(Map<String, Object> data) {
|
||||||
|
Object mcLocation = data.get("mcLocation");
|
||||||
|
if (mcLocation instanceof File) {
|
||||||
|
return ((File) mcLocation).toPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Paths.get(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LaunchClassLoader resolveLaunchClassLoader(Map<String, Object> data) {
|
||||||
|
Object classLoader = data.get("classLoader");
|
||||||
|
if (classLoader instanceof LaunchClassLoader) {
|
||||||
|
return (LaunchClassLoader) classLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalStateException("Forge did not provide a LaunchClassLoader in injectData");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
manifestLibraries {
|
||||||
|
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraftforge/${forge_v2_version}.json"
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v2;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.util.ModLocatorUtils;
|
||||||
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator;
|
||||||
|
|
||||||
|
public final class CommonModLocator extends ModsFolderLocator {
|
||||||
|
public CommonModLocator() {
|
||||||
|
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "srg");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return ModLocatorUtils.LOCATOR_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v2;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.IEnvironment;
|
||||||
|
import cpw.mods.modlauncher.api.ITransformationService;
|
||||||
|
import cpw.mods.modlauncher.api.ITransformer;
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public final class TransformationService implements ITransformationService {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "customskinloader-bootstrap";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(IEnvironment environment) {
|
||||||
|
LOGGER.info("Initializing CustomSkinLoader Bootstrap transformation service");
|
||||||
|
TransformerBootstrap.publishModLoaderInfo();
|
||||||
|
try {
|
||||||
|
List<Path> extraLocators = ModDirTransformerDiscoverer.getExtraLocators();
|
||||||
|
Path servicePath = Paths.get(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath().normalize();
|
||||||
|
if (!extraLocators.contains(servicePath)) {
|
||||||
|
extraLocators.add(servicePath);
|
||||||
|
LOGGER.info("Registered CustomSkinLoader Bootstrap service path as Forge extra locator: " + BootstrapLogger.formatPath(servicePath));
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodError e) { // 1.13.2-25.0.216 ~ 1.14.4-28.1.64
|
||||||
|
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
|
||||||
|
LOGGER.info("Using context ClassLoader fallback for legacy Forge transformation discovery");
|
||||||
|
} catch (NoClassDefFoundError ignored) { // NeoForge
|
||||||
|
LOGGER.debug("Skipping Forge ModDirTransformerDiscoverer setup on NeoForge");
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
LOGGER.error("Unable to resolve CustomSkinLoader bootstrap service path", e);
|
||||||
|
throw new IllegalStateException("Unable to resolve CustomSkinLoader bootstrap service path", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginScanning(IEnvironment environment) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad(IEnvironment environment, Set<String> otherServices) {
|
||||||
|
LOGGER.info("Loaded CustomSkinLoader Bootstrap transformation service with " + otherServices.size() + " other service(s)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ITransformer> transformers() {
|
||||||
|
LOGGER.info("Providing CustomSkinLoader ModLauncher transformer");
|
||||||
|
return Collections.singletonList(new TransformerBootstrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package customskinloader.bootstrap.forge.v2;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.ArgumentHandler;
|
||||||
|
import cpw.mods.modlauncher.Launcher;
|
||||||
|
import cpw.mods.modlauncher.api.ITransformer;
|
||||||
|
import cpw.mods.modlauncher.api.ITransformerVotingContext;
|
||||||
|
import cpw.mods.modlauncher.api.TransformerVoteResult;
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.ModLoaderInfo;
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationReport;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
|
||||||
|
import customskinloader.bootstrap.util.ReflectionUtils;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
final class TransformerBootstrap implements ITransformer<ClassNode> {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class,
|
||||||
|
// official: neoforge 1.20.2-20.2.3 ~ 1.21.3-21.3.97
|
||||||
|
// srg: forge *, neoforge 1.21.4-21.4.0 ~ 1.21.9-21.9.13
|
||||||
|
Launcher.INSTANCE.environment().findLaunchHandler("forgeclient")
|
||||||
|
.map(handle -> handle.getClass().getName().startsWith("net.neoforged.")).orElse(false) ? "official" : "srg");
|
||||||
|
|
||||||
|
public static void publishModLoaderInfo() {
|
||||||
|
try {
|
||||||
|
Object argumentHandler = ReflectionUtils.findField(Launcher.class, "argumentHandler").get(Launcher.INSTANCE);
|
||||||
|
String[] args = (String[]) ReflectionUtils.findField(ArgumentHandler.class, "args").get(argumentHandler);
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
String arg = args[i];
|
||||||
|
if (Objects.equals(arg, "--fml.forgeVersion")) {
|
||||||
|
// forge 1.13.2-25.0.216 ~ 1.20.2-48.1.0
|
||||||
|
ModLoaderInfo.publish("Forge", args[i + 1]);
|
||||||
|
return;
|
||||||
|
} else if (Objects.equals(arg, "--fml.neoForgeVersion")) {
|
||||||
|
// neoforge 1.20.2-20.2.3 ~ 1.21.9-21.9.13
|
||||||
|
ModLoaderInfo.publish("NeoForge", args[i + 1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// forge 1.20.3-49.0.1+
|
||||||
|
ModLoaderInfo.publish("Forge", FMLLoader.class.getPackage().getImplementationVersion());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.warn("Could not determine mod loader", e);
|
||||||
|
ModLoaderInfo.publish("Forge", "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Set<ITransformer.Target> targets;
|
||||||
|
|
||||||
|
TransformerBootstrap() {
|
||||||
|
Set<ITransformer.Target> transformerTargets = new LinkedHashSet<>();
|
||||||
|
for (String targetClassName : SUPPORT.getTargetClassNames()) {
|
||||||
|
transformerTargets.add(ITransformer.Target.targetClass(targetClassName));
|
||||||
|
}
|
||||||
|
this.targets = Collections.unmodifiableSet(transformerTargets);
|
||||||
|
LOGGER.info("Created one ModLauncher transformer for " + this.targets.size() + " target class(es)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassNode transform(ClassNode input, ITransformerVotingContext context) {
|
||||||
|
String internalClassName = input.name;
|
||||||
|
ClassTransformationReport report = SUPPORT.transform(internalClassName, input);
|
||||||
|
if (report.isModified()) {
|
||||||
|
LOGGER.info("Transformed ModLauncher target " + internalClassName + " with " + report.getAppliedRuleNames());
|
||||||
|
}
|
||||||
|
return report.getTransformedClassNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TransformerVoteResult castVote(ITransformerVotingContext context) {
|
||||||
|
return TransformerVoteResult.YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ITransformer.Target> targets() {
|
||||||
|
return this.targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NeoForge
|
||||||
|
public cpw.mods.modlauncher.api.TargetType getTargetType() {
|
||||||
|
return cpw.mods.modlauncher.api.TargetType.CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] labels() {
|
||||||
|
return new String[] {"customskinloader:bootstrap"};
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.forge.v2.TransformationService
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.forge.v2.CommonModLocator
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.forge.v2.CommonModLocator
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
manifestLibraries {
|
||||||
|
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.neoforged/${neoforge_v1_version}.json"
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package customskinloader.bootstrap.neoforge.v1;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.util.ModLocatorUtils;
|
||||||
|
import net.neoforged.fml.loading.FMLPaths;
|
||||||
|
import net.neoforged.fml.loading.moddiscovery.ModsFolderLocator;
|
||||||
|
|
||||||
|
public final class CommonModLocator extends ModsFolderLocator {
|
||||||
|
public CommonModLocator() {
|
||||||
|
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return ModLocatorUtils.LOCATOR_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.neoforge.v1.CommonModLocator
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
manifestLibraries {
|
||||||
|
add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.neoforged/${neoforge_v2_version}.json"
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package customskinloader.bootstrap.neoforge.v2;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.ModLoaderInfo;
|
||||||
|
import net.neoforged.fml.loading.FMLLoader;
|
||||||
|
import net.neoforged.neoforgespi.transformation.ClassProcessorProvider;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
// NeoForge 21.9.14+
|
||||||
|
public final class ClassProcessorProviderImpl implements ClassProcessorProvider {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createProcessors(Context context, Collector collector) {
|
||||||
|
// Always register the bridge processor so late transformer registrations can still be observed.
|
||||||
|
LOGGER.info("Registering CustomSkinLoader Bootstrap NeoForge class processor");
|
||||||
|
ModLoaderInfo.publish("NeoForge", FMLLoader.getCurrent().getVersionInfo().neoForgeVersion());
|
||||||
|
collector.add(new TransformerBootstrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package customskinloader.bootstrap.neoforge.v2;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.util.ModLocatorUtils;
|
||||||
|
import net.neoforged.fml.loading.FMLPaths;
|
||||||
|
import net.neoforged.fml.loading.moddiscovery.locators.ModsFolderLocator;
|
||||||
|
|
||||||
|
// NeoForge 20.6.14+
|
||||||
|
public final class CommonModLocator extends ModsFolderLocator {
|
||||||
|
public CommonModLocator() {
|
||||||
|
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return ModLocatorUtils.LOCATOR_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package customskinloader.bootstrap.neoforge.v2;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import customskinloader.bootstrap.BootstrapLogger;
|
||||||
|
import customskinloader.bootstrap.transformer.ClassTransformationReport;
|
||||||
|
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
|
||||||
|
import net.neoforged.neoforgespi.transformation.ClassProcessor;
|
||||||
|
import net.neoforged.neoforgespi.transformation.ClassProcessorIds;
|
||||||
|
import net.neoforged.neoforgespi.transformation.ProcessorName;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
final class TransformerBootstrap implements ClassProcessor {
|
||||||
|
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||||
|
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "official");
|
||||||
|
private static final ProcessorName PROCESSOR_NAME = new ProcessorName("customskinloader", "bootstrap");
|
||||||
|
|
||||||
|
TransformerBootstrap() {
|
||||||
|
SUPPORT.getTargetClassNames();
|
||||||
|
LOGGER.info("Created CustomSkinLoader Bootstrap NeoForge class processor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessorName name() {
|
||||||
|
return PROCESSOR_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ProcessorName> runsBefore() {
|
||||||
|
return Collections.singleton(ClassProcessorIds.MIXIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlesClass(SelectionContext context) {
|
||||||
|
// The shared framework currently targets concrete classes only, so we skip synthetic empty definitions.
|
||||||
|
return !context.empty() && SUPPORT.getTargetClassNames().contains(context.type().getInternalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ComputeFlags processClass(TransformationContext context) {
|
||||||
|
ClassTransformationReport report = SUPPORT.transform(context.type().getInternalName(), context.node());
|
||||||
|
if (!report.isModified()) {
|
||||||
|
return ComputeFlags.NO_REWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ruleName : report.getAppliedRuleNames()) {
|
||||||
|
context.audit("customskinloader.bootstrap", ruleName);
|
||||||
|
}
|
||||||
|
LOGGER.info("Transformed NeoForge target " + context.type().getInternalName() + " with " + report.getAppliedRuleNames());
|
||||||
|
return ComputeFlags.COMPUTE_FRAMES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderingHint orderingHint() {
|
||||||
|
return OrderingHint.EARLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.neoforge.v2.CommonModLocator
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
customskinloader.bootstrap.neoforge.v2.ClassProcessorProviderImpl
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
def bootstrapCoreProject = project(':Bootstrap:Core')
|
||||||
|
def commonJarTask = project(':Common').tasks.named('jar')
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
dependencies {
|
||||||
|
compileOnly project(':Dummy:Bootstrap')
|
||||||
|
if (project != bootstrapCoreProject) compileOnly bootstrapCoreProject
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
archiveBaseName = rootProject.ext.releaseArchiveBaseName
|
||||||
|
archiveVersion = rootProject.ext.modFullVersion
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(
|
||||||
|
"Automatic-Module-Name" : "customskinloader.bootstrap",
|
||||||
|
"Specification-Title" : "CustomSkinLoader",
|
||||||
|
"Specification-Vendor" : "xfl03",
|
||||||
|
"Specification-Version" : "1",
|
||||||
|
"Implementation-Title" : "CustomSkinLoader",
|
||||||
|
"Implementation-Version" : rootProject.ext.modFullVersion,
|
||||||
|
"Implementation-Vendor" : "xfl03",
|
||||||
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
"FMLCorePlugin" : "customskinloader.bootstrap.forge.v1.LoadingPlugin"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build child module outputs before bundling them into the Bootstrap artifact.
|
||||||
|
dependsOn subprojects.collect { bundledProject ->
|
||||||
|
bundledProject.tasks.named('classes')
|
||||||
|
}
|
||||||
|
dependsOn commonJarTask
|
||||||
|
|
||||||
|
// Package all leaf child module outputs into the Bootstrap jar.
|
||||||
|
from({
|
||||||
|
subprojects.collect { bundledProject ->
|
||||||
|
bundledProject.sourceSets.main.output
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
into('META-INF/jar-jar') {
|
||||||
|
// Bundle the runtime payload with Bridge so Bridge owns releasing the Universal jar.
|
||||||
|
from(commonJarTask.flatMap { it.archiveFile })
|
||||||
|
rename { 'CustomSkinLoader-Common.jar' }
|
||||||
|
}
|
||||||
|
}
|
||||||
+89
-138
@@ -1,152 +1,103 @@
|
|||||||
# Development and Contribution
|
# Contributing to CustomSkinLoader Universal
|
||||||
|
|
||||||
## Building
|
Thanks for helping improve CustomSkinLoader. This branch is the Universal generation: one installable Bootstrap jar carries the shared Common runtime, remaps it for the active Minecraft mapping namespace, and applies loader-specific patches at launch time. A successful Java compile is useful, but changes that touch runtime loading, mappings, or transformers also need in-game verification.
|
||||||
1. Run `./gradlew setupDecompWorkspace clean build` command.
|
|
||||||
1. The built jars are all in `${rootprojectDir}/build/libs` folder.
|
|
||||||
|
|
||||||
*NOTICE: The jar file with specific Minecraft version is for the vanilla edition without Forge and Fabric. The json files are launcher profiles which only work when building with our CI server.*
|
## Requirements
|
||||||
|
|
||||||
## Running and Testing
|
- Git.
|
||||||
For now, CustomSkinLoader is unable to run under self development environment, so it needs to add to another development environment as a library.
|
- A Java 25 JDK. Set `JAVA_HOME` if Java 25 is not the default `java` on your `PATH`.
|
||||||
There are the available versions in different environments below:
|
- The Gradle wrapper from this repository.
|
||||||
|
- Local Minecraft test instances for the loaders and versions affected by your change.
|
||||||
|
|
||||||
| | Forge | Fabric |
|
The build uses Java 25 tooling, while project sources are compiled for Java 8 compatibility unless a module explicitly provides multi-release sources such as `Common/src/main/java21`.
|
||||||
|:-----------------------:|:-----------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------:|
|
|
||||||
| 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* |
|
|
||||||
|
|
||||||
### Preliminary steps for testing local builds
|
## Build
|
||||||
1. Create a new empty minecraft development environment.
|
|
||||||
1. Add below contents to `build.gradle`:
|
|
||||||
```gradle
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url = "file:/${projectDir}/local-repo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
1. Create these folders in the new project directory, then copy the built jar and source jar into it:
|
|
||||||
```
|
|
||||||
Forge 1.8 ~ 1.16.5: ./local-repo/mods/CustomSkinLoader_ForgeLegacy/${version}
|
|
||||||
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*
|
|
||||||
1. Create a pom file in the same folder:
|
|
||||||
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeLegacy-${version}.pom`
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<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>${version}</version>
|
|
||||||
</project>
|
|
||||||
```
|
|
||||||
- Forge 1.17.1 ~ latest: `CustomSkinLoader_ForgeActive-${version}.pom`
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<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>${version}</version>
|
|
||||||
</project>
|
|
||||||
```
|
|
||||||
- Fabric: `CustomSkinLoader_Fabric-${version}.pom`
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<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>${version}</version>
|
|
||||||
</project>
|
|
||||||
```
|
|
||||||
|
|
||||||
### For ForgeGradle 2.x ( forge-1.8-11.14.3.1503 ~ forge-1.12.2-14.23.5.2847 )
|
Use the wrapper instead of a system Gradle installation.
|
||||||
1. Add below contents to `build.gradle`:
|
|
||||||
```gradle
|
|
||||||
dependencies {
|
|
||||||
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00"
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
Windows:
|
||||||
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. 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 )
|
```powershell
|
||||||
1. Add below contents to `build.gradle`:
|
.\gradlew.bat clean build --stacktrace
|
||||||
```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
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
Linux/macOS:
|
||||||
runs {
|
|
||||||
client {
|
|
||||||
args += ["--username", "<Your username>"]
|
|
||||||
args += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker"] // Only required for MinecraftForge 1.12.2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
1. Setup the development environment and run the game as usual.
|
|
||||||
|
|
||||||
### For fabric-loom ( fabric-loader-0.12.0 ~ latest )
|
```bash
|
||||||
1. Add below contents to `build.gradle`:
|
./gradlew clean build --stacktrace
|
||||||
```gradle
|
```
|
||||||
dependencies {
|
|
||||||
modImplementation "mods:CustomSkinLoader_Fabric:14.15-SNAPSHOT-00"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.runClient {
|
The user-facing mod artifact is:
|
||||||
args += ["--username", "<Your username>"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
1. Add `--username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
|
|
||||||
1. Run the game in IDE or through `./gradlew runClient` command..
|
|
||||||
|
|
||||||
## Depend on release builds
|
```text
|
||||||
1. Check the latest version in https://littlesk.in/csl-latest .
|
Bootstrap/build/libs/CustomSkinLoader_Universal-<version>.jar
|
||||||
1. Add below contents to `build.gradle`:
|
```
|
||||||
```gradle
|
|
||||||
// Before Gradle 5.x
|
|
||||||
repositories {
|
|
||||||
ivy {
|
|
||||||
url = "https://csl.littleservice.cn/"
|
|
||||||
layout "pattern", {
|
|
||||||
artifact "[organisation]/[artifact]-[revision](-[classifier])(.[ext])"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// After Gradle 6.x
|
`Common/build/libs/Common-<version>.jar` is bundled into the Universal jar as `META-INF/jar-jar/CustomSkinLoader-Common.jar`. Do not publish or ask users to install the Common jar directly.
|
||||||
repositories {
|
|
||||||
ivy {
|
|
||||||
url = "https://csl.littleservice.cn/"
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
patternLayout {
|
|
||||||
artifact "[organisation]/[artifact]-[revision](-[classifier])(.[ext])"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
1. Follow the same steps in **Running and Testing**.
|
|
||||||
|
|
||||||
## Developing
|
## Project Layout
|
||||||
- CustomSkinLoader is based on forge-1.12.2-14.23.5.2768 currently, including Fabric edition. We use custom reobfuscation mappings such as [Fabric.tsrg](Fabric/Fabric.tsrg) and [mixin.tsrg](Fabric/mixin.tsrg) to generate different editions jar and Mixin reference jsons.
|
|
||||||
- The source codes are all in `${projectDir}/sources` and resource files are in `${projectDir}/resources` instead of `src/main/java` and `src/main/resources`.
|
- `Common`: shared CustomSkinLoader runtime, configuration, skin API loaders, cache, logging, and texture utilities.
|
||||||
- Do not add other required mods.
|
- `Common/src/main/java21`: Java 21+ multi-release overrides for runtime behavior that benefits from newer JVM APIs.
|
||||||
|
- `Bootstrap`: assembles the installable Universal jar.
|
||||||
|
- `Bootstrap/Core`: runtime installer, remapper, mapping reader, transformer registry, and shared patch logic.
|
||||||
|
- `Bootstrap/FabricV1`: Fabric and Quilt-compatible bootstrap integration.
|
||||||
|
- `Bootstrap/ForgeV1`: legacy Forge coremod bootstrap.
|
||||||
|
- `Bootstrap/ForgeV2`: Forge ModLauncher bootstrap.
|
||||||
|
- `Bootstrap/NeoForgeV1` and `Bootstrap/NeoForgeV2`: NeoForge discovery and transformation bootstrap.
|
||||||
|
- `Dummy/Bootstrap` and `Dummy/Common`: compile-time stubs for Minecraft and loader APIs. Keep these minimal; they are not runtime implementations.
|
||||||
|
- `buildSrc`: local Gradle plugin code, including manifest library resolution from launcher metadata.
|
||||||
|
- `.github/workflows` and `.github/scripts`: CI, release, metadata, and publishing automation.
|
||||||
|
|
||||||
|
## Development Guidelines
|
||||||
|
|
||||||
|
- Keep changes scoped to the loader, mapping range, API loader, or Common behavior being modified.
|
||||||
|
- Preserve compatibility across the supported Minecraft and loader matrix unless the change is intentionally narrowing support.
|
||||||
|
- Prefer small, explicit compatibility branches over broad reflection or version checks when the affected API surface is known.
|
||||||
|
- Treat `Bootstrap/Core/src/main/resources/customskinloader/mapping.xml` and transformer patches as runtime-critical code. Document why a mapping range or target class changed.
|
||||||
|
- Do not edit generated Gradle output under `build/`, `.gradle/`, IDE metadata, or files generated by a local Minecraft test run.
|
||||||
|
- Keep `Dummy` classes limited to the members needed for compilation. Runtime behavior belongs in `Common` or `Bootstrap`, not in stubs.
|
||||||
|
- Update `README.md`, issue templates, or release metadata when a user-visible feature, supported loader, supported version, or install path changes.
|
||||||
|
- Follow the existing Java style in nearby files. The codebase intentionally avoids adding large abstractions where a focused compatibility patch is clearer.
|
||||||
|
|
||||||
|
## Testing Checklist
|
||||||
|
|
||||||
|
Before opening a pull request, run the relevant parts of this checklist:
|
||||||
|
|
||||||
|
1. Run `.\gradlew.bat clean build --stacktrace` on Windows, or `./gradlew clean build --stacktrace` on Linux/macOS.
|
||||||
|
2. Install only `Bootstrap/build/libs/CustomSkinLoader_Universal-<version>.jar` into a clean Minecraft instance.
|
||||||
|
3. If you changed `Common`, confirm the runtime payload is regenerated under `.minecraft/CustomSkinLoader/Core/CustomSkinLoader-Common.jar`.
|
||||||
|
4. If you changed `Bootstrap`, mappings, service descriptors, or transformer patches, test at least one Forge or NeoForge instance and one Fabric or Quilt-compatible instance.
|
||||||
|
5. If you changed a version range or mapping entry, test the oldest and newest Minecraft versions covered by that range.
|
||||||
|
6. Check `.minecraft/CustomSkinLoader/CustomSkinLoader.log` for loader, remapper, transformer, and skin loading errors.
|
||||||
|
7. For skin API, cache, or network changes, test a normal online profile and a cache/local-profile fallback path when possible.
|
||||||
|
|
||||||
|
There is currently no standalone test suite that replaces in-game compatibility testing.
|
||||||
|
|
||||||
|
## Pull Requests
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A short summary of the behavior change.
|
||||||
|
- The Minecraft versions and loaders you tested.
|
||||||
|
- Any relevant `CustomSkinLoader.log` snippets for bootstrap, remapping, or skin loading issues.
|
||||||
|
- Screenshots or reproduction steps for visible texture/rendering fixes.
|
||||||
|
- Notes about compatibility risk when changing mappings, ASM patches, service descriptors, or build packaging.
|
||||||
|
|
||||||
|
Keep pull requests focused. If a cleanup is unrelated to the bug or feature, send it separately so compatibility regressions are easier to review.
|
||||||
|
|
||||||
|
## CI and Publishing
|
||||||
|
|
||||||
|
Pull requests run the shared GitHub Actions build on `windows-latest` with PowerShell and Java 25. This is a CI choice; local builds should remain portable across Windows, Linux, and macOS.
|
||||||
|
|
||||||
|
Publishing jobs generate the Universal jar plus metadata files from `gradle.properties`. Beta builds publish moving beta metadata, release builds publish release metadata and upload to distribution platforms. Object-storage upload is optional and is skipped when the required secrets are not configured.
|
||||||
|
|
||||||
|
To generate publish metadata locally without uploading, first build the project, then run:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\.github\scripts\publish-artifacts.ps1 -Channel Beta -LatestJsonName latest-beta.json -DetailJsonName detail-beta.json -SkipObjectStorage
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing, you agree that your contribution will be distributed under the repository license. Source code is licensed under GPL-3.0-only; see `LICENSE`.
|
||||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly project(':Dummy:Common')
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
java21 {
|
||||||
|
java.srcDir('src/main/java21')
|
||||||
|
compileClasspath += sourceSets.main.output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named(sourceSets.java21.compileJavaTaskName, JavaCompile) {
|
||||||
|
dependsOn tasks.named('compileJava')
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
dependsOn tasks.named(sourceSets.java21.classesTaskName)
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes('Multi-Release': 'true')
|
||||||
|
}
|
||||||
|
|
||||||
|
into('META-INF/versions/21') {
|
||||||
|
from(sourceSets.java21.output)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
forge_mc_version=1.12.2
|
|
||||||
forge_version=14.23.5.2768
|
|
||||||
mappings_version=stable_39
|
|
||||||
# this subproject is only to provide dependency for other subprojects.
|
|
||||||
is_real_project=false
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "CustomSkinLoader",
|
|
||||||
"version": "${modVersion}",
|
|
||||||
"fullVersion": "${modFullVersion}",
|
|
||||||
"mcVersion": "${mcVersion}",
|
|
||||||
"mcFullVersions": "${mcFullVersions}",
|
|
||||||
"forgeVersion": "${forgeVersion}",
|
|
||||||
"gitVersion": "${gitVersion}",
|
|
||||||
"buildUrl": "${buildUrl}",
|
|
||||||
"buildTime": "${releaseTime}"
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.client.resources.SkinManager;
|
|
||||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.StringUtils;
|
|
||||||
|
|
||||||
public class FakeClientPlayer {
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
|
|
||||||
*/
|
|
||||||
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager.SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
|
||||||
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer) {//Cache for client player
|
|
||||||
textureCache.put(resourcelocation, threaddownloadimagedata);
|
|
||||||
}
|
|
||||||
return threaddownloadimagedata;
|
|
||||||
}
|
|
||||||
|
|
||||||
//For Legacy Skin
|
|
||||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
|
||||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
|
||||||
TextureManager textman = MinecraftUtil.getTextureManager();
|
|
||||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
|
||||||
|
|
||||||
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
|
|
||||||
//if Legacy Skin for username not loaded yet
|
|
||||||
SkinManager skinman = MinecraftUtil.getSkinManager();
|
|
||||||
UUID offlineUUID = getOfflineUUID(username);
|
|
||||||
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
|
|
||||||
|
|
||||||
//Load Default Skin
|
|
||||||
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
|
||||||
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
|
|
||||||
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
|
||||||
|
|
||||||
//Load Skin from SkinManager
|
|
||||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ito instanceof ThreadDownloadImageData)
|
|
||||||
return (ThreadDownloadImageData) ito;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResourceLocation getLocationSkin(String username) {
|
|
||||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
|
||||||
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UUID getOfflineUUID(String username) {
|
|
||||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
|
||||||
|
|
||||||
public static class LegacyBuffer implements SkinAvailableCallback {
|
|
||||||
ResourceLocation resourceLocationIn;
|
|
||||||
boolean loaded = false;
|
|
||||||
|
|
||||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
|
||||||
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
|
|
||||||
this.resourceLocationIn = resourceLocationIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
|
||||||
if (typeIn != Type.SKIN || loaded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TextureManager textman = MinecraftUtil.getTextureManager();
|
|
||||||
ITextureObject ito = textman.getTexture(location);
|
|
||||||
if (ito == null)
|
|
||||||
ito = textureCache.get(location);
|
|
||||||
if (ito == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
loaded = true;
|
|
||||||
textman.loadTexture(resourceLocationIn, ito);
|
|
||||||
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
|
|
||||||
ito.toString() + " (" + location + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
|
||||||
private HttpTextureUtil.HttpTextureInfo info;
|
|
||||||
private ResourceLocation resourceLocation;
|
|
||||||
|
|
||||||
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
|
||||||
super(url, metadata);
|
|
||||||
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResourceLocation(ResourceLocation resourceLocation) {
|
|
||||||
this.resourceLocation = resourceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getResourceLocation() {
|
|
||||||
return this.resourceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUrl() {
|
|
||||||
return this.info.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHash() {
|
|
||||||
return this.info.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getCacheFile() {
|
|
||||||
return this.info.cacheFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
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 customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
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 Map<ResourceLocation, MinecraftProfileTexture> modelCache = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
|
||||||
this.textureManager = textureManagerInstance;
|
|
||||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
|
||||||
*/
|
|
||||||
public static ResourceLocation setResourceLocation(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
|
|
||||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
|
||||||
((FakeMinecraftProfileTexture) profileTexture).setResourceLocation(resourceLocation);
|
|
||||||
}
|
|
||||||
return resourceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
|
||||||
*/
|
|
||||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, FakeSkinManager fakeManager, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
|
||||||
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();
|
|
||||||
if (params[params.length - 2] instanceof Boolean) {
|
|
||||||
params[params.length - 2] = true;
|
|
||||||
}
|
|
||||||
params[params.length - 1] = fakeManager.new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final static String KEY = "CustomSkinLoaderInfo";
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinAvailableCallback, boolean)}
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
|
||||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, m -> {
|
|
||||||
// This is a hack.
|
|
||||||
((Multimap) profile.getProperties()).put(KEY, m);
|
|
||||||
runnable.run();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
|
||||||
// This is a hack.
|
|
||||||
return (Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>) ((Optional) profile.getProperties().removeAll(KEY).stream().findFirst()).orElse(Maps.newHashMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked from {@link SkinManager#lambda$null$0(Map, SkinAvailableCallback)}
|
|
||||||
*/
|
|
||||||
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
|
||||||
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
|
|
||||||
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
|
|
||||||
if (map.containsKey(type)) {
|
|
||||||
skinManager.loadSkin(map.get(type), type, skinAvailableCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
|
||||||
if (callback != null)
|
|
||||||
callback.skinAvailable(type, location, texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
|
|
||||||
return texture != null && "auto".equals(texture.getMetadata("model"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BaseBuffer implements IImageBuffer {
|
|
||||||
private IImageBuffer buffer;
|
|
||||||
|
|
||||||
private SkinManager.SkinAvailableCallback callback;
|
|
||||||
private MinecraftProfileTexture.Type type;
|
|
||||||
private ResourceLocation location;
|
|
||||||
private MinecraftProfileTexture texture;
|
|
||||||
|
|
||||||
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture 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) {
|
|
||||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
|
||||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.IResource;
|
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeInterfaceManager {
|
|
||||||
public static InputStream IResource_getInputStream(Object resource) {
|
|
||||||
return ((IFakeIResource.V2) resource).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) throws IOException {
|
|
||||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IResourceManager Minecraft_getResourceManager(Minecraft minecraft) {
|
|
||||||
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ThreadDownloadImageData_resetNewBufferedImage(Object threadDownloadImageData, BufferedImage image) {
|
|
||||||
((IFakeThreadDownloadImageData) threadDownloadImageData).resetNewBufferedImage(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.IResource;
|
|
||||||
|
|
||||||
/** {@link net.minecraft.client.resources.IResource} is no longer an interface since 22w14a */
|
|
||||||
public interface IFakeIResource {
|
|
||||||
// 1.13.2 ~ 22w13a
|
|
||||||
interface V1 {
|
|
||||||
default InputStream func_199027_b() {
|
|
||||||
return ((IResource) this).getInputStream();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 22w14a+
|
|
||||||
interface V2 {
|
|
||||||
default InputStream open() {
|
|
||||||
return ((IFakeIResource.V1) this).func_199027_b();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
|
||||||
import net.minecraft.resources.IResource;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public interface IFakeIResourceManager {
|
|
||||||
// 1.13.2 ~ 22w13a
|
|
||||||
default IResource func_199002_a(ResourceLocation location) throws IOException {
|
|
||||||
return (IResource) ((IResourceManager) this).getResource(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 22w14a+
|
|
||||||
default Optional getResource(ResourceLocation location) throws IOException {
|
|
||||||
return Optional.ofNullable(this.func_199002_a(location));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
|
|
||||||
public interface IFakeMinecraft {
|
|
||||||
// 1.13.2+
|
|
||||||
default IResourceManager func_195551_G() {
|
|
||||||
return (IResourceManager) ((Minecraft) this).getResourceManager();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
// This interface is only available before 1.12.2
|
|
||||||
public interface IFakeThreadDownloadImageData {
|
|
||||||
/**
|
|
||||||
* Reset {@link net.minecraft.client.renderer.ThreadDownloadImageData#bufferedImage} and
|
|
||||||
* {@link net.minecraft.client.renderer.ThreadDownloadImageData#textureUploaded} to false to refresh texture.
|
|
||||||
*/
|
|
||||||
void resetNewBufferedImage(BufferedImage image);
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
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=";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
|
||||||
return Lists.newArrayList(new GlitchlessGames(loader));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return root + username;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
GlitchlessApiResponse result = new Gson().fromJson(json, GlitchlessApiResponse.class);
|
|
||||||
if (!result.textures.containsKey(MinecraftProfileTexture.Type.SKIN))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return ModelManager0.toUserProfile(result.textures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "GlitchlessAPI";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GlitchlessApiResponse {
|
|
||||||
protected Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
public class JavaUtil {
|
|
||||||
public static URL[] getClasspath() {
|
|
||||||
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
|
|
||||||
//Java 8-
|
|
||||||
//Use URLClassLoader Directly
|
|
||||||
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
|
|
||||||
return ucl.getURLs();
|
|
||||||
} else {
|
|
||||||
//Java 9+
|
|
||||||
//It uses APPClassLoader instead of URLClassLoader
|
|
||||||
//Get Classpath from properties and parse it to URL array
|
|
||||||
String classpath = System.getProperty("java.class.path");
|
|
||||||
String[] elements = classpath.split(File.pathSeparator);
|
|
||||||
if (elements.length == 0)
|
|
||||||
return new URL[0];
|
|
||||||
LinkedList<URL> urls = new LinkedList<URL>();
|
|
||||||
for (String ele : elements) {
|
|
||||||
try {
|
|
||||||
urls.add(new File(ele).toURI().toURL());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return urls.toArray(new URL[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package net.minecraft.client.renderer;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.NativeImage;
|
|
||||||
|
|
||||||
public interface IImageBuffer extends Runnable {
|
|
||||||
BufferedImage parseUserSkin(BufferedImage image);
|
|
||||||
|
|
||||||
NativeImage func_195786_a(NativeImage image);
|
|
||||||
|
|
||||||
void skinAvailable();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void run() {
|
|
||||||
this.skinAvailable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package net.minecraft.client.renderer.texture;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty stack for NativeImage
|
|
||||||
*/
|
|
||||||
public class NativeImage {
|
|
||||||
public static NativeImage func_195713_a(InputStream inputStreamIn) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getWidth
|
|
||||||
*/
|
|
||||||
public int func_195702_a() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getHeight
|
|
||||||
*/
|
|
||||||
public int func_195714_b() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copyImage image
|
|
||||||
*/
|
|
||||||
public void func_195703_a(NativeImage p_195703_1_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* fillAreaRGBA x0 y0 weight height rgba
|
|
||||||
*/
|
|
||||||
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
|
|
||||||
*/
|
|
||||||
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getPixelRGBA x y
|
|
||||||
*/
|
|
||||||
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* setPixelRGBA x y rgba
|
|
||||||
*/
|
|
||||||
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package net.minecraft.client.resources;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
// this class shouldn't be created by ASM because of modlauncher issue.
|
|
||||||
public interface IResource {
|
|
||||||
InputStream getInputStream();
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package net.minecraft.client.resources;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
// this class shouldn't be created by ASM because of modlauncher issue.
|
|
||||||
public interface IResourceManager {
|
|
||||||
IResource getResource(ResourceLocation location) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package net.minecraft.resources;
|
|
||||||
|
|
||||||
// exclude
|
|
||||||
public interface IResource {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package net.minecraft.resources;
|
|
||||||
|
|
||||||
// exclude
|
|
||||||
public interface IResourceManager {
|
|
||||||
|
|
||||||
}
|
|
||||||
+65
-80
@@ -1,28 +1,28 @@
|
|||||||
package customskinloader;
|
package customskinloader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
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 com.google.common.collect.Maps;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import customskinloader.config.Config;
|
import customskinloader.config.Config;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.GameProfileLoader;
|
||||||
import customskinloader.loader.ProfileLoader;
|
import customskinloader.loader.ProfileLoader;
|
||||||
import customskinloader.profile.DynamicSkullManager;
|
import customskinloader.log.LogManager;
|
||||||
|
import customskinloader.log.Logger;
|
||||||
import customskinloader.profile.ModelManager0;
|
import customskinloader.profile.ModelManager0;
|
||||||
import customskinloader.profile.ProfileCache;
|
import customskinloader.profile.ProfileCache;
|
||||||
import customskinloader.profile.UserProfile;
|
import customskinloader.profile.UserProfile;
|
||||||
import customskinloader.utils.MinecraftUtil;
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
import customskinloader.utils.ThreadPoolFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom skin loader mod for Minecraft.
|
* Custom skin loader mod for Minecraft.
|
||||||
@@ -45,55 +45,27 @@ public class CustomSkinLoader {
|
|||||||
public static final Config config = initConfig();
|
public static final Config config = initConfig();
|
||||||
|
|
||||||
private static final ProfileCache profileCache = new ProfileCache();
|
private static final ProfileCache profileCache = new ProfileCache();
|
||||||
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
|
||||||
|
|
||||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(
|
public static final ExecutorService THREAD_POOL = ThreadPoolFactory.create(config.threadPoolSize, false);
|
||||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
public static final ExecutorService PROFILE_THREAD_POOL = ThreadPoolFactory.create(config.loadlist.size() * config.threadPoolSize, true);
|
||||||
|
|
||||||
//Correct thread name in thread pool
|
|
||||||
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
|
||||||
private static final ThreadFactory customFactory = r -> {
|
|
||||||
Thread t = defaultFactory.newThread(r);
|
|
||||||
if (r instanceof Thread) {
|
|
||||||
t.setName(((Thread) r).getName());
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
//Thread pool will discard oldest task when queue reaches 333 tasks
|
|
||||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
|
|
||||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES,
|
|
||||||
new LinkedBlockingQueue<>(333), customFactory, new ThreadPoolExecutor.DiscardOldestPolicy()
|
|
||||||
);
|
|
||||||
|
|
||||||
public static void loadProfileTextures(Runnable runnable) {
|
public static void loadProfileTextures(Runnable runnable) {
|
||||||
THREAD_POOL.execute(runnable);
|
THREAD_POOL.execute(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadProfileLazily(
|
|
||||||
GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
String tempName = Thread.currentThread().getName();
|
|
||||||
Thread.currentThread().setName(username); // Change Thread Name
|
|
||||||
if (profileCache.isLoading(credential)) {
|
|
||||||
profileCache.putLoader(credential, consumer);
|
|
||||||
Thread.currentThread().setName(tempName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
consumer.accept(loadProfile(gameProfile));
|
|
||||||
Thread.currentThread().setName(tempName);
|
|
||||||
profileCache.getLastLoader(credential).ifPresent(c -> loadProfileLazily(gameProfile, c));
|
|
||||||
}
|
|
||||||
|
|
||||||
//For User Skin
|
//For User Skin
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile) {
|
public static UserProfile loadProfile(GameProfile gameProfile) {
|
||||||
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
|
String tempName = Thread.currentThread().getName();
|
||||||
|
Thread.currentThread().setName(username + " <" + TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile) + ">"); // Change Thread Name
|
||||||
|
|
||||||
|
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||||
|
if (username == null || username.isEmpty() || username.equals(" ")) {
|
||||||
|
return ModelManager0.toUserProfile(GameProfileLoader.getTextures(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(gameProfile)));
|
||||||
|
}
|
||||||
|
|
||||||
UserProfile profile;
|
UserProfile profile;
|
||||||
if (profileCache.isReady(credential)) {
|
if (profileCache.isReady(credential)) {
|
||||||
logger.info("Cached profile will be used.");
|
logger.info("Cached profile will be used.");
|
||||||
@@ -110,25 +82,29 @@ public class CustomSkinLoader {
|
|||||||
profileCache.setLoading(credential, true);
|
profileCache.setLoading(credential, true);
|
||||||
profile = loadProfile0(gameProfile, false);
|
profile = loadProfile0(gameProfile, false);
|
||||||
}
|
}
|
||||||
return ModelManager0.fromUserProfile(profile);
|
Thread.currentThread().setName(tempName);
|
||||||
|
return profile == null ? new UserProfile() : profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Core
|
//Core
|
||||||
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
|
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
|
||||||
String username = gameProfile.getName();
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
profileCache.setLoading(credential, true);
|
profileCache.setLoading(credential, true);
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
logger.info("Loading " + username + "'s profile.");
|
logger.info("Loading " + username + "'s profile.");
|
||||||
if (config.loadlist == null || config.loadlist.isEmpty()) {
|
if (config.loadlist == null || config.loadlist.isEmpty()) {
|
||||||
logger.info("LoadList is Empty.");
|
logger.info("LoadList is Empty.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int size = config.loadlist.size();
|
||||||
|
LinkedList<CompletableFuture<UserProfile>> profileGetters = new LinkedList<>();
|
||||||
UserProfile profile0 = new UserProfile();
|
UserProfile profile0 = new UserProfile();
|
||||||
for (int i = 0; i < config.loadlist.size(); i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
SkinSiteProfile ssp = config.loadlist.get(i);
|
SkinSiteProfile ssp = config.loadlist.get(i);
|
||||||
logger.info((i + 1) + "/" + config.loadlist.size() + " Try to load profile from '" + ssp.name + "'.");
|
logger.info((i + 1) + "/" + size + " Try to load profile from '" + ssp.name + "'.");
|
||||||
if (ssp.type == null) {
|
if (ssp.type == null) {
|
||||||
logger.info("The type of '" + ssp.name + "' is null.");
|
logger.info("The type of '" + ssp.name + "' is null.");
|
||||||
continue;
|
continue;
|
||||||
@@ -138,17 +114,27 @@ public class CustomSkinLoader {
|
|||||||
logger.info("Type '" + ssp.type + "' is not defined.");
|
logger.info("Type '" + ssp.type + "' is not defined.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
UserProfile profile = null;
|
profileGetters.add(CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
String tempName = Thread.currentThread().getName();
|
||||||
profile = loader.loadProfile(ssp, gameProfile);
|
Thread.currentThread().setName(username + " <" + TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile) + "> (" + ssp.name + ")"); // Change Thread Name
|
||||||
} catch (Exception e) {
|
UserProfile profile = null;
|
||||||
logger.warning("Exception occurs while loading.");
|
try {
|
||||||
logger.warning(e);
|
profile = loader.loadProfile(ssp, gameProfile);
|
||||||
if (e.getCause() != null) {
|
} catch (Exception e) {
|
||||||
logger.warning("Caused By:");
|
logger.warning("Exception occurs while loading.");
|
||||||
logger.warning(e.getCause());
|
logger.warning(e);
|
||||||
|
if (e.getCause() != null) {
|
||||||
|
logger.warning("Caused By:");
|
||||||
|
logger.warning(e.getCause());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Thread.currentThread().setName(tempName);
|
||||||
|
return profile;
|
||||||
|
}, PROFILE_THREAD_POOL));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CompletableFuture<UserProfile> profileGetter : profileGetters) {
|
||||||
|
UserProfile profile = profileGetter.join();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -163,8 +149,9 @@ public class CustomSkinLoader {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!profile0.isEmpty()) {
|
if (!profile0.isEmpty()) {
|
||||||
logger.info(username + "'s profile loaded.");
|
logger.info(username + "'s profile loaded. (" + (System.currentTimeMillis() - time) + "ms)");
|
||||||
if (!config.enableCape) {
|
if (!config.enableCape) {
|
||||||
profile0.capeUrl = null;
|
profile0.capeUrl = null;
|
||||||
}
|
}
|
||||||
@@ -173,11 +160,11 @@ public class CustomSkinLoader {
|
|||||||
logger.info(profile0.toString(profileCache.getExpiry(credential)));
|
logger.info(profile0.toString(profileCache.getExpiry(credential)));
|
||||||
return profile0;
|
return profile0;
|
||||||
}
|
}
|
||||||
logger.info(username + "'s profile not found in load list.");
|
logger.info(username + "'s profile not found in load list. (" + (System.currentTimeMillis() - time) + "ms)");
|
||||||
|
|
||||||
if (config.enableLocalProfileCache) {
|
if (config.enableLocalProfileCache) {
|
||||||
UserProfile profile = profileCache.getLocalProfile(credential);
|
UserProfile profile = profileCache.getLocalProfile(credential);
|
||||||
if (profile == null) {
|
if (profile == null || profile.equals(UserProfile.NULL)) {
|
||||||
logger.info(username + "'s LocalProfile not found.");
|
logger.info(username + "'s LocalProfile not found.");
|
||||||
} else {
|
} else {
|
||||||
profileCache.updateCache(credential, profile, false);
|
profileCache.updateCache(credential, profile, false);
|
||||||
@@ -191,16 +178,16 @@ public class CustomSkinLoader {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> INCOMPLETED = ImmutableMap.of();
|
||||||
//For Skull
|
//For Skull
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
||||||
final GameProfile gameProfile) {
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String username = gameProfile.getName();
|
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
|
//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
|
||||||
//Authlib 3.11.50 makes empty username to " "
|
//Authlib 3.11.50 makes empty username to " "
|
||||||
if (username == null || username.isEmpty() || username.equals(" ") || credential == null) {
|
if (username == null || username.isEmpty() || username.equals(" ") || credential == null) {
|
||||||
return dynamicSkullManager.getTexture(gameProfile);
|
return GameProfileLoader.getTextures(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(gameProfile));
|
||||||
}
|
}
|
||||||
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
|
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
|
||||||
UserProfile profile = profileCache.getProfile(credential);
|
UserProfile profile = profileCache.getProfile(credential);
|
||||||
@@ -217,23 +204,21 @@ public class CustomSkinLoader {
|
|||||||
if (config.forceUpdateSkull) {
|
if (config.forceUpdateSkull) {
|
||||||
new Thread(loadThread).start();
|
new Thread(loadThread).start();
|
||||||
} else {
|
} else {
|
||||||
threadPool.execute(loadThread);
|
THREAD_POOL.execute(loadThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Maps.newHashMap();
|
return INCOMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Logger initLogger() {
|
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("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
|
||||||
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
|
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
|
||||||
logger.info("Operating System: " + System.getProperty("os.name") +
|
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
||||||
" (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
logger.info("Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
|
||||||
logger.info("Java Version: " + System.getProperty("java.version") +
|
logger.info("Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
|
||||||
", " + System.getProperty("java.vendor"));
|
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion() + " (" + MinecraftUtil.getLoaderName() + " " + MinecraftUtil.getLoaderVersion() + ")");
|
||||||
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;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-7
@@ -2,7 +2,11 @@ package customskinloader.config;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.loader.ProfileLoader;
|
import customskinloader.loader.ProfileLoader;
|
||||||
@@ -10,7 +14,6 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|||||||
import customskinloader.plugin.PluginLoader;
|
import customskinloader.plugin.PluginLoader;
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
import customskinloader.utils.Version;
|
import customskinloader.utils.Version;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
@@ -22,9 +25,7 @@ public class Config {
|
|||||||
public List<SkinSiteProfile> loadlist;
|
public List<SkinSiteProfile> loadlist;
|
||||||
|
|
||||||
//Function
|
//Function
|
||||||
public boolean enableDynamicSkull = true;
|
|
||||||
public boolean enableTransparentSkin = true;
|
public boolean enableTransparentSkin = true;
|
||||||
public boolean forceIgnoreHttpsCertificate = false;
|
|
||||||
public boolean forceLoadAllTextures = true;
|
public boolean forceLoadAllTextures = true;
|
||||||
public boolean enableCape = true;
|
public boolean enableCape = true;
|
||||||
public int threadPoolSize = 8;
|
public int threadPoolSize = 8;
|
||||||
@@ -75,9 +76,7 @@ public class Config {
|
|||||||
config.loadExtraList();
|
config.loadExtraList();
|
||||||
config.updateLoadlist();
|
config.updateLoadlist();
|
||||||
config.initLocalFolder();
|
config.initLocalFolder();
|
||||||
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
config.threadPoolSize = Math.max(config.threadPoolSize, 2);
|
||||||
if (config.forceIgnoreHttpsCertificate)
|
|
||||||
HttpUtil0.ignoreHttpsCertificate();
|
|
||||||
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
|
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
||||||
File renamed without changes.
+10
-25
@@ -2,26 +2,28 @@ package customskinloader.fake;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||||
import customskinloader.fake.texture.FakeBufferedImage;
|
|
||||||
import customskinloader.fake.texture.FakeImage;
|
import customskinloader.fake.texture.FakeImage;
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
public class FakeCapeBuffer extends FakeSkinBuffer {
|
public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||||
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
private static final Identifier TEXTURE_ELYTRA_V1 = new Identifier("minecraft", "textures/entity/elytra.png");
|
||||||
|
private static final Identifier TEXTURE_ELYTRA_V2 = new Identifier("minecraft", "textures/entity/equipment/wings/elytra.png");
|
||||||
|
|
||||||
private static int loadedGlobal = 0;
|
private static int loadedGlobal = 0;
|
||||||
private static FakeImage elytraImage;
|
private static FakeImage elytraImage;
|
||||||
|
|
||||||
private static FakeImage loadElytra(FakeImage originalImage) {
|
private static FakeImage loadElytra(FakeImage originalImage) {
|
||||||
loadedGlobal++;
|
loadedGlobal++;
|
||||||
try {
|
try {
|
||||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
|
Object resourceManager = Minecraft.getInstance().getResourceManager();
|
||||||
|
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V1)
|
||||||
|
.orElseGet(() -> FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V2).orElse(null)));
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
FakeImage image = originalImage.createImage(is);
|
FakeImage image = originalImage.createImage(is);
|
||||||
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
||||||
@@ -30,7 +32,8 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
image = resetImageFormat(image, 22, 0, 46, 22);
|
image = resetImageFormat(image, 22, 0, 46, 22);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
} catch (IOException | NoSuchElementException ignored) {
|
} catch (IOException e) {
|
||||||
|
CustomSkinLoader.logger.warning(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -38,13 +41,8 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
private int loaded = 0;
|
private int loaded = 0;
|
||||||
private double ratioX = -1;
|
private double ratioX = -1;
|
||||||
private double ratioY = -1;
|
private double ratioY = -1;
|
||||||
private final ResourceLocation location;
|
|
||||||
private String type = null;
|
private String type = null;
|
||||||
|
|
||||||
public FakeCapeBuffer(ResourceLocation location) {
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FakeImage parseUserSkin(FakeImage image) {
|
public FakeImage parseUserSkin(FakeImage image) {
|
||||||
if (image == null) return null;
|
if (image == null) return null;
|
||||||
@@ -74,9 +72,6 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
if ("cape".equals(this.type)) {
|
if ("cape".equals(this.type)) {
|
||||||
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
||||||
this.attachElytra(elytraImage);
|
this.attachElytra(elytraImage);
|
||||||
if (this.image instanceof FakeBufferedImage) { // before 1.12.2
|
|
||||||
this.refreshTexture((FakeBufferedImage) this.image);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.image;
|
return this.image;
|
||||||
@@ -156,16 +151,6 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
return defaultReturnValue;
|
return defaultReturnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureID won't be regenerated when changing resource packs before 1.12.2
|
|
||||||
private void refreshTexture(FakeBufferedImage image) {
|
|
||||||
Object textureObj = MinecraftUtil.getTextureManager().getTexture(this.location);
|
|
||||||
if (textureObj != null) {
|
|
||||||
// NOTICE: OptiFine modified the upload process of the texture from ThreadDownloadImageData
|
|
||||||
// Therefore, it may not be correct to simply copy the vanilla behavior
|
|
||||||
FakeInterfaceManager.ThreadDownloadImageData_resetNewBufferedImage(textureObj, image.getImage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some cape image doesn't support alpha channel, so reset image format to ARGB
|
// Some cape image doesn't support alpha channel, so reset image format to ARGB
|
||||||
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user