Change whole gui system

This commit is contained in:
2026-10-01 16:22:02 -03:00
parent 013a4fbb97
commit deba36260e
48 changed files with 1925 additions and 1302 deletions
+22 -15
View File
@@ -72,6 +72,27 @@ export function setup(ctx: ServerContext) {
applied.delete(player.id);
});
// like curios' CuriosContainer: the slot types in rows of 9, each row centered, over the inventory. the screen is
// in scripts/client.ts
const rows = Math.ceil(active.length / 9);
const menu_type = ctx.menus.register("curios:curios", (menu, _args, player) => {
const curios = curios_of(player);
menu.title = "Curios";
menu.open_data = { rows };
for (const [i, slot] of active.entries()) {
const row = Math.floor(i / 9);
const in_row = Math.min(9, active.length - row * 9);
menu.add_slot(curios, SLOTS.indexOf(slot), {
x: 7 + ((9 - in_row) / 2 + (i % 9)) * 18,
y: 17 + row * 18,
filter: (item) => fits(ctx.tags, slot, item.id),
icon: `curios:empty_${slot}_slot`,
});
}
menu.add_player_inventory(7, 31 + rows * 18);
});
// the curios button, curios' client asks for its menu like the java mod's packet does
ctx.net.on("curios:open", (player) => {
if (active.length === 0) return;
const curios = curios_of(player);
@@ -83,21 +104,7 @@ export function setup(ctx: ServerContext) {
curios.set(index, undefined);
}
}
// in rows of 9, each row centered
ctx.ui.open_container(player, {
container: curios,
layout: active.map((slot, i) => {
const row = Math.floor(i / 9);
const in_row = Math.min(9, active.length - row * 9);
return {
slot: SLOTS.indexOf(slot),
x: (9 - in_row) / 2 + (i % 9),
y: row,
filter: (item) => fits(ctx.tags, slot, item.id),
icon: `curios:empty_${slot}_slot`,
};
}),
});
menu_type.open(player, undefined);
});
ctx.events.after.player_death.subscribe(({ player }) => {