diff --git a/client/1.21.4-fabric/gradle.properties b/client/1.21.4-fabric/gradle.properties new file mode 100644 index 00000000..1e3bbc1d --- /dev/null +++ b/client/1.21.4-fabric/gradle.properties @@ -0,0 +1 @@ +essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.4-pre1 diff --git a/client/build.gradle.kts b/client/build.gradle.kts index 2b06b583..8a4fabe5 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -60,6 +60,7 @@ val shadowCommon by configurations.creating fun slibArtifact(): String { val minecraftVersion = when (platform.mcVersion) { 11904 -> "1.19.3" + 12104 -> "1.21.2" else -> platform.mcVersionStr } @@ -89,10 +90,17 @@ dependencies { 12006 -> "0.97.7+1.20.6" 12100 -> "0.100.4+1.21" 12102 -> "0.105.3+1.21.2" + 12104 -> "0.109.1+1.21.4" else -> throw GradleException("Unsupported platform $platform") } - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}") + fun fabricApiModules(vararg module: String) { + module.forEach { + modImplementation(fabricApi.module("fabric-$it", fabricApiVersion)) + } + } + + fabricApiModules("rendering-v1", "networking-api-v1", "lifecycle-events-v1", "key-binding-api-v1") if (platform.mcVersion >= 12102) { // https://github.com/lucko/fabric-permissions-api/pull/26 diff --git a/client/root.gradle.kts b/client/root.gradle.kts index f9ef6974..d4b2db72 100644 --- a/client/root.gradle.kts +++ b/client/root.gradle.kts @@ -6,6 +6,8 @@ group = "$group.client-root" preprocess { + val fabric12104 = createNode("1.21.4-fabric", 12104, "official") + val neoForge12102 = createNode("1.21.2-neoforge", 12102, "official") val fabric12102 = createNode("1.21.2-fabric", 12102, "official") @@ -37,6 +39,8 @@ preprocess { val forge11605 = createNode("1.16.5-forge", 11605, "official") val fabric11605 = createNode("1.16.5-fabric", 11605, "official") + fabric12104.link(fabric12102) + fabric12102.link(fabric12100) neoForge12102.link(neoForge12100) diff --git a/client/src/main/java/su/plo/voice/client/mixin/MixinSkinManager.java b/client/src/main/java/su/plo/voice/client/mixin/MixinSkinManager.java index df83bf30..d8e8b163 100644 --- a/client/src/main/java/su/plo/voice/client/mixin/MixinSkinManager.java +++ b/client/src/main/java/su/plo/voice/client/mixin/MixinSkinManager.java @@ -9,7 +9,6 @@ //#if MC>=12002 //$$ import com.mojang.authlib.minecraft.MinecraftSessionService; -//$$ import net.minecraft.client.renderer.texture.TextureManager; //$$ //$$ import org.spongepowered.asm.mixin.Unique; //$$ import org.spongepowered.asm.mixin.injection.At; @@ -18,6 +17,11 @@ //$$ //$$ import java.nio.file.Path; //$$ import java.util.concurrent.Executor; + +//#if MC<12104 +//$$ import net.minecraft.client.renderer.texture.TextureManager; +//#endif + //#else import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Shadow; @@ -26,7 +30,19 @@ @Mixin(SkinManager.class) public abstract class MixinSkinManager implements SkinManagerAccessor { - //#if MC>=12002 + //#if MC>=12104 + //$$ @Unique + //$$ private static File SKINS_DIRECTORY; + //$$ @Inject(at = @At("RETURN"), method = "") + //$$ private void init(Path path, MinecraftSessionService minecraftSessionService, Executor executor, CallbackInfo ci) { + //$$ SKINS_DIRECTORY = path.toFile(); + //$$ } + //$$ @NotNull + //$$ @Override + //$$ public File getSkinsCacheFolder() { + //$$ return SKINS_DIRECTORY; + //$$ } + //#elseif MC>=12002 //$$ @Unique //$$ private static File SKINS_DIRECTORY; //$$ @Inject(at = @At("RETURN"), method = "") diff --git a/client/src/main/kotlin/gg/essential/universal/DummyPack.kt b/client/src/main/kotlin/gg/essential/universal/DummyPack.kt index 22fd61cd..453bcdc2 100644 --- a/client/src/main/kotlin/gg/essential/universal/DummyPack.kt +++ b/client/src/main/kotlin/gg/essential/universal/DummyPack.kt @@ -5,7 +5,6 @@ import gg.essential.universal.shader.MCShader import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackResources import net.minecraft.server.packs.PackType -import net.minecraft.server.packs.metadata.MetadataSectionSerializer import net.minecraft.server.packs.resources.IoSupplier import java.io.InputStream @@ -13,6 +12,12 @@ import java.io.InputStream //$$ import net.minecraft.server.packs.PackLocationInfo //#endif +//#if MC>=12104 +//$$ import net.minecraft.server.packs.metadata.MetadataSectionType +//#else +import net.minecraft.server.packs.metadata.MetadataSectionSerializer +//#endif + /** * A dummy resource pack for use in [MCShader], since the [Resource] constructor * on 1.19.3+ requires a [PackResources] instead of a String name. @@ -46,9 +51,15 @@ object DummyPack : PackResources { throw UnsupportedOperationException() } + //#if MC>=12104 + //$$ override fun getMetadataSection(metadataSectionType: MetadataSectionType): T? { + //$$ throw UnsupportedOperationException() + //$$ } + //#else override fun getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer): T? { throw UnsupportedOperationException() } + //#endif //#if MC>=12005 //$$ override fun location(): PackLocationInfo { diff --git a/client/src/main/kotlin/su/plo/voice/client/crowdin/PlasmoCrowdinPack.kt b/client/src/main/kotlin/su/plo/voice/client/crowdin/PlasmoCrowdinPack.kt index 95158a46..6e4022e8 100644 --- a/client/src/main/kotlin/su/plo/voice/client/crowdin/PlasmoCrowdinPack.kt +++ b/client/src/main/kotlin/su/plo/voice/client/crowdin/PlasmoCrowdinPack.kt @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableSet import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackResources import net.minecraft.server.packs.PackType -import net.minecraft.server.packs.metadata.MetadataSectionSerializer import java.io.File import java.io.InputStream @@ -20,6 +19,12 @@ import net.minecraft.server.packs.resources.IoSupplier //$$ import java.util.function.Predicate //#endif +//#if MC>=12104 +//$$ import net.minecraft.server.packs.metadata.MetadataSectionType +//#else +import net.minecraft.server.packs.metadata.MetadataSectionSerializer +//#endif + class PlasmoCrowdinPack( private val crowdinFolder: File ) : PackResources { @@ -88,7 +93,11 @@ class PlasmoCrowdinPack( override fun getNamespaces(packType: PackType): Set = NAMESPACES - override fun getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer) = null + //#if MC>=12104 + //$$ override fun getMetadataSection(metadataSectionType: MetadataSectionType): T? = null + //#else + override fun getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer): T? = null + //#endif //#if MC>11902 override fun packId() = "Plasmo Crowdin resource pack" diff --git a/client/src/main/kotlin/su/plo/voice/client/render/cape/DeveloperCapeManager.kt b/client/src/main/kotlin/su/plo/voice/client/render/cape/DeveloperCapeManager.kt index 19fbf82e..331ececd 100644 --- a/client/src/main/kotlin/su/plo/voice/client/render/cape/DeveloperCapeManager.kt +++ b/client/src/main/kotlin/su/plo/voice/client/render/cape/DeveloperCapeManager.kt @@ -6,7 +6,6 @@ import com.google.common.cache.CacheBuilder import com.google.common.hash.Hashing import com.mojang.authlib.minecraft.MinecraftProfileTexture import net.minecraft.client.Minecraft -import net.minecraft.client.renderer.texture.HttpTexture import net.minecraft.resources.ResourceLocation import su.plo.lib.mod.client.ResourceLocationUtil import su.plo.lib.mod.client.render.texture.ModPlayerSkins @@ -22,6 +21,12 @@ import java.util.function.Supplier //$$ import net.minecraft.client.resources.PlayerSkin //#endif +//#if MC>=12104 +//$$ import net.minecraft.client.renderer.texture.SkinTextureDownloader +//#else +import net.minecraft.client.renderer.texture.HttpTexture +//#endif + object DeveloperCapeManager { private val loadedCapes: Cache>> = CacheBuilder.newBuilder() @@ -93,10 +98,22 @@ object DeveloperCapeManager { capeFile.delete() } + //#if MC>=12104 + //$$ try { + //$$ SkinTextureDownloader.downloadAndRegisterSkin( + //$$ capeLocation, + //$$ capeFile.toPath(), + //$$ texture.url, + //$$ false + //$$ ).get() + //$$ } catch (ignored: Exception) { + //$$ } + //#else Minecraft.getInstance().textureManager.register( capeLocation, HttpTexture(capeFile, texture.url, ModPlayerSkins.getDefaultSkin(UUID.randomUUID()), false) {} ) + //#endif capeLocation } diff --git a/client/versions.toml b/client/versions.toml index 2889c47f..1f5f85be 100644 --- a/client/versions.toml +++ b/client/versions.toml @@ -1,3 +1,7 @@ +[12104] +mcVersions = ">1.21.3" +neoForgeVersion = "[21,)" + [12102] mcVersions = ">1.21.1" neoForgeVersion = "[21,)"