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
@@ -386,7 +395,7 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
386395 "\u274C " ,
387396 ((AbstractContainerScreenAccessor ) (underlay )).clientsort$getLeftPos () + slot .x ,
388397 ((AbstractContainerScreenAccessor ) (underlay )).clientsort$getTopPos () + slot .y ,
389- 0xFF0000
398+ 0xFFFF0000
390399 );
391400 }
392401
@@ -434,17 +443,34 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
434443 }
435444 }
436445
446+ /**
447+ * Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
448+ * {@link EditorScreen#render} and the method can only be called once.
449+ */
450+ @ Override
451+ public void renderBackground (
452+ @ NotNull GuiGraphics graphics ,
453+ int mouseX ,
454+ int mouseY ,
455+ float partialTick
456+ ) {
457+ if (Minecraft .getInstance ().level == null ) {
458+ renderPanorama (graphics , partialTick );
459+ }
460+ renderMenuBackground (graphics );
461+ }
462+
437463 /**
438464 * Modifies the background blur to be constant irrespective of the configured value.
439465 * <p>
440466 * Minimal blur is used to prevent the editable widgets disappearing under underlay items on a
441467 * higher render layer, while still keeping the underlay detail discernible.
442468 */
443469 @ Override
444- protected void renderBlurredBackground () {
470+ protected void renderBlurredBackground (@ NotNull GuiGraphics graphics ) {
445471 int original = Minecraft .getInstance ().options .menuBackgroundBlurriness ().get ();
446472 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (1 );
447- super .renderBlurredBackground ();
473+ super .renderBlurredBackground (graphics );
448474 Minecraft .getInstance ().options .menuBackgroundBlurriness ().set (original );
449475 }
450476
0 commit comments