diff --git a/src/main/java/org/saturnclient/saturnclient/auth/SaturnSocket.java b/src/main/java/org/saturnclient/saturnclient/auth/SaturnSocket.java index dfe2802..cf73279 100644 --- a/src/main/java/org/saturnclient/saturnclient/auth/SaturnSocket.java +++ b/src/main/java/org/saturnclient/saturnclient/auth/SaturnSocket.java @@ -9,6 +9,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.minecraft.client.MinecraftClient; import org.saturnclient.saturnclient.SaturnClient; +import org.saturnclient.saturnclient.cosmetics.Hats; import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks; public class SaturnSocket { @@ -61,6 +62,10 @@ public class SaturnSocket { Cloaks.availableCloaks.add(availableCloak); } + for (String availableHat : parser.getArray("hats")) { + Hats.availableHats.add(availableHat); + } + players.put(uuid, new SaturnPlayer(cloak, hat)); playerNames.put(client.getSession().getUsername(), uuid); @@ -147,6 +152,14 @@ public class SaturnSocket { } } + public static void setHat(String hatName) { + try { + writer.println("set_hat@hat=" + hatName); + } catch (Exception e) { + SaturnClient.LOGGER.error("Request failed", e); + } + } + public static void player(String name, String uuid) { try { playerNames.put(name, uuid.replaceAll("-", "")); diff --git a/src/main/java/org/saturnclient/saturnclient/cosmetics/Hats.java b/src/main/java/org/saturnclient/saturnclient/cosmetics/Hats.java index 9d2a519..cffbe43 100644 --- a/src/main/java/org/saturnclient/saturnclient/cosmetics/Hats.java +++ b/src/main/java/org/saturnclient/saturnclient/cosmetics/Hats.java @@ -3,10 +3,27 @@ package org.saturnclient.saturnclient.cosmetics; import java.util.ArrayList; import java.util.List; +import org.saturnclient.saturnclient.auth.SaturnPlayer; +import org.saturnclient.saturnclient.auth.SaturnSocket; + public class Hats { public static List availableHats = new ArrayList<>(); public static void initialize() { availableHats.add(0, ""); } + + public static void setHat(String uuid, String hatName) { + setHatSilent(uuid, hatName); + SaturnSocket.setHat(hatName); + } + + public static void setHatSilent(String uuid, String hatName) { + SaturnPlayer player = SaturnSocket.players.get(uuid); + if (player == null) { + SaturnSocket.players.put(uuid, new SaturnPlayer("", hatName)); + } else { + player.hat = hatName; + } + } } diff --git a/src/main/java/org/saturnclient/saturnclient/menus/HatsMenu.java b/src/main/java/org/saturnclient/saturnclient/menus/HatsMenu.java index d7b4a02..be6adfd 100644 --- a/src/main/java/org/saturnclient/saturnclient/menus/HatsMenu.java +++ b/src/main/java/org/saturnclient/saturnclient/menus/HatsMenu.java @@ -2,6 +2,7 @@ package org.saturnclient.saturnclient.menus; import net.minecraft.text.Text; import org.saturnclient.saturnclient.SaturnClient; +import org.saturnclient.saturnclient.auth.SaturnSocket; import org.saturnclient.saturnclient.cosmetics.Hats; import org.saturnclient.ui.SaturnUi; import org.saturnclient.ui.Textures; @@ -87,22 +88,20 @@ public class HatsMenu extends SaturnUi { for (String hat : Hats.availableHats) { modsScroll.draw( new SaturnClickableSprite(Textures.BUTTON_BORDER, () -> { - // Hats.setHat(SaturnSocket.uuid, hat); + Hats.setHat(SaturnSocket.uuid, hat); }) .setColor(10526880) .setX(modX) .setY(modY) .setWidth(hatSize + 6) - .setHeight(hatSize + 6) - .setAnimations(SaturnClient.getAnimations())); + .setHeight(hatSize + 6)); modsScroll.draw( new SaturnImage(Textures.getHatPreview(hat)) .setX(modX + 3) .setY(modY + 3) .setWidth(hatSize) - .setHeight(hatSize) - .setAnimations(SaturnClient.getAnimations())); + .setHeight(hatSize)); col++; diff --git a/src/main/resources/assets/saturnclient/items/hat_halo_black.json b/src/main/resources/assets/saturnclient/items/hat_halo_black.json index b33d02a..be1f7ad 100644 --- a/src/main/resources/assets/saturnclient/items/hat_halo_black.json +++ b/src/main/resources/assets/saturnclient/items/hat_halo_black.json @@ -1,6 +1,6 @@ { "model": { "type": "minecraft:model", - "model": "saturnclient:item/halo" + "model": "saturnclient:item/halo_black" } } diff --git a/src/main/resources/assets/saturnclient/models/item/halo_black.json b/src/main/resources/assets/saturnclient/models/item/halo_black.json new file mode 100644 index 0000000..b03fef1 --- /dev/null +++ b/src/main/resources/assets/saturnclient/models/item/halo_black.json @@ -0,0 +1,240 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "saturnclient:item/halo_black" + }, + "elements": [ + { + "name": "hexadecagon", + "from": [7.40326, 10, 5], + "to": [8.59674, 11, 6], + "rotation": {"angle": -45, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 5], + "to": [8.59674, 11, 6], + "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 5], + "to": [8.59674, 11, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 5], + "to": [8.59674, 11, 6], + "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 5], + "to": [8.59674, 11, 6], + "rotation": {"angle": 45, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 10], + "to": [8.59674, 11, 11], + "rotation": {"angle": -45, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 10], + "to": [8.59674, 11, 11], + "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 10], + "to": [8.59674, 11, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 10], + "to": [8.59674, 11, 11], + "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [7.40326, 10, 10], + "to": [8.59674, 11, 11], + "rotation": {"angle": 45, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [5, 10, 7.40326], + "to": [6, 11, 8.59674], + "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [5, 10, 7.40326], + "to": [6, 11, 8.59674], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [5, 10, 7.40326], + "to": [6, 11, 8.59674], + "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [10, 10, 7.40326], + "to": [11, 11, 8.59674], + "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [10, 10, 7.40326], + "to": [11, 11, 8.59674], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + }, + { + "name": "hexadecagon", + "from": [10, 10, 7.40326], + "to": [11, 11, 8.59674], + "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 11, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#1"} + } + } + ], + "groups": [ + { + "name": "hexadecagon", + "origin": [8, 8, 8], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/saturnclient/textures/gui/hat/.png b/src/main/resources/assets/saturnclient/textures/gui/hat/.png new file mode 100644 index 0000000..16c2bbe Binary files /dev/null and b/src/main/resources/assets/saturnclient/textures/gui/hat/.png differ diff --git a/src/main/resources/assets/saturnclient/textures/gui/hat/halo.png b/src/main/resources/assets/saturnclient/textures/gui/hat/halo.png new file mode 100644 index 0000000..cbdeafa Binary files /dev/null and b/src/main/resources/assets/saturnclient/textures/gui/hat/halo.png differ diff --git a/src/main/resources/assets/saturnclient/textures/gui/hat/halo_black.png b/src/main/resources/assets/saturnclient/textures/gui/hat/halo_black.png new file mode 100644 index 0000000..244aeca Binary files /dev/null and b/src/main/resources/assets/saturnclient/textures/gui/hat/halo_black.png differ diff --git a/src/main/resources/assets/saturnclient/textures/item/halo_black.png b/src/main/resources/assets/saturnclient/textures/item/halo_black.png new file mode 100644 index 0000000..c0d7493 Binary files /dev/null and b/src/main/resources/assets/saturnclient/textures/item/halo_black.png differ