Change curios to always show on inventory
This commit is contained in:
+18
-6
@@ -11,7 +11,13 @@ import {
|
||||
room_for,
|
||||
take_output,
|
||||
} from "$/common/inventory.ts";
|
||||
import { CRAFTING_RESULT_SLOT, type MenuSlotInfo, PLAYER_MENU, PLAYER_MENU_CRAFTING } from "$/common/protocol.ts";
|
||||
import {
|
||||
CRAFTING_RESULT_SLOT,
|
||||
type MenuSlotInfo,
|
||||
PLAYER_MENU,
|
||||
PLAYER_MENU_CRAFTING,
|
||||
PLAYER_MENU_EXTRA,
|
||||
} from "$/common/protocol.ts";
|
||||
import type { GridRecipe } from "$/common/mod_data.ts";
|
||||
import { consume_recipe_items, update_crafting_result } from "./crafting.ts";
|
||||
|
||||
@@ -155,8 +161,8 @@ export class Menu {
|
||||
}
|
||||
}
|
||||
|
||||
// menu 0, the player's own inventory and crafting grid, like minecraft's InventoryMenu. clients know its layout, so
|
||||
// it's never sent
|
||||
// menu 0, the player's own inventory and crafting grid, like minecraft's InventoryMenu, then the slots mods add with
|
||||
// ctx.menus.extend_player_menu. clients know its layout, only the mods' slots are sent, with join
|
||||
export class PlayerMenu extends Menu {
|
||||
#crafting: Container;
|
||||
#recipes: () => GridRecipe[];
|
||||
@@ -198,8 +204,13 @@ export class PlayerMenu extends Menu {
|
||||
}
|
||||
}
|
||||
|
||||
// the inventory moves between the hotbar and the rest, never into the grid. the grid and its result go to the
|
||||
// inventory, the rest first
|
||||
// the slots mods added
|
||||
get extra(): MenuSlot[] {
|
||||
return this.slots.slice(PLAYER_MENU_EXTRA);
|
||||
}
|
||||
|
||||
// the inventory goes into the slots mods added that take it, then between the hotbar and the rest, never into the
|
||||
// grid. the grid, its result and the mods' slots go to the inventory, the rest first
|
||||
override quick_move_targets(index: number): number[] {
|
||||
const main = Array.from({ length: PLAYER_MENU_CRAFTING - 9 }, (_, i) => i + 9);
|
||||
const hotbar = Array.from({ length: 9 }, (_, i) => i);
|
||||
@@ -208,6 +219,7 @@ export class PlayerMenu extends Menu {
|
||||
? [...main, ...hotbar].reverse()
|
||||
: [...main, ...hotbar];
|
||||
}
|
||||
return index < 9 ? main : hotbar;
|
||||
const extra = this.extra.map((_, i) => PLAYER_MENU_EXTRA + i);
|
||||
return [...extra, ...(index < 9 ? main : hotbar)];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user