Remove duplicate code
This commit is contained in:
+13
-19
@@ -4,6 +4,7 @@
|
||||
import { resolve, toFileUrl } from "@std/path";
|
||||
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import { load_and_check, load_order } from "$/tools/check_mods.ts";
|
||||
import { mod_data } from "$/common/mod_check.ts";
|
||||
import type { ServerModSource } from "$/server/game/load_mods.ts";
|
||||
import { GameServer } from "$/server/game/game_server.ts";
|
||||
import { start_game } from "$/server/game/load_mods.ts";
|
||||
@@ -41,25 +42,7 @@ function read_mod_sources(mods_dir: string): ServerModSource[] {
|
||||
size: 0,
|
||||
...(mod.manifest?.engine_access === true ? { engine_access: true } : {}),
|
||||
},
|
||||
data: {
|
||||
blocks: mod.blocks.map((b) => b.json),
|
||||
models: mod.models.map((m) => m.json),
|
||||
items: mod.items.map((i) => i.json),
|
||||
recipes: mod.recipes.map((r) => r.json),
|
||||
ores: mod.ores.map((o) => o.json),
|
||||
spawns: mod.spawns.map((s) => s.json),
|
||||
entities: mod.entities.map((e) => e.json),
|
||||
entity_models: mod.entity_models.map((m) => m.json),
|
||||
effects: mod.effects.map((e) => e.json),
|
||||
tags: mod.tags.map((t) => t.json),
|
||||
loot_tables: mod.loot_tables.map((t) => t.json),
|
||||
biomes: mod.biomes.map((b) => b.json),
|
||||
noises: mod.noises.map((n) => n.json),
|
||||
density_functions: mod.density_functions.map((d) => d.json),
|
||||
noise_settings: mod.noise_settings.map((n) => n.json),
|
||||
biome_sources: mod.biome_sources.map((b) => b.json),
|
||||
features: mod.features.map((f) => f.json),
|
||||
},
|
||||
data: mod_data(mod),
|
||||
server_url: url(scripts.server),
|
||||
worldgen_url: url(scripts.worldgen),
|
||||
shared_url: url(scripts.shared),
|
||||
@@ -155,6 +138,13 @@ export function sent_block(messages: any[], join: { blocks: string[] }, x: numbe
|
||||
return [join.blocks[value & ID_MASK], value >>> 16];
|
||||
}
|
||||
|
||||
// a stone floor at y 99 from -radius to radius on x and z, high above the terrain, for players to stand on at y 100
|
||||
export function stone_floor(game: GameServer, radius = 3) {
|
||||
for (let x = -radius; x <= radius; x++) {
|
||||
for (let z = -radius; z <= radius; z++) game.set_block(x, 99, z, "bworld:stone");
|
||||
}
|
||||
}
|
||||
|
||||
export function copy_dir(from: string, to: string) {
|
||||
if (Deno.statSync(from).isDirectory) {
|
||||
Deno.mkdirSync(to, { recursive: true });
|
||||
@@ -174,5 +164,9 @@ export const opened_menu = (messages: Msg[]) => messages.findLast((m) => m.type
|
||||
// what the open menu's slots last held among messages, by menu slot index
|
||||
export const menu_items = (messages: Msg[]) => messages.findLast((m) => m.type === "menu_content")?.items;
|
||||
|
||||
// what a container, like "inventory", last held among messages
|
||||
export const container_items = (messages: Msg[], container: string) =>
|
||||
messages.findLast((m) => m.type === "container" && m.container === container)?.items;
|
||||
|
||||
// what the open menu's data last was among messages
|
||||
export const menu_data = (messages: Msg[]) => messages.findLast((m) => m.type === "menu_data")?.data;
|
||||
|
||||
Reference in New Issue
Block a user