Remove duplicate code

This commit is contained in:
2026-10-13 11:57:43 -03:00
parent dfc6a6d77b
commit 5165698fe3
50 changed files with 307 additions and 812 deletions
+20
View File
@@ -137,6 +137,26 @@ export class ModGraphics implements Graphics {
);
}
progress(
empty: string,
full: string,
x: number,
y: number,
w: number,
h: number,
filled: number,
direction: "right" | "up" = "right",
) {
// nothing filled for NaN too, like progress / max before there's a max
const done = filled > 0 ? Math.min(1, filled) : 0;
this.texture(empty, x, y, w, h);
if (direction === "right") {
this.texture(full, x, y, w * done, h, [0, 0, done, 1]);
} else {
this.texture(full, x, y + h * (1 - done), w, h * done, [0, 1 - done, 1, done]);
}
}
item(id: string, x: number, y: number, count = 1) {
if (!EverythingRegistry.get<ItemRegistry>("items", id)) throw new Error(`unknown item ${id}`);
const stack = new ItemStack(id, count);