Slim skins

This commit is contained in:
2026-09-27 13:55:46 -03:00
parent d822267bd3
commit d0cbec1846
8 changed files with 89 additions and 13 deletions
+23 -8
View File
@@ -1022,15 +1022,28 @@ export class GameServer {
register(
literal<ServerCommandSource>("skin")
.describe("Changes your skin to a 64x64 png from the web, or back to the default without a url")
.describe(
"Changes your skin to a 64x64 png from the web, slim for 3 pixel wide arms. " +
"Back to the default without a url",
)
.executes((context) => {
this.set_skin(context.source.server_player, undefined);
this.set_skin(context.source.server_player, undefined, false);
context.source.send_message("Your skin is back to the default");
})
.then(
argument<string, ServerCommandSource>("url", word())
.executes((context) =>
this.#download_skin(context.source.server_player, context.get<string>("url"))
this.#download_skin(context.source.server_player, context.get<string>("url"), false)
)
.then(
argument<string, ServerCommandSource>("model", choice(["slim", "normal"]))
.executes((context) =>
this.#download_skin(
context.source.server_player,
context.get<string>("url"),
context.get<string>("model") === "slim",
)
),
),
),
);
@@ -1063,15 +1076,17 @@ export class GameServer {
);
}
// a base64 png, or undefined for the default skin. everyone is told, the player too
set_skin(player: ServerPlayer, skin: string | undefined) {
// a base64 png, or undefined for the default skin, and whether it's for the slim model. everyone is told, the
// player too
set_skin(player: ServerPlayer, skin: string | undefined, slim: boolean) {
player.skin = skin;
player.slim = slim;
this.world.dirty = true;
this.#broadcast({ type: "player_skin", id: player.id, skin });
this.#broadcast({ type: "player_skin", id: player.id, skin, slim: slim || undefined });
}
// the host downloads it, which takes a while, so the player hears back later
#download_skin(player: ServerPlayer, url: string) {
#download_skin(player: ServerPlayer, url: string, slim: boolean) {
if (player.downloading_skin) {
throw new CommandError("Your last skin is still downloading");
}
@@ -1086,7 +1101,7 @@ export class GameServer {
throw new Error(problem);
}
if (online()) {
this.set_skin(player, encode_skin(bytes));
this.set_skin(player, encode_skin(bytes), slim);
this.send_chat(player, "Skin changed");
}
})