Skip to content

Commit

Permalink
feat(client): 1.21.4-pre1 fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Nov 21, 2024
1 parent 7d28d99 commit 134a574
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 7 deletions.
1 change: 1 addition & 0 deletions client/1.21.4-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.4-pre1
10 changes: 9 additions & 1 deletion client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions client/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 = "<init>")
//$$ 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 = "<init>")
Expand Down
13 changes: 12 additions & 1 deletion client/src/main/kotlin/gg/essential/universal/DummyPack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ 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

//#if MC>=12005
//$$ 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.
Expand Down Expand Up @@ -46,9 +51,15 @@ object DummyPack : PackResources {
throw UnsupportedOperationException()
}

//#if MC>=12104
//$$ override fun <T : Any?> getMetadataSection(metadataSectionType: MetadataSectionType<T>): T? {
//$$ throw UnsupportedOperationException()
//$$ }
//#else
override fun <T : Any?> getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer<T>): T? {
throw UnsupportedOperationException()
}
//#endif

//#if MC>=12005
//$$ override fun location(): PackLocationInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -88,7 +93,11 @@ class PlasmoCrowdinPack(

override fun getNamespaces(packType: PackType): Set<String> = NAMESPACES

override fun <T : Any?> getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer<T>) = null
//#if MC>=12104
//$$ override fun <T : Any?> getMetadataSection(metadataSectionType: MetadataSectionType<T>): T? = null
//#else
override fun <T : Any?> getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer<T>): T? = null
//#endif

//#if MC>11902
override fun packId() = "Plasmo Crowdin resource pack"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String, Supplier<Supplier<ResourceLocation?>>> = CacheBuilder.newBuilder()
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions client/versions.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[12104]
mcVersions = ">1.21.3"
neoForgeVersion = "[21,)"

[12102]
mcVersions = ">1.21.1"
neoForgeVersion = "[21,)"
Expand Down

0 comments on commit 134a574

Please sign in to comment.