From 6a18565322380c44bbc981c2a4967fd3c0b266fc Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Fri, 25 Oct 2024 01:11:39 -0300 Subject: [PATCH] Add JEI support (fixes #6) --- build.gradle.kts | 15 +++++++++++--- gradle.properties | 2 ++ gradle/libs.versions.toml | 9 ++++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../jei/PlayerRecipeTransferHandlerMixin.java | 20 +++++++++++++++++++ .../ennuis_bigger_gambiarra.mixins.json | 3 ++- 6 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/main/java/io/github/ennuil/ennuis_bigger_gambiarra/mixin/jei/PlayerRecipeTransferHandlerMixin.java diff --git a/build.gradle.kts b/build.gradle.kts index b1b301b..0071b0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,7 @@ loom { repositories { maven(uri("https://maven.terraformersmc.com/releases/")) + maven(uri("https://maven.blamejared.com/")) exclusiveContent { forRepository { maven(uri("https://api.modrinth.com/maven")) @@ -40,11 +41,15 @@ dependencies { modCompileOnly(libs.ennuis.bigger.inventories) modLocalRuntime(libs.ennuis.bigger.inventories) + modCompileOnly(libs.jei) + //modLocalRuntime(libs.jei) + modCompileOnly(libs.emi) modLocalRuntime(libs.emi) } -tasks.processResources { +tasks.named("processResources").configure { + var version = project.version inputs.property("version", version) filesMatching("fabric.mod.json") { @@ -67,9 +72,13 @@ java { } // If you plan to use a different file for the license, don't forget to change the file name here! -tasks.jar { +tasks.named("jar").configure { + var name = project.name + inputs.files("LICENSE.md") + inputs.property("name", name) + from("LICENSE.md") { - rename { "${it}_${base.archivesName.get()}" } + rename { "LICENSE_${name}.md" } } } diff --git a/gradle.properties b/gradle.properties index bf0a8f2..d70653b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,8 @@ org.gradle.jvmargs = -Xmx1G org.gradle.parallel = true org.gradle.caching = true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true kotlin.experimental.tryK2=true # Mod versioning is managed at build.gradle.kts diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a42a62f..cbc3927 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,12 +3,14 @@ minecraft = "1.21.1" quilt_mappings = "1.21.1+build.3" -quilt_loom = "1.7.4" -quilt_loader = "0.26.4" +quilt_loom = "1.8.4" +quilt_loader = "0.27.0-beta.1" -fabric_api = "0.105.0+1.21.1" +fabric_api = "0.106.0+1.21.1" ennuis_bigger_inventories = "0.2.0-beta.3+1.21" +# Keep your friends closer and keep your rivals uh, close to each other??? emi = "1.1.16+1.21.1" +jei = "19.21.0.246" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } @@ -18,6 +20,7 @@ quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loade fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" } ennuis_bigger_inventories = { module = "maven.modrinth:ennuis_bigger_inventories", version.ref = "ennuis_bigger_inventories" } emi = { module = "dev.emi:emi-fabric", version.ref = "emi" } +jei = { module = "mezz.jei:jei-1.21.1-fabric", version.ref = "jei" } [bundles] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72..19d1095 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/io/github/ennuil/ennuis_bigger_gambiarra/mixin/jei/PlayerRecipeTransferHandlerMixin.java b/src/main/java/io/github/ennuil/ennuis_bigger_gambiarra/mixin/jei/PlayerRecipeTransferHandlerMixin.java new file mode 100644 index 0000000..eec2900 --- /dev/null +++ b/src/main/java/io/github/ennuil/ennuis_bigger_gambiarra/mixin/jei/PlayerRecipeTransferHandlerMixin.java @@ -0,0 +1,20 @@ +package io.github.ennuil.ennuis_bigger_gambiarra.mixin.jei; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; +import io.github.ennuil.ennuis_bigger_inventories.api.HackjobKit; +import mezz.jei.library.transfer.BasicRecipeTransferInfo; +import net.minecraft.screen.ScreenHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(BasicRecipeTransferInfo.class) +public abstract class PlayerRecipeTransferHandlerMixin { + @ModifyExpressionValue(method = "getInventorySlots", at = @At(value = "FIELD", target = "Lmezz/jei/library/transfer/BasicRecipeTransferInfo;inventorySlotCount:I")) + private int modifySlotEnd(int original, @Local ScreenHandler screenHandler) { + // This hackjob is generic enough to affect everything that's needed but it might be overreaching! + // I recommend EMI for a better experience, but if you really want JEI, I guess we have this ticking time bomb + // Do *not* point fingers to JEI's mod authors!!! I'm the one doing the gambiarra in the first place! + return original == 36 && HackjobKit.isTenfoursized() ? 40 : original; + } +} diff --git a/src/main/resources/ennuis_bigger_gambiarra.mixins.json b/src/main/resources/ennuis_bigger_gambiarra.mixins.json index a7a5b77..5a3391f 100644 --- a/src/main/resources/ennuis_bigger_gambiarra.mixins.json +++ b/src/main/resources/ennuis_bigger_gambiarra.mixins.json @@ -12,7 +12,8 @@ "emi.accessors.AbstractFurnaceScreenHandlerAccessor", "emi.accessors.CraftingScreenHandlerAccessor", "emi.accessors.PlayerScreenHandlerAccessor", - "emi.accessors.StonecutterScreenHandlerAccessor" + "emi.accessors.StonecutterScreenHandlerAccessor", + "jei.PlayerRecipeTransferHandlerMixin" ], "injectors": { "defaultRequire": 1