From 2e0fc7a5c47f1c86538c7821843dd4b9faccf4c1 Mon Sep 17 00:00:00 2001 From: SPGoding Date: Wed, 11 Dec 2019 23:46:43 -0600 Subject: [PATCH 1/5] Fix typos of block_state_property --- locales/en.json | 2 +- locales/ru.json | 2 +- locales/zh-CN.json | 2 +- schemas/1.14.json | 6 +++--- schemas/1.15.json | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/locales/en.json b/locales/en.json index 67c8ba9e..7e0d046c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -48,7 +48,7 @@ "condition.thundering": "Thundering", "condition.type": "Condition", "condition.type.alternative": "Alternative", - "condition.type.block_state_propery": "Block Properties", + "condition.type.block_state_property": "Block Properties", "condition.type.damage_source_properties": "Damage Source", "condition.type.entity_properties": "Entity Properties", "condition.type.entity_scores": "Entity Scores", diff --git a/locales/ru.json b/locales/ru.json index 97302168..e1704337 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -55,7 +55,7 @@ "condition.thundering": "Гроза", "condition.type": "Условие", "condition.type.alternative": "Выбор", - "condition.type.block_state_propery": "Свойства блока", + "condition.type.block_state_property": "Свойства блока", "condition.type.damage_source_properties": "Источник урона", "condition.type.entity_properties": "Свойства сущности", "condition.type.entity_scores": "Счёты сущности", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index b70a3023..3cd8c661 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -55,7 +55,7 @@ "condition.thundering": "雷雨", "condition.type": "条件", "condition.type.alternative": "析取范式", - "condition.type.block_state_propery": "方块属性", + "condition.type.block_state_property": "方块属性", "condition.type.damage_source_properties": "伤害源", "condition.type.entity_properties": "实体属性", "condition.type.entity_scores": "实体分数", diff --git a/schemas/1.14.json b/schemas/1.14.json index b95ec2fc..b74e3e9b 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -483,7 +483,7 @@ "minecraft:inverted", "minecraft:entity_properties", { - "value": "minecraft:block_state_propery", + "value": "minecraft:block_state_property", "require": ["minecraft:block"] }, { @@ -591,7 +591,7 @@ "type": "string", "translate": "condition.block", "require": [ - "minecraft:block_state_propery" + "minecraft:block_state_property" ] }, { @@ -602,7 +602,7 @@ "type": "string" }, "require": [ - "minecraft:block_state_propery" + "minecraft:block_state_property" ] }, { diff --git a/schemas/1.15.json b/schemas/1.15.json index e23e6899..a59daa73 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -501,7 +501,7 @@ "minecraft:reference", "minecraft:entity_properties", { - "value": "minecraft:block_state_propery", + "value": "minecraft:block_state_property", "require": ["minecraft:block"] }, { @@ -617,7 +617,7 @@ "type": "string", "translate": "condition.block", "require": [ - "minecraft:block_state_propery" + "minecraft:block_state_property" ] }, { @@ -628,7 +628,7 @@ "type": "string" }, "require": [ - "minecraft:block_state_propery" + "minecraft:block_state_property" ] }, { From c691ab3dad50f60ad166b01016d2235467403714 Mon Sep 17 00:00:00 2001 From: SPGoding Date: Wed, 11 Dec 2019 23:50:15 -0600 Subject: [PATCH 2/5] Fix weight and quality being an object --- schemas/1.13.json | 4 ++-- schemas/1.14.json | 4 ++-- schemas/1.15.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schemas/1.13.json b/schemas/1.13.json index d4bc268b..a458c029 100644 --- a/schemas/1.13.json +++ b/schemas/1.13.json @@ -70,12 +70,12 @@ }, { "id": "weight", - "type": "range", + "type": "int", "translate": "entry.weight" }, { "id": "quality", - "type": "range", + "type": "int", "translate": "entry.quality", "luckBased": true }, diff --git a/schemas/1.14.json b/schemas/1.14.json index b95ec2fc..1003104b 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -99,12 +99,12 @@ }, { "id": "weight", - "type": "random", + "type": "int", "translate": "entry.weight" }, { "id": "quality", - "type": "random", + "type": "int", "translate": "entry.quality", "luckBased": true }, diff --git a/schemas/1.15.json b/schemas/1.15.json index e23e6899..66b50ebe 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -99,12 +99,12 @@ }, { "id": "weight", - "type": "random", + "type": "int", "translate": "entry.weight" }, { "id": "quality", - "type": "random", + "type": "int", "translate": "entry.quality", "luckBased": true }, From 2ac16fd0e72bb8b2e1e3c0761a2fa729cf52bcf2 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 13 Dec 2019 18:53:01 +0100 Subject: [PATCH 3/5] Add predicate mode --- index.html | 10 ++++---- locales/en.json | 6 +++-- locales/ru.json | 4 +-- locales/zh-CN.json | 4 +-- model.js | 2 +- schemas/1.13.json | 1 + schemas/1.14.json | 1 + schemas/1.15.json | 62 +++++++++++++++++++++++++++------------------- view.js | 30 +++++++++++++++++----- 9 files changed, 77 insertions(+), 43 deletions(-) diff --git a/index.html b/index.html index 0dab10b2..f3d1b381 100644 --- a/index.html +++ b/index.html @@ -11,13 +11,13 @@ - +
-
-
+
+
@@ -58,7 +58,7 @@
-
+
diff --git a/locales/en.json b/locales/en.json index 67c8ba9e..51423011 100644 --- a/locales/en.json +++ b/locales/en.json @@ -75,7 +75,8 @@ "damage_source.is_magic": "Magic", "damage_source.is_projectile": "Projectile", "damage_source.source_entity": "Source Entity", - "description": "Loot Table Generator for Minecraft", + "description.loot-table": "Loot Table Generator for Minecraft", + "description.predicate": "Predicate Generator for Minecraft", "dimension.overworld": "Overworld", "dimension.the_end": "The End", "dimension.the_nether": "The Nether", @@ -290,7 +291,8 @@ "tabs": "Tabs", "term_add": "Add Term", "term_remove": "Remove Term", - "title": "Loot Table Generator", + "title.loot-table": "Loot Table Generator", + "title.predicate": "Predicate Generator", "true": "True", "unset": "Unset" } diff --git a/locales/ru.json b/locales/ru.json index 97302168..fa056989 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -82,7 +82,7 @@ "damage_source.is_magic": "Магия", "damage_source.is_projectile": "Снаряд", "damage_source.source_entity": "Сущность-источник урона", - "description": "Генератор таблицы добычи для Minecraft", + "description.loot-table": "Генератор таблицы добычи для Minecraft", "dimension.overworld": "Обычный мир", "dimension.the_end": "Энд", "dimension.the_nether": "Незер", @@ -298,7 +298,7 @@ "tabs": "Табуляция", "term_add": "Добавить выражение", "term_remove": "Удалить выражение", - "title": "Генератор таблицы добычи", + "title.loot-table": "Генератор таблицы добычи", "true": "Да", "unset": "Не задано" } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index b70a3023..19ee3d3f 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -82,7 +82,7 @@ "damage_source.is_magic": "魔法", "damage_source.is_projectile": "弹射物", "damage_source.source_entity": "根本来源实体", - "description": "Minecraft 战利品表生成器", + "description.loot-table": "Minecraft 战利品表生成器", "dimension.overworld": "主世界", "dimension.the_end": "末路之地", "dimension.the_nether": "下界", @@ -299,7 +299,7 @@ "tabs": "Tab 缩进", "term_add": "添加条件", "term_remove": "移除条件", - "title": "战利品表生成器", + "title.loot-table": "战利品表生成器", "true": "是", "unset": "未指定" } diff --git a/model.js b/model.js index b04b39e5..93680f25 100644 --- a/model.js +++ b/model.js @@ -148,7 +148,7 @@ function copySource(el) { function getPath(el) { let $node = $(el).closest('[data-index]'); let index = $node.attr('data-index'); - if (index === 'table') return []; + if (index === 'root') return []; let parent = getPath($node.parent()); parent = parent.concat(index.split('.')); return parent; diff --git a/schemas/1.13.json b/schemas/1.13.json index d4bc268b..3771403e 100644 --- a/schemas/1.13.json +++ b/schemas/1.13.json @@ -1,5 +1,6 @@ { "root": { + "id": "loot-table", "fields": [ { "id": "pools", diff --git a/schemas/1.14.json b/schemas/1.14.json index b95ec2fc..b4000f31 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -1,5 +1,6 @@ { "root": { + "id": "loot-table", "fields": [ { "id": "type", diff --git a/schemas/1.15.json b/schemas/1.15.json index e23e6899..95ad8067 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -1,29 +1,41 @@ { - "root": { - "fields": [ - { - "id": "type", - "type": "enum", - "translate": "table.type", - "translateValue": "table.type", - "default": "minecraft:generic", - "values": [ - "minecraft:empty", - "minecraft:entity", - "minecraft:block", - "minecraft:chest", - "minecraft:fishing", - "minecraft:generic" - ] - }, - { - "id": "pools", - "type": "array", - "translate": "pool", - "values": "pool" - } - ] - }, + "roots": [ + { + "id": "loot-table", + "title": "title.loot-table", + "description": "description.loot-table", + "fields": [ + { + "id": "type", + "type": "enum", + "translate": "table.type", + "translateValue": "table.type", + "default": "minecraft:generic", + "values": [ + "minecraft:empty", + "minecraft:entity", + "minecraft:block", + "minecraft:chest", + "minecraft:fishing", + "minecraft:generic" + ] + }, + { + "id": "pools", + "type": "array", + "translate": "pool", + "values": "pool" + } + ] + }, + { + "id": "predicate", + "title": "title.predicate", + "description": "description.predicate", + "type": "object", + "value": "condition" + } + ], "components": [ { "id": "pool", diff --git a/view.js b/view.js index 593ee93c..c15fd461 100644 --- a/view.js +++ b/view.js @@ -2,10 +2,16 @@ let structure; let components; let collections; -changeVersion('1.14'); +changeVersion('1.15'); function changeVersion(version) { $.getJSON('schemas/' + version + '.json', json => { - structure = json.root; + console.log(json); + if (json.root) { + structure = json.root; + } else if (json.roots) { + let id = window.location.pathname.replace(/\/$/, '').replace(/^\//, ''); + structure = json.roots.find(e => e.id === id); + } components = json.components; collections = json.collections; }).fail((jqXHR, textStatus, errorThrown) => { @@ -28,19 +34,31 @@ function changeVersion(version) { function updateView() { if (structure) { - let {out: tableOut, component: $table} = generateTable(table, structure); - $('#structure').append($table); + let {out: sourceOut, component: $component} = generateSourceAndView(table, structure); + $('#structure').removeClass('d-none').html(''); + $('#descriptionSpan').attr('data-i18n', structure.description); + $('title').attr('data-i18n', structure.title); + $('#structure').append($component); if (i18next.isInitialized) { $('html').localize(); } - $('#source').val(JSON.stringify(tableOut, null, indentation)); + $('#source').val(JSON.stringify(sourceOut, null, indentation)); + } +} + +function generateSourceAndView(data, struct) { + if (struct.id === 'loot-table') { + $('#lootTableToolbar').removeClass('d-none'); + $('#structure').attr('data-index', 'pools'); + return generateTable(data, struct); + } else { + return generateObject(data, struct, false); } } function generateTable(data, struct) { let out = {}; let $el = $('
'); - $('#structure').removeClass('d-none').html(''); let type = struct.fields.find(e => e.id === 'type'); if (type) { From 7eb62e2317ff5a7ee701de313b7e35475408998b Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 13 Dec 2019 23:25:37 +0100 Subject: [PATCH 4/5] Show all conditions for predicates --- view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view.js b/view.js index c15fd461..925b7b82 100644 --- a/view.js +++ b/view.js @@ -188,7 +188,7 @@ function generateEnum(data, struct) { } for (let value of collection) { if (typeof value === 'object') { - if (value.require.includes(correctNamespace(table.type))) { + if (structure.id === 'predicate' || value.require.includes(correctNamespace(table.type))) { $el.find('select').append(setValueAndName($('