implement EMI integration

fixes #39
This commit is contained in:
rlnt 2024-02-21 15:53:04 +01:00
parent 4923dd3034
commit 60b2eb339b
No known key found for this signature in database
8 changed files with 92 additions and 1 deletions

View file

@ -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

View file

@ -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()
);
}
}
}

View file

@ -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")
}
)

View file

@ -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}"
}
}

View file

@ -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")
}

View file

@ -38,3 +38,10 @@ mandatory = false
versionRange = "[${reiVersion},)"
ordering = "BEFORE"
side = "BOTH"
[[dependencies."${modId}"]]
modId = "emi"
mandatory = false
versionRange = "[${emiVersion},)"
ordering = "BEFORE"
side = "BOTH"

View file

@ -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
)

View file

@ -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