Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky fix for EMI recipe tree rendering #2736

Open
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading