From 47363fcf928a5288f50ad1df0956af9d83c29995 Mon Sep 17 00:00:00 2001 From: Benonardo Date: Thu, 2 Dec 2021 18:16:58 +0100 Subject: [PATCH] Updated to 1.18 --- build.gradle | 11 ++++------ gradle.properties | 10 +++------ gradle/wrapper/gradle-wrapper.properties | 2 +- ...lientBuiltinResourcePackProviderMixin.java | 21 +++++++++++-------- .../mixin/ResourcePackProfileAccessor.java | 16 ++++++++++++++ src/main/resources/spu.mixins.json | 5 +++-- 6 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 src/main/java/me/jaackson/spu/mixin/ResourcePackProfileAccessor.java diff --git a/build.gradle b/build.gradle index ca6988f..e41d9c3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '0.5-SNAPSHOT' + id 'fabric-loom' version '0.10-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 archivesBaseName = project.archives_base_name version = project.mod_version @@ -27,10 +27,7 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } + it.options.release = 17 } java { diff --git a/gradle.properties b/gradle.properties index f945918..0faab75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,11 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16.2 - yarn_mappings=1.16.2+build.47 - loader_version=0.11.1 + minecraft_version=1.18 + yarn_mappings=1.18+build.1 + loader_version=0.12.8 # Mod Properties mod_version = 1.0 maven_group = me.jaackson archives_base_name = spu - -# Dependencies - # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.29.4+1.16 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/me/jaackson/spu/mixin/ClientBuiltinResourcePackProviderMixin.java b/src/main/java/me/jaackson/spu/mixin/ClientBuiltinResourcePackProviderMixin.java index eba60ea..d14c950 100644 --- a/src/main/java/me/jaackson/spu/mixin/ClientBuiltinResourcePackProviderMixin.java +++ b/src/main/java/me/jaackson/spu/mixin/ClientBuiltinResourcePackProviderMixin.java @@ -1,23 +1,26 @@ package me.jaackson.spu.mixin; import net.minecraft.client.resource.ClientBuiltinResourcePackProvider; -import net.minecraft.resource.ResourcePack; -import net.minecraft.resource.ResourcePackCompatibility; import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourcePackSource; -import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.function.Supplier; +import java.io.File; +import java.util.concurrent.CompletableFuture; @Mixin(ClientBuiltinResourcePackProvider.class) public class ClientBuiltinResourcePackProviderMixin { - - @Redirect(at = @At("NEW"), method = "loadServerPack") - private ResourcePackProfile unlockServerPack(String name, boolean alwaysEnabled, Supplier packFactory, Text displayName, Text description, ResourcePackCompatibility compatibility, ResourcePackProfile.InsertionPosition direction, boolean pinned, ResourcePackSource source) { - return new ResourcePackProfile(name, alwaysEnabled, packFactory, displayName, description, compatibility, direction, false, source); + + @Shadow private @Nullable ResourcePackProfile serverContainer; + + @Inject(at = @At("TAIL"), method = "loadServerPack") + private void unlockServerPack(File packZip, ResourcePackSource packSource, CallbackInfoReturnable> cir) { + this.serverContainer = new ResourcePackProfile(serverContainer.getName(), serverContainer.isAlwaysEnabled(), ((ResourcePackProfileAccessor)serverContainer).accessPackFactory(), serverContainer.getDisplayName(), serverContainer.getDescription(), serverContainer.getCompatibility(), serverContainer.getInitialPosition(), false, serverContainer.getSource()); } } \ No newline at end of file diff --git a/src/main/java/me/jaackson/spu/mixin/ResourcePackProfileAccessor.java b/src/main/java/me/jaackson/spu/mixin/ResourcePackProfileAccessor.java new file mode 100644 index 0000000..a3a5bc1 --- /dev/null +++ b/src/main/java/me/jaackson/spu/mixin/ResourcePackProfileAccessor.java @@ -0,0 +1,16 @@ +package me.jaackson.spu.mixin; + +import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourcePackProfile; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.function.Supplier; + +@Mixin(ResourcePackProfile.class) +public interface ResourcePackProfileAccessor { + + @Accessor("packFactory") + Supplier accessPackFactory(); + +} diff --git a/src/main/resources/spu.mixins.json b/src/main/resources/spu.mixins.json index 049fb90..466f611 100644 --- a/src/main/resources/spu.mixins.json +++ b/src/main/resources/spu.mixins.json @@ -2,9 +2,10 @@ "required": true, "minVersion": "0.8", "package": "me.jaackson.spu.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_17", "client": [ - "ClientBuiltinResourcePackProviderMixin" + "ClientBuiltinResourcePackProviderMixin", + "ResourcePackProfileAccessor" ], "injectors": { "defaultRequire": 1