Skip to content

Commit 3295c66

Browse files
committed
jei -> recipe viewer
1 parent 7d7293a commit 3295c66

27 files changed

+507
-477
lines changed

src/main/java/com/cleanroommc/modularui/api/IMuiScreen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ default void handleDrawBackground(int tint, IntConsumer drawFunction) {
6565
drawFunction.accept(tint);
6666
}
6767
ClientScreenHandler.drawDarkBackground(getGuiScreen(), tint);
68-
// after this JEI will draw itself
69-
// for some reason JEI is too stupid to set up opengl properly
70-
// without this (enableTexture2D() specifically) every item in JEI will be texture less (white)
68+
// after this recipe viewer will draw itself
69+
// for some reason recipe viewer is too stupid to set up opengl properly
70+
// without this (enableTexture2D() specifically) every item in recipe viewer will be texture less (white)
7171
Platform.setupDrawTex();
7272
}
7373

src/main/java/com/cleanroommc/modularui/api/JeiSettings.java

Lines changed: 0 additions & 122 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package com.cleanroommc.modularui.api;
2+
3+
import com.cleanroommc.modularui.api.widget.IWidget;
4+
import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerGhostIngredientSlot;
5+
import com.cleanroommc.modularui.screen.ModularScreen;
6+
7+
import org.jetbrains.annotations.ApiStatus;
8+
9+
import java.awt.*;
10+
11+
/**
12+
* Keeps track of everything related to recipe viewer in a Modular GUI. Recipe viewer is a mod like JEI, NEI and EMI.
13+
* By default, recipe viewer is disabled in client only GUIs.
14+
* This class can be safely interacted with even when recipe viewer is not installed.
15+
*/
16+
@ApiStatus.NonExtendable
17+
public interface RecipeViewerSettings {
18+
19+
/**
20+
* Force recipe viewer to be enabled
21+
*/
22+
void enableRecipeViewer();
23+
24+
/**
25+
* Force recipe viewer to be disabled
26+
*/
27+
void disableRecipeViewer();
28+
29+
/**
30+
* Only enable recipe viewer in synced GUIs
31+
*/
32+
void defaultRecipeViewerState();
33+
34+
/**
35+
* Checks if recipe viewer is enabled for a given screen
36+
*
37+
* @param screen modular screen
38+
* @return true if jei is enabled
39+
*/
40+
boolean isRecipeViewerEnabled(ModularScreen screen);
41+
42+
/**
43+
* Adds an exclusion zone. Recipe viewer will always try to avoid exclusion zones. <br>
44+
* <b>If a widgets wishes to have an exclusion zone it should use {@link #addRecipeViewerExclusionArea(IWidget)}!</b>
45+
*
46+
* @param area exclusion area
47+
*/
48+
void addRecipeViewerExclusionArea(Rectangle area);
49+
50+
/**
51+
* Removes an exclusion zone.
52+
*
53+
* @param area exclusion area to remove (must be the same instance)
54+
*/
55+
void removeRecipeViewerExclusionArea(Rectangle area);
56+
57+
/**
58+
* Adds an exclusion zone of a widget. Recipe viewer will always try to avoid exclusion zones. <br>
59+
* Useful when a widget is outside its panel.
60+
*
61+
* @param area widget
62+
*/
63+
void addRecipeViewerExclusionArea(IWidget area);
64+
65+
/**
66+
* Removes a widget exclusion area.
67+
*
68+
* @param area widget
69+
*/
70+
void removeRecipeViewerExclusionArea(IWidget area);
71+
72+
/**
73+
* Adds a recipe viewer ghost slots. Ghost slots can display an ingredient, but the ingredient does not really exist.
74+
* By calling this method users will be able to drag ingredients from recipe viewer into the slot.
75+
*
76+
* @param slot slot widget
77+
* @param <W> slot widget type
78+
*/
79+
<W extends IWidget & RecipeViewerGhostIngredientSlot<?>> void addRecipeViewerGhostIngredientSlot(W slot);
80+
81+
/**
82+
* Removes a recipe viewer ghost slot.
83+
*
84+
* @param slot slot widget
85+
* @param <W> slot widget type
86+
*/
87+
<W extends IWidget & RecipeViewerGhostIngredientSlot<?>> void removeRecipeViewerGhostIngredientSlot(W slot);
88+
89+
RecipeViewerSettings DUMMY = new RecipeViewerSettings() {
90+
@Override
91+
public void enableRecipeViewer() {}
92+
93+
@Override
94+
public void disableRecipeViewer() {}
95+
96+
@Override
97+
public void defaultRecipeViewerState() {}
98+
99+
@Override
100+
public boolean isRecipeViewerEnabled(ModularScreen screen) {
101+
return false;
102+
}
103+
104+
@Override
105+
public void addRecipeViewerExclusionArea(Rectangle area) {}
106+
107+
@Override
108+
public void removeRecipeViewerExclusionArea(Rectangle area) {}
109+
110+
@Override
111+
public void addRecipeViewerExclusionArea(IWidget area) {}
112+
113+
@Override
114+
public void removeRecipeViewerExclusionArea(IWidget area) {}
115+
116+
@Override
117+
public <W extends IWidget & RecipeViewerGhostIngredientSlot<?>> void addRecipeViewerGhostIngredientSlot(W slot) {}
118+
119+
@Override
120+
public <W extends IWidget & RecipeViewerGhostIngredientSlot<?>> void removeRecipeViewerGhostIngredientSlot(W slot) {}
121+
};
122+
}

src/main/java/com/cleanroommc/modularui/factory/ClientGUI.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.cleanroommc.modularui.factory;
22

33
import com.cleanroommc.modularui.api.MCHelper;
4-
import com.cleanroommc.modularui.screen.JeiSettingsImpl;
54
import com.cleanroommc.modularui.screen.ModularContainer;
65
import com.cleanroommc.modularui.screen.ModularScreen;
6+
import com.cleanroommc.modularui.screen.RecipeViewerSettingsImpl;
77
import com.cleanroommc.modularui.screen.UISettings;
88

99
import net.minecraft.client.gui.GuiScreen;
@@ -27,7 +27,7 @@ private ClientGUI() {
2727
}
2828

2929
/**
30-
* Opens a modular screen on the next client tick with default jei settings.
30+
* Opens a modular screen on the next client tick with default recipe viewer settings.
3131
*
3232
* @param screen new modular screen
3333
*/
@@ -36,18 +36,18 @@ public static void open(@NotNull ModularScreen screen) {
3636
}
3737

3838
/**
39-
* Opens a modular screen on the next client tick with custom jei settings.
39+
* Opens a modular screen on the next client tick with custom recipe viewer settings.
4040
* It needs to be opened in next tick, because we might break the current GUI if we open it now.
4141
*
42-
* @param screen new modular screen
43-
* @param jeiSettings custom jei settings
42+
* @param screen new modular screen
43+
* @param recipeViewerSettings custom recipe viewer settings
4444
*/
45-
public static void open(@NotNull ModularScreen screen, @NotNull JeiSettingsImpl jeiSettings) {
46-
GuiManager.openScreen(screen, new UISettings(jeiSettings));
45+
public static void open(@NotNull ModularScreen screen, @NotNull RecipeViewerSettingsImpl recipeViewerSettings) {
46+
GuiManager.openScreen(screen, new UISettings(recipeViewerSettings));
4747
}
4848

4949
/**
50-
* Opens a modular screen on the next client tick with custom jei settings.
50+
* Opens a modular screen on the next client tick with custom recipe viewer settings.
5151
* It needs to be opened in next tick, because we might break the current GUI if we open it now.
5252
*
5353
* @param screen new modular screen
@@ -60,21 +60,21 @@ public static void open(@NotNull ModularScreen screen, @Nullable Supplier<Modula
6060
}
6161

6262
/**
63-
* Opens a modular screen on the next client tick with custom jei settings.
63+
* Opens a modular screen on the next client tick with custom recipe viewer settings.
6464
* It needs to be opened in next tick, because we might break the current GUI if we open it now.
6565
*
66-
* @param screen new modular screen
67-
* @param jeiSettings custom jei settings
68-
* @param container custom container
66+
* @param screen new modular screen
67+
* @param recipeViewerSettings custom recipe viewer settings
68+
* @param container custom container
6969
*/
70-
public static void open(@NotNull ModularScreen screen, @NotNull JeiSettingsImpl jeiSettings, @Nullable Supplier<ModularContainer> container) {
71-
UISettings settings = new UISettings(jeiSettings);
70+
public static void open(@NotNull ModularScreen screen, @NotNull RecipeViewerSettingsImpl recipeViewerSettings, @Nullable Supplier<ModularContainer> container) {
71+
UISettings settings = new UISettings(recipeViewerSettings);
7272
settings.customContainer(container);
7373
GuiManager.openScreen(screen, settings);
7474
}
7575

7676
/**
77-
* Opens a modular screen on the next client tick with custom jei settings.
77+
* Opens a modular screen on the next client tick with custom recipe viewer settings.
7878
* It needs to be opened in next tick, because we might break the current GUI if we open it now.
7979
*
8080
* @param screen new modular screen

src/main/java/com/cleanroommc/modularui/factory/GuiManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.cleanroommc.modularui.factory;
22

33
import com.cleanroommc.modularui.api.IMuiScreen;
4-
import com.cleanroommc.modularui.api.JeiSettings;
54
import com.cleanroommc.modularui.api.MCHelper;
5+
import com.cleanroommc.modularui.api.RecipeViewerSettings;
66
import com.cleanroommc.modularui.api.UIFactory;
77
import com.cleanroommc.modularui.network.NetworkHandler;
88
import com.cleanroommc.modularui.network.packets.OpenGuiPacket;
@@ -72,7 +72,7 @@ public static <T extends GuiData> void open(@NotNull UIFactory<T> factory, @NotN
7272
if (player instanceof FakePlayer || openedContainers.contains(player)) return;
7373
openedContainers.add(player);
7474
// create panel, collect sync handlers and create container
75-
UISettings settings = new UISettings(JeiSettings.DUMMY);
75+
UISettings settings = new UISettings(RecipeViewerSettings.DUMMY);
7676
settings.defaultCanInteractWith(factory, guiData);
7777
PanelSyncManager syncManager = new PanelSyncManager(false);
7878
ModularPanel panel = factory.createPanel(guiData, syncManager, settings);

src/main/java/com/cleanroommc/modularui/holoui/HoloUI.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.cleanroommc.modularui.holoui;
22

3-
import com.cleanroommc.modularui.screen.JeiSettingsImpl;
43
import com.cleanroommc.modularui.screen.ModularScreen;
5-
64
import com.cleanroommc.modularui.screen.UISettings;
75

86
import net.minecraft.client.Minecraft;
@@ -84,7 +82,7 @@ public Builder plane(Plane3D plane) {
8482

8583
public void open(ModularScreen screen) {
8684
UISettings settings = new UISettings();
87-
settings.getJeiSettings().defaultJei();
85+
settings.getRecipeViewerSettings().defaultRecipeViewerState();
8886
screen.getContext().setSettings(settings);
8987
HoloScreenEntity holoScreenEntity = new HoloScreenEntity(Minecraft.getMinecraft().world, this.plane3D);
9088
holoScreenEntity.setPosition(this.x, this.y, this.z);

0 commit comments

Comments
 (0)