-
Notifications
You must be signed in to change notification settings - Fork 0
/
smwyg.sc
34 lines (30 loc) · 1.23 KB
/
smwyg.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Show Me What You Got
// A simple mod which allows displaying your items to other users in chat.
// Take the item with your mainhand and type `[i]` in your chat message.
// [i] will be replaced with the item info.
__on_player_message(player, message) -> (
if(message ~ '[i]',
message = replace(message, '\\"', '\\\\"');
message = replace(message, '\\\\', '\\\\\\\\');
item = query(player(), 'holds', 'mainhand');
if(!item, return());
name = item_display_name(item);
[item, amount, nbts] = item;
nbts = replace(nbts, '\\"', '\\\\"');
json_text = [str('\"<%s> \"', player())];
parts = split('\\[i\\]', message);
first = true;
if (!parts,
parts = [''];
);
for(parts,
json_text += str('\"%s\"', _);
if(first == true,
json_text += str('{"text":"[","color":"aqua"},{"translate":"entity.minecraft.item","color":"aqua"},{"text":":%s]","color":"aqua","hoverEvent":{"action":"show_item","value":"{id:%s,Count:1,tag:%s}"}}', name, item, nbts);
first = false;
);
);
run(str('/tellraw @a [%s]', join(',', json_text)));
return('cancel');
)
);