mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
479
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7456725158 | ||
|
|
8023f4d1ea | ||
|
|
54339f9e66 | ||
|
|
3abba80b3b | ||
|
|
a7b64a1645 | ||
|
|
56c7e9196d | ||
|
|
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 | ||
|
|
dfa7db1731 | ||
|
|
b645fd1665 | ||
|
|
28fc81cb9a | ||
|
|
bb0a47de4b | ||
|
|
d09b1d9807 | ||
|
|
c207bdfc0e | ||
|
|
69d35a69b7 | ||
|
|
d767f40d32 | ||
|
|
5329a27d1a | ||
|
|
ddefe00ac0 | ||
|
|
dd4b706827 | ||
|
|
84072c62f3 | ||
|
|
2d00e12f0a | ||
|
|
b2b56f5be5 | ||
|
|
43c8ceb21e | ||
|
|
a0ad239770 | ||
|
|
c8f0f7e283 | ||
|
|
bfbd6ee31a | ||
|
|
f8f3caad39 | ||
|
|
bd409ae169 | ||
|
|
82f0aad9ff | ||
|
|
f2fce38137 | ||
|
|
7d19f3114c | ||
|
|
d7a1e0f31f | ||
|
|
201210f567 | ||
|
|
26ed002689 | ||
|
|
7d7e5c9060 | ||
|
|
81bf422250 | ||
|
|
776e31e158 | ||
|
|
4a92223158 | ||
|
|
264aacc8c0 | ||
|
|
0b000731b5 | ||
|
|
f0012b58df | ||
|
|
013c22ae95 | ||
|
|
01d02a27b0 | ||
|
|
077551e161 | ||
|
|
bd642d0106 | ||
|
|
fbec7ce6bb | ||
|
|
ea1b25a38f | ||
|
|
62018a3e8b | ||
|
|
f38a8ddcef | ||
|
|
63251c9f5e | ||
|
|
e94f4b0e99 | ||
|
|
5ee2eee382 | ||
|
|
3063de7ff0 | ||
|
|
583bf1fe6a | ||
|
|
a3de21497d | ||
|
|
51aec265be | ||
|
|
52caeb3bdc | ||
|
|
a3fa4e47c6 | ||
|
|
e1cde0afc7 | ||
|
|
3f379f3cbe | ||
|
|
f50640139a | ||
|
|
46b8635e10 | ||
|
|
02b24229f3 | ||
|
|
941b421d86 | ||
|
|
a67ed507ec | ||
|
|
851fa81f31 | ||
|
|
5bb16ededa | ||
|
|
1e5bfcd1e7 | ||
|
|
1b85fa8ff9 | ||
|
|
e1e5319bdb | ||
|
|
187be47e88 | ||
|
|
b2f8d2cc38 | ||
|
|
8b641e0227 | ||
|
|
c90cea3721 | ||
|
|
b0c11d11c6 | ||
|
|
c77ac58f6d | ||
|
|
16fadc56b4 | ||
|
|
fc6c43bac9 | ||
|
|
b6fc1610bc | ||
|
|
c7d04976e6 | ||
|
|
0eaf1960bf | ||
|
|
cff5846e7f | ||
|
|
c8fb6e216e | ||
|
|
a5d466e0a7 | ||
|
|
31fffa5d23 | ||
|
|
7e9f7fa498 | ||
|
|
f51b55be6e | ||
|
|
584c7b7518 | ||
|
|
51c8900562 | ||
|
|
ab7aebb753 | ||
|
|
dc5ecfb576 | ||
|
|
04899ff676 | ||
|
|
4df8ce38d6 | ||
|
|
3e001c4cdf | ||
|
|
d5dea652ff | ||
|
|
2a4226527d | ||
|
|
6c9494970f | ||
|
|
c84f506af1 | ||
|
|
a0e31ed883 | ||
|
|
8befcb32d8 | ||
|
|
fb50a3db6d | ||
|
|
4daacd18e8 | ||
|
|
98681e8251 | ||
|
|
ea5d890992 | ||
|
|
f5135872cc | ||
|
|
5d736dd4b5 | ||
|
|
1b2a4dc260 | ||
|
|
855131d1aa | ||
|
|
581a2dddea | ||
|
|
a1b52eb7ac | ||
|
|
0ed371fdc1 | ||
|
|
ee7e57cf78 | ||
|
|
90ed224dd8 | ||
|
|
a65445e989 | ||
|
|
da79597a16 | ||
|
|
9c6102a813 | ||
|
|
573c5e4a20 | ||
|
|
12441cc379 | ||
|
|
7df6336b56 | ||
|
|
2dd69e08da | ||
|
|
67fbcf5cec | ||
|
|
f898831276 | ||
|
|
83042f45bd | ||
|
|
dc6d135699 | ||
|
|
f42496e04c | ||
|
|
f003d57ddf | ||
|
|
b64700b9fb | ||
|
|
f64af50a07 | ||
|
|
a8c8edaf20 | ||
|
|
5ebee1f1e0 | ||
|
|
1eb8db550f | ||
|
|
52a232f982 | ||
|
|
eeebc30b58 | ||
|
|
46bccadca2 | ||
|
|
d7f207177c | ||
|
|
339e30247a | ||
|
|
ba8d86789d | ||
|
|
a9f19cfc8d | ||
|
|
8b1400ef0d | ||
|
|
82c2e80e76 | ||
|
|
8146773354 | ||
|
|
5ac6aa1865 | ||
|
|
dab8e3dd22 | ||
|
|
fdceb08a2c | ||
|
|
ad846f37a2 | ||
|
|
b8ce13606b | ||
|
|
2fbd3965e0 | ||
|
|
a714670b9a | ||
|
|
c5460624e3 | ||
|
|
9f63a770c3 | ||
|
|
4d234762d2 | ||
|
|
730b565c59 | ||
|
|
4d12d70bf0 | ||
|
|
42adcb5b27 | ||
|
|
77ddcc8bf5 | ||
|
|
d46adaac5e | ||
|
|
a6666b53a1 | ||
|
|
958860ecce | ||
|
|
6fab945eb1 | ||
|
|
e19b9d860f | ||
|
|
7adb0f9ef7 | ||
|
|
1bb130bb87 | ||
|
|
779e25f837 | ||
|
|
3a2d8f9caf | ||
|
|
0c91fb3975 | ||
|
|
290cbb63d8 | ||
|
|
100e661ac5 | ||
|
|
c490631f2c | ||
|
|
c519d09be4 | ||
|
|
e5a31ae49e | ||
|
|
68615ba724 | ||
|
|
10e57fe349 | ||
|
|
9f70ad0159 | ||
|
|
0d5538a110 | ||
|
|
27efbbfeb0 | ||
|
|
7fad8c602d | ||
|
|
29a0952bc4 | ||
|
|
b7107b7172 | ||
|
|
2adbc25f69 | ||
|
|
3bee9281ec | ||
|
|
917f9f650b | ||
|
|
edf6e241e4 | ||
|
|
d2c65f00c9 | ||
|
|
95ee345441 | ||
|
|
3ade4867d4 | ||
|
|
2d1951774d | ||
|
|
cc3616a074 | ||
|
|
42c48c5c2e | ||
|
|
030daf12a2 | ||
|
|
88763d64ef | ||
|
|
4f2b5edf84 | ||
|
|
cbe07b9003 | ||
|
|
b2867a0dbf | ||
|
|
65dacd8527 | ||
|
|
d2d425e96e | ||
|
|
0762e3e339 | ||
|
|
4cb1e348bb | ||
|
|
7bbfd19bfd | ||
|
|
be8b80bd55 | ||
|
|
47de6d3a89 | ||
|
|
f78a3b2565 | ||
|
|
016249c6ca | ||
|
|
860edd2e1a | ||
|
|
3e6e444857 | ||
|
|
d67b7c6296 | ||
|
|
94f6044c9a | ||
|
|
6b3531964e | ||
|
|
fbd06f147a | ||
|
|
e3020dad00 | ||
|
|
49fb976a2c | ||
|
|
78bc4b5f7e | ||
|
|
7a3dc4f9c2 | ||
|
|
2087f7bb94 | ||
|
|
e95edb16ac | ||
|
|
3b07b5ccca | ||
|
|
a3fb3cd770 | ||
|
|
b7b59c0b85 | ||
|
|
db6b54732e | ||
|
|
09e3b81552 | ||
|
|
2f494d295e | ||
|
|
e8e3a72ae7 | ||
|
|
ca8bd4e83d | ||
|
|
d789119c8f | ||
|
|
bfd1b41ecc | ||
|
|
5807acb34a | ||
|
|
f319d535ae | ||
|
|
f669d095b6 | ||
|
|
ca8b0ba185 | ||
|
|
7acef4d987 | ||
|
|
79404f659c | ||
|
|
85c86ff375 | ||
|
|
f4030701ee | ||
|
|
a36eca2a53 | ||
|
|
6ffdf2aafb | ||
|
|
fba9f7ca28 | ||
|
|
2d157e3d5b | ||
|
|
055aef17db | ||
|
|
622e834d26 | ||
|
|
469c8b62a9 | ||
|
|
1558ec819a | ||
|
|
883e7b45fc | ||
|
|
f30d3319b0 | ||
|
|
58276a7a0c | ||
|
|
883fb39380 | ||
|
|
1358a99f51 | ||
|
|
47ea01dc39 | ||
|
|
ee36f2f42a | ||
|
|
5868a39adb | ||
|
|
f7e000cb82 | ||
|
|
c40bb38e20 | ||
|
|
4449ccdd45 | ||
|
|
67e56957e7 | ||
|
|
ea432f2405 | ||
|
|
eee978fc83 | ||
|
|
9698d4098a | ||
|
|
3f779c9028 | ||
|
|
3945599fb4 | ||
|
|
b50e6a934f | ||
|
|
3dbf812f50 | ||
|
|
2bb8da3ff9 | ||
|
|
1371e7685e | ||
|
|
a49fea706d | ||
|
|
32547481e7 | ||
|
|
faff465ace | ||
|
|
e487ab1147 | ||
|
|
e26bc85f46 | ||
|
|
7dc2c45600 | ||
|
|
d6281881a5 | ||
|
|
7cdd582ed4 | ||
|
|
129b50a6c2 | ||
|
|
eaf9c5f48f | ||
|
|
b7e5c59ecf | ||
|
|
05e98d6eee | ||
|
|
f4b7393b44 | ||
|
|
898a4fe7d9 | ||
|
|
5cbfb87d08 | ||
|
|
8cdabb762d | ||
|
|
4369ddf43e | ||
|
|
8a1dca0dd4 | ||
|
|
b533d33f71 | ||
|
|
bfaa97ba04 | ||
|
|
c86790371d | ||
|
|
ed4bf8dbb3 | ||
|
|
b97f838d59 | ||
|
|
79440740ee | ||
|
|
481b0d9df9 | ||
|
|
cdd42d60e3 | ||
|
|
76bf0b5fdf | ||
|
|
f1c1f2f39a | ||
|
|
3c4b1cc4e2 | ||
|
|
e2258b1540 | ||
|
|
d286e419c5 | ||
|
|
28eb5eb376 | ||
|
|
4d34720d1c | ||
|
|
b9456d599f | ||
|
|
0233b7e077 | ||
|
|
a917e67871 | ||
|
|
ea49e7489a | ||
|
|
bcf5dc4cea | ||
|
|
7e522011e7 | ||
|
|
bdead01ef9 | ||
|
|
87a40fc3c7 | ||
|
|
0d60fb328a | ||
|
|
2f141bd565 | ||
|
|
a7f52365ca | ||
|
|
10ec669589 | ||
|
|
f09fe38831 | ||
|
|
953748f2ae | ||
|
|
e63858d561 | ||
|
|
b2d6532709 | ||
|
|
d2db775a17 | ||
|
|
7cf42be31c | ||
|
|
9a85d18f22 | ||
|
|
5d366d1d8c | ||
|
|
8257d6dfd0 | ||
|
|
1c973e633b | ||
|
|
933244a492 | ||
|
|
e719e9cd4e | ||
|
|
25c864b11b | ||
|
|
d60d9d4c36 | ||
|
|
a2698b5b95 | ||
|
|
b14be41789 | ||
|
|
cf4487f4d3 | ||
|
|
23f301c819 | ||
|
|
958023382d | ||
|
|
037ef06379 | ||
|
|
ad8c356c46 | ||
|
|
c9181c411f | ||
|
|
164632c7be | ||
|
|
7af9df3177 | ||
|
|
37960965b4 | ||
|
|
10c0536dbe | ||
|
|
aaf23aa88a | ||
|
|
8bbb9b1ee9 | ||
|
|
8c1cfa330e | ||
|
|
ff83d7f709 | ||
|
|
e05ee65d19 | ||
|
|
9a39e38ba1 | ||
|
|
7a7b9418d3 | ||
|
|
b08122913b | ||
|
|
bbc355365a | ||
|
|
8bccab4f0b | ||
|
|
1d88a98040 | ||
|
|
7314a08268 | ||
|
|
5c12463c94 | ||
|
|
b34a5b3343 | ||
|
|
7654dc583d | ||
|
|
4e78285bbe | ||
|
|
fe8c556e35 | ||
|
|
ffbe66193d | ||
|
|
fccacc6f98 | ||
|
|
e27c3ecd68 | ||
|
|
11d7d53684 | ||
|
|
fa97359eeb | ||
|
|
1540ecfa8d | ||
|
|
b27654dfe9 | ||
|
|
db10725c31 | ||
|
|
946d6901ea | ||
|
|
3054cc6a13 | ||
|
|
8f73eed29d | ||
|
|
a16c4a7b44 | ||
|
|
fcb24315e5 | ||
|
|
47f198b337 | ||
|
|
a38aa9687c | ||
|
|
0857a80ca8 | ||
|
|
704f3a4102 | ||
|
|
4ebce88594 | ||
|
|
8fa3a567ac | ||
|
|
5a29416ee9 | ||
|
|
4142609635 | ||
|
|
1dbfa30ba8 | ||
|
|
199c5d674e | ||
|
|
bebbbb0050 | ||
|
|
03388e3f85 | ||
|
|
103cd4548d | ||
|
|
87aa82647a | ||
|
|
adbde5334d | ||
|
|
6d44d738a8 | ||
|
|
5f0c3b419c | ||
|
|
4fe495d7fa | ||
|
|
ae4eaeb4ba | ||
|
|
f9a36acf8f | ||
|
|
c6ea90867e | ||
|
|
e584c112df | ||
|
|
f59e58a15a | ||
|
|
be06bbb2ab | ||
|
|
7cbc4ac79e | ||
|
|
ce4d0b550a | ||
|
|
17c6bfad5f |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Telegram
|
||||
url: https://t.me/customskinloader
|
||||
about: Community chat for CustomSkinLoader users.
|
||||
- name: QQ Group
|
||||
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
|
||||
about: Chinese community chat for CustomSkinLoader users.
|
||||
@@ -0,0 +1,126 @@
|
||||
name: Report Bug
|
||||
description: Report a bug and help us improve CustomSkinLoader
|
||||
labels: [ bug ]
|
||||
title: "[Bug] "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Here is the Report Bug issue for CustomSkinLoader
|
||||
With a red asterisk for the mandatory items
|
||||
Please keep the work order content neat and tidy, do not paste the contents of the log file directly onto the work order, it will look very messy and unattractive work orders
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: |
|
||||
A clear and concise description of what the issue is.
|
||||
Provide as much information as possible, videos, crash reports, etc.
|
||||
DO NOT PASTE A CRASH REPORT HERE!!!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproducing
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: How do you trigger this bug?
|
||||
render: bash
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: crash-report
|
||||
attributes:
|
||||
label: Link to crash-report if applicable
|
||||
description: |
|
||||
The files are in the folder `<minecraft-directory>/crash-reports`
|
||||
[Generate URL](https://mclo.gs)
|
||||
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: csl-log
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Link to CustomSkinLoader.log if applicable
|
||||
description: |
|
||||
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||
[Generate URL](https://mclo.gs)
|
||||
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: latest-log
|
||||
attributes:
|
||||
label: Link to latest.log if applicable
|
||||
description: |
|
||||
The path to the file is `<minecraft-directory>/logs/latest.log`.
|
||||
[Generate URL](https://mclo.gs)
|
||||
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: forge-log
|
||||
attributes:
|
||||
label: "[Only Forge User] Link to Forge Log if applicable"
|
||||
description: |
|
||||
The path to the file is `<minecraft-directory>/logs/debug.log` or `<minecraft-directory>/logs/fml-client-latest.log`.
|
||||
if your mod loader isn't `Forge`, URL can set empty
|
||||
[Generate URL](https://mclo.gs)
|
||||
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: mod-version
|
||||
attributes:
|
||||
label: Mod Version
|
||||
placeholder: "Ex: 14.16"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: mc-version
|
||||
attributes:
|
||||
label: Minecraft Version
|
||||
placeholder: "Ex: 1.19.4"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: mc-launcher-version
|
||||
attributes:
|
||||
label: Minecraft Launcher Name and Version
|
||||
placeholder: "Ex: HMCL v3.5.4.232"
|
||||
description: |
|
||||
If you don't know the version of the game, you can just fill in the name of the game launcher
|
||||
- type: dropdown
|
||||
id: loader-type
|
||||
attributes:
|
||||
label: Mod Loader
|
||||
options:
|
||||
- Quilt
|
||||
- Fabric
|
||||
- Forge
|
||||
- <without mod loader>
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: operating-systems
|
||||
attributes:
|
||||
label: Operating System
|
||||
options:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: prerequisites
|
||||
attributes:
|
||||
label: Before submitting a bug report
|
||||
options:
|
||||
- label: |
|
||||
This bug wasn't already reported (I have searched bug reports on GitHub).
|
||||
required: true
|
||||
- label: |
|
||||
This is a valid bug (I am able to reproduce this on the latest dev build).
|
||||
required: true
|
||||
- label: |
|
||||
This problem is triggered in the latest version of the mod (if not the latest please upgrade the mod first)
|
||||
required: true
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
name: 提交问题
|
||||
description: 报告问题以帮助我们改进CustomSkinLoader
|
||||
labels: [ bug ]
|
||||
title: "[Bug] "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
你好,这里是 `CustomSkinLoader`
|
||||
标注红色星号的为必填项
|
||||
以及,保持工单干净整洁,不要直接将日志内容粘贴到工单上,比如粘贴到描述内是不行的
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述问题
|
||||
description: |
|
||||
简单的描述问题, 并提供类似图片、视频,以更好的报告错误(如果可以)
|
||||
!注意:请不要在这里放日志文件或崩溃报告文件的内容
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproducing
|
||||
attributes:
|
||||
label: 复现步骤
|
||||
description: 请问你是如何触发这个问题的
|
||||
render: bash
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: crash-report
|
||||
attributes:
|
||||
label: 崩溃报告查看地址
|
||||
description: |
|
||||
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
|
||||
客户端若无崩溃则直接填写 `客户端无崩溃`
|
||||
[生成连接](https://mclo.gs)
|
||||
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: csl-log
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: CustomSkinLoader.log 查看地址
|
||||
description: |
|
||||
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||
[生成连接](https://mclo.gs)
|
||||
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: latest-log
|
||||
attributes:
|
||||
label: latest.log 查看地址
|
||||
description: |
|
||||
文件路径:`<游戏路径>/logs/latest.log`.
|
||||
[生成连接](https://mclo.gs)
|
||||
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: forge-log
|
||||
attributes:
|
||||
label: "[仅Forge用户] Forge Log 查看地址"
|
||||
description: |
|
||||
文件路径:`<游戏路径>/logs/debug.log` 或者 `<游戏路径>/logs/fml-client-latest.log`.
|
||||
若没有使用 `Forge` 加载器的,可以不填写
|
||||
[生成连接](https://mclo.gs)
|
||||
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||
- type: input
|
||||
id: mod-version
|
||||
attributes:
|
||||
label: 模组版本
|
||||
placeholder: "示例: 14.16"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: mc-version
|
||||
attributes:
|
||||
label: Minecraft游戏版本
|
||||
placeholder: "示例: 1.19.4"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: mc-launcher-version
|
||||
attributes:
|
||||
label: Minecraft启动器 名称 及 版本
|
||||
placeholder: "示例: HMCL v3.5.4.232"
|
||||
description: |
|
||||
若不知道游戏版本 可以只填写游戏启动器的名称
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: loader-type
|
||||
attributes:
|
||||
label: 模组加载器
|
||||
options:
|
||||
- Quilt
|
||||
- Fabric
|
||||
- Forge
|
||||
- 不使用加载器
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: operating-systems
|
||||
attributes:
|
||||
label: 操作系统
|
||||
options:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
- 其他操作系统
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: prerequisites
|
||||
attributes:
|
||||
label: 在提交错误报告之前,有没有做到...
|
||||
options:
|
||||
- label: |
|
||||
先尝试搜索issues里面, 查看并确认打开或关闭的工单, 是否搜索不到
|
||||
required: true
|
||||
- label: |
|
||||
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
|
||||
required: true
|
||||
- label: |
|
||||
这个问题是在最新的mod版本触发(若不是最新的请先升级mod)
|
||||
required: true
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Suggestion
|
||||
description: Suggest a new feature or change for CustomSkinLoader.
|
||||
labels: [ enhancement ]
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: A clear and concise description of what the feature/change is.
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: prerequisites
|
||||
attributes:
|
||||
label: Before submitting a suggestion
|
||||
options:
|
||||
- label: |
|
||||
This feature doesn't already exist in the client. (I have checked every module and their settings on the **latest dev build**)
|
||||
required: true
|
||||
- label: |
|
||||
This wasn't already suggested. (I have searched suggestions on GitHub and read the FAQ)
|
||||
required: true
|
||||
@@ -0,0 +1,22 @@
|
||||
name: 反馈或建议
|
||||
description: 给CustomSkinLoader这个模组提个建议
|
||||
labels: [ enhancement ]
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述一下
|
||||
description: 简单描述一下该功能/变化是什么。
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: prerequisites
|
||||
attributes:
|
||||
label: 在提交反馈或建议之前,请先确认...
|
||||
options:
|
||||
- label: |
|
||||
你要提交的反馈或者建议不存在于本模组的最新开发版下.
|
||||
required: true
|
||||
- label: |
|
||||
以及在issues或者Wiki内搜索过, 并且无结果
|
||||
required: true
|
||||
@@ -0,0 +1,55 @@
|
||||
# Composite action: setup JDK, build with Gradle, upload artifact
|
||||
name: Build
|
||||
description: Build project with Gradle and upload artifact
|
||||
|
||||
inputs:
|
||||
artifact-name:
|
||||
description: Artifact name for upload
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
mod_name:
|
||||
description: Display name of the mod
|
||||
value: ${{ steps.info.outputs.mod_name }}
|
||||
edition:
|
||||
description: Target mod loader edition
|
||||
value: ${{ steps.info.outputs.edition }}
|
||||
short_version:
|
||||
description: Shortened version identifier
|
||||
value: ${{ steps.info.outputs.short_version }}
|
||||
loaders:
|
||||
description: List of supported mod loaders
|
||||
value: ${{ steps.info.outputs.loaders }}
|
||||
game_versions:
|
||||
description: List of compatible Minecraft game versions
|
||||
value: ${{ steps.info.outputs.game_versions }}
|
||||
java:
|
||||
description: List of compatible Java versions
|
||||
value: ${{ steps.info.outputs.java }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '25'
|
||||
cache: gradle
|
||||
|
||||
- name: Build with Gradle
|
||||
shell: pwsh
|
||||
run: |
|
||||
./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }}
|
||||
./gradlew --stop
|
||||
|
||||
- name: Generate metadata JSONs
|
||||
if: github.event_name != 'pull_request'
|
||||
shell: pwsh
|
||||
id: info
|
||||
run: ./.github/scripts/Get-PublishInfo.ps1 -ArtifactDir 'Bootstrap/build/libs' -Type '${{ github.event_name }}'
|
||||
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ inputs.artifact-name }}
|
||||
path: Bootstrap/build/libs/
|
||||
if-no-files-found: error
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Compatibility Test
|
||||
description: Enter a Minecraft world with a build artifact and require a CSL log (Linux runner).
|
||||
|
||||
inputs:
|
||||
artifact-name:
|
||||
description: Build artifact containing the Universal jar
|
||||
required: true
|
||||
minecraft:
|
||||
description: Minecraft version
|
||||
required: true
|
||||
modloader:
|
||||
description: Loader to install (forge, fabric, neoforge)
|
||||
required: true
|
||||
java:
|
||||
description: Java version for the game
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: ${{ inputs.java }}
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ${{ inputs.artifact-name }}
|
||||
path: run/mods
|
||||
|
||||
- uses: headlesshq/[email protected]
|
||||
env:
|
||||
LIBGL_ALWAYS_SOFTWARE: 'true'
|
||||
with:
|
||||
mc: ${{ inputs.minecraft }}
|
||||
modloader: ${{ inputs.modloader }}
|
||||
regex: .*${{ inputs.modloader }}.*
|
||||
java: ${{ inputs.java }}
|
||||
mc-runtime-test: ${{ inputs.modloader == 'forge' && 'lexforge' || inputs.modloader }}
|
||||
dummy-assets: 'false'
|
||||
headlessmc-command: '--jvm "-Djava.awt.headless=true -DMcRuntimeGameTest=false"'
|
||||
|
||||
- name: Upload CSL log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: CustomSkinLoader-Log-${{ inputs.minecraft }}-${{ inputs.modloader }}-Java${{ inputs.java }}-${{ github.job }}-${{ github.run_number }}
|
||||
path: run/CustomSkinLoader/CustomSkinLoader.log
|
||||
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
|
||||
@@ -0,0 +1,83 @@
|
||||
name: Beta
|
||||
on:
|
||||
push:
|
||||
branches: [15-develop]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: ./.github/actions/build
|
||||
with:
|
||||
artifact-name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||
|
||||
publish-release:
|
||||
name: Publish to GitHub Release
|
||||
needs: build
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||
path: artifact
|
||||
|
||||
- name: Generate release body
|
||||
shell: pwsh
|
||||
run: |
|
||||
@"
|
||||
Build Time / 构建时间 : $((Get-Date).ToUniversalTime().AddHours(8).ToString("yyyy.MM.dd HH:mm"))
|
||||
Auto build from branch $env:GITHUB_REF_NAME
|
||||
|
||||
[How to use?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
|
||||
"@ | Set-Content -Path ci-build-body.md -NoNewline
|
||||
|
||||
- uses: ./.github/actions/publish-release
|
||||
with:
|
||||
artifact-path: artifact
|
||||
tag-name: CI-Build
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: '*.jar'
|
||||
prerelease: 'true'
|
||||
notes-file: ci-build-body.md
|
||||
|
||||
publish-object-storage:
|
||||
name: Publish to Object Storage
|
||||
needs: build
|
||||
runs-on: windows-latest
|
||||
environment: Build
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: CustomSkinLoader-Beta-${{ github.run_number }}
|
||||
path: artifact
|
||||
|
||||
- name: Upload jar to R2
|
||||
uses: ./.github/actions/publish-object-storage
|
||||
with:
|
||||
artifact-path: artifact
|
||||
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||
bucket: ${{ secrets.R2_BUCKET }}
|
||||
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||
target-path: mods/
|
||||
files: '*.jar'
|
||||
|
||||
- name: Upload JSONs to R2
|
||||
uses: ./.github/actions/publish-object-storage
|
||||
with:
|
||||
artifact-path: artifact
|
||||
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||
bucket: ${{ secrets.R2_BUCKET }}
|
||||
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||
files: '*.json'
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Pull Request
|
||||
on:
|
||||
push:
|
||||
branches: [ci/minecraft-smoke]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
branches: [15-develop]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: ./.github/actions/build
|
||||
with:
|
||||
artifact-name: CustomSkinLoader-PR-${{ github.run_number }}
|
||||
|
||||
compatibility:
|
||||
name: Compatibility Test (${{ matrix.minecraft }}, ${{ matrix.modloader }}, Java ${{ matrix.java }})
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
include:
|
||||
- { minecraft: '1.12.2', modloader: forge, java: '8' }
|
||||
- { minecraft: '1.16.5', modloader: forge, java: '8' }
|
||||
- { minecraft: '1.16.5', modloader: fabric, java: '8' }
|
||||
- { minecraft: '1.18.2', modloader: forge, java: '17' }
|
||||
- { minecraft: '1.20.2', modloader: forge, java: '17' }
|
||||
- { minecraft: '1.20.2', modloader: fabric, java: '17' }
|
||||
- { minecraft: '1.20.4', modloader: forge, java: '17' }
|
||||
- { minecraft: '1.21.1', modloader: neoforge, java: '21' }
|
||||
- { minecraft: '1.21.4', modloader: fabric, java: '21' }
|
||||
- { minecraft: '1.21.10', modloader: neoforge, java: '21' }
|
||||
- { minecraft: '1.21.11', modloader: fabric, java: '21' }
|
||||
- { minecraft: '26.1.2', modloader: fabric, java: '25' }
|
||||
- { minecraft: '26.2', modloader: fabric, java: '25' }
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: ./.github/actions/compatibility
|
||||
with:
|
||||
artifact-name: CustomSkinLoader-PR-${{ github.run_number }}
|
||||
minecraft: ${{ matrix.minecraft }}
|
||||
modloader: ${{ matrix.modloader }}
|
||||
java: ${{ matrix.java }}
|
||||
@@ -0,0 +1,117 @@
|
||||
name: Release
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: windows-latest
|
||||
outputs:
|
||||
mod_name: ${{ steps.build.outputs.mod_name }}
|
||||
edition: ${{ steps.build.outputs.edition }}
|
||||
short_version: ${{ steps.build.outputs.short_version }}
|
||||
loaders: ${{ steps.build.outputs.loaders }}
|
||||
game_versions: ${{ steps.build.outputs.game_versions }}
|
||||
java: ${{ steps.build.outputs.java }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: ./.github/actions/build
|
||||
id: build
|
||||
with:
|
||||
artifact-name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||
|
||||
publish-release:
|
||||
name: Publish to GitHub Release
|
||||
needs: build
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||
path: artifact
|
||||
|
||||
- uses: ./.github/actions/publish-release
|
||||
with:
|
||||
artifact-path: artifact
|
||||
tag-name: ${{ github.event.release.tag_name }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: '*.jar'
|
||||
generate-notes: 'true'
|
||||
|
||||
publish-object-storage:
|
||||
name: Publish to Object Storage
|
||||
needs: build
|
||||
runs-on: windows-latest
|
||||
environment: Build
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||
path: artifact
|
||||
|
||||
- name: Upload jar to R2
|
||||
uses: ./.github/actions/publish-object-storage
|
||||
with:
|
||||
artifact-path: artifact
|
||||
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||
bucket: ${{ secrets.R2_BUCKET }}
|
||||
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||
target-path: mods/
|
||||
files: '*.jar'
|
||||
|
||||
- name: Upload JSONs to R2
|
||||
uses: ./.github/actions/publish-object-storage
|
||||
with:
|
||||
artifact-path: artifact
|
||||
endpoint-url: ${{ secrets.R2_BASE_URL }}
|
||||
bucket: ${{ secrets.R2_BUCKET }}
|
||||
access-key-id: ${{ secrets.R2_SECRET_ID }}
|
||||
secret-access-key: ${{ secrets.R2_SECRET_KEY }}
|
||||
files: '*.json'
|
||||
|
||||
publish-mod-sites:
|
||||
name: Publish to Mod Sites
|
||||
needs: build
|
||||
runs-on: windows-latest
|
||||
environment: Build
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: CustomSkinLoader-Release-${{ github.run_number }}
|
||||
path: artifact
|
||||
|
||||
- uses: Kir-Antipov/[email protected]
|
||||
with:
|
||||
modrinth-id: idMHQ4n2
|
||||
modrinth-featured: true
|
||||
modrinth-unfeature-mode: subset
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
curseforge-id: 286924
|
||||
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
name: ${{ needs.build.outputs.mod_name }}_${{ needs.build.outputs.edition }}_${{ needs.build.outputs.short_version }}
|
||||
version: ${{ needs.build.outputs.short_version }}-${{ needs.build.outputs.edition }}
|
||||
version-type: release
|
||||
loaders: |
|
||||
${{ needs.build.outputs.loaders }}
|
||||
game-versions: |
|
||||
${{ needs.build.outputs.game_versions }}
|
||||
game-version-filter: releases
|
||||
java: |
|
||||
${{ needs.build.outputs.java }}
|
||||
retry-attempts: 2
|
||||
retry-delay: 10000
|
||||
fail-mode: fail
|
||||
files: |
|
||||
artifact/*.jar
|
||||
+38
-9
@@ -1,12 +1,41 @@
|
||||
*.class
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
!.github/actions/build
|
||||
.kotlin
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.src.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(File logFile){
|
||||
try {
|
||||
if(!logFile.getParentFile().exists()){
|
||||
logFile.getParentFile().mkdirs();
|
||||
}
|
||||
if(!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close(){
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage par1BufferedImage)
|
||||
{
|
||||
if (par1BufferedImage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = par1BufferedImage.getWidth();//Default: 64
|
||||
this.imageHeight = par1BufferedImage.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(par1BufferedImage, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(par1BufferedImage, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(par1BufferedImage, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.hasTransparency(par1, par2, par3, par4))
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ThreadDownloadImageData extends AbstractTexture
|
||||
{
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private SimpleTexture imageLocation;
|
||||
private boolean textureUploaded;
|
||||
|
||||
public boolean enabled;//For Optifine
|
||||
|
||||
public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
||||
{
|
||||
this.imageUrl = par1Str;
|
||||
this.imageBuffer = par3IImageBuffer;
|
||||
this.imageLocation = par2ResourceLocation != null ? new SimpleTexture(par2ResourceLocation) : null;
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
int var1 = super.getGlTextureId();
|
||||
|
||||
if (!this.textureUploaded && this.bufferedImage != null)
|
||||
{
|
||||
TextureUtil.uploadTextureImage(var1, this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
public void getBufferedImage(BufferedImage par1BufferedImage)
|
||||
{
|
||||
this.bufferedImage = par1BufferedImage;
|
||||
}
|
||||
|
||||
public void loadTexture(ResourceManager par1ResourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null)
|
||||
{
|
||||
if (this.imageLocation != null)
|
||||
{
|
||||
this.imageLocation.loadTexture(par1ResourceManager);
|
||||
this.glTextureId = this.imageLocation.getGlTextureId();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureUtil.uploadTextureImage(this.getGlTextureId(), this.bufferedImage);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
this.imageThread = new ThreadDownloadImageDataINNER1(this);
|
||||
this.imageThread.setDaemon(true);
|
||||
//this.imageThread.setName("Skin downloader: " + this.imageUrl);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTextureUploaded()
|
||||
{
|
||||
this.getGlTextureId();
|
||||
return this.textureUploaded;
|
||||
}
|
||||
|
||||
static String getImageUrl(ThreadDownloadImageData par0ThreadDownloadImageData)
|
||||
{
|
||||
return par0ThreadDownloadImageData.imageUrl;
|
||||
}
|
||||
|
||||
static IImageBuffer getImageBuffer(ThreadDownloadImageData par0ThreadDownloadImageData)
|
||||
{
|
||||
return par0ThreadDownloadImageData.imageBuffer;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
class ThreadDownloadImageDataINNER1 extends Thread
|
||||
{
|
||||
final ThreadDownloadImageData theThreadDownloadImageData;
|
||||
|
||||
ThreadDownloadImageDataINNER1(ThreadDownloadImageData par1ThreadDownloadImageData)
|
||||
{
|
||||
this.theThreadDownloadImageData = par1ThreadDownloadImageData;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
|
||||
//HttpURLConnection var1 = null;
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
try
|
||||
{
|
||||
/*
|
||||
var1 = (HttpURLConnection)(new URL(ThreadDownloadImageData.getImageUrl(this.theThreadDownloadImageData))).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
var1.setDoInput(true);
|
||||
var1.setDoOutput(false);
|
||||
var1.connect();
|
||||
|
||||
if (var1.getResponseCode() / 100 != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedImage var2 = ImageIO.read(var1.getInputStream());
|
||||
*/
|
||||
BufferedImage var2 = ImageIO.read(loader.getPlayerSkinStream(
|
||||
ThreadDownloadImageData.getImageUrl(this.theThreadDownloadImageData)));
|
||||
if (ThreadDownloadImageData.getImageBuffer(this.theThreadDownloadImageData) != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.getImageBuffer(this.theThreadDownloadImageData).parseUserSkin(var2);
|
||||
}
|
||||
|
||||
this.theThreadDownloadImageData.getBufferedImage(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
var6.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
/*
|
||||
if (var1 != null)
|
||||
{
|
||||
var1.disconnect();
|
||||
}*/
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 8th Subversion 2016.2.3
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.8";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified()){
|
||||
logger.info("Not Modified!");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
if(C.getContentLength()<=0){//Nothing to get
|
||||
return null;
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
logger.info("Successfully save cache to " + to.getAbsolutePath());
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
logger.info("Cache size : "+is.available());
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
if(to.exists()){
|
||||
to.setLastModified(C.getLastModified());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//TODO Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(File logFile){
|
||||
try {
|
||||
if(!logFile.getParentFile().exists()){
|
||||
logFile.getParentFile().mkdirs();
|
||||
}
|
||||
if(!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close(){
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (p_78432_1_ == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = p_78432_1_.getWidth();//Default: 64
|
||||
this.imageHeight = p_78432_1_.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(p_78432_1_, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(p_78432_1_, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(p_78432_1_, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_152634_a() {}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int var5 = p_78434_1_; var5 < p_78434_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78434_2_; var6 < p_78434_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int var5 = p_78433_1_; var5 < p_78433_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78433_2_; var6 < p_78433_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int var5 = p_78435_1_; var5 < p_78435_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78435_2_; var6 < p_78435_4_; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-158
@@ -1,158 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger field_147643_d = new AtomicInteger(0);
|
||||
private final File field_152434_e;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File p_i1049_1_, String p_i1049_2_, ResourceLocation p_i1049_3_, IImageBuffer p_i1049_4_)
|
||||
{
|
||||
super(p_i1049_3_);
|
||||
this.field_152434_e = p_i1049_1_;
|
||||
this.imageUrl = p_i1049_2_;
|
||||
this.imageBuffer = p_i1049_4_;
|
||||
}
|
||||
|
||||
private void func_147640_e()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.func_147631_c();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void func_147641_a(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.func_152634_a();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager p_110551_1_) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(p_110551_1_);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.field_152434_e != null && this.field_152434_e.isFile())
|
||||
{
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[] {this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.field_152434_e);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.func_147641_a(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException var3)
|
||||
{
|
||||
logger.error("Couldn\'t load skin " + this.field_152434_e, var3);
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_152433_a()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
ThreadDownloadImageData.logger.debug("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
InputStream var9=loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl);
|
||||
|
||||
|
||||
BufferedImage var2;
|
||||
/*
|
||||
if (ThreadDownloadImageData.this.field_152434_e != null)
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(var9, ThreadDownloadImageData.this.field_152434_e);
|
||||
var2 = ImageIO.read(ThreadDownloadImageData.this.field_152434_e);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}*/
|
||||
var2 = ImageIO.read(var9);
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.func_147641_a(var2);
|
||||
loader.disconnect();
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
public static final ResourceLocation field_152793_a = new ResourceLocation("textures/entity/steve.png");
|
||||
private static final ExecutorService field_152794_b = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager field_152795_c;
|
||||
private final File field_152796_d;
|
||||
private final MinecraftSessionService field_152797_e;
|
||||
private final LoadingCache field_152798_f;
|
||||
private static final String __OBFID = "CL_00001830";
|
||||
|
||||
public SkinManager(TextureManager p_i1044_1_, File p_i1044_2_, MinecraftSessionService p_i1044_3_)
|
||||
{
|
||||
this.field_152795_c = p_i1044_1_;
|
||||
this.field_152796_d = p_i1044_2_;
|
||||
this.field_152797_e = p_i1044_3_;
|
||||
this.field_152798_f = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).build(new CacheLoader()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001829";
|
||||
public Map func_152786_a(GameProfile p_152786_1_)
|
||||
{
|
||||
return Minecraft.getMinecraft().func_152347_ac().getTextures(p_152786_1_, false);
|
||||
}
|
||||
public Object load(Object p_load_1_)
|
||||
{
|
||||
return this.func_152786_a((GameProfile)p_load_1_);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ResourceLocation func_152792_a(MinecraftProfileTexture p_152792_1_, Type p_152792_2_)
|
||||
{
|
||||
return this.func_152789_a(p_152792_1_, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
public ResourceLocation func_152789_a(MinecraftProfileTexture p_152789_1_, final Type p_152789_2_, final SkinManager.SkinAvailableCallback p_152789_3_)
|
||||
{
|
||||
|
||||
final ResourceLocation var4 = new ResourceLocation(p_152789_2_.name()+"/" + p_152789_1_.getHash());
|
||||
//ITextureObject var5 = this.field_152795_c.getTexture(var4);
|
||||
/*
|
||||
if (var5 != null)
|
||||
{
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_152121_a(p_152789_2_, var4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File var6 = new File(this.field_152796_d, p_152789_1_.getHash().substring(0, 2));
|
||||
File var7 = new File(var6, p_152789_1_.getHash());
|
||||
final ImageBufferDownload var8 = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData var9 = new ThreadDownloadImageData(var7, p_152789_1_.getUrl(), field_152793_a, new IImageBuffer()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001828";
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
p_78432_1_ = var8.parseUserSkin(p_78432_1_);
|
||||
}
|
||||
|
||||
return p_78432_1_;
|
||||
}
|
||||
public void func_152634_a()
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
var8.func_152634_a();
|
||||
}
|
||||
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_152121_a(p_152789_2_, var4);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.field_152795_c.loadTexture(var4, var9);
|
||||
//}
|
||||
return var4;
|
||||
}
|
||||
|
||||
public void func_152790_a(final GameProfile p_152790_1_, final SkinManager.SkinAvailableCallback p_152790_2_, final boolean p_152790_3_)
|
||||
{
|
||||
field_152794_b.submit(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001827";
|
||||
public void run()
|
||||
{
|
||||
final HashMap var1 = Maps.newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
var1.putAll(SkinManager.this.field_152797_e.getTextures(p_152790_1_, p_152790_3_));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (var1.isEmpty() && p_152790_1_.getId().equals(Minecraft.getMinecraft().getSession().func_148256_e().getId()))
|
||||
{
|
||||
var1.putAll(SkinManager.this.field_152797_e.getTextures(SkinManager.this.field_152797_e.fillProfileProperties(p_152790_1_, false), false));
|
||||
}
|
||||
|
||||
//CustomSkinLoader Begin
|
||||
HashMap var2 = Maps.newHashMap();
|
||||
if (var1.containsKey(Type.SKIN)){
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.SKIN)).getUrl()+"?Skin="+p_152790_1_.getName()));
|
||||
}else{
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+p_152790_1_.getName()+".png"));
|
||||
}
|
||||
if (var1.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.CAPE)).getUrl()+"?Cloak="+p_152790_1_.getName()));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+p_152790_1_.getName()+".png"));
|
||||
}
|
||||
var1.clear();
|
||||
var1.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().func_152344_a(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001826";
|
||||
public void run()
|
||||
{
|
||||
if (var1.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.func_152789_a((MinecraftProfileTexture)var1.get(Type.SKIN), Type.SKIN, p_152790_2_);
|
||||
}
|
||||
|
||||
if (var1.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.func_152789_a((MinecraftProfileTexture)var1.get(Type.CAPE), Type.CAPE, p_152790_2_);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map func_152788_a(GameProfile p_152788_1_)
|
||||
{
|
||||
return (Map)this.field_152798_f.getUnchecked(p_152788_1_);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void func_152121_a(Type p_152121_1_, ResourceLocation p_152121_2_);
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(File logFile){
|
||||
try {
|
||||
if(!logFile.getParentFile().exists()){
|
||||
logFile.getParentFile().mkdirs();
|
||||
}
|
||||
if(!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close(){
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage par1BufferedImage)
|
||||
{
|
||||
if (par1BufferedImage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = par1BufferedImage.getWidth();//Default: 64
|
||||
this.imageHeight = par1BufferedImage.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(par1BufferedImage, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(par1BufferedImage, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(par1BufferedImage, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.hasTransparency(par1, par2, par3, par4))
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger field_147643_d = new AtomicInteger(0);
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
public CustomSkinLoader customSkinLoader=new CustomSkinLoader();
|
||||
|
||||
public boolean enabled;//For Optifine
|
||||
|
||||
public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
||||
{
|
||||
super(par2ResourceLocation);
|
||||
this.imageUrl = par1Str;
|
||||
this.imageBuffer = par3IImageBuffer;
|
||||
}
|
||||
|
||||
private void func_147640_e()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.func_147631_c();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void func_147641_a(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager par1ResourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(par1ResourceManager);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(
|
||||
ThreadDownloadImageData.this.customSkinLoader.getPlayerSkinStream(
|
||||
ThreadDownloadImageData.this.imageUrl));
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null){
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
ThreadDownloadImageData.this.func_147641_a(var2);
|
||||
customSkinLoader.disconnect();
|
||||
}catch (Exception var6){
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
//this.imageThread.setName("Skin downloader: " + this.imageUrl);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTextureUploaded()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return this.textureUploaded;
|
||||
}
|
||||
}
|
||||
-382
@@ -1,382 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class bpi extends bpa
|
||||
{
|
||||
|
||||
private static final brq a = new brq("textures/entity/steve.png");
|
||||
private bih f;
|
||||
private bih g;
|
||||
private bih h;
|
||||
|
||||
public bpi()
|
||||
{
|
||||
super(new bih(0.0F), 0.5F);
|
||||
f = (bih)i;
|
||||
g = new bih(1.0F);
|
||||
h = new bih(0.5F);
|
||||
}
|
||||
|
||||
protected int a(bma bma1, int i, float f1)
|
||||
{
|
||||
abu abu1 = bma1.bm.d(3 - i);
|
||||
if (abu1 != null)
|
||||
{
|
||||
abs abs1 = abu1.b();
|
||||
if (abs1 instanceof zs)
|
||||
{
|
||||
zs zs1 = (zs)abs1;
|
||||
a(bop.a(zs1, i));
|
||||
bih bih1 = i != 2 ? g : h;
|
||||
bih1.c.j = i == 0;
|
||||
bih1.d.j = i == 0;
|
||||
bih1.e.j = i == 1 || i == 2;
|
||||
bih1.f.j = i == 1;
|
||||
bih1.g.j = i == 1;
|
||||
bih1.h.j = i == 2 || i == 3;
|
||||
bih1.i.j = i == 2 || i == 3;
|
||||
a(((bim) (bih1)));
|
||||
bih1.p = this.i.p;
|
||||
bih1.q = this.i.q;
|
||||
bih1.s = this.i.s;
|
||||
if (zs1.m_() == zu.a)
|
||||
{
|
||||
int j = zs1.b(abu1);
|
||||
float f2 = (float)(j >> 16 & 0xff) / 255F;
|
||||
float f3 = (float)(j >> 8 & 0xff) / 255F;
|
||||
float f4 = (float)(j & 0xff) / 255F;
|
||||
GL11.glColor3f(f2, f3, f4);
|
||||
return !abu1.y() ? 16 : 31;
|
||||
}
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
return !abu1.y() ? 1 : 15;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected void b(bma bma1, int i, float f1)
|
||||
{
|
||||
abu abu1 = bma1.bm.d(3 - i);
|
||||
if (abu1 != null)
|
||||
{
|
||||
abs abs1 = abu1.b();
|
||||
if (abs1 instanceof zs)
|
||||
{
|
||||
a(bop.a((zs)abs1, i, "overlay"));
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(bma bma1, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
abu abu1 = bma1.bm.h();
|
||||
g.m = h.m = f.m = abu1 == null ? 0 : 1;
|
||||
if (abu1 != null && bma1.bw() > 0)
|
||||
{
|
||||
acz acz1 = abu1.o();
|
||||
if (acz1 == acz.d)
|
||||
g.m = h.m = f.m = 3;
|
||||
else
|
||||
if (acz1 == acz.e)
|
||||
g.o = h.o = f.o = true;
|
||||
}
|
||||
g.n = h.n = f.n = bma1.am();
|
||||
double d3 = d1 - (double)bma1.L;
|
||||
if (bma1.am() && !(bma1 instanceof bmd))
|
||||
d3 -= 0.125D;
|
||||
super.a(bma1, d, d3, d2, f1, f2);
|
||||
g.o = h.o = f.o = false;
|
||||
g.n = h.n = f.n = false;
|
||||
g.m = h.m = f.m = 0;
|
||||
}
|
||||
|
||||
protected brq a(bma bma1)
|
||||
{
|
||||
return bma1.t();
|
||||
}
|
||||
|
||||
protected void a(bma bma1, float f1)
|
||||
{
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
super.c(bma1, f1);
|
||||
super.e(bma1, f1);
|
||||
abu abu1 = bma1.bm.d(3);
|
||||
if (abu1 != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f.c.c(0.0625F);
|
||||
if (abu1.b() instanceof zy)
|
||||
{
|
||||
if (bmf.a(ahz.a(abu1.b()).b()))
|
||||
{
|
||||
float f2 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, -0.25F, 0.0F);
|
||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f2, -f2, -f2);
|
||||
}
|
||||
b.f.a(bma1, abu1, 0);
|
||||
} else
|
||||
if (abu1.b() == abv.bL)
|
||||
{
|
||||
float f3 = 1.0625F;
|
||||
GL11.glScalef(f3, -f3, -f3);
|
||||
String s = "";
|
||||
if (abu1.p() && abu1.q().b("SkullOwner", 8))
|
||||
s = abu1.q().j("SkullOwner");
|
||||
bnl.b.a(-0.5F, 0.0F, -0.5F, 1, 180F, abu1.k(), s);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (bma1.b_().equals("deadmau5") && bma1.r().a())
|
||||
{
|
||||
a(bma1.t());
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float f4 = (bma1.A + (bma1.y - bma1.A) * f1) - (bma1.aN + (bma1.aM - bma1.aN) * f1);
|
||||
float f5 = bma1.B + (bma1.z - bma1.B) * f1;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(f4, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(f5, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.375F * (float)(i * 2 - 1), 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.375F, 0.0F);
|
||||
GL11.glRotatef(-f5, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-f4, 0.0F, 1.0F, 0.0F);
|
||||
float f6 = 1.333333F;
|
||||
GL11.glScalef(f6, f6, f6);
|
||||
f.b(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
boolean flag = bma1.s().a();
|
||||
if (flag && !bma1.ao() && !bma1.bS())
|
||||
{
|
||||
a(bma1.u());
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||
double d = (bma1.bu + (bma1.bx - bma1.bu) * (double)f1) - (bma1.p + (bma1.s - bma1.p) * (double)f1);
|
||||
double d1 = (bma1.bv + (bma1.by - bma1.bv) * (double)f1) - (bma1.q + (bma1.t - bma1.q) * (double)f1);
|
||||
double d2 = (bma1.bw + (bma1.bz - bma1.bw) * (double)f1) - (bma1.r + (bma1.u - bma1.r) * (double)f1);
|
||||
float f16 = bma1.aN + (bma1.aM - bma1.aN) * f1;
|
||||
double d3 = oy.a((f16 * 3.141593F) / 180F);
|
||||
double d4 = -oy.b((f16 * 3.141593F) / 180F);
|
||||
float f18 = (float)d1 * 10F;
|
||||
if (f18 < -6F)
|
||||
f18 = -6F;
|
||||
if (f18 > 32F)
|
||||
f18 = 32F;
|
||||
float f19 = (float)(d * d3 + d2 * d4) * 100F;
|
||||
float f20 = (float)(d * d4 - d2 * d3) * 100F;
|
||||
if (f19 < 0.0F)
|
||||
f19 = 0.0F;
|
||||
float f21 = bma1.br + (bma1.bs - bma1.br) * f1;
|
||||
f18 += oy.a((bma1.O + (bma1.P - bma1.O) * f1) * 6F) * 32F * f21;
|
||||
if (bma1.am())
|
||||
f18 += 25F;
|
||||
GL11.glRotatef(6F + f19 / 2.0F + f18, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(f20 / 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-f20 / 2.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
|
||||
f.c(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
abu abu2 = bma1.bm.h();
|
||||
if (abu2 != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f.f.c(0.0625F);
|
||||
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
|
||||
if (bma1.bK != null)
|
||||
abu2 = new abu(abv.y);
|
||||
acz acz1 = null;
|
||||
if (bma1.bw() > 0)
|
||||
acz1 = abu2.o();
|
||||
if ((abu2.b() instanceof zy) && bmf.a(ahz.a(abu2.b()).b()))
|
||||
{
|
||||
float f7 = 0.5F;
|
||||
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
|
||||
f7 *= 0.75F;
|
||||
GL11.glRotatef(20F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(-f7, -f7, f7);
|
||||
} else
|
||||
if (abu2.b() == abv.f)
|
||||
{
|
||||
float f8 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
GL11.glRotatef(-20F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f8, -f8, f8);
|
||||
GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
if (abu2.b().f())
|
||||
{
|
||||
float f9 = 0.625F;
|
||||
if (abu2.b().g())
|
||||
{
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, -0.125F, 0.0F);
|
||||
}
|
||||
if (bma1.bw() > 0 && acz1 == acz.d)
|
||||
{
|
||||
GL11.glTranslatef(0.05F, 0.0F, -0.1F);
|
||||
GL11.glRotatef(-50F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-10F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-60F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
|
||||
GL11.glScalef(f9, -f9, f9);
|
||||
GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
{
|
||||
float f10 = 0.375F;
|
||||
GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
|
||||
GL11.glScalef(f10, f10, f10);
|
||||
GL11.glRotatef(60F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
if (abu2.b().b())
|
||||
{
|
||||
for (int j = 0; j <= 1; j++)
|
||||
{
|
||||
int l = abu2.b().a(abu2, j);
|
||||
float f12 = (float)(l >> 16 & 0xff) / 255F;
|
||||
float f14 = (float)(l >> 8 & 0xff) / 255F;
|
||||
float f17 = (float)(l & 0xff) / 255F;
|
||||
GL11.glColor4f(f12, f14, f17, 1.0F);
|
||||
b.f.a(bma1, abu2, j);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
int k = abu2.b().a(abu2, 0);
|
||||
float f11 = (float)(k >> 16 & 0xff) / 255F;
|
||||
float f13 = (float)(k >> 8 & 0xff) / 255F;
|
||||
float f15 = (float)(k & 0xff) / 255F;
|
||||
GL11.glColor4f(f11, f13, f15, 1.0F);
|
||||
b.f.a(bma1, abu2, 0);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void b(bma bma1, float f1)
|
||||
{
|
||||
float f2 = 0.9375F;
|
||||
GL11.glScalef(f2, f2, f2);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, double d, double d1, double d2,
|
||||
String s, float f1, double d3)
|
||||
{
|
||||
if (d3 < 100D)
|
||||
{
|
||||
ayw ayw1 = bma1.bT();
|
||||
ayr ayr1 = ayw1.a(2);
|
||||
if (ayr1 != null)
|
||||
{
|
||||
ayt ayt1 = ayw1.a(bma1.b_(), ayr1);
|
||||
if (bma1.bl())
|
||||
a(((qr) (bma1)), (new StringBuilder()).append(ayt1.c()).append(" ").append(ayr1.d()).toString(), d, d1 - 1.5D, d2, 64);
|
||||
else
|
||||
a(((qr) (bma1)), (new StringBuilder()).append(ayt1.c()).append(" ").append(ayr1.d()).toString(), d, d1, d2, 64);
|
||||
d1 += (float)c().a * 1.15F * f1;
|
||||
}
|
||||
}
|
||||
super.a(bma1, d, d1, d2, s, f1, d3);
|
||||
}
|
||||
|
||||
public void a(xq xq)
|
||||
{
|
||||
float f1 = 1.0F;
|
||||
GL11.glColor3f(f1, f1, f1);
|
||||
f.p = 0.0F;
|
||||
f.a(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, xq);
|
||||
f.f.a(0.0625F);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, double d, double d1, double d2)
|
||||
{
|
||||
if (bma1.Y() && bma1.bl())
|
||||
super.a(bma1, d + (double)bma1.bC, d1 + (double)bma1.cc, d2 + (double)bma1.bD);
|
||||
else
|
||||
super.a(bma1, d, d1, d2);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, float f1, float f2, float f3)
|
||||
{
|
||||
if (bma1.Y() && bma1.bl())
|
||||
{
|
||||
GL11.glRotatef(bma1.bJ(), 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(a(((rm) (bma1))), 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
{
|
||||
super.a(bma1, f1, f2, f3);
|
||||
}
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, double d, double d1, double d2,
|
||||
String s, float f1, double d3)
|
||||
{
|
||||
a((bma)rm, d, d1, d2, s, f1, d3);
|
||||
}
|
||||
|
||||
protected void a(rm rm, float f1)
|
||||
{
|
||||
b((bma)rm, f1);
|
||||
}
|
||||
|
||||
protected void c(rm rm, int i, float f1)
|
||||
{
|
||||
b((bma)rm, i, f1);
|
||||
}
|
||||
|
||||
protected volatile int a(rm rm, int i, float f1)
|
||||
{
|
||||
return a((bma)rm, i, f1);
|
||||
}
|
||||
|
||||
protected void c(rm rm, float f1)
|
||||
{
|
||||
a((bma)rm, f1);
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, float f1, float f2, float f3)
|
||||
{
|
||||
a((bma)rm, f1, f2, f3);
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, double d, double d1, double d2)
|
||||
{
|
||||
a((bma)rm, d, d1, d2);
|
||||
}
|
||||
|
||||
public volatile void a(rm rm, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
a((bma)rm, d, d1, d2, f1, f2);
|
||||
}
|
||||
|
||||
protected volatile brq a(qr qr)
|
||||
{
|
||||
return a((bma)qr);
|
||||
}
|
||||
|
||||
public volatile void a(qr qr, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
a((bma)qr, d, d1, d2, f1, f2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class bqk extends bqn
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final String e;
|
||||
private final bmq f;
|
||||
private BufferedImage g;
|
||||
private Thread h;
|
||||
private boolean i;
|
||||
|
||||
public bqk(String s, brq brq, bmq bmq)
|
||||
{
|
||||
super(brq);
|
||||
e = s;
|
||||
f = bmq;
|
||||
}
|
||||
|
||||
private void e()
|
||||
{
|
||||
if (i)
|
||||
return;
|
||||
if (g != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
brb.a(super.b(), g);
|
||||
i = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
e();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
g = bufferedimage;
|
||||
}
|
||||
|
||||
public void a(brr brr1)
|
||||
{
|
||||
if (g == null && b != null)
|
||||
super.a(brr1);
|
||||
if (h == null)
|
||||
{
|
||||
h = new bql(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
h.setDaemon(true);
|
||||
h.setName((new StringBuilder()).append("Skin downloader: ").append(e).toString());
|
||||
h.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a()
|
||||
{
|
||||
e();
|
||||
return i;
|
||||
}
|
||||
|
||||
static String a(bqk bqk1)
|
||||
{
|
||||
return bqk1.e;
|
||||
}
|
||||
|
||||
static bmq b(bqk bqk1)
|
||||
{
|
||||
return bqk1.f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bql extends Thread
|
||||
{
|
||||
|
||||
final bqk a;
|
||||
|
||||
bql(bqk bqk1, String s)
|
||||
{
|
||||
a = bqk1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bqk.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.4 Builder
|
||||
echo Please Build with Minecraft 1.7.4 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bmv.java[For HD Skin]
|
||||
javac bmv.java
|
||||
echo Building bqk.java[DownloadImage]
|
||||
javac bqk.java
|
||||
echo Building bql.java[ThreadDownloadImage]
|
||||
javac bql.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: bnb.java
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bnb
|
||||
implements bmw
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bnb()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class bqq extends bqt
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final String e;
|
||||
private final bmw f;
|
||||
private BufferedImage g;
|
||||
private Thread h;
|
||||
private boolean i;
|
||||
|
||||
public bqq(String s, brw brw, bmw bmw)
|
||||
{
|
||||
super(brw);
|
||||
e = s;
|
||||
f = bmw;
|
||||
}
|
||||
|
||||
private void e()
|
||||
{
|
||||
if (i)
|
||||
return;
|
||||
if (g != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
brh.a(super.b(), g);
|
||||
i = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
e();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
g = bufferedimage;
|
||||
}
|
||||
|
||||
public void a(brx brx1)
|
||||
{
|
||||
if (g == null && b != null)
|
||||
super.a(brx1);
|
||||
if (h == null)
|
||||
{
|
||||
h = new bqr(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
h.setDaemon(true);
|
||||
h.setName((new StringBuilder()).append("Skin downloader: ").append(e).toString());
|
||||
h.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a()
|
||||
{
|
||||
e();
|
||||
return i;
|
||||
}
|
||||
|
||||
public static String a(bqq bqq1)
|
||||
{
|
||||
return bqq1.e;
|
||||
}
|
||||
|
||||
static bmw b(bqq bqq1)
|
||||
{
|
||||
return bqq1.f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bqr extends Thread
|
||||
{
|
||||
|
||||
final bqq a;
|
||||
|
||||
bqr(bqq bqq1, String s)
|
||||
{
|
||||
a = bqq1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bqq.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.5 Builder
|
||||
echo Please Build with Minecraft 1.7.5 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bnb.java[For HD Skin]
|
||||
javac bnb.java
|
||||
echo Building bqq.java[DownloadImage]
|
||||
javac bqq.java
|
||||
echo Building bqr.java[ThreadDownloadImage]
|
||||
javac bqr.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bom
|
||||
implements boh
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bom()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
public class bsb extends bse
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boh g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsb(File file, String s, bth bth, boh boh1)
|
||||
{
|
||||
super(bth);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boh1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bss.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(bti bti1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(bti1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bsc(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsb bsb1)
|
||||
{
|
||||
return bsb1.f;
|
||||
}
|
||||
|
||||
static File b(bsb bsb1)
|
||||
{
|
||||
return bsb1.e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boh c(bsb bsb1)
|
||||
{
|
||||
return bsb1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bsc extends Thread
|
||||
{
|
||||
|
||||
final bsb a;
|
||||
|
||||
bsc(bsb bsb1, String s)
|
||||
{
|
||||
a = bsb1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsb.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.6 Builder
|
||||
echo Please Build with Minecraft 1.7.6 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bom.java[For HD Skin]
|
||||
javac bom.java
|
||||
echo Building bsb.java[DownloadImage]
|
||||
javac bsb.java
|
||||
echo Building bsc.java[ThreadDownloadImage]
|
||||
javac bsc.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bom
|
||||
implements boh
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bom()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
public class bsb extends bse
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boh g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsb(File file, String s, bth bth, boh boh1)
|
||||
{
|
||||
super(bth);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boh1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bss.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(bti bti1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(bti1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bsc(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsb bsb1)
|
||||
{
|
||||
return bsb1.f;
|
||||
}
|
||||
|
||||
static File b(bsb bsb1)
|
||||
{
|
||||
return bsb1.e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boh c(bsb bsb1)
|
||||
{
|
||||
return bsb1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bsc extends Thread
|
||||
{
|
||||
|
||||
final bsb a;
|
||||
|
||||
bsc(bsb bsb1, String s)
|
||||
{
|
||||
a = bsb1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsb.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.7 Builder
|
||||
echo Please Build with Minecraft 1.7.7 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bom.java[For HD Skin]
|
||||
javac bom.java
|
||||
echo Building bsb.java[DownloadImage]
|
||||
javac bsb.java
|
||||
echo Building bsc.java[ThreadDownloadImage]
|
||||
javac bsc.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class boo
|
||||
implements boj
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public boo()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
b = bufferedimage.getWidth(null);
|
||||
c = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(b, c, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (b == 128 && c == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 256 && c == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 512 && c == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * b];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class bsd extends bsg
|
||||
{
|
||||
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boj g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsd(File file, String s, btj btj, boj boj1)
|
||||
{
|
||||
super(btj);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boj1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bsu.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(btk btk1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(btk1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bse(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsd bsd1)
|
||||
{
|
||||
return bsd1.f;
|
||||
}
|
||||
|
||||
static File b(bsd bsd1)
|
||||
{
|
||||
return bsd1.e;
|
||||
}
|
||||
|
||||
|
||||
static boj c(bsd bsd1)
|
||||
{
|
||||
return bsd1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
class bse extends Thread
|
||||
{
|
||||
|
||||
final bsd a;
|
||||
|
||||
bse(bsd bsd1, String s)
|
||||
{
|
||||
a = bsd1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsd.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.8 Builder
|
||||
echo Please Build with Minecraft 1.7.8 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building boo.java[For HD Skin]
|
||||
javac boo.java
|
||||
echo Building bsd.java[DownloadImage]
|
||||
javac bsd.java
|
||||
echo Building bse.java[ThreadDownloadImage]
|
||||
javac bse.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class boo
|
||||
implements boj
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public boo()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
b = bufferedimage.getWidth(null);
|
||||
c = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(b, c, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (b == 128 && c == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 256 && c == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 512 && c == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * b];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class bsd extends bsg
|
||||
{
|
||||
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boj g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsd(File file, String s, btj btj, boj boj1)
|
||||
{
|
||||
super(btj);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boj1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bsu.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(btk btk1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(btk1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bse(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsd bsd1)
|
||||
{
|
||||
return bsd1.f;
|
||||
}
|
||||
|
||||
static File b(bsd bsd1)
|
||||
{
|
||||
return bsd1.e;
|
||||
}
|
||||
|
||||
|
||||
static boj c(bsd bsd1)
|
||||
{
|
||||
return bsd1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
class bse extends Thread
|
||||
{
|
||||
|
||||
final bsd a;
|
||||
|
||||
bse(bsd bsd1, String s)
|
||||
{
|
||||
a = bsd1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsd.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.9 Builder
|
||||
echo Please Build with Minecraft 1.7.9 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building boo.java[For HD Skin]
|
||||
javac boo.java
|
||||
echo Building bsd.java[DownloadImage]
|
||||
javac bsd.java
|
||||
echo Building bse.java[ThreadDownloadImage]
|
||||
javac bse.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(File logFile){
|
||||
try {
|
||||
if(!logFile.getParentFile().exists()){
|
||||
logFile.getParentFile().mkdirs();
|
||||
}
|
||||
if(!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close(){
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (p_78432_1_ == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ratio=p_78432_1_.getWidth()/64;
|
||||
this.imageWidth = 64 * ratio;
|
||||
this.imageHeight = 64 * ratio;
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
var3.drawImage(p_78432_1_, 0, 0, (ImageObserver)null);
|
||||
|
||||
if (p_78432_1_.getHeight() == 32 * ratio)
|
||||
{
|
||||
var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
}
|
||||
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_152634_a() {}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int var5 = p_78434_1_; var5 < p_78434_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78434_2_; var6 < p_78434_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int var5 = p_78433_1_; var5 < p_78433_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78433_2_; var6 < p_78433_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int var5 = p_78435_1_; var5 < p_78435_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78435_2_; var6 < p_78435_4_; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0);
|
||||
private final File field_152434_e;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File p_i1049_1_, String p_i1049_2_, ResourceLocation p_i1049_3_, IImageBuffer p_i1049_4_)
|
||||
{
|
||||
super(p_i1049_3_);
|
||||
this.field_152434_e = p_i1049_1_;
|
||||
this.imageUrl = p_i1049_2_;
|
||||
this.imageBuffer = p_i1049_4_;
|
||||
}
|
||||
|
||||
private void checkTextureUploaded()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.deleteGlTexture();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.checkTextureUploaded();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void setBufferedImage(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.func_152634_a();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager p_110551_1_) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(p_110551_1_);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.field_152434_e != null && this.field_152434_e.isFile())
|
||||
{
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[] {this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.field_152434_e);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException var3)
|
||||
{
|
||||
logger.error("Couldn\'t load skin " + this.field_152434_e, var3);
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_152433_a()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
//HttpURLConnection var1 = null;
|
||||
ThreadDownloadImageData.logger.info("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
/*
|
||||
var1 = (HttpURLConnection)(new URL(ThreadDownloadImageData.this.imageUrl)).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
var1.setDoInput(true);
|
||||
var1.setDoOutput(false);
|
||||
var1.connect();
|
||||
|
||||
if (var1.getResponseCode() / 100 == 2)
|
||||
{*/
|
||||
BufferedImage var2;
|
||||
/*
|
||||
if (ThreadDownloadImageData.this.field_152434_e != null)
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(var1.getInputStream(), ThreadDownloadImageData.this.field_152434_e);
|
||||
var2 = ImageIO.read(ThreadDownloadImageData.this.field_152434_e);
|
||||
}
|
||||
else
|
||||
{
|
||||
var2 = TextureUtil.func_177053_a(var1.getInputStream());
|
||||
}
|
||||
*/
|
||||
InputStream var9=loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl);
|
||||
var2 = TextureUtil.func_177053_a(var9);
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.setBufferedImage(var2);
|
||||
return;
|
||||
//}
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
/*
|
||||
if (var1 != null)
|
||||
{
|
||||
var1.disconnect();
|
||||
}*/
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager textureManager;
|
||||
private final File skinCacheDir;
|
||||
private final MinecraftSessionService sessionService;
|
||||
private final LoadingCache skinCacheLoader;
|
||||
private static final String __OBFID = "CL_00001830";
|
||||
|
||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
|
||||
{
|
||||
this.textureManager = textureManagerInstance;
|
||||
this.skinCacheDir = skinCacheDirectory;
|
||||
this.sessionService = sessionService;
|
||||
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).build(new CacheLoader()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001829";
|
||||
public Map func_152786_a(GameProfile p_152786_1_)
|
||||
{
|
||||
return Minecraft.getMinecraft().getSessionService().getTextures(p_152786_1_, false);
|
||||
}
|
||||
public Object load(Object p_load_1_)
|
||||
{
|
||||
return this.func_152786_a((GameProfile)p_load_1_);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
|
||||
*/
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture p_152792_1_, Type p_152792_2_)
|
||||
{
|
||||
return this.loadSkin(p_152792_1_, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
|
||||
*/
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture p_152789_1_, final Type p_152789_2_, final SkinManager.SkinAvailableCallback p_152789_3_)
|
||||
{
|
||||
//final ResourceLocation var4 = new ResourceLocation("skins/" + p_152789_1_.getHash());
|
||||
final ResourceLocation var4 = new ResourceLocation(p_152789_2_.name() + "/" + p_152789_1_.getHash());
|
||||
//ITextureObject var5 = this.textureManager.getTexture(var4);
|
||||
/*
|
||||
if (var5 != null)
|
||||
{
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_180521_a(p_152789_2_, var4, p_152789_1_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File var6 = new File(this.skinCacheDir, p_152789_1_.getHash().substring(0, 2));
|
||||
File var7 = new File(var6, p_152789_1_.getHash());
|
||||
final ImageBufferDownload var8 = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData var9 = new ThreadDownloadImageData(var7, p_152789_1_.getUrl(), DefaultPlayerSkin.func_177335_a(), new IImageBuffer()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001828";
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
p_78432_1_ = var8.parseUserSkin(p_78432_1_);
|
||||
}
|
||||
|
||||
return p_78432_1_;
|
||||
}
|
||||
public void func_152634_a()
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
var8.func_152634_a();
|
||||
}
|
||||
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_180521_a(p_152789_2_, var4, p_152789_1_);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.textureManager.loadTexture(var4, var9);
|
||||
//}
|
||||
|
||||
return var4;
|
||||
}
|
||||
|
||||
public void func_152790_a(final GameProfile p_152790_1_, final SkinManager.SkinAvailableCallback p_152790_2_, final boolean p_152790_3_)
|
||||
{
|
||||
THREAD_POOL.submit(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001827";
|
||||
public void run()
|
||||
{
|
||||
final HashMap var1 = Maps.newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
var1.putAll(SkinManager.this.sessionService.getTextures(p_152790_1_, p_152790_3_));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (var1.isEmpty() && p_152790_1_.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId()))
|
||||
{
|
||||
var1.putAll(SkinManager.this.sessionService.getTextures(SkinManager.this.sessionService.fillProfileProperties(p_152790_1_, false), false));
|
||||
}
|
||||
//CustomSkinLoader Begin
|
||||
HashMap var2 = Maps.newHashMap();
|
||||
if (var1.containsKey(Type.SKIN)){
|
||||
MinecraftProfileTexture var3=((MinecraftProfileTexture)var1.get(Type.SKIN));
|
||||
String var4=var3.getMetadata("model");
|
||||
HashMap var5 = null;
|
||||
if(var4!=null){
|
||||
var5 = Maps.newHashMap();
|
||||
var5.put("model", var4);
|
||||
}
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(var3.getUrl()+"?Skin="+p_152790_1_.getName(),var5));
|
||||
}else{
|
||||
HashMap var5 = Maps.newHashMap();
|
||||
//var5.put("model", "slim");
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+p_152790_1_.getName()+".png",var5));
|
||||
}
|
||||
if (var1.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.CAPE)).getUrl()+"?Cloak="+p_152790_1_.getName(),null));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+p_152790_1_.getName()+".png",null));
|
||||
}
|
||||
var1.clear();
|
||||
var1.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001826";
|
||||
public void run()
|
||||
{
|
||||
if (var1.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)var1.get(Type.SKIN), Type.SKIN, p_152790_2_);
|
||||
}
|
||||
|
||||
if (var1.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)var1.get(Type.CAPE), Type.CAPE, p_152790_2_);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map loadSkinFromCache(GameProfile p_152788_1_)
|
||||
{
|
||||
return (Map)this.skinCacheLoader.getUnchecked(p_152788_1_);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void func_180521_a(Type p_180521_1_, ResourceLocation p_180521_2_, MinecraftProfileTexture p_180521_3_);
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(File logFile){
|
||||
try {
|
||||
if(!logFile.getParentFile().exists()){
|
||||
logFile.getParentFile().mkdirs();
|
||||
}
|
||||
if(!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(logFile), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close(){
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage image)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ratio=image.getWidth()/64;
|
||||
this.imageWidth = 64 * ratio;
|
||||
this.imageHeight = 64 * ratio;
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
var3.drawImage(image, 0, 0, (ImageObserver)null);
|
||||
|
||||
if (image.getHeight() == 32 * ratio)
|
||||
{
|
||||
var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
}
|
||||
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void skinAvailable()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int i = p_78434_1_; i < p_78434_3_; ++i)
|
||||
{
|
||||
for (int j = p_78434_2_; j < p_78434_4_; ++j)
|
||||
{
|
||||
this.imageData[i + j * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int i = p_78433_1_; i < p_78433_3_; ++i)
|
||||
{
|
||||
for (int j = p_78433_2_; j < p_78433_4_; ++j)
|
||||
{
|
||||
this.imageData[i + j * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int i = p_78435_1_; i < p_78435_3_; ++i)
|
||||
{
|
||||
for (int j = p_78435_2_; j < p_78435_4_; ++j)
|
||||
{
|
||||
int k = this.imageData[i + j * this.imageWidth];
|
||||
|
||||
if ((k >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0);
|
||||
private final File cacheFile;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn)
|
||||
{
|
||||
super(textureResourceLocation);
|
||||
this.cacheFile = cacheFileIn;
|
||||
this.imageUrl = imageUrlIn;
|
||||
this.imageBuffer = imageBufferIn;
|
||||
}
|
||||
|
||||
private void checkTextureUploaded()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.deleteGlTexture();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.checkTextureUploaded();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void setBufferedImage(BufferedImage bufferedImageIn)
|
||||
{
|
||||
this.bufferedImage = bufferedImageIn;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.skinAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager resourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(resourceManager);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.cacheFile != null && this.cacheFile.isFile())
|
||||
{
|
||||
logger.info("Loading http texture from local cache ({})", new Object[] {this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.cacheFile);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
logger.error((String)("Couldn\'t load skin " + this.cacheFile), (Throwable)ioexception);
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTextureFromServer()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
ThreadDownloadImageData.logger.info("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage bufferedimage;
|
||||
bufferedimage = TextureUtil.readBufferedImage(loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl));
|
||||
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
bufferedimage = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(bufferedimage);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.setBufferedImage(bufferedimage);
|
||||
return;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error((String)"Couldn\'t download http texture", (Throwable)exception);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager textureManager;
|
||||
private final File skinCacheDir;
|
||||
private final MinecraftSessionService sessionService;
|
||||
private final LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skinCacheLoader;
|
||||
|
||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
|
||||
{
|
||||
this.textureManager = textureManagerInstance;
|
||||
this.skinCacheDir = skinCacheDirectory;
|
||||
this.sessionService = sessionService;
|
||||
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).<GameProfile, Map<Type, MinecraftProfileTexture>>build(new CacheLoader<GameProfile, Map<Type, MinecraftProfileTexture>>()
|
||||
{
|
||||
public Map<Type, MinecraftProfileTexture> load(GameProfile p_load_1_) throws Exception
|
||||
{
|
||||
return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
|
||||
*/
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type p_152792_2_)
|
||||
{
|
||||
return this.loadSkin(profileTexture, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
|
||||
*/
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type p_152789_2_, final SkinManager.SkinAvailableCallback skinAvailableCallback)
|
||||
{
|
||||
final ResourceLocation resourcelocation = new ResourceLocation(p_152789_2_.name() + "/" + profileTexture.getHash());
|
||||
/*Remove cache
|
||||
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
|
||||
|
||||
if (itextureobject != null)
|
||||
{
|
||||
if (skinAvailableCallback != null)
|
||||
{
|
||||
skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx");
|
||||
File file2 = new File(file1, profileTexture.getHash());
|
||||
final IImageBuffer iimagebuffer = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer()
|
||||
{
|
||||
public BufferedImage parseUserSkin(BufferedImage image)
|
||||
{
|
||||
if (iimagebuffer != null)
|
||||
{
|
||||
image = iimagebuffer.parseUserSkin(image);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
public void skinAvailable()
|
||||
{
|
||||
if (iimagebuffer != null)
|
||||
{
|
||||
iimagebuffer.skinAvailable();
|
||||
}
|
||||
|
||||
if (skinAvailableCallback != null)
|
||||
{
|
||||
skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
||||
//}
|
||||
|
||||
return resourcelocation;
|
||||
}
|
||||
|
||||
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
|
||||
{
|
||||
THREAD_POOL.submit(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
map.putAll(SkinManager.this.sessionService.getTextures(profile, requireSecure));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (map.isEmpty() && profile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId()))
|
||||
{
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().putAll(Minecraft.getMinecraft().func_181037_M());
|
||||
map.putAll(SkinManager.this.sessionService.getTextures(profile, false));
|
||||
}
|
||||
//CustomSkinLoader Begin
|
||||
Map<Type, MinecraftProfileTexture> var2 = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
||||
if (map.containsKey(Type.SKIN)){
|
||||
MinecraftProfileTexture var3=((MinecraftProfileTexture)map.get(Type.SKIN));
|
||||
String var4=var3.getMetadata("model");
|
||||
Map var5 = null;
|
||||
if(var4!=null){
|
||||
var5 = Maps.newHashMap();
|
||||
var5.put("model", var4);
|
||||
}
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(var3.getUrl()+"?Skin="+profile.getName(),var5));
|
||||
}else{
|
||||
Map var5 = Maps.newHashMap();
|
||||
//var5.put("model", "slim");
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+profile.getName()+".png",var5));
|
||||
}
|
||||
if (map.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)map.get(Type.CAPE)).getUrl()+"?Cloak="+profile.getName(),null));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+profile.getName()+".png",null));
|
||||
}
|
||||
map.clear();
|
||||
map.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (map.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN, skinAvailableCallback);
|
||||
}
|
||||
|
||||
if (map.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.CAPE), Type.CAPE, skinAvailableCallback);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
|
||||
{
|
||||
return (Map)this.skinCacheLoader.getUnchecked(profile);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import customskinloader.bootstrap.mapping.Mappings;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public final class ClassTransformationContext {
|
||||
private final String internalClassName;
|
||||
private final ClassNode currentClassNode;
|
||||
private final Mappings mappings;
|
||||
|
||||
private ClassTransformationContext(String internalClassName, ClassNode currentClassNode, Mappings mappings) {
|
||||
this.internalClassName = internalClassName;
|
||||
this.currentClassNode = currentClassNode;
|
||||
this.mappings = mappings == null ? Mappings.EMPTY : mappings;
|
||||
}
|
||||
|
||||
public static ClassTransformationContext create(String className, ClassNode classNode, Mappings mappings) {
|
||||
if (classNode == null) {
|
||||
throw new IllegalArgumentException("Class node must not be null");
|
||||
}
|
||||
|
||||
return new ClassTransformationContext(normalizeInternalClassName(className, classNode), classNode, mappings);
|
||||
}
|
||||
|
||||
public String getInternalClassName() {
|
||||
return this.internalClassName;
|
||||
}
|
||||
|
||||
public ClassNode getCurrentClassNode() {
|
||||
return this.currentClassNode;
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return this.mappings;
|
||||
}
|
||||
|
||||
public String remapClassName(String sourceName) {
|
||||
return this.mappings.remapClassName(sourceName);
|
||||
}
|
||||
|
||||
public String unmapClassName(String targetName) {
|
||||
return this.mappings.unmapClassName(targetName);
|
||||
}
|
||||
|
||||
public String remapFieldName(String sourceOwner, String sourceName) {
|
||||
return this.mappings.remapFieldName(sourceOwner, sourceName);
|
||||
}
|
||||
|
||||
public String unmapFieldName(String targetOwner, String targetName) {
|
||||
return this.mappings.unmapFieldName(targetOwner, targetName);
|
||||
}
|
||||
|
||||
public String remapMethodName(String sourceOwner, String sourceName, String sourceDescriptor) {
|
||||
return this.mappings.remapMethodName(sourceOwner, sourceName, sourceDescriptor);
|
||||
}
|
||||
|
||||
public String unmapMethodName(String targetOwner, String targetName, String targetDescriptor) {
|
||||
return this.mappings.unmapMethodName(targetOwner, targetName, targetDescriptor);
|
||||
}
|
||||
|
||||
public String remapMethodDescriptor(String sourceDescriptor) {
|
||||
return this.mappings.remapMethodDescriptor(sourceDescriptor);
|
||||
}
|
||||
|
||||
public String unmapMethodDescriptor(String targetDescriptor) {
|
||||
return this.mappings.unmapMethodDescriptor(targetDescriptor);
|
||||
}
|
||||
|
||||
public boolean isTarget(String canonicalName) {
|
||||
return this.getInternalClassName().equals(this.remapClassName(canonicalName));
|
||||
}
|
||||
|
||||
public MethodNode findMethod(String owner, String name, String desc) {
|
||||
String mappedDesc = this.remapMethodDescriptor(desc);
|
||||
String mappedName = "<init>".equals(name) ? name : this.remapMethodName(owner, name, desc);
|
||||
for (MethodNode methodNode : this.getCurrentClassNode().methods) {
|
||||
if (mappedName.equals(methodNode.name) && mappedDesc.equals(methodNode.desc)) {
|
||||
return methodNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FieldNode findField(String owner, String name) {
|
||||
String mappedName = this.remapFieldName(owner, name);
|
||||
for (FieldNode fieldNode : this.getCurrentClassNode().fields) {
|
||||
if (mappedName.equals(fieldNode.name)) {
|
||||
return fieldNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String normalizeInternalClassName(String className, ClassNode classNode) {
|
||||
if (className != null && !className.trim().isEmpty()) {
|
||||
return normalizeInternalClassName(className);
|
||||
}
|
||||
if (classNode == null || classNode.name == null || classNode.name.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Class name must be available from either the context or the ClassNode");
|
||||
}
|
||||
|
||||
return normalizeInternalClassName(classNode.name);
|
||||
}
|
||||
|
||||
private static String normalizeInternalClassName(String className) {
|
||||
return className.replace('.', '/');
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public final class ClassTransformationReport {
|
||||
private final ClassTransformationContext context;
|
||||
private final List<String> appliedTransformerNames;
|
||||
private volatile byte[] transformedBytecode;
|
||||
|
||||
public ClassTransformationReport(ClassTransformationContext context, List<String> appliedTransformerNames) {
|
||||
this.context = context;
|
||||
this.appliedTransformerNames = Collections.unmodifiableList(new ArrayList<>(appliedTransformerNames));
|
||||
}
|
||||
|
||||
public ClassTransformationContext getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public byte[] getTransformedBytecode() {
|
||||
if (this.transformedBytecode == null) {
|
||||
if (this.getTransformedClassNode() == null) {
|
||||
throw new IllegalStateException("Transformed bytecode is not available without a transformed ClassNode");
|
||||
}
|
||||
|
||||
this.transformedBytecode = TransformerBootstrapSupport.toByteArray(this.getTransformedClassNode());
|
||||
}
|
||||
|
||||
return this.transformedBytecode.clone();
|
||||
}
|
||||
|
||||
public ClassNode getTransformedClassNode() {
|
||||
return this.context.getCurrentClassNode();
|
||||
}
|
||||
|
||||
public List<String> getAppliedTransformerNames() {
|
||||
return this.appliedTransformerNames;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return !this.appliedTransformerNames.isEmpty();
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import customskinloader.bootstrap.mapping.Mappings;
|
||||
|
||||
public final class ClassTransformerRegistry {
|
||||
private static final Comparator<TargetedClassTransformer> TRANSFORMER_ORDER = (left, right) -> {
|
||||
// Higher-priority transformers run first so low-priority patches can react to earlier changes.
|
||||
int priorityOrder = Integer.compare(right.getPriority(), left.getPriority());
|
||||
if (priorityOrder != 0) {
|
||||
return priorityOrder;
|
||||
}
|
||||
|
||||
return left.getName().compareTo(right.getName());
|
||||
};
|
||||
|
||||
private final CopyOnWriteArrayList<TargetedClassTransformer> transformers = new CopyOnWriteArrayList<>();
|
||||
|
||||
public void register(TargetedClassTransformer transformer) {
|
||||
this.transformers.add(transformer);
|
||||
this.sortTransformers();
|
||||
}
|
||||
|
||||
public List<TargetedClassTransformer> getTransformers() {
|
||||
return Collections.unmodifiableList(new ArrayList<>(this.transformers));
|
||||
}
|
||||
|
||||
public List<TargetedClassTransformer> getApplicableTransformers(String className, Mappings mappings) {
|
||||
List<TargetedClassTransformer> applicableTransformers = new ArrayList<>();
|
||||
|
||||
for (TargetedClassTransformer transformer : this.transformers) {
|
||||
if (transformer.supports(className, mappings)) {
|
||||
applicableTransformers.add(transformer);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(applicableTransformers);
|
||||
}
|
||||
|
||||
private void sortTransformers() {
|
||||
List<TargetedClassTransformer> sortedTransformers = new ArrayList<>(this.transformers);
|
||||
Collections.sort(sortedTransformers, TRANSFORMER_ORDER);
|
||||
this.transformers.clear();
|
||||
this.transformers.addAll(sortedTransformers);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import customskinloader.bootstrap.BootstrapLogger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class RuntimeClassTransformerEngine {
|
||||
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||
|
||||
private final ClassTransformerRegistry registry;
|
||||
|
||||
public RuntimeClassTransformerEngine(ClassTransformerRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
public ClassTransformationReport transform(ClassTransformationContext context) {
|
||||
List<String> appliedTransformers = new ArrayList<>();
|
||||
|
||||
for (TargetedClassTransformer transformer : this.registry.getApplicableTransformers(context.getInternalClassName(), context.getMappings())) {
|
||||
if (!this.applyTransformer(transformer, context)) {
|
||||
LOGGER.debug("Skipped transformer " + transformer.getName() + " for " + context.getInternalClassName());
|
||||
continue;
|
||||
}
|
||||
appliedTransformers.add(transformer.getName());
|
||||
LOGGER.debug("Applied transformer " + transformer.getName() + " to " + context.getInternalClassName());
|
||||
}
|
||||
|
||||
if (!appliedTransformers.isEmpty()) {
|
||||
LOGGER.info("Transformed " + context.getInternalClassName() + " with " + appliedTransformers);
|
||||
}
|
||||
|
||||
return new ClassTransformationReport(context, appliedTransformers);
|
||||
}
|
||||
|
||||
private boolean applyTransformer(TargetedClassTransformer transformer, ClassTransformationContext context) {
|
||||
try {
|
||||
return transformer.transform(context);
|
||||
} catch (Exception exception) {
|
||||
String message = "Failed to transform " + context.getInternalClassName() + " with " + transformer.getName();
|
||||
LOGGER.error(message, exception);
|
||||
throw new IllegalStateException(message, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class TargetedClassTransformer {
|
||||
private final String name;
|
||||
private final int priority;
|
||||
private final Set<String> targetClassNames;
|
||||
|
||||
protected TargetedClassTransformer(String name, int priority, String... targetClassNames) {
|
||||
this.name = name;
|
||||
this.priority = priority;
|
||||
this.targetClassNames = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(targetClassNames)));
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public final int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public boolean supports(String className, customskinloader.bootstrap.mapping.Mappings mappings) {
|
||||
if (this.targetClassNames.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String targetClassName : this.targetClassNames) {
|
||||
if (className.equals(mappings.remapClassName(targetClassName))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<String> getTargetClassNames() {
|
||||
return this.targetClassNames;
|
||||
}
|
||||
|
||||
public abstract boolean transform(ClassTransformationContext context) throws Exception;
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package customskinloader.bootstrap.transformer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
import customskinloader.bootstrap.BootstrapLogger;
|
||||
import customskinloader.bootstrap.mapping.Loader;
|
||||
import customskinloader.bootstrap.mapping.Mappings;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public final class TransformerBootstrapSupport {
|
||||
private static final Field[] CLASS_NODE_FIELDS = ClassNode.class.getFields();
|
||||
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final Class<?> serviceLoaderAnchor;
|
||||
private final String mappingType;
|
||||
private final ClassTransformerRegistry registry = new ClassTransformerRegistry();
|
||||
private final RuntimeClassTransformerEngine transformerEngine = new RuntimeClassTransformerEngine(this.registry);
|
||||
|
||||
private volatile boolean transformersLoaded;
|
||||
private volatile Mappings mappings;
|
||||
|
||||
public TransformerBootstrapSupport(Class<?> serviceLoaderAnchor, String mappingType) {
|
||||
if (serviceLoaderAnchor == null) {
|
||||
throw new IllegalArgumentException("Service loader anchor must not be null");
|
||||
}
|
||||
|
||||
this.serviceLoaderAnchor = serviceLoaderAnchor;
|
||||
this.mappingType = mappingType;
|
||||
}
|
||||
|
||||
public void ensureTransformersLoaded() {
|
||||
if (this.transformersLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (this.lock) {
|
||||
if (this.transformersLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Discover platform-contributed targeted transformers lazily through the shared service contract.
|
||||
ServiceLoader<TargetedClassTransformer> serviceLoader = ServiceLoader.load(TargetedClassTransformer.class, this.serviceLoaderAnchor.getClassLoader());
|
||||
int transformerCount = 0;
|
||||
for (TargetedClassTransformer transformer : serviceLoader) {
|
||||
this.registry.register(transformer);
|
||||
transformerCount++;
|
||||
LOGGER.debug("Registered transformer " + transformer.getName()
|
||||
+ " with priority " + transformer.getPriority()
|
||||
+ " and targets " + transformer.getTargetClassNames());
|
||||
}
|
||||
|
||||
this.transformersLoaded = true;
|
||||
LOGGER.info("Loaded " + transformerCount + " CustomSkinLoader bootstrap transformer(s) for " + this.mappingType + " mappings");
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> collectTargetClassNames() {
|
||||
this.ensureTransformersLoaded();
|
||||
Mappings loadedMappings = this.getMappings();
|
||||
|
||||
Set<String> targetClassNames = new LinkedHashSet<>();
|
||||
for (TargetedClassTransformer transformer : this.registry.getTransformers()) {
|
||||
for (String targetClassName : transformer.getTargetClassNames()) {
|
||||
targetClassNames.add(loadedMappings.remapClassName(targetClassName));
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("Collected " + targetClassNames.size() + " CustomSkinLoader bootstrap target class(es) for " + this.mappingType + " mappings");
|
||||
return Collections.unmodifiableSet(targetClassNames);
|
||||
}
|
||||
|
||||
public boolean hasApplicableTransformers(String internalClassName) {
|
||||
this.ensureTransformersLoaded();
|
||||
return !this.registry.getApplicableTransformers(internalClassName, this.getMappings()).isEmpty();
|
||||
}
|
||||
|
||||
public ClassTransformationReport transformClassNode(String internalClassName, ClassNode inputClassNode) {
|
||||
this.ensureTransformersLoaded();
|
||||
ClassTransformationContext context = ClassTransformationContext.create(internalClassName, inputClassNode, this.getMappings());
|
||||
return this.transformerEngine.transform(context);
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
Mappings loadedMappings = this.mappings;
|
||||
if (loadedMappings != null) {
|
||||
return loadedMappings;
|
||||
}
|
||||
|
||||
synchronized (this.lock) {
|
||||
loadedMappings = this.mappings;
|
||||
if (loadedMappings == null) {
|
||||
LOGGER.info("Loading CustomSkinLoader bootstrap mappings for " + this.mappingType);
|
||||
loadedMappings = Loader.load(this.serviceLoaderAnchor.getClassLoader(), this.mappingType);
|
||||
this.mappings = loadedMappings;
|
||||
LOGGER.info("Loaded " + loadedMappings.getClassMappings().size() + " CustomSkinLoader bootstrap class mapping(s) for " + this.mappingType);
|
||||
}
|
||||
}
|
||||
|
||||
return loadedMappings;
|
||||
}
|
||||
|
||||
public static byte[] toByteArray(ClassNode classNode) {
|
||||
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(classWriter);
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
public static ClassNode toClassNode(byte[] classBytecode) {
|
||||
ClassReader classReader = new ClassReader(classBytecode);
|
||||
ClassNode classNode = new ClassNode();
|
||||
classReader.accept(classNode, 0);
|
||||
return classNode;
|
||||
}
|
||||
|
||||
public static void copyClassNode(ClassNode source, ClassNode target) {
|
||||
try {
|
||||
for (Field field : CLASS_NODE_FIELDS) {
|
||||
if (!Modifier.isStatic(field.getModifiers())) {
|
||||
field.set(target, field.get(source));
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException exception) {
|
||||
throw new IllegalStateException("Failed to copy transformed ClassNode state", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package customskinloader.bootstrap.transformer.patch;
|
||||
|
||||
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||
|
||||
public final class InterfacePatch extends PatchSupport {
|
||||
public InterfacePatch() {
|
||||
super(
|
||||
"customskinloader:interface-patch", 1000,
|
||||
targets(
|
||||
HTTP_TEXTURE_PROCESSOR, "[,553]", // 19w37a- (1.14.4-)
|
||||
RESOURCE, "",
|
||||
RESOURCE_MANAGER, "",
|
||||
NATIVE_IMAGE, "[404,]", // 1.13.2+
|
||||
IDENTIFIER, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transform(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
|
||||
if (context.isTarget(HTTP_TEXTURE_PROCESSOR)) {
|
||||
modified |= this.requireModified("http-texture-processor.interface", this.addInterface(context.getCurrentClassNode(), FAKE_HTTP_TEXTURE_PROCESSOR));
|
||||
}
|
||||
if (context.isTarget(RESOURCE)) {
|
||||
boolean resourceModified = false;
|
||||
resourceModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V1);
|
||||
resourceModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_V2);
|
||||
modified |= this.requireModified("resource.interfaces", resourceModified);
|
||||
}
|
||||
if (context.isTarget(RESOURCE_MANAGER)) {
|
||||
boolean resourceManagerModified = false;
|
||||
resourceManagerModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V1);
|
||||
resourceManagerModified |= this.addInterface(context.getCurrentClassNode(), FAKE_I_RESOURCE_MANAGER_V2);
|
||||
modified |= this.requireModified("resource-manager.interfaces", resourceManagerModified);
|
||||
}
|
||||
if (context.isTarget(NATIVE_IMAGE)) {
|
||||
modified |= this.requireModified("native-image.interface", this.addInterface(context.getCurrentClassNode(), FAKE_NATIVE_IMAGE));
|
||||
}
|
||||
if (context.isTarget(IDENTIFIER)) {
|
||||
modified |= this.requireModified("identifier.patch", this.makeMethodPublicNonFinal(context.findMethod(IDENTIFIER, "<init>", "(" + objectDesc(STRING) + objectDesc(STRING) + ")V")));
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
package customskinloader.bootstrap.transformer.patch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import customskinloader.bootstrap.BootstrapLogger;
|
||||
import customskinloader.bootstrap.mapping.VersionMetadataReader;
|
||||
import customskinloader.bootstrap.transformer.TargetedClassTransformer;
|
||||
import customskinloader.bootstrap.util.RangeMatcher;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InnerClassNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.TypeInsnNode;
|
||||
|
||||
abstract class PatchSupport extends TargetedClassTransformer implements Opcodes {
|
||||
private static final String IGNORE_PATCH_FAILURE_PROPERTY = "customskinloader.ignorePatchFailure";
|
||||
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||
|
||||
protected static final String BOOLEAN = "java/lang/Boolean";
|
||||
protected static final String OBJECT = "java/lang/Object";
|
||||
protected static final String STRING = "java/lang/String";
|
||||
protected static final String CALL_SITE = "java/lang/invoke/CallSite";
|
||||
protected static final String LAMBDA_METAFACTORY = "java/lang/invoke/LambdaMetafactory";
|
||||
protected static final String METHOD_HANDLE = "java/lang/invoke/MethodHandle";
|
||||
protected static final String METHOD_HANDLES_LOOKUP = "java/lang/invoke/MethodHandles$Lookup";
|
||||
protected static final String METHOD_TYPE = "java/lang/invoke/MethodType";
|
||||
protected static final String FILE = "java/io/File";
|
||||
protected static final String INPUT_STREAM = "java/io/InputStream";
|
||||
protected static final String PATH = "java/nio/file/Path";
|
||||
protected static final String RUNNABLE = "java/lang/Runnable";
|
||||
protected static final String MAP = "java/util/Map";
|
||||
protected static final String UUID = "java/util/UUID";
|
||||
protected static final String COMPLETABLE_FUTURE = "java/util/concurrent/CompletableFuture";
|
||||
protected static final String EXECUTOR = "java/util/concurrent/Executor";
|
||||
protected static final String EXECUTOR_SERVICE = "java/util/concurrent/ExecutorService";
|
||||
protected static final String FUTURE = "java/util/concurrent/Future";
|
||||
protected static final String FUNCTION = "java/util/function/Function";
|
||||
protected static final String SUPPLIER = "java/util/function/Supplier";
|
||||
protected static final String FUNCTION4 = "com/mojang/datafixers/util/Function4";
|
||||
|
||||
protected static final String NATIVE_IMAGE = "com/mojang/blaze3d/platform/NativeImage";
|
||||
protected static final String POSE_STACK = "com/mojang/blaze3d/vertex/PoseStack";
|
||||
|
||||
protected static final String MINECRAFT = "net/minecraft/client/Minecraft";
|
||||
protected static final String GUI_GRAPHICS = "net/minecraft/client/gui/GuiGraphics";
|
||||
protected static final String GUI_GRAPHICS_EXTRACTOR = "net/minecraft/client/gui/GuiGraphicsExtractor";
|
||||
protected static final String PLAYER_TAB_OVERLAY = "net/minecraft/client/gui/components/PlayerTabOverlay";
|
||||
protected static final String CLIENT_PACKET_LISTENER = "net/minecraft/client/multiplayer/ClientPacketListener";
|
||||
protected static final String HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/FakeHttpTextureProcessor"; // net/minecraft/client/renderer/HttpTextureProcessor
|
||||
protected static final String MULTI_BUFFER_SOURCE = "net/minecraft/client/renderer/MultiBufferSource";
|
||||
protected static final String SUBMIT_NODE_COLLECTOR = "net/minecraft/client/renderer/SubmitNodeCollector";
|
||||
protected static final String MODEL_PART = "net/minecraft/client/model/geom/ModelPart";
|
||||
protected static final String ABSTRACT_CLIENT_PLAYER = "net/minecraft/client/player/AbstractClientPlayer";
|
||||
protected static final String CAPE_LAYER = "net/minecraft/client/renderer/entity/layers/CapeLayer";
|
||||
protected static final String AVATAR_RENDER_STATE = "net/minecraft/client/renderer/entity/state/AvatarRenderState";
|
||||
protected static final String PLAYER_RENDER_STATE = "net/minecraft/client/renderer/entity/state/PlayerRenderState";
|
||||
protected static final String PLAYER_RENDERER = "net/minecraft/client/renderer/entity/player/PlayerRenderer";
|
||||
protected static final String RENDER_TYPE = "net/minecraft/client/renderer/rendertype/RenderType";
|
||||
protected static final String RENDER_TYPES = "net/minecraft/client/renderer/rendertype/RenderTypes";
|
||||
protected static final String SKIN_MANAGER = "net/minecraft/client/resources/SkinManager";
|
||||
protected static final String SKIN_MANAGER_1 = "net/minecraft/client/resources/SkinManager$1";
|
||||
protected static final String SKIN_MANAGER_3 = "net/minecraft/client/resources/SkinManager$3";
|
||||
protected static final String SKIN_MANAGER_CACHE_KEY = "net/minecraft/client/resources/SkinManager$CacheKey";
|
||||
protected static final String SKIN_MANAGER_SKIN_TEXTURE_CALLBACK = "net/minecraft/client/resources/SkinManager$SkinTextureCallback";
|
||||
protected static final String SKIN_MANAGER_TEXTURE_CACHE = "net/minecraft/client/resources/SkinManager$TextureCache";
|
||||
protected static final String SKIN_MANAGER_TEXTURE_INFO = "net/minecraft/client/resources/SkinManager$TextureInfo";
|
||||
protected static final String SKIN_TEXTURE_DOWNLOADER = "net/minecraft/client/renderer/texture/SkinTextureDownloader";
|
||||
protected static final String TEXTURE_MANAGER = "net/minecraft/client/renderer/texture/TextureManager";
|
||||
protected static final String HTTP_TEXTURE = "net/minecraft/client/renderer/texture/HttpTexture";
|
||||
protected static final String CLIENT_ASSET_DOWNLOADED_TEXTURE = "net/minecraft/core/ClientAsset$DownloadedTexture";
|
||||
protected static final String IDENTIFIER = "net/minecraft/resources/Identifier";
|
||||
protected static final String SERVICES = "net/minecraft/server/Services";
|
||||
protected static final String RESOURCE = "net/minecraft/server/packs/resources/Resource";
|
||||
protected static final String RESOURCE_MANAGER = "net/minecraft/server/packs/resources/ResourceManager";
|
||||
protected static final String OBJECTIVE = "net/minecraft/world/scores/Objective";
|
||||
protected static final String SCOREBOARD = "net/minecraft/world/scores/Scoreboard";
|
||||
|
||||
protected static final String FAKE_HTTP_TEXTURE_PROCESSOR = "customskinloader/fake/itf/IFakeHttpTextureProcessor";
|
||||
protected static final String FAKE_I_RESOURCE_V1 = "customskinloader/fake/itf/IFakeIResource$V1";
|
||||
protected static final String FAKE_I_RESOURCE_V2 = "customskinloader/fake/itf/IFakeIResource$V2";
|
||||
protected static final String FAKE_I_RESOURCE_MANAGER_V1 = "customskinloader/fake/itf/IFakeIResourceManager$V1";
|
||||
protected static final String FAKE_I_RESOURCE_MANAGER_V2 = "customskinloader/fake/itf/IFakeIResourceManager$V2";
|
||||
protected static final String FAKE_NATIVE_IMAGE = "customskinloader/fake/itf/IFakeNativeImage";
|
||||
|
||||
protected static final String FAKE_SKIN_BUFFER = "customskinloader/fake/FakeSkinBuffer";
|
||||
protected static final String FAKE_SKIN_MANAGER = "customskinloader/fake/FakeSkinManager";
|
||||
protected static final String FAKE_CACHE_KEY = "customskinloader/fake/FakeSkinManager$FakeCacheKey";
|
||||
protected static final String FAKE_HTTP_TEXTURE_V1 = "customskinloader/fake/texture/FakeHttpTexture$V1";
|
||||
protected static final String FAKE_HTTP_TEXTURE_V2 = "customskinloader/fake/texture/FakeHttpTexture$V2";
|
||||
|
||||
protected static final String MINECRAFT_PROFILE_TEXTURE = "com/mojang/authlib/minecraft/MinecraftProfileTexture";
|
||||
protected static final String MINECRAFT_PROFILE_TEXTURE_TYPE = "com/mojang/authlib/minecraft/MinecraftProfileTexture$Type";
|
||||
protected static final String MINECRAFT_SESSION_SERVICE = "com/mojang/authlib/minecraft/MinecraftSessionService";
|
||||
protected static final String MINECRAFT_PROFILE_TEXTURES = "com/mojang/authlib/minecraft/MinecraftProfileTextures";
|
||||
protected static final String GAME_PROFILE = "com/mojang/authlib/GameProfile";
|
||||
protected static final String PROPERTY = "com/mojang/authlib/properties/Property";
|
||||
|
||||
protected static String objectDesc(String internalName) {
|
||||
return "L" + internalName + ";";
|
||||
}
|
||||
|
||||
private final int protocolVersion;
|
||||
private final int worldVersion;
|
||||
|
||||
protected PatchSupport(String name, int priority, Map<String, String> targetClassNames) {
|
||||
this(name, priority, VersionMetadataReader.PROTOCOL_VERSION, VersionMetadataReader.WORLD_VERSION, targetClassNames);
|
||||
}
|
||||
|
||||
private PatchSupport(String name, int priority, int protocolVersion, int worldVersion, Map<String, String> targetClassNames) {
|
||||
super(name, priority, filterTargetClassNames(targetClassNames, protocolVersion, worldVersion));
|
||||
this.protocolVersion = protocolVersion;
|
||||
this.worldVersion = worldVersion;
|
||||
}
|
||||
|
||||
protected static Map<String, String> targets(String... targetClassNameProtocolRanges) {
|
||||
if (targetClassNameProtocolRanges.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("Target class names must be paired with protocol ranges");
|
||||
}
|
||||
|
||||
Map<String, String> targets = new LinkedHashMap<>();
|
||||
for (int index = 0; index < targetClassNameProtocolRanges.length; index += 2) {
|
||||
targets.put(targetClassNameProtocolRanges[index], targetClassNameProtocolRanges[index + 1]);
|
||||
}
|
||||
return Collections.unmodifiableMap(targets);
|
||||
}
|
||||
|
||||
private static String[] filterTargetClassNames(Map<String, String> targetClassNames, int protocolVersion, int worldVersion) {
|
||||
List<String> filteredTargetClassNames = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : targetClassNames.entrySet()) {
|
||||
if (RangeMatcher.matches(entry.getValue(), protocolVersion, worldVersion)) {
|
||||
filteredTargetClassNames.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return filteredTargetClassNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
protected boolean addInterface(ClassNode classNode, String interfaceName) {
|
||||
if (!classNode.interfaces.contains(interfaceName)) {
|
||||
classNode.interfaces.add(interfaceName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean makeClassPublicNonFinal(ClassNode classNode) {
|
||||
boolean modified = false;
|
||||
int access = makePublicNonFinal(classNode.access);
|
||||
if (classNode.access != access) {
|
||||
classNode.access = access;
|
||||
modified = true;
|
||||
}
|
||||
modified |= this.makeInnerClassPublicNonFinal(classNode, classNode.name);
|
||||
return modified;
|
||||
}
|
||||
|
||||
protected boolean makeInnerClassPublicNonFinal(ClassNode classNode, String innerName) {
|
||||
boolean modified = false;
|
||||
for (InnerClassNode innerClassNode : classNode.innerClasses) {
|
||||
if (!innerName.equals(innerClassNode.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
innerClassNode.access = makePublicNonFinal(innerClassNode.access);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
protected boolean makeMethodPublicNonFinal(MethodNode methodNode) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
methodNode.access = makePublicNonFinal(methodNode.access);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean makeFieldPublicNonFinal(FieldNode fieldNode) {
|
||||
if (fieldNode == null) {
|
||||
return false;
|
||||
}
|
||||
fieldNode.access = makePublicNonFinal(fieldNode.access);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int makePublicNonFinal(int access) {
|
||||
return (access & ~(ACC_PRIVATE | ACC_PROTECTED | ACC_FINAL)) | ACC_PUBLIC;
|
||||
}
|
||||
|
||||
protected boolean matches(String range) {
|
||||
return RangeMatcher.matches(range, this.protocolVersion, this.worldVersion);
|
||||
}
|
||||
|
||||
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation) {
|
||||
return applyIfMatches(range, label, operation, true);
|
||||
}
|
||||
|
||||
protected boolean applyIfMatches(String range, String label, BooleanSupplier operation, boolean required) {
|
||||
if (!this.matches(range)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.requireModified(label, operation.getAsBoolean(), required);
|
||||
}
|
||||
|
||||
protected boolean requireModified(String label, boolean modified) {
|
||||
return this.requireModified(label, modified, true);
|
||||
}
|
||||
|
||||
protected boolean requireModified(String label, boolean modified, boolean required) {
|
||||
if (modified) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = "Patch '" + this.getName() + ":" + label + "' matched protocol " + this.protocolVersion
|
||||
+ " but did not modify any bytecode. If you want to force CustomSkinLoader to ignore this patch failure, add -D"
|
||||
+ IGNORE_PATCH_FAILURE_PROPERTY + "=true to the JVM arguments.";
|
||||
if ("false".equalsIgnoreCase(System.getProperty(IGNORE_PATCH_FAILURE_PROPERTY))) {
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
|
||||
if (!required || Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
|
||||
LOGGER.warn(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
|
||||
protected InsnList clone(InsnList source) {
|
||||
InsnList copy = new InsnList();
|
||||
for (AbstractInsnNode abstractInsnNode : source) {
|
||||
copy.add(abstractInsnNode.clone(null));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected AbstractInsnNode findPreviousTypeInstruction(AbstractInsnNode instruction, int opcode, String type) {
|
||||
AbstractInsnNode current = instruction == null ? null : instruction.getPrevious();
|
||||
while (current != null) {
|
||||
if (current.getOpcode() == opcode && current instanceof TypeInsnNode && type.equals(((TypeInsnNode) current).desc)) {
|
||||
return current;
|
||||
}
|
||||
current = current.getPrevious();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected AbstractInsnNode nextRealInstruction(AbstractInsnNode instruction) {
|
||||
AbstractInsnNode current = instruction == null ? null : instruction.getNext();
|
||||
while (current != null && current.getOpcode() < 0) {
|
||||
current = current.getNext();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
protected static void methodNodeSet(MethodNode methodNode, AbstractInsnNode oldInstruction, AbstractInsnNode newInstruction) {
|
||||
methodNode.instructions.set(oldInstruction, newInstruction);
|
||||
}
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
package customskinloader.bootstrap.transformer.patch;
|
||||
|
||||
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public final class RenderPatch extends PatchSupport {
|
||||
public RenderPatch() {
|
||||
super(
|
||||
"customskinloader:render-patch", 1000,
|
||||
targets(
|
||||
PLAYER_TAB_OVERLAY, "",
|
||||
CAPE_LAYER, "[556,]", // 19w39a+ (1.15+)
|
||||
PLAYER_RENDERER, "[556,767],[801,803],[0x40000001,0x400000CC]" // 19w39a ~ 1.21.1 (1.15 ~ 1.21.1)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transform(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
|
||||
if (context.isTarget(PLAYER_TAB_OVERLAY)) {
|
||||
modified |= this.requireModified("player-tab-overlay", this.patchPlayerTabOverlay(context));
|
||||
}
|
||||
if (context.isTarget(CAPE_LAYER)) {
|
||||
modified |= this.requireModified("cape-layer", this.patchCapeLayer(context), false);
|
||||
}
|
||||
if (context.isTarget(PLAYER_RENDERER)) {
|
||||
modified |= this.requireModified("player-renderer", this.patchPlayerRenderer(context), false);
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchPlayerTabOverlay(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 20w16a- (1.15.2-)
|
||||
modified |= this.applyIfMatches("[,712]", "player-tab-overlay.render.v1", () -> replaceMinecraftLocalServerCheck(
|
||||
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
|
||||
));
|
||||
// 20w17a ~ 23w14a (1.16 ~ 1.19.4)
|
||||
modified |= this.applyIfMatches("[713,762],[801,803],[0x40000001,0x40000082]", "player-tab-overlay.render.v2", () -> replaceMinecraftLocalServerCheck(
|
||||
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(POSE_STACK) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
|
||||
));
|
||||
// 23w16a ~ 26.1-snapshot-11 (1.20 ~ 1.21.11)
|
||||
modified |= this.applyIfMatches("[763,774],[0x40000083,0x40000129]", "player-tab-overlay.render.v3", () -> replaceMinecraftLocalServerCheck(
|
||||
context, context.findMethod(PLAYER_TAB_OVERLAY, "render", "(" + objectDesc(GUI_GRAPHICS) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
|
||||
));
|
||||
// 26.1-pre-1 ~ 26.2-snapshot-6 (26.1 ~ 26.1.2)
|
||||
modified |= this.applyIfMatches("775,[0x4000012A,0x40000138]", "player-tab-overlay.extract-render-state.v1", () -> replaceMinecraftLocalServerCheck(
|
||||
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), MINECRAFT, "isLocalServer"
|
||||
));
|
||||
// 26.2-snapshot-7+ (26.2+)
|
||||
modified |= this.applyIfMatches("[776,800],[804,0x40000000],[0x40000139,]", "player-tab-overlay.extract-render-state.v2", () -> replaceMinecraftLocalServerCheck(
|
||||
context, context.findMethod(PLAYER_TAB_OVERLAY, "extractRenderState", "(" + objectDesc(GUI_GRAPHICS_EXTRACTOR) + "I" + objectDesc(SCOREBOARD) + objectDesc(OBJECTIVE) + ")V"), CLIENT_PACKET_LISTENER, "onlineMode"
|
||||
));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceMinecraftLocalServerCheck(ClassTransformationContext context, MethodNode methodNode, String owner, String name) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String remappedOwner = context.remapClassName(owner);
|
||||
String remappedName = context.remapMethodName(owner, name, "()Z");
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!remappedOwner.equals(methodInsnNode.owner) || !remappedName.equals(methodInsnNode.name) || !"()Z".equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList replacement = new InsnList();
|
||||
replacement.add(new InsnNode(POP));
|
||||
replacement.add(new InsnNode(ICONST_1));
|
||||
methodNode.instructions.insertBefore(instruction, replacement);
|
||||
methodNode.instructions.remove(instruction);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
private boolean patchCapeLayer(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 19w39a ~ 19w44a
|
||||
modified |= this.applyIfMatches("[556,560]", "cape-layer.render.v1", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFFF)V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
|
||||
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "cape-layer.render.v2", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + "FFFFFF)V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
// 24w33a ~ 1.21.8 (1.21.2 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[768,772],[0x400000CD,0x40000103]", "cape-layer.render.v3", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(CAPE_LAYER, "render", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(PLAYER_RENDER_STATE) + "FF)V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
// 25w31a ~ 25w42a (1.21.9 ~ 1.21.10)
|
||||
modified |= this.applyIfMatches("773,[0x40000104,0x40000112]", "cape-layer.submit.v1", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
// 25w43a+ (1.21.11+)
|
||||
modified |= this.applyIfMatches("[774,800],[804,0x40000000],[0x40000113,]", "cape-layer.submit.v2", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(CAPE_LAYER, "submit", "(" + objectDesc(POSE_STACK) + objectDesc(SUBMIT_NODE_COLLECTOR) + "I" + objectDesc(AVATAR_RENDER_STATE) + "FF)V"),
|
||||
RENDER_TYPES
|
||||
), false);
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchPlayerRenderer(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 19w39a ~ 19w44a
|
||||
modified |= this.applyIfMatches("[556,560]", "player-renderer.render-hand.v1", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
// 19w45a ~ 1.21.1 (1.15 ~ 1.21.1)
|
||||
modified |= this.applyIfMatches("[561,767],[801,803],[0x40000001,0x400000CC]", "player-renderer.render-hand.v2", () -> replaceEntitySolidWithTranslucent(
|
||||
context, context.findMethod(PLAYER_RENDERER, "renderHand", "(" + objectDesc(POSE_STACK) + objectDesc(MULTI_BUFFER_SOURCE) + "I" + objectDesc(ABSTRACT_CLIENT_PLAYER) + objectDesc(MODEL_PART) + objectDesc(MODEL_PART) + ")V"),
|
||||
RENDER_TYPE
|
||||
), false);
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceEntitySolidWithTranslucent(ClassTransformationContext context, MethodNode methodNode, String owner) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String remappedOwner = context.remapClassName(owner);
|
||||
String desc = "(" + objectDesc(IDENTIFIER) + ")" + objectDesc(RENDER_TYPE);
|
||||
String remappedDesc = context.remapMethodDescriptor(desc);
|
||||
String originalName = context.remapMethodName(owner, "entitySolid", desc);
|
||||
String replacementName = context.remapMethodName(owner, "entityTranslucent", desc);
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!remappedOwner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !remappedDesc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methodNode.instructions.insertBefore(instruction, new InsnNode(DUP));
|
||||
methodNode.instructions.insert(instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
|
||||
methodNode.instructions.insert(instruction, new InsnNode(POP));
|
||||
modified = true;
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
+523
@@ -0,0 +1,523 @@
|
||||
package customskinloader.bootstrap.transformer.patch;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||
import org.objectweb.asm.Handle;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.TypeInsnNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public final class SkinManagerPatch extends PatchSupport {
|
||||
public SkinManagerPatch() {
|
||||
super(
|
||||
"customskinloader:skin-manager-patch", 1000,
|
||||
targets(
|
||||
SKIN_MANAGER, "",
|
||||
SKIN_MANAGER_1, "[764,800],[804,0x40000000],[0x40000090,]", // 23w31a+ (1.20.2+)
|
||||
SKIN_MANAGER_3, "[,340]", // 1.12.2-
|
||||
SKIN_MANAGER_CACHE_KEY, "[764,800],[804,0x40000000],[0x40000090,]", // 23w31a+ (1.20.2+)
|
||||
SKIN_MANAGER_TEXTURE_CACHE, "[764,800],[804,0x40000000],[0x40000090,]" // 23w31a+ (1.20.2+)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transform(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
|
||||
if (context.isTarget(SKIN_MANAGER)) {
|
||||
// 23w31a+ (1.20.2+)
|
||||
modified |= this.applyIfMatches("[764,800],[804,0x40000000],[0x40000090,]", "skin-manager.cache-key-inner-class", () -> makeInnerClassPublicNonFinal(context.getCurrentClassNode(), context.remapClassName(SKIN_MANAGER_CACHE_KEY)));
|
||||
modified |= this.requireModified("skin-manager", this.patchSkinManager(context));
|
||||
}
|
||||
if (context.isTarget(SKIN_MANAGER_1)) {
|
||||
modified |= this.requireModified("skin-manager-1", this.patchSkinManagerLoader(context));
|
||||
}
|
||||
if (context.isTarget(SKIN_MANAGER_3)) {
|
||||
MethodNode getUserProfile = context.findMethod(SKIN_MANAGER_3, "run", "()V");
|
||||
modified |= this.requireModified("skin-manager-3", getUserProfile != null && this.replaceGetTexturesWithFakeUserProfile(getUserProfile));
|
||||
}
|
||||
if (context.isTarget(SKIN_MANAGER_CACHE_KEY)) {
|
||||
modified |= this.requireModified("skin-manager-cache-key", this.patchSkinManagerCacheKeyClass(context));
|
||||
}
|
||||
if (context.isTarget(SKIN_MANAGER_TEXTURE_CACHE)) {
|
||||
modified |= this.requireModified("skin-manager-texture-cache", this.patchSkinManagerTextureCache(context));
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchSkinManager(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
modified |= this.injectSkinManagerConstructors(context);
|
||||
// 1.20.1-
|
||||
modified |= this.applyIfMatches("[,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.v1", () -> patchLegacySkinManager(context));
|
||||
// 23w42a+ (1.20.3+)
|
||||
modified |= this.applyIfMatches("[765,800],[804,0x40000000],[0x4000009D,]", "skin-manager.v2", () -> patchSkinManagerCacheKey(context));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchSkinManagerCacheKeyClass(ClassTransformationContext context) {
|
||||
boolean modified = this.makeClassPublicNonFinal(context.getCurrentClassNode());
|
||||
modified |= this.makeMethodPublicNonFinal(context.findMethod(SKIN_MANAGER_CACHE_KEY, "<init>", "(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V"));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean injectSkinManagerConstructors(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 1.20.1-
|
||||
modified |= this.applyIfMatches("[,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.<init>.v1", () -> injectSetSkinCacheDir(
|
||||
context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(FILE) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")V", 2, objectDesc(FILE)
|
||||
));
|
||||
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
|
||||
modified |= this.applyIfMatches("[764,768],[0x40000090,0x400000DD]", "skin-manager.<init>.v2", () -> injectSetSkinCacheDir(
|
||||
context, "(" + objectDesc(TEXTURE_MANAGER) + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 2, objectDesc(PATH)
|
||||
));
|
||||
// 24w46a ~ 25w33a (1.21.4 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x40000106]", "skin-manager.<init>.v3", () -> injectSetSkinCacheDir(
|
||||
context, "(" + objectDesc(PATH) + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
|
||||
));
|
||||
// 25w34a ~ 25w34b
|
||||
modified |= this.applyIfMatches("[0x40000107,0x40000108]", "skin-manager.<init>.v4", () -> injectSetSkinCacheDir(
|
||||
context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
|
||||
));
|
||||
// 25w35a+ (1.21.9+)
|
||||
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000109,]", "skin-manager.<init>.v5", () -> injectSetSkinCacheDir(
|
||||
context, "(" + objectDesc(PATH) + objectDesc(SERVICES) + objectDesc(SKIN_TEXTURE_DOWNLOADER) + objectDesc(EXECUTOR) + ")V", 1, objectDesc(PATH)
|
||||
));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean injectSetSkinCacheDir(ClassTransformationContext context, String constructorDesc, int localIndex, String argumentDesc) {
|
||||
MethodNode methodNode = context.findMethod(SKIN_MANAGER, "<init>", constructorDesc);
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String remappedArgumentDesc = context.remapMethodDescriptor("(" + argumentDesc + ")V");
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (instruction.getOpcode() != RETURN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList injection = new InsnList();
|
||||
injection.add(new VarInsnNode(ALOAD, localIndex));
|
||||
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "setSkinCacheDir", remappedArgumentDesc, false));
|
||||
methodNode.instructions.insertBefore(instruction, injection);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchLegacySkinManager(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
modified |= this.requireModified("skin-manager.v1.register-texture", this.patchLegacySkinManagerRegisterTexture(context));
|
||||
modified |= this.requireModified("skin-manager.v1.register-skins", this.patchLegacySkinManagerRegisterSkins(context));
|
||||
modified |= this.requireModified("skin-manager.v1.get-insecure-skin-information", this.patchLegacySkinManagerGetInsecureSkinInformation(context));
|
||||
// 1.13.2 ~ 1.20.1
|
||||
modified |= this.applyIfMatches("[404,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.v1.lambda-register-skins-4", () -> patchLegacySkinManagerGetUserProfile(context));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchLegacySkinManagerRegisterTexture(ClassTransformationContext context) {
|
||||
MethodNode registerTexture = context.findMethod(SKIN_MANAGER, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")" + objectDesc(IDENTIFIER));
|
||||
if (registerTexture == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
InsnList insnList = new InsnList();
|
||||
insnList.add(new VarInsnNode(ALOAD, 2));
|
||||
return this.patchCreateThreadDownloadImageData(context, registerTexture, insnList);
|
||||
}
|
||||
|
||||
private boolean patchLegacySkinManagerRegisterSkins(ClassTransformationContext context) {
|
||||
MethodNode registerSkins = context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V");
|
||||
if (registerSkins == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
// 19w37a- (1.14.4-)
|
||||
modified |= this.applyIfMatches("[,553]", "skin-manager.register-skins.v1", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR_SERVICE, "submit", "(" + objectDesc(RUNNABLE) + ")" + objectDesc(FUTURE), true));
|
||||
// 19w38a ~ 1.18-exp7 (1.15 ~ 1.17.1)
|
||||
modified |= this.applyIfMatches("[554,756],[801,803],[0x40000001,0x4000002F]+[2205,2831]", "skin-manager.register-skins.v2", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR, "execute", "(" + objectDesc(RUNNABLE) + ")V", false));
|
||||
// 21w37a ~ 1.20.1 (1.18 ~ 1.20.1)
|
||||
modified |= this.applyIfMatches("[757,763],[0x40000029,0x4000008E]+[2834,3465]", "skin-manager.register-skins.v3", () -> replaceExecutorProfileLoadAtInvocation(registerSkins, EXECUTOR_SERVICE, "execute", "(" + objectDesc(RUNNABLE) + ")V", false));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchLegacySkinManagerGetInsecureSkinInformation(ClassTransformationContext context) {
|
||||
MethodNode loadSkinFromCache = context.findMethod(SKIN_MANAGER, "getInsecureSkinInformation", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP));
|
||||
if (loadSkinFromCache == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.replaceLoadSkinFromCacheMethod(loadSkinFromCache);
|
||||
}
|
||||
|
||||
private boolean patchLegacySkinManagerGetUserProfile(ClassTransformationContext context) {
|
||||
MethodNode getUserProfile = context.findMethod(SKIN_MANAGER, "lambda$registerSkins$4", "(" + objectDesc(GAME_PROFILE) + "Z" + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")V");
|
||||
if (getUserProfile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.replaceGetTexturesWithFakeUserProfile(getUserProfile);
|
||||
}
|
||||
|
||||
private boolean patchSkinManagerCacheKey(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[765,772],[0x4000009D,0x40000106]", "skin-manager.cache-key.v1", () -> {
|
||||
MethodNode getOrLoad = context.findMethod(SKIN_MANAGER, "getOrLoad", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
return getOrLoad != null && redirectCacheKeyConstruction(context, getOrLoad);
|
||||
});
|
||||
// 25w34a+ (1.21.9+)
|
||||
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000107,]", "skin-manager.cache-key.v2", () -> {
|
||||
MethodNode get = context.findMethod(SKIN_MANAGER, "get", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
return get != null && redirectCacheKeyConstruction(context, get);
|
||||
});
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchSkinManagerLoader(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
MethodNode load = context.findMethod(SKIN_MANAGER_1, "load", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
modified |= this.requireModified("skin-manager-1.executor", load != null && this.replaceCompletableFutureExecutor(load));
|
||||
|
||||
modified |= this.patchSkinManagerLoaderLambda(context);
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchSkinManagerLoaderLambda(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 23w31a ~ 23w41a (1.20.2)
|
||||
modified |= this.applyIfMatches("764,[0x40000090,0x4000009C]", "skin-manager-1.lambda-load-0.v1", () -> {
|
||||
MethodNode oldLambda = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_TEXTURE_INFO));
|
||||
return oldLambda != null && replaceGetTexturesWithFakeSkinCache(oldLambda);
|
||||
});
|
||||
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[765,772],[0x4000009D,0x40000106]", "skin-manager-1.lambda-load-0.v2", () -> {
|
||||
MethodNode lambdaWithSession = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(MINECRAFT_SESSION_SERVICE) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES));
|
||||
return lambdaWithSession != null && replaceUnpackTexturesWithFakeSkinCache(context, lambdaWithSession);
|
||||
});
|
||||
// 25w34a+ (1.21.9+)
|
||||
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000107,]", "skin-manager-1.lambda-load-0.v3", () -> {
|
||||
MethodNode lambdaWithServices = context.findMethod(SKIN_MANAGER_1, "lambda$load$0", "(" + objectDesc(SKIN_MANAGER_CACHE_KEY) + objectDesc(SERVICES) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES));
|
||||
return lambdaWithServices != null && replaceUnpackTexturesWithFakeSkinCache(context, lambdaWithServices);
|
||||
});
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchSkinManagerTextureCache(ClassTransformationContext context) {
|
||||
MethodNode registerTexture = context.findMethod(SKIN_MANAGER_TEXTURE_CACHE, "registerTexture", "(" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
if (registerTexture == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String fieldName = context.remapFieldName(SKIN_MANAGER_TEXTURE_CACHE, "type");
|
||||
InsnList loadType = new InsnList();
|
||||
loadType.add(new VarInsnNode(ALOAD, 0));
|
||||
loadType.add(new FieldInsnNode(GETFIELD, context.remapClassName(SKIN_MANAGER_TEXTURE_CACHE), fieldName, objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE)));
|
||||
|
||||
boolean modified = false;
|
||||
// 23w31a ~ 24w45a (1.20.2 ~ 1.21.3)
|
||||
modified |= this.applyIfMatches("[764,768],[0x40000090,0x400000DD]", "skin-manager-texture-cache.http-texture", () -> redirectHttpTextureConstructorToFake(
|
||||
context, registerTexture, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
|
||||
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||
loadType
|
||||
));
|
||||
// 24w46a ~ 25w34b (1.21.4 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x40000108]", "skin-manager-texture-cache.skin-texture-downloader.v1", () -> redirectSkinTextureDownloaderToFake(
|
||||
context, registerTexture, INVOKESTATIC
|
||||
));
|
||||
// 25w35a+ (1.21.9+)
|
||||
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x40000109,]", "skin-manager-texture-cache.skin-texture-downloader.v2", () -> redirectSkinTextureDownloaderToFake(
|
||||
context, registerTexture, INVOKEVIRTUAL
|
||||
));
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
private boolean patchCreateThreadDownloadImageData(ClassTransformationContext context, MethodNode methodNode, InsnList loadTextureType) {
|
||||
boolean modified = false;
|
||||
// 19w37a- (1.14.4-)
|
||||
modified |= this.applyIfMatches("[,553]", "skin-manager.http-texture.v1", () -> redirectHttpTextureConstructorToFake(
|
||||
context, methodNode, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + ")V"),
|
||||
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + objectDesc(HTTP_TEXTURE_PROCESSOR) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||
loadTextureType
|
||||
));
|
||||
// 19w38a ~ 1.20.1 (1.15 ~ 1.20.1)
|
||||
modified |= this.applyIfMatches("[554,763],[801,803],[0x40000001,0x4000008E]", "skin-manager.http-texture.v2", () -> redirectHttpTextureConstructorToFake(
|
||||
context, methodNode, context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + ")V"),
|
||||
context.remapMethodDescriptor("(" + objectDesc(FILE) + objectDesc(STRING) + objectDesc(IDENTIFIER) + "Z" + objectDesc(RUNNABLE) + objectDesc(MINECRAFT_PROFILE_TEXTURE) + objectDesc(MINECRAFT_PROFILE_TEXTURE_TYPE) + ")V"),
|
||||
loadTextureType
|
||||
));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean redirectHttpTextureConstructorToFake(ClassTransformationContext context, MethodNode methodNode, String originalDesc, String replacementDesc, InsnList loadTextureType) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String originalOwner = context.remapClassName(HTTP_TEXTURE);
|
||||
String replacementOwner = context.remapClassName(FAKE_HTTP_TEXTURE_V1);
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (methodInsnNode.getOpcode() != INVOKESPECIAL || !originalOwner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !originalDesc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, originalOwner);
|
||||
if (!(newNode instanceof TypeInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
((TypeInsnNode) newNode).desc = replacementOwner;
|
||||
InsnList injection = new InsnList();
|
||||
injection.add(new VarInsnNode(ALOAD, 1));
|
||||
injection.add(this.clone(loadTextureType));
|
||||
methodNode.instructions.insertBefore(methodInsnNode, injection);
|
||||
methodInsnNode.owner = replacementOwner;
|
||||
methodInsnNode.desc = replacementDesc;
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean redirectSkinTextureDownloaderToFake(ClassTransformationContext context, MethodNode methodNode, int opcode) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
|
||||
String desc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
|
||||
String name = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin", "(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE));
|
||||
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION4) + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z" + objectDesc(MINECRAFT_PROFILE_TEXTURE) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
String functionDesc = context.remapMethodDescriptor("(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + objectDesc(BOOLEAN) + ")" + objectDesc(COMPLETABLE_FUTURE));
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (methodInsnNode.getOpcode() != opcode || !owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList injection = new InsnList();
|
||||
if (opcode == INVOKESTATIC) {
|
||||
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, "", functionDesc, insnNode -> insnNode.getOpcode() == ASTORE, H_INVOKESTATIC)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
String skinManagerOwner = context.remapClassName(SKIN_MANAGER);
|
||||
String fieldName = context.remapFieldName(SKIN_MANAGER, "skinTextureDownloader");
|
||||
if (!replaceSkinTextureDownloaderReceiver(methodNode, methodInsnNode, owner, name, desc, objectDesc(owner), functionDesc, insnNode -> {
|
||||
if (insnNode.getOpcode() == GETFIELD) {
|
||||
FieldInsnNode fieldInsnNode = (FieldInsnNode) insnNode;
|
||||
return skinManagerOwner.equals(fieldInsnNode.owner) && fieldName.equals(fieldInsnNode.name) && objectDesc(owner).equals(fieldInsnNode.desc);
|
||||
}
|
||||
return false;
|
||||
}, H_INVOKEVIRTUAL)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
injection.add(new VarInsnNode(ALOAD, 1));
|
||||
methodNode.instructions.insertBefore(methodInsnNode, injection);
|
||||
methodNodeSet(methodNode, methodInsnNode, new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "downloadAndRegisterSkin", replacementDesc, false));
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceSkinTextureDownloaderReceiver(MethodNode methodNode, MethodInsnNode invoke, String owner, String name, String desc, String ownerDesc, String functionDesc, Predicate<AbstractInsnNode> predicate, int handleTag) {
|
||||
AbstractInsnNode current = invoke.getPrevious();
|
||||
while (current != null) {
|
||||
if (predicate.test(current)) {
|
||||
methodNode.instructions.insert(current, new InvokeDynamicInsnNode(
|
||||
"apply", "(" + ownerDesc + ")" + objectDesc(FUNCTION4),
|
||||
new Handle(H_INVOKESTATIC, LAMBDA_METAFACTORY, "metafactory", "(" + objectDesc(METHOD_HANDLES_LOOKUP) + objectDesc(STRING) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_HANDLE) + objectDesc(METHOD_TYPE) + ")" + objectDesc(CALL_SITE), false),
|
||||
Type.getType("(" + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + objectDesc(OBJECT) + ")" + objectDesc(OBJECT)),
|
||||
new Handle(handleTag, owner, name, desc, false),
|
||||
Type.getType(functionDesc)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
current = current.getPrevious();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean replaceExecutorProfileLoadAtInvocation(MethodNode methodNode, String owner, String name, String desc, boolean pushNullReturn) {
|
||||
boolean modified = false;
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!owner.equals(methodInsnNode.owner) || !name.equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList replacement = new InsnList();
|
||||
replacement.add(new InsnNode(SWAP));
|
||||
replacement.add(new InsnNode(POP));
|
||||
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(RUNNABLE) + ")V", false));
|
||||
if (pushNullReturn) {
|
||||
replacement.add(new InsnNode(ACONST_NULL));
|
||||
}
|
||||
methodNode.instructions.insertBefore(instruction, replacement);
|
||||
methodNode.instructions.remove(instruction);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceLoadSkinFromCacheMethod(MethodNode methodNode) {
|
||||
methodNode.instructions.clear();
|
||||
methodNode.tryCatchBlocks.clear();
|
||||
methodNode.instructions.add(new VarInsnNode(ALOAD, 1));
|
||||
methodNode.instructions.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP), false));
|
||||
methodNode.instructions.add(new InsnNode(ARETURN));
|
||||
methodNode.maxLocals = Math.max(methodNode.maxLocals, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean replaceGetTexturesWithFakeUserProfile(MethodNode methodNode) {
|
||||
boolean modified = false;
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"getTextures".equals(methodInsnNode.name) || !("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "getUserProfile", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean redirectCacheKeyConstruction(ClassTransformationContext context, MethodNode methodNode) {
|
||||
boolean modified = false;
|
||||
String owner = context.remapClassName(SKIN_MANAGER_CACHE_KEY);
|
||||
String desc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + ")V");
|
||||
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(UUID) + objectDesc(PROPERTY) + objectDesc(GAME_PROFILE) + ")" + objectDesc(SKIN_MANAGER_CACHE_KEY));
|
||||
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!owner.equals(methodInsnNode.owner) || !"<init>".equals(methodInsnNode.name) || !desc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, owner);
|
||||
AbstractInsnNode dupNode = this.nextRealInstruction(newNode);
|
||||
if (newNode == null || dupNode == null || dupNode.getOpcode() != DUP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methodNode.instructions.remove(newNode);
|
||||
methodNode.instructions.remove(dupNode);
|
||||
|
||||
InsnList replacement = new InsnList();
|
||||
replacement.add(new VarInsnNode(ALOAD, 1));
|
||||
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_CACHE_KEY, "createFakeCacheKey", replacementDesc, false));
|
||||
methodNode.instructions.insertBefore(methodInsnNode, replacement);
|
||||
methodNode.instructions.remove(methodInsnNode);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceCompletableFutureExecutor(MethodNode methodNode) {
|
||||
boolean modified = false;
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!COMPLETABLE_FUTURE.equals(methodInsnNode.owner)) {
|
||||
continue;
|
||||
}
|
||||
if (("supplyAsync".equals(methodInsnNode.name) && ("(" + objectDesc(SUPPLIER) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc))
|
||||
|| ("thenComposeAsync".equals(methodInsnNode.name) && ("(" + objectDesc(FUNCTION) + objectDesc(EXECUTOR) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc))) {
|
||||
InsnList replacement = new InsnList();
|
||||
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(EXECUTOR) + ")" + objectDesc(EXECUTOR), false));
|
||||
methodNode.instructions.insertBefore(instruction, replacement);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceGetTexturesWithFakeSkinCache(MethodNode methodNode) {
|
||||
boolean modified = false;
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"getTextures".equals(methodInsnNode.name) || !("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceUnpackTexturesWithFakeSkinCache(ClassTransformationContext context, MethodNode methodNode) {
|
||||
boolean modified = false;
|
||||
String desc = context.remapMethodDescriptor("(" + objectDesc(MINECRAFT_SESSION_SERVICE) + objectDesc(PROPERTY) + objectDesc(SKIN_MANAGER_CACHE_KEY) + ")" + objectDesc(OBJECT));
|
||||
String returnType = context.remapClassName(MINECRAFT_PROFILE_TEXTURES);
|
||||
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) || !"unpackTextures".equals(methodInsnNode.name) || !("(" + objectDesc(PROPERTY) + ")" + objectDesc(MINECRAFT_PROFILE_TEXTURES)).equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList replacement = new InsnList();
|
||||
replacement.add(new VarInsnNode(ALOAD, 0));
|
||||
replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", desc, false));
|
||||
replacement.add(new TypeInsnNode(CHECKCAST, returnType));
|
||||
methodNode.instructions.insertBefore(instruction, replacement);
|
||||
methodNode.instructions.remove(instruction);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
package customskinloader.bootstrap.transformer.patch;
|
||||
|
||||
import customskinloader.bootstrap.transformer.ClassTransformationContext;
|
||||
import org.objectweb.asm.Handle;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public final class SkinTexturePatch extends PatchSupport {
|
||||
public SkinTexturePatch() {
|
||||
super(
|
||||
"customskinloader:skin-texture-patch", 1000,
|
||||
targets(
|
||||
HTTP_TEXTURE, "[,768],[801,803],[0x40000001,0x400000DD]", // 24w45a- (1.21.3-)
|
||||
SKIN_TEXTURE_DOWNLOADER, "[769,800],[804,0x40000000],[0x400000DE,]" // 24w46a+ (1.21.4+)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transform(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
|
||||
if (context.isTarget(HTTP_TEXTURE)) {
|
||||
// 24w45a- (1.21.3-)
|
||||
modified |= this.applyIfMatches("[,768],[801,803],[0x40000001,0x400000DD]", "http-texture.uploaded", () -> this.makeFieldPublicNonFinal(context.findField(HTTP_TEXTURE, "uploaded")));
|
||||
// 19w38a ~ 24w45a (1.15 ~ 1.21.3)
|
||||
modified |= this.applyIfMatches("[554,768],[801,803],[0x40000001,0x400000DD]", "http-texture.patch", () -> this.patchHttpTexture(context));
|
||||
}
|
||||
if (context.isTarget(SKIN_TEXTURE_DOWNLOADER)) {
|
||||
modified |= this.requireModified("skin-texture-downloader.patch", this.patchSkinTextureDownloader(context));
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean patchHttpTexture(ClassTransformationContext context) {
|
||||
return this.replaceHttpTextureProcessLegacySkin(
|
||||
context, context.findMethod(HTTP_TEXTURE, "load", "(" + objectDesc(INPUT_STREAM) + ")" + objectDesc(NATIVE_IMAGE))
|
||||
);
|
||||
}
|
||||
|
||||
private boolean patchSkinTextureDownloader(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
modified |= this.requireModified("skin-texture-downloader.then-compose", this.replaceThenComposeTextureFunction(
|
||||
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "downloadAndRegisterSkin", "(" + objectDesc(IDENTIFIER) + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(COMPLETABLE_FUTURE))
|
||||
));
|
||||
// 24w46a+ (1.21.4+)
|
||||
modified |= this.applyIfMatches("[769,800],[804,0x40000000],[0x400000DE,]", "skin-texture-downloader.process-legacy-skin", () -> replaceSkinTextureDownloaderProcessLegacySkin(context));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceThenComposeTextureFunction(ClassTransformationContext context, MethodNode methodNode) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
int locationLocal = (methodNode.access & ACC_STATIC) == 0 ? 1 : 0;
|
||||
int booleanLocal = locationLocal + 3;
|
||||
String remappedHookDesc = context.remapMethodDescriptor("(" + objectDesc(FUNCTION) + objectDesc(IDENTIFIER) + "Z)" + objectDesc(FUNCTION));
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!COMPLETABLE_FUTURE.equals(methodInsnNode.owner) || !"thenCompose".equals(methodInsnNode.name) || !("(" + objectDesc(FUNCTION) + ")" + objectDesc(COMPLETABLE_FUTURE)).equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InsnList injection = new InsnList();
|
||||
injection.add(new VarInsnNode(ALOAD, locationLocal));
|
||||
injection.add(new VarInsnNode(ILOAD, booleanLocal));
|
||||
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_HTTP_TEXTURE_V2, "createTexture", remappedHookDesc, false));
|
||||
methodNode.instructions.insertBefore(instruction, injection);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context) {
|
||||
boolean modified = false;
|
||||
// 24w46a ~ 25w37a (1.21.4 ~ 1.21.8)
|
||||
modified |= this.applyIfMatches("[769,772],[0x400000DE,0x4000010C]", "skin-texture-downloader.process-legacy-skin.v1", () -> replaceSkinTextureDownloaderProcessLegacySkin(
|
||||
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(NATIVE_IMAGE))
|
||||
));
|
||||
// 1.21.9-pre1+ (1.21.9+)
|
||||
modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x4000010D,]", "skin-texture-downloader.process-legacy-skin.v2", () -> replaceSkinTextureDownloaderProcessLegacySkin(
|
||||
context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(CLIENT_ASSET_DOWNLOADED_TEXTURE) + "Z)" + objectDesc(NATIVE_IMAGE))
|
||||
));
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context, MethodNode methodNode) {
|
||||
if (methodNode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String owner = context.remapClassName(SKIN_TEXTURE_DOWNLOADER);
|
||||
String originalDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
|
||||
String originalName = context.remapMethodName(SKIN_TEXTURE_DOWNLOADER, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + objectDesc(STRING) + ")" + objectDesc(NATIVE_IMAGE));
|
||||
for (AbstractInsnNode instruction : methodNode.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (methodInsnNode.getOpcode() != INVOKESTATIC || !owner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !originalDesc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methodNodeSet(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", originalDesc, false));
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean replaceHttpTextureProcessLegacySkin(ClassTransformationContext context, MethodNode load) {
|
||||
if (load == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
String owner = context.remapClassName(HTTP_TEXTURE);
|
||||
String originalName = context.remapMethodName(HTTP_TEXTURE, "processLegacySkin", "(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
|
||||
String imageDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + ")" + objectDesc(NATIVE_IMAGE));
|
||||
String replacementDesc = context.remapMethodDescriptor("(" + objectDesc(NATIVE_IMAGE) + objectDesc(RUNNABLE) + objectDesc(FUNCTION) + ")" + objectDesc(NATIVE_IMAGE));
|
||||
String processTaskField = context.remapFieldName(HTTP_TEXTURE, "onDownloaded");
|
||||
|
||||
for (AbstractInsnNode instruction : load.instructions.toArray()) {
|
||||
if (!(instruction instanceof MethodInsnNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
|
||||
if (!owner.equals(methodInsnNode.owner) || !originalName.equals(methodInsnNode.name) || !imageDesc.equals(methodInsnNode.desc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean staticProcessLegacySkin = methodInsnNode.getOpcode() == INVOKESTATIC;
|
||||
InsnList injection = new InsnList();
|
||||
int implementationHandleTag;
|
||||
String functionFactoryDesc;
|
||||
if (staticProcessLegacySkin) {
|
||||
injection.add(new VarInsnNode(ALOAD, 0));
|
||||
injection.add(new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
|
||||
implementationHandleTag = H_INVOKESTATIC;
|
||||
functionFactoryDesc = "()" + objectDesc(FUNCTION);
|
||||
} else {
|
||||
injection.add(new InsnNode(SWAP));
|
||||
injection.add(new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
|
||||
injection.add(new VarInsnNode(ALOAD, 0));
|
||||
implementationHandleTag = H_INVOKEVIRTUAL;
|
||||
functionFactoryDesc = "(" + objectDesc(owner) + ")" + objectDesc(FUNCTION);
|
||||
}
|
||||
injection.add(new InvokeDynamicInsnNode(
|
||||
"apply", functionFactoryDesc,
|
||||
new Handle(H_INVOKESTATIC, LAMBDA_METAFACTORY, "metafactory", "(" + objectDesc(METHOD_HANDLES_LOOKUP) + objectDesc(STRING) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_TYPE) + objectDesc(METHOD_HANDLE) + objectDesc(METHOD_TYPE) + ")" + objectDesc(CALL_SITE), false),
|
||||
Type.getType("(" + objectDesc(OBJECT) + ")" + objectDesc(OBJECT)),
|
||||
new Handle(implementationHandleTag, owner, originalName, imageDesc, false),
|
||||
Type.getType(imageDesc)
|
||||
));
|
||||
load.instructions.insertBefore(instruction, injection);
|
||||
methodNodeSet(load, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", replacementDesc, false));
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package customskinloader.bootstrap.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import customskinloader.bootstrap.BootstrapLogger;
|
||||
import customskinloader.bootstrap.installer.CommonJarInstaller;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Shared setup for Forge-style mods-folder locators that expose the released jar as a synthetic mod.
|
||||
*/
|
||||
public final class ModLocatorUtils {
|
||||
public static final String LOCATOR_NAME = "customskinloader-locator";
|
||||
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||
|
||||
private ModLocatorUtils() {
|
||||
}
|
||||
|
||||
public static void initialize(Object locator, Class<?> locatorType, Path gameDirectory, String mappingType) {
|
||||
try {
|
||||
Path runtimeDirectory = resolveRuntimeDirectory(gameDirectory);
|
||||
LOGGER.info("Initializing " + LOCATOR_NAME + " for " + mappingType + " mappings in " + BootstrapLogger.formatPath(gameDirectory));
|
||||
setModFolder(locator, locatorType, runtimeDirectory);
|
||||
Path commonJar = CommonJarInstaller.releaseCommonJar(gameDirectory, mappingType);
|
||||
LOGGER.info("Initialized " + LOCATOR_NAME + " with mod folder " + BootstrapLogger.formatPath(runtimeDirectory)
|
||||
+ " and Common jar " + BootstrapLogger.formatPath(commonJar));
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
|
||||
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for discovery", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static Path resolveRuntimeDirectory(Path gameDirectory) {
|
||||
return gameDirectory.resolve("CustomSkinLoader").resolve("Core");
|
||||
}
|
||||
|
||||
private static void setModFolder(Object locator, Class<?> locatorType, Path modFolder) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field = locatorType.getDeclaredField("modFolder");
|
||||
field.setAccessible(true);
|
||||
field.set(locator, modFolder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package customskinloader.bootstrap.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Shared matcher for protocol and ordinal range expressions.
|
||||
*/
|
||||
public final class RangeMatcher {
|
||||
private RangeMatcher() {
|
||||
}
|
||||
|
||||
public static boolean matches(String expression, int protocolVersion, int worldVersion) {
|
||||
if (expression == null || expression.trim().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String protocolRange = "";
|
||||
String worldRange = "";
|
||||
int index = expression.indexOf("+");
|
||||
if (index >= 0) {
|
||||
protocolRange = expression.substring(0, index);
|
||||
worldRange = expression.substring(index + 1);
|
||||
} else {
|
||||
protocolRange = expression;
|
||||
}
|
||||
return matches(protocolRange, protocolVersion) && matches(worldRange, worldVersion);
|
||||
}
|
||||
|
||||
private static boolean matches(String expression, int value) {
|
||||
if (expression == null || expression.trim().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (String token : splitTokens(expression)) {
|
||||
String trimmedToken = token.trim();
|
||||
if (trimmedToken.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmedToken.startsWith("[") && trimmedToken.endsWith("]")) {
|
||||
int commaIndex = trimmedToken.indexOf(',');
|
||||
if (commaIndex < 0) {
|
||||
throw new IllegalArgumentException("Invalid range token: " + trimmedToken);
|
||||
}
|
||||
|
||||
String leftPart = trimmedToken.substring(1, commaIndex).trim();
|
||||
String rightPart = trimmedToken.substring(commaIndex + 1, trimmedToken.length() - 1).trim();
|
||||
int lowerBound = leftPart.isEmpty() ? 0 : parseNumber(leftPart);
|
||||
int upperBound = rightPart.isEmpty() ? Integer.MAX_VALUE : parseNumber(rightPart);
|
||||
if (value >= lowerBound && value <= upperBound) {
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value == parseNumber(trimmedToken)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<String> splitTokens(String expression) {
|
||||
List<String> tokens = new ArrayList<>();
|
||||
StringBuilder currentToken = new StringBuilder();
|
||||
int bracketDepth = 0;
|
||||
|
||||
for (int index = 0; index < expression.length(); index++) {
|
||||
char currentChar = expression.charAt(index);
|
||||
if (currentChar == '[') {
|
||||
bracketDepth++;
|
||||
} else if (currentChar == ']') {
|
||||
bracketDepth--;
|
||||
}
|
||||
|
||||
if (currentChar == ',' && bracketDepth == 0) {
|
||||
tokens.add(currentToken.toString());
|
||||
currentToken.setLength(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
currentToken.append(currentChar);
|
||||
}
|
||||
|
||||
tokens.add(currentToken.toString());
|
||||
return tokens;
|
||||
}
|
||||
|
||||
private static int parseNumber(String token) {
|
||||
String trimmedToken = token.trim();
|
||||
if (trimmedToken.startsWith("0x")) {
|
||||
return Integer.parseInt(trimmedToken.substring(2), 16);
|
||||
}
|
||||
|
||||
return Integer.parseInt(trimmedToken, 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
English(en)
|
||||
|
||||
LICENSE - Binary File
|
||||
You could not modify binary file.
|
||||
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
||||
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
||||
You could not repost this mod to any website without permission.
|
||||
You could not earn money with this mod excluding modpack.
|
||||
|
||||
LICENSE - Source Code
|
||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||
When using the code, you should change the name of package to avoid others' misunderstanding.
|
||||
|
||||
OTHER - Useful Link
|
||||
Source Code: https://github.com/xfl03/MCCustomSkinLoader
|
||||
Release Page: http://www.mcbbs.net/thread-269807-1-1.html
|
||||
Build Server: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||
|
||||
|
||||
中文简体(zh_cn)
|
||||
|
||||
许可 - 编译产物
|
||||
您不得对CustomSkinLoader的成品jar内部内容进行任何修改
|
||||
您可以在不经我许可的情况下,以任意方式传播这一mod以及jar文件(例如加入整合包)。
|
||||
在加入整合包时,请必须在帖子内mod列表中明确写上"万用皮肤补丁"或者"CustomSkinLoader"或者附上发布页面地址。
|
||||
您不得在未经许可的情况下,在国内外任何网站进行二次发布(包括皮肤站)。
|
||||
您不得以任何形式出售CustomSkinLoader或任何使用或参考CustomSkinLoader源代码的作品。
|
||||
|
||||
许可 - 源代码
|
||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||
为避免他人误解,您在使用代码时必须修改包名。
|
||||
|
||||
其他 - 有用的链接
|
||||
源代码: https://github.com/xfl03/MCCustomSkinLoader
|
||||
发布页面: http://www.mcbbs.net/thread-269807-1-1.html
|
||||
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||
+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"
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package customskinloader.bootstrap.fabric.v1;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
public final class MixinConfigPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
TransformerBootstrap.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
// This is the last stable point before postInitialise/validation, so reflected target injection is still visible downstream.
|
||||
TransformerBootstrap.applyPendingMixinTargets(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
TransformerBootstrap.transformTargetClass(targetClassName, targetClass);
|
||||
}
|
||||
}
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
package customskinloader.bootstrap.fabric.v1;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import customskinloader.bootstrap.BootstrapLogger;
|
||||
import customskinloader.bootstrap.ModLoaderInfo;
|
||||
import customskinloader.bootstrap.installer.CommonJarInstaller;
|
||||
import customskinloader.bootstrap.transformer.ClassTransformationReport;
|
||||
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.impl.launch.FabricLauncherBase;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.Config;
|
||||
|
||||
final class TransformerBootstrap {
|
||||
private static final Logger LOGGER = BootstrapLogger.LOGGER;
|
||||
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "intermediary");
|
||||
private static final Object LOCK = new Object();
|
||||
private static final List<PendingMixinTarget> PENDING_MIXIN_TARGETS = new ArrayList<>();
|
||||
private static final String DUMMY_MIXIN = "customskinloader.bootstrap.fabric.v1.mixin.DummyMixin";
|
||||
|
||||
private TransformerBootstrap() {
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Fabric");
|
||||
publishModLoaderInfo();
|
||||
releaseRuntimeArtifacts();
|
||||
int targetCount = 0;
|
||||
for (String targetClassName : SUPPORT.collectTargetClassNames()) {
|
||||
registerMixinTarget(DUMMY_MIXIN, targetClassName.replace('/', '.'));
|
||||
targetCount++;
|
||||
}
|
||||
LOGGER.info("Initialized CustomSkinLoader Bootstrap for Fabric with " + targetCount + " reflected Mixin target(s)");
|
||||
}
|
||||
|
||||
private static void publishModLoaderInfo() {
|
||||
ModLoaderInfo.publish("Fabric", FabricLoader.getInstance().getModContainer("fabricloader").map(m -> m.getMetadata().getVersion().getFriendlyString()).orElse("unknown"));
|
||||
}
|
||||
|
||||
private static void releaseRuntimeArtifacts() {
|
||||
try {
|
||||
Path commonJar = CommonJarInstaller.releaseCommonJar(FabricLoader.getInstance().getGameDir(), "intermediary");
|
||||
FabricLauncherBase.getLauncher().addToClassPath(commonJar, "customskinloader.");
|
||||
LOGGER.info("Added CustomSkinLoader Common jar to Fabric class path: " + BootstrapLogger.formatPath(commonJar));
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
|
||||
throw new IllegalStateException("Failed to prepare CustomSkinLoader runtime artifacts for Fabric", exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerMixinTarget(String mixinClassName, String targetClassName) {
|
||||
synchronized (LOCK) {
|
||||
PENDING_MIXIN_TARGETS.add(new PendingMixinTarget(mixinClassName, targetClassName));
|
||||
LOGGER.debug("Queued Fabric Mixin target " + targetClassName + " for " + mixinClassName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyPendingMixinTargets(IMixinConfigPlugin plugin) {
|
||||
synchronized (LOCK) {
|
||||
if (PENDING_MIXIN_TARGETS.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
IMixinConfig mixinConfig = findOwningMixinConfig(plugin);
|
||||
int appliedTargetCount = 0;
|
||||
Iterator<PendingMixinTarget> iterator = PENDING_MIXIN_TARGETS.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
PendingMixinTarget pendingTarget = iterator.next();
|
||||
applyMixinTarget(mixinConfig, pendingTarget.mixinClassName, pendingTarget.targetClassName);
|
||||
iterator.remove();
|
||||
appliedTargetCount++;
|
||||
}
|
||||
LOGGER.info("Applied " + appliedTargetCount + " reflected Fabric Mixin target(s)");
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
LOGGER.error("Failed to append reflected targets to the current Fabric mixin config", exception);
|
||||
throw new IllegalStateException("Failed to append reflected targets to the current Fabric mixin config", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void transformTargetClass(String targetClassName, ClassNode targetClass) {
|
||||
ClassTransformationReport report = SUPPORT.transformClassNode(targetClassName, targetClass);
|
||||
ClassNode transformedNode = report.getTransformedClassNode();
|
||||
if (transformedNode != targetClass) {
|
||||
TransformerBootstrapSupport.copyClassNode(transformedNode, targetClass);
|
||||
}
|
||||
if (report.isModified()) {
|
||||
LOGGER.info("Transformed Fabric target " + targetClassName + " with " + report.getAppliedTransformerNames());
|
||||
}
|
||||
}
|
||||
|
||||
private static IMixinConfig findOwningMixinConfig(IMixinConfigPlugin plugin) throws ReflectiveOperationException {
|
||||
Field allConfigsField = Config.class.getDeclaredField("allConfigs");
|
||||
allConfigsField.setAccessible(true);
|
||||
|
||||
for (Object configHandle : ((Map<?, ?>) allConfigsField.get(null)).values()) {
|
||||
IMixinConfig mixinConfig = ((Config) configHandle).getConfig();
|
||||
if (mixinConfig.getPlugin() == plugin) {
|
||||
return mixinConfig;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Could not find the owning MixinConfig for " + plugin.getClass().getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void applyMixinTarget(IMixinConfig mixinConfig, String mixinClassName, String targetClassName) throws ReflectiveOperationException {
|
||||
IMixinInfo mixinInfo = findMixinInfo(mixinConfig, mixinClassName);
|
||||
String targetBinaryName = targetClassName.replace('/', '.');
|
||||
String targetInternalName = targetClassName.replace('.', '/');
|
||||
|
||||
List<String> targetClassNames = (List<String>) getField(mixinInfo, "targetClassNames");
|
||||
if (targetClassNames.contains(targetInternalName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClassInfo targetClassInfo = ClassInfo.forName(targetInternalName);
|
||||
if (targetClassInfo == null) {
|
||||
throw new IllegalStateException("Could not resolve target ClassInfo for " + targetInternalName);
|
||||
}
|
||||
|
||||
Method addMixin = ClassInfo.class.getDeclaredMethod("addMixin", Class.forName("org.spongepowered.asm.mixin.transformer.MixinInfo"));
|
||||
addMixin.setAccessible(true);
|
||||
addMixin.invoke(targetClassInfo, mixinInfo);
|
||||
|
||||
List<ClassInfo> targetClasses = (List<ClassInfo>) getField(mixinInfo, "targetClasses");
|
||||
targetClasses.add(targetClassInfo);
|
||||
targetClassNames.add(targetInternalName);
|
||||
|
||||
Map<String, List<Object>> mixinMapping = (Map<String, List<Object>>) getField(mixinConfig, "mixinMapping");
|
||||
List<Object> mappedMixins = mixinMapping.computeIfAbsent(targetBinaryName, k -> new ArrayList<>());
|
||||
if (!mappedMixins.contains(mixinInfo)) {
|
||||
mappedMixins.add(mixinInfo);
|
||||
}
|
||||
|
||||
((Set<String>) getField(mixinConfig, "unhandledTargets")).add(targetBinaryName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static IMixinInfo findMixinInfo(IMixinConfig mixinConfig, String mixinClassName) throws ReflectiveOperationException {
|
||||
for (IMixinInfo mixinInfo : (List<IMixinInfo>) getField(mixinConfig, "mixins")) {
|
||||
String currentMixinName = mixinInfo.getClassName();
|
||||
if (mixinClassName.equals(currentMixinName)) {
|
||||
return mixinInfo;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Could not find mixin " + mixinClassName + " in the current config");
|
||||
}
|
||||
|
||||
private static Object getField(Object instance, String fieldName) throws ReflectiveOperationException {
|
||||
Field field = findField(instance.getClass(), fieldName);
|
||||
field.setAccessible(true);
|
||||
return field.get(instance);
|
||||
}
|
||||
|
||||
private static Field findField(Class<?> type, String fieldName) throws NoSuchFieldException {
|
||||
Class<?> currentType = type;
|
||||
while (currentType != null) {
|
||||
try {
|
||||
return currentType.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException exception) {
|
||||
currentType = currentType.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchFieldException(fieldName);
|
||||
}
|
||||
|
||||
private static final class PendingMixinTarget {
|
||||
private final String mixinClassName;
|
||||
private final String targetClassName;
|
||||
|
||||
private PendingMixinTarget(String mixinClassName, String targetClassName) {
|
||||
this.mixinClassName = mixinClassName;
|
||||
this.targetClassName = targetClassName;
|
||||
}
|
||||
}
|
||||
}
|
||||
+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 {
|
||||
|
||||
}
|
||||
Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user