3737import net .minecraft .client .gui .components .events .GuiEventListener ;
3838import net .minecraft .client .gui .narration .NarratableEntry ;
3939import net .minecraft .client .gui .narration .NarrationElementOutput ;
40+ import net .minecraft .client .gui .navigation .ScreenRectangle ;
4041import net .minecraft .client .gui .screens .inventory .AbstractContainerScreen ;
4142import net .minecraft .client .input .MouseButtonEvent ;
4243import net .minecraft .client .renderer .Rect2i ;
@@ -61,10 +62,10 @@ public class AttachedIoScreen<T extends AttachedIoMenu<?>> extends AbstractConta
6162 */
6263 private static final int TAB_BORDER = 4 ;
6364
64- private static final float TAB_OPEN_PER_TICK = 0.20f ;
65+ private static final float TAB_OPEN_PER_TICK = 0.25f ;
6566
6667 public static final Identifier TEXTURE = MdId .of ("textures/gui/attachment.png" );
67- public static final Identifier TAB_RIGHT_TEXTURE = MdId .of ("textures/gui/ tab_right.png " );
68+ public static final Identifier TAB_RIGHT_TEXTURE = MdId .of ("tab_right" );
6869
6970 private boolean redstoneTabOpen ;
7071 private float redstoneTabCurrentOpen ;
@@ -209,45 +210,17 @@ private void renderRedstoneTabBg(GuiGraphics guiGraphics, float partialTicks) {
209210
210211 updateRedstoneTabRect (partialTicks );
211212
212- // The background image is treated as a border image,
213- // for context see https://developer.mozilla.org/en-US/docs/Web/CSS/border-image
214- // The border is assumed to be 4 PX
215-
216213 var tabX = redstoneTabRect .getX ();
217214 var tabY = redstoneTabRect .getY ();
218215 var tabWidth = redstoneTabRect .getWidth ();
219216 var tabHeight = redstoneTabRect .getHeight ();
220217
221- var tabRight = tabX + tabWidth ;
222- var tabBottom = tabY + tabHeight ;
223-
224218 var color = ARGB .colorFromFloat (1.0f , 0.81f , 0.14f , 0.04f );
225219
226- // Draw all four corners clock-wise starting from top-left
227- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX , tabY , 0 , 0 , TAB_BORDER , TAB_BORDER , 256 , 256 , color );
228- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabRight - TAB_BORDER , tabY , 256 - TAB_BORDER , 0 , TAB_BORDER , TAB_BORDER ,
229- 256 , 256 , color );
230- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabRight - TAB_BORDER , tabBottom - TAB_BORDER , 256 - TAB_BORDER ,
231- 256 - TAB_BORDER , TAB_BORDER , TAB_BORDER , 256 , 256 , color );
232- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX , tabBottom - TAB_BORDER , 0 , 256 - TAB_BORDER , TAB_BORDER , TAB_BORDER ,
233- 256 , 256 , color );
234-
235- // Draw the borders between the corners in the same order
236- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX + TAB_BORDER , tabY , tabWidth - 2 * TAB_BORDER , TAB_BORDER , TAB_BORDER ,
237- 0 , 256 - 2 * TAB_BORDER , TAB_BORDER , 256 , 256 , color );
238- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabRight - TAB_BORDER , tabY + TAB_BORDER , TAB_BORDER ,
239- tabHeight - 2 * TAB_BORDER , 256 - TAB_BORDER , TAB_BORDER , TAB_BORDER , 256 - 2 * TAB_BORDER , 256 , 256 , color );
240- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX + TAB_BORDER , tabBottom - TAB_BORDER , tabWidth - 2 * TAB_BORDER ,
241- TAB_BORDER , TAB_BORDER , 256 - TAB_BORDER , 256 - 2 * TAB_BORDER , TAB_BORDER , 256 , 256 , color );
242- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX , tabY + TAB_BORDER , TAB_BORDER , tabHeight - 2 * TAB_BORDER , 0 ,
243- TAB_BORDER , TAB_BORDER , 256 - 2 * TAB_BORDER , 256 , 256 , color );
244-
245- // Center
246- guiGraphics .blit (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX + TAB_BORDER , tabY + TAB_BORDER , TAB_BORDER , TAB_BORDER ,
247- tabWidth - 2 * TAB_BORDER , tabHeight - 2 * TAB_BORDER , 256 , 256 , color );
220+ guiGraphics .blitSprite (RenderPipelines .GUI_TEXTURED , TAB_RIGHT_TEXTURE , tabX , tabY , tabWidth , tabHeight , color );
248221
249222 var scissorRect = getRedstoneTabScissorRect ();
250- guiGraphics .enableScissor (scissorRect .getX (), scissorRect .getY (), scissorRect .getWidth (), scissorRect .getHeight ());
223+ guiGraphics .enableScissor (scissorRect .left (), scissorRect .top (), scissorRect .right (), scissorRect .bottom ());
251224 // Tell the buttons the scissor rect since they need to be cut off too
252225 redstoneModeIgnored .setScissorRect (scissorRect );
253226 redstoneModeLow .setScissorRect (scissorRect );
@@ -268,23 +241,23 @@ private void renderRedstoneTabBg(GuiGraphics guiGraphics, float partialTicks) {
268241 tabY + 3 );
269242
270243 var header = Component .translatable ("gui.moderndynamics.setting.redstone_control.header" );
271- guiGraphics .drawString (font , header , tabX + TAB_BORDER + 16 , tabY + TAB_BORDER + 4 , 0xe1c92f );
244+ guiGraphics .drawString (font , header , tabX + TAB_BORDER + 16 , tabY + TAB_BORDER + 4 , 0xffe1c92f );
272245
273246 /* Draw a sub-header that indicates whether the attachment is currently operating based on the status or not */
274247 var subHeaderStatus = Component .translatable ("gui.moderndynamics.setting.redstone_control.status_header" );
275- guiGraphics .drawString (font , subHeaderStatus , tabX + TAB_BORDER + 4 , tabY + TAB_BORDER + 42 , 0xaaafb8 );
248+ guiGraphics .drawString (font , subHeaderStatus , tabX + TAB_BORDER + 4 , tabY + TAB_BORDER + 42 , 0xffaaafb8 );
276249 Component enabledStatusText ;
277250 if (menu .isEnabledViaRedstone ()) {
278251 enabledStatusText = Component .translatable ("gui.moderndynamics.setting.redstone_control.enabled" );
279252 } else {
280253 enabledStatusText = Component .translatable ("gui.moderndynamics.setting.redstone_control.disabled" );
281254 }
282- guiGraphics .drawString (font , enabledStatusText , tabX + TAB_BORDER + 12 , tabY + TAB_BORDER + 54 , 0 , false );
255+ guiGraphics .drawString (font , enabledStatusText , tabX + TAB_BORDER + 12 , tabY + TAB_BORDER + 54 , 0xff000000 , false );
283256
284257 /* Draw a sub-header that simply spells out the currently chosen redstone mode again */
285258 var subHeaderSetting = Component .translatable ("gui.moderndynamics.setting.redstone_control.signal_required_header" );
286- guiGraphics .drawString (font , subHeaderSetting , tabX + TAB_BORDER + 4 , tabY + TAB_BORDER + 66 , 0xaaafb8 );
287- guiGraphics .drawString (font , menu .getRedstoneMode ().getTranslation (), tabX + TAB_BORDER + 12 , tabY + TAB_BORDER + 78 , 0 , false );
259+ guiGraphics .drawString (font , subHeaderSetting , tabX + TAB_BORDER + 4 , tabY + TAB_BORDER + 66 , 0xffaaafb8 );
260+ guiGraphics .drawString (font , menu .getRedstoneMode ().getTranslation (), tabX + TAB_BORDER + 12 , tabY + TAB_BORDER + 78 , 0xff000000 , false );
288261
289262 guiGraphics .disableScissor ();
290263 }
@@ -316,17 +289,14 @@ private void updateRedstoneTabRect(float partialTicks) {
316289 }
317290 }
318291
319- private Rect2i getRedstoneTabScissorRect () {
292+ private ScreenRectangle getRedstoneTabScissorRect () {
320293 var tabRect = redstoneTabRect ;
321294
322- // Scissor rect is in physical window coordinates not the rescaled UI space
323- double scale = this .minecraft .getWindow ().getGuiScale ();
324- return new Rect2i (
325- (int ) ((tabRect .getX () + TAB_BORDER ) * scale ),
326- // glScissor has y=0 at the bottom of the screen
327- (int ) ((height - (tabRect .getY () + tabRect .getHeight () - TAB_BORDER )) * scale ),
328- (int ) ((tabRect .getWidth () - 2 * TAB_BORDER ) * scale ),
329- (int ) ((tabRect .getHeight () - 2 * TAB_BORDER ) * scale ));
295+ return new ScreenRectangle (
296+ tabRect .getX () + TAB_BORDER ,
297+ tabRect .getY () + TAB_BORDER ,
298+ tabRect .getWidth () - 2 * TAB_BORDER ,
299+ tabRect .getHeight () - 2 * TAB_BORDER );
330300 }
331301
332302 private float getCurrentRedstoneTabOpen (float partialTicks ) {
@@ -387,6 +357,11 @@ public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
387357 return false ;
388358 }
389359
360+ @ Override
361+ public boolean isMouseOver (double mouseX , double mouseY ) {
362+ return isInRedstoneTabRect (mouseX , mouseY );
363+ }
364+
390365 @ Override
391366 public NarrationPriority narrationPriority () {
392367 return NarrationPriority .NONE ;
0 commit comments