Remove all Legacy Ability Content, cleanup API.

- Add Script Tab to Abilities
- Add Custom Ability
- Add Icon Support for Abilities / Default Icon Support
- Remove Icon Tab and throw it into Effects with allowed Override
- Removed Deprecated API Sources
This commit is contained in:
Kam committed 2026-02-27 16:43:35 -05:00
1 parent 936dc7f0cc
commit 675c4ef4f9
50 files changed
+1488 -938

No files matched your search

@@ -36,23 +36,20 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import noppes.npcs.DataAbilities;
import noppes.npcs.NpcDamageSource;
import noppes.npcs.api.INbt;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.builder.FieldDef;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.Frame;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.AbilityScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.EventHooks;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.AbilityEvent;
import noppes.npcs.scripted.event.player.PlayerAbilityEvent;
import java.util.ArrayList;
import java.util.Collections;
@@ -139,6 +136,13 @@ public abstract class Ability implements IAbility, IAbilityAction {
protected transient boolean builtIn = false;
protected transient String registryKey;
// Default icon (set in subclass constructors, NOT persisted)
protected transient String defaultIconTexture = "";
protected transient java.util.function.IntSupplier defaultIconColorSource = null;
protected transient int defaultIconWidth = 48;
protected transient int defaultIconHeight = 48;
protected transient String[] defaultIconStateTextures = null;
// ═══════════════════════════════════════════════════════════════════
// TOGGLE CONFIGURATION (saved to NBT for custom abilities)
// ═══════════════════════════════════════════════════════════════════
@@ -295,28 +299,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
// ═══════════════════════════════════════════════════════════════════
/**
* Called when this toggle ability is first activated (state goes from 0 to any active state).
* Override to apply effects (e.g., set a DBC flag, apply a buff).
*/
public void onToggleOn(EntityLivingBase caster) {
}
/**
* Called when this toggle ability is fully deactivated (state goes to 0).
* Override to remove effects (e.g., clear a DBC flag, remove a buff).
*/
public void onToggleOff(EntityLivingBase caster) {
}
/**
* Called whenever the toggle state changes (including on/off transitions and mid-cycling).
* For multi-state toggles, this fires on every state transition.
* Called whenever the toggle state changes (activation, deactivation, or mid-cycling).
* Override to apply/remove effects based on state transitions.
*
* @param caster The entity
* @param oldState Previous state (0 = was off)
* @param newState New state (0 = now off, 1+ = active state)
*/
public void onToggleStateChanged(EntityLivingBase caster, int oldState, int newState) {
public void onToggle(EntityLivingBase caster, int oldState, int newState) {
}
/**
@@ -432,39 +422,15 @@ public abstract class Ability implements IAbility, IAbilityAction {
private boolean applyAbilityDamageInternal(EntityLivingBase caster, EntityLivingBase hitEntity,
float damage, float knockback, float knockbackUp,
double knockbackDirX, double knockbackDirZ) {
// Fire hit event for NPC casters (NPC event system)
if (caster instanceof EntityNPCInterface) {
EntityNPCInterface npc = (EntityNPCInterface) caster;
DataAbilities dataAbilities = npc.abilities;
AbilityEvent.HitEvent event = dataAbilities.fireHitEvent(
this, currentTarget, hitEntity, damage, knockback, knockbackUp);
if (event == null) {
return false; // Cancelled
}
damage = event.getDamage();
knockback = event.getKnockback();
knockbackUp = event.getKnockbackUp();
}
// Fire hit event for Player casters (Player event system)
else if (caster instanceof EntityPlayer && ScriptController.Instance != null) {
EntityPlayer player = (EntityPlayer) caster;
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
if (handler != null) {
IPlayer iPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
PlayerAbilityEvent.HitEvent event = new PlayerAbilityEvent.HitEvent(
iPlayer, this, currentTarget, hitEntity, damage, knockback, knockbackUp);
if (noppes.npcs.EventHooks.onPlayerAbilityHit(handler, event)) {
return false; // Cancelled
}
damage = event.getDamage();
knockback = event.getKnockback();
knockbackUp = event.getKnockbackUp();
}
// Fire hit event (unified — works for both NPC and Player casters)
AbilityEvent.HitEvent hitEvent = new AbilityEvent.HitEvent(
caster, this, currentTarget, hitEntity, damage, knockback, knockbackUp);
if (EventHooks.onAbilityHit(this, hitEvent)) {
return false; // Cancelled
}
damage = hitEvent.getDamage();
knockback = hitEvent.getKnockback();
knockbackUp = hitEvent.getKnockbackUp();
// Save velocity before damage to cancel vanilla knockback when ability knockback is zero
double prevMotionX = hitEntity.motionX;
@@ -809,23 +775,30 @@ public abstract class Ability implements IAbility, IAbilityAction {
}
}
// ── Icon tab (native) ─────────────────────────────────────
// ── Icon section (Effects tab) ───────────────────────────
if (!isNpcInlineEdit()) {
AbilityIconData icon = AbilityIconData.fromAbility(this);
defs.add(FieldDef.section("ability.section.icon").tab("Effects"));
defs.add(FieldDef.boolField("ability.hasIcon", icon::isEnabled, icon::setEnabled)
.tab("Effects"));
defs.add(FieldDef.stringField("gui.texture", icon::getTexture, icon::setTexture)
.tab("Icon"));
defs.add(FieldDef.section("ability.icon.section.uv").tab("Icon"));
.tab("Effects").visibleWhen(icon::isEnabled));
defs.add(FieldDef.section("ability.icon.section.uv").tab("Effects")
.visibleWhen(icon::isEnabled));
defs.add(FieldDef.intField("ability.icon.x", icon::getIconX, icon::setIconX)
.tab("Icon").range(0, 4096));
.tab("Effects").range(0, 4096).visibleWhen(icon::isEnabled));
defs.add(FieldDef.intField("ability.icon.y", icon::getIconY, icon::setIconY)
.tab("Icon").range(0, 4096));
defs.add(FieldDef.section("gui.size").tab("Icon"));
.tab("Effects").range(0, 4096).visibleWhen(icon::isEnabled));
defs.add(FieldDef.section("gui.size").tab("Effects")
.visibleWhen(icon::isEnabled));
defs.add(FieldDef.intField("gui.width", icon::getWidth, icon::setWidth)
.tab("Icon").range(1, 256));
.tab("Effects").range(1, 256).visibleWhen(icon::isEnabled));
defs.add(FieldDef.intField("gui.height", icon::getHeight, icon::setHeight)
.tab("Icon").range(1, 256));
.tab("Effects").range(1, 256).visibleWhen(icon::isEnabled));
defs.add(FieldDef.floatField("gui.scale", icon::getScale, icon::setScale)
.tab("Icon").range(0.1f, 10.0f));
.tab("Effects").range(0.1f, 10.0f).visibleWhen(icon::isEnabled));
defs.add(FieldDef.colorSubGui("ability.icon.tint", icon::getTintColor, icon::setTintColor)
.tab("Effects").visibleWhen(icon::isEnabled));
}
// External field providers (e.g., DBC Addon injecting a "DBC" tab)
@@ -1378,7 +1351,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
// NBT (config only, execution state is transient)
// ═══════════════════════════════════════════════════════════════════
public NBTTagCompound writeNBT() {
public NBTTagCompound writeNBT(boolean saveScripts) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("id", id);
nbt.setString("name", name);
@@ -1452,6 +1425,16 @@ public abstract class Ability implements IAbility, IAbilityAction {
writeTypeNBT(typeNBT);
nbt.setTag("typeData", typeNBT);
// Script handler data (matching CustomEffect.writeToNBT pattern)
if (saveScripts) {
AbilityScript handler = getScriptHandler();
if (handler != null) {
NBTTagCompound scriptData = new NBTTagCompound();
handler.writeToNBT(scriptData);
nbt.setTag("ScriptData", scriptData);
}
}
return nbt;
}
@@ -1548,6 +1531,13 @@ public abstract class Ability implements IAbility, IAbilityAction {
if (nbt.hasKey("typeData")) {
readTypeNBT(nbt.getCompoundTag("typeData"));
}
// Script handler data (matching CustomEffect.readFromNBT pattern)
if (nbt.hasKey("ScriptData", 10)) {
AbilityScript handler = new AbilityScript(this.id);
handler.readFromNBT(nbt.getCompoundTag("ScriptData"));
setScriptHandler(handler);
}
}
// ═══════════════════════════════════════════════════════════════════
@@ -1627,8 +1617,48 @@ public abstract class Ability implements IAbility, IAbilityAction {
this.typeId = "ability." + registryKey.replace(':', '.');
}
// ═══════════════════════════════════════════════════════════════════
// DEFAULT ICON
// ═══════════════════════════════════════════════════════════════════
public String getDefaultIconTexture() {
return defaultIconTexture;
}
/**
* Returns the default icon texture for a specific toggle state.
* Falls back to the base defaultIconTexture if no state-specific texture exists.
* @param state 1-indexed toggle state (0 = off/default)
*/
public String getDefaultIconTextureForState(int state) {
if (state > 0 && defaultIconStateTextures != null && state - 1 < defaultIconStateTextures.length) {
return defaultIconStateTextures[state - 1];
}
return defaultIconTexture;
}
public int getDefaultIconColor() {
return defaultIconColorSource != null ? defaultIconColorSource.getAsInt() : 0xFFFFFF;
}
public int getDefaultIconWidth() {
return defaultIconWidth;
}
public int getDefaultIconHeight() {
return defaultIconHeight;
}
public String[] getDefaultIconStateTextures() {
return defaultIconStateTextures;
}
public boolean hasDefaultIcon() {
return defaultIconTexture != null && !defaultIconTexture.isEmpty();
}
public Ability deepCopy() {
return AbilityController.Instance.fromNBT(this.writeNBT());
return AbilityController.Instance.fromNBT(this.writeNBT(true));
}
@Override
@@ -2497,11 +2527,35 @@ public abstract class Ability implements IAbility, IAbilityAction {
@Override
public INbt getNbt() {
return NpcAPI.Instance().getINbt(writeNBT());
return NpcAPI.Instance().getINbt(writeNBT(false));
}
@Override
public void setNbt(INbt nbt) {
readNBT(nbt.getMCNBT());
}
// ═══════════════════════════════════════════════════════════════════
// SCRIPT HANDLER
// ═══════════════════════════════════════════════════════════════════
public AbilityScript getScriptHandler() {
if (this.id == null || this.id.isEmpty()) return null;
return AbilityController.Instance.abilityScriptHandlers.get(this.id);
}
public void setScriptHandler(AbilityScript handler) {
if (this.id == null || this.id.isEmpty()) return;
AbilityController.Instance.abilityScriptHandlers.put(this.id, handler);
}
public AbilityScript getOrCreateScriptHandler() {
if (this.id == null || this.id.isEmpty()) return null;
AbilityScript handler = getScriptHandler();
if (handler == null) {
handler = new AbilityScript(this.id);
AbilityController.Instance.abilityScriptHandlers.put(this.id, handler);
}
return handler;
}
}
@@ -218,7 +218,7 @@ public class AbilityAction {
Ability resolved = getAbility();
if (resolved == null) return false;
inlineAbility = AbilityController.Instance.fromNBT(resolved.writeNBT());
inlineAbility = AbilityController.Instance.fromNBT(resolved.writeNBT(true));
slotType = SlotType.INLINE_ABILITY;
referenceId = null;
cachedAction = null;
@@ -245,12 +245,12 @@ public class AbilityAction {
// NBT
// ═══════════════════════════════════════════════════════════════════
public NBTTagCompound writeNBT() {
public NBTTagCompound writeNBT(boolean saveScripts) {
switch (slotType) {
case INLINE_CHAIN: {
NBTTagCompound nbt = new NBTTagCompound();
if (inlineChain != null) {
nbt.setTag("InlineChain", inlineChain.writeNBT());
nbt.setTag("InlineChain", inlineChain.writeNBT(saveScripts));
}
return nbt;
}
@@ -275,7 +275,7 @@ public class AbilityAction {
case INLINE_ABILITY:
default:
return inlineAbility != null ? inlineAbility.writeNBT() : new NBTTagCompound();
return inlineAbility != null ? inlineAbility.writeNBT(saveScripts) : new NBTTagCompound();
}
}
@@ -0,0 +1,165 @@
package kamkeel.npcs.controllers.data.ability;
import kamkeel.npcs.controllers.data.ability.enums.LockMode;
import kamkeel.npcs.controllers.data.ability.enums.TargetingMode;
import kamkeel.npcs.controllers.data.ability.enums.UserType;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.ICustomAbility;
import noppes.npcs.client.gui.builder.FieldDef;
import java.util.List;
/**
* A blank-slate ability that does nothing by itself.
* All behavior is driven by script event hooks (abilityStart, abilityTick, abilityComplete,
* abilityToggle, abilityToggleTick).
* <p>
* Supports two modes based on toggle configuration:
* <ul>
* <li><b>Instant mode</b> (toggleStates = 0): Uses standard execution lifecycle with
* configurable duration. Script hooks: abilityStart, abilityTick, abilityComplete.</li>
* <li><b>Toggle mode</b> (toggleStates >= 1): Uses toggle lifecycle.
* Script hooks: abilityToggle, abilityToggleTick.</li>
* </ul>
*/
public class CustomAbility extends Ability implements ICustomAbility {
private int durationTicks = 20;
public CustomAbility() {
this.typeId = "ability.cnpc.custom";
this.name = "Custom";
this.targetingMode = TargetingMode.SELF;
this.lockMovement = LockMode.NO;
this.cooldownTicks = 0;
this.windUpTicks = 0;
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
}
// ==================== EXECUTION ====================
@Override
public void onExecute(EntityLivingBase caster, EntityLivingBase target) {
if (durationTicks <= 0) {
signalCompletion();
}
}
@Override
public void onActiveTick(EntityLivingBase caster, EntityLivingBase target, int tick) {
if (durationTicks > 0 && tick >= durationTicks) {
signalCompletion();
}
}
// ==================== PROPERTIES ====================
@Override
public boolean hasDamage() {
return false;
}
@Override
public boolean isConcurrentCapable() {
return true;
}
@Override
public boolean isTargetingModeLocked() {
return false;
}
@Override
public boolean allowFreeOnCast() {
return true;
}
// ==================== FIELDS ====================
@Override
public int getDurationTicks() {
return durationTicks;
}
@Override
public void setDurationTicks(int ticks) {
this.durationTicks = Math.max(0, ticks);
}
// ==================== ICustomAbility ====================
@Override
public int getTelegraphShapeType() {
return getTelegraphType().ordinal();
}
@Override
public void setTelegraphShapeType(int type) {
TelegraphType[] values = TelegraphType.values();
if (type >= 0 && type < values.length) {
setTelegraphType(values[type]);
}
}
@Override
public int getTargetingModeType() {
return getTargetingMode().ordinal();
}
@Override
public void setTargetingModeType(int type) {
TargetingMode[] values = TargetingMode.values();
if (type >= 0 && type < values.length) {
setTargetingMode(values[type]);
}
}
// ==================== NBT ====================
@Override
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setInteger("durationTicks", durationTicks);
}
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.durationTicks = nbt.getInteger("durationTicks");
}
// ==================== GUI ====================
@Override
public void getAbilityDefinitions(List<FieldDef> defs) {
// User Type (NPC / Player / Both)
defs.add(FieldDef.enumField("ability.allowedBy", UserType.class,
this::getAllowedBy, this::setAllowedBy));
// Targeting Mode
defs.add(FieldDef.enumField("ability.targetingMode", TargetingMode.class,
this::getTargetingMode, this::setTargetingMode));
// Telegraph Shape
defs.add(FieldDef.enumField("ability.telegraphShape", TelegraphType.class,
this::getTelegraphType, this::setTelegraphType));
// Toggle section
defs.add(FieldDef.section("ability.section.toggle"));
defs.add(FieldDef.boolField("ability.toggleEnabled",
this::isToggleable, enabled -> setToggleStates(enabled ? Math.max(1, getToggleStates()) : 0)));
defs.add(FieldDef.intField("ability.toggleStates", this::getToggleStates, this::setToggleStates)
.range(1, 10)
.visibleWhen(this::isToggleable));
defs.add(FieldDef.boolField("ability.hasActiveToggle", this::hasActiveToggle, this::setHasActiveToggle)
.visibleWhen(this::isToggleable));
// Duration (instant mode only)
defs.add(FieldDef.section("ability.section.execution")
.visibleWhen(() -> !this.isToggleable()));
defs.add(FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks)
.range(0, 6000)
.visibleWhen(() -> !this.isToggleable()));
}
}
@@ -21,6 +21,12 @@ public class AbilityIconData {
public int height = 32;
public float scale = 1.0f;
/** Whether a custom icon override is active. Default false = use type's default icon. */
private boolean enabled = false;
/** Manual tint color for the custom icon (0xRRGGBB). Default white = no tint. */
private int tintColor = 0xFFFFFF;
/** Per-state icon UV overrides (0-indexed, maps to toggle states 1, 2, ...). */
private int[][] stateIcons = null;
@@ -64,12 +70,14 @@ public class AbilityIconData {
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setBoolean("Enabled", enabled);
nbt.setString("Texture", texture);
nbt.setInteger("IconX", iconX);
nbt.setInteger("IconY", iconY);
nbt.setInteger("Width", width);
nbt.setInteger("Height", height);
nbt.setFloat("Scale", scale);
nbt.setInteger("TintColor", tintColor);
if (stateIcons != null && stateIcons.length > 0) {
NBTTagList list = new NBTTagList();
for (int[] pair : stateIcons) {
@@ -83,7 +91,9 @@ public class AbilityIconData {
}
public void readFromNBT(NBTTagCompound nbt) {
enabled = nbt.getBoolean("Enabled");
texture = nbt.getString("Texture");
tintColor = nbt.hasKey("TintColor") ? nbt.getInteger("TintColor") : 0xFFFFFF;
iconX = nbt.getInteger("IconX");
iconY = nbt.getInteger("IconY");
width = nbt.getInteger("Width");
@@ -114,6 +124,24 @@ public class AbilityIconData {
// GETTERS AND SETTERS (with auto-save)
// ═══════════════════════════════════════════════════════════════════
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
save();
}
public int getTintColor() {
return tintColor;
}
public void setTintColor(int tintColor) {
this.tintColor = tintColor & 0xFFFFFF;
save();
}
public String getTexture() {
return texture;
}
@@ -2,6 +2,7 @@ package kamkeel.npcs.controllers.data.ability.data;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.controllers.data.ChainedAbilityScript;
import kamkeel.npcs.controllers.data.ability.data.entry.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.enums.UserType;
import kamkeel.npcs.controllers.data.ability.conditions.AbilityCondition;
@@ -358,7 +359,7 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
*/
public ChainedAbility deepCopy() {
ChainedAbility copy = new ChainedAbility();
copy.readNBT(this.writeNBT());
copy.readNBT(this.writeNBT(true));
return copy;
}
@@ -376,7 +377,7 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
// NBT SERIALIZATION
// ═══════════════════════════════════════════════════════════════════
public NBTTagCompound writeNBT() {
public NBTTagCompound writeNBT(boolean saveScripts) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("Id", id);
nbt.setString("Name", name);
@@ -398,13 +399,23 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
// Entries
NBTTagList entryList = new NBTTagList();
for (ChainedAbilityEntry entry : entries) {
entryList.appendTag(entry.writeNBT());
entryList.appendTag(entry.writeNBT(saveScripts));
}
nbt.setTag("Entries", entryList);
// Custom data (for external mods)
nbt.setTag("customData", (NBTTagCompound) customData.copy());
// Script handler data (matching CustomEffect.writeToNBT pattern)
if (saveScripts) {
ChainedAbilityScript handler = getScriptHandler();
if (handler != null) {
NBTTagCompound scriptData = new NBTTagCompound();
handler.writeToNBT(scriptData);
nbt.setTag("ScriptData", scriptData);
}
}
return nbt;
}
@@ -418,7 +429,7 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
cooldownTicks = nbt.hasKey("CooldownTicks") ? nbt.getInteger("CooldownTicks") : 100;
minRange = nbt.getFloat("MinRange");
maxRange = nbt.hasKey("MaxRange") ? nbt.getFloat("MaxRange") : 20;
// AllowedBy is computed from child abilities — old NBT data silently ignored
// AllowedBy is computed from child abilities
// Conditions
conditions.clear();
@@ -442,5 +453,33 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
// Custom data (for external mods)
customData = (NBTTagCompound) nbt.getCompoundTag("customData").copy();
// Script handler data (matching CustomEffect.readFromNBT pattern)
if (nbt.hasKey("ScriptData", 10)) {
ChainedAbilityScript handler = new ChainedAbilityScript(this.id);
handler.readFromNBT(nbt.getCompoundTag("ScriptData"));
setScriptHandler(handler);
}
}
// ═══════════════════════════════════════════════════════════════════
// SCRIPT HANDLER
// ═══════════════════════════════════════════════════════════════════
public ChainedAbilityScript getScriptHandler() {
return AbilityController.Instance.chainedAbilityScriptHandlers.get(this.id);
}
public void setScriptHandler(ChainedAbilityScript handler) {
AbilityController.Instance.chainedAbilityScriptHandlers.put(this.id, handler);
}
public ChainedAbilityScript getOrCreateScriptHandler() {
ChainedAbilityScript handler = getScriptHandler();
if (handler == null) {
handler = new ChainedAbilityScript(this.id);
AbilityController.Instance.chainedAbilityScriptHandlers.put(this.id, handler);
}
return handler;
}
}
@@ -50,5 +50,5 @@ public interface IAbilityAction {
*/
IAbilityAction deepCopyAction();
NBTTagCompound writeNBT();
NBTTagCompound writeNBT(boolean saveScripts);
}
@@ -16,10 +16,6 @@ public class EnergyDisplayData implements IEnergyDisplayData {
public float innerAlpha = 1.0f;
public float rotationSpeed = 4.0f;
// TODO: Skybox Feature
// public boolean skyboxEnabled = false;
// public String skyboxTexture = "";
public EnergyDisplayData() {
}
@@ -122,9 +118,6 @@ public class EnergyDisplayData implements IEnergyDisplayData {
nbt.setFloat("outerColorAlpha", outerColorAlpha);
nbt.setFloat("innerAlpha", innerAlpha);
nbt.setFloat("rotationSpeed", rotationSpeed);
// TODO: Skybox Feature
// nbt.setBoolean("skyboxEnabled", skyboxEnabled);
// nbt.setString("skyboxTexture", skyboxTexture);
}
public void readNBT(NBTTagCompound nbt) {
@@ -135,16 +128,10 @@ public class EnergyDisplayData implements IEnergyDisplayData {
outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f;
innerAlpha = nbt.hasKey("innerAlpha") ? nbt.getFloat("innerAlpha") : 1.0f;
rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 4.0f;
// TODO: Skybox Feature
// skyboxEnabled = nbt.hasKey("skyboxEnabled") && nbt.getBoolean("skyboxEnabled");
// skyboxTexture = nbt.hasKey("skyboxTexture") ? nbt.getString("skyboxTexture") : "";
}
public EnergyDisplayData copy() {
EnergyDisplayData copy = new EnergyDisplayData(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, innerAlpha, rotationSpeed);
// TODO: Skybox Feature
// copy.skyboxEnabled = skyboxEnabled;
// copy.skyboxTexture = skyboxTexture;
return copy;
}
}
@@ -155,7 +155,7 @@ public class ChainedAbilityEntry {
Ability resolved = ctrl.resolveAbility(abilityReference);
if (resolved == null) return false;
inlineAbility = ctrl.fromNBT(resolved.writeNBT());
inlineAbility = ctrl.fromNBT(resolved.writeNBT(true));
entryType = EntryType.INLINE;
abilityReference = "";
return true;
@@ -175,22 +175,22 @@ public class ChainedAbilityEntry {
copy.delayTicks = this.delayTicks;
copy.concurrentEnabled = this.concurrentEnabled;
if (this.inlineAbility != null) {
copy.inlineAbility = AbilityController.Instance.fromNBT(this.inlineAbility.writeNBT());
copy.inlineAbility = AbilityController.Instance.fromNBT(this.inlineAbility.writeNBT(true));
}
return copy;
}
// ═══════════════════════════════════════════════════════════════════
// NBT (backwards compatible)
// NBT
// ═══════════════════════════════════════════════════════════════════
public NBTTagCompound writeNBT() {
public NBTTagCompound writeNBT(boolean saveScripts) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("Delay", delayTicks);
nbt.setBoolean("Concurrent", concurrentEnabled);
if (entryType == EntryType.INLINE && inlineAbility != null) {
nbt.setTag("InlineAbility", inlineAbility.writeNBT());
nbt.setTag("InlineAbility", inlineAbility.writeNBT(saveScripts));
} else {
nbt.setString("Reference", abilityReference);
}
@@ -204,14 +204,12 @@ public class ChainedAbilityEntry {
entry.delayTicks = Math.max(0, nbt.getInteger("Delay"));
entry.concurrentEnabled = nbt.hasKey("Concurrent") ? nbt.getBoolean("Concurrent") : true;
// Inline entry (new format)
if (nbt.hasKey("InlineAbility")) {
NBTTagCompound abilityNBT = nbt.getCompoundTag("InlineAbility");
entry.entryType = EntryType.INLINE;
entry.inlineAbility = AbilityController.Instance != null
? AbilityController.Instance.fromNBT(abilityNBT) : null;
} else {
// Reference entry (old + new format)
entry.entryType = EntryType.REFERENCE;
entry.abilityReference = nbt.getString("Reference");
}
@@ -137,7 +137,7 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
for (ChainedAbilityEntry entry : chain.getEntries()) {
Ability resolved = entry.resolve();
if (resolved != null && AbilityController.Instance != null) {
Ability copy = AbilityController.Instance.fromNBT(resolved.writeNBT());
Ability copy = AbilityController.Instance.fromNBT(resolved.writeNBT(true));
if (copy != null) {
chainAbilities.add(copy);
chainDelays.add(entry.getDelayTicks());
@@ -55,6 +55,9 @@ public class AbilityBeam extends AbilityEnergyProjectile<EntityAbilityBeam> impl
this.showTelegraph = true;
this.windUpAnimationName = "Ability_Beam_Windup";
this.activeAnimationName = "Ability_Beam_Active";
this.defaultIconTexture = "customnpcs:textures/gui/ability/beam.png";
this.defaultIconColorSource = () -> isOuterColorEnabled() ? getOuterColor() : getInnerColor();
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@@ -55,6 +55,9 @@ public class AbilityDisc extends AbilityEnergyProjectile<EntityAbilityDisc> impl
this.showTelegraph = true;
this.windUpAnimationName = "Ability_Disc_Windup";
this.activeAnimationName = "Ability_Disc_Active";
this.defaultIconTexture = "customnpcs:textures/gui/ability/disc.png";
this.defaultIconColorSource = () -> isOuterColorEnabled() ? getOuterColor() : getInnerColor();
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@@ -192,20 +192,6 @@ public abstract class AbilityEnergyProjectile<E extends EntityEnergyProjectile>
this.fireDelay = Math.max(0, delay);
}
/**
* @deprecated Use {@link #getFireDelay()}
*/
public int getDualFireDelay() {
return fireDelay;
}
/**
* @deprecated Use {@link #setFireDelay(int)}
*/
public void setDualFireDelay(int delay) {
setFireDelay(delay);
}
protected int clampIndex(int index) {
return Math.max(0, Math.min(index, projectileCount - 1));
}
@@ -53,6 +53,9 @@ public class AbilityLaser extends AbilityEnergyProjectile<EntityAbilityLaser> im
this.showTelegraph = true;
this.windUpAnimationName = "Ability_Laser_Windup";
this.activeAnimationName = "Ability_Laser_Active";
this.defaultIconTexture = "customnpcs:textures/gui/ability/laser.png";
this.defaultIconColorSource = () -> isOuterColorEnabled() ? getOuterColor() : getInnerColor();
}
// ==================== OVERRIDES ====================
@@ -49,6 +49,9 @@ public class AbilityOrb extends AbilityEnergyProjectile<EntityAbilityOrb> implem
this.showTelegraph = true;
this.windUpAnimationName = "Ability_Orb_Windup";
this.activeAnimationName = "Ability_Orb_Active";
this.defaultIconTexture = "customnpcs:textures/gui/ability/orb.png";
this.defaultIconColorSource = () -> isOuterColorEnabled() ? getOuterColor() : getInnerColor();
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================