Skip to content

Commit

Permalink
Support 1.21. (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekerZhayard authored Jul 2, 2024
1 parent cd19228 commit 64490f1
Show file tree
Hide file tree
Showing 90 changed files with 733 additions and 375 deletions.
8 changes: 0 additions & 8 deletions Common/src/main/java/customskinloader/Logger.java

This file was deleted.

7 changes: 5 additions & 2 deletions Common/src/main/java/customskinloader/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import java.io.File;
import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import customskinloader.CustomSkinLoader;
import customskinloader.loader.ProfileLoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
import customskinloader.plugin.PluginLoader;
import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0;
import customskinloader.utils.Version;
import org.apache.commons.io.FileUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.util.ResourceLocation;

public class FakeCapeBuffer extends FakeSkinBuffer {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("minecraft", "textures/entity/elytra.png");
private static int loadedGlobal = 0;
private static FakeImage elytraImage;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package customskinloader.fake.itf;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.function.Function;

import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.CustomSkinLoader;
import customskinloader.utils.TimeUtil;
import org.apache.commons.io.FileUtils;
Expand Down
7 changes: 0 additions & 7 deletions Common/src/main/java/customskinloader/utils/HttpUtil0.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.apache.commons.lang3.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static String getMinecraftMainVersion() {
}

//version.json can be found in 1.14+
URL versionFile = MinecraftUtil.class.getResource("/version.json");
URL versionFile = ClassLoader.getSystemClassLoader().getResource("version.json");
if (versionFile != null) {
try (
InputStream is = versionFile.openStream();
Expand Down
6 changes: 3 additions & 3 deletions Common/src/main/resources/BuildInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "CustomSkinLoader",
"version": "${modVersion}",
"fullVersion": "${modFullVersion}",
"mcVersion": "${mcVersion}",
"mcFullVersions": "${mcFullVersions}",
"forgeVersion": "${forgeVersion}",
"dependencies": {
"${dependencies}"
},
"gitVersion": "${gitVersion}",
"buildUrl": "${buildUrl}",
"buildTime": "${releaseTime}"
Expand Down
46 changes: 1 addition & 45 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {

import customskinloader.gradle.util.RemapUtil
import customskinloader.gradle.util.SourceUtil
import groovy.json.JsonSlurper

apply plugin: 'org.spongepowered.mixin'

Expand All @@ -37,48 +36,5 @@ mixin {
reobfNotchSrgFile = "build/mixin.srg"
}

SourceUtil.addDependencies project, project(":Common")
SourceUtil.addDependencies project, project(":Common"), project(":Vanilla/Common")
RemapUtil.remapSources project

// Resolve snapshot versions
tasks.publishModrinth.doFirst {
def snapshot = []
gameVersions.groupBy { v -> v.endsWith("-Snapshot") }.with {
this.tasks.publishModrinth.gameVersions = it[false]
snapshot = it[true]
}

// The CustomSkinLoader Fabric edition should support all Minecraft snapshot edition.
def jsonSlurper = new JsonSlurper()
def officialVersionList = [] as Set
plugins.withId "net.minecraftforge.gradle.forge", { plugin ->
def currentRelease = null
// Get version manifest json.
// https://github.com/MinecraftForge/ForgeGradle/blob/fc67182a61926f0bdb0d12da5fba7f4322f64d86/src/main/java/net/minecraftforge/gradle/common/BasePlugin.java#L229
jsonSlurper.parse(plugin.cacheFile("McManifest.json")).versions.each { version ->
if (version.type == "snapshot") {
// If the first version is a snapshot, since Mojang no longer provides the target version for snapshots,
// we assume that new snapshots will not be supported until the next release.
if (currentRelease == null) {
return
}
} else if (version.type == "release") {
currentRelease = version.id.with {
it.toString().split($/\./$).with { "${it[0]}.${it[1]}" }
}
} else {
// We do not care about other types.
return
}
if (snapshot.contains("${currentRelease}-Snapshot".toString())) {
officialVersionList << version.id
}
}
}
jsonSlurper.parse(new URL("https://meta.fabricmc.net/v2/versions/game")).each { version ->
// Exclude experimental editions which is not support in Modrinth.
if (!version.stable && officialVersionList.contains(version.version)) {
gameVersions << version.version.replace(" ", "-").replace("Pre-Release-", "pre") // Fix the id of the earlier preview versions of 1.14.
}
}
}
6 changes: 3 additions & 3 deletions Fabric/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
minecraft_version=1.14
minecraft_full_versions=1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21
dependencies=Fabric|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21;\
Quilt|1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21
java_full_versions=8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
#forge gradle needs forge version
forge_mc_version=1.12.2
forge_version=14.23.5.2768
Expand Down
Original file line number Diff line number Diff line change
@@ -1,106 +1,11 @@
package customskinloader.fabric;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Paths;
import java.util.List;
import java.util.Set;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import customskinloader.log.LogManager;
import customskinloader.log.Logger;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

public class MixinConfigPlugin implements IMixinConfigPlugin {
public static Logger logger = LogManager.getLogger("Fabric");
private long world_version;
private long protocol_version;

public class MixinConfigPlugin extends customskinloader.mixin.core.MixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
LogManager.setLogFile(Paths.get("./CustomSkinLoader/CustomSkinLoader.log"));
URL versionJson = this.getClass().getResource("/version.json");
if (versionJson != null) {
logger.info("\"version.json\": " + versionJson.toString());
try (
InputStream is = versionJson.openStream();
InputStreamReader isr = new InputStreamReader(is)
) {
JsonObject object = new JsonParser().parse(isr).getAsJsonObject();
String name = object.get("name").getAsString();
this.world_version = object.get("world_version").getAsLong();
this.protocol_version = object.get("protocol_version").getAsLong();
logger.info("MinecraftVersion: {name='" + name + "', world_version='" + this.world_version + "', protocol_version='" + this.protocol_version + "'}");
} catch (Throwable t) {
logger.warning("An exception occurred when reading \"version.json\"!");
logger.warning(t);
}
} else {
logger.warning("Can't read \"version.json\"! Ignore this message if the version you start is earlier than 18w47b.");
}
super.onLoad(mixinPackage);

// This mod will remap extra classes when in the development environment.
DevEnvRemapper.initRemapper();
}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
boolean result = true;
if (mixinClassName.endsWith(".MixinIImageBuffer")) {
result = this.world_version <= 2204 && this.protocol_version <= 553; // 18w43b ~ 19w37a
} else if (mixinClassName.endsWith(".MixinLayerCape") || mixinClassName.endsWith(".MixinRenderPlayer")) {
result = this.world_version >= 2210 && this.protocol_version >= 558; // 19w41a+
} else if (mixinClassName.endsWith(".MixinSkinManager$V1")) {
result = this.world_version <= 3465 && (this.protocol_version <= 763 || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x4000008E)); // 18w43b ~ 1.20.1
} else if (mixinClassName.endsWith(".MixinSkinManager$V2") || mixinClassName.endsWith(".MixinSkinManager$1") || mixinClassName.endsWith(".MixinSkinManager$CacheKey") || mixinClassName.endsWith(".MixinSkinManager$TextureCache")) {
result = this.world_version >= 3567 && ((this.protocol_version >= 764 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000090); // 23w31a+
} else if (mixinClassName.endsWith(".MixinSkinManager$V3")) {
result = this.world_version >= 3684 && ((this.protocol_version >= 765 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x4000009D); // 23w42a+
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V1")) {
result = (this.world_version >= 2205 && this.world_version <= 2722) && ((this.protocol_version >= 554 && this.protocol_version <= 754) || (this.protocol_version >= 801 && this.protocol_version <= 803) || (this.protocol_version >= 0x40000001 && this.protocol_version <= 0x40000022)); // 19w38a ~ 1.17-rc1
} else if (mixinClassName.endsWith(".MixinThreadDownloadImageData$V2")) {
result = this.world_version >= 2723 && ((this.protocol_version >= 755 && this.protocol_version < 801) || (this.protocol_version > 803 && this.protocol_version < 0x40000001) || this.protocol_version >= 0x40000023); // 1.17-rc2+
}
logger.info("target: " + targetClassName + ", mixin: " + mixinClassName + ", result: " + result);
return result;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

// To be compatible with 0.7.11
public void preApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

// To be compatible with 0.7.11
public void postApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/customskinloader.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessWidener v2 intermediary
accessible method net/minecraft/class_2960 <init> (Ljava/lang/String;Ljava/lang/String;)V
3 changes: 2 additions & 1 deletion Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"environment": "client",
"mixins": [
"mixins.customskinloader.json"
]
],
"accessWidener": "customskinloader.accesswidener"
}
50 changes: 25 additions & 25 deletions Fabric/src/main/resources/mixins.customskinloader.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"compatibilityLevel": "JAVA_8",
"mixinPriority": 1010,
"package": "customskinloader.mixin",
"client": [
"MixinGuiPlayerTabOverlay",
"MixinIImageBuffer",
"MixinIResource",
"MixinIResourceManager",
"MixinLayerCape",
"MixinMinecraft",
"MixinRenderPlayer",
"MixinSkinManager$1",
"MixinSkinManager$CacheKey",
"MixinSkinManager$TextureCache",
"MixinSkinManager$V1",
"MixinSkinManager$V2",
"MixinSkinManager$V3",
"MixinThreadDownloadImageData$V1",
"MixinThreadDownloadImageData$V2"
],
"refmap": "mixins.customskinloader.refmap.json",
"plugin": "customskinloader.fabric.MixinConfigPlugin",
"injectors": {
"defaultRequire": 1
}
"compatibilityLevel": "JAVA_8",
"mixinPriority": 1010,
"package": "customskinloader.mixin",
"client": [
"MixinGuiPlayerTabOverlay",
"MixinIImageBuffer",
"MixinIResource",
"MixinIResourceManager",
"MixinLayerCape",
"MixinMinecraft",
"MixinRenderPlayer",
"MixinSkinManager$1",
"MixinSkinManager$CacheKey",
"MixinSkinManager$TextureCache",
"MixinSkinManager$V1",
"MixinSkinManager$V2",
"MixinSkinManager$V3",
"MixinThreadDownloadImageData$V1",
"MixinThreadDownloadImageData$V2"
],
"refmap": "mixins.customskinloader.refmap.json",
"plugin": "customskinloader.fabric.MixinConfigPlugin",
"injectors": {
"defaultRequire": 1
}
}
8 changes: 0 additions & 8 deletions Forge/Active/build.properties

This file was deleted.

15 changes: 15 additions & 0 deletions Forge/Common/src/main/java/cpw/mods/cl/JarModuleFinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cpw.mods.cl;

import java.lang.module.ModuleFinder;

import cpw.mods.jarhandling.SecureJar;

public class JarModuleFinder implements ModuleFinder {
public static JarModuleFinder of(SecureJar... jars) {
return null;
}

public static class JarModuleReference {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cpw.mods.jarhandling;

import java.nio.file.Path;

public interface SecureJar {
static SecureJar from(final Path... paths) {
return null;
}
}
13 changes: 13 additions & 0 deletions Forge/Common/src/main/java/java/lang/ModuleLayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package java.lang;

import java.lang.module.Configuration;

public class ModuleLayer {
public static ModuleLayer boot() {
return null;
}

public Configuration configuration() {
return null;
}
}
Loading

0 comments on commit 64490f1

Please sign in to comment.