From 2d8723756daef9a7d4ac5ec4193ca9d85c5f513d Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 5 Feb 2024 13:30:00 +0600 Subject: [PATCH] (improve) emotes settings --- .../client/emotes/AnimatorController.java | 30 +++++++++++++++---- .../client/emotes/EmoteManager.java | 11 +++++++ .../silentclient/client/emotes/EmotesMod.java | 18 +++++++++++ .../client/emotes/socket/EmoteSocket.java | 12 ++++++-- 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/silentclient/client/emotes/AnimatorController.java b/src/main/java/net/silentclient/client/emotes/AnimatorController.java index 5ef9683..37a3e6c 100644 --- a/src/main/java/net/silentclient/client/emotes/AnimatorController.java +++ b/src/main/java/net/silentclient/client/emotes/AnimatorController.java @@ -18,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; +import net.silentclient.client.Client; import net.silentclient.client.emotes.animation.Animation; import net.silentclient.client.emotes.animation.AnimationMesh; import net.silentclient.client.emotes.animation.AnimationMeshConfig; @@ -28,6 +29,7 @@ import net.silentclient.client.emotes.bobj.BOBJAction; import net.silentclient.client.emotes.bobj.BOBJArmature; import net.silentclient.client.emotes.bobj.BOBJBone; import net.silentclient.client.emotes.emoticons.Emote; +import net.silentclient.client.emotes.socket.EmoteSocket; import org.joml.Matrix4f; import org.joml.Vector4f; import org.lwjgl.BufferUtils; @@ -482,10 +484,28 @@ public class AnimatorController { boolean flag2 = entitylivingbase.isSneaking() || flag || flag1; if (this.emote.isFinished() || flag2) { this.accessor.entity = entitylivingbase; - if (flag2) { + boolean repeat = true; + if(Client.getInstance().getAccount().getUsername().equalsIgnoreCase(entitylivingbase.getName())) { + if ((flag && !Client.getInstance().getSettingsManager().getSettingByClass(EmotesMod.class, "Enable Running in Emotes").getValBoolean()) || (flag1 || entitylivingbase.isSneaking())) { + this.resetEmote(0); + EmoteSocket.get().endEmote(); + repeat = false; + } + if (!flag2) { + if(!Client.getInstance().getSettingsManager().getSettingByClass(EmotesMod.class, "Infinite Emotes").getValBoolean()) { + this.resetEmote(); + EmoteSocket.get().endEmote(); + repeat = false; + } + } + } + + if(repeat && this.emote.isFinished()) { + this.emote.ticks = 0; + } + + if((flag1 || entitylivingbase.isSneaking()) && repeat) { this.resetEmote(0); - } else { - this.resetEmote(); } } } @@ -552,8 +572,8 @@ public class AnimatorController { this.emote = actionplayback; this.entry = emotex; this.entry.startAnimation(this.accessor); - if (this.mc.gameSettings.thirdPersonView != 2 && entitylivingbase == this.mc.thePlayer) { - this.mc.gameSettings.thirdPersonView = 2; + if (this.mc.gameSettings.thirdPersonView != EmotesMod.getEmotePerspective() && entitylivingbase == this.mc.thePlayer) { + this.mc.gameSettings.thirdPersonView = EmotesMod.getEmotePerspective(); this.resetThirdView = true; } } diff --git a/src/main/java/net/silentclient/client/emotes/EmoteManager.java b/src/main/java/net/silentclient/client/emotes/EmoteManager.java index b2c8615..0bb954e 100644 --- a/src/main/java/net/silentclient/client/emotes/EmoteManager.java +++ b/src/main/java/net/silentclient/client/emotes/EmoteManager.java @@ -21,4 +21,15 @@ public class EmoteManager { } } } + + public static void stop(String name) { + if (Minecraft.getMinecraft().theWorld != null) { + EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); + if (entityPlayer != null) { + if (EmoteControllerManager.controllers.get(entityPlayer) != null) { + EmoteControllerManager.controllers.get(entityPlayer).resetEmote(); + } + } + } + } } diff --git a/src/main/java/net/silentclient/client/emotes/EmotesMod.java b/src/main/java/net/silentclient/client/emotes/EmotesMod.java index 24eb013..d0dd8d4 100644 --- a/src/main/java/net/silentclient/client/emotes/EmotesMod.java +++ b/src/main/java/net/silentclient/client/emotes/EmotesMod.java @@ -7,6 +7,8 @@ import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.Setting; import org.lwjgl.input.Keyboard; +import java.util.ArrayList; + public class EmotesMod extends Mod { public EmotesMod() { super("Emotes", ModCategory.SETTINGS, null); @@ -16,6 +18,14 @@ public class EmotesMod extends Mod { public void setup() { this.addBooleanSetting("Emotes", this, true); this.addKeybindSetting("Emote Wheel Keybind", this, Keyboard.KEY_B); + this.addBooleanSetting("Infinite Emotes", this, false); + this.addBooleanSetting("Enable Running in Emotes", this, false); + + ArrayList perspectives = new ArrayList<>(); + perspectives.add("Second Person"); + perspectives.add("Third Person"); + + this.addModeSetting("Default Emote Perspective", this, "Second Person", perspectives); } @Override @@ -39,4 +49,12 @@ public class EmotesMod extends Mod { } } } + + public static int getEmotePerspective() { + if(Client.getInstance().getSettingsManager().getSettingByClass(EmotesMod.class, "Default Emote Perspective").getValString().equalsIgnoreCase("second person")) { + return 2; + } else { + return 3; + } + } } diff --git a/src/main/java/net/silentclient/client/emotes/socket/EmoteSocket.java b/src/main/java/net/silentclient/client/emotes/socket/EmoteSocket.java index 27ccc70..1015ac7 100644 --- a/src/main/java/net/silentclient/client/emotes/socket/EmoteSocket.java +++ b/src/main/java/net/silentclient/client/emotes/socket/EmoteSocket.java @@ -37,16 +37,24 @@ public class EmoteSocket { SocketError error = Client.getInstance().getGson().fromJson((String)arg0[0], SocketError.class); NotificationUtils.showNotification("Error", error.getError()); }).on("startEmote", (Object... arg0) -> { - Client.logger.info((String)arg0[0]); + Client.logger.info("startEmote: " + (String)arg0[0]); SocketShowEmote data = Client.getInstance().getGson().fromJson((String)arg0[0], SocketShowEmote.class); EmoteManager.sendEmote(data.username, data.emoteId); - }); + }).on("endEmote", (Object... arg0) -> { + Client.logger.info("endEmote: " + (String)arg0[0]); + SocketShowEmote data = Client.getInstance().getGson().fromJson((String)arg0[0], SocketShowEmote.class); + EmoteManager.stop(data.username); + });; } public void startEmote(int id) { this.socket.emit("startEmote", new JSONObject().put("accessToken", Client.getInstance().getUserData().getAccessToken()).put("emoteId", id).toString()); } + public void endEmote() { + this.socket.emit("endEmote", new JSONObject().put("accessToken", Client.getInstance().getUserData().getAccessToken()).toString()); + } + public void connect() { this.socket.connect(); }