mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Fix Default Icon Logic in DBC Addon to work with Layering System of CNPC+
This commit is contained in:
1 parent
8056640102
commit
f71694e210
2 files changed
+21
-6
No files matched your search
@@ -142,21 +142,35 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
protected transient int defaultIconHeight = 48;
|
||||
|
||||
/**
|
||||
* A single layer of a default ability icon. Each layer has a texture and
|
||||
* an optional dynamic color source derived from the ability's properties.
|
||||
* A single layer of a default ability icon. Each layer has a texture,
|
||||
* an optional dynamic color source, and optional per-state texture variants.
|
||||
*/
|
||||
public static class DefaultIconLayer {
|
||||
public final String texture;
|
||||
public final String[] stateTextures;
|
||||
public final java.util.function.IntSupplier colorSource;
|
||||
|
||||
public DefaultIconLayer(String texture, java.util.function.IntSupplier colorSource) {
|
||||
public DefaultIconLayer(String texture, String[] stateTextures, java.util.function.IntSupplier colorSource) {
|
||||
this.texture = texture;
|
||||
this.stateTextures = stateTextures;
|
||||
this.colorSource = colorSource;
|
||||
}
|
||||
|
||||
public DefaultIconLayer(String texture, java.util.function.IntSupplier colorSource) {
|
||||
this(texture, null, colorSource);
|
||||
}
|
||||
|
||||
/** Layer with no color tinting (renders as white). */
|
||||
public DefaultIconLayer(String texture) {
|
||||
this(texture, null);
|
||||
this(texture, null, null);
|
||||
}
|
||||
|
||||
/** Resolve texture for a given toggle state. Falls back to base texture. */
|
||||
public String getTextureForState(int state) {
|
||||
if (state > 0 && stateTextures != null && state - 1 < stateTextures.length) {
|
||||
return stateTextures[state - 1];
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
|
||||
@@ -107,8 +107,9 @@ public class AbilityIcon extends Gui {
|
||||
} else if (hasDefaultLayers()) {
|
||||
// Path 2: Default layers — draw each layer with its dynamic color
|
||||
for (Ability.DefaultIconLayer defLayer : defaultLayers) {
|
||||
if (defLayer.texture == null || defLayer.texture.isEmpty()) continue;
|
||||
ImageData imageData = ClientCacheHandler.getImageData(defLayer.texture);
|
||||
String texPath = defLayer.getTextureForState(state);
|
||||
if (texPath == null || texPath.isEmpty()) continue;
|
||||
ImageData imageData = ClientCacheHandler.getImageData(texPath);
|
||||
if (imageData != null && imageData.imageLoaded()) {
|
||||
int color = defLayer.getColor();
|
||||
float r = ((color >> 16) & 0xFF) / 255f;
|
||||
|
||||
Reference in new issue
Block a user