(improve) emotes with socket

This commit is contained in:
kirillsaint 2024-02-05 12:59:07 +06:00
parent e67b749637
commit 897725c068
26 changed files with 157 additions and 99 deletions

View File

@ -30,6 +30,7 @@ public class Cosmetics {
public Map<Number, HatData> hats = new HashMap<>();
public Map<Number, ShieldData> shields = new HashMap<>();
public Map<Number, StaticResourceLocation> icons = new HashMap<>();
public Map<Number, CosmeticItem> emotes = new HashMap<>();
public ArrayList<CosmeticItem> myIcons = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myWings = new ArrayList<CosmeticItem>();
@ -37,6 +38,7 @@ public class Cosmetics {
public ArrayList<CosmeticItem> myBandanas = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myHats = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myShields = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myEmotes = new ArrayList<CosmeticItem>();
public StaticResourceLocation defaultIcon;
@ -132,6 +134,14 @@ public class Cosmetics {
});
}
Client.logger.info("STARTING > cosmeitcs > emotes");
emotes.clear();
if(allCosmetics != null && allCosmetics.getEmotes() != null) {
allCosmetics.getEmotes().forEach((emote) -> {
emotes.put(emote.getId(), emote);
});
}
Client.logger.info("STARTING > cosmeitcs > outfits");
Outfits.loadOutfits();
}
@ -157,7 +167,8 @@ public class Cosmetics {
Client.getInstance().getCosmetics().setMyBandanas(cosmetics.getAccount().getCosmetics().getBandanas());
Client.getInstance().getCosmetics().setMyHats(cosmetics.getAccount().getCosmetics().getHats());
Client.getInstance().getCosmetics().setMyShields(cosmetics.getAccount().getCosmetics().getShields());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getCosmetics().setMyEmotes(cosmetics.getAccount().getCosmetics().getEmotes());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Type").setValString(cosmetics.getAccount().getCapeType().equals("dynamic_curved") ? "Dynamic Curved" : cosmetics.getAccount().getCapeType().equals("curved_rectangle") ? "Curved Rectangle" : "Rectangle");
if(Minecraft.getMinecraft().thePlayer != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setCapeType(cosmetics.getAccount().getCapeType());
@ -178,6 +189,7 @@ public class Cosmetics {
Client.getInstance().getCosmetics().setMyBandanas(cosmetics.getAccount().getCosmetics().getBandanas());
Client.getInstance().getCosmetics().setMyHats(cosmetics.getAccount().getCosmetics().getHats());
Client.getInstance().getCosmetics().setMyShields(cosmetics.getAccount().getCosmetics().getShields());
Client.getInstance().getCosmetics().setMyEmotes(cosmetics.getAccount().getCosmetics().getEmotes());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Type").setValString(cosmetics.getAccount().getCapeType().equals("dynamic_curved") ? "Dynamic Curved" : cosmetics.getAccount().getCapeType().equals("curved_rectangle") ? "Curved Rectangle" : "Rectangle");
if(Minecraft.getMinecraft().thePlayer != null) {
@ -222,6 +234,14 @@ public class Cosmetics {
return myShields;
}
public ArrayList<CosmeticItem> getMyEmotes() {
return myEmotes;
}
public void setMyEmotes(ArrayList<CosmeticItem> myEmotes) {
this.myEmotes = myEmotes;
}
public static PlayerResponse.Account.Cosmetics getAllCosmetics() {
try {
InputStream in = Client.getInstance().getClass().getResourceAsStream("/assets/minecraft/silentclient/cosmetics.json");

View File

@ -1,7 +1,10 @@
package net.silentclient.client.emotes;
import net.silentclient.client.Client;
import net.silentclient.client.emotes.socket.EmoteSocket;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.Setting;
import org.lwjgl.input.Keyboard;
public class EmotesMod extends Mod {
@ -14,4 +17,26 @@ public class EmotesMod extends Mod {
this.addBooleanSetting("Emotes", this, true);
this.addKeybindSetting("Emote Wheel Keybind", this, Keyboard.KEY_B);
}
@Override
public void onEnable() {
super.onEnable();
if(Client.getInstance().getSettingsManager().getSettingByClass(EmotesMod.class, "Emotes").getValBoolean()) {
EmoteSocket.get().connect();
} else {
EmoteSocket.get().disconnect();
}
}
@Override
public void onChangeSettingValue(Setting setting) {
super.onChangeSettingValue(setting);
if(setting.getName().equals("Emotes")) {
if(setting.getValBoolean()) {
EmoteSocket.get().connect();
} else {
EmoteSocket.get().disconnect();
}
}
}
}

View File

@ -156,17 +156,17 @@ public class PlayerModelManager {
this.registerEmote(new IcebergEmote("iceberg", "Iceberg"));
this.registerEmote(new PresentEmote("present", "Present"));
this.registerEmote(new ChampagneEmote("champagne", "Champagne"));
this.map.put(1, "best_mates");
this.map.put(2, "boneless");
this.map.put(3, "bow");
this.map.put(4, "boy");
this.map.put(5, "calculated");
this.map.put(6, "chicken");
this.map.put(7, "clapping");
this.map.put(8, "confused");
this.map.put(9, "crying");
this.map.put(10, "dab");
this.map.put(11, "default");
this.map.put(1, "default");
this.map.put(2, "best_mates");
this.map.put(3, "boneless");
this.map.put(4, "bow");
this.map.put(5, "boy");
this.map.put(6, "calculated");
this.map.put(7, "chicken");
this.map.put(8, "clapping");
this.map.put(9, "confused");
this.map.put(10, "crying");
this.map.put(11, "dab");
this.map.put(12, "disco_fever");
this.map.put(13, "electro_shuffle");
this.map.put(14, "facepalm");

View File

@ -0,0 +1,78 @@
package net.silentclient.client.emotes.socket;
import io.socket.client.IO;
import io.socket.client.Socket;
import net.silentclient.client.Client;
import net.silentclient.client.emotes.EmoteManager;
import net.silentclient.client.utils.NotificationUtils;
import org.json.JSONObject;
import java.net.URI;
public class EmoteSocket {
public static EmoteSocket instance;
public static EmoteSocket get() {
if(instance == null) {
instance = new EmoteSocket();
return instance;
}
return instance;
}
private Socket socket;
public EmoteSocket() {
try {
this.socket = IO.socket(new URI("https://emotes.silentclient.net:443"));
} catch (Exception err) {
Client.logger.catching(err);
}
this.socket.on(Socket.EVENT_CONNECT, (Object... arg0) -> {
Client.logger.info("Connected to Emotes Socket");
}).on(Socket.EVENT_DISCONNECT, (Object... arg0) -> {
Client.logger.info("Disconnected from Emotes Socket");
}).on("error", (Object... arg0) -> {
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]);
SocketShowEmote data = Client.getInstance().getGson().fromJson((String)arg0[0], SocketShowEmote.class);
EmoteManager.sendEmote(data.username, data.emoteId);
});
}
public void startEmote(int id) {
this.socket.emit("startEmote", new JSONObject().put("accessToken", Client.getInstance().getUserData().getAccessToken()).put("emoteId", id).toString());
}
public void connect() {
this.socket.connect();
}
public void disconnect() {
this.socket.disconnect();
}
public static class SocketError {
public String error;
public String getError() {
return error;
}
}
public static class SocketShowEmote {
public String username;
public int emoteId;
public String getUsername() {
return username;
}
public int getEmoteId() {
return emoteId;
}
}
}

View File

@ -1,11 +1,12 @@
package net.silentclient.client.emotes.ui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.MathHelper;
import net.silentclient.client.emotes.EmoteManager;
import net.silentclient.client.Client;
import net.silentclient.client.emotes.socket.EmoteSocket;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.utils.types.PlayerResponse;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@ -24,12 +25,15 @@ public class ScreenEmoteWheel extends SilentScreen {
private int page = 1;
private void handleScroll() {
int maxPage = (int) Math.ceil((double) Client.getInstance().getCosmetics().getMyEmotes().size() / 6);
int scroll = Mouse.getEventDWheel();
if (scroll > 0 && this.page > 1) {
this.initGui();
--this.page;
}
if (scroll < 0 && this.page < 12) {
if (scroll < 0 && this.page < maxPage) {
this.initGui();
++this.page;
}
}
@ -52,89 +56,16 @@ public class ScreenEmoteWheel extends SilentScreen {
@Override
public void initGui() {
this.handlers.clear();
switch(this.page) {
case 1:
this.handlers.put("Default", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 11));
this.handlers.put("Boneless", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 2));
this.handlers.put("Bow", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 3));
this.handlers.put("Boyy", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 4));
this.handlers.put("Calculated", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 5));
break;
case 2:
this.handlers.put("Chicken", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 6));
this.handlers.put("Clapping", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 7));
this.handlers.put("Confused", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 8));
this.handlers.put("Crying", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 9));
this.handlers.put("Dab", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 10));
break;
case 3:
this.handlers.put("Best Mates", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 1));
this.handlers.put("Disco Fever", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 12));
this.handlers.put("Electro Shuffle", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 13));
this.handlers.put("Facepalm", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 14));
this.handlers.put("Fist", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 15));
break;
case 4:
this.handlers.put("Floss", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 16));
this.handlers.put("Free Flow", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 17));
this.handlers.put("Fresh", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 18));
this.handlers.put("Gangnam Style", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 19));
this.handlers.put("Get Funky", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 20));
break;
case 5:
this.handlers.put("Hype", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 21));
this.handlers.put("Infinite Dab", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 22));
this.handlers.put("Laughing", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 23));
this.handlers.put("No", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 24));
this.handlers.put("Orange Justice", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 25));
break;
case 6:
this.handlers.put("Pointing", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 26));
this.handlers.put("Salute", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 27));
this.handlers.put("Shimmer", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 28));
this.handlers.put("Shrug", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 29));
this.handlers.put("Skibidi", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 30));
break;
case 7:
this.handlers.put("Squat Kick", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 31));
this.handlers.put("Star Power", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 32));
this.handlers.put("T Pose", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 33));
this.handlers.put("Take The L", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 34));
this.handlers.put("Thinking", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 35));
break;
case 8:
this.handlers.put("Tidy", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 36));
this.handlers.put("Wave", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 37));
this.handlers.put("Yes", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 38));
this.handlers.put("Rising From Dead", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 39));
this.handlers.put("Pumpkin", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 40));
break;
case 9:
this.handlers.put("Trick or Treat", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 41));
this.handlers.put("Blow kiss", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 42));
this.handlers.put("Twerk", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 43));
this.handlers.put("Club", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 44));
this.handlers.put("Sneeze", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 45));
break;
case 10:
this.handlers.put("Punch", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 46));
this.handlers.put("Bongo Cat", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 47));
this.handlers.put("Exhausted", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 48));
this.handlers.put("Disgusted", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 49));
this.handlers.put("Bitch Slap", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 50));
break;
case 11:
this.handlers.put("Threatening", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 51));
this.handlers.put("Woah!", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 52));
this.handlers.put("Breathtaking", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 53));
this.handlers.put("Bunny Hop", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 54));
this.handlers.put("Chicken Dance", emote -> EmoteManager.sendEmote(this.mc.thePlayer.getGameProfile().getName(), 55));
break;
case 12:
this.handlers.put("Broom", hello -> EmoteManager.sendEmote(Minecraft.getMinecraft().getSession().getUsername(), 56));
this.handlers.put("Iceberg", hello -> EmoteManager.sendEmote(Minecraft.getMinecraft().getSession().getUsername(), 57));
this.handlers.put("Present", hello -> EmoteManager.sendEmote(Minecraft.getMinecraft().getSession().getUsername(), 58));
this.handlers.put("Champagne", hello -> EmoteManager.sendEmote(Minecraft.getMinecraft().getSession().getUsername(), 59));
int index = page - 1;
int currentIndex = 0;
for(PlayerResponse.Account.Cosmetics.CosmeticItem item : Client.getInstance().getCosmetics().getMyEmotes()) {
if(currentIndex >= index) {
this.handlers.put(item.getName(), (emote) -> EmoteSocket.get().startEmote(item.getId()));
if(this.handlers.size() == 6) {
break;
}
}
currentIndex++;
}
}
@ -145,7 +76,6 @@ public class ScreenEmoteWheel extends SilentScreen {
int centerX = resolution.getScaledWidth() / 2;
super.drawScreen(mouseX, mouseY, partialTicks);
this.foc = null;
this.initGui();
int count = this.handlers.size();
float radius = (float)resolution.getScaledHeight() * 2.0F / 5.0F;
float i = 0.0F;

View File

@ -440,6 +440,7 @@ public class PlayerResponse extends AbstractReply {
public ArrayList<CosmeticItem> bandanas = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> hats = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> shields = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> emotes = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> getCapes() {
return capes;
@ -465,6 +466,10 @@ public class PlayerResponse extends AbstractReply {
return shields;
}
public ArrayList<CosmeticItem> getEmotes() {
return emotes;
}
public class CosmeticItem {
public int id;
public String name;

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB