Hat selector

This commit is contained in:
2025-04-01 16:26:21 +02:00
parent ce64a916c1
commit aa0cd4f42a
9 changed files with 275 additions and 6 deletions
@@ -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("-", ""));
@@ -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<String> 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;
}
}
}
@@ -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++;
@@ -1,6 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "saturnclient:item/halo"
"model": "saturnclient:item/halo_black"
}
}
@@ -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]
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B