-
Notifications
You must be signed in to change notification settings - Fork 96
Emote object lifecycle
If you want to add or mess up emotes with a custom Emotecraft plugin, you should know this
an Emote is stored in an EmoteData object.
When the game starts or the config screen loads, some code is called, what calls the EmoteSerializer to every emote, including builtin and external emotes.
Then a config method is called, to assign keybindings and fast choose wheel to some emotes.
Emotes are stored in a list inside of an EmoteHolderobject.
Its purpose is to store the emote's name, description, and other client-related information.
When an emote is played, the mod first calls the clientStartEmote function inside the [ClientNetwork]
(https://github.com/KosmX/emotes/blob/master/src/main/java/com/kosmx/emotecraft/network/ClientNetwork.java) class.
This method invoke the startPlayClientEmote Callback with 4 arguments: (EmoteData the_emote_itself, PlayerEntity the_player, EmoteHolder the_emote_holder, boolean has_the_server_emotecraft_installed)
If the callback returns with Fail, it will cancel the emote to be streamed and played.
Then the EmoteData will be sent to the server after being serialized into a network packet with EmotePacket.
If everything is done, the emote will be 'converted' into an EmotePlayer object and will be played on the Client.
But what about the other players?
After the server streams the packets (more about it here), the client will receive the packet.
When it receives that packet, it will serialize it back into an EmoteData object.
Another callback will be invoked there, and the EmoteData object will be converted into an EmotePlayer as the client plays it.
EmotePlayer is directly assigned to a player and helps the EmoteData to become alive, you shouldn't do anything with it.