2525import dev .terminalmc .clientsort .client .config .Vec2i ;
2626import dev .terminalmc .clientsort .client .gui .widget .TriggerButton ;
2727import dev .terminalmc .clientsort .mixin .client .accessor .AbstractContainerScreenAccessor ;
28+ import dev .terminalmc .clientsort .mixin .client .accessor .GuiGraphicsAccessor ;
29+ import dev .terminalmc .clientsort .mixin .client .accessor .GuiRenderStateAccessor ;
2830import dev .terminalmc .clientsort .util .inject .ISlot ;
2931import net .minecraft .ChatFormatting ;
3032import net .minecraft .client .Minecraft ;
@@ -58,8 +60,7 @@ public abstract class EditorScreen extends Screen {
5860 public final Set <Integer > ignoredSlots = new TreeSet <>();
5961
6062 /**
61- * An element of {@link EditorScreen#buttons} which 'represents' the whole set of
62- * buttons.
63+ * An element of {@link EditorScreen#buttons} which 'represents' the whole set of buttons.
6364 * <p>
6465 * This can be any element, and the specific choice is only relevant when repositioning via
6566 * mouse drag.
@@ -68,8 +69,8 @@ public abstract class EditorScreen extends Screen {
6869
6970 /**
7071 * The class name of either {@link EditorScreen#rep}'s {@link TriggerButton#container}, or
71- * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former
72- * is {@code null}.
72+ * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former is
73+ * {@code null}.
7374 * <p>
7475 * This value represents the lowest-level key on which a {@link ClassPolicy} can be created, and
7576 * may differ from {@link EditorScreen#rep}'s {@link TriggerButton#activePolicyKey}.
@@ -373,7 +374,15 @@ lowestPolicyKey, new ClassPolicy(
373374 */
374375 @ Override
375376 public void render (@ NotNull GuiGraphics graphics , int mouseX , int mouseY , float partialTick ) {
377+ underlay .renderBackground (graphics , mouseX , mouseY , partialTick );
376378 underlay .render (graphics , mouseX , mouseY , partialTick );
379+
380+ // Workaround for other mods adding blur when rendering the underlay
381+ ((GuiRenderStateAccessor ) ((GuiGraphicsAccessor ) graphics ).clientsort$getGuiRenderState ())
382+ .clientsort$setFirstStratumAfterBlur (Integer .MAX_VALUE );
383+ graphics .nextStratum ();
384+ renderBlurredBackground (graphics );
385+
377386 super .render (graphics , mouseX , mouseY , partialTick );
378387
379388 // Render disabled-slot indicators
@@ -390,7 +399,7 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
390399 + slot .x ,
391400 ((AbstractContainerScreenAccessor ) (underlay )).clientsort$getTopPos ()
392401 + slot .y ,
393- 0xFF0000
402+ 0xFFFF0000
394403 );
395404 }
396405 }
@@ -440,17 +449,34 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
440449 }
441450 }
442451
452+ /**
453+ * Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
454+ * {@link EditorScreen#render} and the method can only be called once.
455+ */
456+ @ Override
457+ public void renderBackground (
458+ @ NotNull GuiGraphics graphics ,
459+ int mouseX ,
460+ int mouseY ,
461+ float partialTick
462+ ) {
463+ if (Minecraft .getInstance ().level == null ) {
464+ renderPanorama (graphics , partialTick );
465+ }
466+ renderMenuBackground (graphics );
467+ }
468+
443469 /**
444470 * Modifies the background blur to be constant irrespective of the configured value.
445471 * <p>
446472 * Minimal blur is used to prevent the editable widgets disappearing under underlay items on a
447473 * higher render layer, while still keeping the underlay detail discernible.
448474 */
449475 @ Override
450- protected void renderBlurredBackground () {
476+ protected void renderBlurredBackground (@ NotNull GuiGraphics graphics ) {
451477 int original = Minecraft .getInstance ().options .menuBackgroundBlurriness ().get ();
452478 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (1 );
453- super .renderBlurredBackground ();
479+ super .renderBlurredBackground (graphics );
454480 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (original );
455481 }
456482
0 commit comments