summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-06-23 23:43:14 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-06-23 23:43:14 +0200
commit0028d1276f042953a4034016815593006d823f6d (patch)
treec3cea08bad6778e24fc3b7de905069f5c35889ff /src
parentfcbea16f2ae86843eb214f64e02a96862e8e3564 (diff)
generate json files programmatically
Diffstat (limited to 'src')
-rw-r--r--src/enum.js16
-rw-r--r--src/worldgen/structure/index.js71
2 files changed, 87 insertions, 0 deletions
diff --git a/src/enum.js b/src/enum.js
new file mode 100644
index 0000000..f6b0dd7
--- /dev/null
+++ b/src/enum.js
@@ -0,0 +1,16 @@
+const TemplatePool = Object.freeze({
+ EMPTY_16: 'vanilla_skyblock:empty_16',
+ EMPTY_FULL: 'vanilla_skyblock:empty_full',
+});
+
+const JigsawStartHeight = Object.freeze({
+ UNIFORM: Symbol('uniform'),
+ BIASED_TO_BOTTOM: Symbol('biased_to_bottom'),
+ VERY_BIASED_TO_BOTTOM: Symbol('very_biased_to_bottom'),
+});
+
+
+module.exports = {
+ TemplatePool,
+ JigsawStartHeight,
+};
diff --git a/src/worldgen/structure/index.js b/src/worldgen/structure/index.js
new file mode 100644
index 0000000..8f19547
--- /dev/null
+++ b/src/worldgen/structure/index.js
@@ -0,0 +1,71 @@
+const { JigsawStartHeight } = require('../../enum.js');
+
+
+const jigsawConversionFields = {
+ type: 'minecraft:jigsaw',
+ start_pool: null,
+ size: 1,
+ start_height: {
+ absolute: {
+ value: 0,
+ },
+ },
+ max_distance_from_center: 1,
+ use_expansion_hack: false,
+};
+
+const jigsawStartHeightUniform = {
+ type: 'minecraft:uniform',
+ min_inclusive: {
+ above_bottom: 0,
+ },
+ max_inclusive: {
+ below_top: 0,
+ },
+};
+
+const jigsawStartHeightBiasedToBottom = {
+ type: 'minecraft:biased_to_bottom',
+ min_inclusive: {
+ above_bottom: 0,
+ },
+ max_inclusive: {
+ below_top: 0,
+ },
+};
+
+const jigsawStartHeightVeryBiasedToBottom = {
+ type: 'minecraft:very_biased_to_bottom',
+ min_inclusive: {
+ above_bottom: 0,
+ },
+ max_inclusive: {
+ below_top: 0,
+ },
+};
+
+
+function jigsawConversion(structure, fields) {
+ fields = Object.assign({
+ ...jigsawConversionFields,
+ }, fields);
+
+ if (fields.start_height === JigsawStartHeight.UNIFORM) {
+ fields.start_height = jigsawStartHeightUniform;
+ }
+ else if (fields.start_height === JigsawStartHeight.BIASED_TO_BOTTOM) {
+ fields.start_height = jigsawStartHeightBiasedToBottom;
+ }
+ else if (fields.start_height === JigsawStartHeight.VERY_BIASED_TO_BOTTOM) {
+ fields.start_height = jigsawStartHeightVeryBiasedToBottom;
+ }
+
+ return Object.assign({}, structure, fields);
+}
+
+
+module.exports = {
+ jigsawConversionFields,
+ jigsawStartHeightUniform,
+ jigsawConversion,
+};