Compare commits

...
Author SHA1 Message Date
33 7456725158 feat: update Minecraft compatibility matrix and add concurrency settings in pull request workflow 2026-09-21 13:02:14 +08:00
33 8023f4d1ea fix: update artifact naming and compatibility test job in workflows 2026-09-21 01:51:30 +08:00
33 54339f9e66 feat: update Minecraft smoke test workflow for compatibility with multiple versions and modloaders 2026-09-21 01:41:18 +08:00
33 3abba80b3b fix: change artifact upload behavior to error on missing files 2026-09-21 01:19:17 +08:00
33 a7b64a1645 feat: add log upload step to Minecraft smoke test workflow 2026-09-21 01:09:58 +08:00
33 56c7e9196d feat: add smoke test workflow for Minecraft 26.2 2026-09-21 00:59:21 +08:00
Copilotandxfl03 f334a61faa Remove Cosmetica from legacy defaults and documented load lists (#391)
* Remove Cosmetica from default profiles and docs

Co-authored-by: xfl03 <[email protected]>

* Remove deprecated LabyMod commented entry

Co-authored-by: xfl03 <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: xfl03 <[email protected]>
2026-08-12 20:27:30 +08:00
Steven QiuandZekerZhayard 873705c4fb feat: default user agent (#389)
* feat: default user agent

* fix: Fabric version detection

* refactor: remove junit test

* refactor: read mod loader info in bootstrap

* Optimize mod loader version retrieval

---------

Co-authored-by: ZekerZhayard <[email protected]>
2026-08-12 20:19:00 +08:00
ZekerZhayard ebea66d261 Fix: relax render patch failures and correct RenderType patching (#381) 2026-06-21 13:42:48 +08:00
23 changed files with 306 additions and 36 deletions

No files matched your search

+3 -1
View File
@@ -38,7 +38,9 @@ runs:
- name: Build with Gradle
shell: pwsh
run: ./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }}
run: |
./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }}
./gradlew --stop
- name: Generate metadata JSONs
if: github.event_name != 'pull_request'
+49
View File
@@ -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
+39
View File
@@ -1,9 +1,15 @@
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
@@ -14,3 +20,36 @@ jobs:
- 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,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);
}
}
@@ -199,11 +199,15 @@ abstract class PatchSupport extends TargetedClassTransformer implements Opcodes
}
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());
return this.requireModified(label, operation.getAsBoolean(), required);
}
protected boolean requireModified(String label, boolean modified) {
@@ -222,7 +226,7 @@ abstract class PatchSupport extends TargetedClassTransformer implements Opcodes
throw new IllegalStateException(message);
}
if (!required && Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
if (!required || Boolean.getBoolean(IGNORE_PATCH_FAILURE_PROPERTY)) {
LOGGER.warn(message);
return false;
}
@@ -97,27 +97,27 @@ public final class RenderPatch extends PatchSupport {
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;
}
@@ -127,12 +127,12 @@ public final class RenderPatch extends PatchSupport {
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;
}
@@ -157,7 +157,9 @@ public final class RenderPatch extends PatchSupport {
continue;
}
methodNode.instructions.set(instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
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;
}
@@ -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);
}
});
}
}
@@ -10,6 +10,7 @@ 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;
@@ -35,6 +36,7 @@ final class TransformerBootstrap {
public static void initialize() {
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Fabric");
publishModLoaderInfo();
releaseRuntimeArtifacts();
int targetCount = 0;
for (String targetClassName : SUPPORT.collectTargetClassNames()) {
@@ -44,6 +46,10 @@ final class TransformerBootstrap {
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");
@@ -6,10 +6,12 @@ import java.nio.file.Paths;
import java.util.Map;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.ModLoaderInfo;
import customskinloader.bootstrap.installer.CommonJarInstaller;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraftforge.fml.relauncher.FMLInjectionData;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
@@ -22,6 +24,9 @@ final class TransformerBootstrap {
public static void injectData(Map<String, Object> data) {
try {
Object[] version = FMLInjectionData.data();
ModLoaderInfo.publish("Forge", version[0] + "." + version[1] + "." + version[2] + "." + version[3]);
Path runtimeDirectory = resolveRuntimeDirectory(data);
LOGGER.info("Initializing CustomSkinLoader Bootstrap for Forge v1 in " + BootstrapLogger.formatPath(runtimeDirectory));
Path commonJar = CommonJarInstaller.releaseCommonJar(runtimeDirectory, "srg");
@@ -1,10 +1,9 @@
package customskinloader.bootstrap.forge.v2;
import customskinloader.bootstrap.util.ModLocatorUtils;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator;
import customskinloader.bootstrap.util.ModLocatorUtils;
public final class CommonModLocator extends ModsFolderLocator {
public CommonModLocator() {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "srg");
@@ -24,6 +24,7 @@ public final class TransformationService implements ITransformationService {
@Override
public void initialize(IEnvironment environment) {
LOGGER.info("Initializing CustomSkinLoader Bootstrap transformation service");
TransformerBootstrap.publishModLoaderInfo();
try {
List<Path> extraLocators = ModDirTransformerDiscoverer.getExtraLocators();
Path servicePath = Paths.get(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath().normalize();
@@ -4,27 +4,59 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import cpw.mods.modlauncher.ArgumentHandler;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.ITransformer;
import cpw.mods.modlauncher.api.ITransformerVotingContext;
import cpw.mods.modlauncher.api.TransformerVoteResult;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.ModLoaderInfo;
import customskinloader.bootstrap.transformer.ClassTransformationReport;
import customskinloader.bootstrap.transformer.TransformerBootstrapSupport;
import customskinloader.bootstrap.util.ReflectionUtils;
import net.minecraftforge.fml.loading.FMLLoader;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
final class TransformerBootstrap {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class,
// official: neoforge 1.20.2-20.2.3 ~ 1.21.3-21.3.97
// srg: forge *, neoforge 1.21.4-21.4.0 ~ 1.21.9-21.9.13
Launcher.INSTANCE.environment().findLaunchHandler("forgeclient")
.map(handle -> handle.getClass().getName().startsWith("net.neoforged.")).orElse(false) ? "official" : "srg");
private TransformerBootstrap() {
}
public static void publishModLoaderInfo() {
try {
Object argumentHandler = ReflectionUtils.findField(Launcher.class, "argumentHandler").get(Launcher.INSTANCE);
String[] args = (String[]) ReflectionUtils.findField(ArgumentHandler.class, "args").get(argumentHandler);
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (Objects.equals(arg, "--fml.forgeVersion")) {
// forge 1.13.2-25.0.216 ~ 1.20.2-48.1.0
ModLoaderInfo.publish("Forge", args[i + 1]);
return;
} else if (Objects.equals(arg, "--fml.neoForgeVersion")) {
// neoforge 1.20.2-20.2.3 ~ 1.21.9-21.9.13
ModLoaderInfo.publish("NeoForge", args[i + 1]);
return;
}
}
// forge 1.20.3-49.0.1+
ModLoaderInfo.publish("Forge", FMLLoader.class.getPackage().getImplementationVersion());
} catch (Exception e) {
LOGGER.warn("Could not determine mod loader", e);
ModLoaderInfo.publish("Forge", "unknown");
}
}
public static List<ITransformer> buildTransformers() {
List<ITransformer> transformers = new ArrayList<>();
for (String targetClassName : SUPPORT.collectTargetClassNames()) {
@@ -9,6 +9,7 @@ public final class CommonModLocator extends ModsFolderLocator {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
}
@Override
public String name() {
return ModLocatorUtils.LOCATOR_NAME;
}
@@ -1,9 +1,12 @@
package customskinloader.bootstrap.neoforge.v2;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.ModLoaderInfo;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforgespi.transformation.ClassProcessorProvider;
import org.apache.logging.log4j.Logger;
// NeoForge 21.9.14+
public final class ClassProcessorProviderImpl implements ClassProcessorProvider {
private static final Logger LOGGER = BootstrapLogger.LOGGER;
@@ -11,6 +14,7 @@ public final class ClassProcessorProviderImpl implements ClassProcessorProvider
public void createProcessors(Context context, Collector collector) {
// Always register the bridge processor so late transformer registrations can still be observed.
LOGGER.info("Registering CustomSkinLoader Bootstrap NeoForge class processor");
ModLoaderInfo.publish("NeoForge", FMLLoader.getCurrent().getVersionInfo().neoForgeVersion());
collector.add(TransformerBootstrap.createProcessor());
}
}
@@ -4,6 +4,7 @@ import customskinloader.bootstrap.util.ModLocatorUtils;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.fml.loading.moddiscovery.locators.ModsFolderLocator;
// NeoForge 20.6.14+
public final class CommonModLocator extends ModsFolderLocator {
public CommonModLocator() {
ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official");
@@ -218,7 +218,7 @@ public class CustomSkinLoader {
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
logger.info("Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
logger.info("Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion() + " (" + MinecraftUtil.getLoaderName() + " " + MinecraftUtil.getLoaderVersion() + ")");
return logger;
}
@@ -51,14 +51,14 @@ public class FakeHttpTexture {
}
public static class V2 extends SimpleTexture {
private static final String DOMAIN = "customskinloader:";
private static final String DOMAIN = "customskinloader";
private FakeCapeBuffer buffer;
private FakeNativeImage image;
public static Function<NativeImage, CompletableFuture<?>> createTexture(Function<NativeImage, CompletableFuture<?>> function, Identifier location, boolean isSkin) {
return isSkin ? _image -> {
if (location.toString().startsWith(DOMAIN)) {
if (location.toString().startsWith(DOMAIN + ":")) {
return CompletableFuture.completedFuture(new AbstractMap.SimpleEntry<>(_image, function.apply(_image)));
}
return function.apply(_image);
@@ -27,9 +27,7 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
public List<IDefaultProfile> getDefaultProfiles() {
return Lists.newArrayList(new LocalSkin(this),
getCapeProfile(this, "OptiFine", "https://optifine.net/capes/{USERNAME}.png", 810),
getCapeProfile(this, "CloakPlus", "http://161.35.130.99/capes/{USERNAME}.png", 840),
//getCapeProfile(this, "LabyMod", "https://dl.labymod.net/capes/{STANDARD_UUID}", 850),
getCapeProfile(this, "Cosmetica", "https://api.cosmetica.cc/get/cloak?username={USERNAME}&uuid={STANDARD_UUID}&nothirdparty", 860)
getCapeProfile(this, "CloakPlus", "http://161.35.130.99/capes/{USERNAME}.png", 840)
);
}
@@ -97,7 +97,8 @@ public class HttpRequestUtil {
CustomSkinLoader.logger.debug("Try to read cache '" + request.cacheFile + "'.");
return loadFromCache(request, new HttpResponce());
}
CustomSkinLoader.logger.debug("Try to request '" + request.url + (request.userAgent == null ? "'." : "' with user agent '" + request.userAgent + "'."));
String userAgent = UserAgentUtil.expandUserAgent(request.userAgent);
CustomSkinLoader.logger.debug("Try to request '" + request.url + "' with user agent '" + userAgent + "'.");
//Check Cache
if (StringUtils.isNotEmpty(request.payload) || CustomSkinLoader.config.forceDisableCache) {
request.cacheTime = -1;//No Cache
@@ -156,9 +157,7 @@ public class HttpRequestUtil {
c.setRequestProperty("If-None-Match", cacheInfo.etag);
}
c.setRequestProperty("Accept-Encoding", "gzip");
if (request.userAgent != null) {
c.setRequestProperty("User-Agent", request.userAgent);
}
c.setRequestProperty("User-Agent", userAgent);
if (StringUtils.isNotEmpty(request.payload)) {
CustomSkinLoader.logger.info("Payload: " + request.payload);
c.setRequestMethod("POST");
@@ -12,8 +12,6 @@ import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
/**
* @author Alexander Xia
@@ -24,13 +22,6 @@ public class MinecraftUtil {
return Minecraft.getInstance().gameDirectory;
}
public static TextureManager getTextureManager() {
return Minecraft.getInstance().getTextureManager();
}
public static SkinManager getSkinManager() {
return Minecraft.getInstance().getSkinManager();
}
private static String minecraftMainVersion = null;
public static String getMinecraftMainVersion() {
@@ -67,6 +58,17 @@ public class MinecraftUtil {
return "unknown";
}
private static final String MOD_LOADER_NAME_PROPERTY = "customskinloader.modLoader.name";
private static final String MOD_LOADER_VERSION_PROPERTY = "customskinloader.modLoader.version";
public static String getLoaderName() {
return System.getProperty(MOD_LOADER_NAME_PROPERTY, "unknown");
}
public static String getLoaderVersion() {
return System.getProperty(MOD_LOADER_VERSION_PROPERTY, "unknown");
}
// (domain|ip)(:port)
public static String getServerAddress() {
ServerData data = Minecraft.getInstance().getCurrentServer();
@@ -0,0 +1,55 @@
package customskinloader.utils;
import customskinloader.CustomSkinLoader;
public final class UserAgentUtil {
public static final String DEFAULT_USER_AGENT_PLACEHOLDER = "{DEFAULT_USER_AGENT}";
public static final String CSL_VERSION_PLACEHOLDER = "{CSL_VERSION}";
public static final String MINECRAFT_VERSION_PLACEHOLDER = "{MINECRAFT_VERSION}";
public static final String MOD_LOADER_NAME_PLACEHOLDER = "{MOD_LOADER_NAME}";
public static final String MOD_LOADER_VERSION_PLACEHOLDER = "{MOD_LOADER_VERSION}";
public static final String JAVA_VERSION_PLACEHOLDER = "{JAVA_VERSION}";
private UserAgentUtil() {
}
public static String expandUserAgent(String userAgent) {
String modVersion = sanitizeComponent(CustomSkinLoader.CustomSkinLoader_FULL_VERSION);
String minecraftVersion = sanitizeComponent(MinecraftUtil.getMinecraftMainVersion());
String loaderName = sanitizeComponent(MinecraftUtil.getLoaderName());
String loaderVersion = sanitizeComponent(MinecraftUtil.getLoaderVersion());
String javaVersion = sanitizeComponent(System.getProperty("java.version", "unknown"));
String defaultUserAgent = "CustomSkinLoader/" + modVersion
+ " (Minecraft/" + minecraftVersion
+ "; " + loaderName + "/" + loaderVersion
+ "; Java/" + javaVersion + ")";
if (userAgent == null) {
return defaultUserAgent;
}
return userAgent
.replace(DEFAULT_USER_AGENT_PLACEHOLDER, defaultUserAgent)
.replace(CSL_VERSION_PLACEHOLDER, modVersion)
.replace(MINECRAFT_VERSION_PLACEHOLDER, minecraftVersion)
.replace(MOD_LOADER_NAME_PLACEHOLDER, loaderName)
.replace(MOD_LOADER_VERSION_PLACEHOLDER, loaderVersion)
.replace(JAVA_VERSION_PLACEHOLDER, javaVersion);
}
private static String sanitizeComponent(String value) {
if (value == null || value.trim().isEmpty()) {
return "unknown";
}
String component = value.trim();
StringBuilder sanitized = new StringBuilder(component.length());
for (int i = 0; i < component.length(); i++) {
char c = component.charAt(i);
sanitized.append(c >= '0' && c <= '9'
|| c >= 'A' && c <= 'Z'
|| c >= 'a' && c <= 'z'
|| "!#$%&'*+-.^_`|~".indexOf(c) >= 0 ? c : '_');
}
return sanitized.toString();
}
}
+1 -3
View File
@@ -69,7 +69,6 @@ Supported special skin sites and profiles:
- [MinecraftCapes](https://minecraftcapes.net/)
- [OptiFineCape](https://optifine.net/home)
- [Cloaks+](https://cloaksplus.com/)
- [Cosmetica](https://cosmetica.cc/)
- [Wynntils](https://wynntils.com/) compatible profile support
You can customize the skin load list and load textures from any compatible skin server. Skin server owners can also use ExtraList files to help users add their server.
@@ -131,7 +130,6 @@ GitHub Actions intentionally runs on Windows with PowerShell, but local project
- [MinecraftCapes](https://minecraftcapes.net/)
- [OptiFineCape](https://optifine.net/home)
- [Cloaks+](https://cloaksplus.com/)
- [Cosmetica](https://cosmetica.cc/)
If you want to add another skin server to the default list, please open an [issue](https://github.com/xfl03/MCCustomSkinLoader/issues).
@@ -148,7 +146,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
### Major Contributor
- 2013-2014 Jeremy Lam ([JLChnToZ](https://github.com/JLChnToZ))
- 2014-2024 Alexander Xia ([xfl03](https://github.com/xfl03))
- 2014-2026 [xfl03](https://github.com/xfl03)
- 2020-2026 [ZekerZhayard](https://github.com/ZekerZhayard)
### Binary File
+1 -1
View File
@@ -1,7 +1,7 @@
{
"mod_group": "customskinloader",
"mod_name": "CustomSkinLoader",
"mod_version": "15.0",
"mod_version": "15.0.1",
"edition": "Universal",
"loaders": [