Add default dimension type and prevent duplicates

This commit is contained in:
Misode
2020-05-21 14:11:50 +02:00
parent 13f99dd21e
commit 5bbcc86251
3 changed files with 32 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
const themes = ["light", "dark"];
let preventDuplicateDimensionType = [false, false, false, false];
themes.forEach(v => $('#themeList').append(`<a class="dropdown-item" onclick="changeTheme('${v}')" data-i18n="theme.${v}"></a>`));
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) {

View File

@@ -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",

View File

@@ -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",