Skip to content

Commit a1cbab5

Browse files
committed
Update to mc1.21.8
1 parent d7e7485 commit a1cbab5

File tree

13 files changed

+170
-93
lines changed

13 files changed

+170
-93
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.0.0-beta.14
44

55
- Added support for configuring specific items to always be sorted to the start or end
6+
- Fixed a launch crash on NeoForge on 1.21.7+
67

78
## 2.0.0-beta.13
89

@@ -13,6 +14,7 @@
1314
## 2.0.0-beta.12
1415

1516
- Fixed button status not saving when changed via editor screen
17+
- Added compatibility with Blur+ mod on 1.21.6+
1618

1719
## 2.0.0-beta.11
1820

common/src/main/java/dev/terminalmc/clientsort/client/compat/itemlocks/ItemLocksCompat.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,16 @@
1616

1717
package dev.terminalmc.clientsort.client.compat.itemlocks;
1818

19-
import com.kirdow.itemlocks.client.LockManager;
20-
import dev.terminalmc.clientsort.util.inject.ISlot;
21-
import net.minecraft.world.entity.player.Inventory;
2219
import net.minecraft.world.inventory.Slot;
2320

24-
import static com.kirdow.itemlocks.client.input.KeyBindings.isBypass;
25-
import static com.kirdow.itemlocks.proxy.Components.getComponent;
26-
2721
public class ItemLocksCompat {
2822

2923
/**
3024
* @param slot the slot to check.
3125
* @return {@code true} if the slot is valid, locked, and the bypass is not active.
3226
*/
3327
static boolean isLocked(Slot slot) {
34-
if (!(slot.container instanceof Inventory))
35-
return false;
36-
int index = adjustForInventory(((ISlot) slot).clientsort$getIndexInInv());
37-
return getComponent(LockManager.class).isLockedSlotRaw(index) && !isBypass();
28+
return false;
3829
}
3930

4031
/**

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/EditorScreen.java

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import dev.terminalmc.clientsort.client.config.Vec2i;
2626
import dev.terminalmc.clientsort.client.gui.widget.TriggerButton;
2727
import 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;
2830
import dev.terminalmc.clientsort.util.inject.ISlot;
2931
import net.minecraft.ChatFormatting;
3032
import 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

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/SelectorScreen.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import dev.terminalmc.clientsort.client.config.Config;
2020
import dev.terminalmc.clientsort.client.gui.TriggerButtonManager;
2121
import dev.terminalmc.clientsort.client.gui.widget.TriggerButton;
22+
import dev.terminalmc.clientsort.mixin.client.accessor.GuiGraphicsAccessor;
23+
import dev.terminalmc.clientsort.mixin.client.accessor.GuiRenderStateAccessor;
2224
import net.minecraft.ChatFormatting;
2325
import net.minecraft.client.Minecraft;
2426
import net.minecraft.client.gui.GuiGraphics;
@@ -99,20 +101,45 @@ private void rebuildGui() {
99101

100102
@Override
101103
public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
104+
underlay.renderBackground(graphics, mouseX, mouseY, partialTick);
102105
underlay.render(graphics, mouseX, mouseY, partialTick);
106+
107+
// Workaround for other mods adding blur when rendering the underlay
108+
((GuiRenderStateAccessor) ((GuiGraphicsAccessor) graphics).clientsort$getGuiRenderState())
109+
.clientsort$setFirstStratumAfterBlur(Integer.MAX_VALUE);
110+
graphics.nextStratum();
111+
renderBlurredBackground(graphics);
112+
103113
super.render(graphics, mouseX, mouseY, partialTick);
104114

105115
for (TriggerButton cb : buttons) {
106116
cb.renderWidget(graphics, mouseX, mouseY, partialTick);
107117
}
108118
}
109119

120+
/**
121+
* Removes the call to {@link Screen#renderBlurredBackground}, since we add a call in
122+
* {@link SelectorScreen#render} and the method can only be called once.
123+
*/
124+
@Override
125+
public void renderBackground(
126+
@NotNull GuiGraphics graphics,
127+
int mouseX,
128+
int mouseY,
129+
float partialTick
130+
) {
131+
if (Minecraft.getInstance().level == null) {
132+
renderPanorama(graphics, partialTick);
133+
}
134+
renderMenuBackground(graphics);
135+
}
136+
110137
@Override
111-
protected void renderBlurredBackground() {
138+
protected void renderBlurredBackground(@NotNull GuiGraphics graphics) {
112139
// Heavy blur, we want the widgets to really stand out
113140
int original = Minecraft.getInstance().options.menuBackgroundBlurriness().get();
114141
Minecraft.getInstance().options.menuBackgroundBlurriness().set(6);
115-
super.renderBlurredBackground();
142+
super.renderBlurredBackground(graphics);
116143
Minecraft.getInstance().options.menuBackgroundBlurriness().set(original);
117144
}
118145

common/src/main/java/dev/terminalmc/clientsort/client/gui/widget/TriggerButton.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
3535
import net.minecraft.client.gui.screens.Screen;
3636
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
37-
import net.minecraft.client.renderer.RenderType;
37+
import net.minecraft.client.renderer.RenderPipelines;
3838
import net.minecraft.network.chat.CommonComponents;
3939
import net.minecraft.network.chat.Component;
4040
import net.minecraft.resources.ResourceLocation;
@@ -170,7 +170,7 @@ public void renderWidget(
170170

171171
// Draw texture
172172
ResourceLocation texture = sprites.get(isActive(), isHoveredOrFocused());
173-
graphics.blitSprite(RenderType::guiTextured, texture, getX(), getY(), width, height);
173+
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, texture, getX(), getY(), width, height);
174174

175175
// Draw policy state indicator
176176
if (!operationAllowed) {

common/src/main/java/dev/terminalmc/clientsort/mixin/client/AbstractContainerScreenMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ private void afterRender(
325325
);
326326

327327
float scale = 0.7F;
328-
graphics.pose().pushPose();
329-
graphics.pose().scale(scale, scale, 0.0F);
328+
graphics.pose().pushMatrix();
329+
graphics.pose().scale(scale, scale);
330330

331331
for (Slot slot : menu.slots) {
332332
int slotId = ((ISlot) slot).clientsort$getIdInContainer();
@@ -348,7 +348,7 @@ private void afterRender(
348348
(int) ((((AbstractContainerScreenAccessor) (this)).clientsort$getTopPos()
349349
+ slot.y)
350350
/ scale),
351-
0xFF0000
351+
0xFFFF0000
352352
);
353353
}
354354
}
@@ -368,7 +368,7 @@ private void afterRender(
368368
(int) ((((AbstractContainerScreenAccessor) (this)).clientsort$getTopPos()
369369
+ slot.y + 12)
370370
/ scale),
371-
0xFFFFFF
371+
0xFFFFFFFF
372372
);
373373
// Draw slot scope, bottom right
374374
graphics.drawString(
@@ -380,10 +380,10 @@ private void afterRender(
380380
(int) ((((AbstractContainerScreenAccessor) (this)).clientsort$getTopPos()
381381
+ slot.y + 12)
382382
/ scale),
383-
0xFFFFFF
383+
0xFFFFFFFF
384384
);
385385
}
386386

387-
graphics.pose().popPose();
387+
graphics.pose().popMatrix();
388388
}
389389
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 TerminalMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.terminalmc.clientsort.mixin.client.accessor;
18+
19+
import net.minecraft.client.gui.GuiGraphics;
20+
import net.minecraft.client.gui.render.state.GuiRenderState;
21+
import org.spongepowered.asm.mixin.Mixin;
22+
import org.spongepowered.asm.mixin.gen.Accessor;
23+
24+
@Mixin(GuiGraphics.class)
25+
public interface GuiGraphicsAccessor {
26+
27+
@Accessor("guiRenderState")
28+
GuiRenderState clientsort$getGuiRenderState();
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2025 TerminalMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.terminalmc.clientsort.mixin.client.accessor;
18+
19+
import net.minecraft.client.gui.render.state.GuiRenderState;
20+
import org.spongepowered.asm.mixin.Mixin;
21+
import org.spongepowered.asm.mixin.gen.Accessor;
22+
23+
@Mixin(GuiRenderState.class)
24+
public interface GuiRenderStateAccessor {
25+
26+
@Accessor("firstStratumAfterBlur")
27+
void clientsort$setFirstStratumAfterBlur(int firstStratumAfterBlur);
28+
}

common/src/main/resources/clientsort.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"client.LocalPlayerMixin",
1515
"client.MinecraftMixin",
1616
"client.accessor.AbstractContainerScreenAccessor",
17+
"client.accessor.GuiGraphicsAccessor",
18+
"client.accessor.GuiRenderStateAccessor",
1719
"client.accessor.KeyMappingAccessor",
1820
"client.accessor.ScreenAccessor",
1921
"client.compat.emi.ReloadWorkerMixin",

0 commit comments

Comments
 (0)