Skip to content

Commit

Permalink
Add optional separate grouping of extra slots
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Nov 26, 2024
1 parent 187b01d commit 5ed4213
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Updated bundle handling
- Added Ukrainian translation (ttrafford7)
- Added support for ItemLocks
- Added an option to change behavior of extra slots (e.g. offhand) when sorting
17 changes: 17 additions & 0 deletions common/src/main/java/dev/terminalmc/clientsort/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static class Options {
public static final HotbarMode defaultHotbarMode = HotbarMode.HARD;
public HotbarMode hotbarMode = defaultHotbarMode;

public static final ExtraSlotMode defaultExtraSlotMode = ExtraSlotMode.NONE;
public ExtraSlotMode extraSlotMode = defaultExtraSlotMode;

public enum HotbarMode {
NONE,
HARD,
Expand All @@ -64,6 +67,20 @@ public String lowerName() {
}
}

public enum ExtraSlotMode {
NONE,
HOTBAR,
INVENTORY;

public String lowerName() {
return switch(this) {
case NONE -> "none";
case HOTBAR -> "hotbar";
case INVENTORY -> "inventory";
};
}
}

public static final boolean defaultLmbBundle = false;
public boolean lmbBundle = defaultLmbBundle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ else if (val > 100) return Optional.of(
.setSaveConsumer(val -> options.hotbarMode = val)
.build());

general.addEntry(eb.startEnumSelector(localized("option", "extraSlotMode"),
Config.Options.ExtraSlotMode.class, options.extraSlotMode)
.setEnumNameProvider(val -> localized("extraSlotMode",
((Config.Options.ExtraSlotMode)val).lowerName()))
.setTooltipSupplier(val -> Optional.of(new Component[]{
localized("extraSlotMode", val.lowerName() + ".tooltip")
}))
.setDefaultValue(Config.Options.defaultExtraSlotMode)
.setSaveConsumer(val -> options.extraSlotMode = val)
.build());

general.addEntry(eb.startBooleanToggle(localized("option", "lmbBundle"),
options.lmbBundle)
.setTooltip(localized("option", "lmbBundle.tooltip"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ public int getScope(Slot slot, boolean preferSmallerScopes) {
}
if (screen instanceof EffectRenderingInventoryScreen) {
if (slot.container instanceof Inventory) {
Config.Options options = Config.get().options;
if (isHotbarSlot(slot)) {
Config.Options options = Config.get().options;
if (options.hotbarMode == Config.Options.HotbarMode.HARD
|| options.hotbarMode == Config.Options.HotbarMode.SOFT && preferSmallerScopes) {
return -1;
}
} else if (((ISlot) slot).mouseWheelie_getIndexInInv() >= 40) {
return -1;
if (options.extraSlotMode == Config.Options.ExtraSlotMode.NONE) {
return -2;
} else if (options.extraSlotMode == Config.Options.ExtraSlotMode.HOTBAR
&& (options.hotbarMode == Config.Options.HotbarMode.HARD
|| options.hotbarMode == Config.Options.HotbarMode.SOFT && preferSmallerScopes)) {
return -1;
}
}
return 0;
} else {
Expand Down
8 changes: 8 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,7 @@
"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.extraSlotMode": "Extra Slot Mode",
"option.clientsort.lmbBundle": "Bundles use Left Click",
"option.clientsort.lmbBundle.tooltip": "In 1.21.2+, bundles use left-click to load, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

Expand All @@ -29,6 +30,13 @@
"hotbarMode.clientsort.off": "Off",
"hotbarMode.clientsort.off.tooltip": "Hotbar cannot be sorted",

"extraSlotMode.clientsort.none": "None",
"extraSlotMode.clientsort.none.tooltip": "Extra slots will not be sortable",
"extraSlotMode.clientsort.hotbar": "Hotbar",
"extraSlotMode.clientsort.hotbar.tooltip": "Extra slots will be sorted with the hotbar",
"extraSlotMode.clientsort.inventory": "Inventory",
"extraSlotMode.clientsort.inventory.tooltip": "Extra slots will be sorted with the main inventory",

"sortOrder.clientsort.none": "None",
"sortOrder.clientsort.alphabet": "Alphabet",
"sortOrder.clientsort.creative": "Creative",
Expand Down
8 changes: 8 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,7 @@
"option.clientsort.interactionRateClient": "Скорость локального взаимодействия",
"option.clientsort.interactionRate.tooltip": "Уменьшите, чтобы ускорить сортировку, увеличьте, если у вас возникли проблемы со скоростью передачи пакетов",
"option.clientsort.hotbarMode": "Режим горячей панели",
"option.clientsort.extraSlotMode": "Extra Slot Mode",
"option.clientsort.lmbBundle": "Bundles use Right Click",
"option.clientsort.lmbBundle.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.",

Expand All @@ -29,6 +30,13 @@
"hotbarMode.clientsort.off": "Выключено",
"hotbarMode.clientsort.off.tooltip": "Горячая панель не может быть отсортирована",

"extraSlotMode.clientsort.none": "None",
"extraSlotMode.clientsort.none.tooltip": "Extra slots will not be sortable",
"extraSlotMode.clientsort.hotbar": "Hotbar",
"extraSlotMode.clientsort.hotbar.tooltip": "Extra slots will be sorted with the hotbar",
"extraSlotMode.clientsort.inventory": "Inventory",
"extraSlotMode.clientsort.inventory.tooltip": "Extra slots will be sorted with the main inventory",

"sortOrder.clientsort.none": "Никакая",
"sortOrder.clientsort.alphabet": "Алфавитная",
"sortOrder.clientsort.creative": "Творческая",
Expand Down
8 changes: 8 additions & 0 deletions common/src/main/resources/assets/clientsort/lang/uk_ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"option.clientsort.interactionRateClient": "Частота взаємодії в одиночній грі",
"option.clientsort.interactionRate.tooltip": "Зменшіть для швидшого сортування, збільшіть якщо виникають проблеми з частотою пакетів",
"option.clientsort.hotbarMode": "Режим панелі швидкого доступу",
"option.clientsort.extraSlotMode": "Extra Slot Mode",
"option.clientsort.lmbBundle": "Bundles use Left Click",
"option.clientsort.lmbBundle.tooltip": "In 1.21.2+, bundles use left-click to load, which breaks sorting. If playing on a 1.21.2+ server, enable this option.",

Expand All @@ -29,6 +30,13 @@
"hotbarMode.clientsort.off": "Вимкнено",
"hotbarMode.clientsort.off.tooltip": "Панель швидкого доступу не може бути відсортована",

"extraSlotMode.clientsort.none": "None",
"extraSlotMode.clientsort.none.tooltip": "Extra slots will not be sortable",
"extraSlotMode.clientsort.hotbar": "Hotbar",
"extraSlotMode.clientsort.hotbar.tooltip": "Extra slots will be sorted with the hotbar",
"extraSlotMode.clientsort.inventory": "Inventory",
"extraSlotMode.clientsort.inventory.tooltip": "Extra slots will be sorted with the main inventory",

"sortOrder.clientsort.none": "Немає",
"sortOrder.clientsort.alphabet": "За алфавітом",
"sortOrder.clientsort.creative": "Творчий режим",
Expand Down
8 changes: 8 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,7 @@
"option.clientsort.interactionRateClient": "单机模式交互速率",
"option.clientsort.interactionRate.tooltip": "降低值可更快整理, 若遇到发包速率问题, 请将该值增加",
"option.clientsort.hotbarMode": "快捷栏模式",
"option.clientsort.extraSlotMode": "Extra Slot Mode",
"option.clientsort.lmbBundle": "Bundles use Right Click",
"option.clientsort.lmbBundle.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.",

Expand All @@ -29,6 +30,13 @@
"hotbarMode.clientsort.off": "关闭",
"hotbarMode.clientsort.off.tooltip": "不整理快捷栏内容",

"extraSlotMode.clientsort.none": "None",
"extraSlotMode.clientsort.none.tooltip": "Extra slots will not be sortable",
"extraSlotMode.clientsort.hotbar": "Hotbar",
"extraSlotMode.clientsort.hotbar.tooltip": "Extra slots will be sorted with the hotbar",
"extraSlotMode.clientsort.inventory": "Inventory",
"extraSlotMode.clientsort.inventory.tooltip": "Extra slots will be sorted with the main inventory",

"sortOrder.clientsort.none": "",
"sortOrder.clientsort.alphabet": "字母",
"sortOrder.clientsort.creative": "创造",
Expand Down
8 changes: 8 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,7 @@
"option.clientsort.interactionRateClient": "單人遊戲排序速率",
"option.clientsort.interactionRate.tooltip": "降低以更快排序,如果遇到封包速率問題則提高",
"option.clientsort.hotbarMode": "快捷欄模式",
"option.clientsort.extraSlotMode": "Extra Slot Mode",
"option.clientsort.lmbBundle": "Bundles use Right Click",
"option.clientsort.lmbBundle.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.",

Expand All @@ -29,6 +30,13 @@
"hotbarMode.clientsort.off": "停用",
"hotbarMode.clientsort.off.tooltip": "快捷欄不能排序",

"extraSlotMode.clientsort.none": "None",
"extraSlotMode.clientsort.none.tooltip": "Extra slots will not be sortable",
"extraSlotMode.clientsort.hotbar": "Hotbar",
"extraSlotMode.clientsort.hotbar.tooltip": "Extra slots will be sorted with the hotbar",
"extraSlotMode.clientsort.inventory": "Inventory",
"extraSlotMode.clientsort.inventory.tooltip": "Extra slots will be sorted with the main inventory",

"sortOrder.clientsort.none": "",
"sortOrder.clientsort.alphabet": "A-Z",
"sortOrder.clientsort.creative": "創造模式",
Expand Down

0 comments on commit 5ed4213

Please sign in to comment.