From 54b7ac7f02d3de41e05960308b9622f11a5a2394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20R=C3=B6sch?= Date: Sun, 10 Dec 2017 00:21:52 +0100 Subject: [PATCH] Finish blockstates schema Reformat all schemas --- .../jsonSchemas/blockstates.schema.json | 256 +++++++++++++++--- .../resources/jsonSchemas/sounds.schema.json | 100 +++---- 2 files changed, 270 insertions(+), 86 deletions(-) diff --git a/src/main/resources/jsonSchemas/blockstates.schema.json b/src/main/resources/jsonSchemas/blockstates.schema.json index c8a3d6581..2ee4eeaba 100644 --- a/src/main/resources/jsonSchemas/blockstates.schema.json +++ b/src/main/resources/jsonSchemas/blockstates.schema.json @@ -2,69 +2,263 @@ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Minecraft Blockstates JSON", "definitions": { + "baseVariantObject": { + "type": "object", + "properties": { + "__comment": { "type": "string" }, + "model": { "type": "string" }, + "textures": { + "type": "object", + "additionalProperties": { "type": "string" } + }, + "x": { + "type": "number", + "multipleOf": 22.5 + }, + "y": { + "type": "number", + "multipleOf": 22.5 + }, + "uvlock": { "type": "boolean" } + }, + "additionalProperties": false + }, + "vanillaVariantObject": { + "oneOf": [ + { "$ref": "#/definitions/baseVariantObject" }, + { + "type": "array", + "items": { + "allOf": [ + { "$ref": "#/definitions/baseVariantObject" }, + { + "properties": { + "weight": { "type": "number" } + } + } + ] + } + } + ] + }, "variantDefinition": { "type": "object", - "additionalProperties": { - "oneOf": [ - { - "type": "object", - "additionalProperties": { "$ref": "#/definitions/variantObject" } + "patternProperties": { + "^([a-z0-9_]+=[^,]*,)*([a-z0-9_]+=[^,]*)$": { + "type": "array", + "items": { "$ref": "#/definitions/variantObject" } + }, + "^[a-z0-9_]+$": { + "type": "object", + "additionalProperties": { "$ref": "#/definitions/variantObject" } + } + } + }, + "variantObject": { + "allOf": [ + { "$ref": "#/definitions/baseVariantObject" }, + { + "properties": { + "transform": { "$ref": "#/definitions/rootTransform" }, + "weight": { "type": "number" }, + "submodel": { + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { + "oneOf": [ + { "$ref": "#/definitions/variantObject" }, + { + "type": "array", + "items": { "$ref": "#/definitions/variantObject" } + } + ] + } + } + ] + }, + "custom": { + "type": "object", + "additionalProperties": true + } + } + } + ] + }, + "rootTransform": { + "oneOf": [ + { "$ref": "#/definitions/transform" }, + { + "type": "object", + "patternProperties": { + "(third|first)person_(left|right)hand": { "$ref": "#/definitions/transform" }, + "gui|head|ground|fixed": { "$ref": "#/definitions/transform" } }, - { - "type": "array", - "items": { "$ref": "#/definitions/variantObject" } + "additionalProperties": false + } + ] + }, + "transform": { + "oneOf": [ + { + "type": "string", + "enum": ["identity", "forge:default-block", "forge:default-item", "forge:default-tool"] + }, + { + "type": "object", + "required": ["matrix"], + "properties": { + "matrix": { "$ref": "#/definitions/transformMatrix" } } - ] + }, + { "$ref": "#/definitions/transformMatrix" }, + { + "type": "object", + "properties": { + "translation": { + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": { "type": "number" } + }, + "scale": { + "oneOf": [ + { + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": { "type": "number" } + }, + { "type": "number" } + ] + }, + "rotation": { "$ref": "#/definitions/transformRotation" }, + "post-rotation": { "$ref": "#/definitions/transformRotation" } + } + } + ] + }, + "transformMatrix": { + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": { + "type": "array", + "minItems": 4, + "maxItems": 4, + "items": { "type": "number" } } }, - "variantObject": { - "type": "object", - "properties": { - "__comment": { - "type": "string" + "transformRotation": { + "oneOf": [ + { + "type": "array", + "minItems": 4, + "maxItems": 4, + "items": { "type": "number" } }, - "model": { "type": "string" }, - "textures": { + { "type": "object", - "additionalProperties": { - "type": "string" + "minProperties": 1, + "maxProperties": 1, + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" }, + "z": { "type": "number" } + } + }, + { + "type": "array", + "items": { + "type": "object", + "minProperties": 1, + "maxProperties": 1, + "properties": { + "x": { "type": "number" }, + "y": { "type": "number" }, + "z": { "type": "number" } + } } } + ] + }, + "multipartCase": { + "type": "object", + "properties": { + "apply": { "$ref": "#/definitions/vanillaVariantObject" }, + "when": { + "oneOf": [ + { + "type": "object", + "patternProperties": { + "^[a-z0-9_]*$": { } + }, + "additionalProperties": false, + "not": { "required": ["OR"] } + }, + { + "type": "object", + "properties": { + "OR": { + "type": "array", + "items": { + "type": "object", + "patternProperties": { + "^[a-z0-9_]*$": { } + }, + "additionalProperties": false + } + } + }, + "required": ["OR"], + "additionalProperties": false + } + ] + } }, - "additionalProperties": false + "required": ["apply"] } }, "oneOf": [ { "type": "object", "properties": { - "__comment": { - "type": "string" - }, + "__comment": { "type": "string" }, "variants": { "type": "object", - "additionalProperties": { "$ref": "#/definitions/variantObject" } + "patternProperties": { + "^([a-z0-9_]+=[^,]*,)*([a-z0-9_]+=[^,]*)$": { "$ref": "#/definitions/vanillaVariantObject" } + } } }, "additionalProperties": false, - "required": [ "variants" ], - "not": { "required": [ "forge_marker" ] } + "required": ["variants"] }, { "type": "object", "properties": { - "__comment": { - "type": "string" - }, + "__comment": { "type": "string" }, "forge_marker": { "type": "integer", - "enum": [ 1 ] + "enum": [1] }, "variants": { "$ref": "#/definitions/variantDefinition" }, - "defaults": { "$ref": "#/definitions/variantObject" } + "defaults": { "$ref": "#/definitions/variantObject" }, + "multipart": { + "type": "array", + "items": { "$ref": "#/definitions/multipartCase" } + } }, "additionalProperties": false, - "required": [ "forge_marker", "variants" ] + "dependencies": { + "defaults": ["forge_marker"], + "variants": ["forge_marker"], + "forge_marker": ["variants"], + "multipart": { + "not": { "required": ["forge_marker"] } + } + } } ] } diff --git a/src/main/resources/jsonSchemas/sounds.schema.json b/src/main/resources/jsonSchemas/sounds.schema.json index a4ba6d0e0..f41341851 100644 --- a/src/main/resources/jsonSchemas/sounds.schema.json +++ b/src/main/resources/jsonSchemas/sounds.schema.json @@ -1,60 +1,50 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Minecraft Sounds JSON", - "type": "object", - "additionalProperties": { + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Minecraft Sounds JSON", "type": "object", - "properties": { - "category": { - "type": "string" - }, - "replace": { - "type": "boolean" - }, - "subtitle": { - "type": "string" - }, - "sounds": { - "type": "array", - "items": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" + "additionalProperties": { + "type": "object", + "properties": { + "category": { "type": "string" }, + "replace": { "type": "boolean" }, + "subtitle": { "type": "string" }, + "sounds": { + "type": "array", + "items": { + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "name": { "type": "string" }, + "volume": { + "type": "number", + "minimum": 0, + "maximum": 1, + "default": 1 + }, + "pitch": { + "type": "number", + "default": 1 + }, + "weight": { + "type": "number", + "default": 1 + }, + "stream": { + "type": "boolean", + "default": false + }, + "type": { + "enum": ["sound", "event"], + "default": "sound" + } + } + } + ] }, - "volume": { - "type": "number", - "minimum": 0, - "maximum": 1, - "default": 1 - }, - "pitch": { - "type": "number", - "default": 1 - }, - "weight": { - "type": "number", - "default": 1 - }, - "stream": { - "type": "boolean", - "default": false - }, - "type": { - "enum": [ "sound", "event" ], - "default": "sound" - } - } + "uniqueItems": true } - ] - }, - "uniqueItems": true - } + } } - } -} \ No newline at end of file +}