2222import dev .terminalmc .clientsort .client .config .*;
2323import dev .terminalmc .clientsort .client .gui .widget .TriggerButton ;
2424import dev .terminalmc .clientsort .mixin .client .accessor .AbstractContainerScreenAccessor ;
25+ import dev .terminalmc .clientsort .mixin .client .accessor .GuiGraphicsAccessor ;
26+ import dev .terminalmc .clientsort .mixin .client .accessor .GuiRenderStateAccessor ;
2527import dev .terminalmc .clientsort .util .inject .ISlot ;
2628import net .minecraft .ChatFormatting ;
2729import net .minecraft .client .Minecraft ;
@@ -62,8 +64,7 @@ public abstract class EditorScreen extends Screen {
6264 public final Set <Integer > ignoredSlots = new TreeSet <>();
6365
6466 /**
65- * An element of {@link EditorScreen#buttons} which 'represents' the whole set of
66- * buttons.
67+ * An element of {@link EditorScreen#buttons} which 'represents' the whole set of buttons.
6768 * <p>
6869 * This can be any element, and the specific choice is only relevant when repositioning via
6970 * mouse drag.
@@ -72,8 +73,8 @@ public abstract class EditorScreen extends Screen {
7273
7374 /**
7475 * The class name of either {@link EditorScreen#rep}'s {@link TriggerButton#container}, or
75- * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former
76- * is {@code null}.
76+ * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former is
77+ * {@code null}.
7778 * <p>
7879 * This value represents the lowest-level key on which a {@link ClassPolicy} can be created, and
7980 * may differ from {@link EditorScreen#rep}'s {@link TriggerButton#activePolicyKey}.
@@ -568,7 +569,15 @@ private void rebuildGui() {
568569 */
569570 @ Override
570571 public void render (@ NotNull GuiGraphics graphics , int mouseX , int mouseY , float partialTick ) {
572+ underlay .renderBackground (graphics , mouseX , mouseY , partialTick );
571573 underlay .render (graphics , mouseX , mouseY , partialTick );
574+
575+ // Workaround for other mods adding blur when rendering the underlay
576+ ((GuiRenderStateAccessor ) ((GuiGraphicsAccessor ) graphics ).clientsort$getGuiRenderState ())
577+ .clientsort$setFirstStratumAfterBlur (Integer .MAX_VALUE );
578+ graphics .nextStratum ();
579+ renderBlurredBackground (graphics );
580+
572581 super .render (graphics , mouseX , mouseY , partialTick );
573582
574583 // Render disabled-slot indicators
@@ -635,17 +644,34 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
635644 }
636645 }
637646
647+ /**
648+ * Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
649+ * {@link EditorScreen#render} and the method can only be called once.
650+ */
651+ @ Override
652+ public void renderBackground (
653+ @ NotNull GuiGraphics graphics ,
654+ int mouseX ,
655+ int mouseY ,
656+ float partialTick
657+ ) {
658+ if (Minecraft .getInstance ().level == null ) {
659+ renderPanorama (graphics , partialTick );
660+ }
661+ renderMenuBackground (graphics );
662+ }
663+
638664 /**
639665 * Modifies the background blur to be constant irrespective of the configured value.
640666 * <p>
641667 * Minimal blur is used to prevent the editable widgets disappearing under underlay items on a
642668 * higher render layer, while still keeping the underlay detail discernible.
643669 */
644670 @ Override
645- protected void renderBlurredBackground () {
671+ protected void renderBlurredBackground (@ NotNull GuiGraphics graphics ) {
646672 int original = Minecraft .getInstance ().options .menuBackgroundBlurriness ().get ();
647673 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (1 );
648- super .renderBlurredBackground ();
674+ super .renderBlurredBackground (graphics );
649675 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (original );
650676 }
651677
0 commit comments