Skip to content

Commit

Permalink
Add option to switch between LMB and RMB for bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Nov 25, 2024
1 parent 0426628 commit 55a29ff
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public String lowerName() {
}
}

public static final boolean defaultRmbBundle = false;
public boolean rmbBundle = defaultRmbBundle;

// Sorting
public static final String defaultSortMode = SortMode.CREATIVE.name;
public String sortModeStr = defaultSortMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ else if (val > 100) return Optional.of(
.setSaveConsumer(val -> options.hotbarMode = val)
.build());

general.addEntry(eb.startBooleanToggle(localized("option", "rmbBundle"),
options.rmbBundle)
.setTooltip(localized("option", "rmbBundle.tooltip"))
.setDefaultValue(Config.Options.defaultRmbBundle)
.setSaveConsumer(val -> {
options.rmbBundle = val;
if (val) CreativeSearchOrder.tryRefreshItemSearchPositionLookup();
})
.build());

ConfigCategory sort = builder.getOrCreateCategory(localized("option", "sorting"));

sort.addEntry(eb.startSelector(localized("option", "sortMode"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package dev.terminalmc.clientsort.inventory.sort;

import dev.terminalmc.clientsort.config.Config;
import dev.terminalmc.clientsort.inventory.ContainerScreenHelper;
import dev.terminalmc.clientsort.network.InteractionManager;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
Expand Down Expand Up @@ -201,18 +202,20 @@ protected void sortOnClient(int[] sortedIds) {
}

// swap the current stack with the target stack
if ((backingStacks[id] instanceof BundleItem && !(carriedItem instanceof AirItem))
|| (carriedItem instanceof BundleItem && !(backingStacks[id] instanceof AirItem))) {
temp = backingStacks[id];
backingStacks[id] = carriedItem;
carriedItem = temp;
if (
Config.get().options.rmbBundle
&& (
(backingStacks[id] instanceof BundleItem && !(carriedItem instanceof AirItem))
|| (carriedItem instanceof BundleItem && !(backingStacks[id] instanceof AirItem))
)
) {
InteractionManager.push(screenHelper.createClickEvent(inventorySlots[id], 1, ClickType.PICKUP));
} else {
temp = backingStacks[id];
backingStacks[id] = carriedItem;
carriedItem = temp;
InteractionManager.push(screenHelper.createClickEvent(inventorySlots[id], 0, ClickType.PICKUP));
}
temp = backingStacks[id];
backingStacks[id] = carriedItem;
carriedItem = temp;
currentStack = stacks[id];
doneSlashEmpty.set(id); // mark the current target as done
// If the target that we just swapped with was empty before, then this breaks the chain.
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/clientsort/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"option.clientsort.interactionRateClient": "Singleplayer Interaction Rate",
"option.clientsort.interactionRate.tooltip": "Reduce to sort faster, increase if you are experiencing packet rate issues",
"option.clientsort.hotbarMode": "Hotbar Mode",
"option.clientsort.rmbBundle": "Bundles use Right Click",
"option.clientsort.rmbBundle.tooltip": "In 1.21.2+, bundles use right-click to load and unload, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

"option.clientsort.sorting": "Sorting",
"option.clientsort.sortMode": "Sort Mode",
"option.clientsort.shiftSortMode": "Shift Sort Mode",
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/clientsort/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"option.clientsort.interactionRateClient": "Скорость локального взаимодействия",
"option.clientsort.interactionRate.tooltip": "Уменьшите, чтобы ускорить сортировку, увеличьте, если у вас возникли проблемы со скоростью передачи пакетов",
"option.clientsort.hotbarMode": "Режим горячей панели",
"option.clientsort.rmbBundle": "Bundles use Right Click",
"option.clientsort.rmbBundle.tooltip": "In 1.21.2+, bundles use right-click to load and unload, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

"option.clientsort.sorting": "Сортировка",
"option.clientsort.sortMode": "Режим сортировки",
"option.clientsort.shiftSortMode": "Режим сортировки по Shift",
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/clientsort/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"option.clientsort.interactionRateClient": "单机模式交互速率",
"option.clientsort.interactionRate.tooltip": "降低值可更快整理, 若遇到发包速率问题, 请将该值增加",
"option.clientsort.hotbarMode": "快捷栏模式",
"option.clientsort.rmbBundle": "Bundles use Right Click",
"option.clientsort.rmbBundle.tooltip": "In 1.21.2+, bundles use right-click to load and unload, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

"option.clientsort.sorting": "整理",
"option.clientsort.sortMode": "整理模式",
"option.clientsort.shiftSortMode": "Shift 键整理模式",
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/clientsort/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"option.clientsort.interactionRateClient": "單人遊戲排序速率",
"option.clientsort.interactionRate.tooltip": "降低以更快排序,如果遇到封包速率問題則提高",
"option.clientsort.hotbarMode": "快捷欄模式",
"option.clientsort.rmbBundle": "Bundles use Right Click",
"option.clientsort.rmbBundle.tooltip": "In 1.21.2+, bundles use right-click to load and unload, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

"option.clientsort.sorting": "排序",
"option.clientsort.sortMode": "排序模式",
"option.clientsort.shiftSortMode": "Shift 排序模式",
Expand Down

0 comments on commit 55a29ff

Please sign in to comment.