From 9606d2c506214d18c7e3d6eda088ac11800a6c02 Mon Sep 17 00:00:00 2001 From: jtuc <6748724+jtuc@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:48:27 +0000 Subject: [PATCH] Hacky fix for EMI rendering Fix #2735 by doing a partial revert of the changes to GTRecipeEMICategory in 039659f I suspect this works due to some implementation detail of EmiTexture/EmiDrawContext setting z to 0 or something? I couldn't figure out the full details myself; please reject this if you know the "proper" way to fix this. --- .../emi/recipe/GTRecipeEMICategory.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java index 403c15e755..6c21d138eb 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java @@ -7,14 +7,17 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.emi.IGui2Renderable; +import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; import net.minecraft.Util; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Items; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories; +import dev.emi.emi.api.render.EmiRenderable; +import dev.emi.emi.api.render.EmiTexture; import dev.emi.emi.api.stack.EmiStack; import java.util.function.Function; @@ -26,10 +29,20 @@ public class GTRecipeEMICategory extends EmiRecipeCategory { private final GTRecipeCategory category; private GTRecipeEMICategory(GTRecipeCategory category) { - super(category.registryKey, IGui2Renderable.toDrawable(category.getIcon(), 16, 16)); + super(category.registryKey, getDrawable(category)); this.category = category; } + public static EmiRenderable getDrawable(GTRecipeCategory category) { + if (category.getIcon() instanceof ResourceTexture tex) { + return new EmiTexture(tex.imageLocation, 0, 0, 16, 16, + (int) tex.imageWidth, (int) tex.imageHeight, (int) tex.imageWidth, (int) tex.imageHeight); + } else if (category.getRecipeType().getIconSupplier() != null) + return EmiStack.of(category.getRecipeType().getIconSupplier().get()); + else + return EmiStack.of(Items.BARRIER); + } + public static void registerDisplays(EmiRegistry registry) { for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { if (!category.shouldRegisterDisplays()) continue;