diff options
author | Yasin <a.piri@hotmail.de> | 2023-10-09 12:58:02 +0200 |
---|---|---|
committer | Yasin <a.piri@hotmail.de> | 2023-10-09 12:58:02 +0200 |
commit | bd3f0329d0e391bd84b5f9e3ff207d9dd9815853 (patch) | |
tree | 2fd1d1ef625f57acc2e4916c967d8d2393844798 /src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java | |
parent | 2315b90da8117f28f66348927afdb621ee4fc815 (diff) | |
download | Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.gz Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.bz2 Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.zip |
new pr because fixing merge conflict would take too long
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/HotbarSlotLock.java | 40 |
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 |