Skip to content

Commit 0f36e94

Browse files
authored
Merge pull request #931 from shedaniel/feature/rei_8.3
REI 8.3
2 parents ce443f1 + e52260b commit 0f36e94

File tree

200 files changed

+7704
-1021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+7704
-1021
lines changed

api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java

+41-8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ static ClientHelper getInstance() {
7474
*/
7575
boolean tryCheatingEntry(EntryStack<?> stack);
7676

77+
/**
78+
* Tries to cheat stack into the given slot.
79+
*
80+
* @param stack the stack to cheat in
81+
* @param hotbarSlotId the hotbar slot id
82+
* @return whether it failed
83+
*/
84+
boolean tryCheatingEntryTo(EntryStack<?> stack, int hotbarSlotId);
85+
7786
/**
7887
* Gets the mod from an item
7988
*
@@ -92,7 +101,7 @@ default String getModFromItem(Item item) {
92101
void sendDeletePacket();
93102

94103
/**
95-
* Gets the formatted mod from an item
104+
* Returns the formatted mod from an item
96105
*
97106
* @param item the item to find
98107
* @return the mod name with blue and italic formatting
@@ -105,7 +114,7 @@ default Component getFormattedModFromItem(Item item) {
105114
}
106115

107116
/**
108-
* Gets the formatted mod from an identifier
117+
* Returns the formatted mod from an identifier
109118
*
110119
* @param identifier the identifier to find
111120
* @return the mod name with blue and italic formatting
@@ -118,18 +127,25 @@ default Component getFormattedModFromIdentifier(ResourceLocation identifier) {
118127
}
119128

120129
/**
121-
* Gets the mod from a modid
130+
* Returns the mod from a modid
122131
*
123-
* @param modid the modid of the mod
132+
* @param modId the modid of the mod
124133
* @return the mod name with blue and italic formatting
125134
*/
126-
default Component getFormattedModFromModId(String modid) {
127-
String mod = getModFromModId(modid);
135+
default Component getFormattedModFromModId(String modId) {
136+
String mod = getModFromModId(modId);
128137
if (mod.isEmpty())
129138
return NarratorChatListener.NO_TITLE;
130139
return new TextComponent(mod).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC);
131140
}
132141

142+
/**
143+
* Appends the formatted mod to the list of tooltip components.
144+
*
145+
* @param components the list of tooltip components
146+
* @param modId the modid of the mod
147+
* @return the list of tooltip components
148+
*/
133149
default List<Component> appendModIdToTooltips(List<Component> components, String modId) {
134150
final String modName = ClientHelper.getInstance().getModFromModId(modId);
135151
boolean alreadyHasMod = false;
@@ -143,10 +159,16 @@ default List<Component> appendModIdToTooltips(List<Component> components, String
143159
return components;
144160
}
145161

162+
/**
163+
* Appends the formatted mod to the tooltip.
164+
*
165+
* @param components the tooltip
166+
* @param modId the modid of the mod
167+
*/
146168
void appendModIdToTooltips(Tooltip components, String modId);
147169

148170
/**
149-
* Gets the mod from an identifier
171+
* Returns the mod from an identifier
150172
*
151173
* @param identifier the identifier to find
152174
* @return the mod name
@@ -158,14 +180,25 @@ default String getModFromIdentifier(ResourceLocation identifier) {
158180
}
159181

160182
/**
161-
* Gets the mod from a modid
183+
* Returns the mod from a modid
162184
*
163185
* @param modId the modid of the mod
164186
* @return the mod name
165187
*/
166188
String getModFromModId(String modId);
167189

190+
/**
191+
* Opens the view after the search is complete.
192+
*
193+
* @param builder the view search builder
194+
* @return whether the view was opened
195+
*/
168196
boolean openView(ViewSearchBuilder builder);
169197

198+
/**
199+
* Returns whether the client can use move items packets.
200+
*
201+
* @return whether the client can use move items packets
202+
*/
170203
boolean canUseMovePackets();
171204
}

api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java

+109
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package me.shedaniel.rei.api.client;
2525

2626
import me.shedaniel.math.Rectangle;
27+
import me.shedaniel.rei.api.client.config.ConfigObject;
2728
import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation;
2829
import me.shedaniel.rei.api.client.gui.widgets.TextField;
2930
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
@@ -36,10 +37,14 @@
3637
import net.minecraft.client.gui.screens.Screen;
3738
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
3839
import net.minecraft.resources.ResourceLocation;
40+
import org.jetbrains.annotations.ApiStatus;
3941
import org.jetbrains.annotations.Nullable;
4042

4143
import java.util.Optional;
4244

45+
/**
46+
* The runtime of REI.
47+
*/
4348
@Environment(EnvType.CLIENT)
4449
public interface REIRuntime extends Reloadable<REIClientPlugin> {
4550
/**
@@ -49,40 +54,144 @@ static REIRuntime getInstance() {
4954
return PluginManager.getClientInstance().get(REIRuntime.class);
5055
}
5156

57+
/**
58+
* Returns whether the overlay is visible, this is usually toggled by
59+
* the user with a keybind.
60+
*
61+
* @return whether the overlay is visible
62+
*/
5263
boolean isOverlayVisible();
5364

65+
/**
66+
* Toggles the visibility of the overlay.
67+
*/
5468
void toggleOverlayVisible();
5569

70+
/**
71+
* Returns the screen overlay of REI, if available and constructed.
72+
*
73+
* @return the screen overlay
74+
*/
5675
default Optional<ScreenOverlay> getOverlay() {
5776
return getOverlay(false, false);
5877
}
5978

79+
/**
80+
* Returns the screen overlay of REI.
81+
* <p>
82+
* if {@param reset} is {@code true}, the overlay will be reset,
83+
* and the returned value <b>must</b> not be {@code null}.
84+
*
85+
* @param reset whether to reset the overlay
86+
* @return the screen overlay
87+
*/
6088
default Optional<ScreenOverlay> getOverlay(boolean reset) {
6189
return getOverlay(reset, true);
6290
}
6391

92+
/**
93+
* Returns the screen overlay of REI.
94+
* <p>
95+
* If {@param reset} is {@code true}, the overlay will be reset,
96+
* and the returned value <b>must</b> not be {@code null}.
97+
* <p>
98+
* If the overlay has not been constructed yet, and {@param init} is {@code true},
99+
* the overlay will be constructed, and the returned value <b>must</b> not be {@code null}.
100+
*
101+
* @param reset whether to reset the overlay
102+
* @param init whether to init the overlay if it has not been constructed yet
103+
* @return the screen overlay
104+
*/
64105
Optional<ScreenOverlay> getOverlay(boolean reset, boolean init);
65106

107+
/**
108+
* Returns the previous opened container screen, if available.
109+
*
110+
* @return the previous opened container screen, or {@code null} if none
111+
*/
66112
@Nullable
67113
AbstractContainerScreen<?> getPreviousContainerScreen();
68114

115+
/**
116+
* Returns the previous opened screen, if available.
117+
*
118+
* @return the previous opened screen, or {@code null} if none
119+
*/
69120
@Nullable
70121
Screen getPreviousScreen();
71122

123+
/**
124+
* Returns whether dark mode is enabled.
125+
*
126+
* @return whether dark mode is enabled
127+
* @see ConfigObject#isUsingDarkTheme()
128+
*/
72129
boolean isDarkThemeEnabled();
73130

131+
/**
132+
* Returns the text field used for searching, if constructed.
133+
*
134+
* @return the text field used for searching, or {@code null} if none
135+
*/
74136
@Nullable
75137
TextField getSearchTextField();
76138

139+
/**
140+
* Queues a tooltip to be displayed.
141+
*
142+
* @param tooltip the tooltip to display, or {@code null}
143+
* @see Tooltip#queue()
144+
*/
77145
void queueTooltip(@Nullable Tooltip tooltip);
78146

147+
/**
148+
* Clear all queued tooltips.
149+
*
150+
* @see Tooltip#queue()
151+
* @since 8.3
152+
*/
153+
@ApiStatus.Experimental
154+
void clearTooltips();
155+
156+
/**
157+
* Returns the texture location of the default display background.
158+
* <p>
159+
* This is different depending on whether dark mode is enabled.
160+
*
161+
* @return the texture location of the default display background
162+
*/
79163
ResourceLocation getDefaultDisplayTexture();
80164

165+
/**
166+
* Returns the texture location of the default display background.
167+
*
168+
* @param darkTheme whether dark mode is enabled
169+
* @return the texture location of the default display background
170+
*/
81171
ResourceLocation getDefaultDisplayTexture(boolean darkTheme);
82172

173+
/**
174+
* Returns the location of the search field, according to the current screen.
175+
* <p>
176+
* If the config location is center, and the current screen is too small to display
177+
* the search field at the bottom center, the location returned will be the side.
178+
*
179+
* @return the location of the search field
180+
*/
83181
SearchFieldLocation getContextualSearchFieldLocation();
84182

183+
/**
184+
* Calculates the area of the entry list, given the bounds of the overlay.
185+
*
186+
* @param bounds the bounds of the overlay
187+
* @return the area of the entry list
188+
*/
85189
Rectangle calculateEntryListArea(Rectangle bounds);
86190

191+
/**
192+
* Calculates the area of the favorites list.
193+
*
194+
* @return the area of the favorites list
195+
*/
87196
Rectangle calculateFavoritesListArea();
88197
}

api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ static ConfigManager getInstance() {
4646
void saveConfig();
4747

4848
/**
49-
* Gets if craftable only filter is enabled
49+
* Returns whether the craftable only filter is enabled.
5050
*
5151
* @return whether craftable only filter is enabled
5252
*/
5353
boolean isCraftableOnlyEnabled();
5454

5555
/**
56-
* Toggles the craftable only filter
56+
* Toggles the craftable only filter.
5757
*/
5858
void toggleCraftableOnly();
5959

6060
/**
61-
* Opens the config screen
61+
* Opens the config screen.
6262
*
6363
* @param parent the screen shown before
6464
*/
@@ -67,12 +67,18 @@ default void openConfigScreen(Screen parent) {
6767
}
6868

6969
/**
70-
* Gets the config screen
70+
* Returns the config screen.
7171
*
7272
* @param parent the screen shown before
7373
* @return the config screen
7474
*/
7575
Screen getConfigScreen(Screen parent);
7676

77+
/**
78+
* Returns the config object.
79+
*
80+
* @return the config object
81+
* @see ConfigObject#getInstance()
82+
*/
7783
ConfigObject getConfig();
7884
}

0 commit comments

Comments
 (0)