Skip to content

Commit

Permalink
custom sitting model
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef-00012 committed Jan 5, 2025
1 parent a28d83a commit efe799c
Show file tree
Hide file tree
Showing 6 changed files with 1,171 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/commands/slash/minecraft.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { avaibleCropTypes, avaibleRenderTypes } from "../../data/constants/lunarEclypse";
import { avaibleCropTypes, avaibleRenderTypes } from "../../data/constants/minecraftSkin";
import type { Client } from "../../structures/DiscordClient";
import type { CropType } from "../../types/lunarEclypse";
import type { CropType } from "../../types/minecraftSkin";
import type { Command } from "../../types/command";
import type {
AutocompleteInteraction,
Expand Down
18 changes: 15 additions & 3 deletions src/commands/slash/minecraft/skin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import { avaibleCropTypes } from "../../../data/constants/lunarEclypse";
import { avaibleCropTypes, customSkinsConfig } from "../../../data/constants/minecraftSkin";
import type { Client } from "../../../structures/DiscordClient";
import type { SkinType } from "../../../types/lunarEclypse";
import type { SkinType } from "../../../types/minecraftSkin";

export default async function (
client: Client,
int: ChatInputCommandInteraction,
) {
const renderType = int.options.getString("render-type", true);
let renderType = int.options.getString("render-type", true);
const cropType = int.options.getString("crop-type", true);

const skinType = int.options.getString("skin-type", false) as SkinType || "wide"
Expand All @@ -34,6 +34,18 @@ export default async function (
skinType
})

if (customSkinsConfig[renderType]) {
const skinConfig = customSkinsConfig[renderType];
renderType = "custom"

const url = `${global.baseUrl}/skinModels/${renderType}`

urlParams.append("wideModel", `${url}/wide.obj`);
urlParams.append("slimModel", `${url}/slim.obj`);
if (skinConfig.cameraPosition) urlParams.append("cameraPosition", JSON.stringify(skinConfig.cameraPosition));
if (skinConfig.cameraFocalPoint) urlParams.append("cameraFocalPoint", JSON.stringify(skinConfig.cameraFocalPoint));
}

if (skinUrl) urlParams.append("skinUrl", skinUrl)

const url = `https://starlightskins.lunareclipse.studio/render/${renderType}/${player}/${cropType}?${urlParams.toString()}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CropType, RenderType } from "../../types/lunarEclypse";
import type { CropType, RenderType, SkinConfig } from "../../types/minecraftSkin";

export const renderTypes: Array<RenderType> = [
"default",
Expand Down Expand Up @@ -29,7 +29,8 @@ export const renderTypes: Array<RenderType> = [
"pixel",
"ornament",
"skin",
"profile"
"profile",
"sitting"
]

export const avaibleCropTypes: {
Expand Down Expand Up @@ -63,7 +64,8 @@ export const avaibleCropTypes: {
pixel: ["full", "bust", "face"],
ornament: ["full"],
skin: ["default", "processed"],
profile: ["full", "bust", "face"]
profile: ["full", "bust", "face"],
sitting: ["full"]
};

export const avaibleRenderTypes: Array<{
Expand Down Expand Up @@ -98,5 +100,23 @@ export const avaibleRenderTypes: Array<{
{ name: "Pixel", value: "pixel" },
{ name: "Ornament", value: "ornament" },
{ name: "Skin", value: "skin" },
{ name: "Profile", value: "profile" }
]
{ name: "Profile", value: "profile" },
{ name: "Sitting", value: "sitting" }
]

export const customSkinsConfig: {
[key in RenderType]?: SkinConfig;
} = {
sitting: {
cameraPosition:{
x: "37.59",
y: "32.05",
z: "-54.2"
},
cameraFocalPoint: {
x: "5.75",
y: "21.35",
z: "-8.27"
},
}
};
20 changes: 19 additions & 1 deletion src/types/lunarEclypse.ts → src/types/minecraftSkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,22 @@ export type RenderType =
| "pixel"
| "ornament"
| "skin"
| "profile";
| "profile"
| "sitting";

export interface SkinConfig {
cameraPosition?: CameraPosition;
cameraFocalPoint?: CameraFocalPoint;
}

export interface CameraPosition {
x: string;
y: string;
z: string;
}

export interface CameraFocalPoint {
x: string;
y: string;
z: string;
}
Loading

0 comments on commit efe799c

Please sign in to comment.