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 ;
@@ -60,8 +62,7 @@ public abstract class EditorScreen extends Screen {
6062 public final Set <Integer > ignoredSlots = new TreeSet <>();
6163
6264 /**
63- * An element of {@link EditorScreen#buttons} which 'represents' the whole set of
64- * buttons.
65+ * An element of {@link EditorScreen#buttons} which 'represents' the whole set of buttons.
6566 * <p>
6667 * This can be any element, and the specific choice is only relevant when repositioning via
6768 * mouse drag.
@@ -70,8 +71,8 @@ public abstract class EditorScreen extends Screen {
7071
7172 /**
7273 * The class name of either {@link EditorScreen#rep}'s {@link TriggerButton#container}, or
73- * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former
74- * is {@code null}.
74+ * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former is
75+ * {@code null}.
7576 * <p>
7677 * This value represents the lowest-level key on which a {@link ClassPolicy} can be created, and
7778 * may differ from {@link EditorScreen#rep}'s {@link TriggerButton#activePolicyKey}.
@@ -446,7 +447,15 @@ lowestPolicyKey, new ClassPolicy(
446447 */
447448 @ Override
448449 public void render (@ NotNull GuiGraphics graphics , int mouseX , int mouseY , float partialTick ) {
450+ underlay .renderBackground (graphics , mouseX , mouseY , partialTick );
449451 underlay .render (graphics , mouseX , mouseY , partialTick );
452+
453+ // Workaround for other mods adding blur when rendering the underlay
454+ ((GuiRenderStateAccessor ) ((GuiGraphicsAccessor ) graphics ).clientsort$getGuiRenderState ())
455+ .clientsort$setFirstStratumAfterBlur (Integer .MAX_VALUE );
456+ graphics .nextStratum ();
457+ renderBlurredBackground (graphics );
458+
450459 super .render (graphics , mouseX , mouseY , partialTick );
451460
452461 // Render disabled-slot indicators
@@ -513,17 +522,34 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
513522 }
514523 }
515524
525+ /**
526+ * Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
527+ * {@link EditorScreen#render} and the method can only be called once.
528+ */
529+ @ Override
530+ public void renderBackground (
531+ @ NotNull GuiGraphics graphics ,
532+ int mouseX ,
533+ int mouseY ,
534+ float partialTick
535+ ) {
536+ if (Minecraft .getInstance ().level == null ) {
537+ renderPanorama (graphics , partialTick );
538+ }
539+ renderMenuBackground (graphics );
540+ }
541+
516542 /**
517543 * Modifies the background blur to be constant irrespective of the configured value.
518544 * <p>
519545 * Minimal blur is used to prevent the editable widgets disappearing under underlay items on a
520546 * higher render layer, while still keeping the underlay detail discernible.
521547 */
522548 @ Override
523- protected void renderBlurredBackground () {
549+ protected void renderBlurredBackground (@ NotNull GuiGraphics graphics ) {
524550 int original = Minecraft .getInstance ().options .menuBackgroundBlurriness ().get ();
525551 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (1 );
526- super .renderBlurredBackground ();
552+ super .renderBlurredBackground (graphics );
527553 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (original );
528554 }
529555
0 commit comments