15
15
import net .minecraft .screen .ScreenHandler ;
16
16
import net .minecraft .screen .slot .Slot ;
17
17
import net .minecraft .text .Text ;
18
+ import org .jetbrains .annotations .ApiStatus ;
18
19
import org .jetbrains .annotations .NotNull ;
19
20
import org .jetbrains .annotations .Nullable ;
20
21
import org .lwjgl .glfw .GLFW ;
21
22
import org .lwjgl .opengl .GL11 ;
22
23
24
+ import java .util .ArrayList ;
23
25
import java .util .function .BiFunction ;
26
+ import java .util .stream .Stream ;
24
27
25
28
public abstract class BaseOwoHandledScreen <R extends ParentComponent , S extends ScreenHandler > extends HandledScreen <S > implements DisposableScreen {
26
29
@@ -162,6 +165,24 @@ protected <C extends Component> C component(Class<C> expectedClass, String id) {
162
165
return this .uiAdapter .rootComponent .childById (expectedClass , id );
163
166
}
164
167
168
+ /**
169
+ * Compute a stream of all components for which to
170
+ * generate exclusion areas in a recipe viewer overlay.
171
+ * Called by the REI and EMI plugins
172
+ */
173
+ @ ApiStatus .OverrideOnly
174
+ public Stream <Component > componentsForExclusionAreas () {
175
+ if (this .children ().isEmpty ()) return Stream .of ();
176
+
177
+ var rootComponent = uiAdapter .rootComponent ;
178
+ var children = new ArrayList <Component >();
179
+
180
+ rootComponent .collectDescendants (children );
181
+ children .remove (rootComponent );
182
+
183
+ return children .stream ().filter (component -> !(component instanceof ParentComponent parent ) || parent .surface () != Surface .BLANK );
184
+ }
185
+
165
186
@ Override
166
187
public void renderBackground (DrawContext context , int mouseX , int mouseY , float delta ) {}
167
188
@@ -179,12 +200,12 @@ public void render(DrawContext vanillaContext, int mouseX, int mouseY, float del
179
200
if (!slot .isEnabled ()) continue ;
180
201
181
202
context .drawText (Text .literal ("H:" + i ),
182
- this .x + slot .x + 15 , this .y + slot .y + 9 , .5f , 0x0096FF ,
183
- OwoUIDrawContext .TextAnchor .BOTTOM_RIGHT
203
+ this .x + slot .x + 15 , this .y + slot .y + 9 , .5f , 0x0096FF ,
204
+ OwoUIDrawContext .TextAnchor .BOTTOM_RIGHT
184
205
);
185
206
context .drawText (Text .literal ("I:" + slot .getIndex ()),
186
- this .x + slot .x + 15 , this .y + slot .y + 15 , .5f , 0x5800FF ,
187
- OwoUIDrawContext .TextAnchor .BOTTOM_RIGHT
207
+ this .x + slot .x + 15 , this .y + slot .y + 15 , .5f , 0x5800FF ,
208
+ OwoUIDrawContext .TextAnchor .BOTTOM_RIGHT
188
209
);
189
210
}
190
211
@@ -200,8 +221,8 @@ public void render(DrawContext vanillaContext, int mouseX, int mouseY, float del
200
221
@ Override
201
222
public boolean keyPressed (int keyCode , int scanCode , int modifiers ) {
202
223
if ((modifiers & GLFW .GLFW_MOD_CONTROL ) == 0
203
- && this .uiAdapter .rootComponent .focusHandler ().focused () instanceof GreedyInputComponent inputComponent
204
- && inputComponent .onKeyPress (keyCode , scanCode , modifiers )) {
224
+ && this .uiAdapter .rootComponent .focusHandler ().focused () instanceof GreedyInputComponent inputComponent
225
+ && inputComponent .onKeyPress (keyCode , scanCode , modifiers )) {
205
226
return true ;
206
227
}
207
228
@@ -252,7 +273,7 @@ public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partial
252
273
GL11 .glGetIntegerv (GL11 .GL_SCISSOR_BOX , scissor );
253
274
254
275
((OwoSlotExtension ) this .slot ).owo$setScissorArea (PositionedRectangle .of (
255
- scissor [0 ], scissor [1 ], scissor [2 ], scissor [3 ]
276
+ scissor [0 ], scissor [1 ], scissor [2 ], scissor [3 ]
256
277
));
257
278
}
258
279
0 commit comments