Skip to content

Commit

Permalink
add jei support for output slot
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude committed Jun 9, 2024
1 parent c55fb25 commit bd4e0a4
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gregtech.common.mui.widget.workbench;

import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider;

import gregtech.api.util.GTLog;
import gregtech.client.utils.RenderUtil;
import gregtech.common.metatileentities.storage.CraftingRecipeLogic;
Expand Down Expand Up @@ -29,14 +31,15 @@
import com.cleanroommc.modularui.widgets.slot.SlotGroup;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class CraftingOutputSlot extends Widget<CraftingOutputSlot> implements Interactable {
public class CraftingOutputSlot extends Widget<CraftingOutputSlot> implements Interactable, JeiIngredientProvider {

private final CraftingSlotSH syncHandler;

Expand Down Expand Up @@ -86,6 +89,11 @@ public void drawForeground(GuiContext context) {
}
}

@Override
public @Nullable ItemStack getIngredient() {
return this.syncHandler.getOutputStack();
}

protected static class CraftingSlotSH extends SyncHandler {

private final CraftingRecipeLogic recipeLogic;
Expand Down Expand Up @@ -139,7 +147,10 @@ public void quickTransfer(ItemStack fromStack) {
for (ModularSlot toSlot : this.shiftClickSlots) {
if (toSlot.isEnabled() && toSlot.isItemValid(fromStack)) {
ItemStack toStack = toSlot.getStack().copy();
if (toStack.isEmpty()) emptySlots.add(toSlot);
if (toStack.isEmpty()) {
emptySlots.add(toSlot);
continue;
}

if (ItemHandlerHelper.canItemStacksStack(fromStack, toStack)) {
int j = toStack.getCount() + fromStack.getCount();
Expand Down

0 comments on commit bd4e0a4

Please sign in to comment.