Skip to content

Commit

Permalink
Show emote info with custom style
Browse files Browse the repository at this point in the history
withInsertion => When shift-clicking on emote
withClickEvent => When clicking on emote
withHoverEvent => When hovering over emote
  • Loading branch information
Vinrobot committed Jul 17, 2023
1 parent fadc45f commit 7dcd3c2
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.text.CharacterVisitor;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.vinrobot.mcemote.client.font.EmoteFontStorage;

import java.util.Iterator;
Expand Down Expand Up @@ -57,7 +60,16 @@ public boolean flush() {
private boolean handleEmote(EmotesManager.EmotePair emote) {
this.characters.clear();

return this.visitor.accept(0, EMOTE_STYLE, emote.codePoint());
final String emoteName = emote.emote().getName();

final Style style = EMOTE_STYLE
.withInsertion(emoteName)
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, emoteName))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(emoteName)));

// TODO: Provide custom info in HoverEvent text, e.g., emote provider name

return this.visitor.accept(0, style, emote.codePoint());
}

private boolean handleText() {
Expand Down

0 comments on commit 7dcd3c2

Please sign in to comment.