Fluid slots and kegs !
This commit is contained in:
@@ -744,6 +744,14 @@ export interface SlotOptions {
|
||||
max_count?: number;
|
||||
}
|
||||
|
||||
export interface FluidSlotOptions {
|
||||
// gui pixels from the screen's top left to the slot's 18 pixel frame
|
||||
x: number;
|
||||
y: number;
|
||||
// fluid containers only fill from it, like a machine's output
|
||||
output_only?: boolean;
|
||||
}
|
||||
|
||||
// what a menu type's build function gets, like neoforge's server menu constructor
|
||||
export interface MenuBuilder {
|
||||
title: string;
|
||||
@@ -751,6 +759,10 @@ export interface MenuBuilder {
|
||||
open_data: unknown;
|
||||
// a slot of a container from ctx.containers, or of player.inventory. returns its menu slot index
|
||||
add_slot(container: Container, slot: number, options: SlotOptions): number;
|
||||
// a tank of handler, like modern industrialization's fluid slots: the screen draws its fluid in an 18 pixel frame,
|
||||
// with the amount in its tooltip, and clicking it with a fluid container on the cursor fills that from the tank, or
|
||||
// else empties it in through the handler. returns its index among the menu's fluid slots
|
||||
add_fluid_slot(handler: FluidHandler, tank: number, options: FluidSlotOptions): number;
|
||||
// the player's 36 slots, like addStandardInventorySlots: the rest of the inventory in 3 rows from x and y, the
|
||||
// hotbar 58 pixels under them. added in inventory order, so inventory slot i is the returned index plus i
|
||||
add_player_inventory(x: number, y: number): number;
|
||||
|
||||
+23
-2
@@ -4,13 +4,14 @@
|
||||
// messages sent between the client and the server, as json over a websocket. chunks are binary, see level_chunk
|
||||
import type { Faces } from "./constants.ts";
|
||||
import type { ItemData } from "./inventory.ts";
|
||||
import type { FluidVariant } from "./mod_api/shared.ts";
|
||||
import type { ModListing } from "./mod_loader.ts";
|
||||
|
||||
export const AIR_ID = "bworld:air";
|
||||
|
||||
// bump when a client and server of different versions can't play together.
|
||||
// the server rejects a different version before the client downloads anything
|
||||
export const PROTOCOL_VERSION = 24;
|
||||
export const PROTOCOL_VERSION = 25;
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
@@ -84,6 +85,21 @@ export interface MenuSlotInfo {
|
||||
max_count?: number;
|
||||
}
|
||||
|
||||
// a tank shown in a menu, like modern industrialization's fluid slots: an 18 pixel frame at x y, which a fluid
|
||||
// container on the cursor fills from, or empties into unless it's an output
|
||||
export interface MenuFluidSlotInfo {
|
||||
x: number;
|
||||
y: number;
|
||||
output?: boolean;
|
||||
}
|
||||
|
||||
// what's in a menu's tank, no fluid when it's empty
|
||||
export interface MenuTank {
|
||||
fluid?: FluidVariant;
|
||||
amount: number;
|
||||
capacity: number;
|
||||
}
|
||||
|
||||
// clients send what the player is trying to do, the server decides what happens
|
||||
export type ClientMessage =
|
||||
| { type: "hello"; name: string; protocol: number }
|
||||
@@ -138,6 +154,8 @@ export type ClientMessage =
|
||||
// a slot of the open menu, or of menu 0 when none is. shift moves the stack to the other part of the menu instead,
|
||||
// like minecraft's quick move. clicks for a menu that isn't open any more are ignored
|
||||
| { type: "click"; menu: number; slot: number; button: number; shift?: boolean }
|
||||
// a fluid slot of the open menu, by its index among the fluid slots, with whatever the cursor holds
|
||||
| { type: "click_fluid"; menu: number; slot: number }
|
||||
// q on a slot (the held one when no screen is open, in menu 0) throws one item, or the whole stack with ctrl
|
||||
| { type: "drop_item"; menu: number; slot: number; all: boolean }
|
||||
// a button of the open menu, like minecraft's clickMenuButton. the menu decides what the number means
|
||||
@@ -248,7 +266,7 @@ export type ServerMessage =
|
||||
| { type: "container"; container: ContainerKey; items: (ItemData | null)[] }
|
||||
| { type: "cursor"; item: ItemData | null }
|
||||
// a menu opened, replacing any other. id counts 1 to 100 and around, type is the menu type whose screen draws it.
|
||||
// its slots' items come in menu_content, its data's changes in menu_data
|
||||
// its slots' items come in menu_content, its tanks in menu_tanks, its data's changes in menu_data
|
||||
| {
|
||||
type: "open_menu";
|
||||
id: number;
|
||||
@@ -256,10 +274,13 @@ export type ServerMessage =
|
||||
title: string;
|
||||
open_data: unknown;
|
||||
slots: MenuSlotInfo[];
|
||||
fluid_slots: MenuFluidSlotInfo[];
|
||||
data: Record<string, number>;
|
||||
}
|
||||
// what's in every slot of the open menu, by menu slot index, when any of it changed
|
||||
| { type: "menu_content"; id: number; items: (ItemData | null)[] }
|
||||
// what's in every fluid slot's tank of the open menu, when any of it changed
|
||||
| { type: "menu_tanks"; id: number; tanks: MenuTank[] }
|
||||
// all the menu's data, when any of it changed
|
||||
| { type: "menu_data"; id: number; data: Record<string, number> }
|
||||
// the server closed it (the block broke, the player walked away), it already put everything back
|
||||
|
||||
Reference in New Issue
Block a user