Load emotes with the Saturn emote library
- Emotes loads assets/saturnclient/player_animations/*.json with emotes-core into Saturn's own EmoteRegistry (not the library's shared one, so other mods can't replace them), and lists the ones that loaded for the wheel. - The emote wheel now also sends the emote to the server, so other players see it. It only played locally before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -8,4 +8,5 @@ java {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "dev.selimaj:session-java:0.2.0"
|
implementation "dev.selimaj:session-java:0.2.0"
|
||||||
|
implementation "org.saturnclient:emotes-core:${emotes_version}"
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,45 @@
|
|||||||
package org.saturnclient.cosmetics;
|
package org.saturnclient.cosmetics;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.saturnclient.common.provider.Providers;
|
||||||
|
import org.saturnclient.emotes.core.Emote;
|
||||||
|
import org.saturnclient.emotes.core.EmoteRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saturn's emotes, loaded from {@code assets/saturnclient/player_animations/<id>.json} (Emotecraft
|
||||||
|
* format). They live in Saturn's own registry rather than the emote library's shared one, so another
|
||||||
|
* mod using the library can't replace them.
|
||||||
|
*/
|
||||||
public class Emotes {
|
public class Emotes {
|
||||||
|
private static final List<String> IDS = List.of("tpose", "back_flip", "facepalm", "cry", "giga_chad",
|
||||||
|
"front_flip");
|
||||||
|
|
||||||
|
private static final EmoteRegistry REGISTRY = new EmoteRegistry();
|
||||||
|
|
||||||
|
/** The emotes that loaded, in wheel order. */
|
||||||
public static List<String> availableEmotes = new ArrayList<>();
|
public static List<String> availableEmotes = new ArrayList<>();
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
availableEmotes.add("tpose");
|
for (String id : IDS) {
|
||||||
availableEmotes.add("back_flip");
|
String path = "/assets/saturnclient/player_animations/" + id + ".json";
|
||||||
availableEmotes.add("facepalm");
|
try (InputStream in = Emotes.class.getResourceAsStream(path)) {
|
||||||
availableEmotes.add("cry");
|
if (in == null) {
|
||||||
availableEmotes.add("giga_chad");
|
Providers.saturn.logError("Missing emote " + path);
|
||||||
availableEmotes.add("front_flip");
|
continue;
|
||||||
|
}
|
||||||
|
REGISTRY.loadEmotecraft(id, in);
|
||||||
|
availableEmotes.add(id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Providers.saturn.logError("Failed to load emote " + id, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Emote> get(String id) {
|
||||||
|
return REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ public class EmoteWheel extends SaturnScreen {
|
|||||||
emoteStagger.draw(
|
emoteStagger.draw(
|
||||||
new TextureButton(Textures.getEmotePreview(emote), () -> {
|
new TextureButton(Textures.getEmotePreview(emote), () -> {
|
||||||
Providers.saturn.playEmote(ServiceClient.uuid, emote);
|
Providers.saturn.playEmote(ServiceClient.uuid, emote);
|
||||||
|
ServiceClient.emote(emote);
|
||||||
provider.close();
|
provider.close();
|
||||||
})
|
})
|
||||||
.dimensions(70, 70)
|
.dimensions(70, 70)
|
||||||
|
|||||||
Reference in New Issue
Block a user