sharing contexts
This commit is contained in:
+12
-17
@@ -27,11 +27,12 @@ import type { ModelJson } from "@/common/block_models.ts";
|
||||
import type { SavedChunk, SavedChunks, WorldSave } from "@/server/game/saves.ts";
|
||||
import { FluidRules } from "@/common/fluids.ts";
|
||||
import { BlockRules } from "@/common/block_rules.ts";
|
||||
import { collision_shape_at, covers_face, is_solid } from "@/common/block_shapes.ts";
|
||||
import { tag_api } from "@/common/tags.ts";
|
||||
import { get_state_value, set_state_value, shared_items_api } from "@/common/utils.ts";
|
||||
import { collision_shape_at, covers_face } from "@/common/block_shapes.ts";
|
||||
import { get_state_value, set_state_value } from "@/common/utils.ts";
|
||||
import type { Face, SharedWorld } from "@/common/mod_api/shared.ts";
|
||||
import { shared as setup_shared } from "@/mods/bworld/scripts/shared.ts";
|
||||
import { shared_context } from "@/common/shared_context.ts";
|
||||
import { RecipeBook } from "@/common/mod_loader.ts";
|
||||
|
||||
// the repo's own mods/, read once: reading and checking every mod's files is most of starting a game in a test. only
|
||||
// mods/ is kept, since tests change the temporary folders they make between games
|
||||
@@ -377,6 +378,7 @@ export function client_of(game: GameServer, area: Area) {
|
||||
const info = (id: string) => EverythingRegistry.get<BlockRegistry>("blocks", id);
|
||||
|
||||
const rules = new BlockRules((_mod, _what, fn) => fn(), (x, y, z) => at(x, y, z)?.[0]);
|
||||
const recipes = new RecipeBook();
|
||||
const world: SharedWorld = {
|
||||
get_block: (x, y, z) => at(x, y, z)?.[0],
|
||||
get_state(x, y, z, name) {
|
||||
@@ -403,22 +405,15 @@ export function client_of(game: GameServer, area: Area) {
|
||||
biome_at: () => undefined,
|
||||
season_at: () => undefined,
|
||||
};
|
||||
setup_shared({
|
||||
mod: { id: "bworld", version: "test" },
|
||||
setup_shared(shared_context({ id: "bworld", version: "test" }, {
|
||||
side: "client",
|
||||
tags: tag_api(),
|
||||
blocks: {
|
||||
exists: (id) => info(id) !== undefined,
|
||||
components: (id) => structuredClone(info(id)!.components ?? {}),
|
||||
solid: (id) => id !== AIR_ID && is_solid(info(id)!),
|
||||
},
|
||||
items: shared_items_api("bworld", new FluidRules((_mod, _what, fn) => fn())),
|
||||
// only its blocks are looked at here
|
||||
fluids: { exists: () => false, same: () => false, register() {} },
|
||||
recipes: { register() {}, list: () => [], register_type() {}, find: () => undefined, all: () => [] },
|
||||
world,
|
||||
components: { register_block: (id, block_rules) => rules.register("bworld", id, block_rules) },
|
||||
});
|
||||
block_rules: rules,
|
||||
fluid_rules: new FluidRules((_mod, _what, fn) => fn()),
|
||||
// its recipes aren't looked at here
|
||||
recipes: () => recipes,
|
||||
running: () => true,
|
||||
}));
|
||||
|
||||
return {
|
||||
// what game_mode does when this client places held against face of x y z, at hit
|
||||
|
||||
Reference in New Issue
Block a user