diff --git a/src/main/java/appeng/integration/modules/emi/AbstractRecipeHandler.java b/src/main/java/appeng/integration/modules/emi/AbstractRecipeHandler.java index dd97c7372a3..ba17289317b 100644 --- a/src/main/java/appeng/integration/modules/emi/AbstractRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/emi/AbstractRecipeHandler.java @@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.Slot; @@ -20,20 +21,24 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; +import dev.emi.emi.api.recipe.EmiPlayerInventory; import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories; import dev.emi.emi.api.recipe.handler.EmiCraftContext; import dev.emi.emi.api.recipe.handler.StandardRecipeHandler; import dev.emi.emi.api.stack.EmiIngredient; +import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.widget.Bounds; import dev.emi.emi.api.widget.SlotWidget; import dev.emi.emi.api.widget.Widget; import appeng.api.stacks.AEKey; +import appeng.api.stacks.GenericStack; import appeng.integration.modules.itemlists.EncodingHelper; import appeng.integration.modules.itemlists.TransferHelper; import appeng.menu.AEBaseMenu; import appeng.menu.SlotSemantics; +import appeng.menu.me.common.MEStorageMenu; import appeng.menu.me.items.CraftingTermMenu; abstract class AbstractRecipeHandler implements StandardRecipeHandler { @@ -68,6 +73,27 @@ public List getCraftingSlots(T menu) { return null; } + @Override + public EmiPlayerInventory getInventory(AbstractContainerScreen screen) { + var list = new ArrayList(); + + for (Slot slot : getInputSources(screen.getMenu())) { + list.add(EmiStack.of(slot.getItem())); + } + + if (screen.getMenu() instanceof MEStorageMenu menu) { + var repo = menu.getClientRepo(); + + if (repo != null) { + for (var entry : repo.getAllEntries()) { + list.add(EmiStackHelper.toEmiStack(new GenericStack(entry.getWhat(), entry.getStoredAmount()))); + } + } + } + + return new EmiPlayerInventory(list); + } + @Override public boolean canCraft(EmiRecipe recipe, EmiCraftContext context) { if (context.getType() == EmiCraftContext.Type.FILL_BUTTON) { diff --git a/src/main/java/appeng/integration/modules/emi/EmiUseCraftingRecipeHandler.java b/src/main/java/appeng/integration/modules/emi/EmiUseCraftingRecipeHandler.java index 6557f1ef1f7..43306d32953 100644 --- a/src/main/java/appeng/integration/modules/emi/EmiUseCraftingRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/emi/EmiUseCraftingRecipeHandler.java @@ -1,14 +1,11 @@ package appeng.integration.modules.emi; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Optional; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.Ingredient; @@ -17,14 +14,11 @@ import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapedRecipePattern; -import dev.emi.emi.api.recipe.EmiPlayerInventory; import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.stack.EmiStack; -import appeng.api.stacks.GenericStack; import appeng.core.localization.ItemModText; import appeng.integration.modules.itemlists.CraftingHelper; -import appeng.menu.me.common.GridInventoryEntry; import appeng.menu.me.items.CraftingTermMenu; /** @@ -47,25 +41,6 @@ public EmiUseCraftingRecipeHandler(Class containerClass) { super(containerClass); } - @Override - public EmiPlayerInventory getInventory(AbstractContainerScreen screen) { - List list = new ArrayList<>(); - - for (Slot slot : getInputSources(screen.getMenu())) { - list.add(EmiStack.of(slot.getItem())); - } - - var repo = screen.getMenu().getClientRepo(); - - if (repo != null) { - for (GridInventoryEntry entry : repo.getAllEntries()) { - list.add(EmiStackHelper.toEmiStack(new GenericStack(entry.getWhat(), entry.getStoredAmount()))); - } - } - - return new EmiPlayerInventory(list); - } - @Override protected Result transferRecipe(T menu, RecipeHolder holder, EmiRecipe emiRecipe, boolean doTransfer) {