diff --git a/src/main/java/com/cleanroommc/bogosorter/ClientEventHandler.java b/src/main/java/com/cleanroommc/bogosorter/ClientEventHandler.java index 91ebd53..0677893 100644 --- a/src/main/java/com/cleanroommc/bogosorter/ClientEventHandler.java +++ b/src/main/java/com/cleanroommc/bogosorter/ClientEventHandler.java @@ -28,6 +28,7 @@ import com.cleanroommc.bogosorter.api.SortRule; import com.cleanroommc.bogosorter.common.config.BogoSorterConfig; import com.cleanroommc.bogosorter.common.config.ConfigGui; +import com.cleanroommc.bogosorter.common.config.PlayerConfig; import com.cleanroommc.bogosorter.common.dropoff.DropOffHandler; import com.cleanroommc.bogosorter.common.dropoff.render.RendererCube; import com.cleanroommc.bogosorter.common.network.CDropOff; @@ -344,7 +345,8 @@ public static boolean sort(GuiScreen guiScreen, @Nullable ISlot slot) { .get(0); } else { slotGroup = sortingContext.getSlotGroup(slot.bogo$getSlotNumber()); - if (slotGroup == null || slotGroup.isEmpty()) return false; + if (slotGroup == null || slotGroup.isEmpty() + || (slotGroup.isHotbar() && !PlayerConfig.getClient().enableHotbarSort)) return false; } List> sortRules = BogoSorterConfig.sortRules; diff --git a/src/main/java/com/cleanroommc/bogosorter/common/config/BogoSorterConfig.java b/src/main/java/com/cleanroommc/bogosorter/common/config/BogoSorterConfig.java index 31800f2..f8b65a8 100644 --- a/src/main/java/com/cleanroommc/bogosorter/common/config/BogoSorterConfig.java +++ b/src/main/java/com/cleanroommc/bogosorter/common/config/BogoSorterConfig.java @@ -41,6 +41,7 @@ public class BogoSorterConfig { public static void save(JsonObject json) { PlayerConfig playerConfig = PlayerConfig.getClient(); JsonObject general = new JsonObject(); + general.addProperty("enableHotbarSort", playerConfig.enableHotbarSort); general.addProperty("enableAutoRefill", playerConfig.enableAutoRefill); general.addProperty("refillDmgThreshold", playerConfig.autoRefillDamageThreshold); general.addProperty("enableDropoff", DropOffHandler.enableDropOff); @@ -93,6 +94,7 @@ public static void load(JsonObject json) { PlayerConfig playerConfig = PlayerConfig.getClient(); if (json.has("General")) { JsonObject general = json.getAsJsonObject("General"); + playerConfig.enableHotbarSort = JsonHelper.getBoolean(general, true, "enableHotbarSort"); playerConfig.enableAutoRefill = JsonHelper.getBoolean(general, true, "enableAutoRefill"); playerConfig.autoRefillDamageThreshold = (short) JsonHelper.getInt(general, 1, "refillDmgThreshold"); DropOffHandler.enableDropOff = JsonHelper.getBoolean(general, true, "enableDropoff"); diff --git a/src/main/java/com/cleanroommc/bogosorter/common/config/ConfigGui.java b/src/main/java/com/cleanroommc/bogosorter/common/config/ConfigGui.java index b763a8f..ce1c1df 100644 --- a/src/main/java/com/cleanroommc/bogosorter/common/config/ConfigGui.java +++ b/src/main/java/com/cleanroommc/bogosorter/common/config/ConfigGui.java @@ -143,6 +143,27 @@ public IWidget createGeneralConfigUI(GuiContext context) { .top(1) .left(32) .size(1, 56)) + .child( + new Row().widthRel(1f) + .height(14) + .margin(0, 2) + .child( + new CycleButtonWidget() + .value( + new BoolValue.Dynamic( + () -> PlayerConfig.getClient().enableHotbarSort, + val -> PlayerConfig.getClient().enableHotbarSort = val)) + .stateOverlay(TOGGLE_BUTTON) + .disableHoverBackground() + .size(14, 14) + .margin(8, 0) + .background(IDrawable.EMPTY)) + .child( + IKey.lang("bogosort.gui.enable_hotbarSort") + .asWidget() + .height(14) + .marginLeft(10) + .expanded())) .child( new Row().widthRel(1f) .height(14) diff --git a/src/main/java/com/cleanroommc/bogosorter/common/config/PlayerConfig.java b/src/main/java/com/cleanroommc/bogosorter/common/config/PlayerConfig.java index 0e90847..a796c4b 100644 --- a/src/main/java/com/cleanroommc/bogosorter/common/config/PlayerConfig.java +++ b/src/main/java/com/cleanroommc/bogosorter/common/config/PlayerConfig.java @@ -20,6 +20,7 @@ public class PlayerConfig { private static final Map playerConfig = new Object2ObjectOpenHashMap<>(); private static final PlayerConfig CLIENT = new PlayerConfig(); + public boolean enableHotbarSort = true; public boolean enableAutoRefill = true; public int autoRefillDamageThreshold = 1; @@ -44,11 +45,13 @@ public static PlayerConfig getClient() { } public void writePacket(PacketBuffer buffer) { + buffer.writeBoolean(enableHotbarSort); buffer.writeBoolean(enableAutoRefill); buffer.writeVarIntToBuffer(autoRefillDamageThreshold); } public void readPacket(PacketBuffer buffer) { + enableHotbarSort = buffer.readBoolean(); enableAutoRefill = buffer.readBoolean(); autoRefillDamageThreshold = buffer.readVarIntFromBuffer(); } diff --git a/src/main/resources/assets/bogosorter/lang/en_US.lang b/src/main/resources/assets/bogosorter/lang/en_US.lang index a6e7209..fde14c4 100644 --- a/src/main/resources/assets/bogosorter/lang/en_US.lang +++ b/src/main/resources/assets/bogosorter/lang/en_US.lang @@ -11,6 +11,7 @@ bogosort.gui.tab.item_sort_rules.name=Item sort rules bogosort.gui.tab.nbt_sort_rules.name=NBT sort rules bogosort.gui.available_sort_rules=Available Sort-Rules bogosort.gui.configured_sort_rules=Configured Sort-Rules +bogosort.gui.enable_hotbarSort=Enable hotbar sorting bogosort.gui.enable_refill=Enable auto hotbar refill bogosort.gui.refill_comment=Quark is installed. If this option is disabled, theirs might still be enabled. You can find the config at 'Management' -> 'Automatic Tool Restock'. bogosort.gui.refill_threshold=Auto refill damage threshold