diff --git a/js/model.js b/js/model.js index fc2f825d..fc6e9f43 100644 --- a/js/model.js +++ b/js/model.js @@ -336,7 +336,7 @@ function toggleCollapseObject(el) { let path = getPath(el); let index = path.pop(); let node = getNode(path); - if (!node[index]) { + if (typeof node[index] !== 'object') { node[index] = {}; } else { delete node[index]; diff --git a/js/view.js b/js/view.js index d0031ff1..29e91b3a 100644 --- a/js/view.js +++ b/js/view.js @@ -22,6 +22,9 @@ function updateView() { $('#descriptionSpan').attr('data-i18n', structure.description); $('title').attr('data-i18n', structure.title); $('#structure').append($component); + if (structure.id === 'worldgen') { + $('#versionLabel').addClass('d-none') + } if (i18next.isInitialized) { $('html').localize(); } @@ -403,14 +406,30 @@ function generateObject(data, struct, options) { } } if (field.collapse) { - let hasNoValue = data[field.id] === undefined; + let hasNoValue = typeof data[field.id] !== 'object'; let arrowDirection = hasNoValue ? 'dropright' : 'dropdown' $body.append(''); if (field.help) { $body.find('span').append(generateTooltip(field.translate)); } if (hasNoValue) { - $body.append('
'); + if (field.values) { + let outValue, $field; + ({out: outValue, component: $field} = generateEnum(data[field.id], field)); + out[field.id] = outValue; + const $selection = $($field.children()[1]); + const $dropdown = $body.children().last(); + $selection.addClass('mt-3'); + $dropdown.addClass('input-group'); + $($dropdown.children()[0]) + .css('border-top-right-radius', '0') + .css('border-bottom-right-radius', '0'); + $selection.attr('data-type', 'enum'); + $selection.attr('data-index', field.id); + $dropdown.append($selection); + } else { + $body.append('
'); + } continue; } } diff --git a/locales/en.json b/locales/en.json index 8e096ddc..37fefcb8 100644 --- a/locales/en.json +++ b/locales/en.json @@ -149,6 +149,16 @@ "dimension.overworld": "Overworld", "dimension.the_end": "The End", "dimension.the_nether": "The Nether", + "dimension.nether": "Nether", + "dimension.end": "End", + "dimension.type": "Dimension Flags", + "dimension.type.ultrawarm": "Ultrawarm", + "dimension.type.natural": "Natural", + "dimension.type.shrunk": "Shrunk", + "dimension.type.ambient_light": "Ambient Light", + "dimension.type.fixed_time": "Fixed Time", + "dimension.type.has_skylight": "Has Skylight", + "dimension.type.has_ceiling": "Has Ceiling", "display": "Display", "display.icon": "Icon", "display.icon.item": "Icon Item", @@ -312,7 +322,15 @@ "generator.type": "Type", "generator.seed": "Dimension Seed", "generator.settings": "Generator Settings", + "generator.settings.bedrock_roof_position": "Bedrock Roof Position", + "generator.settings.bedrock_floor_position": "Bedrock Floor Position", + "generator.settings.sea_level": "Sea Level", + "generator.settings.disable_mob_generation": "Disable Mob Generation", + "generator.settings.default_block": "Default Block", + "generator.settings.default_fluid": "Default Fluid", "help.condition.time_period": "If present, time will be modulo-divided by this value. For example, if set to 24000, value will operate on a time period of days.", + "help.dimension.type.ultrawarm": "If true, water cannot exist and sponges will dry.", + "help.dimension.type.shrunk": "Whether coordinates should be scaled down by a factor of 8.", "help.display": "If present, advancement will be visible in the advancement tabs.", "help.entry.expand": "If false, entry will return all contents of tag, otherwise entry will behave as multiple item entries", "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", diff --git a/schemas/worldgen.json b/schemas/worldgen.json index 766c102a..6617e2b2 100644 --- a/schemas/worldgen.json +++ b/schemas/worldgen.json @@ -101,16 +101,6 @@ "translate": "generator.seed", "type": "int" }, - { - "id": "settings", - "translate": "generator.settings", - "type": "enum", - "values": [ - "minecraft:overworld", - "minecraft:nether", - "minecraft:end" - ] - }, { "id": "biome_source", "type": "object", @@ -136,6 +126,7 @@ { "id": "preset", "translate": "biome_source.preset", + "translateValue": "dimension", "type": "enum", "unset": true, "values": [ @@ -148,6 +139,117 @@ "type": "boolean" } ] + }, + { + "id": "settings", + "translate": "generator.settings", + "translateValue": "dimension", + "type": "object", + "color": "dark", + "collapse": true, + "values": [ + "minecraft:overworld", + "minecraft:nether", + "minecraft:end" + ], + "fields": [ + { + "id": "bedrock_roof_position", + "translate": "generator.settings.bedrock_roof_position", + "type": "int" + }, + { + "id": "bedrock_floor_position", + "translate": "generator.settings.bedrock_floor_position", + "type": "int" + }, + { + "id": "sea_level", + "translate": "generator.settings.sea_level", + "type": "int" + }, + { + "id": "disable_mob_generation", + "translate": "generator.settings.disable_mob_generation", + "type": "boolean" + }, + { + "id": "default_block", + "type": "object", + "card": false, + "fields": [ + { + "id": "Name", + "translate": "generator.settings.default_block", + "type": "string" + } + ] + }, + { + "id": "default_fluid", + "type": "object", + "card": false, + "fields": [ + { + "id": "Name", + "translate": "generator.settings.default_fluid", + "type": "string" + } + ] + } + ] + } + ] + }, + { + "id": "type", + "translate": "dimension.type", + "translateValue": "dimension", + "type": "object", + "color": "dark", + "collapse": true, + "values": [ + "minecraft:overworld", + "minecraft:the_nether", + "minecraft:the_end" + ], + "fields": [ + { + "id": "ultrawarm", + "translate": "dimension.type.ultrawarm", + "type": "boolean", + "help": true + }, + { + "id": "natural", + "translate": "dimension.type.natural", + "type": "boolean" + }, + { + "id": "shrunk", + "translate": "dimension.type.shrunk", + "type": "boolean", + "help": true + }, + { + "id": "ambient_light", + "translate": "dimension.type.ambient_light", + "type": "float" + }, + { + "id": "fixed_time", + "translate": "dimension.type.fixed_time", + "type": "int" + }, + { + "id": "has_skylight", + "translate": "dimension.type.has_skylight", + "type": "boolean" + }, + { + "id": "has_ceiling", + "translate": "dimension.type.has_ceiling", + "type": "boolean" } ] } diff --git a/worldgen/index.html b/worldgen/index.html index be98aaf8..db2d752b 100644 --- a/worldgen/index.html +++ b/worldgen/index.html @@ -18,6 +18,8 @@