From 5bbcc86251eaa69b25d4c3995dbeb54739881d2c Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 21 May 2020 14:11:50 +0200 Subject: [PATCH] Add default dimension type and prevent duplicates --- js/view.js | 25 ++++++++++++++++++++++++- locales/en.json | 4 ++++ schemas/worldgen.json | 7 ++++--- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/js/view.js b/js/view.js index f697acf5..b0991b68 100644 --- a/js/view.js +++ b/js/view.js @@ -1,6 +1,8 @@ const themes = ["light", "dark"]; +let preventDuplicateDimensionType = [false, false, false, false]; + themes.forEach(v => $('#themeList').append(``)); addListener(updateView); @@ -205,7 +207,28 @@ function generateEnum(data, struct) { if (struct.help) { $el.append(generateTooltip(struct.translateValue + '.' + data.replace(/.*:/, ''))); } - return {out: data, component: $el}; + let out = data; + if (struct.translate === 'dimension.type') { + const i = struct.values.indexOf(data) + if (i !== -1 ) { + if (preventDuplicateDimensionType[i]) { + data = 'minecraft:default'; + } else { + preventDuplicateDimensionType[i] = true; + } + } + if (data === 'minecraft:default') { + out = { + "ultrawarm": false, + "natural": true, + "shrunk": false, + "ambient_light": 0, + "has_skylight": true, + "has_ceiling": false + }; + } + } + return {out: out, component: $el}; } function generateSet(data, struct) { diff --git a/locales/en.json b/locales/en.json index 9938b133..910cb83c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -176,6 +176,10 @@ "dimension.type.fixed_time": "Fixed Time", "dimension.type.has_skylight": "Has Skylight", "dimension.type.has_ceiling": "Has Ceiling", + "dimension.type.presets.default": "Default", + "dimension.type.presets.overworld": "Overworld", + "dimension.type.presets.the_nether": "The Nether", + "dimension.type.presets.the_end": "The End", "display": "Display", "display.icon": "Icon", "display.icon.item": "Icon Item", diff --git a/schemas/worldgen.json b/schemas/worldgen.json index 80bfa9fd..e85f40d3 100644 --- a/schemas/worldgen.json +++ b/schemas/worldgen.json @@ -463,12 +463,13 @@ { "id": "type", "translate": "dimension.type", - "translateValue": "dimension", + "translateValue": "dimension.type.presets", "type": "object", "color": "dark", "collapse": true, - "default": "minecraft:overworld", + "default": "minecraft:default", "values": [ + "minecraft:default", "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" @@ -498,7 +499,7 @@ "id": "ambient_light", "translate": "dimension.type.ambient_light", "type": "float", - "default": 0.5 + "default": 0 }, { "id": "fixed_time",