-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JEI plugin to tell it about the sidebars in our computer/robot UIs.
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/li/cil/oc2/common/integration/jei/ExtraGuiAreasJEIPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
|
||
package li.cil.oc2.common.integration.jei; | ||
|
||
import li.cil.oc2.api.API; | ||
import li.cil.oc2.client.gui.AbstractMachineInventoryScreen; | ||
import li.cil.oc2.client.gui.AbstractMachineTerminalScreen; | ||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.JeiPlugin; | ||
import mezz.jei.api.gui.handlers.IGuiContainerHandler; | ||
import mezz.jei.api.registration.IGuiHandlerRegistration; | ||
import net.minecraft.client.renderer.Rect2i; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.List; | ||
|
||
@JeiPlugin | ||
public class ExtraGuiAreasJEIPlugin implements IModPlugin { | ||
@Override | ||
public ResourceLocation getPluginUid() { | ||
return new ResourceLocation(API.MOD_ID, "extra_gui_areas"); | ||
} | ||
|
||
@Override | ||
public void registerGuiHandlers(final IGuiHandlerRegistration registration) { | ||
registration.addGenericGuiContainerHandler(AbstractMachineInventoryScreen.class, new AbstractMachineInventoryScreenGuiContainerHandler()); | ||
registration.addGenericGuiContainerHandler(AbstractMachineTerminalScreen.class, new AbstractMachineTerminalScreenGuiContainerHandler()); | ||
} | ||
|
||
private static final class AbstractMachineInventoryScreenGuiContainerHandler implements IGuiContainerHandler<AbstractMachineInventoryScreen<?>> { | ||
@Override | ||
public List<Rect2i> getGuiExtraAreas(final AbstractMachineInventoryScreen<?> screen) { | ||
return screen.getExtraAreas(); | ||
} | ||
} | ||
|
||
private static final class AbstractMachineTerminalScreenGuiContainerHandler implements IGuiContainerHandler<AbstractMachineTerminalScreen<?>> { | ||
@Override | ||
public List<Rect2i> getGuiExtraAreas(final AbstractMachineTerminalScreen<?> screen) { | ||
return screen.getExtraAreas(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/li/cil/oc2/common/integration/jei/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
|
||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package li.cil.oc2.common.integration.jei; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |