-
Notifications
You must be signed in to change notification settings - Fork 2
/
json_format.d.ts
213 lines (200 loc) · 3.74 KB
/
json_format.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/**
* A reference of the JSON serialized format of the NBT docs
*/
export module nbtdoc {
/**
* A reference to an element inside an `Arena`
*/
export type Index<T> = number;
/**
* A referenceable list
*/
export type Arena<T> = T[];
/**
* A type of index
*/
export type ItemIndex = { Compound: Index<CompoundTag> } |
{ Enum: Index<EnumItem> } |
{ Module: Index<Module> };
/**
* A segment of a path to an actual NBT value
*/
export type FieldPath = "Super" | { Child: string };
/**
* The type that a field can be
*/
export type NbtValue = "Boolean" |
{
/**i8 range*/
Byte: NumberTag
} |
{
/**i16 range*/
Short: NumberTag
} |
{
/**i32 range*/
Int: NumberTag
} |
{
/**i64 range, lossy in JS*/
Long: NumberTag
} |
{
/**f32 range*/
Float: NumberTag
} |
{
/**f64 range*/
Double: NumberTag
} |
"String" |
{
/**i8 value range*/
ByteArray: NumberArrayTag
} |
{
/**i32 value range*/
IntArray: NumberArrayTag
} |
{
/**i64 value range*/
LongArray: NumberArrayTag
} |
{ Compound: Index<CompoundTag> } |
{ Enum: Index<EnumItem> } |
{ List: {
/**positive i32 range*/
length_range: Range | null,
value_type: NbtValue
} } |
{ Index: {
/**ID*/
target: string,
path: FieldPath[]
} } |
{
/**ID*/
Id: string
} |
{ Or: NbtValue[] };
/**
* Internal Use
* Signifies a certain inject that has not been executed yet
*/
type UnresolvedInject = { Compound: [string, Field][]} | { Enum: EnumType };
/**
* A range of numbers. Both sides inclusive
*/
type Range = [number, number];
/**
* The different types of enums
*/
type EnumType = { Byte: {
/**i8 range*/
[key: string]: EnumOption<number>
} } |
{ Short: {
/**i16 range*/
[key: string]: EnumOption<number>
} } |
{ Int: {
/**i32 range*/
[key: string]: EnumOption<number>
} } |
{ Long: {
/**i64 range, lossy in JS*/
[key: string]: EnumOption<number>
} } |
{ Float: {
/**f32 range*/
[key: string]: EnumOption<number>
} } |
{ Double: {
/**f64 range*/
[key: string]: EnumOption<number>
} } |
{ String: {
[key: string]: EnumOption<string>
} };
/**
* The main struct in the validation process
*/
export interface Root {
registries: {
[/**ID*/ key: string]: [
{
[/**ID*/ key: string]: Index<CompoundTag>
},
(Index<CompoundTag> | null)
]
},
root_modules: { [key: string]: Index<Module> },
compound_arena: Arena<CompoundTag>,
enum_arena: Arena<EnumItem>,
module_arena: Arena<Module>,
/** Only needed for inner workings */
unresolved_inject: Array<
{ Unregistered: [ string[], UnresolvedInject ]} |
{ Registered: [ ItemIndex, UnresolvedInject, string ]}
>
}
/**
* A specific compound definition
*/
export interface CompoundTag {
description: string,
fields: { [key: string]: Field },
supers: (
{ Compound: Index<CompoundTag> } |
{ Registry: {
/**ID*/
target: string,
path: FieldPath[]
} } |
null
)
}
/**
* A field in a compound definition
*/
export interface Field {
description: string,
nbttype: NbtValue
}
/**
* An individual module
*/
export interface Module {
children: { [key: string]: ItemIndex },
parent: Index<Module> | null
}
/**
* A value enumeration
*/
export interface EnumItem {
et: EnumType,
description: string
}
/**
* An individual enum option
*/
export interface EnumOption<T> {
value: T,
description: string
}
/**
* A scalar number NBT value
*/
export interface NumberTag {
range: Range | null
}
/**
* A scalar number array NBT value
*/
export interface NumberArrayTag {
/**positive i32 range*/
length_range: Range | null,
value_range: Range | null
}
}