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

@@ -649,9 +649,9 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
// Search matches either the display name or the typeId (strip color codes for matching)
String stripped = displayName.replaceAll("\u00A7.", "");
if (search.isEmpty() || stripped.toLowerCase().contains(search) || typeId.toLowerCase().contains(search)) {
// Yellow for concurrent-capable types, gray for other built-in types
// Lime green for concurrent-capable types, gray for other built-in types
if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7e" + displayName;
displayName = "\u00A7a" + displayName;
} else if (AbilityController.Instance.isBuiltInType(typeId)) {
displayName = "\u00A77" + displayName;
}
@@ -787,7 +787,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
NBTTagList actionList = new NBTTagList();
for (AbilityAction slot : npcSlots) {
actionList.appendTag(slot.writeNBT());
actionList.appendTag(slot.writeNBT(false));
}
compound.setTag("AbilityActions", actionList);
@@ -1105,7 +1105,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
public void onAbilitySaved(Ability ability) {
// Editing a global parent ability via "Modify Parent" on a chain entry
if (editingChainEntryParent) {
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT(false)));
return;
}
@@ -1119,7 +1119,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
AbilityAction slot = npcSlots.get(selectedAbilityIndex);
if (slot.isReference()) {
// Modify Parent on standalone reference — save to global preset
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT(false)));
} else {
// Inline ability — update slot data
npcSlots.set(selectedAbilityIndex, AbilityAction.inline(ability));
@@ -3,6 +3,8 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.conditions.AbilityCondition;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldBuilder;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.controllers.data.AbilityScript;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
@@ -143,6 +145,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
GuiMenuTopButton closeBtn = new GuiMenuTopButton(-1000, guiLeft + xSize - 22, guiTop - 17, "X");
addTopButton(closeBtn);
GuiMenuTopButton scriptBtn = new GuiMenuTopButton(-999, "script.scripts", closeBtn);
addTopButton(scriptBtn);
// Build scroll window dimensions
int swX = guiLeft + 4;
int swY = guiTop + 5;
@@ -152,9 +157,12 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
int y = 5;
int labelCounter = LABEL_ID_START;
// General tab: type label + optional concurrent label at top — reserve space
// General tab: type label + optional info labels at top — reserve space
if (activeTab == TAB_GENERAL) {
y += ROW_H;
if ("ability.cnpc.custom".equals(ability.getTypeId())) {
y += 15;
}
if (ability.isConcurrentCapable()) {
y += 15;
}
@@ -168,14 +176,20 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
GuiScrollWindow sw = builder.buildScrollWindow(tabFields, swX, swY, swW, swH);
// General tab: add type label + optional concurrent label at top of scroll window
// General tab: add type label + optional info labels at top of scroll window
if (activeTab == TAB_GENERAL) {
int baseId = builder.getNextLabelId();
int infoY = 25;
sw.addLabel(new GuiNpcLabel(baseId, "gui.type", 5, 10, 0xFFFFFF));
sw.addLabel(new GuiNpcLabel(baseId + 1, ability.getTypeId(), 55, 10, 0xFFFFFF));
if (ability.isConcurrentCapable()) {
if ("ability.cnpc.custom".equals(ability.getTypeId())) {
sw.addLabel(new GuiNpcLabel(baseId + 2,
StatCollector.translateToLocal("ability.concurrentInfo"), 5, 25, 0x55FF55));
StatCollector.translateToLocal("ability.customScriptInfo"), 5, infoY, 0xFF55FF));
infoY += 15;
}
if (ability.isConcurrentCapable()) {
sw.addLabel(new GuiNpcLabel(baseId + 3,
StatCollector.translateToLocal("ability.concurrentInfo"), 5, infoY, 0x55FF55));
}
}
@@ -302,6 +316,13 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
initGui();
return;
}
if (id == -999) {
GuiNpcTextField.unfocus();
applyToAbility();
callback.onAbilitySaved(ability);
GuiScriptInterface.open(parent, new AbilityScript(ability.getId()));
return;
}
if (id == -1000) {
close();
return;
@@ -405,7 +426,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
public void loadAbility(Ability loadedAbility) {
if (loadedAbility == null) return;
NBTTagCompound nbt = loadedAbility.writeNBT();
NBTTagCompound nbt = loadedAbility.writeNBT(false);
nbt.setString("typeId", ability.getTypeId());
ability.readNBT(nbt);
@@ -70,7 +70,7 @@ public class SubGuiAbilitySaveConfirm extends SubGuiInterface implements ISubGui
private void doSave() {
saved = true;
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT(false)));
if (callback != null) {
callback.onAbilitySaved(ability);
}
@@ -83,8 +83,10 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
continue;
String displayName = I18n.format(typeId);
if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7e" + displayName;
if (typeId.equals("ability.cnpc.custom")) {
displayName = "\u00A7d" + displayName;
} else if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7a" + displayName;
}
allDisplayNameToTypeId.put(displayName, typeId);
}
@@ -122,6 +124,21 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
}
Collections.sort(list, (a, b) -> String.CASE_INSENSITIVE_ORDER.compare(
a.replaceAll("\u00A7.", ""), b.replaceAll("\u00A7.", "")));
// Pin Custom Ability to top of list
String customEntry = null;
for (String name : list) {
String tid = displayNameToTypeId.get(name);
if (tid != null && tid.equals("ability.cnpc.custom")) {
customEntry = name;
break;
}
}
if (customEntry != null) {
list.remove(customEntry);
list.add(0, customEntry);
}
return list;
}
@@ -5,6 +5,8 @@ import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityAction;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.controllers.data.ChainedAbilityScript;
import kamkeel.npcs.controllers.data.ability.data.entry.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.data.AbilityIconData;
import kamkeel.npcs.controllers.data.ability.gui.IChainedAbilityFieldProvider;
@@ -57,6 +59,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
private static final int BTN_TAB_ENTRIES = 91;
private static final int BTN_TAB_TARGET = 92;
private static final int BTN_TAB_EXTRA_BASE = 93;
private static final int BTN_SCRIPT = -999;
private static final int BTN_CLOSE = -1000;
// ── Entries tab: per-entry ID encoding ─────────────────────────────────────
@@ -258,6 +261,9 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
GuiMenuTopButton closeBtn = new GuiMenuTopButton(BTN_CLOSE, guiLeft + xSize - 22, guiTop - 17, "X");
addTopButton(closeBtn);
GuiMenuTopButton scriptBtn = new GuiMenuTopButton(BTN_SCRIPT, "script.scripts", closeBtn);
addTopButton(scriptBtn);
// Scroll window dimensions
int swX = guiLeft + 4;
int swY = guiTop + 5;
@@ -487,6 +493,10 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
initGui();
return;
}
if (id == BTN_SCRIPT) {
GuiScriptInterface.open(parent, new ChainedAbilityScript(chain.getId()));
return;
}
if (id == BTN_CLOSE) {
saveOnClose = true;
close();
@@ -853,7 +863,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
public void onAbilitySaved(Ability ability) {
if (editingParentAbility) {
// Persist the global parent ability to the server
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT(false)));
editingParentAbility = false;
return;
}
@@ -495,7 +495,7 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
private void handleChainConfigClosed() {
if (pendingSaveChain != null) {
PacketClient.sendClient(new ChainedAbilitySavePacket(pendingSaveChain.writeNBT()));
PacketClient.sendClient(new ChainedAbilitySavePacket(pendingSaveChain.writeNBT(false)));
selected = pendingSaveChain.getName();
pendingSaveChain = null;
}
@@ -550,7 +550,7 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
if (pendingSaveAbility == null) return false;
if (gui.isConfirmed()) {
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT(false)));
pendingSaveAbility = null;
return false;
}
@@ -574,7 +574,7 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
setSubGui(new SubGuiDuplicateNameConfirm());
return true;
}
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT()));
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT(false)));
pendingSaveAbility = null;
return false;
}
@@ -25,6 +25,13 @@ public class AbilityIcon extends Gui {
public int width;
public int height;
// Default icon info (extracted from ability)
private String defaultTexture = "";
private String[] defaultStateTextures = null;
private int defaultIconWidth = 48;
private int defaultIconHeight = 48;
private Ability sourceAbility = null;
private AbilityIcon(AbilityIconData data) {
this.data = data;
this.width = data.width;
@@ -33,7 +40,13 @@ public class AbilityIcon extends Gui {
public static AbilityIcon fromAbility(Ability ability) {
if (ability != null) {
return new AbilityIcon(AbilityIconData.fromAbility(ability));
AbilityIcon icon = new AbilityIcon(AbilityIconData.fromAbility(ability));
icon.defaultTexture = ability.getDefaultIconTexture();
icon.defaultStateTextures = ability.getDefaultIconStateTextures();
icon.defaultIconWidth = ability.getDefaultIconWidth();
icon.defaultIconHeight = ability.getDefaultIconHeight();
icon.sourceAbility = ability;
return icon;
}
return fromDefaults();
}
@@ -66,30 +79,85 @@ public class AbilityIcon extends Gui {
public void draw(int state, float alpha) {
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
ImageData imageData = null;
if (data.hasTexture()) {
imageData = ClientCacheHandler.getImageData(data.texture);
}
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, alpha);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Tessellator t;
if (imageData == null || !imageData.imageLoaded()) {
GL11.glScalef(1.0f, 1.0f, 1);
if (data.isEnabled() && data.hasTexture()) {
// Path 1: Custom icon enabled with texture — draw with manual tintColor
ImageData imageData = ClientCacheHandler.getImageData(data.texture);
if (imageData != null && imageData.imageLoaded()) {
int tint = data.getTintColor();
float r = ((tint >> 16) & 0xFF) / 255f;
float g = ((tint >> 8) & 0xFF) / 255f;
float b = (tint & 0xFF) / 255f;
GL11.glColor4f(r, g, b, alpha);
GL11.glScalef(data.scale, data.scale, 1);
renderEngine.bindTexture(imageData.getLocation());
t = getTessellator(imageData, state);
t.draw();
} else {
GL11.glColor4f(1, 1, 1, alpha);
renderEngine.bindTexture(FALLBACK_TEXTURE);
t = getFallbackTessellator();
t.draw();
}
} else if (hasDefaultTexture()) {
// Path 2: No custom icon, but type has a default icon — draw with auto-color tint
String texturePath = resolveDefaultTexture(state);
ImageData defaultImageData = ClientCacheHandler.getImageData(texturePath);
if (defaultImageData != null && defaultImageData.imageLoaded()) {
int autoColor = sourceAbility != null ? sourceAbility.getDefaultIconColor() : 0xFFFFFF;
float r = ((autoColor >> 16) & 0xFF) / 255f;
float g = ((autoColor >> 8) & 0xFF) / 255f;
float b = (autoColor & 0xFF) / 255f;
GL11.glColor4f(r, g, b, alpha);
renderEngine.bindTexture(defaultImageData.getLocation());
t = getDefaultIconTessellator();
t.draw();
} else {
// Default texture not found — use fallback at default icon dimensions with auto-color tint
int autoColor = sourceAbility != null ? sourceAbility.getDefaultIconColor() : 0xFFFFFF;
float r = ((autoColor >> 16) & 0xFF) / 255f;
float g = ((autoColor >> 8) & 0xFF) / 255f;
float b = (autoColor & 0xFF) / 255f;
GL11.glColor4f(r, g, b, alpha);
renderEngine.bindTexture(FALLBACK_TEXTURE);
t = getDefaultIconTessellator();
t.draw();
}
} else {
// Path 3: No custom icon, no default icon — generic fallback with auto-color tint if available
int autoColor = sourceAbility != null ? sourceAbility.getDefaultIconColor() : 0xFFFFFF;
float r = ((autoColor >> 16) & 0xFF) / 255f;
float g = ((autoColor >> 8) & 0xFF) / 255f;
float b = (autoColor & 0xFF) / 255f;
GL11.glColor4f(r, g, b, alpha);
renderEngine.bindTexture(FALLBACK_TEXTURE);
t = getFallbackTessellator();
} else {
GL11.glScalef(data.scale, data.scale, 1);
renderEngine.bindTexture(imageData.getLocation());
t = getTessellator(imageData, state);
t.draw();
}
t.draw();
GL11.glPopMatrix();
}
/**
* Resolve the default texture path for a given toggle state.
* Falls back to the base defaultTexture if no state-specific texture exists.
*/
private String resolveDefaultTexture(int state) {
if (state > 0 && defaultStateTextures != null && state - 1 < defaultStateTextures.length) {
return defaultStateTextures[state - 1];
}
return defaultTexture;
}
private boolean hasDefaultTexture() {
return defaultTexture != null && !defaultTexture.isEmpty();
}
private Tessellator getTessellator(ImageData imageData, int state) {
float hw = data.width / 2f;
float hh = data.height / 2f;
@@ -114,6 +182,19 @@ public class AbilityIcon extends Gui {
return t;
}
private Tessellator getDefaultIconTessellator() {
float hw = defaultIconWidth / 2f;
float hh = defaultIconHeight / 2f;
Tessellator t = Tessellator.instance;
t.startDrawingQuads();
t.addVertexWithUV(-hw, hh, zLevel, 0, 1);
t.addVertexWithUV(hw, hh, zLevel, 1, 1);
t.addVertexWithUV(hw, -hh, zLevel, 1, 0);
t.addVertexWithUV(-hw, -hh, zLevel, 0, 0);
return t;
}
private Tessellator getFallbackTessellator() {
float hw = 16f;
float hh = 16f;
@@ -128,17 +209,20 @@ public class AbilityIcon extends Gui {
}
public boolean hasTexture() {
return data.hasTexture();
return (data.isEnabled() && data.hasTexture()) || hasDefaultTexture();
}
/**
* Returns the approximate visual size (max dimension) that draw() produces.
* Textured: max(width,height) * scale. Fallback: 32.
* Custom icon: max(width,height) * scale. Default icon: max(defaultW,defaultH). Fallback: 32.
*/
public float getDrawSize() {
if (data.hasTexture()) {
if (data.isEnabled() && data.hasTexture()) {
return Math.max(width, height) * data.scale;
}
if (hasDefaultTexture()) {
return Math.max(defaultIconWidth, defaultIconHeight);
}
return 32f;
}
}