mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 13:52:23 +00:00
Add Chained Abilities
This commit is contained in:
1 parent
0311dc5806
commit
0512588a7a
51 files changed
+2955
-800
No files matched your search
@@ -6,7 +6,7 @@ import foxz.command.ScriptedCommand;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.TelegraphController;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.entity.EntityAbilityBeam;
|
||||
import kamkeel.npcs.entity.EntityAbilityDisc;
|
||||
import kamkeel.npcs.entity.EntityAbilityLaser;
|
||||
@@ -480,6 +480,8 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
data = new ScriptEntityData(new noppes.npcs.scripted.entity.ScriptEnergyDome<>((kamkeel.npcs.entity.EntityEnergyDome) entity));
|
||||
else if (entity instanceof kamkeel.npcs.entity.EntityEnergyPanel)
|
||||
data = new ScriptEntityData(new noppes.npcs.scripted.entity.ScriptEnergyPanel<>((kamkeel.npcs.entity.EntityEnergyPanel) entity));
|
||||
else if (entity instanceof kamkeel.npcs.entity.EntityAbilitySweeper)
|
||||
data = new ScriptEntityData(new noppes.npcs.scripted.entity.ScriptEnergySweeper<>((kamkeel.npcs.entity.EntityAbilitySweeper) entity));
|
||||
else
|
||||
data = new ScriptEntityData(new ScriptEntity<>(entity));
|
||||
entity.registerExtendedProperties("ScriptedObject", data);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import kamkeel.npcs.entity.EntityAbilitySweeper;
|
||||
|
||||
public class ScriptEnergySweeper<T extends EntityAbilitySweeper> extends ScriptEnergyAbility<T> {
|
||||
public ScriptEnergySweeper(T entity) {
|
||||
super(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package noppes.npcs.scripted.wrapper;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityAction;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.DataAbilities;
|
||||
@@ -90,7 +90,7 @@ public class ScriptDataAbilities implements IDataAbilities {
|
||||
if (slot.getReferenceId().equals(abilityId)) return true;
|
||||
} else if (!slot.isReference()) {
|
||||
Ability a = slot.getAbility();
|
||||
if (a != null && a.getId().equals(abilityId)) return false;
|
||||
if (a != null && abilityId.equals(a.getId())) return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -135,10 +135,11 @@ public class ScriptDataAbilities implements IDataAbilities {
|
||||
|
||||
@Override
|
||||
public void setGlobalCooldown(int ticks) {
|
||||
// Set the cooldown by manipulating the internal cooldown end time
|
||||
// Not directly exposed, but we can reset and let it tick down
|
||||
data.resetCooldown();
|
||||
// This is a best-effort implementation
|
||||
if (ticks <= 0) {
|
||||
data.resetCooldown();
|
||||
} else {
|
||||
data.setCooldownEndTime(npc.worldObj.getTotalWorldTime() + ticks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package noppes.npcs.scripted.wrapper;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.api.ability.IAbility;
|
||||
import noppes.npcs.api.ability.IPlayerAbilityData;
|
||||
@@ -43,12 +43,14 @@ public class ScriptPlayerAbilityData implements IPlayerAbilityData {
|
||||
|
||||
@Override
|
||||
public void lockAbility(String key) {
|
||||
data.lockAbility(key);
|
||||
String canonicalKey = resolveCanonicalKey(key);
|
||||
data.lockAbility(canonicalKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUnlockedAbility(String key) {
|
||||
return data.hasUnlockedAbility(key);
|
||||
String canonicalKey = resolveCanonicalKey(key);
|
||||
return data.hasUnlockedAbility(canonicalKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,4 +133,16 @@ public class ScriptPlayerAbilityData implements IPlayerAbilityData {
|
||||
if (player == null) return false;
|
||||
return data.activateAbility(player, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a user-provided key to the canonical storage key.
|
||||
* Uses the same resolution as unlockAbility: registry key for built-in, UUID for custom.
|
||||
*/
|
||||
private String resolveCanonicalKey(String key) {
|
||||
Ability ability = AbilityController.Instance.resolveAbility(key);
|
||||
if (ability != null && ability.getId() != null) {
|
||||
return ability.getId();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user