aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java b/src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java
new file mode 100644
index 00000000..13f09ec6
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java
@@ -0,0 +1,40 @@
+package de.hysky.skyblocker.skyblock;
+
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.option.KeyBinding;
+import org.lwjgl.glfw.GLFW;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.List;
+
+public class HotbarSlotLock {
+ public static KeyBinding hotbarSlotLock;
+
+ public static void init() {
+ hotbarSlotLock = KeyBindingHelper.registerKeyBinding(new KeyBinding(
+ "key.hotbarSlotLock",
+ GLFW.GLFW_KEY_H,
+ "key.categories.skyblocker"
+ ));
+ }
+
+ public static boolean isLocked(int slot) {
+ return SkyblockerConfigManager.get().general.lockedSlots.contains(slot);
+ }
+
+ public static void handleDropSelectedItem(int slot, CallbackInfoReturnable<Boolean> cir) {
+ if (isLocked(slot)) cir.setReturnValue(false);
+ }
+
+ public static void handleInputEvents(ClientPlayerEntity player) {
+ while (hotbarSlotLock.wasPressed()) {
+ List<Integer> lockedSlots = SkyblockerConfigManager.get().general.lockedSlots;
+ int selected = player.getInventory().selectedSlot;
+ if (!isLocked(player.getInventory().selectedSlot)) lockedSlots.add(selected);
+ else lockedSlots.remove(Integer.valueOf(selected));
+ SkyblockerConfigManager.save();
+ }
+ }
+} \ No newline at end of file