Skip to content

Commit 9a6dedc

Browse files
committed
Refactored
1 parent 110fc66 commit 9a6dedc

File tree

4 files changed

+100
-56
lines changed

4 files changed

+100
-56
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"script": "build",
77
"isBackground": false,
88
"group": "build",
9-
"label": "npm build 'bc-minecraft-molang'",
9+
"label": "npm compile 'bc-minecraft-molang'",
1010
"presentation": { "reveal": "always", "panel": "dedicated" },
1111
"problemMatcher": ["$tsc"]
1212
},

src/MolangData/MolangData.ts

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,44 @@
1-
import { Types } from "bc-minecraft-bedrock-types";
1+
import { Data } from "./Data";
22

3-
/**
4-
*
5-
*/
6-
export interface MolangFunction extends Types.Identifiable, Types.Documentated {
7-
/**
8-
*
9-
*/
10-
parameters?: MolangParameter[];
3+
import { Animations as MAnimations } from "./Animations";
4+
import { AnimationsControllers as MAnimationsControllers } from "./AnimationsControllers";
5+
import { Blocks as MBlocks } from "./Blocks";
6+
import { Entities as MEntities } from "./Entities";
7+
import { FeaturesRules as MFeaturesRules } from "./FeaturesRules";
8+
import { General as MGeneral } from "./General";
9+
import { Items as MItems } from "./Items";
10+
import { Particles as MParticles } from "./Particles";
11+
import { RenderControllers as MRenderControllers } from "./RenderControllers";
1112

12-
/**If present, then the molang is deprecated and needs to be replaced*/
13-
deprecated? : string;
13+
export interface MolangDataSet {
14+
Variables: Data[];
15+
Contexts: Data[];
16+
Temps: Data[];
1417
}
1518

16-
/**
17-
*
18-
*/
19-
export namespace MolangFunction {
20-
/**
21-
*
22-
* @param value
23-
* @returns
24-
*/
25-
export function is(value: any): value is MolangFunction {
26-
if (typeof value === "object") {
27-
if (typeof value.id === "string") return true;
28-
}
19+
export namespace MolangData {
20+
export const Animations = MAnimations;
21+
export const AnimationsControllers = MAnimationsControllers;
22+
export const Blocks = MBlocks;
23+
export const Entities = MEntities;
24+
export const FeaturesRules = MFeaturesRules;
25+
export const General = MGeneral;
26+
export const Items = MItems;
27+
export const Particles = MParticles;
28+
export const RenderControllers = MRenderControllers;
2929

30-
return false;
30+
export function get(type: MolangDataSetKey): MolangDataSet {
31+
return MolangData[type] as MolangDataSet;
3132
}
3233
}
3334

34-
/**
35-
*
36-
*/
37-
export interface MolangParameter extends Types.Identifiable, Types.Documentated {
38-
/** */
39-
range?: { min: number; max: number };
40-
/**
41-
*
42-
*/
43-
type?: "boolean" | "float" | "string";
44-
}
45-
46-
/**
47-
*
48-
*/
49-
export namespace MolangParameter {
50-
/**
51-
*
52-
* @param value
53-
* @returns
54-
*/
55-
export function is(value: any): value is MolangParameter {
56-
if (typeof value === "object") {
57-
if (typeof value.id === "string") return true;
58-
}
59-
60-
return false;
61-
}
62-
}
35+
export type MolangDataSetKey =
36+
| "Animations"
37+
| "AnimationsControllers"
38+
| "Blocks"
39+
| "Entities"
40+
| "FeaturesRules"
41+
| "General"
42+
| "Items"
43+
| "Particles"
44+
| "RenderControllers";

src/MolangData/MolangFunction.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Types } from "bc-minecraft-bedrock-types";
2+
3+
/**
4+
*
5+
*/
6+
export interface MolangFunction extends Types.Identifiable, Types.Documentated {
7+
/**
8+
*
9+
*/
10+
parameters?: MolangParameter[];
11+
12+
/**If present, then the molang is deprecated and needs to be replaced*/
13+
deprecated? : string;
14+
}
15+
16+
/**
17+
*
18+
*/
19+
export namespace MolangFunction {
20+
/**
21+
*
22+
* @param value
23+
* @returns
24+
*/
25+
export function is(value: any): value is MolangFunction {
26+
if (typeof value === "object") {
27+
if (typeof value.id === "string") return true;
28+
}
29+
30+
return false;
31+
}
32+
}
33+
34+
/**
35+
*
36+
*/
37+
export interface MolangParameter extends Types.Identifiable, Types.Documentated {
38+
/** */
39+
range?: { min: number; max: number };
40+
/**
41+
*
42+
*/
43+
type?: "boolean" | "float" | "string";
44+
}
45+
46+
/**
47+
*
48+
*/
49+
export namespace MolangParameter {
50+
/**
51+
*
52+
* @param value
53+
* @returns
54+
*/
55+
export function is(value: any): value is MolangParameter {
56+
if (typeof value === "object") {
57+
if (typeof value.id === "string") return true;
58+
}
59+
60+
return false;
61+
}
62+
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * as MolangData from "./MolangData";
1+
export * from "./MolangData";
22
export * as Molang from "./Molang";
33
export * from "./Types/Defined Using";

0 commit comments

Comments
 (0)