Curios slots rendering !

This commit is contained in:
2026-10-01 17:57:22 -03:00
parent ea9f3f61bb
commit f2c3cb8135
39 changed files with 1032 additions and 226 deletions
+13
View File
@@ -1,4 +1,5 @@
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_WIDTH } from "$/common/constants.ts";
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import { Container, Cursor, ItemData, ItemStack } from "$/common/inventory.ts";
import type { GridRecipe } from "$/common/mod_data.ts";
import { Menu, PlayerMenu } from "./menu.ts";
@@ -66,6 +67,10 @@ export class ServerPlayer extends LivingEntity {
menu: Menu | undefined;
// the last menu id given out, they go 1 to 100 and around
menu_id = 0;
// what mods show on them, by each mod's key, see set_worn. not saved, mods set it again when they join
worn = new Map<string, ItemStack[]>();
// the json of the worn list everyone was last sent, to send it again when it changes
worn_sent = "[]";
// base64 png, see /skin. undefined is the default skin
skin: string | undefined;
// the skin is for the model with 3 pixel wide arms
@@ -186,9 +191,17 @@ export class ServerPlayer extends LivingEntity {
pitch: this.pitch,
skin: this.skin,
slim: this.slim || undefined,
...(this.worn_list().length ? { worn: this.worn_list() } : {}),
};
}
// what they wear that shows, every key's in the order they were first set: the items that have a worn model
worn_list(): ItemData[] {
return [...this.worn.values()].flat()
.filter((stack) => EverythingRegistry.get<ItemRegistry>("items", stack.type_id)?.worn)
.map((stack) => stack.to_data());
}
save_player(): SavedPlayer {
return {
x: this.x,