Add ability wheel and toggle abilities for enhanced gameplay

This commit is contained in:
Kam committed 2026-02-05 22:49:40 -05:00
1 parent 45a4313b70
commit 095709b9d2
9 files changed
+330 -10

No files matched your search

@@ -368,6 +368,11 @@ public class DataAbilities {
* Check if a specific ability is eligible for use.
*/
private boolean isAbilityEligible(Ability ability, EntityLivingBase target) {
// Check UserType allows NPCs
if (!ability.getAllowedBy().allowsNpc()) {
return false;
}
// Check enabled
if (!ability.isEnabled()) {
return false;
@@ -695,6 +700,11 @@ public class DataAbilities {
return false;
}
// Check UserType allows NPCs
if (!ability.getAllowedBy().allowsNpc()) {
return false;
}
// Stop any currently executing ability
stopCurrentAbility();
@@ -2,6 +2,7 @@ package noppes.npcs;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.data.ParticlePacket;
@@ -792,6 +793,9 @@ public class NoppesUtilServer {
if (controller != null) {
int index = 0;
for (String uuid : controller.getCustomAbilityIds()) {
Ability ability = controller.getCustomAbility(uuid);
if (ability == null || !ability.getAllowedBy().allowsNpc()) continue;
String name = controller.getCustomAbilityName(uuid);
if (name == null || name.isEmpty()) name = uuid;
map.put(name + "\t" + uuid, index++);
@@ -334,8 +334,12 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
Map<String, Integer> dummyMap = new HashMap<>(allAbilityTypes);
filteredAbilityTypes.clear();
filteredAbilityTypes.putAll(getFilteredData(dummyMap));
}
// Reset scroll position when changing category
if (availableTypesScroll != null) {
availableTypesScroll.resetScroll();
}
}
initGui();
}
@@ -42,12 +42,25 @@ public class ScriptDataAbilities implements IDataAbilities {
@Override
public void addAbility(IAbility ability) {
if (ability instanceof Ability) {
data.addAbility((Ability) ability);
Ability a = (Ability) ability;
// Validate ability allows NPCs
if (!a.getAllowedBy().allowsNpc()) {
return; // Ability is PLAYER_ONLY
}
data.addAbility(a);
}
}
@Override
public void addAbilityReference(String key) {
// Validate ability exists and allows NPCs
Ability ability = AbilityController.Instance.resolveAbility(key);
if (ability == null) {
return; // Ability doesn't exist
}
if (!ability.getAllowedBy().allowsNpc()) {
return; // Ability is PLAYER_ONLY
}
data.addAbilityReference(key);
}
@@ -158,6 +171,14 @@ public class ScriptDataAbilities implements IDataAbilities {
@Override
public boolean executeAbility(String key, Object target) {
// Validate ability exists and allows NPCs
Ability ability = AbilityController.Instance.resolveAbility(key);
if (ability == null) {
return false; // Ability doesn't exist
}
if (!ability.getAllowedBy().allowsNpc()) {
return false; // Ability is PLAYER_ONLY
}
EntityLivingBase targetEntity = resolveTarget(target);
return data.executeAbility(key, targetEntity);
}
@@ -1,5 +1,7 @@
package noppes.npcs.scripted.wrapper;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.api.ability.IPlayerAbilityData;
@@ -26,7 +28,17 @@ public class ScriptPlayerAbilityData implements IPlayerAbilityData {
@Override
public void unlockAbility(String key) {
data.unlockAbility(key);
// Validate ability exists and allows players
Ability ability = AbilityController.Instance.resolveAbility(key);
if (ability == null) {
return; // Ability doesn't exist
}
if (!ability.getAllowedBy().allowsPlayer()) {
return; // Ability is NPC-only
}
// Use canonical key (registry key for built-in, UUID for custom)
String canonicalKey = ability.getId() != null ? ability.getId() : key;
data.unlockAbility(canonicalKey);
}
@Override