2024-12-05 23:05:41|Myriagame |source:minecraft skins
This tutorial is set by the author's setting without permission.
question
In the process of playing brittleness, we will get a large number of delivery agreements.If you do not sort it specifically, then you must encounter the dilemma below:
Brother, how can I find this? (Sad) You have to take out these delivery agreements one by one, and then right -click to check the content of them. This is a very painful repeated work.
Therefore, we consider trying to add custom TOOLTIP to the delivery protocol, so that the cursor can be seen when the cursor hovers on the delivery protocol.The effect is as follows:
Solution
This tutorial will give a research idea of the author, hoping that this can help friends who also want to further change crispy osteopia through Kubejs.
Find the information in the delivery agreement item
Through the module Ibe Editor, we can view the NBT information of the delivery agreement:
{{Count: 1B,
ID: "Wares: Delivery_agreement",
Tag: {
Experience: 0.0d,
ID: "Organ",
Message: '{"color": "#33333", "text": "This is some.....
We save quite intact, and ensure that they are used."} ',
Ordered: 4.0D,
Paymentitems: [[
{{
Count: 1B,
ID: "Kubejs: MUSCLE_GOLD"
}
],,,
RequestedItems: [[
{{
Count: 1B,
ID: "LightManscurrency: Coin_EMERALD"
}
],,,
Title: '{"COLOR": "#D15492", "Text": "Organ Merchant"}'
}
}
It is not difficult to see that the PaymentItems array indicates the required items, and the RequestedItems array represents the items that can be obtained by the transaction.
Therefore, we can read the corresponding data in the delivery protocol NBT through Kubejs to add a custom Tooltip to it.
Write Kubejs code
We create a wares_tooltip.js (of course you want to add it directly in the existing JS) under the kubejs/client_scripts. IP)=> {{
Tooltip.addadvanced ('#Wares: Agreements',
/**
*@Param {internalesstack} item
*/
(Item, Advanced, Text) => {
Let RequestedItems = item.nbt? .RequestedItems;
Let paymentItems = item.nbt? .PaymentItems;
If (requestedItems) {
Text.add (text.yllow ('Items required:'));
For (let i = 0; I Let RequestedItem = requestedItems [i]; Let stack = item.of (requestedItem.id). WithCount (requestedItem.Count); Text.add ([Stack.displayName, Text.gray ('X'+RequestedItem.Count)];} } If (paymentItems) { Text.add (text.green ('Againable:')); For (let i = 0; I Let paymentITEM = PaymentItems [i]; Let stack = item.of (paymentitem.id). WithCount (paymentItem.Count); Text.add ([Stack.displayName, Text.gray ('X'+PaymentItem.Count)]; } } }); }) Effect Save the file and start the game. At this time, you will find that the trading information can be seen when the mouse hovers on the delivery agreement. The problem to be solved Since the author uses DisplayName to display the name of the item, there are still situations that cannot be displayed by some items that are distinguished by NBT, as follows: 2024-10-05 The first revision of the transfer door pearl has been solved.Information display problem. 2024-10-05 The first revision A solution that uses reflex to obtain the portal pearl information. At the same time, the number of trading times is added. The following is the updated Kubejs code: Itemevents.Tooltip ((Tooltip) => {{ Tooltip.addadvanced ('#Wares: Agreements', /** *@Param {internalesstack} item */ (Item, Advanced, Text) => { Let RequestedItems = item.nbt? .RequestedItems; Let paymentItems = item.nbt? .PaymentItems; Let delivered = item.nbt? .Delivered; Let order = item.nbt? .Ondered; If (requestedItems) { Text.add (text.yllow ('Items required:')); For (let i = 0; I Let stack = item.of (requestedItems [i] .id). Withnbt (requestedItems [i]); Gray ('x'+stack.count)]; } } If (paymentItems) { Text.add (text.green ('Againable:')); For (let i = 0; I Let stack = item.of (paymentItems [i] .id). Withnbt (paymentItems [i]); If (Stack.id == 'Gateway: Gate_pearl') {{ Let name = component.translation ('gateways.gate_pearl', component.transLatable (paymentitems [i] .tag.gateway.replace (':', '.')). SetStyle k.displayName.getStyle ());Text.add ([Text.litral (''), name, text.gray ('x'+stack.count)]; } Else Text.add ([Stack.displayName, Text.gray ('X'+Stack.count)]; } } If (order) { If (! Delivered) Text.add ([Text.aqua ("" Exchangeable times: "), Text.aqua (` $ {OrderEd}/$ {orderEd})););););); Else text.add ([Text.aqua ("" "Exchangeable times:"), text.aqua (`$ {orderd-delivers}/$ {orderEd}`));); } }); }) The effect is shown in the figure: If you have any questions or a better solution, please make it in the comment area ~ const $ gatepearlitem = java.loadClass ('Shadows.gateway.Item.gatepearlitem')
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22