(improve) emotes settings

This commit is contained in:
kirillsaint 2024-02-05 13:30:00 +06:00
parent 897725c068
commit 2d8723756d
4 changed files with 64 additions and 7 deletions

View File

@ -18,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.emotes.animation.Animation; import net.silentclient.client.emotes.animation.Animation;
import net.silentclient.client.emotes.animation.AnimationMesh; import net.silentclient.client.emotes.animation.AnimationMesh;
import net.silentclient.client.emotes.animation.AnimationMeshConfig; 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.BOBJArmature;
import net.silentclient.client.emotes.bobj.BOBJBone; import net.silentclient.client.emotes.bobj.BOBJBone;
import net.silentclient.client.emotes.emoticons.Emote; import net.silentclient.client.emotes.emoticons.Emote;
import net.silentclient.client.emotes.socket.EmoteSocket;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector4f; import org.joml.Vector4f;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
@ -482,10 +484,28 @@ public class AnimatorController {
boolean flag2 = entitylivingbase.isSneaking() || flag || flag1; boolean flag2 = entitylivingbase.isSneaking() || flag || flag1;
if (this.emote.isFinished() || flag2) { if (this.emote.isFinished() || flag2) {
this.accessor.entity = entitylivingbase; 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); this.resetEmote(0);
} else {
this.resetEmote();
} }
} }
} }
@ -552,8 +572,8 @@ public class AnimatorController {
this.emote = actionplayback; this.emote = actionplayback;
this.entry = emotex; this.entry = emotex;
this.entry.startAnimation(this.accessor); this.entry.startAnimation(this.accessor);
if (this.mc.gameSettings.thirdPersonView != 2 && entitylivingbase == this.mc.thePlayer) { if (this.mc.gameSettings.thirdPersonView != EmotesMod.getEmotePerspective() && entitylivingbase == this.mc.thePlayer) {
this.mc.gameSettings.thirdPersonView = 2; this.mc.gameSettings.thirdPersonView = EmotesMod.getEmotePerspective();
this.resetThirdView = true; this.resetThirdView = true;
} }
} }

View File

@ -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();
}
}
}
}
} }

View File

@ -7,6 +7,8 @@ import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.Setting; import net.silentclient.client.mods.Setting;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
public class EmotesMod extends Mod { public class EmotesMod extends Mod {
public EmotesMod() { public EmotesMod() {
super("Emotes", ModCategory.SETTINGS, null); super("Emotes", ModCategory.SETTINGS, null);
@ -16,6 +18,14 @@ public class EmotesMod extends Mod {
public void setup() { public void setup() {
this.addBooleanSetting("Emotes", this, true); this.addBooleanSetting("Emotes", this, true);
this.addKeybindSetting("Emote Wheel Keybind", this, Keyboard.KEY_B); this.addKeybindSetting("Emote Wheel Keybind", this, Keyboard.KEY_B);
this.addBooleanSetting("Infinite Emotes", this, false);
this.addBooleanSetting("Enable Running in Emotes", this, false);
ArrayList<String> perspectives = new ArrayList<>();
perspectives.add("Second Person");
perspectives.add("Third Person");
this.addModeSetting("Default Emote Perspective", this, "Second Person", perspectives);
} }
@Override @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;
}
}
} }

View File

@ -37,16 +37,24 @@ public class EmoteSocket {
SocketError error = Client.getInstance().getGson().fromJson((String)arg0[0], SocketError.class); SocketError error = Client.getInstance().getGson().fromJson((String)arg0[0], SocketError.class);
NotificationUtils.showNotification("Error", error.getError()); NotificationUtils.showNotification("Error", error.getError());
}).on("startEmote", (Object... arg0) -> { }).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); SocketShowEmote data = Client.getInstance().getGson().fromJson((String)arg0[0], SocketShowEmote.class);
EmoteManager.sendEmote(data.username, data.emoteId); 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) { public void startEmote(int id) {
this.socket.emit("startEmote", new JSONObject().put("accessToken", Client.getInstance().getUserData().getAccessToken()).put("emoteId", id).toString()); 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() { public void connect() {
this.socket.connect(); this.socket.connect();
} }