Curios slots rendering !
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user