mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 19:34:09 +00:00
Add Support for Next / Prev Buttons for Ability Hud
This commit is contained in:
1 parent
ce1ac1be84
commit
fa60ec42f3
3 files changed
+29
No files matched your search
@@ -266,6 +266,8 @@ public class ClientProxy extends CommonProxy {
|
||||
public static KeyBinding NPCButton;
|
||||
public static KeyBinding SpecialKey;
|
||||
public static KeyBinding AbilityHudKey;
|
||||
public static KeyBinding AbilityNextKey;
|
||||
public static KeyBinding AbilityPrevKey;
|
||||
public static final Random RAND = new Random();
|
||||
public static FontContainer Font;
|
||||
|
||||
@@ -351,6 +353,11 @@ public class ClientProxy extends CommonProxy {
|
||||
AbilityHudKey = new KeyBinding("key.customnpcs.abilityHudKey", Keyboard.KEY_LMENU, "key.categories.customnpc");
|
||||
ClientRegistry.registerKeyBinding(AbilityHudKey);
|
||||
|
||||
AbilityNextKey = new KeyBinding("key.customnpcs.abilityNext", Keyboard.KEY_NONE, "key.categories.customnpc");
|
||||
AbilityPrevKey = new KeyBinding("key.customnpcs.abilityPrev", Keyboard.KEY_NONE, "key.categories.customnpc");
|
||||
ClientRegistry.registerKeyBinding(AbilityNextKey);
|
||||
ClientRegistry.registerKeyBinding(AbilityPrevKey);
|
||||
|
||||
new PresetController(CustomNpcs.Dir);
|
||||
|
||||
if (ConfigMain.EnableUpdateChecker) {
|
||||
|
||||
@@ -8,6 +8,9 @@ import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.gui.hud.ClientHudManager;
|
||||
import noppes.npcs.client.gui.hud.EnumHudComponent;
|
||||
import noppes.npcs.client.gui.hud.ability.AbilityHotbarComponent;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -45,6 +48,7 @@ public class KeyPressHandler {
|
||||
|
||||
updateHeldStates(mc);
|
||||
handleNPCButton(mc);
|
||||
handleAbilityCycleKeys(mc);
|
||||
|
||||
if (!Keyboard.isRepeatEvent()) {
|
||||
int key = Keyboard.getEventKey();
|
||||
@@ -69,6 +73,7 @@ public class KeyPressHandler {
|
||||
// Just update held states and handle keybind actions.
|
||||
updateHeldStates(mc);
|
||||
handleNPCButton(mc);
|
||||
handleAbilityCycleKeys(mc);
|
||||
|
||||
int button = Mouse.getEventButton();
|
||||
if (button == -1 && Mouse.getEventDWheel() == 0)
|
||||
@@ -151,6 +156,21 @@ public class KeyPressHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleAbilityCycleKeys(Minecraft mc) {
|
||||
if (mc.currentScreen != null || mc.theWorld == null) return;
|
||||
|
||||
AbilityHotbarComponent comp = (AbilityHotbarComponent) ClientHudManager.getInstance()
|
||||
.getHudComponents().get(EnumHudComponent.AbilityHotbar);
|
||||
if (comp == null || !comp.hasAnyAbilities()) return;
|
||||
|
||||
if (ClientProxy.AbilityNextKey != null && ClientProxy.AbilityNextKey.isPressed()) {
|
||||
comp.onCycleNext();
|
||||
}
|
||||
if (ClientProxy.AbilityPrevKey != null && ClientProxy.AbilityPrevKey.isPressed()) {
|
||||
comp.onCyclePrev();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Public State Queries ─────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user