Skip to content

Fix JEI Compat #62

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

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
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 @@ -60,7 +60,7 @@ public IGuiProperties apply(@NotNull GuiScreenWrapper guiScreen) {
@Nullable
@Override
public IRecipeTransferError transferRecipe(@NotNull ModularContainer container, @NotNull IRecipeLayout recipeLayout, @NotNull EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
ModularScreen screen = ModularScreen.getCurrent();
ModularScreen screen = container.getScreen();
if (screen instanceof JeiRecipeTransferHandler recipeTransferHandler) {
return recipeTransferHandler.transferRecipe(recipeLayout, maxTransfer, !doTransfer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public GuiScreenWrapper(ModularContainer container, ModularScreen screen) {
super(container);
this.screen = screen;
this.screen.construct(this);
container.setScreen(this.screen);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.Optional.Interface;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand All @@ -30,7 +30,7 @@

import java.util.*;

@Optional.Interface(modid = ModularUI.BOGO_SORT, iface = "com.cleanroommc.bogosorter.api.ISortableContainer")
@Interface(modid = ModularUI.BOGO_SORT, iface = "com.cleanroommc.bogosorter.api.ISortableContainer")
public class ModularContainer extends Container implements ISortableContainer {

public static ModularContainer getCurrent(EntityPlayer player) {
Expand All @@ -47,6 +47,8 @@ public static ModularContainer getCurrent(EntityPlayer player) {
private final List<ModularSlot> shiftClickSlots = new ArrayList<>();
private ContainerCustomizer containerCustomizer;

private Optional<?> optionalScreen = Optional.empty();

public ModularContainer(EntityPlayer player, PanelSyncManager panelSyncManager, String mainPanelName) {
this.player = player;
this.syncManager = new ModularSyncManager(this);
Expand All @@ -67,6 +69,17 @@ public ModularContainer(ContainerCustomizer containerCustomizer) {
this.containerCustomizer.initialize(this);
}

@SideOnly(Side.CLIENT)
public void setScreen(ModularScreen screen) {
this.optionalScreen = Optional.ofNullable(screen);
}

@Nullable
@SideOnly(Side.CLIENT)
public ModularScreen getScreen() {
return (ModularScreen) optionalScreen.orElse(null);
}

public ContainerAccessor acc() {
return (ContainerAccessor) this;
}
Expand Down