本模组已弃用!请使用 Omni Ocular 代替!
最新信息请始终访问
我的网站:
MCF:
描述
Waila NBT 是一个模组,用于在 Waila HUD 上显示玩家定义的特定 NBT 信息。
Waila NBT 是 Waila 的客户端附加组件。并且需要 In-Game NBTEdit(1.7.10 版本)来查看 NBT 数据结构。
示例(含配置文件)
下载 .json 文件并将其放入 config\WailaNBT 文件夹即可使用。
请分享你的配置!
更多配置文件可在 找到。
Botania(手持 Forestry Wand)
Blood magic(手持 Divination Sigil)
BuildCraft(手持 BC Wrench),由 ViKaleidoscope 提供
Ender IO(手持 Yeta Wrench),由 ViKaleidoscope 提供
Thaumcraft(手持 Wand),由 ViKaleidoscope 提供
Industrial Craft 2(手持任意物品均可),由 ViKaleidoscope 提供
Thermal Expansion(手持月牙锤)by ViKaleidoscope
Witchery(手持任意物品均可)by ViKaleidoscope
教程
本教程以 Blood Magic by WayofTime 和 Botania by Vazkii 为例。
第一部分:方块(Tile Entity)
首先,将 jar 文件放入 mods 文件夹并启动游戏。
你的 config 文件夹中会生成一个配置文件夹以及一个空的 “default.json” 文件。只有在其中填入正确的配置后,模组才会生效。
如果存在错误,会在聊天窗口中显示。
配置文件采用 JSON 格式,结构如下:
{
"Holding Item Name": {
"Tile Entity ID 1": {
"Tag Name 1": "Display Name 1",
"Tag Name 2>>>Tag Name 3": "Display Name 2"
},
"Tile Entity ID X": {
},
"Holding Item Name X": {}
}
}
|
该配置的含义是:当玩家手持名为 “Holding Item Name” 的物品,并将光标悬停在 ID 为 “Tile Entity ID 1” 的Tile Entity上时,将显示 “Tag Name” 的值,而 “Display Name 1” 是在 Waila HUD 中代表 “Tag Name” 值的名称。
“Tag Name 2>>>Tag Name 3” 表示显示位于名为 “Tag Name 2” 的 NBT Tag Compound 中 “Tag Name 3” 的值。这类似于子文件夹。如果 “Tag Name 3” 包含在 “Tag Name 2” 内部,请使用 “>>>” 分隔名称。“>>>” 仅在此类子文件夹条件下使用。对于 TagList,你可以使用数字。例如,使用 “Items>>>2>>Count” 来访问高亮显示的字段。

“Holding Item Name”、“Tile Entity ID 1” 和 “Tag Name 1” 支持正则表达式,因此像 “|”(管道符)这样的特殊字符前面需要加上 “\”(反斜杠)。例如:“BuildCraft|Transport” 必须写作 “BuildCraft\|Transport”。
让我们来看一个实际的例子。
Blood Altar(血祭坛)是 Blood Magic 的基础方块。它可以储存 “Life Essence”(生命精华)并转化物品。

当指向它时,运行命令 “/nbtedit”


这是血魔法(Blood Magic)中的工具(占卜符印)显示的内容。

现在我们知道这个方块的 ID 是 “containerAltar”,我们推测 “Amount” 代表 “当前精华量”,而 “capacity” 代表 “容量”。
目标是:手持占卜符印时,我们可以直接从 Waila HUD 中读取 “当前精华量” 和 “容量”,而不需要右键点击。
手持占卜符印并运行命令 “/wnn”(代表 Waila NBT Name)。它的识别名称 “AWWayofTime:divinationSigil” 将显示在聊天窗口中。
对于 Inventory Tweak 用户

因此我们将以下内容写入 default.json。(或者如果你想保持它们有序,可以创建一个名为 “bloodmagic.json” 的文件并在其中编写。)
{
"AWWayofTime:divinationSigil": {
"containerAltar": {
"Amount": "Current Essence",
"capacity": "Capacity"
}
}
}
|
保存配置文件后。运行命令 “/wnr”(代表 Waila NBT Reload)以重新加载配置。
然后手持占卜符印并指向鲜血祭坛。

成功了!
让我们再试一个。日耀花(Daybloom)。
首先运行命令 “/nbtedit”。

ID 为 “botania:specialFlower”,而有用的数据 “mana” 位于一个名为 “subTileCmp” 的 NBTTagCompound 下。
将以下内容保存到文件夹 “config/WailaNBT” 中的 “botania.json” 文件里。(default.json 就位于该文件夹中。)
{
".*": {
"botania:specialFlower": {
"subTileCmp>>>mana": "Mana"
}
}
}
|
“.*” 是一个匹配所有字符串的正则表达式。注意它也匹配未持有物品时的手槽。因为不持有物品等于持有名为 “”(空字符串)的物品。
别忘了运行命令 “/wnr” 来重新加载配置。
现在指向日耀花,它应该能正常工作了。

第二部分:生物(实体)
Waila NBT 也适用于实体(生物等)。

只需编写配置文件,并将 “Tile Entity ID” 改为 “Entity ID”,后者可通过命令 “/wne”(代表 Waila NBT Entity)获取。

你也可以使用 “/nbtedit” 来查看实体的 NBT 数据结构。

以下是上面那只羊的示例配置文件。
{
".*": {
"Sheep": {
"Age": "Love cooldown",
"InLove": "Love time left"
}
}
}
|
第 3 部分:物品(工具提示)
WailaNBT 同样适用于物品,并会在工具提示中显示信息。

没有直接查看物品 NBT 数据结构的方法,因此需要一个箱子。将物品放入箱子中并运行命令 “/nbtedit”。蓝色边框包围的部分即为该物品的 NBT 结构。

你需要将 “Holding Item Name” 改为 “tooltip”,并将 “Tile Entity ID” 改为 “Item Name”,后者无法通过命令 “/wnn” 获取。
以下是上面 Notch 头颅的示例配置文件。
{
"tooltip": {
"minecraft:skull": {
"SkullOwner": "Name"
}
}
}
|
第 4 部分:修改显示值
可以使用 printf 风格的格式化器或 JavaScript 来修改显示值,并可以添加颜色和字体样式装饰。
别忘了添加 Holding Item 和 Tile Entity ID 的内容。这部分仅关注 “Tag Name 1”: “Display Name 1”。
Printf 风格格式化器
例如,“Owner>>>Name”:”This is %s’s head!” 将获得如下效果。

你可能会发现 “%.2f” 很有用。这将强制显示两位小数。
JavaScript
如果你不仅仅想格式化字符串,比如将刻数除以 20 以秒为单位显示,那么 JavaScript 修饰符适合你。
让我们以熔炉为例。
要以秒为单位显示燃烧时间,请使用以下代码:
“BurnTime”: “function p(v){var r = (v/20);return ‘Burn time left: ’+r.toFixed(1)+’ seconds’}”
太棒了!

如果你想使用 JavaScript 来修改值,必须使用 “function p(v){}”。这是要运行的基本函数。“v” 是根据 Tag Name 读取的值,你可以在 JavaScript 中对它进行任何操作。别忘了返回你想要显示的内容。
在库存中查找 ID 时有时会很棘手,它是一个数字,很难知道它实际上是什么。遇到这个问题时,使用一个名为 “names{}” 的预定义对象。

你可以使用 name['id'] 来获取数字 ID 对应的名称。注意,目前它只能处理有限的本地化名称。
例如,如果你想显示漏斗中的第一个物品名称。请在配置文件中写入以下内容:
“Items>>>0>>>id”: “function p(v){r = ‘first item is ‘ + names[v];return r}”
Waila 将显示:

颜色和字体样式
可以使用 16 种颜色以及加粗/删除线/下划线/斜体来装饰显示的文本。你也可以使用一些文本来使文本右对齐或居中对齐,或者使用制表符来使内容整齐。
未修改的文本以灰色显示。
要使用颜色和字体样式,请参阅:
要对齐和制表符:
“\u00A4\u00A4a” 用作制表符
“\u00A4\u00A4b” 用作右对齐
“\u00A4\u00A4c” 用作居中对齐
默认样式为“键名+制表符+右对齐+白色值”
例如,“BrewTime”: “Brew time left \u00A4\u00A4a\u00A4\u00A4b\u00A7f%.0f ticks” 效果如下所示。

注意事项
此模组过于强大,可能会破坏生存模式的体验。它通常用于测试目的。未经服务器管理员许可在服务器上使用该模组可能被视为作弊。
手持空手等于手持一个名为“”(空字符串)的物品。
如果未提供显示名称(如 “Amount”:“”),则标签名称(“Amount”)将被使用。(给像我这样的懒人 ;;P
如果存在两个包含相同“方块实体 ID”且其“持有物品名称”相同的配置,其中一个“方块实体 ID”将被忽略。
config/WailaNBT 文件夹中的内容将被直接忽略。
计划功能
支持地面掉落物品的显示。
允许根据配置隐藏部分信息,可能是按键触发
更好地分发和控制预配置文件
支持从服务器端下载配置,使其在多人游戏(SMP)中不被视为作弊模组
更复杂的匹配方法
致谢
感谢 Prof Mobius 带来 Waila。
感谢 Pahimar 教我基础模组开发。
感谢 Davidee 带来 In-Game NBTEdit,以及 bjbinc 为其制作 1.7.10 移植版。
感谢 ViKaleidoscope 进行简体中文本地化和配置文件翻译。
感谢 Fixided 对教程编辑提出的建议。
许可证
此模组的源代码可在以下位置找到:
你可以将其包含在整合包中并重新分发二进制文件。但请注明出处并保留对此帖子的链接,我们将不胜感激。
This mod is deprecated! Use Omni Ocular instead!
Most latest information is always on
My Website:
MCF:
Description
Waila NBT is a mod to show player defined specific NBT info on Waila HUD.
Waila NBT is a Client-Side addon for Waila. And In-Game NBTEdit (1.7.10 version)is needed to look up NBT data structure.
Examples (with config files)
Download .json file and put in config\WailaNBT folder and its ready to use.
Please share your config!
More config files can be found at .
Botania (Holding Forestry Wand)
Blood magic (Holding Divination Sigil)
BuildCraft (Holding BC Wrench) by ViKaleidoscope
Ender IO (Holding Yeta Wrench) by ViKaleidoscope
Thaumcraft (Holding Wand) by ViKaleidoscope
Industrial Craft 2 (Holding anything is fine) by ViKaleidoscope
Thermal Expansion (Holding Crescent Hammer) by ViKaleidoscope
Witchery (Holding anything is fine) by ViKaleidoscope
Tutorial
Blood Magic by WayofTime and Botania by Vazkii are used as examples for tutorial.
Part 1. Blocks(Tile Entity)
First, drop the jar file into mods and start game.
A configuration folder as well as an empty file “default.json” will be generated in your config folder. The mod is useless until you put right config in it.
Possible errors will be displayed in you chat window, if any.
The config file is in JSON format looks like this:
{
"Holding Item Name": {
"Tile Entity ID 1": {
"Tag Name 1": "Display Name 1",
"Tag Name 2>>>Tag Name 3": "Display Name 2"
},
"Tile Entity ID X": {
},
"Holding Item Name X": {}
}
}
|
This configuration means, when player holding an item named “Holding Item Name”, and point cursor at aTile Entity with ID “Tile Entity ID 1″, “Value of Tag Name” will be shown, and “Display Name 1″is the name that will represent “Value of Tag Name” in Waila HUD.
“Tag Name 2>>>Tag Name 3″ means display the value of “Tag Name 3″ in the NBT Tag Compound named “Tag Name 2″. That’s somehow similar to a sub folder. Use “>>>” to separate to name if “Tag Name 3″ is inside “Tag Name 2″. “>>>” should only be used under this sub folder condition. As for TagList, you can use number. e.g. Use “Items>>>2>>Count” to access the highlighting field.

“Holding Item Name”, “Tile Entity ID 1″ and “Tag Name 1″ support regular expression, so some special characters like “|”(pipe) need a “\”(backslash) before it. e.g: “BuildCraft|Transport” must be written as “BuildCraft\|Transport”.
Let’s take a living example.
Blood Altar is a basic block of Blood Magic. It can store “Life Essence” and transmute items.

When pointing at it, run command “/nbtedit”


And here is what the tool(Divination Sigil) from blood magic says.

Now we know the ID of this block is “containerAltar“, and we guess that the “Amount” is the “Current Essence” and “capacity” is “Capacity”.
The target is, when holding the Divination Sigil, we can directly read the “Current Essence” and “Capacity” from the Waila HUD rather than a right click.
Hold the Divination Sigil and run command “/wnn” (stand for Waila NBT Name). The identify name “AWWayofTime:divinationSigil” of it will be shown in chat window.
For Inventory Tweak user

So we write following content to default.json. (Or if you wanna keep them in order, create a “bloodmagic.json” and write in it instead.)
{
"AWWayofTime:divinationSigil": {
"containerAltar": {
"Amount": "Current Essence",
"capacity": "Capacity"
}
}
}
|
After saving the config file. Run command “/wnr” (stand for Waila NBT Reload) to reload configuration.
Then hold the Divination Sigil and point at the Blood Altar.

It works!
Let’s try another. Daybloom.
Run command “/nbtedit” first.

ID is “botania:specialFlower”, and what useful data “mana” is under a NBTTagCompound named “subTileCmp”.
Save following content to “botania.json” in folder “config/WailaNBT”. (Where the default.json located.)
{
".*": {
"botania:specialFlower": {
"subTileCmp>>>mana": "Mana"
}
}
}
|
“.*” is an regular expression matches all string. Note it also matches hand without holding anything. Because holding nothing equals holding an item named “”(empty string).
And don’t forget run command “/wnr” to reload configuration.
Now point at Daybloom and it should work.

Part 2. Mobs(Entity)
Waila NBT also works on entity(mobs, etc.).

Just write configs and change “Tile Entity ID” to “Entity ID”, which can be known by command “/wne”(stand for Waila NBT Entity).

And you can use “/nbtedit” to see NBT data structure of an entity too.

Following is the example config file for the picture of sheep above.
{
".*": {
"Sheep": {
"Age": "Love cooldown",
"InLove": "Love time left"
}
}
}
|
Part 3. Items (Tool tips)
WailaNBT works on item too. And will show information on tool-tip.

There are no method to look up the NBT data structure of an item, so a chest is needed. Put item in a chest and run command “/nbtedit”. The part surrounded with a blue border is the NBT structure of the item.

You need to change “Holding Item Name” to “tooltip” and change “Tile Entity ID” to “Item Name”, which cant be get by the command “/wnn”.
Following is the example config file for the picture of notch’s head above.
{
"tooltip": {
"minecraft:skull": {
"SkullOwner": "Name"
}
}
}
|
Part 4. Modify displayed value
Displayed value can be modify by using printf style formatter or JavaScript and can be decorate with color and font style.
Don’t forget to add the Holding Item and Tile Entity ID content. This part only focus on “Tag Name 1″: “Display Name 1″.
Printf style formatter
e.g. “Owner>>>Name”:”This is %s’s head!” will get the effect below.

You may find “%.2f” useful. This will force it show 2 decimal places.
JavaScript
You may wanna do more than format a string, like divide ticks by 20 to show in seconds. JavaScript modifier is for you.
Let’s take furnace as an example.
To show the burn time in seconds, use this code below
“BurnTime”: “function p(v){var r = (v/20);return ‘Burn time left: ‘+r.toFixed(1)+’ seconds’}”
Amazing!

“function p(v){}” is forced if you want to you JavaScript to modify the value. that’s the basic function to run. “v” is the value read according to Tag Name and you can do anything you like in JavaScript with it. And don’t forget to return what you want to display.
It’s tricky sometime when you look up ID in an inventory. It’s a number and hard to know what actually is. When encounter this problem, use a pre-defined object named “names{}”.

You can use name['id'] to get the name of the numeric id. Note it can only handle limited localized name now.
e.g. If you want to display the first item name in a hopper. Write below in the config file:
“Items>>>0>>>id”: “function p(v){r = ‘first item is ‘ + names[v];return r}”
Waila will display:

Color and Font style
16 colors and bold/strike/underline/italic can be used to decorate displayed text. you can also use some text to make the text right/center aligned or use tab to make things neat.
Unmodified text shows in grey.
To use colors and font style, please look it up in
To use align and tab:
“\u00A4\u00A4a” works as tab
“\u00A4\u00A4b” works as right-aligned
“\u00A4\u00A4c” works as center-aligned
The default style is “key tab+right-aligned+white value”
e.g.”BrewTime”: “Brew time left \u00A4\u00A4a\u00A4\u00A4b\u00A7f%.0f ticks” works as below.

Notice
This mod is over powered and may destroy experience in survival mode. It’s generally written for testing purpose. Use it on server without permission may be considered as cheating.
Holding nothing equals holding an item named “”(empty string).
If display name is not provided (like “Amount”:””), the tag name(“Amount”) will be used. (for lazy people like me ;P
If there are two config contains same “Tile Entity ID” and their “Holding Item Name” is same, one of “Tile Entity ID” will be ignored.
Folders in config/WailaNBT will be directly ignored.
Planning Feature
Support for items dropped on ground.
Allow hide type/part of info according to config, maybe keys
Better distribute and control pre-config files
Support download config from server side to make it not a cheat mod for SMP
More complex match method
Thanks
Prof Mobius for bring us Waila.
Pahimar for teaching me basic modding.
Davidee for bring us In-Game NBTEdit, and bjbinc for 1.7.10 port
ViKaleidoscope for Simplified Chinese localization and config files.
Fixided for tutorial editing advice.
License
Source code of this mod can be found here:
You can include it in modpacks and redistribute binary files. But a notice in this post and keeping a link to this post will be appreciated.
评论 0
登录后参与评分
还没有评论,来抢沙发吧