diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts index ea2de95..dea7f65 100644 --- a/Common/build.gradle.kts +++ b/Common/build.gradle.kts @@ -7,6 +7,7 @@ val junitVersion: String by project val fabricLoaderVersion: String by project val jeiVersion: String by project val reiVersion: String by project +val emiVersion: String by project plugins { id("com.github.gmazzo.buildconfig") version "4.0.4" @@ -35,6 +36,7 @@ dependencies { modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for jei plugin modCompileOnly("mezz.jei:jei-$minecraftVersion-lib:$jeiVersion") // required for jei mixin modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for rei plugin + modCompileOnly("dev.emi:emi-xplat-intermediary:$emiVersion+$minecraftVersion:api") // required for emi plugin // compile time dependencies compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer diff --git a/Common/src/main/java/com/almostreliable/unified/compat/AlmostEMI.java b/Common/src/main/java/com/almostreliable/unified/compat/AlmostEMI.java new file mode 100644 index 0000000..7b18ddb --- /dev/null +++ b/Common/src/main/java/com/almostreliable/unified/compat/AlmostEMI.java @@ -0,0 +1,68 @@ +package com.almostreliable.unified.compat; + +import com.almostreliable.unified.AlmostUnified; +import com.almostreliable.unified.AlmostUnifiedFallbackRuntime; +import com.almostreliable.unified.config.UnifyConfig; +import com.almostreliable.unified.recipe.CRTLookup; +import dev.emi.emi.api.EmiEntrypoint; +import dev.emi.emi.api.EmiInitRegistry; +import dev.emi.emi.api.EmiPlugin; +import dev.emi.emi.api.EmiRegistry; +import dev.emi.emi.api.recipe.EmiRecipe; +import dev.emi.emi.api.recipe.EmiRecipeDecorator; +import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.api.widget.WidgetHolder; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.item.ItemStack; + +@SuppressWarnings("UnstableApiUsage") +@EmiEntrypoint +public class AlmostEMI implements EmiPlugin { + + @Override + public void initialize(EmiInitRegistry registry) { + AlmostUnifiedFallbackRuntime.getInstance().reload(); + + var emiDisabled = AlmostUnified.getRuntime() + .getUnifyConfig() + .map(UnifyConfig::reiOrJeiDisabled) + .orElse(false); + if (emiDisabled) return; + + for (ItemStack item : HideHelper.createHidingList(AlmostUnified.getRuntime())) { + registry.disableStack(EmiStack.of(item)); + } + } + + @Override + public void register(EmiRegistry registry) { + registry.addRecipeDecorator(new IndicatorDecorator()); + } + + private static class IndicatorDecorator implements EmiRecipeDecorator { + + @Override + public void decorateRecipe(EmiRecipe recipe, WidgetHolder widgets) { + var recipeId = recipe.getId(); + if (recipeId == null) return; + + var link = CRTLookup.getLink(recipeId); + if (link == null) return; + + var area = new Rect2i( + recipe.getDisplayWidth() - 5, + recipe.getDisplayHeight() - 3, + RecipeIndicator.RENDER_SIZE - 1, + RecipeIndicator.RENDER_SIZE - 1 + ); + widgets.addDrawable(0, 0, 0, 0, (stack, mX, mY, delta) -> RecipeIndicator.renderIndicator(stack, area)); + widgets.addTooltipText( + RecipeIndicator.constructTooltip(link), + area.getX(), + area.getY(), + area.getWidth(), + area.getHeight() + ); + } + } +} diff --git a/Fabric/build.gradle.kts b/Fabric/build.gradle.kts index e72c5b0..0140a96 100644 --- a/Fabric/build.gradle.kts +++ b/Fabric/build.gradle.kts @@ -4,6 +4,7 @@ val fabricApiVersion: String by project val fabricRecipeViewer: String by project val jeiVersion: String by project val reiVersion: String by project +val emiVersion: String by project plugins { id("com.github.johnrengelman.shadow") version "8.1.1" @@ -36,12 +37,14 @@ dependencies { // compile time mods modCompileOnly("mezz.jei:jei-$minecraftVersion-fabric-api:$jeiVersion") // required for common jei plugin modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$reiVersion") // required for common rei plugin + modCompileOnly("dev.emi:emi-fabric:$emiVersion+$minecraftVersion:api") // required for common emi plugin // runtime dependencies modLocalRuntime( when (fabricRecipeViewer) { "jei" -> "mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion" "rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion" + "emi" -> "dev.emi:emi-fabric:$emiVersion+$minecraftVersion" else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer") } ) diff --git a/Fabric/src/main/resources/fabric.mod.json b/Fabric/src/main/resources/fabric.mod.json index a7cde67..7f2bfaa 100644 --- a/Fabric/src/main/resources/fabric.mod.json +++ b/Fabric/src/main/resources/fabric.mod.json @@ -23,6 +23,9 @@ ], "rei_client": [ "com.almostreliable.unified.compat.AlmostREI" + ], + "emi": [ + "com.almostreliable.unified.compat.AlmostEMI" ] }, "mixins": [ @@ -35,6 +38,7 @@ }, "suggests": { "jei": ">=${jeiVersion}", - "roughlyenoughitems": ">=${reiVersion}" + "roughlyenoughitems": ">=${reiVersion}", + "emi": ">=${emiVersion}" } } diff --git a/Forge/build.gradle.kts b/Forge/build.gradle.kts index 47f4f5e..0951da0 100644 --- a/Forge/build.gradle.kts +++ b/Forge/build.gradle.kts @@ -5,6 +5,7 @@ val forgeVersion: String by project val forgeRecipeViewer: String by project val jeiVersion: String by project val reiVersion: String by project +val emiVersion: String by project val extraModsPrefix = "extra-mods" @@ -56,11 +57,13 @@ dependencies { isTransitive = false // prevents breaking the forge runtime } modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for common rei plugin + modCompileOnly("dev.emi:emi-forge:$emiVersion+$minecraftVersion:api") // required for common emi plugin // runtime mods when (forgeRecipeViewer) { "jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false } "rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") + "emi" -> modLocalRuntime("dev.emi:emi-forge:$emiVersion+$minecraftVersion") else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer") } diff --git a/Forge/src/main/resources/META-INF/mods.toml b/Forge/src/main/resources/META-INF/mods.toml index 3f37e90..77a764c 100644 --- a/Forge/src/main/resources/META-INF/mods.toml +++ b/Forge/src/main/resources/META-INF/mods.toml @@ -38,3 +38,10 @@ mandatory = false versionRange = "[${reiVersion},)" ordering = "BEFORE" side = "BOTH" + +[[dependencies."${modId}"]] +modId = "emi" +mandatory = false +versionRange = "[${emiVersion},)" +ordering = "BEFORE" +side = "BOTH" diff --git a/build.gradle.kts b/build.gradle.kts index 552d94b..d281011 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ val fabricApiVersion: String by project val forgeVersion: String by project val jeiVersion: String by project val reiVersion: String by project +val emiVersion: String by project val githubRepo: String by project val githubUser: String by project @@ -74,6 +75,7 @@ subprojects { maven("https://maven.parchmentmc.org") // Parchment maven("https://maven.shedaniel.me") // REI maven("https://maven.blamejared.com/") // JEI + maven("https://maven.terraformersmc.com/") // EMI mavenLocal() } @@ -122,6 +124,7 @@ subprojects { "forgeFMLVersion" to forgeVersion.substringBefore("."), "jeiVersion" to jeiVersion, "reiVersion" to reiVersion, + "emiVersion" to emiVersion, "githubUser" to githubUser, "githubRepo" to githubRepo ) diff --git a/gradle.properties b/gradle.properties index 17e592a..25d51c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,6 +23,7 @@ parchmentVersion = 2022.11.27 # Mod Dependencies jeiVersion = 11.6.0.1012 reiVersion = 9.1.580 +emiVersion = 1.1.2 # Fabric Dependencies fabricLoaderVersion = 0.14.19