mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-15 21:54:44 +00:00
Player Abilities
This commit is contained in:
1 parent
06c9daf81b
commit
db6a68e430
7 files changed
+261
-28
No files matched your search
@@ -151,6 +151,28 @@ public interface IAbility {
|
||||
*/
|
||||
int getCurrentTick();
|
||||
|
||||
/**
|
||||
* Get the allowed user type for this ability.
|
||||
* @return 0=NPC_ONLY, 1=PLAYER_ONLY, 2=BOTH
|
||||
*/
|
||||
int getAllowedByType();
|
||||
|
||||
/**
|
||||
* Set the allowed user type for this ability.
|
||||
* @param type 0=NPC_ONLY, 1=PLAYER_ONLY, 2=BOTH
|
||||
*/
|
||||
void setAllowedByType(int type);
|
||||
|
||||
/**
|
||||
* Check if this ability ignores cooldowns.
|
||||
*/
|
||||
boolean isIgnoreCooldown();
|
||||
|
||||
/**
|
||||
* Set whether this ability ignores cooldowns.
|
||||
*/
|
||||
void setIgnoreCooldown(boolean ignore);
|
||||
|
||||
/**
|
||||
* Get this ability's data as NBT.
|
||||
*/
|
||||
|
||||
@@ -30,4 +30,22 @@ public interface IAbilityHandler {
|
||||
* Returns null if the type is not registered.
|
||||
*/
|
||||
IAbility create(String typeId);
|
||||
|
||||
/**
|
||||
* Register a pre-configured ability by name.
|
||||
* These abilities are resolved by name and can be referenced by NPCs and players.
|
||||
* Call during FMLInitializationEvent.
|
||||
*
|
||||
* @param name The unique name for the ability
|
||||
* @param ability The ability instance
|
||||
*/
|
||||
void registerAbility(String name, IAbility ability);
|
||||
|
||||
/**
|
||||
* Check if a registered ability exists by name.
|
||||
*
|
||||
* @param name The ability name
|
||||
* @return true if the ability exists
|
||||
*/
|
||||
boolean hasAbility(String name);
|
||||
}
|
||||
@@ -17,15 +17,20 @@ public interface IDataAbilities {
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Get all abilities assigned to this NPC.
|
||||
* Get all abilities assigned to this NPC (resolved from slots).
|
||||
*/
|
||||
IAbility[] getAbilities();
|
||||
|
||||
/**
|
||||
* Add an ability to this NPC.
|
||||
* Add an inline ability to this NPC.
|
||||
*/
|
||||
void addAbility(IAbility ability);
|
||||
|
||||
/**
|
||||
* Add a reference ability by key (built-in name or custom UUID).
|
||||
*/
|
||||
void addAbilityReference(String key);
|
||||
|
||||
/**
|
||||
* Remove an ability by ID.
|
||||
*/
|
||||
@@ -41,6 +46,17 @@ public interface IDataAbilities {
|
||||
*/
|
||||
boolean hasAbility(String abilityId);
|
||||
|
||||
/**
|
||||
* Check if a slot is a reference (by ability ID).
|
||||
*/
|
||||
boolean isAbilityReference(String abilityId);
|
||||
|
||||
/**
|
||||
* Convert a reference slot to inline (by ability ID).
|
||||
* Returns false if the reference cannot be resolved.
|
||||
*/
|
||||
boolean convertToInline(String abilityId);
|
||||
|
||||
/**
|
||||
* Clear all abilities from this NPC.
|
||||
*/
|
||||
@@ -96,25 +112,25 @@ public interface IDataAbilities {
|
||||
boolean forceStartAbility(String abilityId, Object target);
|
||||
|
||||
/**
|
||||
* Execute a preset ability on this NPC by preset name.
|
||||
* Execute an ability on this NPC by key (built-in name or custom UUID).
|
||||
* The NPC does NOT need to have this ability assigned.
|
||||
* If an ability is currently executing, it will be cancelled.
|
||||
*
|
||||
* @param presetName The name of the saved ability preset
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
* @return true if the ability was started successfully
|
||||
*/
|
||||
boolean executePresetAbility(String presetName);
|
||||
boolean executeAbility(String key);
|
||||
|
||||
/**
|
||||
* Execute a preset ability on this NPC with a specific target.
|
||||
* Execute an ability on this NPC with a specific target.
|
||||
* The NPC does NOT need to have this ability assigned.
|
||||
* If an ability is currently executing, it will be cancelled.
|
||||
*
|
||||
* @param presetName The name of the saved ability preset
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
* @param target The target entity (can be null for self-targeted abilities)
|
||||
* @return true if the ability was started successfully
|
||||
*/
|
||||
boolean executePresetAbility(String presetName, Object target);
|
||||
boolean executeAbility(String key, Object target);
|
||||
|
||||
/**
|
||||
* Create a new ability instance by type ID.
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package noppes.npcs.api.ability;
|
||||
|
||||
/**
|
||||
* Interface for managing player abilities.
|
||||
* Players reference abilities by key (built-in names or custom UUIDs).
|
||||
* <p>
|
||||
* Access via IPlayerData.getAbilityData()
|
||||
*/
|
||||
public interface IPlayerAbilityData {
|
||||
|
||||
/**
|
||||
* Get all unlocked ability keys.
|
||||
*/
|
||||
String[] getUnlockedAbilities();
|
||||
|
||||
/**
|
||||
* Unlock an ability for this player.
|
||||
*
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
*/
|
||||
void unlockAbility(String key);
|
||||
|
||||
/**
|
||||
* Lock (remove) an ability from this player.
|
||||
*/
|
||||
void lockAbility(String key);
|
||||
|
||||
/**
|
||||
* Check if the player has unlocked a specific ability.
|
||||
*/
|
||||
boolean hasUnlockedAbility(String key);
|
||||
|
||||
/**
|
||||
* Get the currently selected ability index.
|
||||
*/
|
||||
int getSelectedIndex();
|
||||
|
||||
/**
|
||||
* Set the selected ability index.
|
||||
*/
|
||||
void setSelectedIndex(int index);
|
||||
|
||||
/**
|
||||
* Get the key of the currently selected ability.
|
||||
*/
|
||||
String getSelectedAbilityKey();
|
||||
|
||||
/**
|
||||
* Select the next ability in the list.
|
||||
*/
|
||||
void selectNext();
|
||||
|
||||
/**
|
||||
* Select the previous ability in the list.
|
||||
*/
|
||||
void selectPrevious();
|
||||
|
||||
/**
|
||||
* Check if the player is currently executing an ability.
|
||||
*/
|
||||
boolean isExecutingAbility();
|
||||
|
||||
/**
|
||||
* Get the currently executing ability.
|
||||
*/
|
||||
IAbility getCurrentAbility();
|
||||
|
||||
/**
|
||||
* Interrupt the currently executing ability.
|
||||
*/
|
||||
void interruptCurrentAbility();
|
||||
|
||||
/**
|
||||
* Check if the player is on universal cooldown.
|
||||
*/
|
||||
boolean isOnCooldown();
|
||||
|
||||
/**
|
||||
* Check if a specific ability is on cooldown.
|
||||
*
|
||||
* @param key The ability key
|
||||
* @return true if on cooldown
|
||||
*/
|
||||
boolean isOnCooldown(String key);
|
||||
|
||||
/**
|
||||
* Reset the universal cooldown.
|
||||
*/
|
||||
void resetCooldown();
|
||||
|
||||
/**
|
||||
* Reset cooldown for a specific ability key.
|
||||
*
|
||||
* @param key The ability key
|
||||
*/
|
||||
void resetCooldown(String key);
|
||||
|
||||
/**
|
||||
* Reset all cooldowns.
|
||||
*/
|
||||
void resetAllCooldowns();
|
||||
|
||||
/**
|
||||
* Activate the currently selected ability.
|
||||
*/
|
||||
boolean activateAbility();
|
||||
|
||||
/**
|
||||
* Activate a specific ability by key.
|
||||
*/
|
||||
boolean activateAbility(String key);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package noppes.npcs.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.api.ability.IAbility;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
|
||||
/**
|
||||
* Events related to player ability execution.
|
||||
* These events are fired during the ability lifecycle when a player uses an ability.
|
||||
*/
|
||||
public interface IPlayerAbilityEvent extends IPlayerEvent {
|
||||
|
||||
/**
|
||||
* Get the ability involved in this event.
|
||||
*/
|
||||
IAbility getAbility();
|
||||
|
||||
/**
|
||||
* Get the target of the ability, or null if no target.
|
||||
*/
|
||||
IEntityLivingBase getTarget();
|
||||
|
||||
/**
|
||||
* Fired when a player's ability hits an entity with damage.
|
||||
* Canceling this event prevents the damage from being applied.
|
||||
*/
|
||||
@Cancelable
|
||||
interface HitEvent extends IPlayerAbilityEvent {
|
||||
/**
|
||||
* Get the entity that was hit by the ability.
|
||||
*/
|
||||
IEntityLivingBase getHitEntity();
|
||||
|
||||
/**
|
||||
* Get the damage amount.
|
||||
*/
|
||||
float getDamage();
|
||||
|
||||
/**
|
||||
* Set the damage amount. Allows scripts to modify damage.
|
||||
*/
|
||||
void setDamage(float damage);
|
||||
|
||||
/**
|
||||
* Get the horizontal knockback amount.
|
||||
*/
|
||||
float getKnockback();
|
||||
|
||||
/**
|
||||
* Set the horizontal knockback amount.
|
||||
*/
|
||||
void setKnockback(float knockback);
|
||||
|
||||
/**
|
||||
* Get the vertical knockback (upward force) amount.
|
||||
*/
|
||||
float getKnockbackUp();
|
||||
|
||||
/**
|
||||
* Set the vertical knockback (upward force) amount.
|
||||
*/
|
||||
void setKnockbackUp(float knockbackUp);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package noppes.npcs.api.handler;
|
||||
|
||||
/**
|
||||
* Handler for ability presets. Allows scripts to save, load, and manage
|
||||
* reusable ability templates.
|
||||
* Handler for ability management. Allows scripts to query ability types,
|
||||
* built-in abilities, and custom ability presets.
|
||||
* <p>
|
||||
* Access via API.getAbilities()
|
||||
*/
|
||||
@@ -10,40 +10,38 @@ public interface IAbilityHandler {
|
||||
|
||||
/**
|
||||
* Get all registered ability type IDs.
|
||||
* These are the types that can be used to create new abilities.
|
||||
*
|
||||
* @return Array of type IDs (e.g., "cnpc:slam", "cnpc:charge")
|
||||
*/
|
||||
String[] getTypes();
|
||||
|
||||
/**
|
||||
* Check if an ability type is registered.
|
||||
*
|
||||
* @param typeId The type ID to check
|
||||
* @return true if the type exists
|
||||
*/
|
||||
boolean hasType(String typeId);
|
||||
|
||||
/**
|
||||
* Get all saved ability preset names.
|
||||
*
|
||||
* @return Array of saved ability names
|
||||
* Get all built-in ability names.
|
||||
*/
|
||||
String[] getSavedNames();
|
||||
String[] getAbilityNameArray();
|
||||
|
||||
/**
|
||||
* Check if a saved ability preset exists.
|
||||
*
|
||||
* @param name The name of the ability
|
||||
* @return true if the preset exists
|
||||
* Check if a built-in ability exists by name.
|
||||
*/
|
||||
boolean has(String name);
|
||||
boolean hasAbilityName(String name);
|
||||
|
||||
/**
|
||||
* Delete a saved ability preset.
|
||||
* Get all custom ability preset UUIDs.
|
||||
*/
|
||||
String[] getCustomAbilityIdArray();
|
||||
|
||||
/**
|
||||
* Check if a custom ability preset exists by UUID.
|
||||
*/
|
||||
boolean hasCustomAbilityId(String uuid);
|
||||
|
||||
/**
|
||||
* Delete a custom ability preset by UUID.
|
||||
*
|
||||
* @param name The name of the ability to delete
|
||||
* @return true if deleted successfully
|
||||
*/
|
||||
boolean delete(String name);
|
||||
boolean deleteCustomAbilityById(String uuid);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.api.handler;
|
||||
|
||||
import noppes.npcs.api.ability.IPlayerAbilityData;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
|
||||
public interface IPlayerData {
|
||||
@@ -28,5 +29,7 @@ public interface IPlayerData {
|
||||
|
||||
IPlayerTradeData getTradeData();
|
||||
|
||||
IPlayerAbilityData getAbilityData();
|
||||
|
||||
void save();
|
||||
}
|
||||
Reference in new issue
Block a user