配色与样式(Color Type & Style)
基本信息
| 属性 |
值 |
| 样式枚举 |
com.caedis.duradisplay.overlay.OverlayDurabilityLike.Style |
| 颜色枚举 |
com.caedis.duradisplay.utils.ColorType |
| 数字格式枚举 |
com.caedis.duradisplay.utils.DurabilityFormatter.Format |
| 配置基类 |
com.caedis.duradisplay.config.ConfigDurabilityLike |
样式 Style 枚举
| 值 |
渲染器 |
说明 |
Text |
TextRenderer |
在物品上叠加文本(百分比/剩余次数/分数等),numpad 1-9 选位 |
Bar |
BarRenderer |
物品底部 13×1 像素条 |
VerticalBar |
VerticalBarRenderer |
物品右侧 1×13 像素竖条 |
| 值 |
输出格式 |
示例(current=257, max=1024) |
PERCENT |
0-100% 整数(查表缓存 0-100) |
25% |
REMAINING |
短格式当前值 |
257 |
USED |
短格式 max - current |
767 |
MAX |
短格式最大值 |
1k |
FRACTION |
current/max 整数 |
257/1024 |
CONTAINER |
自适应(max≥100 不显示分母;≥1000 显示 *) |
257(max < 1000) |
短格式 shortenNumber
>= 1_000_000_000:1.2b
>= 1_000_000:2.5m
>= 1_000:257
- 整数小值:
Long.toString(whole)
- 否则
DecimalFormat("0.#"):例如 12.5
颜色 ColorType 枚举
| 值 |
算法 |
用途 |
RYGDurability |
HSBtoRGB(max(0, percent)/3, 1, 1),0% 纯红、33% 纯黄、66%+ 纯绿 |
默认 Durability / Container overlay |
Threshold |
按 colorThreshold 阈值返回 threeColors[0/1/2] |
阈值分段(低/中/高三色) |
Vanilla |
(255 - k) << 16 | k << 8,仿原版耐久度条的红→绿 |
原版条带兼容 |
Single |
直接返回 cfg.color(hex RGB) |
纯色 |
Smooth |
在 threeColors[0] 与 threeColors[1] 之间,再与 threeColors[2] 二次插值 |
多色渐变(默认 Charge overlay) |
Threshold 三色规则(cfg.colorThreshold = {30, 70} 默认)
durability% ≤ 30:返回 threeColors[0](默认红 0xFF0000)
durability% ≥ 70:返回 threeColors[1](默认黄 0x55FF00)
- 其余:返回
threeColors[2](默认绿 0x00FF00)
注意源码里 [1] 与 [2] 的角色与通常命名相反:黄在中段、绿在最高段。
Smooth 渐变(双段插值)
输入:低色 threeColors[0]、中色 threeColors[1]、高色 threeColors[2],percent ∈ [0,1]。
- 在
c0 ↔ c1 间生成 (r,g,b)(percent 权重)
- 在
c1 ↔ c2 间生成 (r2,g2,b2)
- 最终
(r3,g3,b3) = (r,g,b)·(1-percent) + (r2,g2,b2)·percent
效果:从 0% 到 100% 平滑经过三个锚点;默认(橙灰 → 冷蓝 → 青)形成冷暖过渡。
各 overlay 默认样式对照表
| Overlay |
Style |
Format |
Color |
ColorType |
ThreeColors |
NumPad Pos |
| Durability |
Text |
PERCENT |
0x00FF00 |
RYGDurability |
{0xFF0000, 0x55FF00, 0x00FF00} |
2 |
| Charge |
Text |
PERCENT |
0xFF55FF |
Smooth |
{0xFFB9AA, 0xBDD6FF, 0x55FFFF} |
8 |
| Gadgets |
Text |
REMAINING |
0xFFFFFF |
Single |
{0xFF0000, 0xFFBDC8, 0xFFFFFF} |
2 |
| Container |
Text |
CONTAINER |
0x00FF00 |
RYGDurability |
{0xFF0000, 0x55FF00, 0x00FF00} |
2 |
| PotionBrew |
Text |
REMAINING |
0xFFFFFF |
Single |
{0xFF0000, 0xFFBDC8, 0xFFFFFF} |
2 |
配置路径
ConfigDurabilityLike.loadConfig 把样式/颜色拆到子分类:
| 路径 |
键 |
<category> |
Enable、ShowWhenFull、ShowWhenEmpty |
<category> |
Style(顶层枚举值) |
<category>.StyleConfig.Text |
Position(1-9)、TextFormat |
<category>.Color |
ColorType、Color(hex)、ThreeColors(hex 数组)、ColorThresholds(双值,0-100) |
<category>.StyleConfig.Bars |
SmoothBar、BarOffset(0-16)、ShowBackground |
相关条目