Skip to content

Commit cc958c4

Browse files
committed
Update to mc1.21.3
1 parent bdd9ebe commit cc958c4

File tree

12 files changed

+75
-103
lines changed

12 files changed

+75
-103
lines changed

common/src/main/java/dev/terminalmc/clientsort/client/ClientSort.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ public static void afterConfigSaved(Config config) {
9696

9797
public static void updateItemTags(Config.Options options) {
9898
options.typeMatchItemCache.clear();
99-
BuiltInRegistries.ITEM.getTags().forEach((pair) -> {
100-
if (options.typeMatchTags.contains(pair.getFirst().location().getPath())) {
101-
pair.getSecond().forEach((itemHolder) ->
102-
options.typeMatchItemCache.add(itemHolder.value()));
99+
BuiltInRegistries.ITEM.getTags().forEach((named) -> {
100+
if (options.typeMatchTags.contains(named.key().location().getPath())) {
101+
named.forEach((itemHolder) -> options.typeMatchItemCache.add(itemHolder.value()));
103102
}
104103
});
105104
}

common/src/main/java/dev/terminalmc/clientsort/client/config/Config.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ public enum ExtraSlotScope {
109109
val != null && Arrays.stream(ExtraSlotScope.values()).toList().contains(val)
110110
? val : extraSlotScopeDefault;
111111

112-
113-
public static final boolean bundlesUseLeftClickDefault = false;
114-
public boolean bundlesUseLeftClick = bundlesUseLeftClickDefault;
112+
public static final boolean bundlesUseRightClickDefault = false;
113+
public boolean bundlesUseRightClick = bundlesUseRightClickDefault;
115114

116115
// Matching options
117116

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/config/ClothScreenProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ else if (val > Config.Options.AUTO_OP_DELAY_MAX)
178178
.build());
179179

180180
general.addEntry(eb.startBooleanToggle(
181-
localized("option", "bundlesUseLeftClick"),
182-
options.bundlesUseLeftClick
181+
localized("option", "bundlesUseRightClick"),
182+
options.bundlesUseRightClick
183183
)
184-
.setTooltip(localized("option", "bundlesUseLeftClick.tooltip"))
185-
.setDefaultValue(Config.Options.bundlesUseLeftClickDefault)
184+
.setTooltip(localized("option", "bundlesUseRightClick.tooltip"))
185+
.setDefaultValue(Config.Options.bundlesUseRightClickDefault)
186186
.setSaveConsumer(val -> {
187-
options.bundlesUseLeftClick = val;
187+
options.bundlesUseRightClick = val;
188188
if (val)
189189
CreativeSearchOrder.tryRefreshStackPositionMap();
190190
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
520520
* higher render layer, while still keeping the underlay detail discernible.
521521
*/
522522
@Override
523-
protected void renderBlurredBackground(float partialTick) {
523+
protected void renderBlurredBackground() {
524524
int original = Minecraft.getInstance().options.menuBackgroundBlurriness().get();
525525
Minecraft.getInstance().options.menuBackgroundBlurriness().set(1);
526-
super.renderBlurredBackground(partialTick);
526+
super.renderBlurredBackground();
527527
Minecraft.getInstance().options.menuBackgroundBlurriness().set(original);
528528
}
529529

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
110110
}
111111

112112
@Override
113-
protected void renderBlurredBackground(float partialTick) {
113+
protected void renderBlurredBackground() {
114114
// Heavy blur, we want the widgets to really stand out
115115
int original = Minecraft.getInstance().options.menuBackgroundBlurriness().get();
116116
Minecraft.getInstance().options.menuBackgroundBlurriness().set(6);
117-
super.renderBlurredBackground(partialTick);
117+
super.renderBlurredBackground();
118118
Minecraft.getInstance().options.menuBackgroundBlurriness().set(original);
119119
}
120120

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
3636
import net.minecraft.client.gui.screens.Screen;
3737
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
38+
import net.minecraft.client.renderer.RenderType;
3839
import net.minecraft.network.chat.CommonComponents;
3940
import net.minecraft.network.chat.Component;
4041
import net.minecraft.resources.ResourceLocation;
@@ -173,7 +174,7 @@ public void renderWidget(
173174

174175
// Draw texture
175176
ResourceLocation texture = sprites.get(isActive(), isHoveredOrFocused());
176-
graphics.blitSprite(texture, getX(), getY(), 0, width, height);
177+
graphics.blitSprite(RenderType::guiTextured, texture, getX(), getY(), width, height);
177178

178179
// Draw policy state indicator
179180
if (!operationAllowed) {

common/src/main/java/dev/terminalmc/clientsort/client/inventory/helper/ContainerScreenHelper.java

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import dev.terminalmc.clientsort.util.inject.ISlot;
2222
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
2323
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
24-
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
2524
import net.minecraft.world.Container;
2625
import net.minecraft.world.entity.player.Inventory;
2726
import net.minecraft.world.inventory.Slot;
@@ -78,74 +77,48 @@ public static boolean isExtraSlot(Slot slot) {
7877
* @return the scope of the slot, or {@link Scope#INVALID} if the slot is not accessible.
7978
*/
8079
public Scope getScope(Slot slot) {
81-
//noinspection ConstantValue
82-
if (slot.container == null)
83-
return Scope.INVALID;
84-
if (slot.container instanceof ContainerSingleItem)
85-
return Scope.INVALID;
8680
if (slot.isFake())
8781
return Scope.INVALID;
82+
return switch (slot.container) {
83+
//noinspection DataFlowIssue
84+
case null -> Scope.INVALID;
85+
case ContainerSingleItem ignored -> Scope.INVALID;
8886

89-
// Screen with only player inventory
90-
if (screen instanceof EffectRenderingInventoryScreen) {
91-
// Player inventory
92-
if (slot.container instanceof Inventory) {
93-
return getScopeInInventory(slot);
94-
}
95-
// Out of inventory e.g. 2x2 crafting grid
96-
else {
97-
return Scope.PLAYER_OTHER;
98-
}
99-
}
100-
// Screen with container, and probably player inventory attached
101-
else {
10287
// Player inventory
103-
if (slot.container instanceof Inventory) {
104-
return getScopeInInventory(slot);
105-
}
106-
// Container
107-
else {
108-
return Scope.CONTAINER_INV;
109-
}
110-
}
111-
}
112-
113-
/**
114-
* Gets the scope of the specified {@link Slot}, assuming the slot's container is already known
115-
* to be an instance of {@link Inventory}.
116-
*
117-
* @param slot the slot for which to get the scope.
118-
* @return the scope of the slot, which may be {@link Scope#INVALID}.
119-
*/
120-
private static Scope getScopeInInventory(Slot slot) {
121-
boolean mergeWithHotbar = false;
122-
123-
// Extra inventory slots e.g. offhand
124-
if (isExtraSlot(slot)) {
125-
switch (options().extraSlotScope) {
126-
case HOTBAR -> mergeWithHotbar = true;
127-
case EXTRA -> {
128-
return Scope.PLAYER_INV_EXTRA;
129-
}
130-
case NONE -> {
131-
return Scope.INVALID;
88+
case Inventory ignored -> {
89+
boolean mergeWithHotbar = false;
90+
91+
// Extra inventory slots e.g. offhand
92+
if (isExtraSlot(slot)) {
93+
switch (options().extraSlotScope) {
94+
case HOTBAR -> mergeWithHotbar = true;
95+
case EXTRA -> {
96+
yield Scope.PLAYER_INV_EXTRA;
97+
}
98+
case NONE -> {
99+
yield Scope.INVALID;
100+
}
101+
}
132102
}
133-
}
134-
}
135103

136-
// Hotbar
137-
if (mergeWithHotbar || isHotbarSlot(slot)) {
138-
switch (options().hotbarScope) {
139-
case HOTBAR -> {
140-
return Scope.PLAYER_INV_HOTBAR;
141-
}
142-
case NONE -> {
143-
return Scope.INVALID;
104+
// Hotbar
105+
if (mergeWithHotbar || isHotbarSlot(slot)) {
106+
switch (options().hotbarScope) {
107+
case HOTBAR -> {
108+
yield Scope.PLAYER_INV_HOTBAR;
109+
}
110+
case NONE -> {
111+
yield Scope.INVALID;
112+
}
113+
}
144114
}
115+
116+
yield Scope.PLAYER_INV;
145117
}
146-
}
147118

148-
return Scope.PLAYER_INV;
119+
// Not player inventory
120+
default -> Scope.CONTAINER_INV;
121+
};
149122
}
150123

151124
/**

common/src/main/java/dev/terminalmc/clientsort/client/inventory/operator/client/ClientSurvivalOperator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import dev.terminalmc.clientsort.mixin.client.accessor.AbstractContainerScreenAccessor;
2626
import dev.terminalmc.clientsort.util.inject.ISlot;
2727
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
28+
import net.minecraft.tags.ItemTags;
2829
import net.minecraft.world.inventory.ClickType;
2930
import net.minecraft.world.inventory.Slot;
3031
import net.minecraft.world.item.BundleItem;
3132
import net.minecraft.world.item.ItemStack;
32-
import net.minecraft.world.item.Items;
3333

3434
import java.util.ArrayDeque;
3535
import java.util.BitSet;
@@ -289,7 +289,7 @@ protected void sort(int[] sortedIds, boolean playSound) {
289289
&& !(carriedStack.isEmpty());
290290
boolean clickOnItemWithBundle = isBundle(carriedStack)
291291
&& !(originScopeStacks[dstId].isEmpty());
292-
if (options().bundlesUseLeftClick
292+
if (!options().bundlesUseRightClick
293293
&& (clickOnBundleWithItem || clickOnItemWithBundle)) {
294294
mouseButton = 1;
295295
}
@@ -631,6 +631,6 @@ private InteractionEvent createClickEvent(
631631
* @return whether the stack is a bundle.
632632
*/
633633
private static boolean isBundle(ItemStack stack) {
634-
return stack.is(Items.BUNDLE) || stack.getItem() instanceof BundleItem;
634+
return stack.is(ItemTags.BUNDLES) || stack.getItem() instanceof BundleItem;
635635
}
636636
}

common/src/main/resources/assets/clientsort/lang/en_us.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
"option.clientsort.autoOpDelayContainer.tooltip": "The delay, in ticks, after which to perform automatic operations on a container when it is opened.",
8181
"option.clientsort.hotbarScope": "Hotbar Scope",
8282
"option.clientsort.extraSlotScope": "Extra Slot Scope",
83-
"option.clientsort.bundlesUseLeftClick": "Bundles use Left Click",
84-
"option.clientsort.bundlesUseLeftClick.tooltip": "In 1.21.2+, bundles use left-click to load, which can interfere with inventory actions. If playing on a 1.21.2+ server, enable this option.",
83+
"option.clientsort.bundlesUseRightClick": "Bundles use Right Click",
84+
"option.clientsort.bundlesUseRightClick.tooltip": "In 1.21.1 and earlier versions, bundles use right-click to load, which can interfere with inventory actions. If playing on a 1.21.1 or earlier server, enable this option.",
8585
"option.clientsort.showDebugInfo": "Show Debug Info",
8686
"option.clientsort.showDebugInfo.tooltip": "Whether to show debug info on the GUI and enable debug logging. Value will reset when you restart the game.",
8787

common/src/main/resources/assets/clientsort/lang/ru_ru.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
"option.clientsort.autoOpDelayContainer.tooltip": "Задержка в тиках перед выполнением автоматических операций с контейнером после его открытия.",
8181
"option.clientsort.hotbarScope": "Область панели быстрого доступа",
8282
"option.clientsort.extraSlotScope": "Область дополнительных слотов",
83-
"option.clientsort.bundlesUseLeftClick": "Пакеты используют ЛКМ",
84-
"option.clientsort.bundlesUseLeftClick.tooltip": "С версии 1.21.2+ для загрузки пакетов используется ЛКМ, что может мешать сортировке. Если вы играете на сервере 1.21.2+, включите эту опцию.",
83+
"option.clientsort.bundlesUseRightClick": "Пакеты используют ПКМ",
84+
"option.clientsort.bundlesUseRightClick.tooltip": "До версии 1.21.2 для загрузки пакетов использовалась ПКМ, что нарушало сортировку. Если вы играете на сервере 1.21.1 или более ранней версии, включите эту опцию.",
8585
"option.clientsort.showDebugInfo": "Показать отладочную информацию",
8686
"option.clientsort.showDebugInfo.tooltip": "Показывать отладочную информацию в интерфейсе и включать логирование. Значение сбрасывается при перезапуске игры.",
8787

0 commit comments

Comments
 (0)