From 5e9fbc0f893a4d0d4b39681271afbb31b0b6da2d Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 4 Oct 2019 10:15:47 +0200 Subject: [PATCH] Add maps of objects + add entity effect property --- locales/en.json | 14 +++++++-- model.js | 3 +- schemas/1.14.json | 74 +++++++++++++++++++++++++++++++++++++++++++++-- view.js | 18 +++++++++--- 4 files changed, 98 insertions(+), 11 deletions(-) diff --git a/locales/en.json b/locales/en.json index e8ebc6b6..d0c87a2e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -29,8 +29,7 @@ "block_state": "Block State", "block_state_add": "Add Block State", "block_state_remove": "Remove Block State", - "objective": "Objective", - "score": "Score", + "score": "Objective", "score_add": "Add Score", "score_remove": "Remove Score", "location": "Location", @@ -234,7 +233,10 @@ "$entity": { "type": "Entity", "nbt": "NBT", - "location": "Location" + "location": "Location", + "status_effect": "Effects", + "status_effect_add": "Add Effect", + "status_effect_remove": "Remove Effect" }, "$location": { "position": "Position", @@ -247,6 +249,12 @@ "feature": "Feature", "dimension": "Dimension" }, + "$status_effect": { + "amplifier": "Amplifier", + "duration": "Duration", + "ambient": "Ambient", + "visible": "Visible" + }, "$item": { "name": "Item ID", "tag": "Item Tag", diff --git a/model.js b/model.js index 14c20ade..3ed3745e 100644 --- a/model.js +++ b/model.js @@ -242,6 +242,8 @@ function addToMap(el) { node[map][key] = 0; } else if (type === 'boolean') { node[map][key] = false; + } else if (type === 'object') { + node[map][key] = {}; } else { node[map][key] = ""; } @@ -275,7 +277,6 @@ function toggleCollapseObject(el) { function updateField(el) { let path = getPath(el); - console.log(path); let $field = $(el).closest('[data-index]'); let field = path.pop(); let node = getNode(path); diff --git a/schemas/1.14.json b/schemas/1.14.json index f94a0995..d2eba69b 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -505,7 +505,6 @@ "id": "properties", "type": "map", "translate": "$condition.block_state", - "translateValue": "$condition.block_state", "values": { "type": "string" }, @@ -516,8 +515,7 @@ { "id": "scores", "type": "map", - "translate": "$condition.objective", - "translateValue": "$condition.score", + "translate": "$condition.score", "values": { "type": "range" }, @@ -703,6 +701,15 @@ "translate": "$entity.location", "value": "location", "collapse": true + }, + { + "id": "effects", + "type": "map", + "translate": "$entity.status_effect", + "values": { + "type": "object", + "value": "status_effect" + } } ] }, @@ -761,6 +768,33 @@ } ] }, + { + "id": "status_effect", + "type": "object", + "color": "dark", + "fields": [ + { + "id": "amplifier", + "type": "range", + "translate": "$status_effect.amplifier" + }, + { + "id": "duration", + "type": "range", + "translate": "$status_effect.duration" + }, + { + "id": "ambient", + "type": "boolean", + "translate": "$status_effect.ambient" + }, + { + "id": "visible", + "type": "boolean", + "translate": "$status_effect.visible" + } + ] + }, { "id": "item", "type": "object", @@ -1104,6 +1138,40 @@ "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" + ], + "status_effects": [ + "minecraft:speed", + "minecraft:slowness", + "minecraft:haste", + "minecraft:mining_fatigue", + "minecraft:strength", + "minecraft:instant_health", + "minecraft:instant_damage", + "minecraft:jump_boost", + "minecraft:nausea", + "minecraft:regeneration", + "minecraft:resistance", + "minecraft:fire_resistance", + "minecraft:water_breathing", + "minecraft:invisibility", + "minecraft:blindness", + "minecraft:night_vision", + "minecraft:hunger", + "minecraft:weakness", + "minecraft:poison", + "minecraft:wither", + "minecraft:health_boost", + "minecraft:absorption", + "minecraft:saturation", + "minecraft:glowing", + "minecraft:levitation", + "minecraft:luck", + "minecraft:unluck", + "minecraft:slow_falling", + "minecraft:conduit_power", + "minecraft:dolphins_grace", + "minecraft:bad_omen", + "minecraft:hero_of_the_village" ] } } diff --git a/view.js b/view.js index fa70e529..2565b724 100644 --- a/view.js +++ b/view.js @@ -197,13 +197,23 @@ function generateMap(data, struct) { let $el = $('#components').find('[data-type="map"]').clone(); $el.attr('data-index', struct.id).attr('data-item-type', struct.values.type); $el.find('[data-name="1"]').attr('data-i18n', struct.translate); - $el.find('[data-name="2"]').attr('data-i18n', struct.translateValue + '_add'); + $el.find('[data-name="2"]').attr('data-i18n', struct.translate + '_add'); $el.find('input').keypress((e) => {if (e.which == 13) addToMap(e.target);}); if (data) { for (let key of Object.keys(data)) { - console.log(data[key]); - let $item = generateComponent(data[key], {id: key, type: struct.values.type, translate: key}); - $item.append('
'); + let field = struct.values; + field.id = key; + field.translate = key; + let $item = generateComponent(data[key], field);; + if (field.type === 'object') { + let $header = $('
'); + $header.append(('')); + $header.append(''); + $item.prepend($header); + } else { + $item.append('
'); + } + $item.attr('data-index', field.id); $el.append($item); } }