小工具 Overlay(Gadgets Overlay)

基本信息

属性 值
实现类 com.caedis.duradisplay.overlay.OverlayGadgets
配置分类 gadgets
默认开启 是
默认显示样式 Text
默认数字格式 REMAINING(剩余次数的短格式 k/m/b)
默认文本颜色 0xFFFFFF
默认 ColorType Single(固定白)

功能

Gadgets 接管最大耐久度 < 100 的一般损坏物品("小工具"类)以及 GT 系列的打火机/喷漆罐等 UseCount-style 物品,避免这些低耐久物品被原版默认按百分比显示。它优先于 Durability overlay:当 OverlayDurability.handleDefault 看到 isAllowListed(stack) 时会主动返回 null。

AllowList(白名单)

初始化时遍历 Item.itemRegistry,把可损坏且 unlocalized name 在下表内的物品加入 allowListItems 集合:

unlocalized name 含义
item.flintAndSteel 原版打火石
ic2.itemWeedEx IC2 除草器
item.for.waxCast Forestry 蜡桶
item.for.solderingIron Forestry 烙铁
ic2.itemTreetap IC2 采胶器
item.appliedenergistics2.ToolCertusQuartzCuttingKnife AE2 赛特斯石英切割刀
item.appliedenergistics2.ToolNetherQuartzCuttingKnife AE2 下界石英切割刀
ic2.itemToolForgeHammer IC2 锻造锤
item.spellCloth 神秘遗物墨水瓶布
item.WoodenBrickForm 木砖模具

isAllowListed 的判定条件:item.isDamageable() && allowListItems.contains(item)。

第三方 mod 集成

Mod 处理类 行为
GregTech gregtech.common.items.MetaGeneratedItem01 handleGregtechMeta1 按 stack.getItemDamage() 区分(详见下表)
BuildCraft buildcraft.core.ItemPaintbrush 需 NBT;max = item.getMaxDamage() + 1,current = max - getDamage(stack)
Tinkers Mechworks tmechworks.items.SpoolOfWire max = item.getMaxDamage(),current = max - getDamage(stack)
IC2 ic2.core.item.tool.ItemToolPainter 委托 OverlayDurability::handleDefault
Alchemical Wizardry WayofTime.alchemicalWizardry.common.items.ScribeTool 委托 OverlayDurability::handleDefault
Thaumcraft thaumcraft.api.IScribeTools 委托 OverlayDurability::handleDefault
原版 net.minecraft.item.Item handleByAllowList:仅在 allowlist 命中时返回 DurabilityLikeInfo(max - damage, max)

GT MetaGeneratedItem01 Damage ID 映射

handleGregtechMeta1 仅在 stack.stackSize == 1 时生效,按 getItemDamage() 走 switch:

Damage 范围 物品 max current 初值
32472 Tool_MatchBox_Used 16 0
32473 Tool_MatchBox_Full 16 16
32474, 32475 Tool_Lighter_Invar_Empty / Used 100 0
32476 Tool_Lighter_Invar_Full 100 100
32477, 32478 Tool_Lighter_Platinum_Empty / Used 1000 0
32479 Tool_Lighter_Platinum_Full 1000 1000
32430..32460(奇数=已用,偶数=满) 喷漆罐系列(31 种) 512 满则 512,否则 0
32465 喷漆罐移除器(满) 1024 1024
32466 喷漆罐移除器 1024 0
其他 - null null

随后检查 NBT:若含 GT.RemainingPaint / GT.LighterFuel 则覆盖 current(用于实际剩余量追踪)。

相关条目