-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (61 loc) · 2.26 KB
/
Copy pathscript.js
File metadata and controls
68 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$(document).ready(function() {
// Fetch block data from blocks.json
$.getJSON("blocks.json", function(data) {
// Initialize Select2 for the block input
$('.blockInput').select2({
placeholder: 'Select a block...',
minimumInputLength: 0,
width: '480px',
data: data.values.map(function(value) {
return { id: value, text: value };
})
});
});
// Fetch biome data from biomes.json
$.getJSON("biomes.json", function(data) {
// Initialize Select2 for the biome input
$('#biome').select2({
placeholder: 'Select a biome...',
minimumInputLength: 0,
width: '300px',
data: data.values.map(function(value) {
return { id: value, text: value };
})
});
});
});
function addLayer() {
const layerInputsDiv = document.getElementById('layerInputs');
const newLayerInput = document.createElement('div');
newLayerInput.classList.add('layerInput');
newLayerInput.innerHTML = `
<input type="number" class="heightInput" placeholder="Height" min="0" max="4064">
<select class="blockInput" style="width: 200px;">
<option></option>
</select>
<button class="removeLayerButton" onclick="removeLayer(this)">Remove</button>
`;
layerInputsDiv.appendChild(newLayerInput);
}
function removeLayer(button) {
button.parentElement.remove();
}
function generateJSON() {
const layers = [];
document.querySelectorAll('.layerInput').forEach(layerInput => {
const height = parseInt(layerInput.querySelector('.heightInput').value) || 1;
const block = layerInput.querySelector('.blockInput').value || 'minecraft:air';
layers.push({ height, block });
});
const biome = document.getElementById('biome').value || 'plains';
const lakes = document.getElementById('lakes').checked || false;
const features = document.getElementById('features').checked || false;
const config = {
layers,
biome,
lakes,
features
};
const jsonResultDiv = document.getElementById('jsonResult');
jsonResultDiv.innerHTML = '<pre>' + JSON.stringify(config).replace(/\n/g, '') + '</pre>';
}