Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e3b6cf7f8 | ||
|
|
6fb38e4f9b | ||
|
|
997fbbe9a9 | ||
|
|
01a8ea15a0 | ||
|
|
08cee2172c |
@@ -2,12 +2,22 @@ package org.saturnclient.saturnclient.auth;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.cosmetics.Hats;
|
import org.saturnclient.saturnclient.cosmetics.Hats;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||||
import org.saturnclient.ui2.SaturnScreen;
|
import org.saturnclient.ui2.SaturnScreen;
|
||||||
import org.saturnclient.ui2.elements.Notification;
|
import org.saturnclient.ui2.elements.Notification;
|
||||||
import org.saturnclient.ui2.elements.Notification.NotificationKind;
|
import org.saturnclient.ui2.elements.Notification.NotificationKind;
|
||||||
|
|
||||||
|
import dev.kosmx.playerAnim.api.layered.AnimationStack;
|
||||||
|
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess;
|
||||||
|
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
|
||||||
public class Auth {
|
public class Auth {
|
||||||
@@ -104,18 +114,66 @@ public class Auth {
|
|||||||
String hat = parser.getStringOrNull("hat");
|
String hat = parser.getStringOrNull("hat");
|
||||||
if (cloak != null) {
|
if (cloak != null) {
|
||||||
Cloaks.availableCloaks.add(cloak);
|
Cloaks.availableCloaks.add(cloak);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (hat != null) {
|
if (hat != null) {
|
||||||
Hats.availableHats.add(hat);
|
Hats.availableHats.add(hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "update_cloak":
|
||||||
|
String targetUuid = parser.getStringOrNull("uuid");
|
||||||
|
String targetCloak = parser.getStringOrNull("cloak");
|
||||||
|
if (targetUuid != null && targetCloak != null) {
|
||||||
|
SaturnPlayer player = players.get(targetUuid);
|
||||||
|
if (player != null) {
|
||||||
|
player.cloak = targetCloak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "update_hat":
|
||||||
|
targetUuid = parser.getStringOrNull("uuid");
|
||||||
|
String targetHat = parser.getStringOrNull("hat");
|
||||||
|
if (targetUuid != null && targetHat != null) {
|
||||||
|
SaturnPlayer player = players.get(targetUuid);
|
||||||
|
if (player != null) {
|
||||||
|
player.hat = targetHat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "emote":
|
||||||
|
targetUuid = parser.getStringOrNull("uuid");
|
||||||
|
String emote = parser.getStringOrNull("name");
|
||||||
|
|
||||||
|
for (AbstractClientPlayerEntity player : SaturnClient.client.world.getPlayers()) {
|
||||||
|
if (player.getUuidAsString().replace("-", "").equals(targetUuid)) {
|
||||||
|
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
||||||
|
if (emote != null && !emote.isEmpty()) {
|
||||||
|
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
||||||
|
animationStack.removeLayer(1000);
|
||||||
|
}
|
||||||
|
animationStack.addAnimLayer(1000,
|
||||||
|
PlayerAnimationRegistry
|
||||||
|
.getAnimation(Identifier.of("saturnclient", emote))
|
||||||
|
.playAnimation());
|
||||||
|
} else {
|
||||||
|
animationStack.removeLayer(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (parser.error != null) {
|
if (parser.error != null) {
|
||||||
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
||||||
|
|
||||||
if (SaturnClient.client.currentScreen instanceof SaturnScreen) {
|
if (SaturnClient.client.currentScreen instanceof SaturnScreen) {
|
||||||
String[] a = parser.error.replace("!", "").split(": ");
|
String[] a = parser.error.replace("!", "").split(": ");
|
||||||
((SaturnScreen) SaturnClient.client.currentScreen).draw(new Notification(SaturnClient.client.currentScreen.width, SaturnClient.client.currentScreen.height, NotificationKind.Error, a[0], a[1]));
|
((SaturnScreen) SaturnClient.client.currentScreen)
|
||||||
|
.draw(new Notification(SaturnClient.client.currentScreen.width,
|
||||||
|
SaturnClient.client.currentScreen.height, NotificationKind.Error,
|
||||||
|
a[0], a[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -179,7 +237,7 @@ public class Auth {
|
|||||||
|
|
||||||
public static void setCloak(String cloakName) {
|
public static void setCloak(String cloakName) {
|
||||||
try {
|
try {
|
||||||
Network.write("set_cloak@cloak=" + cloakName);
|
Network.write("set_cloak@cloak=" + cloakName + "@notify=" + stringifyPlayers());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
@@ -187,12 +245,26 @@ public class Auth {
|
|||||||
|
|
||||||
public static void setHat(String hatName) {
|
public static void setHat(String hatName) {
|
||||||
try {
|
try {
|
||||||
Network.write("set_hat@hat=" + hatName);
|
Network.write("set_hat@hat=" + hatName + "@notify=" + stringifyPlayers());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void emote(String name) {
|
||||||
|
try {
|
||||||
|
Network.write("emote@name=" + name + "@notify=" + stringifyPlayers());
|
||||||
|
} catch (Exception e) {
|
||||||
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String stringifyPlayers() {
|
||||||
|
return players.keySet().stream()
|
||||||
|
.filter(key -> key != uuid)
|
||||||
|
.collect(Collectors.joining("$"));
|
||||||
|
}
|
||||||
|
|
||||||
public static void player(String name, String uuid) {
|
public static void player(String name, String uuid) {
|
||||||
try {
|
try {
|
||||||
playerNames.put(name, uuid.replaceAll("-", ""));
|
playerNames.put(name, uuid.replaceAll("-", ""));
|
||||||
@@ -202,41 +274,6 @@ public class Auth {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendReload() {
|
|
||||||
for (Map.Entry<String, String> player : playerNames.entrySet()) {
|
|
||||||
if (players.containsKey(player.getValue()) && !player.getValue().equals(uuid)) {
|
|
||||||
SaturnClient.client.player.networkHandler
|
|
||||||
.sendChatCommand("msg " + player.getKey() + " "
|
|
||||||
+ "$SATURN_RELOAD if you are seeing this as a player, please report this to https://github.com/saturnclientmc/saturnclient/issues");
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendEmote(String emote) {
|
|
||||||
String uuid = SaturnClient.client.player.getUuidAsString().replace("-", "");
|
|
||||||
for (Map.Entry<String, String> player : playerNames.entrySet()) {
|
|
||||||
if (players.containsKey(player.getValue()) && !player.getValue().equals(uuid)) {
|
|
||||||
SaturnClient.client.player.networkHandler
|
|
||||||
.sendChatCommand("msg " + player.getKey() + " "
|
|
||||||
+ "$SATURN_EMOTE&@"+uuid+"&@"+emote+"&@ if you are seeing this as a player, please report this to https://github.com/saturnclientmc/saturnclient/issues");
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cancelEmote() {
|
|
||||||
String uuid = SaturnClient.client.player.getUuidAsString().replace("-", "");
|
|
||||||
for (Map.Entry<String, String> player : playerNames.entrySet()) {
|
|
||||||
if (players.containsKey(player.getValue()) && !player.getValue().equals(uuid)) {
|
|
||||||
SaturnClient.client.player.networkHandler
|
|
||||||
.sendChatCommand("msg " + player.getKey() + " "
|
|
||||||
+ "$SATURN_CANCEL_EMOTE&@"+uuid+"&@ if you are seeing this as a player, please report this to https://github.com/saturnclientmc/saturnclient/issues");
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void buyCloak(String name) {
|
public static void buyCloak(String name) {
|
||||||
try {
|
try {
|
||||||
Network.write("buy_cloak@cloak=" + name);
|
Network.write("buy_cloak@cloak=" + name);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class Hats {
|
|||||||
public static void setHat(String uuid, String hatName) {
|
public static void setHat(String uuid, String hatName) {
|
||||||
setHatSilent(uuid, hatName);
|
setHatSilent(uuid, hatName);
|
||||||
Auth.setHat(hatName);
|
Auth.setHat(hatName);
|
||||||
Auth.sendReload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHatSilent(String uuid, String hatName) {
|
public static void setHatSilent(String uuid, String hatName) {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class Cloaks {
|
|||||||
public static void setCloak(String uuid, String cloakName) {
|
public static void setCloak(String uuid, String cloakName) {
|
||||||
Auth.setCloak(cloakName);
|
Auth.setCloak(cloakName);
|
||||||
setCloakSilent(uuid, cloakName);
|
setCloakSilent(uuid, cloakName);
|
||||||
Auth.sendReload();
|
|
||||||
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,20 +112,25 @@ public class Cloaks {
|
|||||||
List<AnimatedCloakData> animatedFrames = new ArrayList<>();
|
List<AnimatedCloakData> animatedFrames = new ArrayList<>();
|
||||||
for (int i = 0; i < frameCount; i++) {
|
for (int i = 0; i < frameCount; i++) {
|
||||||
String frameId = fileName.replace(".gif", "") + "_frame_" + i;
|
String frameId = fileName.replace(".gif", "") + "_frame_" + i;
|
||||||
Identifier frameIdentifier = Identifier.of(SaturnClient.MOD_ID, "cloaks_" + frameId);
|
Identifier frameIdentifier = Identifier.of(SaturnClient.MOD_ID,
|
||||||
IdentifierUtils.registerBufferedImageTexture(frameIdentifier, frames.get(i));
|
"cloaks_" + frameId);
|
||||||
|
IdentifierUtils.registerBufferedImageTexture(frameIdentifier,
|
||||||
|
frames.get(i));
|
||||||
animatedFrames.add(new AnimatedCloakData(frameIdentifier, delays.get(i)));
|
animatedFrames.add(new AnimatedCloakData(frameIdentifier, delays.get(i)));
|
||||||
}
|
}
|
||||||
animatedCloaks.put(uuid, animatedFrames);
|
animatedCloaks.put(uuid, animatedFrames);
|
||||||
lastFrameTime.put(uuid, System.currentTimeMillis());
|
lastFrameTime.put(uuid, System.currentTimeMillis());
|
||||||
SaturnClient.LOGGER.info("Loaded " + frames.size() + " frames for animated cloak: " + fileName);
|
SaturnClient.LOGGER.info(
|
||||||
|
"Loaded " + frames.size() + " frames for animated cloak: " + fileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Failed to register animated cloak textures: " + fileName, e);
|
SaturnClient.LOGGER
|
||||||
|
.error("Failed to register animated cloak textures: " + fileName, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SaturnClient.LOGGER.error("Failed to load animated cloak from resources: " + player.cloak + ".gif", e);
|
SaturnClient.LOGGER
|
||||||
|
.error("Failed to load animated cloak from resources: " + player.cloak + ".gif", e);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.minecraft.client.util.InputUtil;
|
|||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
// import org.saturnclient.saturnclient.auth.Auth;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.ui2.screens.EmoteWheel;
|
import org.saturnclient.ui2.screens.EmoteWheel;
|
||||||
import org.saturnclient.ui2.screens.ShiftMenu;
|
import org.saturnclient.ui2.screens.ShiftMenu;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public class KeyInputHandler {
|
|||||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(SaturnClient.client.player);
|
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(SaturnClient.client.player);
|
||||||
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
||||||
animationStack.removeLayer(1000);
|
animationStack.removeLayer(1000);
|
||||||
// Auth.cancelEmote();
|
Auth.emote("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.mixin;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import org.saturnclient.saturnclient.auth.Auth;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import dev.kosmx.playerAnim.api.layered.AnimationStack;
|
|
||||||
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess;
|
|
||||||
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry;
|
|
||||||
import net.minecraft.client.gui.hud.ChatHud;
|
|
||||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
|
||||||
import net.minecraft.network.message.MessageSignatureData;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
@Mixin(ChatHud.class)
|
|
||||||
public class SaturnReload {
|
|
||||||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void onAddMessage(Text message, @Nullable MessageSignatureData signatureData,
|
|
||||||
@Nullable MessageIndicator indicator, CallbackInfo ci) {
|
|
||||||
try {
|
|
||||||
String msg = message.toString();
|
|
||||||
if (msg.contains("$SATURN_RELOAD")) {
|
|
||||||
for (Map.Entry<String, String> player : Auth.playerNames.entrySet()) {
|
|
||||||
String name = player.getKey();
|
|
||||||
if (msg.contains(name)) {
|
|
||||||
Auth.player(name, player.getValue());
|
|
||||||
}
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
} else if (msg.contains("$SATURN_EMOTE")) {
|
|
||||||
String[] args = msg.split("&@");
|
|
||||||
for (AbstractClientPlayerEntity player : SaturnClient.client.world.getPlayers()) {
|
|
||||||
if (player.getUuidAsString().replace("-", "").equals(args[1])) {
|
|
||||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
|
||||||
animationStack.addAnimLayer(1000, PlayerAnimationRegistry.getAnimation(Identifier.of("saturnclient", args[2])).playAnimation());
|
|
||||||
ci.cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (msg.contains("$SATURN_CANCEL_EMOTE")) {
|
|
||||||
String[] args = msg.split("&@");
|
|
||||||
for (AbstractClientPlayerEntity player : SaturnClient.client.world.getPlayers()) {
|
|
||||||
if (player.getUuidAsString().replace("-", "").equals(args[1])) {
|
|
||||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
|
||||||
animationStack.removeLayer(1000);
|
|
||||||
ci.cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package org.saturnclient.ui2.screens;
|
|||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
// import org.saturnclient.saturnclient.auth.Auth;
|
// import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.cosmetics.Emotes;
|
import org.saturnclient.saturnclient.cosmetics.Emotes;
|
||||||
import org.saturnclient.ui2.SaturnScreen;
|
import org.saturnclient.ui2.SaturnScreen;
|
||||||
@@ -29,8 +30,10 @@ public class EmoteWheel extends SaturnScreen {
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
|
||||||
draw(new ImageTexture(Textures.LOGO_TEXT).dimensions(98, 10).centerOffset(width, height, 0, -105).animation(new Fade(700)));
|
draw(new ImageTexture(Textures.LOGO_TEXT).dimensions(98, 10).centerOffset(width, height, 0, -105)
|
||||||
draw(new ImageTexture(SaturnClientConfig.getLogo()).dimensions(98, 98).centerOffset(width, height, 0, -149).animation(new SlideY(700, -20)));
|
.animation(new Fade(700)));
|
||||||
|
draw(new ImageTexture(SaturnClientConfig.getLogo()).dimensions(98, 98).centerOffset(width, height, 0, -149)
|
||||||
|
.animation(new SlideY(700, -20)));
|
||||||
|
|
||||||
draw(new TextureButton(Textures.LEFT, () -> {
|
draw(new TextureButton(Textures.LEFT, () -> {
|
||||||
if (page > 1) {
|
if (page > 1) {
|
||||||
@@ -64,12 +67,14 @@ public class EmoteWheel extends SaturnScreen {
|
|||||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(SaturnClient.client.player);
|
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(SaturnClient.client.player);
|
||||||
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
||||||
animationStack.removeLayer(1000);
|
animationStack.removeLayer(1000);
|
||||||
// Auth.cancelEmote();
|
|
||||||
}
|
}
|
||||||
animationStack.addAnimLayer(1000, PlayerAnimationRegistry.getAnimation(Identifier.of("saturnclient", emote)).playAnimation());
|
animationStack.addAnimLayer(1000,
|
||||||
// Auth.sendEmote(emote);
|
PlayerAnimationRegistry.getAnimation(Identifier.of("saturnclient",
|
||||||
|
emote)).playAnimation());
|
||||||
|
Auth.emote(emote);
|
||||||
close();
|
close();
|
||||||
}).dimensions(70, 70).centerOffset(width, height, -80 + (col * 80), -35 + (row * 80)).animation(new Fade(700)));
|
}).dimensions(70, 70).centerOffset(width, height, -80 + (col * 80), -35 + (row * 80))
|
||||||
|
.animation(new Fade(700)));
|
||||||
|
|
||||||
if (col < 2) {
|
if (col < 2) {
|
||||||
col++;
|
col++;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
"NameTagMixin",
|
"NameTagMixin",
|
||||||
"PlayerEntityRendererMixin",
|
"PlayerEntityRendererMixin",
|
||||||
"WhoAmI",
|
"WhoAmI",
|
||||||
"SaturnReload",
|
|
||||||
"DrawContextAccessor",
|
"DrawContextAccessor",
|
||||||
"TitleScreenMixin"
|
"TitleScreenMixin"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user