Skip to content

Commit 54b7ac7

Browse files
committed
Finish blockstates schema
Reformat all schemas
1 parent 6dddbeb commit 54b7ac7

File tree

2 files changed

+270
-86
lines changed

2 files changed

+270
-86
lines changed

src/main/resources/jsonSchemas/blockstates.schema.json

+225-31
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,263 @@
22
"$schema": "http://json-schema.org/draft-04/schema#",
33
"title": "Minecraft Blockstates JSON",
44
"definitions": {
5+
"baseVariantObject": {
6+
"type": "object",
7+
"properties": {
8+
"__comment": { "type": "string" },
9+
"model": { "type": "string" },
10+
"textures": {
11+
"type": "object",
12+
"additionalProperties": { "type": "string" }
13+
},
14+
"x": {
15+
"type": "number",
16+
"multipleOf": 22.5
17+
},
18+
"y": {
19+
"type": "number",
20+
"multipleOf": 22.5
21+
},
22+
"uvlock": { "type": "boolean" }
23+
},
24+
"additionalProperties": false
25+
},
26+
"vanillaVariantObject": {
27+
"oneOf": [
28+
{ "$ref": "#/definitions/baseVariantObject" },
29+
{
30+
"type": "array",
31+
"items": {
32+
"allOf": [
33+
{ "$ref": "#/definitions/baseVariantObject" },
34+
{
35+
"properties": {
36+
"weight": { "type": "number" }
37+
}
38+
}
39+
]
40+
}
41+
}
42+
]
43+
},
544
"variantDefinition": {
645
"type": "object",
7-
"additionalProperties": {
8-
"oneOf": [
9-
{
10-
"type": "object",
11-
"additionalProperties": { "$ref": "#/definitions/variantObject" }
46+
"patternProperties": {
47+
"^([a-z0-9_]+=[^,]*,)*([a-z0-9_]+=[^,]*)$": {
48+
"type": "array",
49+
"items": { "$ref": "#/definitions/variantObject" }
50+
},
51+
"^[a-z0-9_]+$": {
52+
"type": "object",
53+
"additionalProperties": { "$ref": "#/definitions/variantObject" }
54+
}
55+
}
56+
},
57+
"variantObject": {
58+
"allOf": [
59+
{ "$ref": "#/definitions/baseVariantObject" },
60+
{
61+
"properties": {
62+
"transform": { "$ref": "#/definitions/rootTransform" },
63+
"weight": { "type": "number" },
64+
"submodel": {
65+
"oneOf": [
66+
{ "type": "string" },
67+
{
68+
"type": "object",
69+
"additionalProperties": {
70+
"oneOf": [
71+
{ "$ref": "#/definitions/variantObject" },
72+
{
73+
"type": "array",
74+
"items": { "$ref": "#/definitions/variantObject" }
75+
}
76+
]
77+
}
78+
}
79+
]
80+
},
81+
"custom": {
82+
"type": "object",
83+
"additionalProperties": true
84+
}
85+
}
86+
}
87+
]
88+
},
89+
"rootTransform": {
90+
"oneOf": [
91+
{ "$ref": "#/definitions/transform" },
92+
{
93+
"type": "object",
94+
"patternProperties": {
95+
"(third|first)person_(left|right)hand": { "$ref": "#/definitions/transform" },
96+
"gui|head|ground|fixed": { "$ref": "#/definitions/transform" }
1297
},
13-
{
14-
"type": "array",
15-
"items": { "$ref": "#/definitions/variantObject" }
98+
"additionalProperties": false
99+
}
100+
]
101+
},
102+
"transform": {
103+
"oneOf": [
104+
{
105+
"type": "string",
106+
"enum": ["identity", "forge:default-block", "forge:default-item", "forge:default-tool"]
107+
},
108+
{
109+
"type": "object",
110+
"required": ["matrix"],
111+
"properties": {
112+
"matrix": { "$ref": "#/definitions/transformMatrix" }
16113
}
17-
]
114+
},
115+
{ "$ref": "#/definitions/transformMatrix" },
116+
{
117+
"type": "object",
118+
"properties": {
119+
"translation": {
120+
"type": "array",
121+
"minItems": 3,
122+
"maxItems": 3,
123+
"items": { "type": "number" }
124+
},
125+
"scale": {
126+
"oneOf": [
127+
{
128+
"type": "array",
129+
"minItems": 3,
130+
"maxItems": 3,
131+
"items": { "type": "number" }
132+
},
133+
{ "type": "number" }
134+
]
135+
},
136+
"rotation": { "$ref": "#/definitions/transformRotation" },
137+
"post-rotation": { "$ref": "#/definitions/transformRotation" }
138+
}
139+
}
140+
]
141+
},
142+
"transformMatrix": {
143+
"type": "array",
144+
"minItems": 3,
145+
"maxItems": 3,
146+
"items": {
147+
"type": "array",
148+
"minItems": 4,
149+
"maxItems": 4,
150+
"items": { "type": "number" }
18151
}
19152
},
20-
"variantObject": {
21-
"type": "object",
22-
"properties": {
23-
"__comment": {
24-
"type": "string"
153+
"transformRotation": {
154+
"oneOf": [
155+
{
156+
"type": "array",
157+
"minItems": 4,
158+
"maxItems": 4,
159+
"items": { "type": "number" }
25160
},
26-
"model": { "type": "string" },
27-
"textures": {
161+
{
28162
"type": "object",
29-
"additionalProperties": {
30-
"type": "string"
163+
"minProperties": 1,
164+
"maxProperties": 1,
165+
"properties": {
166+
"x": { "type": "number" },
167+
"y": { "type": "number" },
168+
"z": { "type": "number" }
169+
}
170+
},
171+
{
172+
"type": "array",
173+
"items": {
174+
"type": "object",
175+
"minProperties": 1,
176+
"maxProperties": 1,
177+
"properties": {
178+
"x": { "type": "number" },
179+
"y": { "type": "number" },
180+
"z": { "type": "number" }
181+
}
31182
}
32183
}
184+
]
185+
},
186+
"multipartCase": {
187+
"type": "object",
188+
"properties": {
189+
"apply": { "$ref": "#/definitions/vanillaVariantObject" },
190+
"when": {
191+
"oneOf": [
192+
{
193+
"type": "object",
194+
"patternProperties": {
195+
"^[a-z0-9_]*$": { }
196+
},
197+
"additionalProperties": false,
198+
"not": { "required": ["OR"] }
199+
},
200+
{
201+
"type": "object",
202+
"properties": {
203+
"OR": {
204+
"type": "array",
205+
"items": {
206+
"type": "object",
207+
"patternProperties": {
208+
"^[a-z0-9_]*$": { }
209+
},
210+
"additionalProperties": false
211+
}
212+
}
213+
},
214+
"required": ["OR"],
215+
"additionalProperties": false
216+
}
217+
]
218+
}
33219
},
34-
"additionalProperties": false
220+
"required": ["apply"]
35221
}
36222
},
37223
"oneOf": [
38224
{
39225
"type": "object",
40226
"properties": {
41-
"__comment": {
42-
"type": "string"
43-
},
227+
"__comment": { "type": "string" },
44228
"variants": {
45229
"type": "object",
46-
"additionalProperties": { "$ref": "#/definitions/variantObject" }
230+
"patternProperties": {
231+
"^([a-z0-9_]+=[^,]*,)*([a-z0-9_]+=[^,]*)$": { "$ref": "#/definitions/vanillaVariantObject" }
232+
}
47233
}
48234
},
49235
"additionalProperties": false,
50-
"required": [ "variants" ],
51-
"not": { "required": [ "forge_marker" ] }
236+
"required": ["variants"]
52237
},
53238
{
54239
"type": "object",
55240
"properties": {
56-
"__comment": {
57-
"type": "string"
58-
},
241+
"__comment": { "type": "string" },
59242
"forge_marker": {
60243
"type": "integer",
61-
"enum": [ 1 ]
244+
"enum": [1]
62245
},
63246
"variants": { "$ref": "#/definitions/variantDefinition" },
64-
"defaults": { "$ref": "#/definitions/variantObject" }
247+
"defaults": { "$ref": "#/definitions/variantObject" },
248+
"multipart": {
249+
"type": "array",
250+
"items": { "$ref": "#/definitions/multipartCase" }
251+
}
65252
},
66253
"additionalProperties": false,
67-
"required": [ "forge_marker", "variants" ]
254+
"dependencies": {
255+
"defaults": ["forge_marker"],
256+
"variants": ["forge_marker"],
257+
"forge_marker": ["variants"],
258+
"multipart": {
259+
"not": { "required": ["forge_marker"] }
260+
}
261+
}
68262
}
69263
]
70264
}

0 commit comments

Comments
 (0)