Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 501ccd1

Browse files
authored
- Add spawn rule internal (#268)
1 parent b4b868e commit 501ccd1

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/internal/behavior-pack/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export * from "./item";
99
export * from "./feature";
1010
export * from "./feature_rule";
1111
export * from './item_catalog';
12-
export * from './recipe';
12+
export * from './recipe';
13+
export * from './spawn_rule';
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ComponentContainer } from 'bc-minecraft-bedrock-types/lib/minecraft/components';
2+
import { FormatVersion } from "../types/format-version";
3+
4+
/** */
5+
export interface SpawnRule extends Readonly<FormatVersion> {
6+
/** */
7+
format_version: string;
8+
/** */
9+
"minecraft:spawn_rules": {
10+
description: {
11+
identifier: string
12+
population_control: string
13+
},
14+
conditions: ComponentContainer[]
15+
};
16+
}
17+
18+
/**
19+
*
20+
*/
21+
export namespace SpawnRule {
22+
/**
23+
*
24+
* @param value
25+
* @returns
26+
*/
27+
export function is(value: any): value is SpawnRule {
28+
if (typeof value === "object" && typeof value.format_version === "string" && typeof value["minecraft:spawn_rules"] === "object") {
29+
const desc = value["minecraft:spawn_rules"].description;
30+
31+
if (typeof desc === "object" && typeof desc.identifier === "string" && Array.isArray(value['minecraft:spawn_rules'].conditions)) {
32+
return true;
33+
}
34+
}
35+
36+
return false;
37+
}
38+
}

0 commit comments

Comments
 (0)