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 ;
@@ -59,8 +61,7 @@ public abstract class EditorScreen extends Screen {
5961 public final Set <Integer > ignoredSlots = new TreeSet <>();
6062
6163 /**
62- * An element of {@link EditorScreen#buttons} which 'represents' the whole set of
63- * buttons.
64+ * An element of {@link EditorScreen#buttons} which 'represents' the whole set of buttons.
6465 * <p>
6566 * This can be any element, and the specific choice is only relevant when repositioning via
6667 * mouse drag.
@@ -69,8 +70,8 @@ public abstract class EditorScreen extends Screen {
6970
7071 /**
7172 * The class name of either {@link EditorScreen#rep}'s {@link TriggerButton#container}, or
72- * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former
73- * is {@code null}.
73+ * {@link EditorScreen#underlay}'s {@link AbstractContainerScreen#getMenu} if the former is
74+ * {@code null}.
7475 * <p>
7576 * This value represents the lowest-level key on which a {@link ClassPolicy} can be created, and
7677 * may differ from {@link EditorScreen#rep}'s {@link TriggerButton#activePolicyKey}.
@@ -404,7 +405,15 @@ lowestPolicyKey, new ClassPolicy(
404405 */
405406 @ Override
406407 public void render (@ NotNull GuiGraphics graphics , int mouseX , int mouseY , float partialTick ) {
408+ underlay .renderBackground (graphics , mouseX , mouseY , partialTick );
407409 underlay .render (graphics , mouseX , mouseY , partialTick );
410+
411+ // Workaround for other mods adding blur when rendering the underlay
412+ ((GuiRenderStateAccessor ) ((GuiGraphicsAccessor ) graphics ).clientsort$getGuiRenderState ())
413+ .clientsort$setFirstStratumAfterBlur (Integer .MAX_VALUE );
414+ graphics .nextStratum ();
415+ renderBlurredBackground (graphics );
416+
408417 super .render (graphics , mouseX , mouseY , partialTick );
409418
410419 // Render disabled-slot indicators
@@ -471,17 +480,34 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
471480 }
472481 }
473482
483+ /**
484+ * Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
485+ * {@link EditorScreen#render} and the method can only be called once.
486+ */
487+ @ Override
488+ public void renderBackground (
489+ @ NotNull GuiGraphics graphics ,
490+ int mouseX ,
491+ int mouseY ,
492+ float partialTick
493+ ) {
494+ if (Minecraft .getInstance ().level == null ) {
495+ renderPanorama (graphics , partialTick );
496+ }
497+ renderMenuBackground (graphics );
498+ }
499+
474500 /**
475501 * Modifies the background blur to be constant irrespective of the configured value.
476502 * <p>
477503 * Minimal blur is used to prevent the editable widgets disappearing under underlay items on a
478504 * higher render layer, while still keeping the underlay detail discernible.
479505 */
480506 @ Override
481- protected void renderBlurredBackground () {
507+ protected void renderBlurredBackground (@ NotNull GuiGraphics graphics ) {
482508 int original = Minecraft .getInstance ().options .menuBackgroundBlurriness ().get ();
483509 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (1 );
484- super .renderBlurredBackground ();
510+ super .renderBlurredBackground (graphics );
485511 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (original );
486512 }
487513
0 commit comments