diff --git a/index.html b/index.html index 0459ceb3..2ec63925 100644 --- a/index.html +++ b/index.html @@ -159,6 +159,12 @@
+
+
+ +
+ +
diff --git a/schemas/1.14.json b/schemas/1.14.json index b11323f6..dca1ffa6 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -190,7 +190,7 @@ }, { "id": "tag", - "type": "string", + "type": "nbt", "require": [ "minecraft:set_nbt" ] @@ -319,6 +319,15 @@ "minecraft:set_attributes" ] }, + { + "id": "ops", + "type": "array", + "button": "field", + "values": "nbt_operation", + "require": [ + "minecraft:copy_nbt" + ] + }, { "id": "conditions", "type": "array", @@ -405,6 +414,37 @@ ] } ] + }, + { + "id": "nbt_operation", + "type": "object", + "color": "dark", + "default": { + "operation": "replace" + }, + "fields": [ + { + "id": "source", + "type": "string", + "class": "code" + }, + { + "id": "target", + "type": "string", + "class": "code" + }, + { + "id": "op", + "type": "enum", + "source": "operation.type", + "default": "replace", + "values": [ + "replace", + "append", + "merge" + ] + } + ] } ] } diff --git a/view.js b/view.js index a8749b9d..3756471a 100644 --- a/view.js +++ b/view.js @@ -51,6 +51,7 @@ function generateComponent(data, struct) { case 'set': return generateSet(data, struct); case 'json': return generateJson(data, struct); case 'json-list': return generateJsonList(data, struct); + case 'nbt': return generateNbt(data, struct); case 'array': return generateArray(data, struct); case 'object': return generateObject(data, struct); default: return generateError('Unknown component type "' + struct.type + '"')}; @@ -198,6 +199,14 @@ function generateJsonList(data, struct) { return $el; } +function generateNbt(data, struct) { + let $el = $('#components').find('[data-type="nbt"]').clone(); + $el.attr('data-field', struct.id); + $el.find('[data-name]').attr('data-i18n', struct.id); + $el.find('textarea').val(data).keydown(e => preventNewline(e)); + return $el; +} + function generateError(error) { let $el = $('#components').find('[data-type="error"]').clone(); $el.find('[data-name]').val(error); @@ -239,6 +248,9 @@ function generateObject(data, struct) { console.error(e); $field = generateError('Failed generating "' + field.id + '" component'); } + if (field.class) { + $field.addClass(field.class); + } if (field.type === 'array') { let color = field.color; if (color === undefined) { @@ -254,6 +266,8 @@ function generateObject(data, struct) { $field.attr('data-field', field.id); } $body.append($field); + } else { + delete data[field.id]; } } $body.children().first().removeClass('mt-3');