mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 08:40:26 +00:00
Compare commits
571 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd86664e5e | |||
| b9ac23baba | |||
| c620c17ac6 | |||
| c1232298b3 | |||
| 373f6a5fe3 | |||
| fb505fe28b | |||
| 3594beb406 | |||
| 2b142b282f | |||
| f1bda5c907 | |||
| dca8dd4c4f | |||
| 54335bfd70 | |||
| ddbae360c3 | |||
| 9718c99149 | |||
| 32cc38c6b2 | |||
| 965d0681eb | |||
| f137fe2b7a | |||
| 72a4909145 | |||
| 5919d5f031 | |||
| 03241fa412 | |||
| 9eecaf71c8 | |||
| f5c73e926f | |||
| bea45ff030 | |||
| 2263e6722b | |||
| df6cdf37aa | |||
| 6010ea3bd6 | |||
| c8429141c8 | |||
| a15c5f2cca | |||
| 7becdf7f64 | |||
| 76173c1f31 | |||
| 3a47fd5aa9 | |||
| ddf1334f6f | |||
| bda3594025 | |||
| 1dbcb031ea | |||
| b407ca8821 | |||
| 0b0742d850 | |||
| 102828039d | |||
| a21eb2c3ba | |||
| 43874521db | |||
| 7f7dc23b09 | |||
| a2d8a5a259 | |||
| 1c5945706f | |||
| 480e41b99a | |||
| 276c78a329 | |||
| dd0ef7ea45 | |||
| d5fd653130 | |||
| 6da14f58df | |||
| 13ab02984b | |||
| fa8a66833e | |||
| 9d24e8a282 | |||
| 6df5aa112a | |||
| dd0c6b557d | |||
| 1522e6b57d | |||
| cefa4369f2 | |||
| d6b36f4d3f | |||
| 12c068b252 | |||
| 26152ec94e | |||
| 19861ec27b | |||
| fda44b8e99 | |||
| 1624c999ac | |||
| d43eccc442 | |||
| 7a44b74b61 | |||
| 220a981b05 | |||
| 987de074c6 | |||
| e356291bba | |||
| 12d78e0b73 | |||
| bc199d9b06 | |||
| 926e5a8ca9 | |||
| 4ad638983a | |||
| 90e127a512 | |||
| 9d12fe1bf1 | |||
| d09fe9b2a4 | |||
| f00766ea93 | |||
| 122e72e842 | |||
| b3f15b77ee | |||
| ec19c468a2 | |||
| 782a43ca53 | |||
| 8ec438ab15 | |||
| 002b311827 | |||
| 36e6d1270d | |||
| 07c8bfb29e | |||
| 63667f256b | |||
| abfd050acb | |||
| db93c9e2e9 | |||
| 1739c51ce6 | |||
| 9693fa641b | |||
| 167ab3146e | |||
| 5321662847 | |||
| 347e0d2bd1 | |||
| ca02187b0c | |||
| 649273db01 | |||
| fb3f90a9cd | |||
| 7430116fa9 | |||
| c8bb780312 | |||
| b25be7ae98 | |||
| 4567011313 | |||
| a24de0ab97 | |||
| f76ef93fe6 | |||
| c64266febb | |||
| 6da8c72593 | |||
| c13494ca03 | |||
| 19d4673afe | |||
| 7f09ee4af3 | |||
| f73366fcb3 | |||
| 074528003b | |||
| 22aa03cd51 | |||
| cb876d12f9 | |||
| 41d3e2f6b0 | |||
| 5cafd4999a | |||
| 4ec1ab7c16 | |||
| b19b85fd60 | |||
| 68f82fef02 | |||
| af4af84a48 | |||
| e882be2ba4 | |||
| 34868680c1 | |||
| 5bd70da0bc | |||
| e8ee7bc64f | |||
| 7f3a7645bd | |||
| 2790373071 | |||
| 8751346693 | |||
| f987ffa6d0 | |||
| d83e6f09a7 | |||
| 7b70478a7f | |||
| 363b70c1a6 | |||
| a3a4cf8251 | |||
| 47c284656b | |||
| 1ae9ae71de | |||
| 3b5e6b80d5 | |||
| fb26b02ad1 | |||
| 67d3af71bf | |||
| 672349f5b7 | |||
| aecb7201b8 | |||
| cdd7abc596 | |||
| 4c7179cfa2 | |||
| fb6f591f0b | |||
| 6cd60d3f4f | |||
| 507ea8bc88 | |||
| bbcd571156 | |||
| 321c50c417 | |||
| fe18d89580 | |||
| a15e45875e | |||
| bcc6e314eb | |||
| 789d5d1e23 | |||
| 9d540d471d | |||
| e16208bd76 | |||
| 579195481b | |||
| f297636c61 | |||
| 2fdada2121 | |||
| 1613ea843d | |||
| 169ed64568 | |||
| 9d687208c9 | |||
| 6d0a32f251 | |||
| 7d70b8fcdf | |||
| 89b03aa3fb | |||
| 696ee07c33 | |||
| 55030450b5 | |||
| be9e817c88 | |||
| 2f9387fbf0 | |||
| 4da5ce748d | |||
| f659c32749 | |||
| cdcbd28aa0 | |||
| 8ae457b251 | |||
| 9bf7b373b1 | |||
| b3f92410e0 | |||
| 6ea11de2fd | |||
| ad9cc1afcb | |||
| ec14666c6d | |||
| 2517b74951 | |||
| fe68aa6279 | |||
| a753351137 | |||
| 2e2f9d854d | |||
| 76b6c0a984 | |||
| 1f9a51fc40 | |||
| 1039bf6001 | |||
| 109b5e38cd | |||
| ea60b30321 | |||
| 8898bbd5c4 | |||
| a56d1818c8 | |||
| 7f050b37a4 | |||
| 2948f25b50 | |||
| a91a5019f8 | |||
| 82169f0921 | |||
| 9359ba0c97 | |||
| ba53923e8c | |||
| deb1063592 | |||
| 2ea16f68a2 | |||
| 2175ea849f | |||
| b630ab6531 | |||
| 8eddffb0a6 | |||
| 953318d9c0 | |||
| 6f1938ef82 | |||
| 1d6d63b399 | |||
| d8a5951f6e | |||
| 185df6e8a4 | |||
| 315da531b7 | |||
| ec26e7b1b0 | |||
| 7363a305af | |||
| bff0106e65 | |||
| 089eac9dc5 | |||
| a0a15802e4 | |||
| dce3742fcb | |||
| 502d2b5814 | |||
| 36ce88af0a | |||
| 3f42b9ab3e | |||
| facd878788 | |||
| 9713a7a7ba | |||
| a030fb93f3 | |||
| 67c45b7be3 | |||
| af1520eb83 | |||
| 7932a97985 | |||
| 5c92316725 | |||
| a28f46eca3 | |||
| 36838d8938 | |||
| 662196c7a6 | |||
| d8bbc95c1e | |||
| 57658d2268 | |||
| 73fd1c9edd | |||
| d054be5f25 | |||
| 5a85099357 | |||
| f7a5066008 | |||
| 5a8f5aa29c | |||
| d0434ef05e | |||
| 5c3cd73c03 | |||
| 6f03cfa600 | |||
| 4c4df28adb | |||
| de4376dd9c | |||
| f27e732b39 | |||
| 90e60ca6aa | |||
| 2373174132 | |||
| 6158cda740 | |||
| 6285b7646b | |||
| 299bf0dae8 | |||
| fe60e12f16 | |||
| c71445d3e5 | |||
| feea26dea7 | |||
| 12540f3a2c | |||
| a6324ae6e2 | |||
| e63d675549 | |||
| 1349d5b00e | |||
| 6be4c0b7c6 | |||
| 7b9a473275 | |||
| 137206884c | |||
| 5ea08eb898 | |||
| d6e2acce38 | |||
| 7b1853823c | |||
| c8bb9bbfeb | |||
| 3a7edcb1e4 | |||
| 0ff6a9cce1 | |||
| d807abb165 | |||
| c1dfcafa1d | |||
| 7a554a1fdb | |||
| 7fef7125fe | |||
| 4c25a8f909 | |||
| a8d4354851 | |||
| f9a199f177 | |||
| 04d78c1e32 | |||
| 4dc04131f4 | |||
| e7af30350b | |||
| 165642806c | |||
| 9673ab8ce1 | |||
| 24a4ff4044 | |||
| d997fc69bf | |||
| 03e4636ef9 | |||
| 458fc422de | |||
| 04bdd0b4a3 | |||
| 785323f3f6 | |||
| d036ed289c | |||
| 96b52f9a3e | |||
| f0441cbefc | |||
| 6f40e7b1f5 | |||
| 3bf8fe7901 | |||
| 7acfc5e3d0 | |||
| 913e7fd6df | |||
| a70641e01b | |||
| ac99d89e96 | |||
| fc63798103 | |||
| 1a3a7df3f7 | |||
| 46f64b5434 | |||
| 4447005b43 | |||
| 15f749bfe9 | |||
| 11f161d546 | |||
| 04e998748d | |||
| 40cd6607b2 | |||
| 4b4c26eb84 | |||
| d5601229ac | |||
| ebc81b196a | |||
| d10e2050cb | |||
| cd208cbd18 | |||
| d4e678fd65 | |||
| 03b96816c9 | |||
| d3a080127a | |||
| 3fecbe5d1d | |||
| 4a893cf081 | |||
| a2dac6dfca | |||
| bc96006c4b | |||
| d4112e46c7 | |||
| ec28f613d3 | |||
| 3a94c5287c | |||
| 689fe0bc70 | |||
| 84e7d11156 | |||
| 1194cca485 | |||
| ced5a05370 | |||
| 6cff6db152 | |||
| be55f4a62d | |||
| f57c5f39b9 | |||
| 180aae6e34 | |||
| 0f638b0317 | |||
| 6b191ac00b | |||
| b52dcf2f15 | |||
| 62cf861c22 | |||
| fec5b138d2 | |||
| f4f595425a | |||
| fc2ce229ed | |||
| 3c4c8c62b2 | |||
| deedfb1f8d | |||
| 3261e7451f | |||
| 98a0c9e052 | |||
| 453e1ebb87 | |||
| c65ea812ed | |||
| c26418b5ba | |||
| b626b74624 | |||
| ff329b2d18 | |||
| 6f5cca5e4e | |||
| 1e5a0bb93f | |||
| 78735ec769 | |||
| 887b17a421 | |||
| d43f226f2d | |||
| 53b5ee2ca9 | |||
| 3ec536dc03 | |||
| 2f5751cda7 | |||
| f0e3b1aa1d | |||
| 72f0b07a38 | |||
| 810340dbfb | |||
| f4820e5a06 | |||
| 55733b0e28 | |||
| 5bae639923 | |||
| a673f961b3 | |||
| a66641cb8a | |||
| b1589ed046 | |||
| 60edef989c | |||
| 646d8970aa | |||
| 2e6b62d690 | |||
| 0bd6ff9469 | |||
| 9e7bab340e | |||
| 2cd71cdcd3 | |||
| 319df9e638 | |||
| 9d2ae0a828 | |||
| d94ddb3e76 | |||
| cb4b537a2f | |||
| 2705e7d6a2 | |||
| b3594b2479 | |||
| 8cd2554d3a | |||
| 95e6479505 | |||
| 34e78ab55e | |||
| 089af42623 | |||
| 7a38284158 | |||
| 7fa2e8251e | |||
| bac5557873 | |||
| 2745bb8ba3 | |||
| 26d91a715c | |||
| 19672b1083 | |||
| c21038a21e | |||
| d2aa7cf5d5 | |||
| f12d23b4cb | |||
| 0dfde174ad | |||
| 27d9716c5d | |||
| 589158ee71 | |||
| dea68d0ede | |||
| 61d03a7022 | |||
| 3be90cab53 | |||
| cf88c51fda | |||
| 6f7b7a2336 | |||
| cfaa2f33ae | |||
| 9b6247dcb8 | |||
| 113568da9b | |||
| 52295af5a7 | |||
| 43f77f1531 | |||
| 0ba02719c0 | |||
| 9664e003c6 | |||
| 519956dc11 | |||
| d09ef5052a | |||
| 3f539b1e30 | |||
| 3dc564c0f7 | |||
| f61883547e | |||
| f8b0f03d11 | |||
| d0c9145aad | |||
| b36955a10a | |||
| 40e28c5e4b | |||
| b609a0ba63 | |||
| 8dcd50d3fb | |||
| 719ea83bcd | |||
| 6ca9ba029b | |||
| e1abc67989 | |||
| 6a1cc16dc3 | |||
| 1ac903cf91 | |||
| 2f55206cf0 | |||
| 43395fef08 | |||
| 99d64fec36 | |||
| 66a5cce399 | |||
| 88dfb299a5 | |||
| 25073199f0 | |||
| 5c4ef3f23b | |||
| 9c3b6ea8bd | |||
| 7ca0be40dd | |||
| da26a1c54e | |||
| 01351883d1 | |||
| 4acfeab948 | |||
| 04725698e8 | |||
| 52a269b686 | |||
| 39f5aef0c5 | |||
| b8e1e99b84 | |||
| fe28fcedd1 | |||
| 27a54101e7 | |||
| 7f1963a367 | |||
| 6f8a7d6364 | |||
| 9221a4f1ae | |||
| d4a784ddb5 | |||
| 888e9e8def | |||
| a89b250765 | |||
| e7a2758722 | |||
| d2298240ed | |||
| dea12d3056 | |||
| b4f464c428 | |||
| 7fcce19897 | |||
| 58a5160d53 | |||
| 9f37285c9a | |||
| 8213d23d72 | |||
| fb63e38862 | |||
| d4d1a4434e | |||
| d8eeeded60 | |||
| 1a50060ff0 | |||
| 0441837b19 | |||
| 7c30437031 | |||
| 3da777459e | |||
| 32b0cd0b26 | |||
| 1ad08a599d | |||
| 1777dc1aca | |||
| 3ea6724e6c | |||
| 25339ca4ef | |||
| 3364a75cec | |||
| 19d482f249 | |||
| 2b2aa493b1 | |||
| 54f4722297 | |||
| e9dc7d3db6 | |||
| 5c66dd4f17 | |||
| 46c6113020 | |||
| bff7e44984 | |||
| 7834509390 | |||
| 8ff022cbc8 | |||
| 6755054c97 | |||
| 62520af8e7 | |||
| 215a1e0e86 | |||
| 8a000137a2 | |||
| f4873f7569 | |||
| 445bf3d053 | |||
| bf5e8d903c | |||
| abd3683a49 | |||
| 22c97ca390 | |||
| 9880f488e5 | |||
| 7cd60d6d4e | |||
| ca3a9180be | |||
| bce7a181bd | |||
| 43307b737c | |||
| 4ecb08619f | |||
| edb5e316ba | |||
| a3cbf9a945 | |||
| 002c7037f1 | |||
| 3386570439 | |||
| d880d95637 | |||
| 966e1eb2a6 | |||
| 56029851f0 | |||
| 4306b179bb | |||
| cbb746c752 | |||
| da0fb7dd15 | |||
| ff4cbda294 | |||
| 9fa660409d | |||
| dc1f1a0339 | |||
| ab9f98994d | |||
| 03ecf6197a | |||
| 0acff143fb | |||
| c4de7e578a | |||
| 18d071128d | |||
| 255e4396dd | |||
| c26f4dfc2f | |||
| 9838a4ce0b | |||
| cf30f3d067 | |||
| 4bac67b8d7 | |||
| c0b55c3e4e | |||
| f69fdbe37e | |||
| 918ff28ed4 | |||
| 2906a4f891 | |||
| d4d2b659dc | |||
| 89657e362a | |||
| 9631b1b578 | |||
| f380247613 | |||
| 686680d731 | |||
| e34e2dd0b2 | |||
| 24b8fc859c | |||
| 506f59f8af | |||
| fa0bd103f3 | |||
| a5f879ae7a | |||
| bb888380aa | |||
| 7495a6b4a1 | |||
| cf214cc274 | |||
| 10f633be9a | |||
| 43aa3fc086 | |||
| efd1665c1d | |||
| 40e950732b | |||
| b15ec9a215 | |||
| 2316043c1e | |||
| ec20387aea | |||
| 85e4c0eca1 | |||
| fa01c47f43 | |||
| b85880fc92 | |||
| d5dc37629e | |||
| b3e2685564 | |||
| b948202ef2 | |||
| 9ba544bf71 | |||
| 82dfe652e0 | |||
| 392ad207d9 | |||
| 01e47b0bab | |||
| c7cbf11631 | |||
| afdb4fbfa2 | |||
| ef8a5b1453 | |||
| 1f56673c77 | |||
| 0ad0355250 | |||
| 8d3b3c7024 | |||
| b63ea99167 | |||
| 444324e7c6 | |||
| 4908c7bb73 | |||
| 62b60fcdb3 | |||
| 9b52277d9a | |||
| 1209842bcd | |||
| 596ac1c389 | |||
| 9551a1e875 | |||
| 77bb04e91f | |||
| 97aa9d9a91 | |||
| 526049523f | |||
| f7ea81cb51 | |||
| 9ea8dc7eee | |||
| df2c654192 | |||
| 5542dee7b7 | |||
| 5397df57b8 | |||
| aa0de88821 | |||
| bd3136ca92 | |||
| 339413c0de | |||
| 31b55ca682 | |||
| aaf0830d66 | |||
| f78ee70609 | |||
| 9c1a35f444 | |||
| f4716cb28f | |||
| b3e3c28276 | |||
| 4eadbb7d83 | |||
| 7b3b341627 | |||
| 89267ce8cb | |||
| 78e3575d9b | |||
| e671ef783f | |||
| 91144dc8f8 | |||
| 4202875675 | |||
| 4237657dad | |||
| 75cb6be36f | |||
| 88a7397bbe | |||
| a6a1810b4a | |||
| da4aebe498 | |||
| 03ebafc7b6 | |||
| a78e64a9bb | |||
| 6374b0ab08 | |||
| 473ed45dee | |||
| d96d834a08 | |||
| f756ebef44 | |||
| e6931a53d6 | |||
| 58b5f3a5fe |
+5
-5
@@ -105,7 +105,7 @@ ij_java_for_statement_wrap = off
|
||||
ij_java_generate_final_locals = false
|
||||
ij_java_generate_final_parameters = false
|
||||
ij_java_if_brace_force = never
|
||||
ij_java_imports_layout = *,|,javax.**,java.**,|,$*
|
||||
ij_java_imports_layout = *, |, javax.**, java.**, |, $*
|
||||
ij_java_indent_case_from_switch = true
|
||||
ij_java_insert_inner_class_imports = false
|
||||
ij_java_insert_override_annotation = true
|
||||
@@ -137,7 +137,7 @@ ij_java_method_parameters_wrap = off
|
||||
ij_java_modifier_list_wrap = false
|
||||
ij_java_names_count_to_use_import_on_demand = 3
|
||||
ij_java_new_line_after_lparen_in_record_header = false
|
||||
ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.*
|
||||
ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.*
|
||||
ij_java_parameter_annotation_wrap = off
|
||||
ij_java_parentheses_expression_new_line_after_left_paren = false
|
||||
ij_java_parentheses_expression_right_paren_on_new_line = false
|
||||
@@ -246,7 +246,7 @@ ij_java_wrap_comments = false
|
||||
ij_java_wrap_first_method_in_call_chain = false
|
||||
ij_java_wrap_long_lines = false
|
||||
|
||||
[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
|
||||
[{*.gradle.kts, *.kt, *.kts, *.main.kts}]
|
||||
ij_kotlin_align_in_columns_case_branch = false
|
||||
ij_kotlin_align_multiline_binary_operation = false
|
||||
ij_kotlin_align_multiline_extends_list = false
|
||||
@@ -325,7 +325,7 @@ ij_kotlin_wrap_elvis_expressions = 1
|
||||
ij_kotlin_wrap_expression_body_functions = 0
|
||||
ij_kotlin_wrap_first_method_in_call_chain = false
|
||||
|
||||
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}]
|
||||
[{*.har, *.jsb2, *.jsb3, *.json, .babelrc, .eslintrc, .stylelintrc, bowerrc, jest.config}]
|
||||
indent_size = 2
|
||||
ij_json_keep_blank_lines_in_code = 0
|
||||
ij_json_keep_indents_on_empty_lines = false
|
||||
@@ -338,7 +338,7 @@ ij_json_spaces_within_braces = false
|
||||
ij_json_spaces_within_brackets = false
|
||||
ij_json_wrap_long_lines = false
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
[{*.yaml, *.yml}]
|
||||
indent_size = 2
|
||||
ij_yaml_keep_indents_on_empty_lines = true
|
||||
ij_yaml_keep_line_breaks = true
|
||||
|
||||
@@ -8,4 +8,5 @@ assignees: ""
|
||||
---
|
||||
|
||||
## Describe the issue
|
||||
|
||||
<!-- Please describe the issue as clearly and as concisely as possible, without missing any details. -->
|
||||
@@ -1,11 +1,11 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Which Issue Template do I Choose?
|
||||
url: https://github.com/PolyhedralDev/Terra/wiki/How-To-Choose-An-Issue-Template
|
||||
- name: Which Issue Template do I Choose?
|
||||
url: https://github.com/PolyhedralDev/Terra/wiki/How-To-Choose-An-Issue-Template
|
||||
about: Click this if you don't know which issue template to select. This will help you make sure you choose the right one and provide enough information for us to help you.
|
||||
- name: Terra Wiki
|
||||
url: https://github.com/PolyhedralDev/Terra/wiki
|
||||
- name: Terra Wiki
|
||||
url: https://github.com/PolyhedralDev/Terra/wiki
|
||||
about: Documentation for all things Terra.
|
||||
- name: Join the Support Discord
|
||||
url: https://discord.dfsek.com
|
||||
- name: Join the Support Discord
|
||||
url: https://discord.dfsek.com
|
||||
about: If you have a basic support question, join the Discord instead.
|
||||
@@ -1,40 +0,0 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Build Terra
|
||||
run: gradle shadowJar
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Package
|
||||
path: build/libs
|
||||
|
||||
- name: Publish release
|
||||
uses: marvinpinto/action-automatic-releases@latest
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
prerelease: false
|
||||
files: |
|
||||
build/libs/Terra-*.jar
|
||||
LICENSE
|
||||
|
||||
@@ -7,40 +7,47 @@ to your specifications, with no knowledge of Java required.
|
||||
|
||||
* Paper+ servers (Paper, Tuinity, Purpur, etc): [SpigotMC](https://www.spigotmc.org/resources/85151/)
|
||||
* Fabric: [Modrinth](https://modrinth.com/mod/terra) / [CurseForge](https://www.curseforge.com/minecraft/mc-mods/terra-world-generator)
|
||||
* Forge **(ALPHA - NOT PRODUCTION-READY)**: [Modrinth](https://modrinth.com/mod/terra) / [CurseForge](https://www.curseforge.com/minecraft/mc-mods/terra-world-generator)
|
||||
* Forge **(ALPHA - NOT PRODUCTION-READY)**: [Modrinth](https://modrinth.com/mod/terra)
|
||||
/ [CurseForge](https://www.curseforge.com/minecraft/mc-mods/terra-world-generator)
|
||||
|
||||
## Building and Running Terra
|
||||
|
||||
To build, simply run `./gradlew build` (`gradlew.bat build` on Windows). This will build all platforms, and
|
||||
produce JARs in `platforms/<platform>/build/libs`
|
||||
To build, simply run `./gradlew build` (`gradlew.bat build` on Windows). This will build all platforms, and produce JARs
|
||||
in `platforms/<platform>/build/libs`
|
||||
|
||||
### Production JARs:
|
||||
|
||||
* Bukkit: `Terra-<version>-shaded.jar`
|
||||
* Fabric: `Terra-<version>-shaded-mapped.jar`
|
||||
* Forge: `Terra-<version>-shaded.jar`
|
||||
|
||||
### Building a Specific Platform
|
||||
|
||||
To build a specific platform, run `gradlew :platforms:<platform>:build`.
|
||||
|
||||
JARs are produced in `platforms/<platform>/build/libs`.
|
||||
|
||||
### Running Minecraft in the IDE
|
||||
|
||||
To run Minecraft with Terra in the IDE (for testing) use the following tasks:
|
||||
|
||||
* Bukkit
|
||||
* `installPaper` - Install a [Paper](https://github.com/PaperMC/Paper) test server. (Only needs to be run once).
|
||||
* `installPurpur` - Install a [Purpur](https://github.com/pl3xgaming/Purpur) test server. (Only needs to be run once).
|
||||
* `runPaper` - Run the Paper test server with Terra (`installPaper` must have been run previously).
|
||||
* `runPurpur` - Run the Purpur test server with Terra (`installPurpur` must have been run previously).
|
||||
* `installPaper` - Install a [Paper](https://github.com/PaperMC/Paper) test server. (Only needs to be run once).
|
||||
* `installPurpur` - Install a [Purpur](https://github.com/pl3xgaming/Purpur) test server. (Only needs to be run once).
|
||||
* `runPaper` - Run the Paper test server with Terra (`installPaper` must have been run previously).
|
||||
* `runPurpur` - Run the Purpur test server with Terra (`installPurpur` must have been run previously).
|
||||
* Fabric
|
||||
* `runClient` - Run a Minecraft Fabric client with Terra installed.
|
||||
* `runServer` - Run a Minecraft Fabric server with Terra installed.
|
||||
* `runClient` - Run a Minecraft Fabric client with Terra installed.
|
||||
* `runServer` - Run a Minecraft Fabric server with Terra installed.
|
||||
* Forge
|
||||
* `runClient` - Run a Minecraft Forge client with Terra installed.
|
||||
* `runServer` - Run a Minecraft Forge server with Terra installed.
|
||||
* `runClient` - Run a Minecraft Forge client with Terra installed.
|
||||
* `runServer` - Run a Minecraft Forge server with Terra installed.
|
||||
|
||||
## Contributing
|
||||
Contributions are welcome! If you want to see a feature in Terra, please, open an issue, or implement it yourself and
|
||||
submit a PR!
|
||||
|
||||
Contributions are welcome! If you want to see a feature in Terra, please, open an issue, or implement it yourself and submit a PR!
|
||||
Join the discord [here](https://discord.gg/PXUEbbF) if you would like to talk more about the project!
|
||||
|
||||
## Beta
|
||||
|
||||
Terra is still in beta! While it is stable, it is not feature-complete. There is a lot to be added!
|
||||
|
||||
+16
-5
@@ -1,15 +1,20 @@
|
||||
import com.dfsek.terra.getGitHash
|
||||
import com.dfsek.terra.*
|
||||
|
||||
val versionObj = Version("5", "3", "3", true)
|
||||
val versionObj = Version("6", "0", "0", true)
|
||||
|
||||
allprojects {
|
||||
version = versionObj
|
||||
group = "com.dfsek.terra"
|
||||
|
||||
configureDependencies()
|
||||
configureCompilation()
|
||||
configurePublishing()
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
options.isIncremental = true
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -18,11 +23,17 @@ allprojects {
|
||||
failFast = true
|
||||
maxParallelForks = (Runtime.getRuntime().availableProcessors() - 1).takeIf { it > 0 } ?: 1
|
||||
|
||||
reports.html.isEnabled = false
|
||||
reports.junitXml.isEnabled = false
|
||||
reports.html.required.set(false)
|
||||
reports.junitXml.required.set(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
project(":platforms").subprojects.forEach { // Platform projects are where distribution happens
|
||||
it.configureDistribution()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version class that does version stuff.
|
||||
*/
|
||||
|
||||
@@ -10,4 +10,5 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
"implementation"("com.github.jengelman.gradle.plugins:shadow:+")
|
||||
"implementation"("org.yaml:snakeyaml:1.27")
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import java.io.File
|
||||
import java.util.function.Predicate
|
||||
import kotlin.streams.asStream
|
||||
|
||||
|
||||
/**
|
||||
* Configures a directory where addons will be put.
|
||||
*/
|
||||
fun Project.addonDir(dir: File, task: Task) {
|
||||
task.doFirst {
|
||||
dir.parentFile.mkdirs()
|
||||
matchingAddons(dir) {
|
||||
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
|
||||
}.forEach {
|
||||
println("Deleting old addon: " + it.absolutePath)
|
||||
it.delete()
|
||||
}
|
||||
project(":common:addons").subprojects.forEach { addonProject ->
|
||||
val jar = (addonProject.tasks.named("jar").get() as Jar)
|
||||
|
||||
val target = File(dir, jar.archiveFileName.get())
|
||||
|
||||
val base = "${jar.archiveBaseName.get()}-${project.version}"
|
||||
|
||||
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
||||
|
||||
jar.archiveFile.orNull?.asFile?.copyTo(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {
|
||||
val matching = HashSet<File>()
|
||||
dir.walk().maxDepth(1).asStream().filter(matcher).forEach(matching::add)
|
||||
return matching
|
||||
}
|
||||
@@ -1,19 +1,8 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun Project.configureCommon() {
|
||||
configureDependencies()
|
||||
configureCompilation()
|
||||
configureDistribution()
|
||||
|
||||
version = rootProject.version
|
||||
}
|
||||
|
||||
fun Project.getGitHash(): String {
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
@@ -11,9 +11,11 @@ import org.gradle.language.jvm.tasks.ProcessResources
|
||||
|
||||
fun Project.configureCompilation() {
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "idea")
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
configure<JavaPluginExtension> {
|
||||
sourceCompatibility = JavaVersion.VERSION_16
|
||||
targetCompatibility = JavaVersion.VERSION_16
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
fun Project.configureDependencies() {
|
||||
apply(plugin = "java")
|
||||
@@ -26,13 +23,22 @@ fun Project.configureDependencies() {
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://maven.fabricmc.net/") }
|
||||
gradlePluginPortal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
"api"("org.jetbrains:annotations:20.1.0")
|
||||
"compileOnly"("org.jetbrains:annotations:20.1.0")
|
||||
|
||||
"compileOnly"("com.google.guava:guava:30.0-jre")
|
||||
"testImplementation"("com.google.guava:guava:30.0-jre")
|
||||
}
|
||||
|
||||
if (project(":common:addons").subprojects.contains(this)) { // If this is an addon project, depend on the API.
|
||||
dependencies {
|
||||
"compileOnly"(project(":common:api"))
|
||||
"testImplementation"(project(":common:api"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,23 @@ package com.dfsek.terra
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.BasePluginConvention
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.api.plugins.BasePluginExtension
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.yaml.snakeyaml.DumperOptions
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.FileWriter
|
||||
import java.net.URL
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
fun Project.configureDistribution() {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
||||
@@ -25,7 +33,85 @@ fun Project.configureDistribution() {
|
||||
downloadPack(netherPackUrl, project)
|
||||
}
|
||||
}
|
||||
tasks["processResources"].dependsOn(downloadDefaultPacks)
|
||||
|
||||
val installAddons = tasks.create("installAddons") {
|
||||
group = "terra"
|
||||
project(":common:addons").subprojects.forEach {
|
||||
it.afterEvaluate {
|
||||
dependsOn(it.tasks.getByName("build")) // Depend on addon JARs
|
||||
}
|
||||
}
|
||||
|
||||
doFirst {
|
||||
// The addons are copied into a JAR because of a ShadowJar bug
|
||||
// which expands *all* JARs, even resource ones, into the fat JAR.
|
||||
// To get around this, we copy all addon JARs into a *new* JAR,
|
||||
// then, ShadowJar expands the newly created JAR, putting the original
|
||||
// JARs where they should go.
|
||||
//
|
||||
// https://github.com/johnrengelman/shadow/issues/111
|
||||
val dest = File(buildDir, "/resources/main/addons.jar")
|
||||
dest.parentFile.mkdirs()
|
||||
|
||||
val zip = ZipOutputStream(FileOutputStream(dest))
|
||||
|
||||
project(":common:addons").subprojects.forEach { addonProject ->
|
||||
val jar = (addonProject.tasks.named("jar").get() as Jar)
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}.")
|
||||
|
||||
val entry = ZipEntry("addons/${jar.archiveFileName.get()}")
|
||||
zip.putNextEntry(entry)
|
||||
FileInputStream(jar.archiveFile.get().asFile).copyTo(zip)
|
||||
zip.closeEntry()
|
||||
}
|
||||
zip.close()
|
||||
}
|
||||
}
|
||||
|
||||
val generateResourceManifest = tasks.create("generateResourceManifest") {
|
||||
group = "terra"
|
||||
dependsOn(downloadDefaultPacks)
|
||||
dependsOn(installAddons)
|
||||
doFirst {
|
||||
val resources = HashMap<String, MutableList<String>>()
|
||||
val packsDir = File("${project.buildDir}/resources/main/packs/")
|
||||
|
||||
packsDir.walkTopDown().forEach {
|
||||
if (it.isDirectory || !it.name.endsWith(".zip")) return@forEach
|
||||
resources.computeIfAbsent("packs") { ArrayList() }.add(it.name)
|
||||
}
|
||||
|
||||
val langDir = File("${project(":common:implementation").buildDir}/resources/main/lang/")
|
||||
|
||||
langDir.walkTopDown().forEach {
|
||||
if (it.isDirectory || !it.name.endsWith(".yml")) return@forEach
|
||||
resources.computeIfAbsent("lang") { ArrayList() }.add(it.name)
|
||||
}
|
||||
|
||||
project(":common:addons").subprojects.forEach { addonProject ->
|
||||
val jar = (addonProject.tasks.named("jar").get() as Jar).archiveFileName.get()
|
||||
resources.computeIfAbsent("addons") { ArrayList() }.add(jar)
|
||||
}
|
||||
|
||||
val options = DumperOptions()
|
||||
options.indent = 2
|
||||
options.indentWithIndicator = true
|
||||
options.indicatorIndent = 2
|
||||
options.isPrettyFlow = true
|
||||
options.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
|
||||
options.defaultScalarStyle = DumperOptions.ScalarStyle.DOUBLE_QUOTED
|
||||
|
||||
val yaml = Yaml(options)
|
||||
|
||||
val manifest = File("${project.buildDir}/resources/main/resources.yml")
|
||||
|
||||
if (manifest.exists()) manifest.delete()
|
||||
manifest.createNewFile()
|
||||
yaml.dump(resources, FileWriter(manifest))
|
||||
}
|
||||
}
|
||||
|
||||
tasks["processResources"].dependsOn(generateResourceManifest)
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
// Tell shadow to download the packs
|
||||
@@ -36,17 +122,14 @@ fun Project.configureDistribution() {
|
||||
archiveClassifier.set("shaded")
|
||||
setVersion(project.version)
|
||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
|
||||
relocate("com.google.errorprone", "com.dfsek.terra.lib.google.errorprone")
|
||||
relocate("com.google.j2objc", "com.dfsek.terra.lib.google.j2objc")
|
||||
relocate("org.checkerframework", "com.dfsek.terra.lib.checkerframework")
|
||||
relocate("org.javax.annotation", "com.dfsek.terra.lib.javax.annotation")
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
|
||||
minimize()
|
||||
}
|
||||
convention.getPlugin<BasePluginConvention>().archivesBaseName = project.name
|
||||
|
||||
configure<BasePluginExtension> {
|
||||
archivesName.set(project.name)
|
||||
}
|
||||
|
||||
tasks.named<DefaultTask>("build") {
|
||||
dependsOn(tasks["shadowJar"])
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
fun Project.configurePublishing() {
|
||||
configure<PublishingExtension> {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks["sourcesJar"])
|
||||
artifact(tasks["jar"])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
|
||||
//val mavenSnapshotUrl = "https://repo.codemc.io/repository/maven-snapshots/"
|
||||
|
||||
maven(mavenUrl) {
|
||||
val mavenUsername: String? by project
|
||||
val mavenPassword: String? by project
|
||||
if (mavenUsername != null && mavenPassword != null) {
|
||||
credentials {
|
||||
username = mavenUsername
|
||||
password = mavenPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Core Addons
|
||||
|
||||
This directory contains the modularized "core addons" that implement Terra's default behavior.
|
||||
@@ -0,0 +1,8 @@
|
||||
# api-features
|
||||
Contains the API for feature generation.
|
||||
|
||||
This API implemented in:
|
||||
* `config-feature`
|
||||
* `generation-stage-feature`
|
||||
* `config-locators`
|
||||
* `config-distributors`
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies {
|
||||
"shadedApi"("commons-io:commons-io:2.6")
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Function<T> extends Returnable<T> {
|
||||
Function<?> NULL = new Function<Object>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
+3
-4
@@ -1,8 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.parser.lang.functions;
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.exception.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.structures.tokenizer;
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
public class Position {
|
||||
private final int line;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public interface StructureScript extends Structure {
|
||||
@SuppressWarnings("try")
|
||||
boolean test(Vector3 location, World world, Random random, Rotation rotation);
|
||||
}
|
||||
+13
-6
@@ -1,22 +1,25 @@
|
||||
package com.dfsek.terra.api.structures.script;
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.structure.Rotation;
|
||||
import com.dfsek.terra.api.structures.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TerraImplementationArguments implements ImplementationArguments {
|
||||
public class TerraProperties implements Properties {
|
||||
private final Buffer buffer;
|
||||
private final Rotation rotation;
|
||||
private final Random random;
|
||||
private final World world;
|
||||
private final int recursions;
|
||||
private boolean waterlog = false;
|
||||
|
||||
public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, int recursions) {
|
||||
public TerraProperties(Buffer buffer, Rotation rotation, Random random, World world, int recursions) {
|
||||
this.buffer = buffer;
|
||||
this.rotation = rotation;
|
||||
this.random = random;
|
||||
this.world = world;
|
||||
this.recursions = recursions;
|
||||
}
|
||||
|
||||
@@ -43,4 +46,8 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
public void setWaterlog(boolean waterlog) {
|
||||
this.waterlog = waterlog;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
|
||||
@Addon("api-terrascript")
|
||||
@Version("1.0.0")
|
||||
@Author("Terra")
|
||||
public class TerraScriptAPIAddon extends TerraAddon {
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Cell implements BufferedItem {
|
||||
private final List<BufferedItem> items = new ArrayList<>();
|
||||
private String mark = null;
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
items.forEach(item -> item.paste(origin.clone(), world));
|
||||
}
|
||||
|
||||
public void add(BufferedItem item) {
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
public String getMark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
public void setMark(String mark) {
|
||||
this.mark = mark;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Buffer implementation that directly pastes to the world.
|
||||
*/
|
||||
public class DirectBuffer implements Buffer {
|
||||
private final Vector3 origin;
|
||||
private final World target;
|
||||
private final Map<Vector3, String> marks = new LinkedHashMap<>();
|
||||
|
||||
public DirectBuffer(Vector3 origin, World target) {
|
||||
this.origin = origin;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, Chunk chunk) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||
item.paste(origin.clone().add(location), target);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Vector3 location) {
|
||||
return marks.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Vector3 location) {
|
||||
marks.put(location, mark);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class IntermediateBuffer implements Buffer {
|
||||
private final Buffer original;
|
||||
private final Vector3 offset;
|
||||
|
||||
public IntermediateBuffer(Buffer original, Vector3 offset) {
|
||||
this.original = original;
|
||||
this.offset = offset.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, Chunk chunk) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||
return original.addItem(item, location.clone().add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getOrigin() {
|
||||
return original.getOrigin().clone().add(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Vector3 location) {
|
||||
return original.getMark(location.clone().add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Vector3 location) {
|
||||
original.setMark(mark, location.clone().add(offset));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StructureBuffer implements Buffer {
|
||||
private final Map<Vector3, Cell> bufferedItemMap = new LinkedHashMap<>();
|
||||
private final Vector3 origin;
|
||||
private boolean succeeded;
|
||||
|
||||
public StructureBuffer(Vector3 origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public void paste(Vector3 origin, World world) {
|
||||
bufferedItemMap.forEach(((vector3, item) -> item.paste(origin.clone().add(vector3), world)));
|
||||
}
|
||||
|
||||
public void paste(Vector3 origin, Chunk chunk) {
|
||||
bufferedItemMap.forEach(((location, item) -> {
|
||||
Vector3 current = origin.clone().add(location);
|
||||
if(FastMath.floorDiv(current.getBlockX(), 16) != chunk.getX() || FastMath.floorDiv(current.getBlockZ(), 16) != chunk.getZ())
|
||||
return;
|
||||
item.paste(current, chunk.getWorld());
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||
bufferedItemMap.computeIfAbsent(location.clone(), l -> new Cell()).add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Vector3 location) {
|
||||
Cell cell = bufferedItemMap.get(location);
|
||||
if(cell != null) {
|
||||
return cell.getMark();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Vector3 location) {
|
||||
bufferedItemMap.computeIfAbsent(location.clone(), l -> new Cell()).setMark(mark);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setSucceeded(boolean succeeded) {
|
||||
this.succeeded = succeeded;
|
||||
}
|
||||
|
||||
public boolean succeeded() {
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getOrigin() {
|
||||
return origin.clone();
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedBlock implements BufferedItem {
|
||||
private final BlockState data;
|
||||
private final boolean overwrite;
|
||||
private final TerraPlugin main;
|
||||
private final boolean waterlog;
|
||||
|
||||
public BufferedBlock(BlockState data, boolean overwrite, TerraPlugin main, boolean waterlog) {
|
||||
this.data = data;
|
||||
this.overwrite = overwrite;
|
||||
this.main = main;
|
||||
this.waterlog = waterlog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
try {
|
||||
BlockState current = world.getBlockData(origin);
|
||||
if(overwrite || current.isAir()) {
|
||||
if(waterlog && current.has(Properties.WATERLOGGED) && current.getBlockType().isWater()) {
|
||||
current.set(Properties.WATERLOGGED, true);
|
||||
}
|
||||
world.setBlockData(origin, data);
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
||||
main.getDebugLogger().stack(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedEntity implements BufferedItem {
|
||||
|
||||
private final EntityType type;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public BufferedEntity(EntityType type, TerraPlugin main) {
|
||||
this.type = type;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5), type);
|
||||
main.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
|
||||
}
|
||||
}
|
||||
+14
-13
@@ -1,14 +1,16 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer.items;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.StructureScript;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.api.platform.block.state.Container;
|
||||
import com.dfsek.terra.api.structures.loot.LootTable;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BufferedLootApplication implements BufferedItem {
|
||||
private final LootTable table;
|
||||
@@ -22,21 +24,20 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(Vector3 origin, World world) {
|
||||
try {
|
||||
Block block = origin.getBlock();
|
||||
BlockState data = block.getState();
|
||||
BlockEntity data = world.getBlockState(origin);
|
||||
if(!(data instanceof Container)) {
|
||||
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||
return;
|
||||
}
|
||||
Container container = (Container) data;
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(block, container, table, block.getLocation().getWorld().getTerraGenerator().getConfigPack(), structure);
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
|
||||
main.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(), new FastRandom(origin.hashCode()));
|
||||
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedPulledBlock implements BufferedItem {
|
||||
private final BlockState data;
|
||||
|
||||
public BufferedPulledBlock(BlockState data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
Vector3 mutable = origin.clone();
|
||||
while(mutable.getY() > world.getMinHeight()) {
|
||||
if(!world.getBlockData(mutable).isAir()) {
|
||||
world.setBlockData(mutable, data);
|
||||
break;
|
||||
}
|
||||
mutable.subtract(0, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -1,8 +1,10 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
package com.dfsek.terra.addons.terrascript.api.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private final TerraPlugin main;
|
||||
@@ -14,9 +16,9 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(Vector3 origin, World world) {
|
||||
try {
|
||||
BlockState state = origin.getBlock().getState();
|
||||
BlockEntity state = world.getBlockState(origin);
|
||||
state.applyState(data);
|
||||
state.update(false);
|
||||
} catch(Exception e) {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.structures.parser.exceptions;
|
||||
package com.dfsek.terra.addons.terrascript.api.exception;
|
||||
|
||||
import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
|
||||
public class ParseException extends Exception {
|
||||
private static final long serialVersionUID = 6744390543046766386L;
|
||||
+4
-6
@@ -1,9 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.parser.lang.constants;
|
||||
package com.dfsek.terra.addons.terrascript.api.lang;
|
||||
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.variables.Variable;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,7 +15,7 @@ public abstract class ConstantExpression<T> implements Returnable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public T apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return constant;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.lang;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Item<T> {
|
||||
T apply(Context context, Map<String, Variable<?>> variableMap);
|
||||
|
||||
Position getPosition();
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.lang;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Returnable<T> extends Item<T> {
|
||||
ReturnType returnType();
|
||||
|
||||
enum ReturnType {
|
||||
NUMBER(true), STRING(true), BOOLEAN(false), VOID(false), OBJECT(false);
|
||||
|
||||
private final boolean comparable;
|
||||
|
||||
ReturnType(boolean comparable) {
|
||||
this.comparable = comparable;
|
||||
}
|
||||
|
||||
public boolean isComparable() {
|
||||
return comparable;
|
||||
}
|
||||
}
|
||||
|
||||
static <T> Returnable<T> constant(T value, ReturnType type, Position position) {
|
||||
return new Returnable<T>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.lang;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
|
||||
public interface Variable<T> {
|
||||
T getValue();
|
||||
|
||||
void setValue(T value);
|
||||
|
||||
Returnable.ReturnType getType();
|
||||
|
||||
Position getPosition();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
# biome-provider-image
|
||||
|
||||
Implements and registers the `IMAGE` biome provider, a biome provider which generates
|
||||
biomes from an image, using the `color` attribute of biomes.
|
||||
|
||||
This addon registers the provider type, and all associated config options.
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
+4
-10
@@ -1,8 +1,7 @@
|
||||
package com.dfsek.terra.api.world.biome.provider;
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -11,7 +10,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ImageBiomeProvider implements BiomeProvider, BiomeProvider.BiomeProviderBuilder { // This provider does not need a seed, so it is its own builder.
|
||||
public class ImageBiomeProvider implements BiomeProvider {
|
||||
private final Map<Color, TerraBiome> colorBiomeMap = new HashMap<>();
|
||||
private final BufferedImage image;
|
||||
private final int resolution;
|
||||
@@ -29,7 +28,7 @@ public class ImageBiomeProvider implements BiomeProvider, BiomeProvider.BiomePro
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z) {
|
||||
public TerraBiome getBiome(int x, int z, long seed) {
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
Color color = align.getColor(image, x, z);
|
||||
@@ -40,11 +39,6 @@ public class ImageBiomeProvider implements BiomeProvider, BiomeProvider.BiomePro
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider build(long seed) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Align {
|
||||
CENTER {
|
||||
@Override
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Addon("biome-provider-image")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class ImageBiomeProviderAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("IMAGE", () -> new ImageProviderTemplate(event.getPack().getRegistry(TerraBiome.class)));
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ImageProviderTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
private final Registry<TerraBiome> biomes;
|
||||
@Value("image.name")
|
||||
private BufferedImage image;
|
||||
|
||||
@Value("image.align")
|
||||
private ImageBiomeProvider.Align align;
|
||||
|
||||
@Value("resolution")
|
||||
@Default
|
||||
private int resolution = 1;
|
||||
|
||||
public ImageProviderTemplate(Registry<TerraBiome> set) {
|
||||
this.biomes = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider get() {
|
||||
return new ImageBiomeProvider(new HashSet<>(biomes.entries()), image, resolution, align);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# biome-provider-pipeline
|
||||
|
||||
Implements the Biome Pipeline, a procedural biome provider that uses a series
|
||||
of "stages" to apply "mutations" to a 2D grid of biomes.
|
||||
|
||||
|
||||
This addon registers the `PIPELINE` biome provider type, and all associated configurations.
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
+19
-18
@@ -1,18 +1,19 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline;
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeExpander;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.expand.BiomeExpander;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.source.BiomeSource;
|
||||
|
||||
public class TerraBiomeHolder implements BiomeHolder {
|
||||
public class BiomeHolderImpl implements BiomeHolder {
|
||||
private final Vector2 origin;
|
||||
private final int width;
|
||||
private TerraBiome[][] biomes;
|
||||
private final int offset;
|
||||
private TerraBiome[][] biomes;
|
||||
|
||||
public TerraBiomeHolder(int width, Vector2 origin) {
|
||||
public BiomeHolderImpl(int width, Vector2 origin) {
|
||||
width += 4;
|
||||
this.width = width;
|
||||
biomes = new TerraBiome[width][width];
|
||||
@@ -20,7 +21,7 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
this.offset = 2;
|
||||
}
|
||||
|
||||
private TerraBiomeHolder(TerraBiome[][] biomes, Vector2 origin, int width, int offset) {
|
||||
private BiomeHolderImpl(TerraBiome[][] biomes, Vector2 origin, int width, int offset) {
|
||||
this.biomes = biomes;
|
||||
this.origin = origin;
|
||||
this.width = width;
|
||||
@@ -28,7 +29,7 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeHolder expand(BiomeExpander expander) {
|
||||
public BiomeHolder expand(BiomeExpander expander, long seed) {
|
||||
TerraBiome[][] old = biomes;
|
||||
int newWidth = width * 2 - 1;
|
||||
|
||||
@@ -38,31 +39,31 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
for(int z = 0; z < width; z++) {
|
||||
biomes[x * 2][z * 2] = old[x][z];
|
||||
if(z != width - 1)
|
||||
biomes[x * 2][z * 2 + 1] = expander.getBetween(x + origin.getX(), z + 1 + origin.getZ(), old[x][z], old[x][z + 1]);
|
||||
biomes[x * 2][z * 2 + 1] = expander.getBetween(x + origin.getX(), z + 1 + origin.getZ(), seed, old[x][z], old[x][z + 1]);
|
||||
if(x != width - 1)
|
||||
biomes[x * 2 + 1][z * 2] = expander.getBetween(x + 1 + origin.getX(), z + origin.getZ(), old[x][z], old[x + 1][z]);
|
||||
biomes[x * 2 + 1][z * 2] = expander.getBetween(x + 1 + origin.getX(), z + origin.getZ(), seed, old[x][z], old[x + 1][z]);
|
||||
if(x != width - 1 && z != width - 1)
|
||||
biomes[x * 2 + 1][z * 2 + 1] = expander.getBetween(x + 1 + origin.getX(), z + 1 + origin.getZ(), old[x][z], old[x + 1][z + 1], old[x][z + 1], old[x + 1][z]);
|
||||
biomes[x * 2 + 1][z * 2 + 1] = expander.getBetween(x + 1 + origin.getX(), z + 1 + origin.getZ(), seed, old[x][z], old[x + 1][z + 1], old[x][z + 1], old[x + 1][z]);
|
||||
}
|
||||
}
|
||||
return new TerraBiomeHolder(biomes, origin.setX(origin.getX() * 2 - 1).setZ(origin.getZ() * 2 - 1), newWidth, offset);
|
||||
return new BiomeHolderImpl(biomes, origin.setX(origin.getX() * 2 - 1).setZ(origin.getZ() * 2 - 1), newWidth, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mutate(BiomeMutator mutator) {
|
||||
public void mutate(BiomeMutator mutator, long seed) {
|
||||
for(int x = 0; x < width; x++) {
|
||||
for(int z = 0; z < width; z++) {
|
||||
BiomeMutator.ViewPoint viewPoint = new BiomeMutator.ViewPoint(this, x, z);
|
||||
biomes[x][z] = mutator.mutate(viewPoint, x + origin.getX(), z + origin.getZ());
|
||||
biomes[x][z] = mutator.mutate(viewPoint, x + origin.getX(), z + origin.getZ(), seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(BiomeSource source) {
|
||||
public void fill(BiomeSource source, long seed) {
|
||||
for(int x = 0; x < width; x++) {
|
||||
for(int z = 0; z < width; z++) {
|
||||
biomes[x][z] = source.getBiome(origin.getX() + x, origin.getZ() + z);
|
||||
biomes[x][z] = source.getBiome(origin.getX() + x, origin.getZ() + z, seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BiomePipeline {
|
||||
private final BiomeSource source;
|
||||
private final List<Stage> stages;
|
||||
private final int size;
|
||||
private final int init;
|
||||
|
||||
private BiomePipeline(BiomeSource source, List<Stage> stages, int size, int init) {
|
||||
this.source = source;
|
||||
this.stages = stages;
|
||||
this.size = size;
|
||||
this.init = init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get biomes in a chunk
|
||||
*
|
||||
* @param x Chunk X coord
|
||||
* @param z Chunk Z coord
|
||||
* @return BiomeHolder containing biomes.
|
||||
*/
|
||||
public BiomeHolder getBiomes(int x, int z, long seed) {
|
||||
BiomeHolder holder = new BiomeHolderImpl(init, new Vector2(x * (init - 1), z * (init - 1)));
|
||||
holder.fill(source, seed);
|
||||
for(Stage stage : stages) holder = stage.apply(holder, seed);
|
||||
return holder;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public static final class BiomePipelineBuilder {
|
||||
private final int init;
|
||||
List<Stage> stages = new ArrayList<>();
|
||||
private int expand;
|
||||
|
||||
public BiomePipelineBuilder(int init) {
|
||||
this.init = init;
|
||||
expand = init;
|
||||
}
|
||||
|
||||
public BiomePipeline build(BiomeSource source) {
|
||||
for(Stage stage : stages) {
|
||||
if(stage.isExpansion()) expand = expand * 2 - 1;
|
||||
}
|
||||
|
||||
return new BiomePipeline(source, stages, expand, init);
|
||||
}
|
||||
|
||||
public BiomePipelineBuilder addStage(Stage stage) {
|
||||
stages.add(stage);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.BiomePipelineTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.NoiseSourceTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.expander.ExpanderStageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.BorderListMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.BorderMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.ReplaceListMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.ReplaceMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.SmoothMutatorTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Addon("biome-provider-pipeline")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class BiomePipelineAddon extends TerraAddon {
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeSource>>> SOURCE_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Stage>>> STAGE_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("PIPELINE", () -> new BiomePipelineTemplate(main));
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeSource>>> sourceRegistry = event.getPack().getOrCreateRegistry(SOURCE_REGISTRY_KEY);
|
||||
sourceRegistry.register("NOISE", NoiseSourceTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Stage>>> stageRegistry = event.getPack().getOrCreateRegistry(STAGE_REGISTRY_KEY);
|
||||
stageRegistry.register("FRACTAL_EXPAND", ExpanderStageTemplate::new);
|
||||
stageRegistry.register("SMOOTH", SmoothMutatorTemplate::new);
|
||||
stageRegistry.register("REPLACE", ReplaceMutatorTemplate::new);
|
||||
stageRegistry.register("REPLACE_LIST", ReplaceListMutatorTemplate::new);
|
||||
stageRegistry.register("BORDER", BorderMutatorTemplate::new);
|
||||
stageRegistry.register("BORDER_LIST", BorderListMutatorTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BiomePipelineProvider implements BiomeProvider {
|
||||
private final LoadingCache<SeededVector, BiomeHolder> holderCache;
|
||||
private final BiomePipeline pipeline;
|
||||
private final int resolution;
|
||||
private final NoiseSampler mutator;
|
||||
private final double noiseAmp;
|
||||
|
||||
public BiomePipelineProvider(BiomePipeline pipeline, TerraPlugin main, int resolution, NoiseSampler mutator, double noiseAmp) {
|
||||
this.resolution = resolution;
|
||||
this.mutator = mutator;
|
||||
this.noiseAmp = noiseAmp;
|
||||
holderCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(main == null ? 32 : main.getTerraConfig().getProviderCache())
|
||||
.build(
|
||||
new CacheLoader<SeededVector, BiomeHolder>() {
|
||||
@Override
|
||||
public BiomeHolder load(@NotNull SeededVector key) {
|
||||
return pipeline.getBiomes(key.x, key.z, key.seed);
|
||||
}
|
||||
}
|
||||
);
|
||||
this.pipeline = pipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z, long seed) {
|
||||
x += mutator.getNoiseSeeded(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.getNoiseSeeded(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
|
||||
x = FastMath.floorToInt(FastMath.floorDiv(x, resolution));
|
||||
|
||||
z = FastMath.floorToInt(FastMath.floorDiv(z, resolution));
|
||||
|
||||
int fdX = FastMath.floorDiv(x, pipeline.getSize());
|
||||
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
||||
return holderCache.getUnchecked(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(), z - fdZ * pipeline.getSize());
|
||||
}
|
||||
|
||||
private static final class SeededVector {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final long seed;
|
||||
|
||||
private SeededVector(int x, int z, long seed) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
result = 31 * result + ((int) (seed ^ (seed >>> 32)));
|
||||
result = 31 * result + x;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof SeededVector)) return false;
|
||||
SeededVector that = (SeededVector) obj;
|
||||
|
||||
return this.seed == that.seed && this.x == that.x && this.z == that.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeExpander {
|
||||
TerraBiome getBetween(double x, double z, long seed, TerraBiome... others);
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeHolder {
|
||||
BiomeHolder expand(BiomeExpander expander, long seed);
|
||||
|
||||
void mutate(BiomeMutator mutator, long seed);
|
||||
|
||||
void fill(BiomeSource source, long seed);
|
||||
|
||||
TerraBiome getBiome(int x, int z);
|
||||
|
||||
TerraBiome getBiomeRaw(int x, int z);
|
||||
}
|
||||
+2
-3
@@ -1,10 +1,9 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.api;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.BiomeHolder;
|
||||
|
||||
public interface BiomeMutator {
|
||||
TerraBiome mutate(ViewPoint viewPoint, double x, double z);
|
||||
TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed);
|
||||
|
||||
class ViewPoint {
|
||||
private final BiomeHolder biomes;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api;
|
||||
|
||||
public interface Stage {
|
||||
boolean isExpansion();
|
||||
|
||||
BiomeHolder apply(BiomeHolder in, long seed);
|
||||
|
||||
}
|
||||
+13
-12
@@ -1,13 +1,14 @@
|
||||
package com.dfsek.terra.config.loaders.config.biome.templates.provider;
|
||||
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.BiomePipeline;
|
||||
import com.dfsek.terra.addons.biome.pipeline.BiomePipelineProvider;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.seeded.SourceSeeded;
|
||||
import com.dfsek.terra.api.util.seeded.StageSeeded;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.BiomePipeline;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.biome.provider.StandardBiomeProvider;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,23 +17,23 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
private final TerraPlugin main;
|
||||
@Value("pipeline.initial-size")
|
||||
@Default
|
||||
private int initialSize = 2;
|
||||
private @Meta int initialSize = 2;
|
||||
|
||||
@Value("pipeline.stages")
|
||||
private List<StageSeeded> stages;
|
||||
private @Meta List<@Meta Stage> stages;
|
||||
|
||||
@Value("pipeline.source")
|
||||
private SourceSeeded source;
|
||||
private @Meta BiomeSource source;
|
||||
|
||||
public BiomePipelineTemplate(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider build(long seed) {
|
||||
public BiomeProvider get() {
|
||||
BiomePipeline.BiomePipelineBuilder biomePipelineBuilder = new BiomePipeline.BiomePipelineBuilder(initialSize);
|
||||
stages.forEach(biomePipelineBuilder::addStage);
|
||||
BiomePipeline pipeline = biomePipelineBuilder.build(source.apply(seed), seed);
|
||||
return new StandardBiomeProvider(pipeline, main, resolution, blend.apply(seed), blendAmp, (int) seed);
|
||||
BiomePipeline pipeline = biomePipelineBuilder.build(source);
|
||||
return new BiomePipelineProvider(pipeline, main, resolution, blend, blendAmp);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.addons.biome.pipeline.BiomePipelineProvider;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
|
||||
public class BiomeProviderLoader implements TypeLoader<BiomeProvider> {
|
||||
@Override
|
||||
public BiomeProvider load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return loader.loadType(BiomePipelineProvider.class, c); // TODO: actually implement this lol
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
@Value("resolution")
|
||||
@Default
|
||||
protected @Meta int resolution = 1;
|
||||
@Value("blend.noise")
|
||||
@Default
|
||||
protected @Meta NoiseSampler blend = NoiseSampler.zero();
|
||||
@Value("blend.amplitude")
|
||||
@Default
|
||||
protected @Meta double blendAmp = 0d;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.NoiseSource;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class NoiseSourceTemplate extends SourceTemplate {
|
||||
@Value("noise")
|
||||
private @Meta NoiseSampler noise;
|
||||
|
||||
@Value("biomes")
|
||||
private @Meta ProbabilityCollection<@Meta TerraBiome> biomes;
|
||||
|
||||
@Override
|
||||
public BiomeSource get() {
|
||||
return new NoiseSource(biomes, noise);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
|
||||
public abstract class SourceTemplate implements ObjectTemplate<BiomeSource> {
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
public abstract class StageTemplate implements ObjectTemplate<Stage> {
|
||||
@Value("noise")
|
||||
protected @Meta NoiseSampler noise;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.expander;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.expand.FractalExpander;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.ExpanderStage;
|
||||
|
||||
public class ExpanderStageTemplate extends StageTemplate {
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new ExpanderStage(new FractalExpander(noise));
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.mutator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.mutator.BorderListMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class BorderListMutatorTemplate extends StageTemplate {
|
||||
@Value("from")
|
||||
private @Meta String from;
|
||||
|
||||
@Value("default-replace")
|
||||
private @Meta String defaultReplace;
|
||||
|
||||
@Value("default-to")
|
||||
private @Meta ProbabilityCollection<@Meta TerraBiome> defaultTo;
|
||||
|
||||
@Value("replace")
|
||||
private @Meta Map<@Meta TerraBiome, @Meta ProbabilityCollection<@Meta TerraBiome>> replace;
|
||||
|
||||
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new MutatorStage(new BorderListMutator(replace, from, defaultReplace, noise, defaultTo));
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.mutator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.mutator.BorderMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class BorderMutatorTemplate extends StageTemplate {
|
||||
@Value("from")
|
||||
private @Meta String from;
|
||||
|
||||
@Value("replace")
|
||||
private @Meta String replace;
|
||||
|
||||
@Value("to")
|
||||
private @Meta ProbabilityCollection<@Meta TerraBiome> to;
|
||||
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new MutatorStage(new BorderMutator(from, replace, noise, to));
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.mutator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.mutator.ReplaceListMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ReplaceListMutatorTemplate extends StageTemplate {
|
||||
@Value("default-from")
|
||||
private @Meta String defaultFrom;
|
||||
|
||||
@Value("default-to")
|
||||
private @Meta ProbabilityCollection<@Meta TerraBiome> defaultTo;
|
||||
|
||||
@Value("to")
|
||||
private @Meta Map<@Meta TerraBiome, @Meta ProbabilityCollection<@Meta TerraBiome>> replace;
|
||||
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new MutatorStage(new ReplaceListMutator(replace, defaultFrom, defaultTo, noise));
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.mutator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.mutator.ReplaceMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ReplaceMutatorTemplate extends StageTemplate {
|
||||
@Value("from")
|
||||
private @Meta String from;
|
||||
|
||||
@Value("to")
|
||||
private @Meta ProbabilityCollection<@Meta TerraBiome> to;
|
||||
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new MutatorStage(new ReplaceMutator(from, to, noise));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.config.stage.mutator;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.config.stage.StageTemplate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.mutator.SmoothMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
|
||||
public class SmoothMutatorTemplate extends StageTemplate {
|
||||
@Override
|
||||
public Stage get() {
|
||||
return new MutatorStage(new SmoothMutator(noise));
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.expand;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeExpander;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class FractalExpander implements BiomeExpander {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
public FractalExpander(NoiseSampler sampler) {
|
||||
this.sampler = sampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBetween(double x, double z, long seed, TerraBiome... others) {
|
||||
return others[MathUtil.normalizeIndex(sampler.getNoiseSeeded(seed, x, z), others.length)];
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -22,7 +23,7 @@ public class BorderListMutator implements BiomeMutator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z) {
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed) {
|
||||
TerraBiome origin = viewPoint.getBiome(0, 0);
|
||||
if(origin.getTags().contains(defaultReplace)) {
|
||||
for(int xi = -1; xi <= 1; xi++) {
|
||||
@@ -32,10 +33,10 @@ public class BorderListMutator implements BiomeMutator {
|
||||
if(current == null) continue;
|
||||
if(current.getTags().contains(border)) {
|
||||
if(replace.containsKey(origin)) {
|
||||
TerraBiome biome = replace.get(origin).get(noiseSampler, x, z);
|
||||
TerraBiome biome = replace.get(origin).get(noiseSampler, x, z, seed);
|
||||
return biome == null ? origin : biome;
|
||||
}
|
||||
TerraBiome biome = replaceDefault.get(noiseSampler, x, z);
|
||||
TerraBiome biome = replaceDefault.get(noiseSampler, x, z, seed);
|
||||
return biome == null ? origin : biome;
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class BorderMutator implements BiomeMutator {
|
||||
@@ -18,7 +19,7 @@ public class BorderMutator implements BiomeMutator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z) {
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed) {
|
||||
TerraBiome origin = viewPoint.getBiome(0, 0);
|
||||
if(origin.getTags().contains(replaceTag)) {
|
||||
for(int xi = -1; xi <= 1; xi++) {
|
||||
@@ -27,7 +28,7 @@ public class BorderMutator implements BiomeMutator {
|
||||
TerraBiome current = viewPoint.getBiome(xi, zi);
|
||||
if(current == null) continue;
|
||||
if(current.getTags().contains(border)) {
|
||||
TerraBiome biome = replace.get(noiseSampler, x, z);
|
||||
TerraBiome biome = replace.get(noiseSampler, x, z, seed);
|
||||
return biome == null ? origin : biome;
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -20,14 +21,14 @@ public class ReplaceListMutator implements BiomeMutator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z) {
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed) {
|
||||
TerraBiome center = viewPoint.getBiome(0, 0);
|
||||
if(replace.containsKey(center)) {
|
||||
TerraBiome biome = replace.get(center).get(sampler, x, z);
|
||||
TerraBiome biome = replace.get(center).get(sampler, x, z, seed);
|
||||
return biome == null ? viewPoint.getBiome(0, 0) : biome;
|
||||
}
|
||||
if(viewPoint.getBiome(0, 0).getTags().contains(defaultTag)) {
|
||||
TerraBiome biome = replaceDefault.get(sampler, x, z);
|
||||
TerraBiome biome = replaceDefault.get(sampler, x, z, seed);
|
||||
return biome == null ? viewPoint.getBiome(0, 0) : biome;
|
||||
}
|
||||
return center;
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class ReplaceMutator implements BiomeMutator {
|
||||
@@ -16,9 +17,9 @@ public class ReplaceMutator implements BiomeMutator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z) {
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed) {
|
||||
if(viewPoint.getBiome(0, 0).getTags().contains(replaceableTag)) {
|
||||
TerraBiome biome = replace.get(sampler, x, z);
|
||||
TerraBiome biome = replace.get(sampler, x, z, seed);
|
||||
return biome == null ? viewPoint.getBiome(0, 0) : biome;
|
||||
}
|
||||
return viewPoint.getBiome(0, 0);
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -15,7 +16,7 @@ public class SmoothMutator implements BiomeMutator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z) {
|
||||
public TerraBiome mutate(ViewPoint viewPoint, double x, double z, long seed) {
|
||||
TerraBiome top = viewPoint.getBiome(1, 0);
|
||||
TerraBiome bottom = viewPoint.getBiome(-1, 0);
|
||||
TerraBiome left = viewPoint.getBiome(0, 1);
|
||||
@@ -26,7 +27,7 @@ public class SmoothMutator implements BiomeMutator {
|
||||
boolean horiz = Objects.equals(left, right) && left != null;
|
||||
|
||||
if(vert && horiz) {
|
||||
return MathUtil.normalizeIndex(sampler.getNoise(x, z), 2) == 0 ? left : top;
|
||||
return MathUtil.normalizeIndex(sampler.getNoiseSeeded(seed, x, z), 2) == 0 ? left : top;
|
||||
}
|
||||
|
||||
if(vert) return top;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.source;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeSource {
|
||||
TerraBiome getBiome(double x, double z, long seed);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.source;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public class NoiseSource implements BiomeSource {
|
||||
private final ProbabilityCollection<TerraBiome> biomes;
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
public NoiseSource(ProbabilityCollection<TerraBiome> biomes, NoiseSampler sampler) {
|
||||
this.biomes = biomes;
|
||||
this.sampler = sampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(double x, double z, long seed) {
|
||||
return biomes.get(sampler, x, z, seed);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.stages;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeExpander;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
|
||||
public class ExpanderStage implements Stage {
|
||||
private final BiomeExpander expander;
|
||||
|
||||
public ExpanderStage(BiomeExpander expander) {
|
||||
this.expander = expander;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpansion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeHolder apply(BiomeHolder in, long seed) {
|
||||
return in.expand(expander, seed);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
FRACTAL
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.stages;
|
||||
package com.dfsek.terra.addons.biome.pipeline.stages;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.pipeline.BiomeHolder;
|
||||
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.Stage;
|
||||
|
||||
public class MutatorStage implements Stage {
|
||||
private final BiomeMutator mutator;
|
||||
@@ -16,8 +17,8 @@ public class MutatorStage implements Stage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeHolder apply(BiomeHolder in) {
|
||||
in.mutate(mutator);
|
||||
public BiomeHolder apply(BiomeHolder in, long seed) {
|
||||
in.mutate(mutator, seed);
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# biome-provider-single
|
||||
|
||||
Registers and configures the `SINGLE` biome provider, a biome provider which
|
||||
accepts a single biome to generate continuously.
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.dfsek.terra.addons.biome.single;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public class SingleBiomeProvider implements BiomeProvider {
|
||||
private final TerraBiome biome;
|
||||
|
||||
public SingleBiomeProvider(TerraBiome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z, long seed) {
|
||||
return biome;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.dfsek.terra.addons.biome.single;
|
||||
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Addon("biome-provider-single")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class SingleBiomeProviderAddon extends TerraAddon {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register("SINGLE", SingleBiomeProviderTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.dfsek.terra.addons.biome.single;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public class SingleBiomeProviderTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
@Value("biome")
|
||||
private @Meta TerraBiome biome;
|
||||
|
||||
@Override
|
||||
public BiomeProvider get() {
|
||||
return new SingleBiomeProvider(biome);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# chunk-generator-noise-3d
|
||||
|
||||
Registers the `NOISE_3D` chunk generator, a chunk generator which uses biomes'
|
||||
samplers in 3D to generate chunk data.
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
@Value("palette")
|
||||
private @Meta PaletteHolder palette;
|
||||
|
||||
@Value("slant")
|
||||
@Default
|
||||
private @Meta SlantHolder slant = null;
|
||||
|
||||
@Value("ocean.level")
|
||||
private @Meta int seaLevel;
|
||||
|
||||
@Value("ocean.palette")
|
||||
private @Meta Palette oceanPalette;
|
||||
|
||||
@Override
|
||||
public PaletteInfo get() {
|
||||
return new PaletteInfo(palette, slant, oceanPalette, seaLevel);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.generators.NoiseChunkGenerator3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderLoader;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolderLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
|
||||
@Addon("chunk-generator-noise-3d")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class NoiseChunkGenerator3DAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().getOrCreateRegistry(ChunkGeneratorProvider.class).register("NOISE_3D", pack -> new NoiseChunkGenerator3D(pack, main));
|
||||
event.getPack()
|
||||
.applyLoader(SlantHolder.class, new SlantHolderLoader())
|
||||
.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
||||
})
|
||||
.failThrough();
|
||||
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(TerraBiome.class)) {
|
||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomePaletteTemplate()).get());
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
|
||||
public final class PaletteUtil {
|
||||
public static Palette getPalette(int x, int y, int z, GenerationSettings c, Sampler sampler, PaletteInfo paletteInfo) {
|
||||
SlantHolder slant = paletteInfo.getSlantHolder();
|
||||
if(slant != null) {
|
||||
double slope = MathUtil.derivative(sampler, x, y, z);
|
||||
if(slope > slant.getMinSlope()) {
|
||||
return slant.getPalette(slope).getPalette(y);
|
||||
}
|
||||
}
|
||||
|
||||
return paletteInfo.getPaletteHolder().getPalette(y);
|
||||
}
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.generators;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.PaletteUtil;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final ConfigPack configPack;
|
||||
private final TerraPlugin main;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack c, TerraPlugin main) {
|
||||
this.configPack = c;
|
||||
this.main = main;
|
||||
this.air = main.getWorldHandle().air();
|
||||
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"try"})
|
||||
static void biomes(@NotNull World world, int chunkX, int chunkZ, @NotNull BiomeGrid biome, TerraPlugin main) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("biomes")) {
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
long seed = world.getSeed();
|
||||
BiomeProvider grid = world.getBiomeProvider();
|
||||
for(int x = 0; x < 4; x++) {
|
||||
for(int z = 0; z < 4; z++) {
|
||||
int cx = xOrig + (x << 2);
|
||||
int cz = zOrig + (z << 2);
|
||||
TerraBiome b = grid.getBiome(cx, cz, seed);
|
||||
|
||||
biome.setBiome(cx, cz, b.getVanillaBiomes().get(b.getGenerator().getBiomeNoise(), cx, 0, cz, world.getSeed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getConfigPack() {
|
||||
return configPack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraPlugin getMain() {
|
||||
return main;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"try"})
|
||||
public ChunkData generateChunkData(@NotNull World world, Random random, int chunkX, int chunkZ, ChunkData chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("chunk_base_3d")) {
|
||||
BiomeProvider grid = world.getBiomeProvider();
|
||||
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
Sampler sampler = world.getConfig().getSamplerCache().getChunk(chunkX, chunkZ);
|
||||
|
||||
long seed = world.getSeed();
|
||||
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int paletteLevel = 0;
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
TerraBiome biome = grid.getBiome(cx, cz, seed);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
|
||||
if(paletteInfo == null) {
|
||||
main.logger().info("null palette: " + biome.getID());
|
||||
}
|
||||
|
||||
GenerationSettings generationSettings = biome.getGenerator();
|
||||
|
||||
int sea = paletteInfo.getSeaLevel();
|
||||
Palette seaPalette = paletteInfo.getOcean();
|
||||
|
||||
boolean justSet = false;
|
||||
BlockState data = null;
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
justSet = true;
|
||||
|
||||
data = PaletteUtil.getPalette(x, y, z, generationSettings, sampler, paletteInfo).get(paletteLevel, cx, y, cz, seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
|
||||
paletteLevel++;
|
||||
} else if(y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
|
||||
|
||||
justSet = false;
|
||||
paletteLevel = 0;
|
||||
} else {
|
||||
|
||||
justSet = false;
|
||||
paletteLevel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean placeStair(BlockState orig, ChunkData chunk, Vector3 block, double thresh, Sampler sampler, BlockState stairNew) {
|
||||
|
||||
if(sampler.sample(block.getBlockX() - 0.55, block.getY(), block.getZ()) > thresh) {
|
||||
stairNew.set(Properties.DIRECTION, Direction.WEST);
|
||||
} else if(sampler.sample(block.getBlockX(), block.getY(), block.getZ() - 0.55) > thresh) {
|
||||
stairNew.set(Properties.DIRECTION, Direction.NORTH);
|
||||
} else if(sampler.sample(block.getBlockX(), block.getY(), block.getZ() + 0.55) > thresh) {
|
||||
stairNew.set(Properties.DIRECTION, Direction.SOUTH);
|
||||
} else if(sampler.sample(block.getX() + 0.55, block.getY(), block.getZ()) > thresh) {
|
||||
stairNew.set(Properties.DIRECTION, Direction.EAST);
|
||||
} else stairNew = null;
|
||||
if(stairNew != null) {
|
||||
stairNew.setIfPresent(Properties.WATERLOGGED, orig.getBlockType().isWater());
|
||||
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), stairNew);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateBiomes(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
|
||||
biomes(world, chunkX, chunkZ, biome, main);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
||||
return new Sampler3D(chunkX, chunkZ, provider, world, elevationSmooth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GenerationStage> getGenerationStages() {
|
||||
return generationStages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(World world, int x, int y, int z) {
|
||||
BiomeProvider provider = world.getBiomeProvider();
|
||||
TerraBiome biome = provider.getBiome(x, z, world.getSeed());
|
||||
Sampler sampler = world.getConfig().getSamplerCache().get(x, z);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
Palette palette = PaletteUtil.getPalette(x, y, z, biome.getGenerator(), sampler, paletteInfo);
|
||||
int fdX = FastMath.floorMod(x, 16);
|
||||
int fdZ = FastMath.floorMod(z, 16);
|
||||
double noise = sampler.sample(fdX, y, fdZ);
|
||||
if(noise > 0) {
|
||||
int level = 0;
|
||||
for(int yi = world.getMaxHeight() - 1; yi > y; yi--) {
|
||||
if(sampler.sample(fdX, yi, fdZ) > 0) level++;
|
||||
else level = 0;
|
||||
}
|
||||
return palette.get(level, x, y, z, world.getSeed());
|
||||
} else if(y <= paletteInfo.getSeaLevel()) {
|
||||
return paletteInfo.getOcean().get(paletteInfo.getSeaLevel() - y, x, y, z, world.getSeed());
|
||||
} else return air;
|
||||
}
|
||||
}
|
||||
+17
-14
@@ -1,10 +1,11 @@
|
||||
package com.dfsek.terra.world.generation.math.interpolation;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.world.biome.Generator;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkInterpolator;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -17,7 +18,7 @@ import java.util.function.BiFunction;
|
||||
*/
|
||||
public class ChunkInterpolator2D implements ChunkInterpolator {
|
||||
private final Interpolator[][] interpGrid = new Interpolator[4][4];
|
||||
private final BiFunction<Generator, Vector3, Double> noiseGetter;
|
||||
private final BiFunction<GenerationSettings, Vector3, Double> noiseGetter;
|
||||
|
||||
/**
|
||||
* Instantiates a 3D ChunkInterpolator3D at a pair of chunk coordinates.
|
||||
@@ -26,24 +27,26 @@ public class ChunkInterpolator2D implements ChunkInterpolator {
|
||||
* @param chunkZ Z coordinate of the chunk.
|
||||
* @param provider Biome Provider to use for biome fetching.
|
||||
*/
|
||||
public ChunkInterpolator2D(World w, int chunkX, int chunkZ, BiomeProvider provider, BiFunction<Generator, Vector3, Double> noiseGetter) {
|
||||
public ChunkInterpolator2D(World w, int chunkX, int chunkZ, BiomeProvider provider, BiFunction<GenerationSettings, Vector3, Double> noiseGetter) {
|
||||
this.noiseGetter = noiseGetter;
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
|
||||
long seed = w.getSeed();
|
||||
|
||||
double[][] noiseStorage = new double[5][5];
|
||||
|
||||
for(int x = 0; x < 5; x++) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
Generator generator = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2)).getGenerator(w);
|
||||
Map<Generator, MutableInteger> genMap = new HashMap<>();
|
||||
GenerationSettings generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed).getGenerator();
|
||||
Map<GenerationSettings, MutableInteger> genMap = new HashMap<>();
|
||||
|
||||
int step = generator.getBlendStep();
|
||||
int blend = generator.getBlendDistance();
|
||||
int step = generationSettings.getBlendStep();
|
||||
int blend = generationSettings.getBlendDistance();
|
||||
|
||||
for(int xi = -blend; xi <= blend; xi++) {
|
||||
for(int zi = -blend; zi <= blend; zi++) {
|
||||
genMap.computeIfAbsent(provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step)).getGenerator(w), g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
genMap.computeIfAbsent(provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step), seed).getGenerator(), g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +69,8 @@ public class ChunkInterpolator2D implements ChunkInterpolator {
|
||||
return FastMath.max(FastMath.min(value, high), 0);
|
||||
}
|
||||
|
||||
public double computeNoise(Generator generator, double x, double y, double z) {
|
||||
return noiseGetter.apply(generator, new Vector3(x, y, z));
|
||||
public double computeNoise(GenerationSettings generationSettings, double x, double y, double z) {
|
||||
return noiseGetter.apply(generationSettings, new Vector3(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
+19
-16
@@ -1,10 +1,11 @@
|
||||
package com.dfsek.terra.world.generation.math.interpolation;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.world.biome.Generator;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkInterpolator;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -17,7 +18,7 @@ import java.util.function.BiFunction;
|
||||
*/
|
||||
public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
private final Interpolator3[][][] interpGrid;
|
||||
private final BiFunction<Generator, Vector3, Double> noiseGetter;
|
||||
private final BiFunction<GenerationSettings, Vector3, Double> noiseGetter;
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
@@ -29,7 +30,7 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
* @param chunkZ Z coordinate of the chunk.
|
||||
* @param provider Biome Provider to use for biome fetching.
|
||||
*/
|
||||
public ChunkInterpolator3D(World w, int chunkX, int chunkZ, BiomeProvider provider, BiFunction<Generator, Vector3, Double> noiseGetter) {
|
||||
public ChunkInterpolator3D(World w, int chunkX, int chunkZ, BiomeProvider provider, BiFunction<GenerationSettings, Vector3, Double> noiseGetter) {
|
||||
this.noiseGetter = noiseGetter;
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
@@ -44,17 +45,19 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
|
||||
double[][][] noiseStorage = new double[5][5][size + 1];
|
||||
|
||||
long seed = w.getSeed();
|
||||
|
||||
for(int x = 0; x < 5; x++) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
Generator generator = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2)).getGenerator(w);
|
||||
Map<Generator, MutableInteger> genMap = new HashMap<>();
|
||||
GenerationSettings generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed).getGenerator();
|
||||
Map<GenerationSettings, MutableInteger> genMap = new HashMap<>();
|
||||
|
||||
int step = generator.getBlendStep();
|
||||
int blend = generator.getBlendDistance();
|
||||
int step = generationSettings.getBlendStep();
|
||||
int blend = generationSettings.getBlendDistance();
|
||||
|
||||
for(int xi = -blend; xi <= blend; xi++) {
|
||||
for(int zi = -blend; zi <= blend; zi++) {
|
||||
genMap.computeIfAbsent(provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step)).getGenerator(w), g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
genMap.computeIfAbsent(provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step), seed).getGenerator(), g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,14 +84,14 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
}
|
||||
}
|
||||
|
||||
public double computeNoise(Generator generator, double x, double y, double z) {
|
||||
return noiseGetter.apply(generator, new Vector3(x, y, z));
|
||||
}
|
||||
|
||||
private static int reRange(int value, int high) {
|
||||
return FastMath.max(FastMath.min(value, high), 0);
|
||||
}
|
||||
|
||||
public double computeNoise(GenerationSettings generationSettings, double x, double y, double z) {
|
||||
return noiseGetter.apply(generationSettings, new Vector3(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the noise at a pair of internal chunk coordinates.
|
||||
*
|
||||
+10
-9
@@ -1,9 +1,8 @@
|
||||
package com.dfsek.terra.world.generation.math.interpolation;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.world.biome.Generator;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.world.generation.WorldGenerator;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public class ElevationInterpolator {
|
||||
private final double[][] values = new double[18][18];
|
||||
@@ -12,12 +11,14 @@ public class ElevationInterpolator {
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
|
||||
WorldGenerator[][] gens = new WorldGenerator[18 + 2 * smooth][18 + 2 * smooth];
|
||||
long seed = world.getSeed();
|
||||
|
||||
GenerationSettings[][] gens = new GenerationSettings[18 + 2 * smooth][18 + 2 * smooth];
|
||||
|
||||
// Precompute generators.
|
||||
for(int x = -1 - smooth; x <= 16 + smooth; x++) {
|
||||
for(int z = -1 - smooth; z <= 16 + smooth; z++) {
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = (WorldGenerator) provider.getBiome(xOrigin + x, zOrigin + z).getGenerator(world);
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getGenerator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +28,8 @@ public class ElevationInterpolator {
|
||||
double div = 0;
|
||||
for(int xi = -smooth; xi <= smooth; xi++) {
|
||||
for(int zi = -smooth; zi <= smooth; zi++) {
|
||||
Generator gen = gens[x + 1 + smooth + xi][z + 1 + smooth + zi];
|
||||
noise += gen.getElevationSampler().getNoise(xOrigin + x, zOrigin + z) * gen.getElevationWeight();
|
||||
GenerationSettings gen = gens[x + 1 + smooth + xi][z + 1 + smooth + zi];
|
||||
noise += gen.getElevationSampler().getNoiseSeeded(seed, xOrigin + x, zOrigin + z) * gen.getElevationWeight();
|
||||
div += gen.getElevationWeight();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.world.generation.math.interpolation;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
/**
|
||||
* Class for bilinear interpolation of values arranged on a unit square.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.world.generation.math.interpolation;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
/**
|
||||
* Class for bilinear interpolation of values arranged on a unit square.
|
||||
+7
-6
@@ -1,9 +1,10 @@
|
||||
package com.dfsek.terra.world.generation.math.samplers;
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.world.generation.math.interpolation.ChunkInterpolator3D;
|
||||
import com.dfsek.terra.world.generation.math.interpolation.ElevationInterpolator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ChunkInterpolator3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ElevationInterpolator;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class Sampler3D implements Sampler {
|
||||
@@ -11,7 +12,7 @@ public class Sampler3D implements Sampler {
|
||||
private final ElevationInterpolator elevationInterpolator;
|
||||
|
||||
public Sampler3D(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
|
||||
this.interpolator = new ChunkInterpolator3D(world, x, z, provider, (generator, coord) -> generator.getBaseSampler().getNoise(coord));
|
||||
this.interpolator = new ChunkInterpolator3D(world, x, z, provider, (generator, coord) -> generator.getBaseSampler().getNoiseSeeded(coord, world.getSeed()));
|
||||
this.elevationInterpolator = new ElevationInterpolator(world, x, z, provider, elevationSmooth);
|
||||
}
|
||||
|
||||
+5
-6
@@ -1,18 +1,17 @@
|
||||
package com.dfsek.terra.api.world.palette.holder;
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
public class PaletteHolder {
|
||||
private final Palette<BlockData>[] palettes;
|
||||
private final Palette[] palettes;
|
||||
private final int offset;
|
||||
|
||||
protected PaletteHolder(Palette<BlockData>[] palettes, int offset) {
|
||||
protected PaletteHolder(Palette[] palettes, int offset) {
|
||||
this.palettes = palettes;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Palette<BlockData> getPalette(int y) {
|
||||
public Palette getPalette(int y) {
|
||||
int index = y + offset;
|
||||
return index >= 0
|
||||
? index < palettes.length
|
||||
+7
-9
@@ -1,30 +1,28 @@
|
||||
package com.dfsek.terra.api.world.palette.holder;
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class PaletteHolderBuilder {
|
||||
private final TreeMap<Integer, Palette<BlockData>> paletteMap = new TreeMap<>();
|
||||
private final TreeMap<Integer, Palette> paletteMap = new TreeMap<>();
|
||||
|
||||
public PaletteHolderBuilder add(int y, Palette<BlockData> palette) {
|
||||
public PaletteHolderBuilder add(int y, Palette palette) {
|
||||
paletteMap.put(y, palette);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"})
|
||||
public PaletteHolder build() {
|
||||
|
||||
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
|
||||
|
||||
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
|
||||
Palette[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
|
||||
for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) {
|
||||
Palette<BlockData> d = null;
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
|
||||
Palette d = null;
|
||||
for(Map.Entry<Integer, Palette> e : paletteMap.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
d = e.getValue();
|
||||
break;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PaletteHolderLoader implements TypeLoader<PaletteHolder> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PaletteHolder load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
List<Map<String, Integer>> palette = (List<Map<String, Integer>>) o;
|
||||
PaletteHolderBuilder builder = new PaletteHolderBuilder();
|
||||
for(Map<String, Integer> layer : palette) {
|
||||
for(Map.Entry<String, Integer> entry : layer.entrySet()) {
|
||||
builder.add(entry.getValue(), configLoader.loadType(Palette.class, entry.getKey()));
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
public class PaletteInfo implements Properties {
|
||||
private final PaletteHolder paletteHolder;
|
||||
private final SlantHolder slantHolder;
|
||||
private final Palette ocean;
|
||||
|
||||
private final int seaLevel;
|
||||
|
||||
public PaletteInfo(PaletteHolder paletteHolder, SlantHolder slantHolder, Palette ocean, int seaLevel) {
|
||||
this.paletteHolder = paletteHolder;
|
||||
this.slantHolder = slantHolder;
|
||||
this.ocean = ocean;
|
||||
this.seaLevel = seaLevel;
|
||||
}
|
||||
|
||||
public Palette getOcean() {
|
||||
return ocean;
|
||||
}
|
||||
|
||||
public PaletteHolder getPaletteHolder() {
|
||||
return paletteHolder;
|
||||
}
|
||||
|
||||
public SlantHolder getSlantHolder() {
|
||||
return slantHolder;
|
||||
}
|
||||
|
||||
public int getSeaLevel() {
|
||||
return seaLevel;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class SlantHolder {
|
||||
private final TreeMap<Double, PaletteHolder> layers;
|
||||
private final double minSlope;
|
||||
|
||||
public SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
this.layers = layers;
|
||||
this.minSlope = minSlope;
|
||||
}
|
||||
|
||||
public PaletteHolder getPalette(double slope) {
|
||||
return layers.floorEntry(slope).getValue();
|
||||
}
|
||||
|
||||
public double getMinSlope() {
|
||||
return minSlope;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class SlantHolderLoader implements TypeLoader<SlantHolder> {
|
||||
@Override
|
||||
public SlantHolder load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
List<Map<Object, Object>> layers = (List<Map<Object, Object>>) o;
|
||||
TreeMap<Double, PaletteHolder> slantLayers = new TreeMap<>();
|
||||
double minThreshold = Double.MAX_VALUE;
|
||||
|
||||
for(Map<Object, Object> layer : layers) {
|
||||
double threshold = ((Number) layer.get("threshold")).doubleValue();
|
||||
if(threshold < minThreshold) minThreshold = threshold;
|
||||
slantLayers.put(threshold, configLoader.loadType(PaletteHolder.class, layer.get("palette")));
|
||||
}
|
||||
|
||||
return new SlantHolder(slantLayers, minThreshold);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# config-biome
|
||||
|
||||
Registers the default configuration for Terra Biomes, `BIOME`.
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies {
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.dfsek.terra.addons.biome;
|
||||
|
||||
import com.dfsek.terra.addons.biome.holder.PaletteHolder;
|
||||
import com.dfsek.terra.addons.biome.holder.PaletteHolderLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
|
||||
@Addon("config-biome")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class BiomeAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
event.getPack().registerConfigType(new BiomeConfigType(event.getPack()), "BIOME", 5);
|
||||
event.getPack().applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user