aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java
diff options
context:
space:
mode:
authormsg-programs <msgdoesstuff@gmail.com>2023-10-10 19:15:52 +0200
committermsg-programs <msgdoesstuff@gmail.com>2023-10-10 19:15:52 +0200
commitc1cc4ea51f84281336e6ca23bdd01e281d5fb4a3 (patch)
tree7082b35b68a915a18d1e1df171fae700bacd77e0 /src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java
parent87983958dcebd98f73c6971a5ea82c80871a12af (diff)
parenta373db64a319c263b2b4c1d07084fa18bd12353b (diff)
downloadSkyblocker-c1cc4ea51f84281336e6ca23bdd01e281d5fb4a3.tar.gz
Skyblocker-c1cc4ea51f84281336e6ca23bdd01e281d5fb4a3.tar.bz2
Skyblocker-c1cc4ea51f84281336e6ca23bdd01e281d5fb4a3.zip
Merge branch 'master' of https://github.com/SkyblockerMod/Skyblocker into beeper-creams
# Conflicts: # src/main/java/de/hysky/skyblocker/SkyblockerMod.java # src/main/java/de/hysky/skyblocker/skyblock/dungeon/CreeperBeams.java Pull updates from upstream and NOT get a heart attack
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