Compare commits
621 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fb1915c69 | |||
| a7e2ead7fa | |||
| 21a510c023 | |||
| b3ee205f49 | |||
| e242893a92 | |||
| 48c5d32093 | |||
| a3d167a958 | |||
| 923fe0576f | |||
| 9bb1a04402 | |||
| e355fcd660 | |||
| 6c62155d36 | |||
| 2d2ea5b44f | |||
| 05dbe0f07e | |||
| e27676d06b | |||
| 89e32cd17a | |||
| 8f48d15b1f | |||
| 4af31ac5b9 | |||
| 993a9a6864 | |||
| 9c90db3718 | |||
| 4d37429c49 | |||
| e03536f315 | |||
| 6057141094 | |||
| 55f7e2cd30 | |||
| 39e923ae79 | |||
| 99852fded6 | |||
| d75bf8afe7 | |||
| 086185783c | |||
| 70321c2d0f | |||
| 9ce353d897 | |||
| 1d1a2d455d | |||
| fa1e7704e0 | |||
| 1227c56353 | |||
| 22c85f1eda | |||
| d75a4f8d1a | |||
| 7f69809345 | |||
| e460aa2e0d | |||
| 705535e574 | |||
| f0966befb2 | |||
| ec3bab3158 | |||
| 7510f23d19 | |||
| 9c9974de5b | |||
| e49a400dba | |||
| 893e82b181 | |||
| f8427c4f40 | |||
| 6576f55c55 | |||
| ddca97f679 | |||
| 6bf405c0b1 | |||
| d97bc912f7 | |||
| ac91979a3f | |||
| 3119fae67b | |||
| b77a53fc2a | |||
| 9d45717356 | |||
| 6235453387 | |||
| 0e52c06d35 | |||
| 680ab28491 | |||
| b31ee404fd | |||
| 4c604a24cb | |||
| ebba4939c5 | |||
| 285a507370 | |||
| 2f7008bbc3 | |||
| 68b0550696 | |||
| bafe93a28a | |||
| b1b464c592 | |||
| b21cfd8304 | |||
| 8dc3f744fe | |||
| 225703cdf1 | |||
| 3fb9fa8609 | |||
| a4fca06531 | |||
| fdd416b514 | |||
| 03f134bde3 | |||
| e8d1ca995c | |||
| 00b43dc90f | |||
| 2efb6fff49 | |||
| 16adf15975 | |||
| 417b98f881 | |||
| ffa64874c9 | |||
| 8454b5056d | |||
| a81fd9a483 | |||
| 4ee1949873 | |||
| 6acb4d4184 | |||
| 2798368099 | |||
| bcdce2bdf5 | |||
| 43773652aa | |||
| 10072200b5 | |||
| a00647f8e7 | |||
| 96429eec00 | |||
| c49e38a58c | |||
| b2047ce0c0 | |||
| 5b60d515e9 | |||
| cf0205caa4 | |||
| c91ab1deb1 | |||
| 2b5dd236aa | |||
| 0658479921 | |||
| ff8b07ac12 | |||
| fb87ee529a | |||
| 1fabc24e45 | |||
| 9ab2cfcb6a | |||
| e81e31fc24 | |||
| e69b7dec7d | |||
| 534e4a4377 | |||
| 3193773583 | |||
| 4d4906228e | |||
| e4a1d7478a | |||
| cf8eaa57cf | |||
| 2211add5e0 | |||
| e432358e1b | |||
| 3ccce80e1d | |||
| 1952f91540 | |||
| 0e1017111e | |||
| b4be8ab83f | |||
| 3b807dae95 | |||
| 9fdaeed69b | |||
| b7d627f0f5 | |||
| 733bbc0b58 | |||
| 17f6147e13 | |||
| 08c4c8667a | |||
| 526791aae7 | |||
| 8fdd6dcccc | |||
| fb4f5819fd | |||
| 58554f3891 | |||
| 5020084663 | |||
| 5aaab01ac9 | |||
| 024f60de9b | |||
| 1ccc46869d | |||
| 3edcb8d03d | |||
| d7189f0f05 | |||
| f19aa7831e | |||
| 601eeb7fbe | |||
| a8f20a407b | |||
| 872a7d9fa8 | |||
| 310b85ad83 | |||
| b8d94ba7eb | |||
| 4c112aa8ae | |||
| df6da4b48a | |||
| c3e8449979 | |||
| d8707bfe01 | |||
| f07940c11f | |||
| 889c3d32c9 | |||
| 1e502c5933 | |||
| f01e31f475 | |||
| 4285f32b94 | |||
| af5bcafa45 | |||
| 909870b321 | |||
| 2b5dd8b77e | |||
| 4d4e4a9706 | |||
| ac82e90dc2 | |||
| 8063141406 | |||
| 5c17e9599b | |||
| 2e54f2166d | |||
| a0bd2ba4a1 | |||
| 38102ac17f | |||
| 139c5869c9 | |||
| 79206420f9 | |||
| e046b972ca | |||
| ea4949b3a2 | |||
| 05d5f0b943 | |||
| 81df84dc37 | |||
| ff9bab99c7 | |||
| 301ea26a03 | |||
| bd7a03b0ca | |||
| 4e0619a269 | |||
| 8b13afeb23 | |||
| ce44feeb40 | |||
| 821e86b875 | |||
| 015e596eda | |||
| 09e535abf4 | |||
| 855f7f0f9a | |||
| 5fa3e3cb7f | |||
| 0bddc2dcac | |||
| 42a8e0e0f0 | |||
| 7b77e07a7d | |||
| db17d27823 | |||
| 362b800f25 | |||
| 29e26d659d | |||
| afa658cc00 | |||
| cde0d466dd | |||
| 4031b55630 | |||
| 86e07156d1 | |||
| 1e8df274ee | |||
| f0153cc4a6 | |||
| 3044c238fd | |||
| ead58390cd | |||
| 504d22ff37 | |||
| cc42f8667f | |||
| 6135b3ce7f | |||
| 3c8efa17d5 | |||
| dccae0aea0 | |||
| 2728236ced | |||
| 76ce1d6b21 | |||
| 94ddebaec0 | |||
| cec165176b | |||
| 99ad837441 | |||
| f8be132ba2 | |||
| 122f5431a6 | |||
| c2884954a4 | |||
| 3a0453c8c5 | |||
| 9d241ab175 | |||
| ee7eed8d3c | |||
| 1125452a8f | |||
| a3712c8f72 | |||
| e2022fab2d | |||
| bcea1be19b | |||
| 8d799203c5 | |||
| 980ce2f2af | |||
| c6bea3faa3 | |||
| 7707f55b25 | |||
| f087bb7182 | |||
| bf269c9abf | |||
| a8c7405f9d | |||
| 43c9232e7e | |||
| 8351c58d7b | |||
| aa86381b80 | |||
| 563840ca58 | |||
| b5b9b688c3 | |||
| 3731223087 | |||
| 72d770c0f3 | |||
| ee4b83fa99 | |||
| ee6e3a9876 | |||
| 17e375bc61 | |||
| a2c8c90a5e | |||
| b376014df8 | |||
| b9ee54f6ad | |||
| 6c7e1900a3 | |||
| 6f929f40f9 | |||
| b6a8930855 | |||
| 7a91b258de | |||
| 35bef76aeb | |||
| 780d0ad9fb | |||
| c0d5dd6dee | |||
| 3e87e625ba | |||
| 56f9403859 | |||
| 8259c79e9c | |||
| be1e2fe7e6 | |||
| 609ee5c70d | |||
| 207cab9a0f | |||
| c80b025ac1 | |||
| 8610917b86 | |||
| fae4bee871 | |||
| b9608498a2 | |||
| fe59c6b0c9 | |||
| b082b048d6 | |||
| 91712cee2a | |||
| 5adfbb2dee | |||
| ec32d09468 | |||
| 919990820e | |||
| 5cc31efa12 | |||
| 5f48b41693 | |||
| 9530eea287 | |||
| ebbf304c94 | |||
| 7c8ac0c2ff | |||
| eefad5e052 | |||
| 9a1e6e29d4 | |||
| 62ab450d98 | |||
| b4a5da4a74 | |||
| ed82480c89 | |||
| 82449c5edc | |||
| b165726bc9 | |||
| 11910d0f28 | |||
| f66e27b077 | |||
| f84570a6fc | |||
| 835beb607d | |||
| c4e2d3fb0f | |||
| eb3d8d9da5 | |||
| 151d548099 | |||
| c5cdc2760f | |||
| a663bf9f19 | |||
| a0f5af46a2 | |||
| 7ddd48d132 | |||
| 18074f15f5 | |||
| bba0424c6d | |||
| 282f6cfbb8 | |||
| ce10a43cc6 | |||
| 5476af5bb3 | |||
| b97b1b61b7 | |||
| 25d2cfd7b8 | |||
| 1b754387e0 | |||
| bcad40069f | |||
| 5aa9061006 | |||
| 873e8cec57 | |||
| f6f96c3aea | |||
| aeed672295 | |||
| 832fbe6d15 | |||
| 03deddf666 | |||
| d06413d1b4 | |||
| 8afa50d585 | |||
| 9f28f1f812 | |||
| 985388fd90 | |||
| e27e10082a | |||
| 4e510d96fc | |||
| c0ec02f062 | |||
| bd27a96bde | |||
| d6aeaf8e9d | |||
| 2b9bba4aa7 | |||
| 58b0991891 | |||
| 59cbbef327 | |||
| 7047c81a2b | |||
| 6e2ab47359 | |||
| f879332e1d | |||
| 6fcafecc61 | |||
| a5af93aef1 | |||
| 4b84fd2a67 | |||
| 924efc0cbd | |||
| 288457b5bd | |||
| d29fa86de6 | |||
| 97be227e3d | |||
| 909d6a54c3 | |||
| 228b6a80dc | |||
| 6936a5f96f | |||
| 740560a50a | |||
| 47c28f0f37 | |||
| 1c859cd7da | |||
| e4a97dd76d | |||
| 4fd1e5ea06 | |||
| 6039aeabde | |||
| 17a384f074 | |||
| 25e8f5ec6a | |||
| eac8cacd42 | |||
| 75193d76a3 | |||
| aa24fd341e | |||
| 81adade05b | |||
| e3808dc986 | |||
| d669b2a1fe | |||
| 2bd8dab240 | |||
| 2b423c2edd | |||
| 1a4faf4bdd | |||
| b70829aceb | |||
| bba771d376 | |||
| 75b18f8bd8 | |||
| 60da404900 | |||
| b75eebd0dc | |||
| 72cbd1167a | |||
| e4e51ebf5b | |||
| dd2096bf1b | |||
| 393a94a7a1 | |||
| ef0023ef39 | |||
| f0994fff75 | |||
| 31f41540c0 | |||
| 81fe13b9c0 | |||
| 332df13b29 | |||
| b3af6df0c5 | |||
| 9392e618c0 | |||
| fd361a39a1 | |||
| f41de59f39 | |||
| c701cf987b | |||
| f05e878600 | |||
| dc028db5ed | |||
| c59d7a7d27 | |||
| a3dd346a02 | |||
| dba8061f71 | |||
| 3da2d961fc | |||
| aa83dc7465 | |||
| 392821c081 | |||
| 7e5fc979cc | |||
| 7ebb555b94 | |||
| 3612a2f9e0 | |||
| 42b67825f8 | |||
| 30a636c840 | |||
| e5722c19a9 | |||
| 6b6a9ab0a9 | |||
| 6da74c6f4e | |||
| 0bafa37f66 | |||
| 6ba6b11f6b | |||
| 739653f37a | |||
| 213d70f2d1 | |||
| dda3c7636b | |||
| 3956578043 | |||
| d11f067392 | |||
| 9f9fe6a231 | |||
| 486a30cb93 | |||
| 01545dc295 | |||
| 165a3799f3 | |||
| 308f809d5d | |||
| 003dbdff02 | |||
| 99f8dbb042 | |||
| 4263ea9733 | |||
| c09b07a21b | |||
| 4e0160648b | |||
| ad367f681d | |||
| a5a70cd65b | |||
| 4ff37cfdad | |||
| 9a1abdefa1 | |||
| 37cc7e7b37 | |||
| 04cbb1e92c | |||
| 5033175808 | |||
| 689928708c | |||
| 98327e6fdf | |||
| 5aef0977c0 | |||
| e6738f1c80 | |||
| b55c1b8f56 | |||
| 3764a4cc9e | |||
| d6bbb9d8dc | |||
| a38e7a00e4 | |||
| 2ec84ae3cf | |||
| f03035e3f9 | |||
| 1d914b8f8a | |||
| ee947b36a2 | |||
| ba393f61e5 | |||
| 796c8e7bef | |||
| fe60de314d | |||
| d237db3302 | |||
| f665b452b0 | |||
| 17750691d6 | |||
| 89ba5b9d15 | |||
| cea44a3f8a | |||
| a99c9aff76 | |||
| 1827ab646c | |||
| db00f7ebec | |||
| 0b93c7b5dc | |||
| 97204f3a3c | |||
| 02a6db0a62 | |||
| 577af4d854 | |||
| 68155142c3 | |||
| 43897e1298 | |||
| bf2c520966 | |||
| ee1528f694 | |||
| 8bd7556c89 | |||
| facbb174f5 | |||
| 9d3ce5307c | |||
| 54f3e9e12d | |||
| e294fc79eb | |||
| a750aaf90a | |||
| be8e09eb9b | |||
| 016d26a6f7 | |||
| 539698c456 | |||
| bcc11b8f0c | |||
| c2a960162e | |||
| c42a3a5fb3 | |||
| 59d6289177 | |||
| 4f028d118d | |||
| b555e35016 | |||
| 26b4c3a2d9 | |||
| 2a5199f851 | |||
| 408dbc2169 | |||
| c9ffcfb1e8 | |||
| 3bd1eedcb8 | |||
| 8500ec7a00 | |||
| 223570a0b7 | |||
| de8c063731 | |||
| 0cffa30286 | |||
| 1d3a282c60 | |||
| 9b6cd955b5 | |||
| 8e1559ac61 | |||
| ce597576ba | |||
| d53a7a5fc4 | |||
| 35bb5cdc92 | |||
| 26e9cc21fd | |||
| 71fd448b7f | |||
| 93e18230f0 | |||
| d305741be2 | |||
| 5830c8d87a | |||
| 5161439536 | |||
| deb6ada6cc | |||
| e72a0546be | |||
| e27b43f03a | |||
| daf4f06a30 | |||
| e5ef93a26d | |||
| b158dff2c6 | |||
| 23bbbce749 | |||
| 898be82aab | |||
| dc9ed37de2 | |||
| b390e54801 | |||
| 9736d2169e | |||
| b507f459b3 | |||
| 51a7053d7e | |||
| 3ba40dd910 | |||
| 248f8e5e70 | |||
| 49b0911aaf | |||
| e4b40c9383 | |||
| 328ac93178 | |||
| d91f86aed5 | |||
| 8119cc06ad | |||
| 94c9d0e276 | |||
| e262dfa14a | |||
| 5e0b63347e | |||
| b7df3bad22 | |||
| 6a56c0c96f | |||
| fd8a94d77c | |||
| 7d38fac16d | |||
| 235ffb03a5 | |||
| fa2702209c | |||
| f9f9f98750 | |||
| 0c46947f4d | |||
| b5b57dfaba | |||
| 39e7812f8b | |||
| 025e8b3f9b | |||
| 35e3a4262b | |||
| 562c8154ff | |||
| e23244181a | |||
| 6aa6c32299 | |||
| fbdabf52e7 | |||
| f4c1f1bcd7 | |||
| 965c19d426 | |||
| 239a876fcf | |||
| d53165881f | |||
| 40733ea1fc | |||
| 66a16ee508 | |||
| b1a9a8ac8d | |||
| 06a2f9f336 | |||
| 978bc58c11 | |||
| a5577e80f1 | |||
| 9daf5a013c | |||
| 72e2cb8a64 | |||
| db819698af | |||
| 09e427ab97 | |||
| a6b3a7ea5a | |||
| 4d08339f79 | |||
| 2ba32a8c94 | |||
| ebedd5e181 | |||
| 357c355e26 | |||
| faca159721 | |||
| 3556528932 | |||
| 8513e46fdc | |||
| 323eced2a4 | |||
| 6a87539ca3 | |||
| fe725b6795 | |||
| 02862a770f | |||
| a7759ab8e9 | |||
| da1b2051dd | |||
| 4fdc596474 | |||
| d0c710b7e1 | |||
| 41ee9dcd99 | |||
| 506ce87f5f | |||
| 08e42ebfe5 | |||
| 699d27afd2 | |||
| 4a64ce0bed | |||
| b3b94d29b5 | |||
| 3a30516088 | |||
| 6f469737f3 | |||
| 183720d1e5 | |||
| b2dcc66bd0 | |||
| 5c67be30de | |||
| 4ad4e2c29c | |||
| d1f805d178 | |||
| 73071119fa | |||
| 97c52834f5 | |||
| 3e472e454a | |||
| 7ddab31337 | |||
| fd5b9be523 | |||
| f9dd870067 | |||
| 4908acd7ac | |||
| 87486f6825 | |||
| c721c14e27 | |||
| 3521af9792 | |||
| ff94dba348 | |||
| 31d0a45555 | |||
| 41c1473e04 | |||
| d5f12466b2 | |||
| bdd9ef6b40 | |||
| 9b6895ec68 | |||
| a3854561fc | |||
| a66df74ec9 | |||
| eb4b31e876 | |||
| 6015b9a1dc | |||
| 146d42bbe9 | |||
| 16b14bc424 | |||
| a37e4ca232 | |||
| 8103c16064 | |||
| 6ae41b0caa | |||
| ba81f31027 | |||
| 71c72e26e7 | |||
| 97828f465d | |||
| ec37803572 | |||
| b7a54eff7a | |||
| 9604ce297c | |||
| 5ad961d80e | |||
| 843ec2fef8 | |||
| 1b3e90b669 | |||
| 55aadb73f1 | |||
| e3d87c70c4 | |||
| 8b1205f79e | |||
| 291f5d247c | |||
| ad63825194 | |||
| b0e0cd107d | |||
| 5f60cd8d4d | |||
| d0e17ccab7 | |||
| 38a4643cf3 | |||
| 938adca022 | |||
| e2ec80134e | |||
| 903f166041 | |||
| a9bdbfda4e | |||
| 378349b870 | |||
| 190ce716ff | |||
| d2c3a87fa8 | |||
| 2d5acbbf45 | |||
| 4e973099f9 | |||
| ee4f43cc59 | |||
| 3e64b7400e | |||
| c44daa759c | |||
| 17c662b10f | |||
| 3cfbb69dd9 | |||
| 470668265b | |||
| b6ced30d70 | |||
| d3e0f1e14d | |||
| 910350ba3a | |||
| 8dcf30e776 | |||
| 30d4bcd6a1 | |||
| 66300cbe70 | |||
| 50ae719f24 | |||
| dccad778fb | |||
| f163e31cd2 | |||
| 5499079ada | |||
| 8d1277db1b | |||
| 34fcac25c2 | |||
| cb0516cae8 | |||
| 4fdad05252 | |||
| dc785b4fe1 | |||
| 8df7e1762a | |||
| 43d9b41648 | |||
| 880559f94a | |||
| 6f04ddce87 | |||
| 6eb065f7c9 | |||
| 17ebad9141 | |||
| 9bcc799b0b | |||
| f247410ae4 | |||
| 2f3bb2ec34 | |||
| 5c47170ef4 | |||
| 29d152b312 | |||
| aa48f0f5c6 | |||
| 05ea683fcf | |||
| 65163a2477 | |||
| 9dc4c46b99 |
@@ -51,3 +51,6 @@ Merged/
|
||||
|
||||
# file from notepad++
|
||||
*.bak
|
||||
|
||||
# file genearated via MC version switching using preprocessor
|
||||
build.properties
|
||||
+238
-90
@@ -3,16 +3,17 @@ image: gradle:eclipse-temurin
|
||||
|
||||
# all stages need to be defined here
|
||||
stages:
|
||||
- gradleSetup
|
||||
- build
|
||||
- merge
|
||||
- build_19_4
|
||||
- build_19_3
|
||||
- build_19_2
|
||||
- build_19_1
|
||||
- build_19
|
||||
- build_18_2
|
||||
- build_18_1
|
||||
- build_17_1
|
||||
- build_16_5
|
||||
|
||||
variables:
|
||||
# Disable the Gradle daemon for Continuous Integration servers as correctness
|
||||
# is usually a priority over speed in CI environments. Using a fresh
|
||||
# runtime for each build is more reliable since the runtime is completely
|
||||
# isolated from any previous builds.
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
# Pull core when building
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
|
||||
@@ -24,90 +25,236 @@ before_script:
|
||||
|
||||
|
||||
|
||||
# 1.16.5 build
|
||||
build_16_5:
|
||||
stage: build_16_5
|
||||
script:
|
||||
- echo "Building 1.16.5..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.16.5" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_16_5-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# first stage
|
||||
# This prevents us from re-downloading Gradle every stage
|
||||
gradleSetup:
|
||||
stage: gradleSetup
|
||||
script: ./gradlew --build-cache --gradle-user-home cache/ check
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- gradle/wrapper/gradle-wrapper.properties
|
||||
policy: push
|
||||
paths:
|
||||
- cache/
|
||||
# 1.17.1 build
|
||||
build_17_1:
|
||||
stage: build_17_1
|
||||
script:
|
||||
- echo "Building 1.17.1..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.17.7" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.17.1" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_17_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
# even if one build fails, upload the successful jars
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.1 build
|
||||
build_18_1:
|
||||
stage: build_18_1
|
||||
script:
|
||||
- echo "Building 1.18.1..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.18.1" --gradle-user-home cache/; # make sure any previously merged jars are removed before running this job
|
||||
- ./gradlew clean -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.18.1" --gradle-user-home cache/;
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.18.2 build
|
||||
build_18_2:
|
||||
stage: build_18_2
|
||||
script:
|
||||
- echo "Building 1.18.2..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.18.2" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19 build
|
||||
build_19:
|
||||
stage: build_19
|
||||
script:
|
||||
- echo "Building 1.19..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.19" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.19" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.19" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.19" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19.1 build
|
||||
build_19_1:
|
||||
stage: build_19_1
|
||||
script:
|
||||
- echo "Building 1.19.1..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.19.1" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.19.1" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.19.1" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19.1" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.19.1" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19_1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19.2 build
|
||||
build_19_2:
|
||||
stage: build_19_2
|
||||
script:
|
||||
- echo "Building 1.19.2..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.19.2" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.19.2" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.19.2" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19.2" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.19.2" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19.3 build
|
||||
build_19_3:
|
||||
stage: build_19_3
|
||||
script:
|
||||
- echo "Building 1.19.3..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.19.3" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.19.3" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.19.3" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19.3" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.19.3" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19_3-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
# 1.19.4 build
|
||||
build_19_4:
|
||||
stage: build_19_4
|
||||
script:
|
||||
- echo "Building 1.19.4..."
|
||||
- ./gradlew deleteMerged -PmcVer="1.19.4" --gradle-user-home cache/;
|
||||
- ./gradlew clean -PmcVer="1.19.4" --gradle-user-home cache/;
|
||||
- ./gradlew core:build -PmcVer="1.19.4" --gradle-user-home cache/;
|
||||
- ./gradlew build -PmcVer="1.19.4" --gradle-user-home cache/;
|
||||
- ./gradlew mergeJars -PmcVer="1.19.4" --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild_1_19_4-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
|
||||
|
||||
# second stage
|
||||
build:
|
||||
stage: build
|
||||
script: ./gradlew build --gradle-user-home cache/
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .architectury-transformer
|
||||
- .gradle
|
||||
- build
|
||||
- common/.gradle
|
||||
- common/build
|
||||
- core/.gradle
|
||||
- core/build
|
||||
- fabric/.gradle
|
||||
- fabric/src/generated
|
||||
- forge/.gradle
|
||||
- forge/src/generated
|
||||
- build
|
||||
- .gradle
|
||||
- cache/
|
||||
artifacts:
|
||||
name: "NightlyBuild-$CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- fabric/build/libs
|
||||
- forge/build/libs
|
||||
exclude:
|
||||
- fabric/build/libs/*-dev.jar
|
||||
- fabric/build/libs/*-dev-shadow.jar
|
||||
- fabric/build/libs/*-sources-dev.jar
|
||||
- fabric/build/libs/*-sources.jar
|
||||
- forge/build/libs/*-dev.jar
|
||||
- forge/build/libs/*-dev-shadow.jar
|
||||
- forge/build/libs/*-sources-dev.jar
|
||||
- forge/build/libs/*-sources.jar
|
||||
reports:
|
||||
# To ensure we've access to these files in the next stage
|
||||
dotenv: generate_jars.env
|
||||
expire_in: 1 day
|
||||
|
||||
# third stage
|
||||
merge:
|
||||
stage: merge
|
||||
script: ./gradlew merge --gradle-user-home cache/
|
||||
# build using Java 17
|
||||
image: eclipse-temurin:17
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- build
|
||||
- .gradle
|
||||
- cache/
|
||||
artifacts:
|
||||
name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
# relative to the root directory
|
||||
- Merged
|
||||
expire_in: 1 day
|
||||
|
||||
|
||||
## forth stage
|
||||
# unused deployment stage
|
||||
#deploy:
|
||||
# stage: deploy
|
||||
# image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
@@ -129,4 +276,5 @@ merge:
|
||||
# - name: 'Fabric Jars'
|
||||
# url: 'https://gitlab.com/jeseibel/minecraft-lod-mod/cw/-/jobs/${GE_JOB_ID}/artifacts/file/fabric/build/libs'
|
||||
# - name: 'Forge Jars'
|
||||
# url: 'https://gitlab.com/jeseibel/minecraft-lod-mod/cw/-/jobs/${GE_JOB_ID}/artifacts/file/forge/build/libs'
|
||||
# url: 'https://gitlab.com/jeseibel/minecraft-lod-mod/cw/-/jobs/${GE_JOB_ID}/artifacts/file/forge/build/libs'
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
[submodule "core"]
|
||||
path = core
|
||||
url = https://gitlab.com/jeseibel/distant-horizons-core.git
|
||||
branch = main
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.16.5 version
|
||||
|
||||
java_version=8
|
||||
minecraft_version=1.16.5
|
||||
parchment_version=2022.03.06
|
||||
compatible_minecraft_versions=["1.16.4", "1.16.5"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.2
|
||||
fabric_api_version=0.42.0+1.16
|
||||
# Fabric mod versions
|
||||
modmenu_version=1.16.22
|
||||
starlight_version_fabric=
|
||||
phosphor_version_fabric=
|
||||
lithium_version=mc1.16.5-0.6.6
|
||||
sodium_version=3488820
|
||||
iris_version=1.16.x-v1.1.4
|
||||
bclib_version=
|
||||
immersive_portals_version =
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_lithium=0
|
||||
enable_sodium=1
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=36.2.28
|
||||
# Forge mod versions
|
||||
starlight_version_forge=
|
||||
terraforged_version=3285909
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=2
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.17.1 version
|
||||
|
||||
java_version=16
|
||||
minecraft_version=1.17.1
|
||||
parchment_version=2021.12.12
|
||||
compatible_minecraft_versions=["1.17", "1.17.1"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.2
|
||||
fabric_api_version=0.46.1+1.17
|
||||
# Fabric mod versions
|
||||
modmenu_version=2.0.14
|
||||
starlight_version_fabric=3442770
|
||||
phosphor_version_fabric=
|
||||
lithium_version=mc1.17.1-0.7.5
|
||||
sodium_version=3605275
|
||||
iris_version=1.17.x-v1.1.4
|
||||
bclib_version=
|
||||
immersive_portals_version = 0.14-1.17
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_lithium=0
|
||||
enable_sodium=1
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=37.1.1
|
||||
# Forge mod versions
|
||||
starlight_version_forge=3457784
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and dont run
|
||||
# 1 = Can be refranced in code but dosnt run
|
||||
# 2 = Can be refranced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.1 version
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.18.1
|
||||
parchment_version=2022.03.06
|
||||
compatible_minecraft_versions=["1.18", "1.18.1"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.3
|
||||
fabric_api_version=0.46.6+1.18
|
||||
# Fabric mod versions
|
||||
modmenu_version=3.0.1
|
||||
starlight_version_fabric=3554912
|
||||
phosphor_version_fabric=3573395
|
||||
lithium_version=mc1.18.1-0.7.7
|
||||
sodium_version=3605309
|
||||
iris_version=1.18.x-v1.1.4
|
||||
bclib_version=1.2.5
|
||||
immersive_portals_version = v1.0.4-1.18
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=39.1.2
|
||||
# Forge mod versions
|
||||
starlight_version_forge=3559934
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Dont enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.18.2
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.18.2"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.13.3
|
||||
fabric_api_version=0.48.0+1.18.2
|
||||
# Fabric mod versions
|
||||
modmenu_version=3.1.0
|
||||
starlight_version_fabric=3667443
|
||||
phosphor_version_fabric=3573395
|
||||
lithium_version=mc1.18.2-0.7.9
|
||||
sodium_version=3669187
|
||||
iris_version=1.18.x-v1.2.2
|
||||
immersive_portals_version = v1.0.4-1.18
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=40.0.18
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.19.1
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.19", "1.19.1"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.8
|
||||
fabric_api_version=0.58.5+1.19.1
|
||||
# Fabric mod versions
|
||||
modmenu_version=4.0.0
|
||||
starlight_version_fabric=0
|
||||
phosphor_version_fabric=0
|
||||
lithium_version=0
|
||||
sodium_version=3820973
|
||||
iris_version=1.19.x-v1.2.6
|
||||
immersive_portals_version = 0
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=42.0.0
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.19.2
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.19.2"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.8
|
||||
fabric_api_version=0.58.5+1.19.1
|
||||
# Fabric mod versions
|
||||
modmenu_version=4.0.0
|
||||
starlight_version_fabric=0
|
||||
phosphor_version_fabric=0
|
||||
lithium_version=0
|
||||
sodium_version=3820973
|
||||
iris_version=1.19.x-v1.2.6
|
||||
immersive_portals_version = 0
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=43.0.0
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.19.3
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.19.3"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.11
|
||||
fabric_api_version=0.68.1+1.19.3
|
||||
# Fabric mod versions
|
||||
modmenu_version=5.0.2
|
||||
starlight_version_fabric=0
|
||||
phosphor_version_fabric=0
|
||||
lithium_version=0
|
||||
sodium_version=4145281
|
||||
iris_version=1.19.x-v1.2.6
|
||||
immersive_portals_version = 0
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=44.0.6
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.19.4
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.19.4"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.17
|
||||
fabric_api_version=0.75.3+1.19.4
|
||||
# Fabric mod versions
|
||||
modmenu_version=6.1.0-rc.1
|
||||
starlight_version_fabric=0
|
||||
phosphor_version_fabric=0
|
||||
lithium_version=0
|
||||
sodium_version=4145281
|
||||
iris_version=1.19.x-v1.2.6
|
||||
immersive_portals_version = 0
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=45.0.0
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,43 @@
|
||||
# 1.18.2 version based stuff
|
||||
|
||||
java_version = 17
|
||||
minecraft_version=1.19
|
||||
parchment_version=2022.03.13
|
||||
compatible_minecraft_versions=["1.19"]
|
||||
|
||||
# Fabric loader
|
||||
fabric_loader_version=0.14.8
|
||||
fabric_api_version=0.57.0+1.19
|
||||
# Fabric mod versions
|
||||
modmenu_version=4.0.0
|
||||
starlight_version_fabric=0
|
||||
phosphor_version_fabric=0
|
||||
lithium_version=0
|
||||
sodium_version=3820973
|
||||
iris_version=1.19.x-v1.2.6
|
||||
immersive_portals_version = 0
|
||||
bclib_version=0
|
||||
|
||||
# Fabric mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight=0
|
||||
enable_phosphor=0
|
||||
enable_sodium=1
|
||||
enable_lithium=0
|
||||
enable_iris=0
|
||||
enable_bclib=0
|
||||
|
||||
# Forge loader
|
||||
forge_version=41.0.94
|
||||
# Forge mod versions
|
||||
starlight_version_forge=0
|
||||
terraforged_version=
|
||||
|
||||
# Forge mod run
|
||||
# 0 = Don't enable and don't run
|
||||
# 1 = Can be referenced in code but doesn't run
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -1,10 +1,7 @@
|
||||
# THIS VERSION IS NO LONGER MAINTAINED! ALL DEVELOPMENT HAVE BEEN MOVED OVER TO THE MAIN BRANCH
|
||||
|
||||
# <img src="https://gitlab.com/jeseibel/distant-horizons-core/-/raw/main/_logo%20files/LOD%20logo%20flat%20-%20with%20boarder.png" width="32"> Distant Horizons
|
||||
|
||||
> A mod that adds a Level of Detail System to Minecraft
|
||||
|
||||
|
||||
# What is Distant Horizons?
|
||||
|
||||
This mod adds a Level Of Detail (LOD) system to Minecraft.\
|
||||
@@ -14,55 +11,142 @@ allowing for an increased view distance without harming performance.
|
||||
Or in other words: this mod lets you see farther without turning your game into a slide show.\
|
||||
If you want to see a quick demo, check out a video covering the mod here:
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=H2tnvEVbO1c" target="_blank"></a>
|
||||
<a href="https://youtu.be/_04BZ8W2bDM" target="_blank"></a>
|
||||
|
||||
### Versions
|
||||
|
||||
This branch is for these versions of Minecraft
|
||||
- 1.19.3
|
||||
- 1.19.2
|
||||
- 1.19.1 & 1.19
|
||||
- 1.18.2
|
||||
- 1.18.1 & 1.18
|
||||
- 1.17.1 & 1.17
|
||||
- 1.16.5 & 1.16.4
|
||||
|
||||
Architectury version: 3.4-SNAPSHOT\
|
||||
Forge version: 36.2.28\
|
||||
Fabric version: 0.13.2\
|
||||
Fabric API version: 0.42.0+1.16
|
||||
Architectury loom version: 0.12.0-SNAPSHOT\
|
||||
Java Compiler plugin: Manifold Preprocessor
|
||||
|
||||
|
||||
#### 1.19.3 mods
|
||||
Forge version: 44.0.6\
|
||||
Fabric version: 0.14.11\
|
||||
Fabric API version: 0.68.1+1.19.3\
|
||||
Modmenu version: 5.0.2
|
||||
|
||||
#### 1.19.2 mods
|
||||
Forge version: 43.0.0\
|
||||
Fabric version: 0.14.8\
|
||||
Fabric API version: 0.58.5+1.19.1\
|
||||
Modmenu version: 4.0.0
|
||||
|
||||
#### 1.19.1 mods
|
||||
Forge version: 42.0.0\
|
||||
Fabric version: 0.14.8\
|
||||
Fabric API version: 0.58.5+1.19.1\
|
||||
Modmenu version: 4.0.0
|
||||
|
||||
#### 1.18.2 mods
|
||||
Forge version: 40.0.18\
|
||||
Fabric version: 0.13.3\
|
||||
Fabric API version: 0.48.0+1.18.2\
|
||||
Modmenu version: 3.1.0
|
||||
|
||||
#### 1.18.1 mods
|
||||
Forge version: 39.1.2\
|
||||
Fabric version: 0.13.3\
|
||||
Fabric API version: 0.42.6+1.18\
|
||||
Modmenu version: 3.0.1
|
||||
|
||||
#### 1.17.1 mods
|
||||
Forge version: 37.1.1\
|
||||
Fabric version: 0.13.2\
|
||||
Fabric API version: 0.46.1+1.17\
|
||||
Modmenu version: 2.0.14
|
||||
|
||||
#### 1.16.5 mods
|
||||
Forge version: 36.2.28\
|
||||
Fabric vetsion: 0.13.2\
|
||||
Fabric API version: 0.42.0+1.16\
|
||||
Modmenu version: 1.16.22
|
||||
|
||||
|
||||
|
||||
Notes:\
|
||||
This version has been confirmed to work in Eclipse and Retail Minecraft.\
|
||||
(Retail running forge version 1.16.5-36.1.0 and fabric version 1.16.5-0.12.3)
|
||||
This version has been confirmed to work in IDE and Retail Minecraft with ether the Fabric or Forge mod-loader.
|
||||
|
||||
|
||||
## source code installation
|
||||
## Source Code Installation
|
||||
|
||||
See the Forge Documentation online for more detailed instructions:\
|
||||
http://mcforge.readthedocs.io/en/latest/gettingstarted/
|
||||
#### Nightlly builds
|
||||
This mod has an autobuild system to automatically build the mod on each commit
|
||||
- 1.19.1: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_19_1
|
||||
- 1.19: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_19
|
||||
- 1.18.2: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_18_2
|
||||
- 1.18.1: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_18_1
|
||||
- 1.17.1: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_17_1
|
||||
- 1.16.5: https://gitlab.com/jeseibel/minecraft-lod-mod/-/jobs/artifacts/1.6.4a_dev/download?job=build_16_5
|
||||
|
||||
See the Fabric Documentation online for more detailed instructions:\
|
||||
https://fabricmc.net/wiki/tutorial:setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* A Java Development Kit (JDK) for Java 16 (recommended) or newer. Visit https://www.oracle.com/java/technologies/downloads/ for installers.
|
||||
* A Java Development Kit (JDK) for Java 17 (recommended) or newer. Visit https://www.oracle.com/java/technologies/downloads/ for installers.
|
||||
* Git or someway to clone git projects. Visit https://git-scm.com/ for installers.
|
||||
* (Not required) Any Java IDE, for example Intellij IDEA and Eclipse. You may also use any other code editors, such as Visual Studio Code. (Optional)
|
||||
It's better to use IntelliJ IDEA since Eclipse is not supported by Architectury, but it still works.
|
||||
* (Not required) Any Java IDE with plugins that support Manifold, for example Intellij IDEA.
|
||||
|
||||
**If using IntelliJ:**
|
||||
0. Install Manifold plugin
|
||||
1. open IDEA and import the build.gradle
|
||||
2. refresh the Gradle project in IDEA if required
|
||||
|
||||
**If using Ecplise:**
|
||||
Not supported...
|
||||
**If using Ecplise: (Note that Eclispe currently doesn't support Manifold's preprocessor!)**
|
||||
1. run the command: `./gradlew geneclipseruns`
|
||||
2. run the command: `./gradlew eclipse`
|
||||
3. Make sure eclipse has the JDK 17 installed. (This is needed so that eclipse can run minecraft)
|
||||
4. Import the project into eclipse
|
||||
|
||||
Side note: invalidate caches and restart if required
|
||||
## Switching Versions
|
||||
This branch support 6 built versions:
|
||||
- 1.19.1
|
||||
- 1.19
|
||||
- 1.18.2
|
||||
- 1.18.1 (which also runs on 1.18)
|
||||
- 1.17.1 (which also runs on 1.17)
|
||||
- 1.16.5 (which also runs 1.16.4)
|
||||
|
||||
To switch between active versions, change `mcVer=1.?` in `gradle.properties` file.
|
||||
|
||||
If running on IDE, to ensure IDE pickup the changed versions, you will need to run a gradle command again to allow gradle to update all the libs. (In IntellJ you will also need to do a gradle sync again if it didn't start it automatically.)
|
||||
>Note: There may be a `java.nio.file.FileSystemException` thrown on running the command after switching versions. To fix it, either restart your IDE (as your IDE is locking up a file) or use tools like LockHunter to unlock the linked file. (Often a lib file under `common\build\lib` or `forge\build\lib` or `fabric\build\lib`). If anyone knows how to solve this issue please comment to this issue: https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233
|
||||
|
||||
## Compiling
|
||||
|
||||
**Using GUI**
|
||||
1. Open a command line in the project folder
|
||||
2. Run the command: `./gradlew build`
|
||||
1. Download the zip of the project and extract it
|
||||
2. Download the core from https://gitlab.com/jeseibel/distant-horizons-core and extract into a folder called `core`
|
||||
3. Open a command line in the project folder
|
||||
4. Run the command: `./gradlew assemble`
|
||||
5. Then run command: `./gradlew mergeJars`
|
||||
6. The compiled jar file will be in the folder `Merged`
|
||||
|
||||
**If in terminal:**
|
||||
1. `git clone -b 1.16.5_architectury --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
1. `git clone -b 1.6.4a_dev --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git`
|
||||
2. `cd minecraft-lod-mod`
|
||||
3. `./gradlew assemble`
|
||||
5. `./gradlew mergeJars`
|
||||
6. The compiled jar file will be in the folder `Merged`
|
||||
4. `./gradlew mergeJars`
|
||||
5. The compiled jar file will be in the folder `Merged`
|
||||
> ### **WARNING:** Due to a bug at the moment, the merged jar does not contain the core.
|
||||
> To add the core follow the steps below
|
||||
> 1. Go into `core/build/libs` and extract the jar with the smallest name
|
||||
> 2. In that extracted folder, copy the folder called `com`
|
||||
> 3. Go into the `Merged` folder and extract the jar in that
|
||||
> 4. Paste in the folder which you copied from step 2 into the newly extracted jar
|
||||
> 5. Zip all the files that were extracted and make sure the file extension is .jar
|
||||
|
||||
>Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file.
|
||||
|
||||
|
||||
## Other commands
|
||||
@@ -76,15 +160,19 @@ Side note: invalidate caches and restart if required
|
||||
|
||||
The Minecraft source code is NOT added to your workspace in an editable way. Minecraft is treated like a normal Library. Sources are there for documentation and research purposes only.
|
||||
|
||||
Source code uses Mojang mappings.
|
||||
Source code uses Mojang mappings & [Parchment](https://parchmentmc.org/) mappings.
|
||||
|
||||
To generate the source code run `./gradlew genSources`\
|
||||
If your IDE fails to auto-detect the sources JAR when browsing Minecraft classes manually select the JAR file ending with -sources.jar when prompted by your IDE
|
||||
|
||||
In IntelliJ it's at the top where it says choose sources when browsing Minecraft classes
|
||||
|
||||
## Useful commands
|
||||
|
||||
Build only Fabric: `./gradlew fabric:assemble` or `./gradlew fabric:build`\
|
||||
Build only Forge: `./gradlew fabric:assemble` or `./gradlew forge:build`\
|
||||
Run the Fabric client (for debugging): `./gradlew fabric:runClient`\
|
||||
Run the Forge client (**THIS DOST WORK** due to a bug with architectury): `./gradlew forge:runClient`\
|
||||
To use a custom version of Java use `-D` then the path for Java
|
||||
Run the Forge client (for debugging): `./gradlew forge:runClient`
|
||||
|
||||
## Open Source Acknowledgements
|
||||
|
||||
|
||||
+374
-116
@@ -8,150 +8,408 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: JarMergerPlugin
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version
|
||||
group = rootProject.maven_group
|
||||
|
||||
task printConfigurations {
|
||||
doLast {task ->
|
||||
println "Project Name: $name configurations:"
|
||||
configurations.each {
|
||||
println " $it.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
|
||||
ArrayList<String> redefineList = new ArrayList<String>()
|
||||
for (int i=0; i<mcVers.size(); i++) {
|
||||
String mcStr = mcVers.get(i).replace(".", "_")
|
||||
if (mcIndex<i) {
|
||||
redefineList.add("PRE_MC_"+mcStr)
|
||||
}
|
||||
if (mcIndex==i) {
|
||||
redefineList.add("MC_"+mcStr)
|
||||
}
|
||||
if (mcIndex>=i) {
|
||||
redefineList.add("POST_MC_"+mcStr)
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder()
|
||||
for (String s : redefineList) {
|
||||
sb.append(s)
|
||||
sb.append("=\n")
|
||||
}
|
||||
new File(projectDir, "build.properties").text = sb.toString()
|
||||
}
|
||||
|
||||
// Sets up the variables for Manifold in the code
|
||||
def loadProperties() {
|
||||
def defaultMcVersion = "1.19.2"
|
||||
def mcVersion = ""
|
||||
def mcVers = mcVersions.split(",")
|
||||
int mcIndex = -1
|
||||
println "Avalible MC versions: ${mcVersions}"
|
||||
if (project.hasProperty("mcVer")) {
|
||||
mcVersion = mcVer
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(mcVer)
|
||||
}
|
||||
if (mcIndex == -1) {
|
||||
println "No mcVer set or the set mcVer is invalid! Defaulting to ${defaultMcVersion}."
|
||||
println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer."
|
||||
mcVersion = defaultMcVersion
|
||||
mcIndex = Arrays.asList(mcVers).indexOf(defaultMcVersion)
|
||||
assert mcIndex != -1
|
||||
}
|
||||
|
||||
println "Loading properties file at " + mcVersion + ".properties"
|
||||
def props = new Properties()
|
||||
props.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties"))
|
||||
|
||||
props.each { prop ->
|
||||
rootProject.ext.set(prop.key, prop.value)
|
||||
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
|
||||
}
|
||||
writeBuildGradlePredefine(Arrays.asList(mcVers), mcIndex)
|
||||
|
||||
// Stuff for access wideners
|
||||
def mcVersionToAcsessWidenerVersion = [
|
||||
"1.16.5": "1_16",
|
||||
"1.17.1": "1_17",
|
||||
"1.18.1": "1_18",
|
||||
"1.18.2": "1_18",
|
||||
"1.19" : "1_19",
|
||||
"1.19.1" : "1_19",
|
||||
"1.19.2" : "1_19",
|
||||
"1.19.3" : "1_19_3",
|
||||
"1.19.4" : "1_19_3"
|
||||
]
|
||||
// Use this as sometimes multiple versions use the same access wideners
|
||||
rootProject.ext.set("acsessWidenerVersion", mcVersionToAcsessWidenerVersion.get(mcVersion))
|
||||
}
|
||||
loadProperties()
|
||||
|
||||
architectury {
|
||||
minecraft = rootProject.minecraft_version
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file("build/resources/main"))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
//runClient.enabled = false
|
||||
//runServer.enabled = false
|
||||
|
||||
// this deletes the merged folder so we don't carry over
|
||||
// the previous merges to each new build job in the CI/CD pipeline
|
||||
task deleteMerged(type: Delete) {
|
||||
delete files("./Merged")
|
||||
}
|
||||
|
||||
|
||||
// ===============================CORE Gradle basically================================
|
||||
subprojects { p ->
|
||||
apply plugin: "dev.architectury.loom"
|
||||
if (p == project(":core")) {
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowMe
|
||||
implementation.extendsFrom shadowMe
|
||||
}
|
||||
p.archivesBaseName = rootProject.archives_base_name
|
||||
p.version = rootProject.mod_version
|
||||
p.group = rootProject.maven_group
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings
|
||||
mappings loom.officialMojangMappings()
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
configurations {
|
||||
common
|
||||
shadowMe
|
||||
implementation.extendsFrom shadowMe
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
if (
|
||||
rootProject.minecraft_version != "1.19"
|
||||
&& rootProject.minecraft_version != "1.19.1"
|
||||
&& rootProject.minecraft_version != "1.19.2"
|
||||
&& rootProject.minecraft_version != "1.19.3"
|
||||
&& rootProject.minecraft_version != "1.19.4"
|
||||
) // We are not gonna use this build script anymore so dont bother fixing this
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
else
|
||||
parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19.x or higher doesnt have parchment mappings yet, we use 1.18.2 mapping
|
||||
// Note: parchment may have later mappings at the time you are reading this, but at the time this was written, it didnt
|
||||
// Check the main branch for the new build system, with the working mappings
|
||||
}
|
||||
|
||||
//Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
|
||||
if (p != project(":forge")) {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader unless working with fabric
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
}
|
||||
|
||||
|
||||
if (p != project(":core")) {
|
||||
common(project(":core")) { transitive false }
|
||||
shadowMe(project(":core")) { transitive false }
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version
|
||||
group = rootProject.maven_group
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
// Allows the jar to run standalone
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain'
|
||||
// When changing the main of the jar change this line
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version: mod_version,
|
||||
mod_name: mod_name,
|
||||
authors: mod_authors,
|
||||
description: mod_description,
|
||||
homepage: mod_homepage,
|
||||
source: mod_source,
|
||||
issues: mod_issues
|
||||
] // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
task printConfigurations {
|
||||
doLast {task ->
|
||||
println "Project Name: $p.name configurations:"
|
||||
configurations.each {
|
||||
println " $it.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||
def targetVersion = 8
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
options.release = targetVersion
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file(p.file("build/resources/main")))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into p.file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into p.file("build/resources/main")
|
||||
}
|
||||
|
||||
p.tasks.withType(JavaCompile) {
|
||||
// Add Manifold Preprocessor
|
||||
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
||||
//
|
||||
//options.compilerArgs += ['-deprecation']
|
||||
//options.compilerArgs += ['-verbose']
|
||||
//options.compilerArgs += ['-Xlint:unchecked']
|
||||
//options.compilerArgs += ['-Xdiags:verbose']
|
||||
//options.compilerArgs += ['-Xprint']
|
||||
//options.compilerArgs += ['-XprintProcessorInfo']
|
||||
//options.compilerArgs += ['-XprintRounds']
|
||||
|
||||
// println options.compilerArgs
|
||||
|
||||
// Set the java version
|
||||
options.release = 8; // Core should use Java 8 no matter what
|
||||
// TODO: make everything use java 8
|
||||
// options.release = 8 // Use Java 8 for everything so back porting is easier
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
p.runClient.enabled = false
|
||||
p.runServer.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
+207
-10
@@ -1,16 +1,72 @@
|
||||
loom {
|
||||
accessWidenerPath.set(file("src/main/resources/lod.accesswidener"))
|
||||
}
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version
|
||||
group = rootProject.maven_group
|
||||
|
||||
architectury {
|
||||
common()
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks {
|
||||
remapJar {
|
||||
remapAccessWidener.set(false)
|
||||
}
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener"))
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowMe
|
||||
implementation.extendsFrom shadowMe
|
||||
}
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
if (
|
||||
rootProject.minecraft_version != "1.19"
|
||||
&& rootProject.minecraft_version != "1.19.1"
|
||||
&& rootProject.minecraft_version != "1.19.2"
|
||||
&& rootProject.minecraft_version != "1.19.3"
|
||||
&& rootProject.minecraft_version != "1.19.4"
|
||||
) // We are not gonna use this build script anymore so dont bother fixing this
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
else
|
||||
parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19.x or higher doesnt have parchment mappings yet, we use 1.18.2 mapping
|
||||
// Note: parchment may have later mappings at the time you are reading this, but at the time this was written, it didnt
|
||||
// Check the main branch for the new build system, with the working mappings
|
||||
}
|
||||
|
||||
//Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader unless working with fabric
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"\
|
||||
|
||||
common(project(":core")) { transitive false }
|
||||
shadowMe(project(":core")) { transitive false }
|
||||
}
|
||||
|
||||
// Allows the jar to run standalone
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +82,145 @@ publishing {
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task printConfigurations {
|
||||
doLast {task ->
|
||||
println "Project Name: $name configurations:"
|
||||
configurations.each {
|
||||
println " $it.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file("build/resources/main"))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
processResources {
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println "Copying [common/src/main/resources/${acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]."
|
||||
copy {
|
||||
from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")
|
||||
into project(":fabric").file("build/resources/main")
|
||||
rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
// Add Manifold Preprocessor
|
||||
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
||||
//
|
||||
//options.compilerArgs += ['-deprecation']
|
||||
//options.compilerArgs += ['-verbose']
|
||||
//options.compilerArgs += ['-Xlint:unchecked']
|
||||
//options.compilerArgs += ['-Xdiags:verbose']
|
||||
//options.compilerArgs += ['-Xprint']
|
||||
//options.compilerArgs += ['-XprintProcessorInfo']
|
||||
//options.compilerArgs += ['-XprintRounds']
|
||||
|
||||
// println options.compilerArgs
|
||||
|
||||
// Set the java version
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
options.release = rootProject.java_version as Integer
|
||||
// TODO: make everything use java 8
|
||||
// options.release = 8 // Use Java 8 for everything so back porting is easier
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
}
|
||||
|
||||
runClient.enabled = false
|
||||
runServer.enabled = false
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,23 +19,27 @@
|
||||
|
||||
package com.seibel.lod.common;
|
||||
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
import com.seibel.lod.core.config.*;
|
||||
import com.seibel.lod.core.enums.config.*;
|
||||
import com.seibel.lod.core.enums.rendering.*;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog.IHeightFog;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer;
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.*;
|
||||
|
||||
|
||||
/**
|
||||
* This handles any configuration the user has access to.
|
||||
* @author coolGi2007
|
||||
* @author coolGi
|
||||
* @version 12-12-2021
|
||||
*/
|
||||
public class Config extends ConfigGui
|
||||
|
||||
public class Config
|
||||
//public class Config extends TinyConfig
|
||||
{
|
||||
// CONFIG STRUCTURE
|
||||
@@ -52,12 +56,12 @@ public class Config extends ConfigGui
|
||||
// |-> Threads
|
||||
// |-> Buffers
|
||||
// |-> Debugging
|
||||
|
||||
|
||||
// Since the original config system uses forge stuff, that means we have to rewrite the whole config system
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Client client;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _optionsButton = ILodConfigWrapperSingleton.IClient.OPTIONS_BUTTON_DESC;
|
||||
// I know this option should be in Client
|
||||
@@ -65,108 +69,231 @@ public class Config extends ConfigGui
|
||||
// Tough it is in client in the wrapper singleton
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean optionsButton = true;
|
||||
|
||||
|
||||
public static class Client
|
||||
{
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Graphics graphics;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static WorldGenerator worldGenerator;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Multiplayer multiplayer;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Advanced advanced;
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Graphics
|
||||
{
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Quality quality;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static FogQuality fogQuality;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static AdvancedGraphics advancedGraphics;
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Quality
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _drawResolution = IQuality.DRAW_RESOLUTION_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static HorizontalResolution drawResolution = IQuality.DRAW_RESOLUTION_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 16, maxValue = 2048)
|
||||
@ConfigAnnotations.Entry(minValue = 32, maxValue = 2048)
|
||||
public static int lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _verticalQuality = IQuality.VERTICAL_QUALITY_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static VerticalQuality verticalQuality = IQuality.VERTICAL_QUALITY_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _horizontalScale = IQuality.HORIZONTAL_SCALE_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 2, maxValue = 32)
|
||||
@ConfigAnnotations.Entry(minValue = 2, maxValue = 64)
|
||||
public static int horizontalScale = IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _horizontalQuality = IQuality.HORIZONTAL_SCALE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static HorizontalQuality horizontalQuality = IQuality.HORIZONTAL_QUALITY_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _dropoffQuality = IQuality.DROPOFF_QUALITY_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static DropoffQuality dropoffQuality = IQuality.DROPOFF_QUALITY_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0, maxValue = 7)
|
||||
public static int lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_MIN_DEFAULT_MAX.defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class FogQuality
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _fogDistance = IFogQuality.FOG_DISTANCE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static FogDistance fogDistance = IFogQuality.FOG_DISTANCE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _fogDrawMode = IFogQuality.FOG_DRAW_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static FogDrawMode fogDrawMode = IFogQuality.FOG_DRAW_MODE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _fogColorMode = IFogQuality.FOG_COLOR_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static FogColorMode fogColorMode = IFogQuality.FOG_COLOR_MODE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static AdvancedFog advancedFog;
|
||||
|
||||
public static class AdvancedFog {
|
||||
static final double SQRT2 = 1.4142135623730951;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogStart = IAdvancedFog.FAR_FOG_START_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2)
|
||||
public static double farFogStart = IAdvancedFog.FAR_FOG_START_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogEnd = IAdvancedFog.FAR_FOG_END_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2)
|
||||
public static double farFogEnd = IAdvancedFog.FAR_FOG_END_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogMin = IAdvancedFog.FAR_FOG_MIN_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2)
|
||||
public static double farFogMin = IAdvancedFog.FAR_FOG_MIN_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogMax = IAdvancedFog.FAR_FOG_MAX_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0)
|
||||
public static double farFogMax = IAdvancedFog.FAR_FOG_MAX_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogType = IAdvancedFog.FAR_FOG_TYPE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static FogSetting.FogType farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0)
|
||||
public static double farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static HeightFog heightFog;
|
||||
|
||||
public static class HeightFog {
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static HeightFogMixMode heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DEFAULT;
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static HeightFogMode heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = -4096.0, maxValue = 4096.0)
|
||||
public static double heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogStart = IHeightFog.HEIGHT_FOG_START_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2)
|
||||
public static double heightFogStart = IHeightFog.HEIGHT_FOG_START_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogEnd = IHeightFog.HEIGHT_FOG_END_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2)
|
||||
public static double heightFogEnd = IHeightFog.HEIGHT_FOG_END_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogMin = IHeightFog.HEIGHT_FOG_MIN_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2)
|
||||
public static double heightFogMin = IHeightFog.HEIGHT_FOG_MIN_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogMax = IHeightFog.HEIGHT_FOG_MAX_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0)
|
||||
public static double heightFogMax = IHeightFog.HEIGHT_FOG_MAX_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static FogSetting.FogType heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0)
|
||||
public static double heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class AdvancedGraphics
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static VanillaOverdraw vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _overdrawOffset = IAdvancedGraphics.OVERDRAW_OFFSET_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = -16, maxValue = 16)
|
||||
public static int overdrawOffset = IAdvancedGraphics.OVERDRAW_OFFSET_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _enableCaveCulling = IAdvancedGraphics.ENABLE_CAVE_CULLING_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean enableCaveCulling = IAdvancedGraphics.ENABLE_CAVE_CULLING_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _caveCullingHeight = IAdvancedGraphics.CAVE_CULLING_HEIGHT_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = -4096, maxValue = 4096)
|
||||
public static int caveCullingHeight = IAdvancedGraphics.CAVE_CULLING_HEIGHT_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _earthCurveRatio = IAdvancedGraphics.EARTH_CURVE_RATIO_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0, maxValue = 5000)
|
||||
public static int earthCurveRatio = IAdvancedGraphics.EARTH_CURVE_RATIO_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
/*
|
||||
@ConfigAnnotations.FileComment
|
||||
@@ -176,107 +303,175 @@ public class Config extends ConfigGui
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class WorldGenerator
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DEFAULT;
|
||||
|
||||
|
||||
// @ConfigAnnotations.FileComment
|
||||
// public static String _distanceGenerationMode = IWorldGenerator.getDistanceGenerationModeDesc();
|
||||
@ConfigAnnotations.Entry
|
||||
public static DistanceGenerationMode distanceGenerationMode = IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _lightGenerationMode = IWorldGenerator.LIGHT_GENERATION_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LightGenerationMode lightGenerationMode = IWorldGenerator.LIGHT_GENERATION_MODE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _generationPriority = IWorldGenerator.GENERATION_PRIORITY_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static GenerationPriority generationPriority = IWorldGenerator.GENERATION_PRIORITY_DEFAULT;
|
||||
|
||||
/*
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _allowUnstableFeatureGeneration = IWorldGenerator.ALLOW_UNSTABLE_FEATURE_GENERATION_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean allowUnstableFeatureGeneration = IWorldGenerator.ALLOW_UNSTABLE_FEATURE_GENERATION_DEFAULT;
|
||||
*/
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT;
|
||||
}
|
||||
|
||||
public static class Multiplayer {
|
||||
|
||||
|
||||
public static class Multiplayer
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static ServerFolderNameMode serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0.0, maxValue = 1.0)
|
||||
public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_MIN_DEFAULT_MAX.defaultValue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class Advanced
|
||||
{
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Threading threading;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Debugging debugging;
|
||||
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static Buffers buffers;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _lodOnlyMode = IAdvanced.LOD_ONLY_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean lodOnlyMode = IAdvanced.LOD_ONLY_MODE_DEFAULT;
|
||||
|
||||
|
||||
public static class Threading
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 1, maxValue = 50)
|
||||
public static int numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue;
|
||||
|
||||
@ConfigAnnotations.Entry(minValue = 0.1, maxValue = 50.0)
|
||||
public static double numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 1, maxValue = 50)
|
||||
public static int numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Debugging
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _drawLods = IDebugging.DRAW_LODS_DESC;
|
||||
public static String _rendererType = IDebugging.RENDERER_TYPE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean drawLods = IDebugging.DRAW_LODS_DEFAULT;
|
||||
|
||||
public static RendererType rendererType = IDebugging.RENDERER_TYPE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _debugMode = IDebugging.DEBUG_MODE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static DebugMode debugMode = IDebugging.DEBUG_MODE_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static boolean enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.ScreenEntry
|
||||
public static DebugSwitch debugSwitch;
|
||||
|
||||
public static class DebugSwitch {
|
||||
/* The logging switches available:
|
||||
* WorldGenEvent
|
||||
* WorldGenPerformance
|
||||
* WorldGenLoadEvent
|
||||
* LodBuilderEvent
|
||||
* RendererBufferEvent
|
||||
* RendererGLEvent
|
||||
* FileReadWriteEvent
|
||||
* FileSubDimEvent
|
||||
* NetworkEvent //NOT IMPL YET
|
||||
*/
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logWorldGenEvent = IDebugSwitch.LOG_WORLDGEN_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logWorldGenEvent = IDebugSwitch.LOG_WORLDGEN_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logWorldGenPerformance = IDebugSwitch.LOG_WORLDGEN_PERFORMANCE_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logWorldGenPerformance = IDebugSwitch.LOG_WORLDGEN_PERFORMANCE_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logWorldGenLoadEvent = IDebugSwitch.LOG_WORLDGEN_LOAD_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logWorldGenLoadEvent = IDebugSwitch.LOG_WORLDGEN_LOAD_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logLodBuilderEvent = IDebugSwitch.LOG_LODBUILDER_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logLodBuilderEvent = IDebugSwitch.LOG_LODBUILDER_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logRendererBufferEvent = IDebugSwitch.LOG_RENDERER_BUFFER_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logRendererBufferEvent = IDebugSwitch.LOG_RENDERER_BUFFER_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logRendererGLEvent = IDebugSwitch.LOG_RENDERER_GL_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logRendererGLEvent = IDebugSwitch.LOG_RENDERER_GL_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logFileReadWriteEvent = IDebugSwitch.LOG_FILE_READWRITE_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logFileReadWriteEvent = IDebugSwitch.LOG_FILE_READWRITE_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logFileSubDimEvent = IDebugSwitch.LOG_FILE_SUB_DIM_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logFileSubDimEvent = IDebugSwitch.LOG_FILE_SUB_DIM_EVENT_DEFAULT;
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _logNetworkEvent = IDebugSwitch.LOG_NETWORK_EVENT_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static LoggerMode logNetworkEvent = IDebugSwitch.LOG_NETWORK_EVENT_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Buffers
|
||||
{
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
public static GpuUploadMethod gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DEFAULT;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DESC;
|
||||
@ConfigAnnotations.Entry(minValue = 0, maxValue = 50)
|
||||
public static int gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.defaultValue;
|
||||
|
||||
|
||||
@ConfigAnnotations.FileComment
|
||||
public static String _rebuildTimes = IBuffers.REBUILD_TIMES_DESC;
|
||||
@ConfigAnnotations.Entry
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common;
|
||||
|
||||
import com.seibel.lod.common.forge.LodForgeMethodCaller;
|
||||
import com.seibel.lod.common.networking.NetworkInterface;
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
|
||||
/**
|
||||
* This is the common main class
|
||||
@@ -14,7 +32,6 @@ public class LodCommonMain {
|
||||
public static boolean forge = false;
|
||||
public static boolean serverSided;
|
||||
public static LodForgeMethodCaller forgeMethodCaller;
|
||||
public static NetworkInterface networkInterface;
|
||||
|
||||
public static void startup(LodForgeMethodCaller caller, boolean serverSided) {
|
||||
LodCommonMain.serverSided = serverSided;
|
||||
@@ -26,11 +43,8 @@ public class LodCommonMain {
|
||||
DependencySetup.createInitialBindings();
|
||||
}
|
||||
|
||||
|
||||
public static void initConfig() {
|
||||
ConfigGui.init(Config.class);
|
||||
}
|
||||
|
||||
public static void registerNetworking(NetworkInterface networkInterface) {
|
||||
LodCommonMain.networkInterface = networkInterface;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.forge;
|
||||
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.core.Direction;
|
||||
#if POST_MC_1_19
|
||||
import net.minecraft.util.RandomSource;
|
||||
#endif
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@@ -15,5 +39,11 @@ import java.util.Random;
|
||||
* @author Ran
|
||||
*/
|
||||
public interface LodForgeMethodCaller {
|
||||
List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random);
|
||||
#if PRE_MC_1_19
|
||||
List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random); // FIXME: For 1.19
|
||||
#else
|
||||
List<BakedQuad> getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, RandomSource random); // FIXME: For 1.19
|
||||
#endif
|
||||
|
||||
int colorResolverGetColor(ColorResolver resolver, Biome biome, double x, double z);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
|
||||
/**
|
||||
* This is packet handler for our mod
|
||||
* It basically handles the packets sent from the server & client
|
||||
*
|
||||
* @author Ran
|
||||
*/
|
||||
public class NetworkHandler {
|
||||
// If you need the response sender then tell me
|
||||
// I'll add extra code to get the response sender
|
||||
public static void receivePacketClient(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf) {
|
||||
// TODO: Server sided stuff here
|
||||
// You can make client execute something by using client.execute(Runnable)
|
||||
// In the fabric docs it says that client.execute is ran on the render thread?
|
||||
}
|
||||
|
||||
// If you need the response sender then tell me
|
||||
// I'll add extra code to get the response sender
|
||||
public static void receivePacketServer(MinecraftServer server, ServerPlayer client, ServerGamePacketListenerImpl handler, FriendlyByteBuf buf) {
|
||||
// TODO: Server sided stuff here
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
/**
|
||||
* @author Ran
|
||||
*/
|
||||
public interface NetworkInterface {
|
||||
void send(FriendlyByteBuf packetByteBuf);
|
||||
|
||||
FriendlyByteBuf receive();
|
||||
void register_Client();
|
||||
void register_Server();
|
||||
}
|
||||
|
||||
@@ -1,23 +1,119 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.networking;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class holds most of the networking code for the mod.
|
||||
* @author Ran
|
||||
*/
|
||||
public class Networking {
|
||||
// public void example(int packetId) {
|
||||
// FriendlyByteBuf packetByteBuf = Networking.createNew();
|
||||
// packetByteBuf.writeInt(packetId);
|
||||
// LodCommonMain.networkInterface.send(packetByteBuf);
|
||||
// }
|
||||
public static final ResourceLocation resourceLocation_meow = new ResourceLocation("lod", "meow");
|
||||
|
||||
public static FriendlyByteBuf createNew() {
|
||||
return new FriendlyByteBuf(Unpooled.buffer());
|
||||
// TODO: Probably replace the Unpooled.buffer()
|
||||
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
buf.writeInt(ModInfo.PROTOCOL_VERSION);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* All code below is from the fabric api and might have been modified to work with Distant Horizons
|
||||
* Which is licensed under the Apache License 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sends a packet to a player.
|
||||
*
|
||||
* @param player the player to send the packet to
|
||||
* @param buf the payload of the packet.
|
||||
*/
|
||||
public static void send(ServerPlayer player, FriendlyByteBuf buf) {
|
||||
Objects.requireNonNull(player, "Server player entity cannot be null");
|
||||
Objects.requireNonNull(resourceLocation_meow, "Channel name cannot be null");
|
||||
Objects.requireNonNull(buf, "Packet byte buf cannot be null");
|
||||
|
||||
player.connection.send(createS2CPacket(resourceLocation_meow, buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet to the connected server.
|
||||
*
|
||||
* @param buf the payload of the packet
|
||||
* @throws IllegalStateException if the client is not connected to a server
|
||||
*/
|
||||
public static void send(FriendlyByteBuf buf) throws IllegalStateException {
|
||||
// You cant send without a client player, so this is fine
|
||||
if (Minecraft.getInstance().getConnection() != null) {
|
||||
Minecraft.getInstance().getConnection().send(createC2SPacket(resourceLocation_meow, buf));
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Cannot send packets when not in game!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a packet which may be sent to the connected client.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
* @param buf the packet byte buf which represents the payload of the packet
|
||||
* @return a new packet
|
||||
*/
|
||||
public static Packet<?> createS2CPacket(ResourceLocation channelName, FriendlyByteBuf buf) {
|
||||
Objects.requireNonNull(channelName, "Channel cannot be null");
|
||||
Objects.requireNonNull(buf, "Buf cannot be null");
|
||||
|
||||
return createPlayS2CPacket(channelName, buf);
|
||||
}
|
||||
|
||||
public static Packet<?> createPlayS2CPacket(ResourceLocation channel, FriendlyByteBuf buf) {
|
||||
return new ClientboundCustomPayloadPacket(channel, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a packet which may be sent to a the connected server.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
* @param buf the packet byte buf which represents the payload of the packet
|
||||
* @return a new packet
|
||||
*/
|
||||
public static Packet<?> createC2SPacket(ResourceLocation channelName, FriendlyByteBuf buf) {
|
||||
Objects.requireNonNull(channelName, "Channel name cannot be null");
|
||||
Objects.requireNonNull(buf, "Buf cannot be null");
|
||||
|
||||
return createPlayC2SPacket(channelName, buf);
|
||||
}
|
||||
|
||||
public static Packet<?> createPlayC2SPacket(ResourceLocation channelName, FriendlyByteBuf buf) {
|
||||
return new ServerboundCustomPayloadPacket(channelName, buf);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.handlers.IReflectionHandler;
|
||||
import com.seibel.lod.core.handlers.ReflectionHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies, so we
|
||||
@@ -22,14 +41,16 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
public class DependencySetup {
|
||||
public static void createInitialBindings() {
|
||||
public static void createInitialBindings()
|
||||
{
|
||||
SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
if (!LodCommonMain.serverSided) {
|
||||
SingletonHandler.bind(IMinecraftWrapper.class, MinecraftClientWrapper.INSTANCE);
|
||||
if (!LodCommonMain.serverSided)
|
||||
{
|
||||
SingletonHandler.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE);
|
||||
SingletonHandler.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE);
|
||||
SingletonHandler.bind(IReflectionHandler.class, ReflectionHandler.createSingleton(MinecraftClientWrapper.INSTANCE.getOptions().getClass().getDeclaredFields(), MinecraftClientWrapper.INSTANCE.getOptions()));
|
||||
SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
}
|
||||
|
||||
SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
|
||||
DependencySetupDoneCheck.isDone = true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DependencySetupDoneCheck
|
||||
{
|
||||
public static boolean isDone = false;
|
||||
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> {return false;});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,10 +21,17 @@ package com.seibel.lod.common.wrappers;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
#if PRE_MC_1_19_3
|
||||
import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
#endif
|
||||
import com.seibel.lod.common.wrappers.block.BlockPosWrapper;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
/**
|
||||
@@ -36,27 +43,76 @@ import net.minecraft.core.Direction;
|
||||
*/
|
||||
public class McObjectConverter
|
||||
{
|
||||
private static int bufferIndex(int x, int y) {
|
||||
return y * 4 + x;
|
||||
}
|
||||
/** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */
|
||||
public static void storeMatrix(Matrix4f matrix, FloatBuffer buffer) {
|
||||
#if PRE_MC_1_19_3
|
||||
matrix.store(buffer);
|
||||
#else
|
||||
// Mojang starts to use joml's Matrix4f libary in 1.19.3 so we copy their store method and use it here if its newer than 1.19.3
|
||||
buffer.put(bufferIndex(0, 0), matrix.m00());
|
||||
buffer.put(bufferIndex(0, 1), matrix.m01());
|
||||
buffer.put(bufferIndex(0, 2), matrix.m02());
|
||||
buffer.put(bufferIndex(0, 3), matrix.m03());
|
||||
buffer.put(bufferIndex(1, 0), matrix.m10());
|
||||
buffer.put(bufferIndex(1, 1), matrix.m11());
|
||||
buffer.put(bufferIndex(1, 2), matrix.m12());
|
||||
buffer.put(bufferIndex(1, 3), matrix.m13());
|
||||
buffer.put(bufferIndex(2, 0), matrix.m20());
|
||||
buffer.put(bufferIndex(2, 1), matrix.m21());
|
||||
buffer.put(bufferIndex(2, 2), matrix.m22());
|
||||
buffer.put(bufferIndex(2, 3), matrix.m23());
|
||||
buffer.put(bufferIndex(3, 0), matrix.m30());
|
||||
buffer.put(bufferIndex(3, 1), matrix.m31());
|
||||
buffer.put(bufferIndex(3, 2), matrix.m32());
|
||||
buffer.put(bufferIndex(3, 3), matrix.m33());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 4x4 float matrix converter */
|
||||
public static Mat4f Convert(Matrix4f mcMatrix)
|
||||
{
|
||||
FloatBuffer buffer = FloatBuffer.allocate(16);
|
||||
mcMatrix.store(buffer);
|
||||
storeMatrix(mcMatrix, buffer);
|
||||
Mat4f matrix = new Mat4f(buffer);
|
||||
matrix.transpose();
|
||||
#if PRE_MC_1_19_3
|
||||
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
|
||||
#endif
|
||||
return matrix;
|
||||
}
|
||||
|
||||
static final Direction[] directions;
|
||||
static {
|
||||
LodDirection[] lodDirs = LodDirection.values();
|
||||
directions = new Direction[lodDirs.length];
|
||||
for (LodDirection lodDir : lodDirs) {
|
||||
directions[lodDir.ordinal()] = Direction.byName(lodDir.name());
|
||||
}
|
||||
}
|
||||
|
||||
static final Direction[] directions;
|
||||
static final LodDirection[] lodDirections;
|
||||
static {
|
||||
LodDirection[] lodDirs = LodDirection.values();
|
||||
directions = new Direction[lodDirs.length];
|
||||
lodDirections = new LodDirection[lodDirs.length];
|
||||
for (LodDirection lodDir : lodDirs) {
|
||||
Direction dir = Enum.valueOf(Direction.class, lodDir.name());
|
||||
if (dir == null) {
|
||||
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
|
||||
}
|
||||
directions[lodDir.ordinal()] = dir;
|
||||
lodDirections[dir.ordinal()] = lodDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPos Convert(AbstractBlockPosWrapper wrappedPos) {
|
||||
return new BlockPos(wrappedPos.getX(),wrappedPos.getY(), wrappedPos.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static Direction Convert(LodDirection lodDirection)
|
||||
{
|
||||
return directions[lodDirection.ordinal()];
|
||||
}
|
||||
public static LodDirection Convert(Direction direction)
|
||||
{
|
||||
return lodDirections[direction.ordinal()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
@@ -7,54 +26,32 @@ import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
* @author James Seibel
|
||||
* @version 12-11-2021
|
||||
*/
|
||||
public class VersionConstants implements IVersionConstants {
|
||||
public static final VersionConstants INSTANCE = new VersionConstants();
|
||||
|
||||
|
||||
private VersionConstants() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMinimumWorldHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldGeneratorSingleThreaded(DistanceGenerationMode distanceGenerationMode) {
|
||||
// We are always asking the server to generate the chunk,
|
||||
// so no use running this stuff multithreaded.
|
||||
return true;
|
||||
/*
|
||||
switch (distanceGenerationMode) {
|
||||
default:
|
||||
case NONE:
|
||||
case BIOME_ONLY:
|
||||
case BIOME_ONLY_SIMULATE_HEIGHT:
|
||||
case SURFACE:
|
||||
case FEATURES:
|
||||
return false;
|
||||
|
||||
case FULL:
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWorldGenerationCountPerThread() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public class VersionConstants implements IVersionConstants
|
||||
{
|
||||
public static final VersionConstants INSTANCE = new VersionConstants();
|
||||
|
||||
|
||||
private VersionConstants()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasBatchGenerationImplementation() {
|
||||
return true;
|
||||
public int getMinimumWorldHeight()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanillaRenderedChunkSquare() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getWorldGenerationCountPerThread()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanillaRenderedChunkSquare()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,11 +26,9 @@ import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractWorldGeneratorWrapper;
|
||||
import com.seibel.lod.common.wrappers.block.BlockPosWrapper;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkPosWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.WorldGeneratorWrapper;
|
||||
|
||||
/**
|
||||
* This handles creating abstract wrapper objects.
|
||||
@@ -38,53 +36,59 @@ import com.seibel.lod.common.wrappers.worldGeneration.WorldGeneratorWrapper;
|
||||
* @author James Seibel
|
||||
* @version 11-20-2021
|
||||
*/
|
||||
public class WrapperFactory implements IWrapperFactory {
|
||||
public static final WrapperFactory INSTANCE = new WrapperFactory();
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper createBlockPos() {
|
||||
return new BlockPosWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper createBlockPos(int x, int y, int z) {
|
||||
return new BlockPosWrapper(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos() {
|
||||
return new ChunkPosWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(long xAndZPositionCombined) {
|
||||
return new ChunkPosWrapper(xAndZPositionCombined);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(int x, int z) {
|
||||
return new ChunkPosWrapper(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(AbstractChunkPosWrapper newChunkPos) {
|
||||
return new ChunkPosWrapper(newChunkPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(AbstractBlockPosWrapper blockPos) {
|
||||
return new ChunkPosWrapper(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWorldGeneratorWrapper createWorldGenerator(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) {
|
||||
return new WorldGeneratorWrapper(newLodBuilder, newLodDimension, worldWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) {
|
||||
public class WrapperFactory implements IWrapperFactory
|
||||
{
|
||||
public static final WrapperFactory INSTANCE = new WrapperFactory();
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper createBlockPos()
|
||||
{
|
||||
return new BlockPosWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper createBlockPos(int x, int y, int z)
|
||||
{
|
||||
return new BlockPosWrapper(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos()
|
||||
{
|
||||
return new ChunkPosWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(long xAndZPositionCombined)
|
||||
{
|
||||
return new ChunkPosWrapper(xAndZPositionCombined);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(int x, int z)
|
||||
{
|
||||
return new ChunkPosWrapper(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(AbstractChunkPosWrapper newChunkPos)
|
||||
{
|
||||
return new ChunkPosWrapper(newChunkPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractChunkPosWrapper createChunkPos(AbstractBlockPosWrapper blockPos)
|
||||
{
|
||||
return new ChunkPosWrapper(blockPos);
|
||||
}
|
||||
|
||||
public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(LodBuilder newLodBuilder,
|
||||
LodDimension newLodDimension, IWorldWrapper worldWrapper)
|
||||
{
|
||||
return new BatchGenerationEnvironment(worldWrapper, newLodBuilder, newLodDimension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,286 +1,47 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.util.ColorUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.BlockDetail;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.FlowerBlock;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class BlockDetailMap
|
||||
{
|
||||
public static final int FLOWER_COLOR_SCALE = 5;
|
||||
|
||||
public static final Random random = new Random(0);
|
||||
|
||||
//TODO: Perhaps make this not just use the first frame?
|
||||
//FIXME: Stuff is wrong.
|
||||
private static int calculateColorFromTexture(TextureAtlasSprite texture, boolean useFlowerScaling, boolean useFastLeaf) {
|
||||
|
||||
int count = 0;
|
||||
double alpha = 0;
|
||||
double red = 0;
|
||||
double green = 0;
|
||||
double blue = 0;
|
||||
int tempColor;
|
||||
|
||||
{
|
||||
// textures normally use u and v instead of x and y
|
||||
for (int u = 0; u < texture.getWidth(); u++)
|
||||
{
|
||||
for (int v = 0; v < texture.getHeight(); v++)
|
||||
{
|
||||
//note: Minecraft color format is: 0xAA BB GG RR
|
||||
//________ DH mod color format is: 0xAA RR GG BB
|
||||
//OpenGL RGBA format native order: 0xRR GG BB AA
|
||||
//_ OpenGL RGBA format Java Order: 0xAA BB GG RR
|
||||
tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v);
|
||||
|
||||
double r = ((tempColor & 0x000000FF) )/255.;
|
||||
double g = ((tempColor & 0x0000FF00) >>> 8)/255.;
|
||||
double b = ((tempColor & 0x00FF0000) >>> 16)/255.;
|
||||
double a = ((tempColor & 0xFF000000) >>> 24)/255.;
|
||||
int scale = 1;
|
||||
|
||||
if (useFastLeaf) {
|
||||
r *= a;
|
||||
g *= a;
|
||||
b *= a;
|
||||
a = 1.;
|
||||
} else if (a==0.) {
|
||||
continue;
|
||||
} else if (useFlowerScaling && (g+0.1<b || g+0.1<r)) {
|
||||
scale = FLOWER_COLOR_SCALE;
|
||||
}
|
||||
|
||||
count += scale;
|
||||
alpha += a*a*scale;
|
||||
red += r*r*scale;
|
||||
green += g*g*scale;
|
||||
blue += b*b*scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
// this block is entirely transparent
|
||||
tempColor = ColorUtil.rgbToInt(255,255,0,255);
|
||||
else
|
||||
{
|
||||
// determine the average color
|
||||
tempColor = ColorUtil.rgbToInt(
|
||||
(int) (Math.sqrt(alpha/count)*255.),
|
||||
(int) (Math.sqrt(red / count)*255.),
|
||||
(int) (Math.sqrt(green / count)*255.),
|
||||
(int) (Math.sqrt(blue / count)*255.));
|
||||
}
|
||||
// TODO: Remove this when transparency is added!
|
||||
double colorAlpha = ColorUtil.getAlpha(tempColor)/255.;
|
||||
tempColor = ColorUtil.rgbToInt(
|
||||
ColorUtil.getAlpha(tempColor),
|
||||
(int)(ColorUtil.getRed(tempColor) * colorAlpha),
|
||||
(int)(ColorUtil.getGreen(tempColor) * colorAlpha),
|
||||
(int)(ColorUtil.getBlue(tempColor) * colorAlpha)
|
||||
);
|
||||
|
||||
return tempColor;
|
||||
}
|
||||
|
||||
|
||||
static class BlockDetailCache {
|
||||
static BlockDetailCache NULL_BLOCK_DETAIL = new BlockDetailCache();
|
||||
|
||||
private static final Block[] BLOCK_TO_AVOID = {Blocks.AIR, Blocks.CAVE_AIR, Blocks.BARRIER};
|
||||
|
||||
private static final Direction[] DIRECTION_ORDER = {Direction.UP, Direction.NORTH, Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.DOWN};
|
||||
|
||||
ConcurrentHashMap<Biome, BlockDetail> biomeDetailMap = null;
|
||||
BlockDetail blockDetail;
|
||||
BlockDetail defaultTintedDetail = null;
|
||||
boolean requireResolving;
|
||||
@SuppressWarnings("unused")
|
||||
boolean requireShade; //TODO: Add back using this in renderer
|
||||
@SuppressWarnings("unused")
|
||||
boolean scaleFlowerColor; //FIXME: Do I need to scale the tint color???
|
||||
int tintIndex;
|
||||
|
||||
static boolean isBlockToBeAvoid(Block b) {
|
||||
for (Block bta : BLOCK_TO_AVOID)
|
||||
if (bta==b) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean hasNoCollision(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
if (!bs.getFluidState().isEmpty() || bs.getBlock() instanceof LiquidBlock) // Is blockState a fluid?
|
||||
return false;
|
||||
if (bs.getCollisionShape(getter, pos).isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
static boolean hasOnlyNonFullFace(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
if (!bs.getFluidState().isEmpty() || bs.getBlock() instanceof LiquidBlock) // Is blockState a fluid?
|
||||
return false;
|
||||
VoxelShape voxelShape = bs.getShape(getter, pos);
|
||||
if (voxelShape.isEmpty()) return true;
|
||||
AABB bbox = voxelShape.bounds();
|
||||
double xWidth = (bbox.maxX - bbox.minX);
|
||||
double yWidth = (bbox.maxY - bbox.minY);
|
||||
double zWidth = (bbox.maxZ - bbox.minZ);
|
||||
return xWidth < 1 && zWidth < 1 && yWidth < 1;
|
||||
}
|
||||
|
||||
static BlockDetailCache make(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
boolean noCol, nonFull, canOcclude;
|
||||
if(!bs.getFluidState().isEmpty()) {
|
||||
bs = bs.getFluidState().createLegacyBlock();
|
||||
FluidState fs = bs.getFluidState();
|
||||
fs.getType();
|
||||
noCol = false;
|
||||
nonFull = false;
|
||||
canOcclude = false;
|
||||
BlockDetailCache result = new BlockDetailCache(fs);
|
||||
//ApiShared.LOGGER.info(fs.toString()+" = ["+result+"]");
|
||||
return result;
|
||||
} else {
|
||||
if (bs.getRenderShape() != RenderShape.MODEL) return NULL_BLOCK_DETAIL;
|
||||
if (isBlockToBeAvoid(bs.getBlock())) return NULL_BLOCK_DETAIL;
|
||||
//BlocksToAvoid toAvoid = CONFIG.client().worldGenerator().getBlocksToAvoid();
|
||||
noCol = hasNoCollision(bs, pos, getter);
|
||||
nonFull = hasOnlyNonFullFace(bs, pos, getter);
|
||||
canOcclude = bs.canOcclude();
|
||||
List<BakedQuad> quads = null;
|
||||
for (Direction direction : DIRECTION_ORDER)
|
||||
{
|
||||
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(bs).getQuads(bs, direction, random);
|
||||
if (!quads.isEmpty() && !(bs.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP))
|
||||
break;
|
||||
};
|
||||
if (quads == null || quads.isEmpty()) return NULL_BLOCK_DETAIL;
|
||||
BlockDetailCache result = new BlockDetailCache(canOcclude, noCol, nonFull, quads.get(0),
|
||||
bs.getBlock() instanceof FlowerBlock, bs.getBlock() instanceof LeavesBlock);
|
||||
// ApiShared.LOGGER.info(bs.toString()+" = ["+result+"]");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
BlockDetailCache(boolean isFullBlock, boolean noCol, boolean nonFull, BakedQuad quad, boolean useFlowerScaling, boolean useFastLeaf) {
|
||||
requireResolving = quad.isTinted();
|
||||
requireShade = quad.isShade();
|
||||
tintIndex = quad.getTintIndex();
|
||||
scaleFlowerColor = useFlowerScaling;
|
||||
blockDetail = new BlockDetail(calculateColorFromTexture(quad.sprite, useFlowerScaling, useFastLeaf), isFullBlock, noCol, nonFull);
|
||||
if (quad.isTinted()) biomeDetailMap = new ConcurrentHashMap<Biome, BlockDetail>();
|
||||
}
|
||||
|
||||
BlockDetailCache(FluidState fluid) {
|
||||
requireResolving = true; // TODO: Maybe in the future recheck that there really is no way to see if a fluid needs tinting
|
||||
requireShade = false;
|
||||
tintIndex = 0; // Vanilla doesn't use this index currently. (Checked at 1.18.X, See BlockColors.class)
|
||||
scaleFlowerColor = false;
|
||||
TextureAtlasSprite text = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(fluid.createLegacyBlock()).getParticleIcon();
|
||||
blockDetail = new BlockDetail(calculateColorFromTexture(text, false, false), true, false, false);
|
||||
biomeDetailMap = new ConcurrentHashMap<Biome, BlockDetail>();
|
||||
}
|
||||
|
||||
private BlockDetailCache()
|
||||
{
|
||||
//DUMMY CREATOR
|
||||
}
|
||||
|
||||
BlockDetail getResolvedBlockDetail(BlockState bs, int x, int y, int z, LevelReader getter) {
|
||||
if (!requireResolving) return blockDetail;
|
||||
BlockPos pos = new BlockPos(x,y,z);
|
||||
Biome biome = getter.getBiome(pos);
|
||||
BlockDetail tintDetail = biomeDetailMap.get(biome);
|
||||
if (tintDetail == null) {
|
||||
if (!bs.getFluidState().isEmpty()) bs = bs.getFluidState().createLegacyBlock();
|
||||
BlockColors bc = Minecraft.getInstance().getBlockColors();
|
||||
int tintColor = bc.getColor(bs, getter, pos, tintIndex);
|
||||
tintColor = ColorUtil.multiplyARGBwithRGB(blockDetail.color, tintColor);
|
||||
tintDetail = new BlockDetail(tintColor, blockDetail.isFullBlock,
|
||||
blockDetail.hasNoCollision, blockDetail.hasOnlyNonFullFace);
|
||||
BlockDetail tintDetailCAS = biomeDetailMap.putIfAbsent(biome, tintDetail);
|
||||
if (tintDetailCAS != null) tintDetail = tintDetailCAS;
|
||||
}
|
||||
return tintDetail;
|
||||
}
|
||||
|
||||
// Note: this one won't resolve biome based or pos based colors. (Kinda like GUI block icons)
|
||||
BlockDetail getResolvedBlockDetail(BlockState bs) {
|
||||
if (!requireResolving) return blockDetail;
|
||||
if (defaultTintedDetail != null) return defaultTintedDetail;
|
||||
|
||||
BlockColors bc = Minecraft.getInstance().getBlockColors();
|
||||
if (!bs.getFluidState().isEmpty()) bs = bs.getFluidState().createLegacyBlock();
|
||||
int tintColor = bc.getColor(bs, null, null, tintIndex);
|
||||
if (tintColor == -1) {
|
||||
defaultTintedDetail = blockDetail;
|
||||
}
|
||||
else {
|
||||
defaultTintedDetail = new BlockDetail(ColorUtil.multiplyARGBwithRGB(blockDetail.color, tintColor),
|
||||
blockDetail.isFullBlock, blockDetail.hasNoCollision, blockDetail.hasOnlyNonFullFace);
|
||||
}
|
||||
return defaultTintedDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[BlockDetail: "+blockDetail+", RequireResolving: "+requireResolving+", requireShade: "+requireShade+", scaleFlowerColor: "+scaleFlowerColor+"]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static ConcurrentHashMap<BlockState, BlockDetailCache> map = new ConcurrentHashMap<BlockState, BlockDetailCache>();
|
||||
|
||||
private BlockDetailMap() {}
|
||||
|
||||
private static BlockDetailCache getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
BlockDetailCache cache = map.get(bs);
|
||||
if (cache != null) return cache;
|
||||
if (bs.getFluidState().isEmpty()) {
|
||||
cache = BlockDetailCache.make(bs, pos, getter);
|
||||
} else {
|
||||
cache = BlockDetailCache.make(bs.getFluidState().createLegacyBlock(), pos, getter);
|
||||
}
|
||||
BlockDetailCache cacheCAS = map.putIfAbsent(bs, cache);
|
||||
return cacheCAS==null ? cache : cacheCAS;
|
||||
}
|
||||
|
||||
|
||||
// Return null means skip the block
|
||||
public static BlockDetail getBlockDetail(BlockState bs) {
|
||||
BlockDetailCache cache = getOrMakeBlockDetailCache(bs, new BlockPos(0, 0, 0), null);
|
||||
if (cache == BlockDetailCache.NULL_BLOCK_DETAIL) return null;
|
||||
return cache.getResolvedBlockDetail(bs);
|
||||
}
|
||||
|
||||
// Return null means skip the block
|
||||
public static BlockDetail getBlockDetailWithCompleteTint(BlockState bs, int x, int y, int z, LevelReader tintGetter) {
|
||||
BlockDetailCache cache = getOrMakeBlockDetailCache(bs, new BlockPos(x,y,z), tintGetter);
|
||||
if (cache == BlockDetailCache.NULL_BLOCK_DETAIL) return null;
|
||||
return cache.getResolvedBlockDetail(bs, x, y, z, tintGetter);
|
||||
}
|
||||
|
||||
private static ConcurrentHashMap<BlockState, BlockDetailWrapper> map = new ConcurrentHashMap<BlockState, BlockDetailWrapper>();
|
||||
|
||||
private BlockDetailMap() {}
|
||||
|
||||
public static BlockDetailWrapper getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
if (!bs.getFluidState().isEmpty()) {
|
||||
bs = bs.getFluidState().createLegacyBlock();
|
||||
}
|
||||
BlockDetailWrapper cache = map.get(bs);
|
||||
if (cache != null) return cache;
|
||||
cache = BlockDetailWrapper.make(bs, pos, getter);
|
||||
//ApiShared.LOGGER.info("New blockDetail cache for {} to {} ", bs, cache);
|
||||
BlockDetailWrapper cacheCAS = map.putIfAbsent(bs, cache);
|
||||
return cacheCAS==null ? cache : cacheCAS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.seibel.lod.common.Config;
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.util.ColorUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Cursor3D;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.FlowerBlock;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
#if POST_MC_1_19
|
||||
import net.minecraft.util.RandomSource;
|
||||
#endif
|
||||
|
||||
/*-- WARN: This class should NEVER hold reference to anything large,
|
||||
as this is never dealloc until the end of runtime!! --*/
|
||||
public class BlockDetailWrapper extends IBlockDetailWrapper
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
public static final int FLOWER_COLOR_SCALE = 5;
|
||||
|
||||
#if PRE_MC_1_19
|
||||
public static final Random random = new Random(0);
|
||||
#else
|
||||
public static final RandomSource random = RandomSource.create();
|
||||
#endif
|
||||
|
||||
enum ColorMode {
|
||||
Default,
|
||||
Flower,
|
||||
Leaves;
|
||||
static ColorMode getColorMode(Block b) {
|
||||
if (b instanceof LeavesBlock) return Leaves;
|
||||
if (b instanceof FlowerBlock) return Flower;
|
||||
return Default;
|
||||
}
|
||||
}
|
||||
//TODO: Perhaps make this not just use the first frame?
|
||||
private static int calculateColorFromTexture(TextureAtlasSprite texture, ColorMode colorMode) {
|
||||
|
||||
int count = 0;
|
||||
double alpha = 0;
|
||||
double red = 0;
|
||||
double green = 0;
|
||||
double blue = 0;
|
||||
int tempColor;
|
||||
|
||||
{
|
||||
// textures normally use u and v instead of x and y
|
||||
for (int u = 0; u <
|
||||
#if PRE_MC_1_19_3
|
||||
texture.getWidth();
|
||||
#else
|
||||
texture.contents().width();
|
||||
#endif
|
||||
u++)
|
||||
{
|
||||
for (int v = 0; v <
|
||||
#if PRE_MC_1_19_3
|
||||
texture.getHeight();
|
||||
#else
|
||||
texture.contents().height();
|
||||
#endif
|
||||
v++)
|
||||
{
|
||||
//note: Minecraft color format is: 0xAA BB GG RR
|
||||
//________ DH mod color format is: 0xAA RR GG BB
|
||||
//OpenGL RGBA format native order: 0xRR GG BB AA
|
||||
//_ OpenGL RGBA format Java Order: 0xAA BB GG RR
|
||||
tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v);
|
||||
|
||||
double r = ((tempColor & 0x000000FF) )/255.;
|
||||
double g = ((tempColor & 0x0000FF00) >>> 8)/255.;
|
||||
double b = ((tempColor & 0x00FF0000) >>> 16)/255.;
|
||||
double a = ((tempColor & 0xFF000000) >>> 24)/255.;
|
||||
int scale = 1;
|
||||
|
||||
if (colorMode == ColorMode.Leaves) {
|
||||
r *= a;
|
||||
g *= a;
|
||||
b *= a;
|
||||
a = 1.;
|
||||
} else if (a==0.) {
|
||||
continue;
|
||||
} else if (colorMode == ColorMode.Flower && (g+0.1<b || g+0.1<r)) {
|
||||
scale = FLOWER_COLOR_SCALE;
|
||||
}
|
||||
|
||||
count += scale;
|
||||
alpha += a*a*scale;
|
||||
red += r*r*scale;
|
||||
green += g*g*scale;
|
||||
blue += b*b*scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
// this block is entirely transparent
|
||||
tempColor = ColorUtil.rgbToInt(255,255,0,255);
|
||||
else
|
||||
{
|
||||
// determine the average color
|
||||
tempColor = ColorUtil.rgbToInt(
|
||||
(int) (Math.sqrt(alpha/count)*255.),
|
||||
(int) (Math.sqrt(red / count)*255.),
|
||||
(int) (Math.sqrt(green / count)*255.),
|
||||
(int) (Math.sqrt(blue / count)*255.));
|
||||
}
|
||||
// TODO: Remove this when transparency is added!
|
||||
double colorAlpha = ColorUtil.getAlpha(tempColor)/255.;
|
||||
tempColor = ColorUtil.rgbToInt(
|
||||
ColorUtil.getAlpha(tempColor),
|
||||
(int)(ColorUtil.getRed(tempColor) * colorAlpha),
|
||||
(int)(ColorUtil.getGreen(tempColor) * colorAlpha),
|
||||
(int)(ColorUtil.getBlue(tempColor) * colorAlpha)
|
||||
);
|
||||
return tempColor;
|
||||
}
|
||||
|
||||
private static final Block[] BLOCK_TO_AVOID = {Blocks.AIR, Blocks.CAVE_AIR, Blocks.BARRIER};
|
||||
|
||||
private static final Direction[] DIRECTION_ORDER = {Direction.UP, Direction.NORTH, Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.DOWN};
|
||||
|
||||
private static boolean isBlockToBeAvoid(Block b) {
|
||||
for (Block bta : BLOCK_TO_AVOID)
|
||||
if (bta==b) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
final BlockState state;
|
||||
|
||||
//boolean isShapeResolved = false;
|
||||
//^ Shapes no longer lazy resolved due to memory leaks from needing
|
||||
// to keep a reference to the block getter
|
||||
|
||||
boolean[] dontOccludeFaces = null;
|
||||
boolean noCollision = false;
|
||||
boolean noFullFace = false;
|
||||
|
||||
boolean isColorResolved = false;
|
||||
int baseColor = 0; //TODO: Impl per-face color
|
||||
boolean needShade = true;
|
||||
boolean needPostTinting = false;
|
||||
int tintIndex = 0;
|
||||
|
||||
public static BlockDetailWrapper NULL_BLOCK_DETAIL = new BlockDetailWrapper();
|
||||
|
||||
public BlockDetailWrapper(BlockState state, BlockPos pos, LevelReader getter) {
|
||||
this.state = state;
|
||||
resolveShapes(getter, pos);
|
||||
//ApiShared.LOGGER.info("Created BlockDetailWrapper for blockstate {} at {}", state, pos);
|
||||
}
|
||||
|
||||
private BlockDetailWrapper() {
|
||||
this.state = null;
|
||||
}
|
||||
|
||||
static BlockDetailWrapper make(BlockState bs, BlockPos pos, LevelReader getter) {
|
||||
if(!bs.getFluidState().isEmpty()) { // Is a fluidBlock
|
||||
if (isBlockToBeAvoid(bs.getBlock())) return NULL_BLOCK_DETAIL;
|
||||
if (bs.isAir()) return NULL_BLOCK_DETAIL;
|
||||
return new BlockDetailWrapper(bs, pos, getter);
|
||||
} else {
|
||||
if (bs.getRenderShape() != RenderShape.MODEL) return NULL_BLOCK_DETAIL;
|
||||
if (isBlockToBeAvoid(bs.getBlock())) return NULL_BLOCK_DETAIL;
|
||||
return new BlockDetailWrapper(bs, pos, getter);
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveShapes(LevelReader sampleGetter, BlockPos samplePos) {
|
||||
//if (isShapeResolved) return;
|
||||
if (state.getFluidState().isEmpty()) {
|
||||
noCollision = state.getCollisionShape(sampleGetter, samplePos).isEmpty();
|
||||
dontOccludeFaces = new boolean[6];
|
||||
if (state.canOcclude()) {
|
||||
/* FIXME: Figure out how or if needed to impl per-face culling?
|
||||
for (Direction dir : Direction.values()) {
|
||||
dontOccludeFaces[McObjectConverter.Convert(dir).ordinal()]
|
||||
= state.getFaceOcclusionShape(sampleGetter, samplePos, dir).isEmpty();
|
||||
}*/
|
||||
} else {
|
||||
Arrays.fill(dontOccludeFaces, true);
|
||||
}
|
||||
|
||||
VoxelShape voxelShape = state.getShape(sampleGetter, samplePos);
|
||||
if (voxelShape.isEmpty()) {
|
||||
noFullFace = true;
|
||||
} else {
|
||||
AABB bbox = voxelShape.bounds();
|
||||
double xWidth = (bbox.maxX - bbox.minX);
|
||||
double yWidth = (bbox.maxY - bbox.minY);
|
||||
double zWidth = (bbox.maxZ - bbox.minZ);
|
||||
noFullFace = xWidth < 1 && zWidth < 1 && yWidth < 1;
|
||||
}
|
||||
} else { // Liquid Block
|
||||
dontOccludeFaces = new boolean[6];
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveColors() {
|
||||
if (isColorResolved) return;
|
||||
if (state.getFluidState().isEmpty()) {
|
||||
List<BakedQuad> quads = null;
|
||||
for (Direction direction : DIRECTION_ORDER)
|
||||
{
|
||||
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().
|
||||
getBlockModel(state).getQuads(state, direction, random);
|
||||
if (!quads.isEmpty() &&
|
||||
!(state.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP))
|
||||
break;
|
||||
};
|
||||
if (quads == null || quads.isEmpty()) {
|
||||
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().
|
||||
getBlockModel(state).getQuads(state, null, random);
|
||||
}
|
||||
if (quads != null && !quads.isEmpty()) {
|
||||
needPostTinting = quads.get(0).isTinted();
|
||||
needShade = quads.get(0).isShade();
|
||||
tintIndex = quads.get(0).getTintIndex();
|
||||
baseColor = calculateColorFromTexture(
|
||||
#if PRE_MC_1_17_1 quads.get(0).sprite,
|
||||
#else quads.get(0).getSprite(), #endif
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
} else { // Backup method.
|
||||
needPostTinting = false;
|
||||
needShade = false;
|
||||
tintIndex = 0;
|
||||
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state),
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
}
|
||||
} else { // Liquid Block
|
||||
needPostTinting = true;
|
||||
needShade = false;
|
||||
tintIndex = 0;
|
||||
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state),
|
||||
ColorMode.getColorMode(state.getBlock()));
|
||||
}
|
||||
isColorResolved = true;
|
||||
}
|
||||
|
||||
private BlockAndTintGetter wrapColorResolver(LevelReader level) {
|
||||
int blendDistance = CONFIG.client().graphics().quality().getLodBiomeBlending();
|
||||
if (blendDistance == 0) {
|
||||
return new TintGetterOverrideFast(level);
|
||||
} else {
|
||||
return new TintGetterOverrideSmooth(level, blendDistance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAndResolveFaceColor(LodDirection dir, IChunkWrapper chunk, AbstractBlockPosWrapper blockPos)
|
||||
{
|
||||
// FIXME: impl per-face colors
|
||||
resolveColors();
|
||||
if (!needPostTinting) return baseColor;
|
||||
int tintColor = Minecraft.getInstance().getBlockColors()
|
||||
.getColor(state, wrapColorResolver(((ChunkWrapper)chunk).getColorResolver()),
|
||||
McObjectConverter.Convert(blockPos), tintIndex);
|
||||
if (tintColor == -1) return baseColor;
|
||||
return ColorUtil.multiplyARGBwithRGB(baseColor, tintColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFaceCullingFor(LodDirection dir)
|
||||
{
|
||||
//resolveShapes();
|
||||
return !dontOccludeFaces[dir.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNoCollision()
|
||||
{
|
||||
//resolveShapes();
|
||||
return noCollision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean noFaceIsFullFace()
|
||||
{
|
||||
//resolveShapes();
|
||||
return noFullFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize()
|
||||
{
|
||||
// FIXME: Impl this for the blockState Storage stuff
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSame(IBlockDetailWrapper iBlockDetail)
|
||||
{
|
||||
return ((BlockDetailWrapper)iBlockDetail).state.getBlock().equals(state.getBlock());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "BlockDetail{" + state + "}";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -14,7 +33,7 @@ import net.minecraft.core.BlockPos;
|
||||
*/
|
||||
public class BlockPosWrapper extends AbstractBlockPosWrapper
|
||||
{
|
||||
private BlockPos.MutableBlockPos blockPos;
|
||||
private final BlockPos.MutableBlockPos blockPos;
|
||||
|
||||
|
||||
public BlockPosWrapper()
|
||||
|
||||
+36
-2
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
|
||||
@@ -18,7 +37,22 @@ public class TextureAtlasSpriteWrapper {
|
||||
* The code has been modified to use TextureAtlasSprite
|
||||
*/
|
||||
public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y) {
|
||||
// Require access widener
|
||||
return sprite.mainImage[0].getPixelRGBA(x + sprite.framesX[frameIndex] * sprite.getWidth(), y + sprite.framesY[frameIndex] * sprite.getHeight());
|
||||
#if PRE_MC_1_17_1
|
||||
return sprite.mainImage[0].getPixelRGBA(
|
||||
x + sprite.framesX[frameIndex] * sprite.getWidth(),
|
||||
y + sprite.framesY[frameIndex] * sprite.getHeight());
|
||||
#elif PRE_MC_1_19_3
|
||||
if (sprite.animatedTexture != null) {
|
||||
x += sprite.animatedTexture.getFrameX(frameIndex) * sprite.width;
|
||||
y += sprite.animatedTexture.getFrameY(frameIndex) * sprite.height;
|
||||
}
|
||||
return sprite.mainImage[0].getPixelRGBA(x, y);
|
||||
#else
|
||||
if (sprite.contents().animatedTexture != null) {
|
||||
x += sprite.contents().animatedTexture.getFrameX(frameIndex) * sprite.contents().width();
|
||||
y += sprite.contents().animatedTexture.getFrameY(frameIndex) * sprite.contents().width();
|
||||
}
|
||||
return sprite.contents().originalImage.getPixelRGBA(x, y);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Cursor3D;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TintGetterOverrideFast implements BlockAndTintGetter {
|
||||
LevelReader parent;
|
||||
|
||||
public TintGetterOverrideFast(LevelReader parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if POST_MC_1_18_2
|
||||
return parent.getBiome(pos).value();
|
||||
#else
|
||||
return parent.getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
|
||||
if (LodCommonMain.forgeMethodCaller != null) {
|
||||
return LodCommonMain.forgeMethodCaller.colorResolverGetColor(colorResolver, _getBiome(blockPos),
|
||||
blockPos.getX(), blockPos.getZ());
|
||||
} else {
|
||||
return colorResolver.getColor(_getBiome(blockPos), blockPos.getX(), blockPos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShade(Direction direction, boolean bl) {
|
||||
return parent.getShade(direction, bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelLightEngine getLightEngine() {
|
||||
return parent.getLightEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightness(LightLayer lightLayer, BlockPos blockPos) {
|
||||
return parent.getBrightness(lightLayer, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawBrightness(BlockPos blockPos, int i) {
|
||||
return parent.getRawBrightness(blockPos, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeSky(BlockPos blockPos) {
|
||||
return parent.canSeeSky(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntity getBlockEntity(BlockPos blockPos) {
|
||||
return parent.getBlockEntity(blockPos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos blockPos) {
|
||||
return parent.getBlockState(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockPos blockPos) {
|
||||
return parent.getFluidState(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightEmission(BlockPos blockPos) {
|
||||
return parent.getLightEmission(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLightLevel() {
|
||||
return parent.getMaxLightLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<BlockState> getBlockStates(AABB aABB) {
|
||||
return parent.getBlockStates(aABB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult clip(ClipContext clipContext) {
|
||||
return parent.clip(clipContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockHitResult clipWithInteractionOverride(Vec3 vec3, Vec3 vec32, BlockPos blockPos, VoxelShape voxelShape, BlockState blockState) {
|
||||
return parent.clipWithInteractionOverride(vec3, vec32, blockPos, voxelShape, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockFloorHeight(VoxelShape voxelShape, Supplier<VoxelShape> supplier) {
|
||||
return parent.getBlockFloorHeight(voxelShape, supplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockFloorHeight(BlockPos blockPos) {
|
||||
return parent.getBlockFloorHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return parent.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight() {
|
||||
return parent.getMinBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionsCount() {
|
||||
return parent.getSectionsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSection() {
|
||||
return parent.getMinSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSection() {
|
||||
return parent.getMaxSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutsideBuildHeight(BlockPos blockPos) {
|
||||
return parent.isOutsideBuildHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutsideBuildHeight(int i) {
|
||||
return parent.isOutsideBuildHeight(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionIndex(int i) {
|
||||
return parent.getSectionIndex(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionIndexFromSectionY(int i) {
|
||||
return parent.getSectionIndexFromSectionY(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionYFromSectionIndex(int i) {
|
||||
return parent.getSectionYFromSectionIndex(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import com.seibel.lod.common.LodCommonMain;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Cursor3D;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TintGetterOverrideSmooth implements BlockAndTintGetter {
|
||||
LevelReader parent;
|
||||
public int smoothingRange;
|
||||
|
||||
public TintGetterOverrideSmooth(LevelReader parent, int smoothingRange) {
|
||||
this.parent = parent;
|
||||
this.smoothingRange = smoothingRange;
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if POST_MC_1_18_2
|
||||
return parent.getBiome(pos).value();
|
||||
#else
|
||||
return parent.getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver)
|
||||
{
|
||||
int i = smoothingRange;
|
||||
if (i == 0)
|
||||
return colorResolver.getColor(_getBiome(blockPos), blockPos.getX(), blockPos.getZ());
|
||||
int j = (i * 2 + 1) * (i * 2 + 1);
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
int m = 0;
|
||||
Cursor3D cursor3D = new Cursor3D(blockPos.getX() - i, blockPos.getY(), blockPos.getZ() - i, blockPos.getX() + i, blockPos.getY(), blockPos.getZ() + i);
|
||||
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
while (cursor3D.advance())
|
||||
{
|
||||
mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ());
|
||||
int n;
|
||||
if (LodCommonMain.forgeMethodCaller != null) {
|
||||
n = LodCommonMain.forgeMethodCaller.colorResolverGetColor(colorResolver, _getBiome(mutableBlockPos),
|
||||
mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
} else {
|
||||
n = colorResolver.getColor(_getBiome(mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
}
|
||||
|
||||
k += (n & 0xFF0000) >> 16;
|
||||
l += (n & 0xFF00) >> 8;
|
||||
m += n & 0xFF;
|
||||
}
|
||||
return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
|
||||
return calculateBlockTint(blockPos, colorResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShade(Direction direction, boolean bl) {
|
||||
return parent.getShade(direction, bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelLightEngine getLightEngine() {
|
||||
return parent.getLightEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightness(LightLayer lightLayer, BlockPos blockPos) {
|
||||
return parent.getBrightness(lightLayer, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawBrightness(BlockPos blockPos, int i) {
|
||||
return parent.getRawBrightness(blockPos, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeSky(BlockPos blockPos) {
|
||||
return parent.canSeeSky(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntity getBlockEntity(BlockPos blockPos) {
|
||||
return parent.getBlockEntity(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos blockPos) {
|
||||
return parent.getBlockState(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockPos blockPos) {
|
||||
return parent.getFluidState(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightEmission(BlockPos blockPos) {
|
||||
return parent.getLightEmission(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLightLevel() {
|
||||
return parent.getMaxLightLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<BlockState> getBlockStates(AABB aABB) {
|
||||
return parent.getBlockStates(aABB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult clip(ClipContext clipContext) {
|
||||
return parent.clip(clipContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockHitResult clipWithInteractionOverride(Vec3 vec3, Vec3 vec32, BlockPos blockPos, VoxelShape voxelShape, BlockState blockState) {
|
||||
return parent.clipWithInteractionOverride(vec3, vec32, blockPos, voxelShape, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockFloorHeight(VoxelShape voxelShape, Supplier<VoxelShape> supplier) {
|
||||
return parent.getBlockFloorHeight(voxelShape, supplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockFloorHeight(BlockPos blockPos) {
|
||||
return parent.getBlockFloorHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBuildHeight() {
|
||||
return parent.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos blockPos, BlockEntityType<T> blockEntityType) {
|
||||
return parent.getBlockEntity(blockPos, blockEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) {
|
||||
return parent.isBlockInLine(clipBlockStateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return parent.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight() {
|
||||
return parent.getMinBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionsCount() {
|
||||
return parent.getSectionsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSection() {
|
||||
return parent.getMinSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSection() {
|
||||
return parent.getMaxSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutsideBuildHeight(BlockPos blockPos) {
|
||||
return parent.isOutsideBuildHeight(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutsideBuildHeight(int i) {
|
||||
return parent.isOutsideBuildHeight(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionIndex(int i) {
|
||||
return parent.getSectionIndex(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionIndexFromSectionY(int i) {
|
||||
return parent.getSectionIndexFromSectionY(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionYFromSectionIndex(int i) {
|
||||
return parent.getSectionYFromSectionIndex(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -18,7 +37,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||
*/
|
||||
public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
{
|
||||
private net.minecraft.world.level.ChunkPos chunkPos;
|
||||
private final net.minecraft.world.level.ChunkPos chunkPos;
|
||||
|
||||
public ChunkPosWrapper()
|
||||
{
|
||||
@@ -44,12 +63,12 @@ public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
{
|
||||
this.chunkPos = new ChunkPos(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public ChunkPosWrapper(long l)
|
||||
{
|
||||
this.chunkPos = new ChunkPos(l);
|
||||
|
||||
public ChunkPosWrapper(long l) {
|
||||
this.chunkPos = new ChunkPos(l);
|
||||
}
|
||||
|
||||
|
||||
public ChunkPosWrapper(ChunkPos pos)
|
||||
{
|
||||
this.chunkPos = pos;
|
||||
@@ -85,29 +104,29 @@ public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
@Override
|
||||
public int getRegionX()
|
||||
{
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.x, LodUtil.REGION_DETAIL_LEVEL);
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.x, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionZ()
|
||||
{
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.z, LodUtil.REGION_DETAIL_LEVEL);
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.z, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong() {
|
||||
return chunkPos.toLong();
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos()
|
||||
{
|
||||
return chunkPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong() {
|
||||
return chunkPos.toLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
// If the object is compared with itself then return true
|
||||
// If the object is compared with itself then return true
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
@@ -129,9 +148,12 @@ public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
public AbstractBlockPosWrapper getWorldPosition()
|
||||
{
|
||||
// the parameter here is the y position
|
||||
#if PRE_MC_1_17_1
|
||||
BlockPos blockPos = chunkPos.getWorldPosition();
|
||||
#else
|
||||
BlockPos blockPos = chunkPos.getMiddleBlockPosition(0);
|
||||
#endif
|
||||
return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,177 +1,251 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
|
||||
import com.seibel.lod.common.wrappers.block.BlockDetailWrapper;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.BlockDetail;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
|
||||
import com.seibel.lod.common.wrappers.WrapperUtil;
|
||||
import com.seibel.lod.common.wrappers.block.BlockDetailMap;
|
||||
import com.seibel.lod.common.wrappers.world.BiomeWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.core.QuartPos;
|
||||
#endif
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 11-21-2021
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public class ChunkWrapper implements IChunkWrapper
|
||||
{
|
||||
private ChunkAccess chunk;
|
||||
private LevelReader lightSource;
|
||||
private final ChunkAccess chunk;
|
||||
private final LevelReader lightSource;
|
||||
|
||||
|
||||
public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource)
|
||||
{
|
||||
this.chunk = chunk;
|
||||
this.lightSource = lightSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
#if PRE_MC_1_17_1
|
||||
return 255;
|
||||
#else
|
||||
return chunk.getHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight()
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return 0;
|
||||
#else
|
||||
return chunk.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public int getMaxBuildHeight()
|
||||
{
|
||||
return chunk.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeightMapValue(int xRel, int zRel)
|
||||
{
|
||||
return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBiomeWrapper getBiome(int x, int y, int z)
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(
|
||||
x >> 2, y >> 2, z >> 2));
|
||||
#elif PRE_MC_1_18_1
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
|
||||
#elif PRE_MC_1_18_2
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
|
||||
#else
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
|
||||
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value());
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockDetailWrapper getBlockDetail(int x, int y, int z) {
|
||||
BlockPos pos = new BlockPos(x,y,z);
|
||||
BlockState blockState = chunk.getBlockState(pos);
|
||||
IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
|
||||
return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return 255;
|
||||
public IBlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) {
|
||||
int fy = y+dir.getNormal().y;
|
||||
if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null;
|
||||
BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z);
|
||||
BlockState blockState;
|
||||
if (blockPosInsideChunk(x,y,z))
|
||||
blockState = chunk.getBlockState(pos);
|
||||
else {
|
||||
blockState = lightSource.getBlockState(pos);
|
||||
}
|
||||
if (blockState == null || blockState.isAir()) return null;
|
||||
IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
|
||||
return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getMaxBuildHeight()
|
||||
{
|
||||
return chunk.getMaxBuildHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeightMapValue(int xRel, int zRel)
|
||||
{
|
||||
return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBiomeWrapper getBiome(int x, int y, int z)
|
||||
{
|
||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(
|
||||
x >> 2, y >> 2, z >> 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockDetail getBlockDetail(int x, int y, int z) {
|
||||
BlockState blockState = chunk.getBlockState(new BlockPos(x, y, z));
|
||||
return BlockDetailMap.getBlockDetailWithCompleteTint(blockState, x, y, z, lightSource);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChunkWrapper(ChunkAccess chunk)
|
||||
{
|
||||
this.chunk = chunk;
|
||||
this.lightSource = null;
|
||||
}
|
||||
public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) {
|
||||
this.chunk = chunk;
|
||||
this.lightSource = lightSource;
|
||||
}
|
||||
|
||||
public ChunkAccess getChunk() {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosX(){
|
||||
return chunk.getPos().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosZ(){
|
||||
return chunk.getPos().z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosX(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosX(), LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosZ(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosZ(), LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY(int x, int z) {
|
||||
return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxX(){
|
||||
return chunk.getPos().getMaxBlockX();
|
||||
}
|
||||
@Override
|
||||
public int getMaxZ(){
|
||||
return chunk.getPos().getMaxBlockZ();
|
||||
}
|
||||
@Override
|
||||
public int getMinX(){
|
||||
return chunk.getPos().getMinBlockX();
|
||||
}
|
||||
@Override
|
||||
public int getMinZ() {
|
||||
return chunk.getPos().getMinBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightCorrect(){
|
||||
return true;//chunk.isLightCorrect();
|
||||
}
|
||||
|
||||
public boolean isWaterLogged(int x, int y, int z)
|
||||
{
|
||||
BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z));
|
||||
|
||||
//This type of block is always in water
|
||||
return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock))
|
||||
&& (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEmittedBrightness(int x, int y, int z)
|
||||
{
|
||||
return chunk.getLightEmission(new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLight(int x, int y, int z) {
|
||||
if (lightSource == null) return -1;
|
||||
return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
if (lightSource == null) return -1;
|
||||
return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
|
||||
public ChunkAccess getChunk() {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosX(){
|
||||
return chunk.getPos().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkPosZ(){
|
||||
return chunk.getPos().z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosX(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosZ(){
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY(int x, int z) {
|
||||
return chunk.getHeight(Heightmap.Types.WORLD_SURFACE, Math.floorMod(x, 16), Math.floorMod(z, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxX(){
|
||||
return chunk.getPos().getMaxBlockX();
|
||||
}
|
||||
@Override
|
||||
public int getMaxZ(){
|
||||
return chunk.getPos().getMaxBlockZ();
|
||||
}
|
||||
@Override
|
||||
public int getMinX(){
|
||||
return chunk.getPos().getMinBlockX();
|
||||
}
|
||||
@Override
|
||||
public int getMinZ() {
|
||||
return chunk.getPos().getMinBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLongChunkPos() {
|
||||
return chunk.getPos().toLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightCorrect(){
|
||||
#if PRE_MC_1_18_1
|
||||
return true;
|
||||
#else
|
||||
if (chunk instanceof LevelChunk) {
|
||||
return ((LevelChunk) chunk).isClientLightReady();
|
||||
}
|
||||
return chunk.isLightCorrect();
|
||||
#endif
|
||||
}
|
||||
|
||||
public boolean isWaterLogged(int x, int y, int z)
|
||||
{
|
||||
BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z));
|
||||
|
||||
//This type of block is always in water
|
||||
return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock))
|
||||
&& (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEmittedBrightness(int x, int y, int z)
|
||||
{
|
||||
return chunk.getLightEmission(new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLight(int x, int y, int z) {
|
||||
if (lightSource == null) return -1;
|
||||
return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
if (lightSource == null) return -1;
|
||||
return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesNearbyChunksExist() {
|
||||
if (lightSource instanceof LightedWorldGenRegion) return true;
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
if (dx==0 && dz==0) continue;
|
||||
if (lightSource.getChunk(dx+getChunkPosX(), dz+getChunkPosZ(), ChunkStatus.BIOMES, false) == null) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public LevelReader getColorResolver()
|
||||
{
|
||||
return lightSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesNearbyChunksExist() {
|
||||
if (lightSource instanceof LightedWorldGenRegion) return true;
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
if (dx == 0 && dz == 0) continue;
|
||||
if (lightSource.getChunk(dx + getChunkPosX(), dz + getChunkPosZ(), ChunkStatus.BIOMES, false) == null)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return chunk.getClass().getSimpleName() + chunk.getPos();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+502
-95
@@ -3,7 +3,6 @@ package com.seibel.lod.common.wrappers.config;
|
||||
import com.seibel.lod.core.enums.config.*;
|
||||
import com.seibel.lod.core.enums.rendering.*;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer;
|
||||
import com.seibel.lod.common.Config;
|
||||
|
||||
/**
|
||||
@@ -16,47 +15,47 @@ import com.seibel.lod.common.Config;
|
||||
public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
{
|
||||
public static final LodConfigWrapperSingleton INSTANCE = new LodConfigWrapperSingleton();
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Client client = new Client();
|
||||
@Override
|
||||
public IClient client()
|
||||
{
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
public static class Client implements IClient
|
||||
{
|
||||
public final IGraphics graphics;
|
||||
public final IWorldGenerator worldGenerator;
|
||||
public final IMultiplayer multiplayer;
|
||||
public final IAdvanced advanced;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IGraphics graphics()
|
||||
{
|
||||
return graphics;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IWorldGenerator worldGenerator()
|
||||
{
|
||||
return worldGenerator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMultiplayer multiplayer() {
|
||||
return multiplayer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAdvanced advanced()
|
||||
{
|
||||
return advanced;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getOptionsButton()
|
||||
{
|
||||
@@ -68,8 +67,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("optionsButton").value = newOptionsButton;
|
||||
ConfigGui.editSingleOption.saveOption("optionsButton");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// Client Configs //
|
||||
//================//
|
||||
@@ -80,8 +79,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
multiplayer = new Multiplayer();
|
||||
advanced = new Advanced();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==================//
|
||||
// Graphics Configs //
|
||||
//==================//
|
||||
@@ -90,36 +89,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
public final IQuality quality;
|
||||
public final IFogQuality fogQuality;
|
||||
public final IAdvancedGraphics advancedGraphics;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IQuality quality()
|
||||
{
|
||||
return quality;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IFogQuality fogQuality()
|
||||
{
|
||||
return fogQuality;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAdvancedGraphics advancedGraphics()
|
||||
{
|
||||
return advancedGraphics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Graphics()
|
||||
{
|
||||
quality = new Quality();
|
||||
fogQuality = new FogQuality();
|
||||
advancedGraphics = new AdvancedGraphics();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Quality implements IQuality
|
||||
{
|
||||
@Override
|
||||
@@ -133,8 +132,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.drawResolution").value = newHorizontalResolution;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.drawResolution");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getLodChunkRenderDistance()
|
||||
{
|
||||
@@ -146,8 +145,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodChunkRenderDistance").value = newLodChunkRenderDistance;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodChunkRenderDistance");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VerticalQuality getVerticalQuality()
|
||||
{
|
||||
@@ -159,8 +158,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.verticalQuality").value = newVerticalQuality;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.verticalQuality");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getHorizontalScale()
|
||||
{
|
||||
@@ -172,8 +171,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalScale").value = newHorizontalScale;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalScale");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HorizontalQuality getHorizontalQuality()
|
||||
{
|
||||
@@ -185,7 +184,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalQuality").value = newHorizontalQuality;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalQuality");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DropoffQuality getDropoffQuality() {
|
||||
return Config.Client.Graphics.Quality.dropoffQuality;
|
||||
@@ -195,11 +194,29 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.dropoffQuality").value = newDropoffQuality;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.dropoffQuality");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLodBiomeBlending() {
|
||||
return Config.Client.Graphics.Quality.lodBiomeBlending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLodBiomeBlending(int newLodBiomeBlending) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodBiomeBlending").value = newLodBiomeBlending;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodBiomeBlending");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class FogQuality implements IFogQuality
|
||||
{
|
||||
public final IAdvancedFog advancedFog;
|
||||
|
||||
FogQuality()
|
||||
{
|
||||
advancedFog = new AdvancedFog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FogDistance getFogDistance()
|
||||
{
|
||||
@@ -211,36 +228,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDistance").value = newFogDistance;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDistance");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FogDrawMode getFogDrawMode()
|
||||
{
|
||||
return Config.Client.Graphics.FogQuality.fogDrawMode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFogDrawMode(FogDrawMode setFogDrawMode)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDrawMode").value = setFogDrawMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDrawMode");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FogColorMode getFogColorMode()
|
||||
{
|
||||
return Config.Client.Graphics.FogQuality.fogColorMode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFogColorMode(FogColorMode newFogColorMode)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogColorMode").value = newFogColorMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogColorMode");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getDisableVanillaFog()
|
||||
{
|
||||
@@ -252,9 +269,170 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAdvancedFog advancedFog() {
|
||||
return advancedFog;
|
||||
}
|
||||
|
||||
public static class AdvancedFog implements IAdvancedFog {
|
||||
public final IHeightFog heightFog;
|
||||
|
||||
public AdvancedFog() {
|
||||
heightFog = new HeightFog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFarFogStart() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogStart;
|
||||
}
|
||||
@Override
|
||||
public double getFarFogEnd() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogEnd;
|
||||
}
|
||||
@Override
|
||||
public double getFarFogMin() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMin;
|
||||
}
|
||||
@Override
|
||||
public double getFarFogMax() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax;
|
||||
}
|
||||
@Override
|
||||
public FogSetting.FogType getFarFogType() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType;
|
||||
}
|
||||
@Override
|
||||
public double getFarFogDensity() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogDensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFarFogStart(double newFarFogStart) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogStart").value = newFarFogStart;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogStart");
|
||||
}
|
||||
@Override
|
||||
public void setFarFogEnd(double newFarFogEnd) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogEnd").value = newFarFogEnd;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogEnd");
|
||||
}
|
||||
@Override
|
||||
public void setFarFogMin(double newFarFogMin) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMin").value = newFarFogMin;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMin");
|
||||
}
|
||||
@Override
|
||||
public void setFarFogMax(double newFarFogMax) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMax").value = newFarFogMax;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax");
|
||||
}
|
||||
@Override
|
||||
public void setFarFogType(FogSetting.FogType newFarFogType) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType");
|
||||
}
|
||||
@Override
|
||||
public void setFarFogDensity(double newFarFogDensity) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogDensity").value = newFarFogDensity;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogDensity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHeightFog heightFog() {
|
||||
return heightFog;
|
||||
}
|
||||
|
||||
public static class HeightFog implements IHeightFog {
|
||||
|
||||
@Override
|
||||
public HeightFogMixMode getHeightFogMixMode() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMixMode;
|
||||
}
|
||||
@Override
|
||||
public HeightFogMode getHeightFogMode() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMode;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogHeight() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogHeight;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogStart() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogStart;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogEnd() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogEnd;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogMin() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMin;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogMax() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMax;
|
||||
}
|
||||
@Override
|
||||
public FogSetting.FogType getHeightFogType() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogType;
|
||||
}
|
||||
@Override
|
||||
public double getHeightFogDensity() {
|
||||
return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogDensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightFogMixMode(HeightFogMixMode newHeightFogMixMode) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode").value = newHeightFogMixMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogMode(HeightFogMode newHeightFogMode) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogHeight(double newHeightFogHeight) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight").value = newHeightFogHeight;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogStart(double newHeightFogStart) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogEnd(double newHeightFogEnd) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd").value = newHeightFogEnd;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogMin(double newHeightFogMin) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin").value = newHeightFogMin;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogMax(double newHeightFogMax) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax").value = newHeightFogMax;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogType(FogSetting.FogType newHeightFogType) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType");
|
||||
}
|
||||
@Override
|
||||
public void setHeightFogDensity(double newHeightFogDensity) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity").value = newHeightFogDensity;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class AdvancedGraphics implements IAdvancedGraphics
|
||||
{
|
||||
@Override
|
||||
@@ -268,8 +446,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.disableDirectionalCulling").value = newDisableDirectionalCulling;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VanillaOverdraw getVanillaOverdraw()
|
||||
{
|
||||
@@ -281,6 +459,17 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.vanillaOverdraw").value = newVanillaOverdraw;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.vanillaOverdraw");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOverdrawOffset() {
|
||||
return Config.Client.Graphics.AdvancedGraphics.overdrawOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverdrawOffset(int newOverdrawOffset) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.overdrawOffset").value = newOverdrawOffset;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.overdrawOffset");
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public int getBacksideCullingRange()
|
||||
@@ -293,7 +482,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.backsideCullingRange").value = newBacksideCullingRange;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.backsideCullingRange");
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getUseExtendedNearClipPlane()
|
||||
{
|
||||
@@ -305,12 +494,73 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBrightnessMultiplier()
|
||||
{
|
||||
return Config.Client.Graphics.AdvancedGraphics.brightnessMultiplier;
|
||||
}
|
||||
@Override
|
||||
public void setBrightnessMultiplier(double newBrightnessMultiplier)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.brightnessMultiplier").value = newBrightnessMultiplier;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.brightnessMultiplier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSaturationMultiplier()
|
||||
{
|
||||
return Config.Client.Graphics.AdvancedGraphics.saturationMultiplier;
|
||||
}
|
||||
@Override
|
||||
public void setSaturationMultiplier(double newSaturationMultiplier)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.saturationMultiplier").value = newSaturationMultiplier;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.saturationMultiplier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableCaveCulling() {
|
||||
return Config.Client.Graphics.AdvancedGraphics.enableCaveCulling;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnableCaveCulling(boolean newEnableCaveCulling) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.enableCaveCulling").value = newEnableCaveCulling;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.enableCaveCulling");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCaveCullingHeight() {
|
||||
return Config.Client.Graphics.AdvancedGraphics.caveCullingHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaveCullingHeight(int newCaveCullingHeight) {
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.caveCullingHeight").value = newCaveCullingHeight;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.caveCullingHeight");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEarthCurveRatio()
|
||||
{
|
||||
return (int) ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.earthCurveRatio").value;
|
||||
}
|
||||
@Override
|
||||
public void setEarthCurveRatio(int newEarthCurveRatio)
|
||||
{
|
||||
if (newEarthCurveRatio < 50) newEarthCurveRatio = 0;
|
||||
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.earthCurveRatio").value = newEarthCurveRatio;
|
||||
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.earthCurveRatio");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================//
|
||||
// WorldGenerator Configs //
|
||||
//========================//
|
||||
@@ -327,8 +577,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.worldGenerator.generationPriority").value = newGenerationPriority;
|
||||
ConfigGui.editSingleOption.saveOption("client.worldGenerator.generationPriority");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public DistanceGenerationMode getDistanceGenerationMode()
|
||||
{
|
||||
@@ -341,6 +591,20 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.saveOption("client.worldGenerator.distanceGenerationMode");
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean getAllowUnstableFeatureGeneration()
|
||||
{
|
||||
return Config.Client.WorldGenerator.allowUnstableFeatureGeneration;
|
||||
}
|
||||
@Override
|
||||
public void setAllowUnstableFeatureGeneration(boolean newAllowUnstableFeatureGeneration)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration;
|
||||
ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration");
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public BlocksToAvoid getBlocksToAvoid()
|
||||
{
|
||||
@@ -375,9 +639,9 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.saveOption("client.worldGenerator.lightGenerationMode");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=====================//
|
||||
// Multiplayer Configs //
|
||||
//=====================//
|
||||
@@ -394,12 +658,23 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getMultiDimensionRequiredSimilarity()
|
||||
{
|
||||
return Config.Client.Multiplayer.multiDimensionRequiredSimilarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.multiplayer.multiDimensionMinimumSimilarityPercent").value = newMultiDimensionMinimumSimilarityPercent;
|
||||
ConfigGui.editSingleOption.saveOption("client.multiplayer.multiDimensionMinimumSimilarityPercent");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//============================//
|
||||
// AdvancedModOptions Configs //
|
||||
//============================//
|
||||
@@ -408,22 +683,22 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
public final IThreading threading;
|
||||
public final IDebugging debugging;
|
||||
public final IBuffers buffers;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IThreading threading()
|
||||
{
|
||||
return threading;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IDebugging debugging()
|
||||
{
|
||||
return debugging;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IBuffers buffers()
|
||||
{
|
||||
@@ -437,22 +712,22 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
debugging = new Debugging();
|
||||
buffers = new Buffers();
|
||||
}
|
||||
|
||||
|
||||
public static class Threading implements IThreading
|
||||
{
|
||||
@Override
|
||||
public int getNumberOfWorldGenerationThreads()
|
||||
public double getNumberOfWorldGenerationThreads()
|
||||
{
|
||||
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads;
|
||||
}
|
||||
@Override
|
||||
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
|
||||
public void setNumberOfWorldGenerationThreads(double newNumberOfWorldGenerationThreads)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getNumberOfBufferBuilderThreads()
|
||||
{
|
||||
@@ -465,28 +740,38 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfBufferBuilderThreads");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===============//
|
||||
// Debug Options //
|
||||
//===============//
|
||||
public static class Debugging implements IDebugging
|
||||
{
|
||||
public final IDebugSwitch debugSwitch;
|
||||
|
||||
@Override
|
||||
public boolean getDrawLods()
|
||||
public IDebugSwitch debugSwitch()
|
||||
{
|
||||
return (boolean) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value;
|
||||
}
|
||||
@Override
|
||||
public void setDrawLods(boolean newDrawLods)
|
||||
{
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods");
|
||||
return debugSwitch;
|
||||
}
|
||||
|
||||
|
||||
/* RendererType:
|
||||
* DEFAULT
|
||||
* DEBUG
|
||||
* DISABLED
|
||||
* */
|
||||
@Override
|
||||
public RendererType getRendererType() {
|
||||
return (RendererType) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.rendererType").value;
|
||||
}
|
||||
@Override
|
||||
public void setRendererType(RendererType newRenderType) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.rendererType").value = newRenderType;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.rendererType");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DebugMode getDebugMode()
|
||||
{
|
||||
@@ -498,8 +783,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugMode").value = newDebugMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugMode");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getDebugKeybindingsEnabled()
|
||||
{
|
||||
@@ -511,12 +796,122 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.enableDebugKeybindings").value = newEnableDebugKeybindings;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings");
|
||||
}
|
||||
|
||||
public Debugging()
|
||||
{
|
||||
debugSwitch = new DebugSwitch();
|
||||
}
|
||||
|
||||
public static class DebugSwitch implements IDebugSwitch {
|
||||
|
||||
/* The logging switches available:
|
||||
* WorldGenEvent
|
||||
* WorldGenPerformance
|
||||
* WorldGenLoadEvent
|
||||
* LodBuilderEvent
|
||||
* RendererBufferEvent
|
||||
* RendererGLEvent
|
||||
* FileReadWriteEvent
|
||||
* FileSubDimEvent
|
||||
* NetworkEvent //NOT IMPL YET
|
||||
*/
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogWorldGenEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogWorldGenEvent(LoggerMode newLogWorldGenEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenEvent").value = newLogWorldGenEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogWorldGenPerformance() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenPerformance").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogWorldGenPerformance(LoggerMode newLogWorldGenPerformance) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenPerformance").value = newLogWorldGenPerformance;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenPerformance");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogWorldGenLoadEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogWorldGenLoadEvent(LoggerMode newLogWorldGenLoadEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent").value = newLogWorldGenLoadEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogLodBuilderEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logLodBuilderEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogLodBuilderEvent(LoggerMode newLogLodBuilderEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logLodBuilderEvent").value = newLogLodBuilderEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logLodBuilderEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogRendererBufferEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererBufferEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogRendererBufferEvent(LoggerMode newLogRendererBufferEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererBufferEvent").value = newLogRendererBufferEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logRendererBufferEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogRendererGLEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererGLEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogRendererGLEvent(LoggerMode newLogRendererGLEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererGLEvent").value = newLogRendererGLEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logRendererGLEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogFileReadWriteEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileReadWriteEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogFileReadWriteEvent(LoggerMode newLogFileReadWriteEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileReadWriteEvent").value = newLogFileReadWriteEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logFileReadWriteEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogFileSubDimEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileSubDimEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogFileSubDimEvent(LoggerMode newLogFileSubDimEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileSubDimEvent").value = newLogFileSubDimEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logFileSubDimEvent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerMode getLogNetworkEvent() {
|
||||
return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logNetworkEvent").value;
|
||||
}
|
||||
@Override
|
||||
public void setLogNetworkEvent(LoggerMode newLogNetworkEvent) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logNetworkEvent").value = newLogNetworkEvent;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logNetworkEvent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class Buffers implements IBuffers
|
||||
{
|
||||
|
||||
|
||||
@Override
|
||||
public GpuUploadMethod getGpuUploadMethod()
|
||||
{
|
||||
@@ -528,8 +923,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadMethod").value = newDisableVanillaFog;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadMethod");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getGpuUploadPerMegabyteInMilliseconds()
|
||||
{
|
||||
@@ -540,8 +935,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds").value = newMilliseconds;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public BufferRebuildTimes getRebuildTimes()
|
||||
{
|
||||
@@ -554,6 +949,18 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.newBufferRebuildTimes");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getLodOnlyMode() {
|
||||
return Config.Client.Advanced.lodOnlyMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLodOnlyMode(boolean newLodOnlyMode) {
|
||||
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.lodOnlyMode").value = newLodOnlyMode;
|
||||
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.lodOnlyMode");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
-21
@@ -1,10 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.config;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
@@ -12,9 +31,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||
* Creates a button with a texture on it
|
||||
*/
|
||||
public class TexturedButtonWidget extends ImageButton {
|
||||
// public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, ResourceLocation texture, OnPress pressAction) {
|
||||
// super(x, y, width, height, u, v, texture, pressAction);
|
||||
// }
|
||||
#if POST_MC_1_17_1
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, ResourceLocation texture, OnPress pressAction) {
|
||||
super(x, y, width, height, u, v, texture, pressAction);
|
||||
}
|
||||
#endif
|
||||
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation texture, int textureWidth, int textureHeight, OnPress pressAction) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction);
|
||||
}
|
||||
@@ -23,24 +45,55 @@ public class TexturedButtonWidget extends ImageButton {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction, text);
|
||||
}
|
||||
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation texture, int textureWidth, int textureHeight, OnPress pressAction, OnTooltip tooltipSupplier, Component text) {
|
||||
super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction, tooltipSupplier, text);
|
||||
// public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation texture, int textureWidth, int textureHeight, OnPress pressAction, OnTooltip tooltipSupplier, Component text) {
|
||||
// super(x, y, width, height, u, v, hoveredVOffset, texture, textureWidth, textureHeight, pressAction, tooltipSupplier, text);
|
||||
// }
|
||||
|
||||
#if PRE_MC_1_19_4
|
||||
@Override
|
||||
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
#if PRE_MC_1_17_1
|
||||
Minecraft.getInstance().getTextureManager().bind(WIDGETS_LOCATION);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
#else
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
#endif
|
||||
|
||||
int i = this.getYImage(this.isHovered);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
#if PRE_MC_1_19_3
|
||||
this.blit(matrices, this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
|
||||
this.blit(matrices, this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
|
||||
#else
|
||||
this.blit(matrices, this.getX(), this.getY(), 0, 46 + i * 20, this.getWidth() / 2, this.getHeight());
|
||||
this.blit(matrices, this.getX() + this.getWidth() / 2, this.getY(), 200 - this.width / 2, 46 + i * 20, this.getWidth() / 2, this.getHeight());
|
||||
#endif
|
||||
|
||||
super.renderButton(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public void renderWidget(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
|
||||
@Override
|
||||
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
int i = 1;
|
||||
if (!this.active)
|
||||
i = 0;
|
||||
else if (this.isHovered)
|
||||
i = 2;
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
this.blit(matrices, this.getX(), this.getY(), 0, 46 + i * 20, this.getWidth() / 2, this.getHeight());
|
||||
this.blit(matrices, this.getX() + this.getWidth() / 2, this.getY(), 200 - this.width / 2, 46 + i * 20, this.getWidth() / 2, this.getHeight());
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bind(WIDGETS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
|
||||
int i = getYImage(isHovered());
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
this.blit(matrices, this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
|
||||
this.blit(matrices, this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2,
|
||||
this.height);
|
||||
|
||||
super.renderButton(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
super.renderWidget(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+26
-58
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,7 +27,6 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
@@ -56,19 +55,22 @@ import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
#endif
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A singleton that wraps the Minecraft class
|
||||
* to allow for easier movement between Minecraft versions.
|
||||
* A singleton that wraps the Minecraft object.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 9-16-2021
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
{
|
||||
@@ -165,57 +167,6 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
return LodUtil.getDimensionIDFromWorld(WorldWrapper.getWorldWrapper(mc.level));
|
||||
}
|
||||
|
||||
/** This texture changes every frame */
|
||||
@Override
|
||||
public ILightMapWrapper getCurrentLightMap()
|
||||
{
|
||||
// get the current lightMap if the cache is empty
|
||||
if (lightMap == null)
|
||||
{
|
||||
LightTexture tex = mc.gameRenderer.lightTexture();
|
||||
lightMap = tex.lightPixels;
|
||||
}
|
||||
return new LightMapWrapper(lightMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color int at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param blockLight x location in texture space
|
||||
* @param skyLight z location in texture space
|
||||
*/
|
||||
@Override
|
||||
public int getColorIntFromLightMap(int blockLight, int skyLight)
|
||||
{
|
||||
if (lightMap == null)
|
||||
{
|
||||
sendChatMessage("new");
|
||||
// make sure the lightMap is up-to-date
|
||||
getCurrentLightMap();
|
||||
}
|
||||
|
||||
return lightMap.getPixelRGBA(blockLight, skyLight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Color at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param blockLight x location in texture space
|
||||
* @param skyLight z location in texture space
|
||||
*/
|
||||
@Override
|
||||
public Color getColorFromLightMap(int blockLight, int skyLight) {
|
||||
if (lightMap == null) {
|
||||
// make sure the lightMap is up-to-date
|
||||
getCurrentLightMap();
|
||||
}
|
||||
|
||||
return LodUtil.intToColor(lightMap.getPixelRGBA(blockLight, skyLight));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// Simple gets //
|
||||
//=============//
|
||||
@@ -241,7 +192,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
@Override
|
||||
public ChunkPosWrapper getPlayerChunkPos()
|
||||
{
|
||||
return new ChunkPosWrapper(getPlayer().chunkPosition().x, getPlayer().chunkPosition().z);
|
||||
#if PRE_MC_1_17_1
|
||||
ChunkPos playerPos = new ChunkPos(getPlayer().blockPosition());
|
||||
#else
|
||||
ChunkPos playerPos = getPlayer().chunkPosition();
|
||||
#endif
|
||||
return new ChunkPosWrapper(playerPos.x, playerPos.z);
|
||||
}
|
||||
|
||||
public Options getOptions()
|
||||
@@ -374,6 +330,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
return mc.getCurrentServer() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerSkylight() {
|
||||
if (mc.level == null) return -1;
|
||||
if (mc.player == null) return -1;
|
||||
if (mc.player.blockPosition() == null) return -1;
|
||||
return mc.level.getBrightness(LightLayer.SKY, mc.player.blockPosition());
|
||||
}
|
||||
|
||||
public ServerData getCurrentServer()
|
||||
{
|
||||
return mc.getCurrentServer();
|
||||
@@ -404,7 +368,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
|
||||
@Override
|
||||
public void sendChatMessage(String string)
|
||||
{
|
||||
#if PRE_MC_1_19
|
||||
getPlayer().sendMessage(new TextComponent(string), getPlayer().getUUID());
|
||||
#else
|
||||
getPlayer().sendSystemMessage(Component.translatable(string));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+234
-239
@@ -1,48 +1,78 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.minecraft;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.lod.common.wrappers.WrapperFactory;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.common.wrappers.misc.LightMapWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
#if PRE_MC_1_19_3
|
||||
import com.mojang.math.Vector3f;
|
||||
#else
|
||||
import org.joml.Vector3f;
|
||||
#endif
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import com.seibel.lod.core.objects.math.Vec3d;
|
||||
import com.seibel.lod.core.objects.math.Vec3f;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.WrapperFactory;
|
||||
import com.seibel.lod.common.wrappers.block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
#else
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
#endif
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,261 +80,226 @@ import net.minecraft.world.phys.Vec3;
|
||||
* related to rendering in Minecraft.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 12-14-2021
|
||||
* @version 12-12-2021
|
||||
*/
|
||||
public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
{
|
||||
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
||||
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
||||
|
||||
private static final Minecraft MC = Minecraft.getInstance();
|
||||
private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
|
||||
private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE;
|
||||
|
||||
private static final Minecraft MC = Minecraft.getInstance();
|
||||
private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
|
||||
private static final WrapperFactory FACTORY = WrapperFactory.INSTANCE;
|
||||
public LightMapWrapper lightmap = null;
|
||||
|
||||
@Override
|
||||
public Vec3f getLookAtVector()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
Vector3f cameraDir = camera.getLookVector();
|
||||
return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper getCameraBlockPosition()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
BlockPos blockPos = camera.getBlockPosition();
|
||||
return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHasBlindnessEffect()
|
||||
{
|
||||
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getCameraExactPosition()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
Vec3 projectedView = camera.getPosition();
|
||||
|
||||
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mat4f getDefaultProjectionMatrix(float partialTicks)
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getMainCamera(), partialTicks, true));
|
||||
#else
|
||||
return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGamma()
|
||||
{
|
||||
#if PRE_MC_1_19
|
||||
return MC.options.gamma;
|
||||
#else
|
||||
return MC.options.gamma().get();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFogColor(float partialTicks) {
|
||||
|
||||
|
||||
@Override
|
||||
public Vec3f getLookAtVector()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
Vector3f cameraDir = camera.getLookVector();
|
||||
return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z());
|
||||
#if PRE_MC_1_17_1
|
||||
float[] colorValues = new float[4];
|
||||
GL15.glGetFloatv(GL15.GL_FOG_COLOR, colorValues);
|
||||
#else
|
||||
FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks));
|
||||
float[] colorValues = RenderSystem.getShaderFogColor();
|
||||
#endif
|
||||
return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
|
||||
}
|
||||
// getSpecialFogColor() is the same as getFogColor()
|
||||
|
||||
@Override
|
||||
public Color getSkyColor() {
|
||||
if (MC.level.dimensionType().hasSkyLight()) {
|
||||
#if PRE_MC_1_17_1
|
||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), MC.getFrameTime());
|
||||
#else
|
||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime());
|
||||
#endif
|
||||
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
||||
} else
|
||||
return new Color(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFov(float partialTicks)
|
||||
{
|
||||
return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true);
|
||||
}
|
||||
|
||||
/** Measured in chunks */
|
||||
@Override
|
||||
public int getRenderDistance()
|
||||
{
|
||||
#if PRE_MC_1_18_1
|
||||
//FIXME: How to resolve this?
|
||||
return MC.options.renderDistance;
|
||||
#else
|
||||
return MC.options.getEffectiveRenderDistance();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScreenWidth()
|
||||
{
|
||||
return MC.getWindow().getWidth();
|
||||
}
|
||||
@Override
|
||||
public int getScreenHeight()
|
||||
{
|
||||
return MC.getWindow().getHeight();
|
||||
}
|
||||
|
||||
private RenderTarget getRenderTarget() {
|
||||
RenderTarget r = null; //MC.levelRenderer.getCloudsTarget();
|
||||
return r!=null ? r : MC.getMainRenderTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlockPosWrapper getCameraBlockPosition()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
BlockPos blockPos = camera.getBlockPosition();
|
||||
return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
public int getTargetFrameBuffer() {
|
||||
return getRenderTarget().frameBufferId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHasBlindnessEffect()
|
||||
{
|
||||
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null;
|
||||
public int getTargetFrameBufferViewportWidth() {
|
||||
return getRenderTarget().viewWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getCameraExactPosition()
|
||||
{
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
Vec3 projectedView = camera.getPosition();
|
||||
|
||||
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
||||
public int getTargetFrameBufferViewportHeight() {
|
||||
return getRenderTarget().viewHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mat4f getDefaultProjectionMatrix(float partialTicks)
|
||||
{
|
||||
return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getMainCamera(), partialTicks, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGamma()
|
||||
{
|
||||
return MC.options.gamma;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFogColor(float partialTick) {
|
||||
float[] colorValues = new float[4];
|
||||
GL15.glGetFloatv(GL15.GL_FOG_COLOR, colorValues);
|
||||
return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
|
||||
}
|
||||
// getSpecialFogColor() is the same as getFogColor()
|
||||
|
||||
@Override
|
||||
public Color getSkyColor() {
|
||||
if (MC.level.dimensionType().hasSkyLight()) {
|
||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime());
|
||||
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
||||
} else
|
||||
return new Color(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFov(float partialTicks)
|
||||
{
|
||||
return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true);
|
||||
}
|
||||
|
||||
/** Measured in chunks */
|
||||
@Override
|
||||
public int getRenderDistance()
|
||||
{
|
||||
return MC.options.renderDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScreenWidth()
|
||||
{
|
||||
return MC.getWindow().getWidth();
|
||||
}
|
||||
@Override
|
||||
public int getScreenHeight()
|
||||
{
|
||||
return MC.getWindow().getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the ChunkPos of all chunks that Minecraft
|
||||
* is going to render this frame. <br><br>
|
||||
* <p>
|
||||
*/
|
||||
/**
|
||||
* This method returns the ChunkPos of all chunks that Minecraft
|
||||
* is going to render this frame. <br><br>
|
||||
* <p>
|
||||
*/
|
||||
|
||||
public boolean usingBackupGetVanillaRenderedChunks = false;
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getVanillaRenderedChunks()
|
||||
{
|
||||
ISodiumAccessor sodium = ModAccessorHandler.get(ISodiumAccessor.class);
|
||||
if (sodium != null)
|
||||
{
|
||||
return sodium.getNormalRenderedChunks();
|
||||
}
|
||||
IOptifineAccessor optifine = ModAccessorHandler.get(IOptifineAccessor.class);
|
||||
if (optifine != null)
|
||||
{
|
||||
HashSet<AbstractChunkPosWrapper> pos = optifine.getNormalRenderedChunks();
|
||||
if (pos==null) pos = getMaximumRenderedChunks();
|
||||
return pos;
|
||||
}
|
||||
if (!usingBackupGetVanillaRenderedChunks) {
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getVanillaRenderedChunks() {
|
||||
ISodiumAccessor sodium = ModAccessorHandler.get(ISodiumAccessor.class);
|
||||
if (sodium != null) {
|
||||
return sodium.getNormalRenderedChunks();
|
||||
}
|
||||
IOptifineAccessor optifine = ModAccessorHandler.get(IOptifineAccessor.class);
|
||||
if (optifine != null) {
|
||||
HashSet<AbstractChunkPosWrapper> pos = optifine.getNormalRenderedChunks();
|
||||
if (pos == null)
|
||||
pos = getMaximumRenderedChunks();
|
||||
return pos;
|
||||
}
|
||||
if (!usingBackupGetVanillaRenderedChunks) {
|
||||
try {
|
||||
LevelRenderer levelRenderer = MC.levelRenderer;
|
||||
ObjectList<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunks;
|
||||
return (chunks.stream().map((chunk) -> {
|
||||
AABB chunkBoundingBox = chunk.chunk.bb;
|
||||
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
|
||||
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
LevelRenderer levelRenderer = MC.levelRenderer;
|
||||
Collection<LevelRenderer.RenderChunkInfo> chunks =
|
||||
#if PRE_MC_1_18_1 levelRenderer.renderChunks;
|
||||
#else levelRenderer.renderChunkStorage.get().renderChunks; #endif
|
||||
|
||||
return (chunks.stream().map((chunk) -> {
|
||||
AABB chunkBoundingBox =
|
||||
#if PRE_MC_1_18_2 chunk.chunk.bb;
|
||||
#else chunk.chunk.getBoundingBox(); #endif
|
||||
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
|
||||
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
} catch (LinkageError e) {
|
||||
try {
|
||||
MinecraftClientWrapper.INSTANCE.sendChatMessage(
|
||||
"\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed."
|
||||
+ " Using Backup Method.");
|
||||
+ " Using Backup Method.");
|
||||
MinecraftClientWrapper.INSTANCE.sendChatMessage(
|
||||
"\u00A7eOverdraw prevention will be worse than normal.");
|
||||
} catch (Exception e2) {}
|
||||
ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e);
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e);
|
||||
usingBackupGetVanillaRenderedChunks = true;
|
||||
}
|
||||
}
|
||||
return getMaximumRenderedChunks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getLightmapPixels()
|
||||
{
|
||||
LightTexture tex = GAME_RENDERER.lightTexture();
|
||||
tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug
|
||||
NativeImage lightMapPixels = tex.lightPixels;
|
||||
LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels);
|
||||
|
||||
|
||||
int lightMapHeight = getLightmapTextureHeight();
|
||||
int lightMapWidth = getLightmapTextureWidth();
|
||||
|
||||
int pixels[] = new int[lightMapWidth * lightMapHeight];
|
||||
for (int u = 0; u < lightMapWidth; u++)
|
||||
{
|
||||
for (int v = 0; v < lightMapWidth; v++)
|
||||
{
|
||||
// this could probably be kept as a int, but
|
||||
// it is easier to test and see the colors when debugging this way.
|
||||
// When creating a new release this should be changed to the int version.
|
||||
Color c = LodUtil.intToColor(lightMap.getLightValue(u, v));
|
||||
|
||||
// these should both create a totally white image
|
||||
// int col =
|
||||
// Integer.MAX_VALUE;
|
||||
// int col =
|
||||
// 0b11111111 + // red
|
||||
// (0b11111111 << 8) + // green
|
||||
// (0b11111111 << 16) + // blue
|
||||
// (0b11111111 << 24); // blue
|
||||
|
||||
int col =
|
||||
((c.getRed() & 0xFF) << 16) | // blue
|
||||
((c.getGreen() & 0xFF) << 8) | // green
|
||||
((c.getBlue() & 0xFF)) | // red
|
||||
((c.getAlpha() & 0xFF) << 24); // alpha
|
||||
|
||||
|
||||
// 2D array stored in a 1D array.
|
||||
// Thank you Tim from College ;)
|
||||
pixels[u * lightMapWidth + v] = col;
|
||||
}
|
||||
}
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightmapTextureHeight()
|
||||
{
|
||||
int height = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null)
|
||||
{
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null)
|
||||
{
|
||||
height = tex.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightmapTextureWidth()
|
||||
{
|
||||
int width = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null)
|
||||
{
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null)
|
||||
{
|
||||
width = tex.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightmapGLFormat() {
|
||||
int glFormat = -1;
|
||||
|
||||
LightTexture lightTexture = GAME_RENDERER.lightTexture();
|
||||
if (lightTexture != null) {
|
||||
NativeImage tex = lightTexture.lightPixels;
|
||||
if (tex != null) {
|
||||
glFormat = tex.format().glFormat();
|
||||
}
|
||||
}
|
||||
|
||||
return glFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFogStateSpecial() {
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
FogType fogType = camera.getFluidInCamera();
|
||||
Entity entity = camera.getEntity();
|
||||
boolean enableFog = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
enableFog |= fogType.equals(FogType.WATER);
|
||||
enableFog |= fogType.equals(FogType.LAVA);
|
||||
enableFog |= fogType.equals(FogType.POWDER_SNOW);
|
||||
return enableFog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryDisableVanillaFog() {
|
||||
return true; // Handled via the MixinFogRenderer at fabric and forge
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILightMapWrapper getLightmapWrapper() {
|
||||
return lightmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFogStateSpecial() {
|
||||
#if PRE_MC_1_17_1
|
||||
Camera camera = GAME_RENDERER.getMainCamera();
|
||||
FluidState fluidState = camera.getFluidInCamera();
|
||||
Entity entity = camera.getEntity();
|
||||
boolean isUnderWater = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
isUnderWater |= fluidState.is(FluidTags.WATER);
|
||||
isUnderWater |= fluidState.is(FluidTags.LAVA);
|
||||
return isUnderWater;
|
||||
#else
|
||||
Entity entity = GAME_RENDERER.getMainCamera().getEntity();
|
||||
boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryDisableVanillaFog() {
|
||||
return true; // Handled via MixinFogRenderer in both forge and fabric
|
||||
}
|
||||
|
||||
public void updateLightmap(NativeImage lightPixels) {
|
||||
if (lightmap== null) {
|
||||
lightmap = new LightMapWrapper();
|
||||
}
|
||||
lightmap.uploadLightmap(lightPixels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.minecraft;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.misc;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
@@ -9,21 +33,39 @@ import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
*/
|
||||
public class LightMapWrapper implements ILightMapWrapper
|
||||
{
|
||||
static NativeImage lightMap = null;
|
||||
private int textureId = 0;
|
||||
|
||||
public LightMapWrapper(NativeImage newLightMap)
|
||||
public LightMapWrapper()
|
||||
{
|
||||
lightMap = newLightMap;
|
||||
}
|
||||
|
||||
public static void setLightMap(NativeImage newLightMap)
|
||||
private void createLightmap(NativeImage image)
|
||||
{
|
||||
lightMap = newLightMap;
|
||||
textureId = GL32.glGenTextures();
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, image.format().glFormat(), image.getWidth(), image.getHeight(),
|
||||
0, image.format().glFormat(), GL32.GL_UNSIGNED_BYTE, (ByteBuffer) null);
|
||||
}
|
||||
|
||||
public void uploadLightmap(NativeImage image)
|
||||
{
|
||||
int currentBind = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
if (textureId == 0) {
|
||||
createLightmap(image);
|
||||
}
|
||||
// NativeImage::upload(int levelOfDetail, int xOffset, int yOffset, bool shouldCleanup?)
|
||||
image.upload(0, 0, 0, false);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, currentBind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(int skyLight, int blockLight)
|
||||
{
|
||||
return lightMap.getPixelRGBA(skyLight, blockLight);
|
||||
public void bind() {
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, textureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbind() {
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,14 +20,35 @@
|
||||
package com.seibel.lod.common.wrappers.world;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
|
||||
#if PRE_MC_1_19_3
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
#else
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
#endif
|
||||
|
||||
#if POST_MC_1_19
|
||||
import net.minecraft.data.worldgen.biome.EndBiomes;
|
||||
import net.minecraft.data.worldgen.biome.NetherBiomes;
|
||||
#endif
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
|
||||
@@ -36,7 +57,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
{
|
||||
|
||||
public static final ConcurrentMap<Biome, BiomeWrapper> biomeWrapperMap = new ConcurrentHashMap<>();
|
||||
private Biome biome;
|
||||
private final Biome biome;
|
||||
|
||||
public BiomeWrapper(Biome biome)
|
||||
{
|
||||
@@ -58,14 +79,13 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
return biomeWrapper;
|
||||
}
|
||||
|
||||
|
||||
/** Returns a color int for the given biome. */
|
||||
#if PRE_MC_1_19
|
||||
@Override
|
||||
public int getColorForBiome(int x, int z)
|
||||
{
|
||||
int colorInt;
|
||||
|
||||
switch (biome.getBiomeCategory())
|
||||
switch (biome.biomeCategory)
|
||||
{
|
||||
|
||||
case NETHER:
|
||||
@@ -110,21 +130,163 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
case SAVANNA:
|
||||
case SWAMP:
|
||||
default:
|
||||
Color tmp = LodUtil.intToColor(biome.getGrassColor(x, z));
|
||||
tmp = tmp.darker();
|
||||
colorInt = LodUtil.colorToInt(tmp);
|
||||
colorInt = biome.getGrassColor(x,z);
|
||||
//FIXME: Repair what James did - LeeTom
|
||||
// Color tmp = LodUtil.intToColor(biome.getGrassColor(x, z));
|
||||
// tmp = tmp.darker();
|
||||
// colorInt = LodUtil.colorToInt(tmp);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return colorInt;
|
||||
}
|
||||
#else
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return biome.toString();
|
||||
|
||||
private static int _colorEnd(Biome b) {
|
||||
return Blocks.END_STONE.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorNether(Biome b) {
|
||||
return Blocks.NETHERRACK.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorSand(Biome b) {
|
||||
return Blocks.SAND.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorStone(Biome b) {
|
||||
return Blocks.STONE.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorGravel(Biome b) {
|
||||
return Blocks.GRAVEL.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorDripStone(Biome b) {
|
||||
return Blocks.DRIPSTONE_BLOCK.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorMoss(Biome b) {
|
||||
return Blocks.MOSS_BLOCK.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorSculk(Biome b) {
|
||||
return Blocks.SCULK.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorMushoom(Biome b) {
|
||||
return Blocks.MYCELIUM.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorBamboo(Biome b) {
|
||||
return Blocks.BAMBOO.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorSnow(Biome b) {
|
||||
return Blocks.SNOW.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorIce(Biome b) {
|
||||
return Blocks.ICE.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorRedSand(Biome b) {
|
||||
return Blocks.RED_SAND.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorSoulSand(Biome b) {
|
||||
return Blocks.SOUL_SAND.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorBasalt(Biome b) {
|
||||
return Blocks.BASALT.defaultMaterialColor().col;
|
||||
}
|
||||
private static int _colorWater(Biome b) {
|
||||
return b.getWaterColor();
|
||||
}
|
||||
private static int _colorFoliage(Biome b) {
|
||||
return b.getFoliageColor();
|
||||
}
|
||||
|
||||
private static Biome _get(ResourceKey<Biome> r) {
|
||||
#if PRE_MC_1_19_3
|
||||
return BuiltinRegistries.BIOME.getOrThrow(r);
|
||||
#else
|
||||
// The fix below is a hacky and convoluted way of doing the thing above so...
|
||||
// TODO[1.19.3]: Find a less convoluted method to get the Minecraft's registryAccess
|
||||
return (((ServerLevel) ((WorldWrapper) LodUtil.getServerWorldFromDimension(ApiShared.lodWorld.getLodDimension(SingletonHandler.get(IMinecraftClientWrapper.class).getCurrentDimension()).dimension)).getWorld()).getServer().registryAccess()) // This entire mess is just to get Minecraft's registryAccess (FIND A BETTER WAY LATER)
|
||||
.registryOrThrow(Registries.BIOME).getOrThrow(r); // Once youve gotten the registryAccess, the rest is easy
|
||||
#endif
|
||||
}
|
||||
|
||||
//FIXME: THIS IS HELL!
|
||||
private static final ImmutableBiMap<Biome, Function<Biome, Integer>> BIOME_COLOR_MAP =
|
||||
ImmutableBiMap.<Biome, Function<Biome, Integer>>builder()
|
||||
.put(_get(Biomes.SNOWY_PLAINS), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.ICE_SPIKES), BiomeWrapper::_colorIce)
|
||||
.put(_get(Biomes.DESERT), BiomeWrapper::_colorSand)
|
||||
.put(_get(Biomes.SWAMP), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.MANGROVE_SWAMP), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.FLOWER_FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.BIRCH_FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.DARK_FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.OLD_GROWTH_BIRCH_FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.OLD_GROWTH_PINE_TAIGA), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.OLD_GROWTH_SPRUCE_TAIGA), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.TAIGA), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.SNOWY_TAIGA), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.WINDSWEPT_GRAVELLY_HILLS), BiomeWrapper::_colorGravel)
|
||||
.put(_get(Biomes.WINDSWEPT_FOREST), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.JUNGLE), BiomeWrapper::_colorFoliage)
|
||||
.put(_get(Biomes.BAMBOO_JUNGLE), BiomeWrapper::_colorBamboo)
|
||||
.put(_get(Biomes.BADLANDS), BiomeWrapper::_colorRedSand)
|
||||
.put(_get(Biomes.ERODED_BADLANDS), BiomeWrapper::_colorRedSand)
|
||||
.put(_get(Biomes.WOODED_BADLANDS), BiomeWrapper::_colorStone)
|
||||
.put(_get(Biomes.GROVE), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.SNOWY_SLOPES), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.FROZEN_PEAKS), BiomeWrapper::_colorIce)
|
||||
.put(_get(Biomes.JAGGED_PEAKS), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.STONY_PEAKS), BiomeWrapper::_colorStone)
|
||||
.put(_get(Biomes.RIVER), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.FROZEN_RIVER), BiomeWrapper::_colorIce)
|
||||
.put(_get(Biomes.BEACH), BiomeWrapper::_colorSand)
|
||||
.put(_get(Biomes.SNOWY_BEACH), BiomeWrapper::_colorSnow)
|
||||
.put(_get(Biomes.STONY_SHORE), BiomeWrapper::_colorStone)
|
||||
.put(_get(Biomes.WARM_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.LUKEWARM_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.DEEP_LUKEWARM_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.DEEP_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.COLD_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.DEEP_COLD_OCEAN), BiomeWrapper::_colorWater)
|
||||
.put(_get(Biomes.FROZEN_OCEAN), BiomeWrapper::_colorIce)
|
||||
.put(_get(Biomes.DEEP_FROZEN_OCEAN), BiomeWrapper::_colorIce)
|
||||
.put(_get(Biomes.MUSHROOM_FIELDS), BiomeWrapper::_colorMushoom)
|
||||
.put(_get(Biomes.DRIPSTONE_CAVES), BiomeWrapper::_colorDripStone)
|
||||
.put(_get(Biomes.LUSH_CAVES), BiomeWrapper::_colorMoss)
|
||||
.put(_get(Biomes.DEEP_DARK), BiomeWrapper::_colorSculk)
|
||||
.put(_get(Biomes.NETHER_WASTES), BiomeWrapper::_colorNether)
|
||||
.put(_get(Biomes.WARPED_FOREST), BiomeWrapper::_colorNether)
|
||||
.put(_get(Biomes.CRIMSON_FOREST), BiomeWrapper::_colorNether)
|
||||
.put(_get(Biomes.SOUL_SAND_VALLEY), BiomeWrapper::_colorSoulSand)
|
||||
.put(_get(Biomes.BASALT_DELTAS), BiomeWrapper::_colorBasalt)
|
||||
.put(_get(Biomes.THE_END), BiomeWrapper::_colorEnd)
|
||||
.put(_get(Biomes.END_HIGHLANDS), BiomeWrapper::_colorEnd)
|
||||
.put(_get(Biomes.END_MIDLANDS), BiomeWrapper::_colorEnd)
|
||||
.put(_get(Biomes.SMALL_END_ISLANDS), BiomeWrapper::_colorEnd)
|
||||
.put(_get(Biomes.END_BARRENS), BiomeWrapper::_colorEnd)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public int getColorForBiome(int x, int z)
|
||||
{
|
||||
int colorInt;
|
||||
Function<Biome, Integer> colorFunction = BIOME_COLOR_MAP.get(biome);
|
||||
if (colorFunction != null)
|
||||
{
|
||||
colorInt = colorFunction.apply(biome);
|
||||
}
|
||||
else
|
||||
{
|
||||
colorInt = biome.getGrassColor(x, z);
|
||||
}
|
||||
return colorInt;
|
||||
}
|
||||
#endif
|
||||
@Override public String getName()
|
||||
{
|
||||
return biome.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGrassTint(int x, int z)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -34,7 +34,7 @@ import net.minecraft.world.level.dimension.DimensionType;
|
||||
public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||
{
|
||||
private static final ConcurrentMap<DimensionType, DimensionTypeWrapper> dimensionTypeWrapperMap = new ConcurrentHashMap<>();
|
||||
private DimensionType dimensionType;
|
||||
private final DimensionType dimensionType;
|
||||
|
||||
public DimensionTypeWrapper(DimensionType dimensionType)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,13 +23,11 @@ import java.io.File;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.core.enums.WorldType;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
|
||||
import com.seibel.lod.common.wrappers.block.BlockPosWrapper;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -38,7 +36,9 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -51,12 +51,12 @@ public class WorldWrapper implements IWorldWrapper
|
||||
private static final ConcurrentMap<LevelAccessor, WorldWrapper> worldWrapperMap = new ConcurrentHashMap<>();
|
||||
private final LevelAccessor world;
|
||||
public final WorldType worldType;
|
||||
|
||||
|
||||
|
||||
|
||||
public WorldWrapper(LevelAccessor newWorld)
|
||||
{
|
||||
world = newWorld;
|
||||
|
||||
|
||||
if (world.getClass() == ServerLevel.class)
|
||||
worldType = WorldType.ServerWorld;
|
||||
else if (world.getClass() == ClientLevel.class)
|
||||
@@ -64,8 +64,8 @@ public class WorldWrapper implements IWorldWrapper
|
||||
else
|
||||
worldType = WorldType.Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
public static WorldWrapper getWorldWrapper(LevelAccessor world)
|
||||
{
|
||||
@@ -73,100 +73,117 @@ public class WorldWrapper implements IWorldWrapper
|
||||
//first we check if the biome has already been wrapped
|
||||
if(worldWrapperMap.containsKey(world) && worldWrapperMap.get(world) != null)
|
||||
return worldWrapperMap.get(world);
|
||||
|
||||
|
||||
|
||||
|
||||
//if it hasn't been created yet, we create it and save it in the map
|
||||
WorldWrapper worldWrapper = new WorldWrapper(world);
|
||||
worldWrapperMap.put(world, worldWrapper);
|
||||
|
||||
|
||||
//we return the newly created wrapper
|
||||
return worldWrapper;
|
||||
}
|
||||
|
||||
|
||||
public static void clearMap()
|
||||
{
|
||||
worldWrapperMap.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType()
|
||||
{
|
||||
return worldType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DimensionTypeWrapper getDimensionType()
|
||||
{
|
||||
return DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getBlockLight(int x, int y, int z)
|
||||
{
|
||||
return world.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z)
|
||||
{
|
||||
return world.getBrightness(LightLayer.SKY, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
|
||||
public LevelAccessor getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling()
|
||||
{
|
||||
return world.dimensionType().hasCeiling();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight()
|
||||
{
|
||||
return world.dimensionType().hasSkyLight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return world.getHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getMinHeight()
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
return (short) 0;
|
||||
#else
|
||||
return (short) world.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */
|
||||
@Override
|
||||
public File getSaveFolder() throws UnsupportedOperationException
|
||||
{
|
||||
if (worldType != WorldType.ServerWorld)
|
||||
throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds.");
|
||||
|
||||
|
||||
ServerChunkCache chunkSource = ((ServerLevel) world).getChunkSource();
|
||||
return chunkSource.getDataStorage().dataFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */
|
||||
public ServerLevel getServerWorld() throws UnsupportedOperationException
|
||||
{
|
||||
if (worldType != WorldType.ServerWorld)
|
||||
throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds.");
|
||||
|
||||
|
||||
return (ServerLevel) world;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSeaLevel()
|
||||
{
|
||||
// TODO this is depreciated, what should we use instead?
|
||||
return world.getSeaLevel();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) {
|
||||
public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) {
|
||||
ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false);
|
||||
if (chunk == null) return null;
|
||||
return new ChunkWrapper(chunk, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChunkLoaded(int chunkX, int chunkZ) {
|
||||
// world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT!
|
||||
ChunkSource source = world.getChunkSource();
|
||||
return source.hasChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
+314
-188
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2021 Tom Lee (TomTheFurry)
|
||||
* Copyright (C) 2021 Tom Lee (TomTheFurry)
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,20 +17,22 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.util.GridList;
|
||||
import com.seibel.lod.core.util.LodThreadFactory;
|
||||
import com.seibel.lod.core.enums.config.LightGenerationMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.util.gridList.ArrayGridList;
|
||||
import com.seibel.lod.core.util.LodThreadFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
|
||||
|
||||
@@ -41,6 +44,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.ChunkLoader;
|
||||
@@ -55,6 +59,9 @@ import com.seibel.lod.common.wrappers.worldGeneration.step.StepStructureReferenc
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.step.StepStructureStart;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.step.StepSurface;
|
||||
|
||||
#if POST_MC_1_19_3
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#endif
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -66,8 +73,10 @@ import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
/*
|
||||
Total: 3.135214124s
|
||||
@@ -83,14 +92,23 @@ Feature Step: 0.389072425s
|
||||
Lod Generation: 0.269023348s
|
||||
*/
|
||||
|
||||
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvionmentWrapper {
|
||||
public static final boolean ENABLE_PERF_LOGGING = false;
|
||||
public static final boolean ENABLE_EVENT_LOGGING = false;
|
||||
public static final boolean ENABLE_LOAD_EVENT_LOGGING = false;
|
||||
public static final boolean DISABLE_LOADING_SAVES = false;
|
||||
// TODO: Make actual proper support for StarLight
|
||||
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvionmentWrapper
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
public static final ConfigBasedSpamLogger PREF_LOGGER =
|
||||
new ConfigBasedSpamLogger(LogManager.getLogger("LodWorldGen"),
|
||||
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenPerformance(),1);
|
||||
public static final ConfigBasedLogger EVENT_LOGGER =
|
||||
new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
|
||||
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenEvent());
|
||||
public static final ConfigBasedLogger LOAD_LOGGER =
|
||||
new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
|
||||
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenLoadEvent());
|
||||
|
||||
public static class PrefEvent {
|
||||
//TODO: Make actual proper support for StarLight
|
||||
|
||||
public static class PrefEvent
|
||||
{
|
||||
long beginNano = 0;
|
||||
long emptyNano = 0;
|
||||
long structStartNano = 0;
|
||||
@@ -102,20 +120,27 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
long featureNano = 0;
|
||||
long lightNano = 0;
|
||||
long endNano = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "beginNano: " + beginNano + ",\n" + "emptyNano: " + emptyNano + ",\n" + "structStartNano: "
|
||||
+ structStartNano + ",\n" + "structRefNano: " + structRefNano + ",\n" + "biomeNano: " + biomeNano
|
||||
+ ",\n" + "noiseNano: " + noiseNano + ",\n" + "surfaceNano: " + surfaceNano + ",\n" + "carverNano: "
|
||||
+ carverNano + ",\n" + "featureNano: " + featureNano + ",\n" + "lightNano: " + lightNano + ",\n"
|
||||
+ "endNano: " + endNano + "\n";
|
||||
public String toString()
|
||||
{
|
||||
return "beginNano: " + beginNano + ",\n" +
|
||||
"emptyNano: " + emptyNano + ",\n" +
|
||||
"structStartNano: " + structStartNano + ",\n" +
|
||||
"structRefNano: " + structRefNano + ",\n" +
|
||||
"biomeNano: " + biomeNano + ",\n" +
|
||||
"noiseNano: " + noiseNano + ",\n" +
|
||||
"surfaceNano: " + surfaceNano + ",\n" +
|
||||
"carverNano: " + carverNano + ",\n" +
|
||||
"featureNano: " + featureNano + ",\n" +
|
||||
"lightNano: " + lightNano + ",\n" +
|
||||
"endNano: " + endNano + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
public static class PerfCalculator {
|
||||
public static final int SIZE = 10;
|
||||
private int dataCount = 0;
|
||||
|
||||
public static class PerfCalculator
|
||||
{
|
||||
public static final int SIZE = 50;
|
||||
Rolling totalTime = new Rolling(SIZE);
|
||||
Rolling emptyTime = new Rolling(SIZE);
|
||||
Rolling structStartTime = new Rolling(SIZE);
|
||||
@@ -127,56 +152,64 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
Rolling featureTime = new Rolling(SIZE);
|
||||
Rolling lightTime = new Rolling(SIZE);
|
||||
Rolling lodTime = new Rolling(SIZE);
|
||||
|
||||
public void recordEvent(PrefEvent e) {
|
||||
dataCount++;
|
||||
|
||||
public void recordEvent(PrefEvent e)
|
||||
{
|
||||
long preTime = e.beginNano;
|
||||
totalTime.add(e.endNano - preTime);
|
||||
if (e.emptyNano != 0) {
|
||||
if (e.emptyNano != 0)
|
||||
{
|
||||
emptyTime.add(e.emptyNano - preTime);
|
||||
preTime = e.emptyNano;
|
||||
}
|
||||
if (e.structStartNano != 0) {
|
||||
if (e.structStartNano != 0)
|
||||
{
|
||||
structStartTime.add(e.structStartNano - preTime);
|
||||
preTime = e.structStartNano;
|
||||
}
|
||||
if (e.structRefNano != 0) {
|
||||
if (e.structRefNano != 0)
|
||||
{
|
||||
structRefTime.add(e.structRefNano - preTime);
|
||||
preTime = e.structRefNano;
|
||||
}
|
||||
if (e.biomeNano != 0) {
|
||||
if (e.biomeNano != 0)
|
||||
{
|
||||
biomeTime.add(e.biomeNano - preTime);
|
||||
preTime = e.biomeNano;
|
||||
}
|
||||
if (e.noiseNano != 0) {
|
||||
if (e.noiseNano != 0)
|
||||
{
|
||||
noiseTime.add(e.noiseNano - preTime);
|
||||
preTime = e.noiseNano;
|
||||
}
|
||||
if (e.surfaceNano != 0) {
|
||||
if (e.surfaceNano != 0)
|
||||
{
|
||||
surfaceTime.add(e.surfaceNano - preTime);
|
||||
preTime = e.surfaceNano;
|
||||
}
|
||||
if (e.carverNano != 0) {
|
||||
if (e.carverNano != 0)
|
||||
{
|
||||
carverTime.add(e.carverNano - preTime);
|
||||
preTime = e.carverNano;
|
||||
}
|
||||
if (e.featureNano != 0) {
|
||||
if (e.featureNano != 0)
|
||||
{
|
||||
featureTime.add(e.featureNano - preTime);
|
||||
preTime = e.featureNano;
|
||||
}
|
||||
if (e.lightNano != 0) {
|
||||
if (e.lightNano != 0)
|
||||
{
|
||||
lightTime.add(e.lightNano - preTime);
|
||||
preTime = e.lightNano;
|
||||
}
|
||||
if (e.endNano != 0) {
|
||||
if (e.endNano != 0)
|
||||
{
|
||||
lodTime.add(e.endNano - preTime);
|
||||
preTime = e.endNano;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (dataCount < SIZE)
|
||||
return "Pref Calculator collecting samples...";
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Total: " + Duration.ofNanos((long) totalTime.getAverage()) + ", Empty/LoadChunk: "
|
||||
+ Duration.ofNanos((long) emptyTime.getAverage()) + ", StructStart: "
|
||||
+ Duration.ofNanos((long) structStartTime.getAverage()) + ", StructRef: "
|
||||
@@ -190,199 +223,257 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
+ Duration.ofNanos((long) lodTime.getAverage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final int TIMEOUT_SECONDS = 60;
|
||||
|
||||
// =================Generation Step===================
|
||||
|
||||
public final LinkedList<GenerationEvent> events = new LinkedList<GenerationEvent>();
|
||||
|
||||
//=================Generation Step===================
|
||||
|
||||
public final LinkedList<GenerationEvent> events = new LinkedList<>();
|
||||
public final GlobalParameters params;
|
||||
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference();
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
||||
public final StepBiomes stepBiomes = new StepBiomes(this);
|
||||
public final StepNoise stepNoise = new StepNoise(this);
|
||||
public final StepSurface stepSurface = new StepSurface(this);
|
||||
public final StepFeatures stepFeatures = new StepFeatures(this);
|
||||
public final StepLight stepLight = new StepLight(this);
|
||||
public boolean unsafeThreadingRecorded = false;
|
||||
static private final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class);
|
||||
//public boolean safeMode = false;
|
||||
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
|
||||
public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
|
||||
public static final int EXCEPTION_COUNTER_TRIGGER = 20;
|
||||
public static final int RANGE_TO_RANGE_EMPTY_EXTENSION = 1;
|
||||
public int unknownExceptionCount = 0;
|
||||
public long lastExceptionTriggerTime = 0;
|
||||
|
||||
|
||||
public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
|
||||
|
||||
|
||||
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<>();
|
||||
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() {
|
||||
return (isDistantGeneratorThread.get() != null);
|
||||
}
|
||||
|
||||
static {
|
||||
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
}
|
||||
|
||||
public ExecutorService executors = Executors.newFixedThreadPool(
|
||||
CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads(), threadFactory);
|
||||
CONFIG.client().advanced().threading()._getWorldGenerationThreadPoolSize(), threadFactory);
|
||||
|
||||
public <T> T joinSync(CompletableFuture<T> f) {
|
||||
if (!unsafeThreadingRecorded && !f.isDone()) {
|
||||
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Unsafe Threading in Chunk Generator Detected!");
|
||||
MC.sendChatMessage("\u00A7eTo increase stability, it is recommended to set world generation threads count to 1.");
|
||||
ApiShared.LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
|
||||
EVENT_LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
|
||||
EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
|
||||
unsafeThreadingRecorded = true;
|
||||
}
|
||||
return f.join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resizeThreadPool(int newThreadCount) {
|
||||
|
||||
public void resizeThreadPool(int newThreadCount)
|
||||
{
|
||||
executors = Executors.newFixedThreadPool(newThreadCount,
|
||||
new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target, boolean genAllDetails) {
|
||||
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target, boolean genAllDetails, double runTimeRatio)
|
||||
{
|
||||
int boxSize = range * 2 + 1;
|
||||
int x = Math.floorDiv(px, boxSize) * boxSize + range;
|
||||
int z = Math.floorDiv(pz, boxSize) * boxSize + range;
|
||||
|
||||
for (GenerationEvent event : events) {
|
||||
|
||||
for (GenerationEvent event : events)
|
||||
{
|
||||
if (event.tooClose(x, z, range))
|
||||
return false;
|
||||
}
|
||||
// System.out.println(x + ", "+z);
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target, genAllDetails));
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target, genAllDetails, runTimeRatio));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllFutures() {
|
||||
|
||||
public void updateAllFutures()
|
||||
{
|
||||
if (unknownExceptionCount > 0) {
|
||||
if (System.nanoTime() - lastExceptionTriggerTime >= EXCEPTION_TIMER_RESET_TIME) {
|
||||
unknownExceptionCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Update all current out standing jobs
|
||||
Iterator<GenerationEvent> iter = events.iterator();
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext())
|
||||
{
|
||||
GenerationEvent event = iter.next();
|
||||
if (event.isCompleted()) {
|
||||
try {
|
||||
if (event.isCompleted())
|
||||
{
|
||||
try
|
||||
{
|
||||
event.join();
|
||||
} catch (Throwable e) {
|
||||
ApiShared.LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
|
||||
ApiShared.LOGGER.error("Exception: ", e);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
EVENT_LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
|
||||
EVENT_LOGGER.error("Exception: ", e);
|
||||
unknownExceptionCount++;
|
||||
lastExceptionTriggerTime = System.nanoTime();
|
||||
} finally {
|
||||
}
|
||||
finally
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
} else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
||||
ApiShared.LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
|
||||
ApiShared.LOGGER.info("Dump PrefEvent: " + event.pEvent);
|
||||
try {
|
||||
}
|
||||
else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS))
|
||||
{
|
||||
EVENT_LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
|
||||
EVENT_LOGGER.info("Dump PrefEvent: " + event.pEvent);
|
||||
try
|
||||
{
|
||||
if (!event.terminate())
|
||||
ApiShared.LOGGER.error("Failed to terminate the stuck generation event!");
|
||||
} finally {
|
||||
EVENT_LOGGER.error("Failed to terminate the stuck generation event!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unknownExceptionCount > EXCEPTION_COUNTER_TRIGGER) {
|
||||
try {
|
||||
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Too many exceptions in Batching World Generator! Disabling the generator.");
|
||||
} catch (Exception e) {}
|
||||
ApiShared.LOGGER.error("Too many exceptions in Batching World Generator! Now disabling.");
|
||||
EVENT_LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
|
||||
unknownExceptionCount = 0;
|
||||
CONFIG.client().worldGenerator().setEnableDistantGeneration(false);
|
||||
}
|
||||
}
|
||||
|
||||
public BatchGenerationEnvironment(IWorldWrapper serverlevel, LodBuilder lodBuilder, LodDimension lodDim) {
|
||||
|
||||
public BatchGenerationEnvironment(IWorldWrapper serverlevel, LodBuilder lodBuilder, LodDimension lodDim)
|
||||
{
|
||||
super(serverlevel, lodBuilder, lodDim);
|
||||
ApiShared.LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
EVENT_LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
ChunkGenerator generator = ((WorldWrapper) serverlevel).getServerWorld().getChunkSource().getGenerator();
|
||||
if (!(generator instanceof NoiseBasedChunkGenerator ||
|
||||
generator instanceof DebugLevelSource ||
|
||||
generator instanceof FlatLevelSource)) {
|
||||
MC.sendChatMessage("\u00A74\u00A7l\u00A7uWARNING: Distant Horizons: Unknown Chunk Generator Detected! Distant Generation May Fail!");
|
||||
MC.sendChatMessage("\u00A7eIf it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
ApiShared.LOGGER.warn("Unknown Chunk Generator detected: {}", generator.getClass());
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator")) {
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: [{}], Distant Generation will try its best to support it.", generator.getClass());
|
||||
EVENT_LOGGER.info("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
} else {
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: [{}], Distant Generation May Fail!", generator.getClass());
|
||||
EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
|
||||
}
|
||||
}
|
||||
params = new GlobalParameters((ServerLevel) ((WorldWrapper) serverlevel).getWorld(), lodBuilder, lodDim);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private static ChunkAccess loadOrMakeChunk(ChunkPos chunkPos, ServerLevel level, LevelLightEngine lightEngine) {
|
||||
if (DISABLE_LOADING_SAVES) {
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY);
|
||||
}
|
||||
public static ChunkAccess loadOrMakeChunk(ChunkPos chunkPos, ServerLevel level, LevelLightEngine lightEngine)
|
||||
{
|
||||
CompoundTag chunkData = null;
|
||||
try {
|
||||
try
|
||||
{
|
||||
#if POST_MC_1_19
|
||||
chunkData = level.getChunkSource().chunkMap.readChunk(chunkPos).get().orElse(null);
|
||||
#else
|
||||
chunkData = level.getChunkSource().chunkMap.readChunk(chunkPos);
|
||||
} catch (Exception e) {
|
||||
ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
#endif
|
||||
}
|
||||
if (chunkData == null) {
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY);
|
||||
} else {
|
||||
catch (Exception e)
|
||||
{
|
||||
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
}
|
||||
if (chunkData == null)
|
||||
{
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, level #endif
|
||||
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(
|
||||
#if PRE_MC_1_19_3
|
||||
Registry.BIOME_REGISTRY
|
||||
#else
|
||||
Registries.BIOME
|
||||
#endif
|
||||
), null #endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
|
||||
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
|
||||
} catch (Exception e) {
|
||||
ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY);
|
||||
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
|
||||
return new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, level #endif
|
||||
#if POST_MC_1_18_1, level.registryAccess().registryOrThrow(
|
||||
#if PRE_MC_1_19_3
|
||||
Registry.BIOME_REGISTRY
|
||||
#else
|
||||
Registries.BIOME
|
||||
#endif
|
||||
), null #endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void generateLodFromList(GenerationEvent e) {
|
||||
if (ENABLE_EVENT_LOGGING)
|
||||
ApiShared.LOGGER.info("Lod Generate Event: " + e.pos);
|
||||
|
||||
public void generateLodFromList(GenerationEvent e)
|
||||
{
|
||||
EVENT_LOGGER.debug("Lod Generate Event: " + e.pos);
|
||||
e.pEvent.beginNano = System.nanoTime();
|
||||
GridList<ChunkAccess> referencedChunks;
|
||||
ArrayGridList<ChunkAccess> referencedChunks;
|
||||
ArrayGridList<ChunkAccess> genChunks;
|
||||
DistanceGenerationMode generationMode;
|
||||
LightedWorldGenRegion region;
|
||||
WorldGenLevelLightEngine lightEngine;
|
||||
LightGetterAdaptor adaptor;
|
||||
|
||||
try {
|
||||
int refRange = e.range + RANGE_TO_RANGE_EMPTY_EXTENSION;
|
||||
int refOffsetX = e.pos.x - refRange;
|
||||
int refOffsetZ = e.pos.z - refRange;
|
||||
try
|
||||
{
|
||||
adaptor = new LightGetterAdaptor(params.level);
|
||||
lightEngine = new WorldGenLevelLightEngine(adaptor);
|
||||
|
||||
int cx = e.pos.x;
|
||||
int cy = e.pos.z;
|
||||
int rangeEmpty = e.range + 1;
|
||||
GridList<ChunkAccess> chunks = new GridList<ChunkAccess>(rangeEmpty);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
EmptyChunkGenerator generator = (int x, int z) -> {
|
||||
EmptyChunkGenerator generator = (int x, int z) ->
|
||||
{
|
||||
ChunkPos chunkPos = new ChunkPos(x, z);
|
||||
ChunkAccess target = null;
|
||||
try {
|
||||
try
|
||||
{
|
||||
target = loadOrMakeChunk(chunkPos, params.level, lightEngine);
|
||||
} catch (RuntimeException e2) {
|
||||
}
|
||||
catch (RuntimeException e2)
|
||||
{
|
||||
// Continue...
|
||||
}
|
||||
if (target == null)
|
||||
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY);
|
||||
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY
|
||||
#if POST_MC_1_17_1, params.level #endif
|
||||
#if POST_MC_1_18_1, params.biomes, null #endif
|
||||
);
|
||||
return target;
|
||||
};
|
||||
|
||||
for (int oy = -rangeEmpty; oy <= rangeEmpty; oy++) {
|
||||
for (int ox = -rangeEmpty; ox <= rangeEmpty; ox++) {
|
||||
ChunkAccess target = generator.generate(cx + ox, cy + oy);
|
||||
chunks.add(target);
|
||||
}
|
||||
}
|
||||
referencedChunks = new ArrayGridList<>(refRange*2+1,
|
||||
(x,z) -> generator.generate(x + refOffsetX,z + refOffsetZ)
|
||||
);
|
||||
e.pEvent.emptyNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
region = new LightedWorldGenRegion(params.level, lightEngine, e.tParam.structFeat, chunks,
|
||||
ChunkStatus.STRUCTURE_STARTS, rangeEmpty, e.lightMode, generator);
|
||||
region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks,
|
||||
ChunkStatus.STRUCTURE_STARTS, refRange, e.lightMode, generator);
|
||||
adaptor.setRegion(region);
|
||||
e.tParam.makeStructFeat(region);
|
||||
referencedChunks = chunks.subGrid(e.range);
|
||||
referencedChunks = generateDirect(e, referencedChunks, e.target, region);
|
||||
|
||||
} catch (StructStartCorruptedException f) {
|
||||
e.tParam.makeStructFeat(region, params);
|
||||
genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION,
|
||||
referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION);
|
||||
generateDirect(e, genChunks, e.target, region);
|
||||
}
|
||||
catch (StepStructureStart.StructStartCorruptedException f)
|
||||
{
|
||||
e.tParam.markAsInvalid();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.target) {
|
||||
|
||||
switch (e.target)
|
||||
{
|
||||
case Empty:
|
||||
case StructureStart:
|
||||
case StructureReference:
|
||||
@@ -390,7 +481,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
break;
|
||||
case Biomes:
|
||||
generationMode = DistanceGenerationMode.BIOME_ONLY;
|
||||
break;
|
||||
case Noise:
|
||||
generationMode = DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT;
|
||||
break;
|
||||
@@ -406,88 +496,125 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
default:
|
||||
return;
|
||||
}
|
||||
int centreIndex = referencedChunks.size() / 2;
|
||||
|
||||
for (int oy = -e.range; oy <= e.range; oy++) {
|
||||
for (int ox = -e.range; ox <= e.range; ox++) {
|
||||
int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy);
|
||||
ChunkAccess target = referencedChunks.get(targetIndex);
|
||||
target.setLightCorrect(true);
|
||||
|
||||
for (int oy = 0; oy < genChunks.gridSize; oy++)
|
||||
{
|
||||
for (int ox = 0; ox < genChunks.gridSize; ox++)
|
||||
{
|
||||
ChunkAccess target = genChunks.get(ox, oy);
|
||||
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region);
|
||||
if (!wrappedChunk.isLightCorrect()) {
|
||||
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
|
||||
}
|
||||
|
||||
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
|
||||
if (isFull) {
|
||||
if (ENABLE_LOAD_EVENT_LOGGING)
|
||||
ApiShared.LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
#if POST_MC_1_18_1
|
||||
boolean isPartial = target.isOldNoiseGeneration();
|
||||
#endif
|
||||
if (isFull)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
|
||||
} else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE) {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
LodBuilderConfig.getFillVoidConfig(), true, e.genAllDetails);
|
||||
} else {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
else if (isPartial)
|
||||
{
|
||||
LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(generationMode), true, e.genAllDetails);
|
||||
}
|
||||
lightEngine.retainData(target.getPos(), false);
|
||||
#endif
|
||||
else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE)
|
||||
{
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk,
|
||||
LodBuilderConfig.getFillVoidConfig(), true, e.genAllDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(generationMode), true, e.genAllDetails);
|
||||
}
|
||||
if (e.lightMode == LightGenerationMode.FANCY || isFull)
|
||||
{
|
||||
lightEngine.retainData(target.getPos(), false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
e.pEvent.endNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (ENABLE_PERF_LOGGING) {
|
||||
if (PREF_LOGGER.canMaybeLog())
|
||||
{
|
||||
e.tParam.perf.recordEvent(e.pEvent);
|
||||
ApiShared.LOGGER.info(e.tParam.perf);
|
||||
PREF_LOGGER.infoInc("{}", e.tParam.perf);
|
||||
}
|
||||
}
|
||||
|
||||
GridList<ChunkAccess> generateDirect(GenerationEvent e, GridList<ChunkAccess> subRange, Steps step,
|
||||
LightedWorldGenRegion region) {
|
||||
try {
|
||||
subRange.forEach((chunk) -> {
|
||||
if (chunk instanceof ProtoChunk) {
|
||||
|
||||
public void generateDirect(GenerationEvent e, ArrayGridList<ChunkAccess> subRange, Steps step,
|
||||
LightedWorldGenRegion region)
|
||||
{
|
||||
try
|
||||
{
|
||||
subRange.forEach((chunk) ->
|
||||
{
|
||||
if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
((ProtoChunk) chunk).setLightEngine(region.getLightEngine());
|
||||
//region.getLightEngine().retainData(chunk.getPos(), true);
|
||||
region.getLightEngine().retainData(chunk.getPos(), true);
|
||||
}
|
||||
});
|
||||
if (step == Steps.Empty)
|
||||
return subRange;
|
||||
return;
|
||||
stepStructureStart.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.structStartNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.StructureStart)
|
||||
return subRange;
|
||||
return;
|
||||
stepStructureReference.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.structRefNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.StructureReference)
|
||||
return subRange;
|
||||
return;
|
||||
stepBiomes.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.biomeNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Biomes)
|
||||
return subRange;
|
||||
return;
|
||||
stepNoise.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.noiseNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Noise)
|
||||
return subRange;
|
||||
return;
|
||||
stepSurface.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.surfaceNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
if (step == Steps.Surface)
|
||||
return subRange;
|
||||
return;
|
||||
if (step == Steps.Carvers)
|
||||
return subRange;
|
||||
return;
|
||||
stepFeatures.generateGroup(e.tParam, region, subRange);
|
||||
e.pEvent.featureNano = System.nanoTime();
|
||||
e.refreshTimeout();
|
||||
return subRange;
|
||||
} finally {
|
||||
switch (region.lightMode) {
|
||||
}
|
||||
finally
|
||||
{
|
||||
switch (region.lightMode)
|
||||
{
|
||||
case FANCY:
|
||||
stepLight.generateGroup(region.getLightEngine(), subRange);
|
||||
break;
|
||||
case FAST:
|
||||
subRange.forEach((p) -> {
|
||||
subRange.forEach((p) ->
|
||||
{
|
||||
if (p instanceof ProtoChunk)
|
||||
((ProtoChunk) p).setLightCorrect(true);
|
||||
#if POST_MC_1_18_1
|
||||
if (p instanceof LevelChunk) {
|
||||
((LevelChunk) p).setLightCorrect(true);
|
||||
((LevelChunk) p).setClientLightReady(true);
|
||||
}
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -495,8 +622,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
e.refreshTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
public interface EmptyChunkGenerator {
|
||||
|
||||
public interface EmptyChunkGenerator
|
||||
{
|
||||
ChunkAccess generate(int x, int z);
|
||||
}
|
||||
|
||||
@@ -507,16 +635,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
@Override
|
||||
public void stop(boolean blocking) {
|
||||
ApiShared.LOGGER.info("Batch Chunk Generator shutting down...");
|
||||
EVENT_LOGGER.info("Batch Chunk Generator shutting down...");
|
||||
executors.shutdownNow();
|
||||
if (blocking) {
|
||||
try {
|
||||
if (!executors.awaitTermination(10, TimeUnit.SECONDS)) {
|
||||
ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
|
||||
if (blocking) try {
|
||||
if (!executors.awaitTermination(10, TimeUnit.SECONDS)) {
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
-29
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -6,86 +25,118 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.PrefEvent;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.config.LightGenerationMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper.Steps;
|
||||
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
//======================= Main Event class======================
|
||||
public final class GenerationEvent {
|
||||
public final class GenerationEvent
|
||||
{
|
||||
static private final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
|
||||
private static int generationFutureDebugIDs = 0;
|
||||
final ThreadedParameters tParam;
|
||||
final ChunkPos pos;
|
||||
final int range;
|
||||
final Future<?> future;
|
||||
long nanotime;
|
||||
long creationNanotime;
|
||||
final int id;
|
||||
final Steps target;
|
||||
final LightGenerationMode lightMode;
|
||||
final PrefEvent pEvent = new PrefEvent();
|
||||
final boolean genAllDetails;
|
||||
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup, Steps target, boolean genAllDetails) {
|
||||
nanotime = System.nanoTime();
|
||||
final double runTimeRatio;
|
||||
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup,
|
||||
Steps target, boolean genAllDetails, double runTimeRatio)
|
||||
{
|
||||
creationNanotime = System.nanoTime();
|
||||
this.pos = pos;
|
||||
this.range = range;
|
||||
id = generationFutureDebugIDs++;
|
||||
this.target = target;
|
||||
this.tParam = ThreadedParameters.getOrMake(generationGroup.params);
|
||||
LightGenerationMode mode = CONFIG.client().worldGenerator().getLightGenerationMode();
|
||||
|
||||
|
||||
this.lightMode = mode;
|
||||
this.genAllDetails = genAllDetails;
|
||||
|
||||
future = generationGroup.executors.submit(() -> {
|
||||
generationGroup.generateLodFromList(this);
|
||||
this.runTimeRatio = runTimeRatio;
|
||||
|
||||
future = generationGroup.executors.submit(() ->
|
||||
{
|
||||
long startTime = System.nanoTime();
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
try {
|
||||
generationGroup.generateLodFromList(this);
|
||||
} finally {
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
if (!Thread.interrupted() && runTimeRatio < 1.0) {
|
||||
long endTime = System.nanoTime();
|
||||
try {
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - startTime);
|
||||
Thread.sleep((long) (deltaMs/runTimeRatio - deltaMs));
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
|
||||
public boolean isCompleted()
|
||||
{
|
||||
return future.isDone();
|
||||
}
|
||||
|
||||
public boolean hasTimeout(int duration, TimeUnit unit) {
|
||||
|
||||
public boolean hasTimeout(int duration, TimeUnit unit)
|
||||
{
|
||||
long currentTime = System.nanoTime();
|
||||
long delta = currentTime - nanotime;
|
||||
long delta = currentTime - creationNanotime;
|
||||
return (delta > TimeUnit.NANOSECONDS.convert(duration, unit));
|
||||
}
|
||||
|
||||
public boolean terminate() {
|
||||
future.cancel(true);
|
||||
|
||||
public boolean terminate()
|
||||
{
|
||||
ApiShared.LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN=======================");
|
||||
BatchGenerationEnvironment.threadFactory.dumpAllThreadStacks();
|
||||
future.cancel(true);
|
||||
return future.isCancelled();
|
||||
}
|
||||
|
||||
public void join() {
|
||||
try {
|
||||
|
||||
public void join()
|
||||
{
|
||||
try
|
||||
{
|
||||
future.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
}
|
||||
catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
throw new RuntimeException(e.getCause()==null? e : e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tooClose(int cx, int cz, int cr) {
|
||||
|
||||
public boolean tooClose(int cx, int cz, int cr)
|
||||
{
|
||||
int distX = Math.abs(cx - pos.x);
|
||||
int distZ = Math.abs(cz - pos.z);
|
||||
int minRange = cr + range + 1; // Need one to account for the center
|
||||
minRange += 1 + 1; // Account for required empty chunks
|
||||
return distX < minRange && distZ < minRange;
|
||||
}
|
||||
|
||||
public void refreshTimeout() {
|
||||
nanotime = System.nanoTime();
|
||||
|
||||
public void refreshTimeout()
|
||||
{
|
||||
creationNanotime = System.nanoTime();
|
||||
LodUtil.checkInterruptsUnchecked();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return id + ":" + range + "@" + pos + "(" + target + ")";
|
||||
}
|
||||
}
|
||||
+64
-6
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
@@ -10,15 +29,38 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ThreadedLevelLightEngine;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
#else
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
#if POST_MC_1_19_3
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#endif
|
||||
#endif
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
|
||||
public final class GlobalParameters {
|
||||
public final class GlobalParameters
|
||||
{
|
||||
public final ChunkGenerator generator;
|
||||
#if PRE_MC_1_19
|
||||
public final StructureManager structures;
|
||||
#else
|
||||
public final StructureTemplateManager structures;
|
||||
public final RandomState randomState;
|
||||
#endif
|
||||
#if PRE_MC_1_19_3
|
||||
public final WorldGenSettings worldGenSettings;
|
||||
#else
|
||||
public final WorldOptions worldOptions;
|
||||
#endif
|
||||
public final ThreadedLevelLightEngine lightEngine;
|
||||
public final LodBuilder lodBuilder;
|
||||
public final LodDimension lodDim;
|
||||
@@ -27,22 +69,38 @@ public final class GlobalParameters {
|
||||
public final long worldSeed;
|
||||
public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works?
|
||||
public final DataFixer fixerUpper;
|
||||
|
||||
public GlobalParameters(ServerLevel level, LodBuilder lodBuilder, LodDimension lodDim) {
|
||||
#if POST_MC_1_18_1
|
||||
public final BiomeManager biomeManager;
|
||||
public final ChunkScanAccess chunkScanner; // FIXME: Figure out if this is actually needed
|
||||
#endif
|
||||
|
||||
public GlobalParameters(ServerLevel level, LodBuilder lodBuilder, LodDimension lodDim)
|
||||
{
|
||||
this.lodBuilder = lodBuilder;
|
||||
this.lodDim = lodDim;
|
||||
this.level = level;
|
||||
lightEngine = (ThreadedLevelLightEngine) level.getLightEngine();
|
||||
MinecraftServer server = level.getServer();
|
||||
WorldData worldData = server.getWorldData();
|
||||
worldGenSettings = worldData.worldGenSettings();
|
||||
registry = server.registryAccess();
|
||||
#if PRE_MC_1_19_3
|
||||
worldGenSettings = worldData.worldGenSettings();
|
||||
biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
worldSeed = worldGenSettings.seed();
|
||||
// biomeManager = new BiomeManager(level,
|
||||
// BiomeManager.obfuscateSeed(worldSeed));
|
||||
#else
|
||||
worldOptions = worldData.worldGenOptions();
|
||||
biomes = registry.registryOrThrow(Registries.BIOME);
|
||||
worldSeed = worldOptions.seed();
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed));
|
||||
chunkScanner = level.getChunkSource().chunkScanner();
|
||||
#endif
|
||||
structures = server.getStructureManager();
|
||||
generator = level.getChunkSource().getGenerator();
|
||||
fixerUpper = server.getFixerUpper();
|
||||
#if POST_MC_1_19
|
||||
randomState = level.getChunkSource().randomState();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,53 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
//FIXME: Move this outside the WorldGenerationStep thingy
|
||||
public class Rolling {
|
||||
|
||||
public class Rolling
|
||||
{
|
||||
|
||||
private final int size;
|
||||
private double total = 0d;
|
||||
private int index = 0;
|
||||
private final double[] samples;
|
||||
|
||||
public Rolling(int size) {
|
||||
|
||||
public Rolling(int size)
|
||||
{
|
||||
this.size = size;
|
||||
samples = new double[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
samples[i] = 0d;
|
||||
}
|
||||
|
||||
public void add(double x) {
|
||||
|
||||
public void add(double x)
|
||||
{
|
||||
total -= samples[index];
|
||||
samples[index] = x;
|
||||
total += x;
|
||||
if (++index == size)
|
||||
index = 0; // cheaper than modulus
|
||||
}
|
||||
|
||||
public double getAverage() {
|
||||
|
||||
public double getAverage()
|
||||
{
|
||||
return total / size;
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
public class StructStartCorruptedException extends RuntimeException {
|
||||
private static final long serialVersionUID = -8987434342051563358L;
|
||||
|
||||
public StructStartCorruptedException(ArrayIndexOutOfBoundsException e) {
|
||||
super("StructStartCorruptedException");
|
||||
super.initCause(e);
|
||||
fillInStackTrace();
|
||||
}
|
||||
}
|
||||
+56
-13
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.PerfCalculator;
|
||||
@@ -5,16 +25,23 @@ import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenStruct
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
|
||||
public final class ThreadedParameters {
|
||||
public final class ThreadedParameters
|
||||
{
|
||||
private static final ThreadLocal<ThreadedParameters> localParam = new ThreadLocal<ThreadedParameters>();
|
||||
final ServerLevel level;
|
||||
public final WorldGenStructFeatManager structFeat;
|
||||
public WorldGenStructFeatManager structFeat = null;
|
||||
#if POST_MC_1_18_1
|
||||
public final StructureCheck structCheck;
|
||||
#endif
|
||||
boolean isValid = true;
|
||||
public final PerfCalculator perf = new PerfCalculator();
|
||||
|
||||
public static ThreadedParameters getOrMake(GlobalParameters param) {
|
||||
|
||||
public static ThreadedParameters getOrMake(GlobalParameters param)
|
||||
{
|
||||
ThreadedParameters tParam = localParam.get();
|
||||
if (tParam != null && tParam.isValid && tParam.level == param.level)
|
||||
return tParam;
|
||||
@@ -22,17 +49,33 @@ public final class ThreadedParameters {
|
||||
localParam.set(tParam);
|
||||
return tParam;
|
||||
}
|
||||
|
||||
public void markAsInvalid() {
|
||||
|
||||
public void markAsInvalid()
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
private ThreadedParameters(GlobalParameters param) {
|
||||
|
||||
private ThreadedParameters(GlobalParameters param)
|
||||
{
|
||||
level = param.level;
|
||||
structFeat = new WorldGenStructFeatManager(level, param.worldGenSettings, null);
|
||||
#if PRE_MC_1_18_1
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, level);
|
||||
#elif PRE_MC_1_19
|
||||
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
#else
|
||||
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, param.randomState, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void makeStructFeat(WorldGenLevel genLevel) {
|
||||
structFeat.setGenLevel(genLevel);
|
||||
|
||||
public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param) {
|
||||
#if PRE_MC_1_19_3
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel #if POST_MC_1_18_1, structCheck #endif);
|
||||
#else
|
||||
structFeat = new WorldGenStructFeatManager(param.worldOptions, genLevel #if POST_MC_1_18_1, structCheck #endif);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
-144
@@ -1,144 +0,0 @@
|
||||
package com.seibel.lod.common.wrappers.worldGeneration;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
//import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
//import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractWorldGeneratorWrapper;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 11-13-2021
|
||||
*/
|
||||
public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper {
|
||||
public final ServerLevel serverWorld;
|
||||
public final LodDimension lodDim;
|
||||
public final LodBuilder lodBuilder;
|
||||
|
||||
public WorldGeneratorWrapper(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) {
|
||||
super(newLodBuilder, newLodDimension, worldWrapper);
|
||||
|
||||
lodBuilder = newLodBuilder;
|
||||
lodDim = newLodDimension;
|
||||
serverWorld = ((WorldWrapper) worldWrapper).getServerWorld();
|
||||
}
|
||||
|
||||
/** takes about 2-5 ms */
|
||||
@Override
|
||||
public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode) {
|
||||
generate(pos.getX(), pos.getZ(), generationMode);
|
||||
}
|
||||
|
||||
/** takes about 10 - 20 ms */
|
||||
@Override
|
||||
public void generateSurface(AbstractChunkPosWrapper pos) {
|
||||
generate(pos.getX(), pos.getZ(), DistanceGenerationMode.SURFACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* takes about 15 - 20 ms
|
||||
* <p>
|
||||
*/
|
||||
@Override
|
||||
public void generateFeatures(AbstractChunkPosWrapper pos) {
|
||||
generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FEATURES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates using MC's ServerWorld.
|
||||
* <p>
|
||||
* on pre generated chunks 0 - 1 ms <br>
|
||||
* on un generated chunks 0 - 50 ms <br>
|
||||
* with the median seeming to hover around 15 - 30 ms <br>
|
||||
* and outliers in the 100 - 200 ms range <br>
|
||||
* <p>
|
||||
* Note this should not be multithreaded and does cause server/simulation lag
|
||||
* (Higher lag for generating than loading)
|
||||
*/
|
||||
@Override
|
||||
public void generateFull(AbstractChunkPosWrapper pos) {
|
||||
generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FULL);
|
||||
}
|
||||
|
||||
private void generate(int chunkX, int chunkZ, DistanceGenerationMode generationMode) {
|
||||
|
||||
// long t = System.nanoTime();
|
||||
|
||||
ChunkStatus targetStatus;
|
||||
switch (generationMode) {
|
||||
case NONE:
|
||||
return;
|
||||
case BIOME_ONLY:
|
||||
targetStatus = ChunkStatus.BIOMES;
|
||||
break;
|
||||
case BIOME_ONLY_SIMULATE_HEIGHT:
|
||||
targetStatus = ChunkStatus.NOISE;
|
||||
break;
|
||||
case SURFACE:
|
||||
targetStatus = ChunkStatus.SURFACE;
|
||||
break;
|
||||
case FEATURES:
|
||||
targetStatus = ChunkStatus.FEATURES;
|
||||
break;
|
||||
case FULL:
|
||||
targetStatus = ChunkStatus.FULL;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// The bool=true means that we wants to generate chunk, and that the returned
|
||||
// ChunkAccess must not be null
|
||||
|
||||
ChunkAccess ca = serverWorld.getChunkSource().getChunk(chunkX, chunkZ, targetStatus, true);
|
||||
if (ca == null)
|
||||
throw new RuntimeException("This should NEVER be null due to bool being true");
|
||||
lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(ca, serverWorld),
|
||||
new LodBuilderConfig(generationMode), false, true);
|
||||
|
||||
// long duration = System.nanoTime()-t;
|
||||
|
||||
// Debug print the duration
|
||||
// System.out.println("LodChunkGenFull["+chunkX+","+chunkZ+"]:
|
||||
// "+(double)(duration)/1000.);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Ask leetom to update chart performance/generation tests related to
|
||||
* serverWorld.getChunk(x, z, ChunkStatus. *** )
|
||||
*
|
||||
* true/false is whether they generated blocks or not the time is how long it
|
||||
* took to generate
|
||||
*
|
||||
* ChunkStatus.EMPTY 0 - 1 ms false (empty, what did you expect? :P)
|
||||
* ChunkStatus.STRUCTURE_REFERENCES 1 - 2 ms false (no height, only generates
|
||||
* some chunks) ChunkStatus.BIOMES 1 - 10 ms false (no height) ChunkStatus.NOISE
|
||||
* 4 - 15 ms true (all blocks are stone) ChunkStatus.LIQUID_CARVERS 6 - 12 ms
|
||||
* true (no snow/trees, just grass) ChunkStatus.SURFACE 5 - 15 ms true (no
|
||||
* snow/trees, just grass) ChunkStatus.CARVERS 5 - 30 ms true (no snow/trees,
|
||||
* just grass) ChunkStatus.FEATURES 7 - 25 ms true ChunkStatus.HEIGHTMAPS 20 -
|
||||
* 40 ms true ChunkStatus.LIGHT 20 - 40 ms true ChunkStatus.FULL 30 - 50 ms true
|
||||
* ChunkStatus.SPAWN 50 - 80 ms true
|
||||
*
|
||||
*
|
||||
* At this point I would suggest using FEATURES, as it generates snow and trees
|
||||
* (and any other object that are needed to make biomes distinct)
|
||||
*
|
||||
* Otherwise, if snow/trees aren't necessary SURFACE is the next fastest
|
||||
* (although not by much)
|
||||
*/
|
||||
}
|
||||
+256
-93
@@ -1,73 +1,196 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
|
||||
import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.SectionPos;
|
||||
#if POST_MC_1_19_3
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#endif
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.ChunkTickList;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.TickList;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.chunk.ChunkBiomeContainer;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.ProtoTickList;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.ticks.LevelChunkTicks;
|
||||
#endif
|
||||
#if POST_MC_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ChunkLoader {
|
||||
private static final Logger LOGGER = ApiShared.LOGGER;
|
||||
public class ChunkLoader
|
||||
{
|
||||
#if POST_MC_1_19
|
||||
private static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
#elif POST_MC_1_18_1
|
||||
private static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codec(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
#endif
|
||||
private static final String TAG_UPGRADE_DATA = "UpgradeData";
|
||||
private static final String BLOCK_TICKS_TAG_18 = "block_ticks";
|
||||
private static final String FLUID_TICKS_TAG_18 = "fluid_ticks";
|
||||
private static final String BLOCK_TICKS_TAG_PRE18 = "TileTicks";
|
||||
private static final String FLUID_TICKS_TAG_PRE18 = "LiquidTicks";
|
||||
private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER;
|
||||
|
||||
private static LevelChunkSection[] readSections(WorldGenLevel level, LevelLightEngine lightEngine,
|
||||
ChunkPos chunkPos, CompoundTag tagLevel) {
|
||||
boolean isLightOn = tagLevel.getBoolean("isLightOn");
|
||||
ListTag listTag = tagLevel.getList("Sections", 10);
|
||||
LevelChunkSection[] levelChunkSections = new LevelChunkSection[16];
|
||||
boolean bl2 = level.getLevel().dimensionType().hasSkyLight();
|
||||
if (isLightOn)
|
||||
lightEngine.retainData(chunkPos, true);
|
||||
for (int j = 0; j < listTag.size(); j++) {
|
||||
CompoundTag compoundTag3 = listTag.getCompound(j);
|
||||
int k = compoundTag3.getByte("Y");
|
||||
if (compoundTag3.contains("Palette", 9) && compoundTag3.contains("BlockStates", 12)) {
|
||||
LevelChunkSection levelChunkSection = new LevelChunkSection(k << 4);
|
||||
levelChunkSection.getStates().read(compoundTag3.getList("Palette", 10),
|
||||
compoundTag3.getLongArray("BlockStates"));
|
||||
#if POST_MC_1_18_1
|
||||
private static BlendingData readBlendingData(CompoundTag chunkData)
|
||||
{
|
||||
BlendingData blendingData = null;
|
||||
if (chunkData.contains("blending_data", 10))
|
||||
{
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
Dynamic<CompoundTag> blendingDataTag = new Dynamic(NbtOps.INSTANCE, chunkData.getCompound("blending_data"));
|
||||
blendingData = BlendingData.CODEC.parse(blendingDataTag).resultOrPartial(LOGGER::error).orElse(null);
|
||||
}
|
||||
return blendingData;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
|
||||
{
|
||||
#if POST_MC_1_18_1
|
||||
#if PRE_MC_1_19_3
|
||||
Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
#else
|
||||
Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registries.BIOME);
|
||||
#endif
|
||||
#if PRE_MC_1_18_2
|
||||
Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec(
|
||||
biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS));
|
||||
#elif PRE_MC_1_19
|
||||
Codec<PalettedContainer<Holder<Biome>>> biomeCodec = PalettedContainer.codec(
|
||||
biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
|
||||
#else
|
||||
Codec<PalettedContainer<Holder<Biome>>> biomeCodec = PalettedContainer.codecRW(
|
||||
biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
|
||||
#endif
|
||||
#endif
|
||||
int i = #if PRE_MC_1_17_1 16; #else level.getSectionsCount(); #endif
|
||||
LevelChunkSection[] chunkSections = new LevelChunkSection[i];
|
||||
|
||||
boolean isLightOn = chunkData.getBoolean("isLightOn");
|
||||
boolean hasSkyLight = level.dimensionType().hasSkyLight();
|
||||
ListTag tagSections = chunkData.getList("Sections", 10);
|
||||
if (tagSections.isEmpty()) tagSections = chunkData.getList("sections", 10);
|
||||
|
||||
for (int j = 0; j < tagSections.size(); ++j)
|
||||
{
|
||||
CompoundTag tagSection = tagSections.getCompound(j);
|
||||
int sectionYPos = tagSection.getByte("Y");
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
if (tagSection.contains("Palette", 9) && tagSection.contains("BlockStates", 12)) {
|
||||
LevelChunkSection levelChunkSection = new LevelChunkSection(sectionYPos << 4);
|
||||
levelChunkSection.getStates().read(tagSection.getList("Palette", 10),
|
||||
tagSection.getLongArray("BlockStates"));
|
||||
levelChunkSection.recalcBlockCounts();
|
||||
if (!levelChunkSection.isEmpty())
|
||||
levelChunkSections[k] = levelChunkSection;
|
||||
chunkSections[#if PRE_MC_1_17_1 sectionYPos #else level.getSectionIndexFromSectionY(sectionYPos) #endif]
|
||||
= levelChunkSection;
|
||||
}
|
||||
if (isLightOn) {
|
||||
if (compoundTag3.contains("BlockLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, k),
|
||||
new DataLayer(compoundTag3.getByteArray("BlockLight")), true);
|
||||
if (bl2 && compoundTag3.contains("SkyLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, k),
|
||||
new DataLayer(compoundTag3.getByteArray("SkyLight")), true);
|
||||
}
|
||||
}
|
||||
return levelChunkSections;
|
||||
}
|
||||
#else
|
||||
int sectionId = level.getSectionIndexFromSectionY(sectionYPos);
|
||||
if (sectionId >= 0 && sectionId < chunkSections.length)
|
||||
{
|
||||
PalettedContainer<BlockState> blockStateContainer;
|
||||
#if PRE_MC_1_18_2
|
||||
PalettedContainer<Biome> biomeContainer;
|
||||
#else
|
||||
PalettedContainer<Holder<Biome>> biomeContainer;
|
||||
#endif
|
||||
|
||||
private static void readHeightmaps(LevelChunk chunk, CompoundTag chunkData) {
|
||||
blockStateContainer = tagSection.contains("block_states", 10)
|
||||
? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<BlockState>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
|
||||
#if PRE_MC_1_18_2
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<Biome>(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#else
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error)
|
||||
: new PalettedContainer<Holder<Biome>>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#endif
|
||||
chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!isLightOn) continue;
|
||||
if (tagSection.contains("BlockLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos),
|
||||
new DataLayer(tagSection.getByteArray("BlockLight")), true);
|
||||
if (hasSkyLight && tagSection.contains("SkyLight", 7))
|
||||
lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos),
|
||||
new DataLayer(tagSection.getByteArray("SkyLight")), true);
|
||||
}
|
||||
return chunkSections;
|
||||
}
|
||||
|
||||
private static void readHeightmaps(LevelChunk chunk, CompoundTag chunkData)
|
||||
{
|
||||
CompoundTag tagHeightmaps = chunkData.getCompound("Heightmaps");
|
||||
for (Heightmap.Types type : ChunkStatus.FULL.heightmapsAfter()) {
|
||||
for (Heightmap.Types type : ChunkStatus.FULL.heightmapsAfter())
|
||||
{
|
||||
String heightmap = type.getSerializationKey();
|
||||
if (tagHeightmaps.contains(heightmap, 12))
|
||||
chunk.setHeightmap(type, tagHeightmaps.getLongArray(heightmap));
|
||||
@@ -75,76 +198,116 @@ public class ChunkLoader {
|
||||
Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter());
|
||||
}
|
||||
|
||||
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) {
|
||||
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData)
|
||||
{
|
||||
ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9);
|
||||
for (int n = 0; n < tagPostProcessings.size(); ++n) {
|
||||
for (int n = 0; n < tagPostProcessings.size(); ++n)
|
||||
{
|
||||
ListTag listTag3 = tagPostProcessings.getList(n);
|
||||
for (int o = 0; o < listTag3.size(); ++o) {
|
||||
for (int o = 0; o < listTag3.size(); ++o)
|
||||
{
|
||||
chunk.addPackedPostProcess(listTag3.getShort(o), n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ChunkStatus.ChunkType readChunkType(CompoundTag tagLevel) {
|
||||
|
||||
public static ChunkStatus.ChunkType readChunkType(CompoundTag tagLevel)
|
||||
{
|
||||
ChunkStatus chunkStatus = ChunkStatus.byName(tagLevel.getString("Status"));
|
||||
if (chunkStatus != null) {
|
||||
return chunkStatus.getChunkType();
|
||||
}
|
||||
return ChunkStatus.ChunkType.PROTOCHUNK;
|
||||
}
|
||||
|
||||
public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos,
|
||||
CompoundTag chunkData) {
|
||||
|
||||
public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
|
||||
{
|
||||
#if PRE_MC_1_18_1
|
||||
CompoundTag tagLevel = chunkData.getCompound("Level");
|
||||
|
||||
ChunkStatus.ChunkType chunkType = readChunkType(tagLevel);
|
||||
if (chunkType != ChunkStatus.ChunkType.LEVELCHUNK)
|
||||
return null;
|
||||
#else
|
||||
CompoundTag tagLevel = chunkData;
|
||||
#endif
|
||||
|
||||
ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos"));
|
||||
if (!Objects.equals(chunkPos, actualPos)) {
|
||||
LOGGER.error("Distant Horizons: Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})",
|
||||
(Object) chunkPos, (Object) chunkPos, (Object) actualPos);
|
||||
LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", chunkPos, chunkPos, actualPos);
|
||||
return null;
|
||||
}
|
||||
|
||||
// ====================== Read params for making the LevelChunk
|
||||
// ============================
|
||||
|
||||
ChunkBiomeContainer chunkBiomeContainer = new ChunkBiomeContainer(
|
||||
level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), chunkPos,
|
||||
level.getLevel().getChunkSource().getGenerator().getBiomeSource(),
|
||||
tagLevel.contains("Biomes", 11) ? tagLevel.getIntArray("Biomes") : null);
|
||||
|
||||
UpgradeData upgradeData = tagLevel.contains("UpgradeData", 10)
|
||||
? new UpgradeData(tagLevel.getCompound("UpgradeData"))
|
||||
: UpgradeData.EMPTY;
|
||||
|
||||
TickList<Block> blockTicks = tagLevel.contains("TileTicks", 9)
|
||||
? ChunkTickList.create(tagLevel.getList("TileTicks", 10), Registry.BLOCK::getKey, Registry.BLOCK::get)
|
||||
: new ProtoTickList<Block>(block -> (block == null || block.defaultBlockState().isAir()), chunkPos,
|
||||
tagLevel.getList("ToBeTicked", 9));
|
||||
|
||||
TickList<Fluid> liquidTicks = tagLevel.contains("LiquidTicks", 9)
|
||||
? ChunkTickList.create(tagLevel.getList("LiquidTicks", 10), Registry.FLUID::getKey, Registry.FLUID::get)
|
||||
: new ProtoTickList<Fluid>(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos,
|
||||
tagLevel.getList("LiquidsToBeTicked", 9));
|
||||
ChunkStatus.ChunkType chunkType = readChunkType(tagLevel);
|
||||
#if PRE_MC_1_18_1
|
||||
if (chunkType != ChunkStatus.ChunkType.LEVELCHUNK)
|
||||
return null;
|
||||
#else
|
||||
BlendingData blendingData = readBlendingData(tagLevel);
|
||||
#if PRE_MC_1_19
|
||||
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
|
||||
return null;
|
||||
#else
|
||||
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || level.getChunk(chunkPos.getMiddleBlockX(),chunkPos.getMiddleBlockZ()).isOldNoiseGeneration()))
|
||||
return null;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
long inhabitedTime = tagLevel.getLong("InhabitedTime");
|
||||
|
||||
//================== Read params for making the LevelChunk ==================
|
||||
UpgradeData upgradeData = tagLevel.contains(TAG_UPGRADE_DATA, 10)
|
||||
? new UpgradeData(tagLevel.getCompound(TAG_UPGRADE_DATA)#if POST_MC_1_17_1, level #endif)
|
||||
: UpgradeData.EMPTY;
|
||||
|
||||
boolean isLightOn = tagLevel.getBoolean("isLightOn");
|
||||
if (isLightOn) lightEngine.retainData(chunkPos, true);
|
||||
#if PRE_MC_1_18_1
|
||||
ChunkBiomeContainer chunkBiomeContainer = new ChunkBiomeContainer(
|
||||
level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)#if POST_MC_1_17_1, level #endif,
|
||||
chunkPos, level.getLevel().getChunkSource().getGenerator().getBiomeSource(),
|
||||
tagLevel.contains("Biomes", 11) ? tagLevel.getIntArray("Biomes") : null);
|
||||
|
||||
TickList<Block> blockTicks = tagLevel.contains(BLOCK_TICKS_TAG_PRE18, 9)
|
||||
? ChunkTickList.create(tagLevel.getList(BLOCK_TICKS_TAG_PRE18, 10), Registry.BLOCK::getKey, Registry.BLOCK::get)
|
||||
: new ProtoTickList<Block>(block -> (block == null || block.defaultBlockState().isAir()), chunkPos,
|
||||
tagLevel.getList("ToBeTicked", 9)#if POST_MC_1_17_1, level #endif);
|
||||
|
||||
TickList<Fluid> fluidTicks = tagLevel.contains(FLUID_TICKS_TAG_PRE18, 9)
|
||||
? ChunkTickList.create(tagLevel.getList(FLUID_TICKS_TAG_PRE18, 10), Registry.FLUID::getKey, Registry.FLUID::get)
|
||||
: new ProtoTickList<Fluid>(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos,
|
||||
tagLevel.getList("LiquidsToBeTicked", 9)#if POST_MC_1_17_1, level #endif);
|
||||
#else
|
||||
#if PRE_MC_1_19_3
|
||||
LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10),
|
||||
string -> Registry.BLOCK.getOptional(ResourceLocation.tryParse(string)), chunkPos);
|
||||
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
|
||||
string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
|
||||
#else
|
||||
LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10),
|
||||
(string -> BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(string))), chunkPos);
|
||||
LevelChunkTicks<Fluid> fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10),
|
||||
string -> BuiltInRegistries.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LevelChunkSection[] levelChunkSections = readSections(level, lightEngine, chunkPos, tagLevel);
|
||||
|
||||
// ======================== Make the chunk
|
||||
// ===========================================
|
||||
LevelChunk chunk = new LevelChunk(level.getLevel(), chunkPos, chunkBiomeContainer, upgradeData, blockTicks,
|
||||
liquidTicks, inhabitedTime, levelChunkSections, null);
|
||||
|
||||
// ========================== Post setup some chunk data
|
||||
// ==============================
|
||||
chunk.setLightCorrect(tagLevel.getBoolean("isLightOn"));
|
||||
readHeightmaps(chunk, tagLevel);
|
||||
readPostPocessings(chunk, tagLevel);
|
||||
// ClientApi.LOGGER.info("Loaded chunk @ "+chunk.getPos());
|
||||
// ====================== Make the chunk =========================
|
||||
#if PRE_MC_1_18_1
|
||||
LevelChunk chunk = new LevelChunk((Level) level.getLevel(), chunkPos, chunkBiomeContainer, upgradeData, blockTicks,
|
||||
fluidTicks, inhabitedTime, levelChunkSections, null);
|
||||
#else
|
||||
|
||||
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks,
|
||||
fluidTicks, inhabitedTime, levelChunkSections, null, blendingData);
|
||||
#endif
|
||||
// Set some states after object creation
|
||||
chunk.setLightCorrect(isLightOn);
|
||||
readHeightmaps(chunk, chunkData);
|
||||
readPostPocessings(chunk, chunkData);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private static void logErrors(ChunkPos chunkPos, int i, String string)
|
||||
{
|
||||
LOGGER.error("Distant Horizons: Recoverable errors when loading section [" + chunkPos.x + ", " + i + ", " + chunkPos.z + "]: " + string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -1,9 +1,31 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LightChunkGetter;
|
||||
|
||||
@@ -33,4 +55,10 @@ public class LightGetterAdaptor implements LightChunkGetter {
|
||||
public BlockGetter getLevel() {
|
||||
return shouldReturnNull ? null : (genRegion != null ? genRegion : heightGetter);
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
public LevelHeightAccessor getLevelHeightAccessor() {
|
||||
return heightGetter;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+123
-22
@@ -1,25 +1,56 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.EmptyChunkGenerator;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.config.LightGenerationMode;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockTintCache;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Cursor3D;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
#endif
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -28,7 +59,6 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
|
||||
@@ -40,39 +70,71 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
public final int size;
|
||||
private final ChunkPos firstPos;
|
||||
private final List<ChunkAccess> cache;
|
||||
private final StructureFeatureManager structFeat;
|
||||
Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
|
||||
#if PRE_MC_1_18_1
|
||||
private ChunkPos overrideCenterPos = null;
|
||||
|
||||
public void setOverrideCenter(ChunkPos pos) {overrideCenterPos = pos;}
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return overrideCenterPos==null ? super.getCenterX() : overrideCenterPos.x;
|
||||
}
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return overrideCenterPos==null ? super.getCenterZ() : overrideCenterPos.z;
|
||||
}
|
||||
#if PRE_MC_1_17_1
|
||||
@Override
|
||||
public int getCenterX() {
|
||||
return overrideCenterPos==null ? super.getCenterX() : overrideCenterPos.x;
|
||||
}
|
||||
@Override
|
||||
public int getCenterZ() {
|
||||
return overrideCenterPos==null ? super.getCenterX() : overrideCenterPos.z;
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public ChunkPos getCenter() {
|
||||
return overrideCenterPos==null ? super.getCenter() : overrideCenterPos;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
|
||||
StructureFeatureManager structFeat, List<ChunkAccess> list, ChunkStatus chunkStatus, int i,
|
||||
List<ChunkAccess> list, ChunkStatus chunkStatus, int i,
|
||||
LightGenerationMode lightMode, EmptyChunkGenerator generator) {
|
||||
super(serverLevel, list);
|
||||
super(serverLevel, list #if POST_MC_1_17_1, chunkStatus, i #endif);
|
||||
this.lightMode = lightMode;
|
||||
this.firstPos = list.get(0).getPos();
|
||||
this.generator = generator;
|
||||
this.structFeat = structFeat;
|
||||
light = lightEngine;
|
||||
writeRadius = i;
|
||||
cache = list;
|
||||
size = Mth.floor(Math.sqrt(list.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
|
||||
StructureFeature<?> structureFeature) {
|
||||
return structFeat.startsForFeature(sectionPos, structureFeature);
|
||||
}
|
||||
#if POST_MC_1_17_1
|
||||
// Bypass BCLib mixin overrides.
|
||||
@Override
|
||||
public boolean ensureCanWrite(BlockPos blockPos) {
|
||||
int i = SectionPos.blockToSectionCoord(blockPos.getX());
|
||||
int j = SectionPos.blockToSectionCoord(blockPos.getZ());
|
||||
ChunkPos chunkPos = this.getCenter();
|
||||
ChunkAccess center = this.getChunk(chunkPos.x, chunkPos.z);
|
||||
int k = Math.abs(chunkPos.x - i);
|
||||
int l = Math.abs(chunkPos.z - j);
|
||||
if (k > this.writeRadius || l > this.writeRadius) {
|
||||
return false;
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
if (center.isUpgrading()) {
|
||||
LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration();
|
||||
if (blockPos.getY() < levelHeightAccessor.getMinBuildHeight() || blockPos.getY() >= levelHeightAccessor.getMaxBuildHeight()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO Check this
|
||||
// @Override
|
||||
// public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
|
||||
// StructureFeature<?> structureFeature) {
|
||||
// return structFeat.startsForFeature(sectionPos, structureFeature);
|
||||
// }
|
||||
|
||||
// Skip updating the related tile entities
|
||||
@Override
|
||||
@@ -150,7 +212,7 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus, boolean bl) {
|
||||
ChunkAccess chunk = getChunkAccess(i, j, chunkStatus, bl);
|
||||
if (chunk instanceof LevelChunk) {
|
||||
chunk = new ImposterProtoChunk((LevelChunk) chunk);
|
||||
chunk = new ImposterProtoChunk((LevelChunk) chunk #if POST_MC_1_18_1, true #endif);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
@@ -214,5 +276,44 @@ public class LightedWorldGenRegion extends WorldGenRegion {
|
||||
public boolean canSeeSky(BlockPos blockPos) {
|
||||
return (getBrightness(LightLayer.SKY, blockPos) >= getMaxLightLevel());
|
||||
}
|
||||
|
||||
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver)
|
||||
{
|
||||
return calculateBlockTint(blockPos, colorResolver);
|
||||
}
|
||||
|
||||
private Biome _getBiome(BlockPos pos) {
|
||||
#if POST_MC_1_18_2
|
||||
return getBiome(pos).value();
|
||||
#else
|
||||
return getBiome(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver)
|
||||
{
|
||||
#if PRE_MC_1_19
|
||||
int i = (Minecraft.getInstance()).options.biomeBlendRadius;
|
||||
#else
|
||||
int i = (Minecraft.getInstance()).options.biomeBlendRadius().get();
|
||||
#endif
|
||||
if (i == 0)
|
||||
return colorResolver.getColor((Biome) _getBiome(blockPos), blockPos.getX(), blockPos.getZ());
|
||||
int j = (i * 2 + 1) * (i * 2 + 1);
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
int m = 0;
|
||||
Cursor3D cursor3D = new Cursor3D(blockPos.getX() - i, blockPos.getY(), blockPos.getZ() - i, blockPos.getX() + i, blockPos.getY(), blockPos.getZ() + i);
|
||||
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
while (cursor3D.advance())
|
||||
{
|
||||
mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ());
|
||||
int n = colorResolver.getColor((Biome) _getBiome((BlockPos) mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
|
||||
k += (n & 0xFF0000) >> 16;
|
||||
l += (n & 0xFF00) >> 8;
|
||||
m += n & 0xFF;
|
||||
}
|
||||
return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF;
|
||||
}
|
||||
|
||||
}
|
||||
+189
-132
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -5,6 +24,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
@@ -16,149 +38,184 @@ import net.minecraft.world.level.lighting.SkyLightEngine;
|
||||
|
||||
public class WorldGenLevelLightEngine extends LevelLightEngine {
|
||||
public static final int MAX_SOURCE_LEVEL = 15;
|
||||
public static final int LIGHT_SECTION_PADDING = 1;
|
||||
@Nullable
|
||||
public final BlockLightEngine blockEngine;
|
||||
@Nullable
|
||||
public final SkyLightEngine skyEngine;
|
||||
public static final int LIGHT_SECTION_PADDING = 1;
|
||||
#if POST_MC_1_17_1
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
#endif
|
||||
@Nullable
|
||||
public final BlockLightEngine blockEngine;
|
||||
@Nullable
|
||||
public final SkyLightEngine skyEngine;
|
||||
|
||||
public WorldGenLevelLightEngine(LightGetterAdaptor genRegion) {
|
||||
super(genRegion, false, false);
|
||||
this.blockEngine = new BlockLightEngine(genRegion);
|
||||
this.skyEngine = new SkyLightEngine(genRegion);
|
||||
}
|
||||
public WorldGenLevelLightEngine(LightGetterAdaptor genRegion) {
|
||||
super(genRegion, false, false);
|
||||
#if POST_MC_1_17_1
|
||||
this.levelHeightAccessor = genRegion.getLevelHeightAccessor();
|
||||
#endif
|
||||
this.blockEngine = new BlockLightEngine(genRegion);
|
||||
this.skyEngine = new SkyLightEngine(genRegion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkBlock(BlockPos blockPos) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.checkBlock(blockPos);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.checkBlock(blockPos);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void checkBlock(BlockPos blockPos) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.checkBlock(blockPos);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.checkBlock(blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockEmissionIncrease(BlockPos blockPos, int i) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.onBlockEmissionIncrease(blockPos, i);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockEmissionIncrease(BlockPos blockPos, int i) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.onBlockEmissionIncrease(blockPos, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLightWork() {
|
||||
if (this.skyEngine != null && this.skyEngine.hasLightWork()) {
|
||||
return true;
|
||||
}
|
||||
return this.blockEngine != null && this.blockEngine.hasLightWork();
|
||||
}
|
||||
@Override
|
||||
public boolean hasLightWork() {
|
||||
if (this.skyEngine != null && this.skyEngine.hasLightWork()) {
|
||||
return true;
|
||||
}
|
||||
return this.blockEngine != null && this.blockEngine.hasLightWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int runUpdates(int i, boolean bl, boolean bl2) {
|
||||
if (this.blockEngine != null && this.skyEngine != null) {
|
||||
int j = i / 2;
|
||||
int k = this.blockEngine.runUpdates(j, bl, bl2);
|
||||
int l = i - j + k;
|
||||
int m = this.skyEngine.runUpdates(l, bl, bl2);
|
||||
if (k == 0 && m > 0) {
|
||||
return this.blockEngine.runUpdates(m, bl, bl2);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
if (this.blockEngine != null) {
|
||||
return this.blockEngine.runUpdates(i, bl, bl2);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
return this.skyEngine.runUpdates(i, bl, bl2);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@Override
|
||||
public int runUpdates(int i, boolean bl, boolean bl2) {
|
||||
if (this.blockEngine != null && this.skyEngine != null) {
|
||||
int j = i / 2;
|
||||
int k = this.blockEngine.runUpdates(j, bl, bl2);
|
||||
int l = i - j + k;
|
||||
int m = this.skyEngine.runUpdates(l, bl, bl2);
|
||||
if (k == 0 && m > 0) {
|
||||
return this.blockEngine.runUpdates(m, bl, bl2);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
if (this.blockEngine != null) {
|
||||
return this.blockEngine.runUpdates(i, bl, bl2);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
return this.skyEngine.runUpdates(i, bl, bl2);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSectionStatus(SectionPos sectionPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.updateSectionStatus(sectionPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.updateSectionStatus(sectionPos, bl);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateSectionStatus(SectionPos sectionPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.updateSectionStatus(sectionPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.updateSectionStatus(sectionPos, bl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableLightSources(ChunkPos chunkPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.enableLightSources(chunkPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.enableLightSources(chunkPos, bl);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void enableLightSources(ChunkPos chunkPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.enableLightSources(chunkPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.enableLightSources(chunkPos, bl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayerLightEventListener getLayerListener(LightLayer lightLayer) {
|
||||
if (lightLayer == LightLayer.BLOCK) {
|
||||
if (this.blockEngine == null) {
|
||||
return LayerLightEventListener.DummyLightLayerEventListener.INSTANCE;
|
||||
}
|
||||
return this.blockEngine;
|
||||
}
|
||||
if (this.skyEngine == null) {
|
||||
return LayerLightEventListener.DummyLightLayerEventListener.INSTANCE;
|
||||
}
|
||||
return this.skyEngine;
|
||||
}
|
||||
@Override
|
||||
public LayerLightEventListener getLayerListener(LightLayer lightLayer) {
|
||||
if (lightLayer == LightLayer.BLOCK) {
|
||||
if (this.blockEngine == null) {
|
||||
return LayerLightEventListener.DummyLightLayerEventListener.INSTANCE;
|
||||
}
|
||||
return this.blockEngine;
|
||||
}
|
||||
if (this.skyEngine == null) {
|
||||
return LayerLightEventListener.DummyLightLayerEventListener.INSTANCE;
|
||||
}
|
||||
return this.skyEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawBrightness(BlockPos blockPos, int i) {
|
||||
int j = this.skyEngine == null ? 0 : this.skyEngine.getLightValue(blockPos) - i;
|
||||
int k = this.blockEngine == null ? 0 : this.blockEngine.getLightValue(blockPos);
|
||||
return Math.max(k, j);
|
||||
}
|
||||
@Override
|
||||
public int getRawBrightness(BlockPos blockPos, int i) {
|
||||
int j = this.skyEngine == null ? 0 : this.skyEngine.getLightValue(blockPos) - i;
|
||||
int k = this.blockEngine == null ? 0 : this.blockEngine.getLightValue(blockPos);
|
||||
return Math.max(k, j);
|
||||
}
|
||||
|
||||
public void lightChunk(ChunkAccess chunkAccess, boolean needLightBlockUpdate) {
|
||||
ChunkPos chunkPos = chunkAccess.getPos();
|
||||
chunkAccess.setLightCorrect(false);
|
||||
public void lightChunk(ChunkAccess chunkAccess, boolean needLightBlockUpdate) {
|
||||
ChunkPos chunkPos = chunkAccess.getPos();
|
||||
chunkAccess.setLightCorrect(false);
|
||||
|
||||
LevelChunkSection[] levelChunkSections = chunkAccess.getSections();
|
||||
for (int i = 0; i <
|
||||
#if POST_MC_1_17_1
|
||||
chunkAccess.getSectionsCount()
|
||||
#else
|
||||
16
|
||||
#endif
|
||||
; ++i) {
|
||||
LevelChunkSection levelChunkSection = levelChunkSections[i];
|
||||
#if PRE_MC_1_17_1
|
||||
if (!LevelChunkSection.isEmpty(levelChunkSection)) {
|
||||
updateSectionStatus(SectionPos.of(chunkPos, i), false);
|
||||
}
|
||||
#elif PRE_MC_1_18_1
|
||||
if (!LevelChunkSection.isEmpty(levelChunkSection)) {
|
||||
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
|
||||
updateSectionStatus(SectionPos.of(chunkPos, j), false);
|
||||
}
|
||||
#else
|
||||
if (levelChunkSection.hasOnlyAir()) continue;
|
||||
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
|
||||
updateSectionStatus(SectionPos.of(chunkPos, j), false);
|
||||
#endif
|
||||
}
|
||||
enableLightSources(chunkPos, true);
|
||||
if (needLightBlockUpdate) {
|
||||
chunkAccess.getLights().forEach(blockPos ->
|
||||
onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos)));
|
||||
}
|
||||
|
||||
LevelChunkSection[] levelChunkSections = chunkAccess.getSections();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
LevelChunkSection levelChunkSection = levelChunkSections[i];
|
||||
if (!LevelChunkSection.isEmpty(levelChunkSection)) {
|
||||
updateSectionStatus(SectionPos.of(chunkPos, i), false);
|
||||
}
|
||||
}
|
||||
enableLightSources(chunkPos, true);
|
||||
if (needLightBlockUpdate) {
|
||||
chunkAccess.getLights()
|
||||
.forEach(blockPos -> onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos)));
|
||||
}
|
||||
chunkAccess.setLightCorrect(true);
|
||||
}
|
||||
|
||||
chunkAccess.setLightCorrect(true);
|
||||
}
|
||||
@Override
|
||||
public String getDebugData(LightLayer lightLayer, SectionPos sectionPos) {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
@Override
|
||||
public void queueSectionData(LightLayer lightLayer, SectionPos sectionPos, @Nullable DataLayer dataLayer, boolean bl) {
|
||||
if (lightLayer == LightLayer.BLOCK) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
|
||||
}
|
||||
} else if (this.skyEngine != null) {
|
||||
this.skyEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void retainData(ChunkPos chunkPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.retainData(chunkPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.retainData(chunkPos, bl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDebugData(LightLayer lightLayer, SectionPos sectionPos) {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queueSectionData(LightLayer lightLayer, SectionPos sectionPos, @Nullable DataLayer dataLayer,
|
||||
boolean bl) {
|
||||
if (lightLayer == LightLayer.BLOCK) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
|
||||
}
|
||||
} else if (this.skyEngine != null) {
|
||||
this.skyEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retainData(ChunkPos chunkPos, boolean bl) {
|
||||
if (this.blockEngine != null) {
|
||||
this.blockEngine.retainData(chunkPos, bl);
|
||||
}
|
||||
if (this.skyEngine != null) {
|
||||
this.skyEngine.retainData(chunkPos, bl);
|
||||
}
|
||||
}
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public int getLightSectionCount() {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
@Override
|
||||
public int getMinLightSection() {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
@Override
|
||||
public int getMaxLightSection() {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+214
-22
@@ -1,56 +1,248 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
#else
|
||||
#if POST_MC_1_19_3
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
#endif
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
|
||||
#if PRE_MC_1_19
|
||||
public class WorldGenStructFeatManager extends StructureFeatureManager {
|
||||
WorldGenLevel genLevel;
|
||||
#else
|
||||
public class WorldGenStructFeatManager extends StructureManager {
|
||||
#endif
|
||||
final WorldGenLevel genLevel;
|
||||
#if PRE_MC_1_19_3
|
||||
WorldGenSettings worldGenSettings;
|
||||
#else
|
||||
WorldOptions worldOptions;
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
StructureCheck structureCheck;
|
||||
#endif
|
||||
#if PRE_MC_1_19_3
|
||||
public WorldGenStructFeatManager(WorldGenSettings worldGenSettings,
|
||||
WorldGenLevel genLevel #if POST_MC_1_18_1, StructureCheck structureCheck #endif) {
|
||||
|
||||
public WorldGenStructFeatManager(LevelAccessor levelAccessor, WorldGenSettings worldGenSettings,
|
||||
WorldGenLevel genLevel) {
|
||||
super(levelAccessor, worldGenSettings);
|
||||
this.genLevel = genLevel;
|
||||
super(genLevel,
|
||||
worldGenSettings #if POST_MC_1_19_3 .options() #endif
|
||||
#if POST_MC_1_18_1, structureCheck #endif
|
||||
);
|
||||
this.worldGenSettings = worldGenSettings;
|
||||
}
|
||||
|
||||
public void setGenLevel(WorldGenLevel genLevel) {
|
||||
#else
|
||||
public WorldGenStructFeatManager(WorldOptions worldOptions,
|
||||
WorldGenLevel genLevel #if POST_MC_1_18_1, StructureCheck structureCheck #endif) {
|
||||
|
||||
super(genLevel, worldOptions, structureCheck);
|
||||
this.worldOptions = worldOptions;
|
||||
#endif
|
||||
this.genLevel = genLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) {
|
||||
if (worldGenRegion == genLevel)
|
||||
return this;
|
||||
return new WorldGenStructFeatManager(worldGenRegion, worldGenSettings, worldGenRegion);
|
||||
return new WorldGenStructFeatManager(
|
||||
#if PRE_MC_1_19_3 worldGenSettings #else worldOptions #endif
|
||||
, worldGenRegion #if POST_MC_1_18_1, structureCheck #endif);
|
||||
}
|
||||
|
||||
private ChunkAccess _getChunk(int x, int z, ChunkStatus status) {
|
||||
if (genLevel == null) return null;
|
||||
return genLevel.getChunk(x, z, status, false);
|
||||
}
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
@Override
|
||||
public Stream<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos2,
|
||||
StructureFeature<?> structureFeature) {
|
||||
if (genLevel == null)
|
||||
return Stream.empty();
|
||||
ChunkAccess chunk = genLevel.getChunk(sectionPos2.x(), sectionPos2.z(), ChunkStatus.STRUCTURE_REFERENCES,
|
||||
false);
|
||||
if (chunk == null)
|
||||
return Stream.empty();
|
||||
StructureFeature<?> structureFeature) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos2.x(), sectionPos2.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return Stream.empty();
|
||||
|
||||
return chunk.getReferencesForFeature(structureFeature).stream().map(pos -> {
|
||||
SectionPos sectPos = SectionPos.of(ChunkPos.getX(pos), 0, ChunkPos.getZ(pos));
|
||||
ChunkAccess startChunk = genLevel.getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS, false);
|
||||
if (startChunk == null)
|
||||
return null;
|
||||
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
|
||||
if (startChunk == null) return null;
|
||||
return this.getStartForFeature(sectPos, structureFeature, startChunk);
|
||||
}).filter(structureStart -> structureStart != null && structureStart.isValid());
|
||||
}
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public boolean hasAnyStructureAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return false;
|
||||
return chunk.hasAnyStructureReferences();
|
||||
}
|
||||
#if MC_1_18_1
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
|
||||
StructureFeature<?> structureFeature) {
|
||||
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...) with slight tweaks
|
||||
LongSet longSet = chunk.getReferencesForFeature(structureFeature);
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
LongIterator longIterator = longSet.iterator();
|
||||
while (longIterator.hasNext()) {
|
||||
long l = (Long)longIterator.next();
|
||||
SectionPos sectPos = SectionPos.of(new ChunkPos(l), genLevel.getMinSection());
|
||||
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
|
||||
if (startChunk == null) continue;
|
||||
StructureStart<?> structureStart = this.getStartForFeature(sectPos, structureFeature, startChunk);
|
||||
if (structureStart == null || !structureStart.isValid()) continue;
|
||||
builder.add(structureStart);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
#else
|
||||
#if PRE_MC_1_19
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, Predicate<ConfiguredStructureFeature<?, ?>> predicate) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map = chunk.getAllReferences();
|
||||
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Iterator<Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet>> var5 = map.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet> entry = var5.next();
|
||||
ConfiguredStructureFeature<?, ?> configuredStructureFeature = entry.getKey();
|
||||
if (predicate.test(configuredStructureFeature)) {
|
||||
LongSet var10002 = (LongSet)entry.getValue();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, var10002, builder::add);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureStart> startsForFeature(SectionPos sectionPos, ConfiguredStructureFeature<?, ?> configuredStructureFeature) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (List<StructureStart>) Stream.empty();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
LongSet longSet = chunk.getReferencesForFeature(configuredStructureFeature);
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForFeature(configuredStructureFeature, longSet, builder::add);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ConfiguredStructureFeature<?, ?>, LongSet> getAllStructuresAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (Map<ConfiguredStructureFeature<?, ?>, LongSet>) Stream.empty();
|
||||
return chunk.getAllReferences();
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public List<StructureStart> startsForStructure(ChunkPos sectionPos, Predicate<Structure> predicate) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x, sectionPos.z, ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return List.of();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
Map<Structure, LongSet> map = chunk.getAllReferences();
|
||||
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Iterator<Map.Entry<Structure, LongSet>> var5 = map.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<Structure, LongSet> entry = var5.next();
|
||||
Structure configuredStructureFeature = entry.getKey();
|
||||
if (predicate.test(configuredStructureFeature)) {
|
||||
LongSet var10002 = (LongSet)entry.getValue();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForStructure(configuredStructureFeature, var10002, builder::add);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureStart> startsForStructure(SectionPos sectionPos, Structure structure) {
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (List<StructureStart>) Stream.empty();
|
||||
|
||||
// Copied from StructureFeatureManager::startsForFeature(...)
|
||||
LongSet longSet = chunk.getReferencesForStructure(structure);
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Objects.requireNonNull(builder);
|
||||
this.fillStartsForStructure(structure, longSet, builder::add);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Structure, LongSet> getAllStructuresAt(BlockPos blockPos) {
|
||||
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
|
||||
if (chunk == null) return (Map<Structure, LongSet>) Stream.empty();
|
||||
return chunk.getAllReferences();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
+55
-12
@@ -1,45 +1,88 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
#endif
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepBiomes {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepBiomes(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepBiomes(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.BIOMES;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepBiomes: "+chunk.getPos());
|
||||
envionment.params.generator.createBiomes(envionment.params.biomes, chunk);
|
||||
#if PRE_MC_1_18_1
|
||||
environment.params.generator.createBiomes(environment.params.biomes, chunk);
|
||||
#elif PRE_MC_1_19
|
||||
chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#elif PRE_MC_1_19_3
|
||||
chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, environment.params.randomState, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#else
|
||||
chunk = environment.joinSync(environment.params.generator.createBiomes(Runnable::run, environment.params.randomState, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
-14
@@ -1,53 +1,83 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.util.GridList;
|
||||
import com.seibel.lod.core.util.gridList.ArrayGridList;
|
||||
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepFeatures {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepFeatures(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepFeatures(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.FEATURES;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion, GridList<ChunkAccess> chunks) {
|
||||
public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkAccess> chunks) {
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
try {
|
||||
#if PRE_MC_1_18_1
|
||||
worldGenRegion.setOverrideCenter(chunk.getPos());
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
envionment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
|
||||
#else
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion));
|
||||
#endif
|
||||
} catch (ReportedException e) {
|
||||
e.printStackTrace();
|
||||
// FIXME: Features concurrent modification issue. Something about cocobeans might just
|
||||
// error out. For now just retry.
|
||||
}
|
||||
}
|
||||
worldGenRegion.setOverrideCenter(null);
|
||||
}
|
||||
}
|
||||
+40
-15
@@ -1,8 +1,27 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenLevelLightEngine;
|
||||
import com.seibel.lod.core.util.GridList;
|
||||
import com.seibel.lod.core.util.gridList.ArrayGridList;
|
||||
|
||||
import net.minecraft.server.level.ThreadedLevelLightEngine;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -10,47 +29,53 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import net.minecraft.world.level.lighting.LightEventListener;
|
||||
|
||||
public final class StepLight {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepLight(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepLight(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.LIGHT;
|
||||
|
||||
public void generateGroup(LevelLightEngine lightEngine, GridList<ChunkAccess> chunks) {
|
||||
// ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
public void generateGroup(
|
||||
#if PRE_MC_1_17_1 LevelLightEngine lightEngine,
|
||||
#else LightEventListener lightEngine, #endif
|
||||
ArrayGridList<ChunkAccess> chunks) {
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
boolean hasCorrectBlockLight = (chunk instanceof LevelChunk && chunk.isLightCorrect());
|
||||
try {
|
||||
if (lightEngine == null) {
|
||||
// Do nothing
|
||||
} else if (lightEngine instanceof WorldGenLevelLightEngine) {
|
||||
((WorldGenLevelLightEngine) lightEngine).lightChunk(chunk, !hasCorrectBlockLight);
|
||||
((WorldGenLevelLightEngine)lightEngine).lightChunk(chunk, !hasCorrectBlockLight);
|
||||
} else if (lightEngine instanceof ThreadedLevelLightEngine) {
|
||||
((ThreadedLevelLightEngine) lightEngine).lightChunk(chunk, !hasCorrectBlockLight).join();
|
||||
} else {
|
||||
assert (false);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
#if POST_MC_1_18_1
|
||||
if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true);
|
||||
#endif
|
||||
chunk.setLightCorrect(true);
|
||||
}
|
||||
lightEngine.runUpdates(Integer.MAX_VALUE, true, true);
|
||||
|
||||
+62
-13
@@ -1,45 +1,94 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.util.Mth;
|
||||
#if POST_MC_1_17_1
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
#endif
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseSettings;
|
||||
#if POST_MC_1_18_1
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
#endif
|
||||
|
||||
public final class StepNoise {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepNoise(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepNoise(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.NOISE;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepNoise: "+chunk.getPos());
|
||||
envionment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk);
|
||||
#if PRE_MC_1_17_1
|
||||
environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk);
|
||||
#elif PRE_MC_1_18_1
|
||||
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#elif PRE_MC_1_19
|
||||
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#else
|
||||
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), environment.params.randomState,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
|
||||
#endif
|
||||
LodUtil.checkInterruptsUnchecked(); // Speed up termination responsiveness
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
-43
@@ -1,10 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -13,66 +32,44 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
#if PRE_MC_1_19
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
#endif
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
|
||||
public final class StepStructureReference {
|
||||
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
private void createReferences(WorldGenRegion worldGenLevel, StructureFeatureManager structureFeatureManager,
|
||||
ChunkAccess chunkAccess) {
|
||||
ChunkPos chunkPos = chunkAccess.getPos();
|
||||
int j = chunkPos.x;
|
||||
int k = chunkPos.z;
|
||||
int l = chunkPos.getMinBlockX();
|
||||
int m = chunkPos.getMinBlockZ();
|
||||
|
||||
SectionPos sectionPos = SectionPos.of(chunkAccess.getPos(), 0);
|
||||
|
||||
for (int n = j - 8; n <= j + 8; n++) {
|
||||
for (int o = k - 8; o <= k + 8; o++) {
|
||||
if (!worldGenLevel.hasChunk(n, o))
|
||||
continue;
|
||||
long p = ChunkPos.asLong(n, o);
|
||||
for (StructureStart<?> structureStart : worldGenLevel.getChunk(n, o).getAllStarts().values()) {
|
||||
try {
|
||||
if (structureStart.isValid()
|
||||
&& structureStart.getBoundingBox().intersects(l, m, l + 15, m + 15)) {
|
||||
structureFeatureManager.addReferenceForFeature(sectionPos, structureStart.getFeature(), p,
|
||||
chunkAccess);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(exception, "Generating structure reference");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Structure");
|
||||
crashReportCategory.setDetail("Id",
|
||||
() -> Registry.STRUCTURE_FEATURE.getKey(structureStart.getFeature()).toString());
|
||||
crashReportCategory.setDetail("Name", () -> structureStart.getFeature().getFeatureName());
|
||||
crashReportCategory.setDetail("Class",
|
||||
() -> structureStart.getFeature().getClass().getCanonicalName());
|
||||
throw new ReportedException(crashReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepStructureReference(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepStructureReference: "+chunk.getPos());
|
||||
createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
environment.params.generator.createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
-12
@@ -1,10 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -15,33 +34,69 @@ public final class StepStructureStart {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepStructureStart(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepStructureStart(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_STARTS;
|
||||
|
||||
public static class StructStartCorruptedException extends RuntimeException {
|
||||
private static final long serialVersionUID = -8987434342051563358L;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
public StructStartCorruptedException(ArrayIndexOutOfBoundsException e) {
|
||||
super("StructStartCorruptedException");
|
||||
super.initCause(e);
|
||||
fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
if (envionment.params.worldGenSettings.generateFeatures()) {
|
||||
#if PRE_MC_1_19
|
||||
if (environment.params.worldGenSettings.generateFeatures()) {
|
||||
#elif PRE_MC_1_19_3
|
||||
if (environment.params.worldGenSettings.generateStructures()) {
|
||||
#else
|
||||
if (environment.params.worldOptions.generateStructures()) {
|
||||
#endif
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepStructureStart: "+chunk.getPos());
|
||||
envionment.params.generator.createStructures(envionment.params.registry, tParams.structFeat, chunk,
|
||||
envionment.params.structures, envionment.params.worldSeed);
|
||||
#if PRE_MC_1_19
|
||||
environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures,
|
||||
environment.params.worldSeed);
|
||||
#elif PRE_MC_1_19_3
|
||||
environment.params.generator.createStructures(environment.params.registry, environment.params.randomState, tParams.structFeat, chunk, environment.params.structures,
|
||||
environment.params.worldSeed);
|
||||
#else
|
||||
environment.params.generator.createStructures(environment.params.registry,
|
||||
environment.params.level.getChunkSource().getGeneratorState(),
|
||||
tParams.structFeat, chunk, environment.params.structures);
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
try {
|
||||
tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts());
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// There's a rare issue with StructStart where it throws ArrayIndexOutOfBounds
|
||||
// This means the structFeat is corrupted (For some reason) and I need to reset it.
|
||||
// TODO: Figure out in the future why this happens even though I am using new structFeat
|
||||
throw new StepStructureStart.StructStartCorruptedException(e);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+37
-11
@@ -1,10 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -15,30 +34,37 @@ public final class StepSurface {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
private final BatchGenerationEnvironment environment;
|
||||
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
* @param batchGenerationEnvironment
|
||||
*/
|
||||
public StepSurface(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
public StepSurface(BatchGenerationEnvironment batchGenerationEnvironment)
|
||||
{
|
||||
environment = batchGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.SURFACE;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
|
||||
List<ChunkAccess> chunks) {
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunks) {
|
||||
if (chunk.getStatus().isOrAfter(STATUS))
|
||||
continue;
|
||||
if (chunk.getStatus().isOrAfter(STATUS)) continue;
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
chunksToDo.add(chunk);
|
||||
}
|
||||
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepSurface: "+chunk.getPos());
|
||||
envionment.params.generator.buildSurfaceAndBedrock(worldGenRegion, chunk);
|
||||
#if PRE_MC_1_18_1
|
||||
environment.params.generator.buildSurfaceAndBedrock(worldGenRegion, chunk);
|
||||
#elif PRE_MC_1_19
|
||||
environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
#else
|
||||
environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), environment.params.randomState, chunk);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-3
@@ -1,26 +1,36 @@
|
||||
accessWidener v1 named
|
||||
|
||||
# used when determining where to save files too
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertexCount I
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer id I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
# pre-render setup
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectList;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
#accessible field net/minecraft/world/entity/Entity blockPosition Lnet/minecraft/core/BlockPos;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
|
||||
#accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
accessible field net/minecraft/world/level/chunk/ChunkGenerator biomeSource Lnet/minecraft/world/level/biome/BiomeSource;
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
@@ -31,3 +41,5 @@ accessible field net/minecraft/client/renderer/block/model/BakedQuad sprite Lnet
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesX [I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesY [I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
@@ -0,0 +1,48 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# pre-render setup
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectArrayList;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
|
||||
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
|
||||
|
||||
|
||||
# grabbing textures
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture;
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
@@ -0,0 +1,50 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunkStorage Ljava/util/concurrent/atomic/AtomicReference;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
|
||||
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess;
|
||||
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
|
||||
|
||||
|
||||
# grabbing textures
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture;
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
|
||||
# hacky stuff
|
||||
accessible field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
mutable field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
@@ -0,0 +1,47 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunkStorage Ljava/util/concurrent/atomic/AtomicReference;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;
|
||||
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
|
||||
|
||||
# grabbing textures
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture;
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I
|
||||
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I
|
||||
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I
|
||||
extendable class com/mojang/math/Matrix4f
|
||||
|
||||
# hacky stuff
|
||||
accessible field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
mutable field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
@@ -0,0 +1,44 @@
|
||||
accessWidener v1 named
|
||||
|
||||
|
||||
# used when determining where to save files to
|
||||
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
|
||||
|
||||
# used when rendering
|
||||
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
|
||||
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
|
||||
|
||||
# used for grabbing vanilla rendered chunks
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer renderChunkStorage Ljava/util/concurrent/atomic/AtomicReference;
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
||||
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
|
||||
|
||||
# lighting
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
|
||||
|
||||
# world generation
|
||||
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
|
||||
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
|
||||
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
|
||||
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
|
||||
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Ljava/util/concurrent/CompletableFuture;
|
||||
|
||||
|
||||
# lod generation from save file
|
||||
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
|
||||
|
||||
|
||||
# grabbing textures
|
||||
accessible class net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture
|
||||
accessible method net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture getFrameX (I)I
|
||||
accessible method net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture getFrameY (I)I
|
||||
accessible field net/minecraft/client/renderer/texture/SpriteContents animatedTexture Lnet/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture;
|
||||
accessible field net/minecraft/client/renderer/texture/SpriteContents originalImage Lcom/mojang/blaze3d/platform/NativeImage;
|
||||
|
||||
# hacky stuff
|
||||
accessible field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
mutable field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
|
||||
+1
-1
Submodule core updated: 510058b7df...131ba164cf
+222
-19
@@ -1,28 +1,96 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
id "com.modrinth.minotaur" version "1.2.1"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
||||
}
|
||||
|
||||
// From parent
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version //FIXME: Redef
|
||||
group = rootProject.maven_group
|
||||
|
||||
version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm")
|
||||
|
||||
loom {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/lod.accesswidener"))
|
||||
silentMojangMappingsLicense()
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener"))
|
||||
}
|
||||
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowMe
|
||||
implementation.extendsFrom shadowMe
|
||||
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
|
||||
addModJar
|
||||
include.extendsFrom addModJar
|
||||
modImplementation.extendsFrom addModJar
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar.dependsOn(project(":core").remapJar)
|
||||
remapSourcesJar.dependsOn(project(":core").remapJar)
|
||||
|
||||
repositories {
|
||||
// Required for ModMenu
|
||||
maven { url "https://maven.terraformersmc.com/" }
|
||||
|
||||
mavenCentral()
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def addMod(path, enabled) {
|
||||
@@ -33,34 +101,94 @@ def addMod(path, enabled) {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
if (
|
||||
rootProject.minecraft_version != "1.19"
|
||||
&& rootProject.minecraft_version != "1.19.1"
|
||||
&& rootProject.minecraft_version != "1.19.2"
|
||||
&& rootProject.minecraft_version != "1.19.3"
|
||||
&& rootProject.minecraft_version != "1.19.4"
|
||||
) // We are not gonna use this build script anymore so dont bother fixing this
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
else
|
||||
parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19.x or higher doesnt have parchment mappings yet, we use 1.18.2 mapping
|
||||
// Note: parchment may have later mappings at the time you are reading this, but at the time this was written, it didnt
|
||||
// Check the main branch for the new build system, with the working mappings
|
||||
}
|
||||
|
||||
//Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader unless working with fabric
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
common(project(":core"))
|
||||
|
||||
// Fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
|
||||
// Fabric API
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version))
|
||||
|
||||
// Mod Menu
|
||||
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
|
||||
|
||||
// Starlight
|
||||
addMod("curse.maven:starlight-521783:${rootProject.starlight_version_fabric}", rootProject.enable_starlight)
|
||||
|
||||
// Phosphor
|
||||
addMod("curse.maven:phosphor-372124:${rootProject.phosphor_version_fabric}", rootProject.enable_phosphor)
|
||||
|
||||
// Sodium
|
||||
addMod("curse.maven:sodium-394468:${rootProject.sodium_version}", rootProject.enable_sodium)
|
||||
implementation "org.joml:joml:1.10.2"
|
||||
modImplementation(fabricApi.module("fabric-rendering-data-attachment-v1", rootProject.fabric_api_version))
|
||||
modImplementation(fabricApi.module("fabric-rendering-fluids-v1", rootProject.fabric_api_version))
|
||||
|
||||
// Lithium
|
||||
// Lithium
|
||||
addMod("maven.modrinth:lithium:${rootProject.lithium_version}", rootProject.enable_lithium)
|
||||
|
||||
// Iris
|
||||
addMod("maven.modrinth:iris:${rootProject.iris_version}", rootProject.enable_iris)
|
||||
|
||||
// BCLib
|
||||
addMod("com.github.paulevsGitch:BCLib:${rootProject.bclib_version}", rootProject.enable_bclib)
|
||||
|
||||
// Immersive Portals
|
||||
/*
|
||||
modImplementation("com.github.qouteall.ImmersivePortalsMod:build:${rootProject.immersive_portals_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
transitive(false)
|
||||
}
|
||||
modImplementation("com.github.qouteall.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
transitive(false)
|
||||
}
|
||||
modImplementation("com.github.qouteall.ImmersivePortalsMod:q_misc_util:${rootProject.immersive_portals_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
transitive(false)
|
||||
}
|
||||
*/
|
||||
|
||||
// Toml
|
||||
shadowMe("com.electronwill.night-config:toml:${rootProject.toml_version}") {}
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowMe(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
shadowMe files(project(":core").file("build/libs/DistantHorizons-${rootProject.mod_version}.jar"))
|
||||
|
||||
// Compression
|
||||
common 'org.tukaani:xz:1.9'
|
||||
@@ -69,10 +197,14 @@ dependencies {
|
||||
shadowMe 'org.apache.commons:commons-compress:1.21'
|
||||
}
|
||||
|
||||
// This method copies the access wideners from the common project to the fabric project. And it was generated by Github Copilot
|
||||
task deleteResources(type: Delete) {
|
||||
delete file("build/resources/main")
|
||||
}
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/lod.accesswidener")
|
||||
into file("src/generated/resources")
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file("build/resources/main"))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
@@ -80,26 +212,60 @@ task copyCoreResources(type: Copy) {
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
task deleteResources(type: Delete) {
|
||||
delete file("build/resources/main")
|
||||
}
|
||||
|
||||
task copyCommonResources(type: Copy) {
|
||||
from fileTree(project(":common").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
dependsOn(copyAccessWidener)
|
||||
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runClient {
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
dependsOn(copyAccessWidener)
|
||||
jvmArgs "-XX:-OmitStackTraceInFastThrow"
|
||||
finalizedBy(deleteResources)
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyAccessWidener)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowMe]
|
||||
relocate 'org.tukaani', 'shaded.tukaani'
|
||||
@@ -118,6 +284,11 @@ remapJar {
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
@@ -146,3 +317,35 @@ publishing {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
|
||||
task printConfigurations {
|
||||
doLast {task ->
|
||||
println "Project Name: $name configurations:"
|
||||
configurations.each {
|
||||
println " $it.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
// Add Manifold Preprocessor
|
||||
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
||||
//
|
||||
//options.compilerArgs += ['-deprecation']
|
||||
//options.compilerArgs += ['-verbose']
|
||||
//options.compilerArgs += ['-Xlint:unchecked']
|
||||
//options.compilerArgs += ['-Xdiags:verbose']
|
||||
//options.compilerArgs += ['-Xprint']
|
||||
//options.compilerArgs += ['-XprintProcessorInfo']
|
||||
//options.compilerArgs += ['-XprintRounds']
|
||||
|
||||
// println options.compilerArgs
|
||||
|
||||
// Set the java version
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
options.release = rootProject.java_version as Integer
|
||||
// TODO: make everything use java 8
|
||||
// options.release = 8 // Use Java 8 for everything so back porting is easier
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,29 +19,26 @@
|
||||
|
||||
package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.api.EventApi;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.fabric.mixins.events.MixinClientLevel;
|
||||
|
||||
import com.seibel.lod.fabric.mixins.MixinUtilBackgroudThread;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.fabricmc.fabric.mixin.event.lifecycle.client.ClientChunkManagerMixin;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -50,14 +47,15 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
* @author coolGi2007
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @version 11-23-2021
|
||||
*/
|
||||
@@ -66,13 +64,14 @@ public class ClientProxy
|
||||
private final EventApi eventApi = EventApi.INSTANCE;
|
||||
private final ClientApi clientApi = ClientApi.INSTANCE;
|
||||
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran
|
||||
*/
|
||||
public void registerEvents() {
|
||||
// TODO: Fix this if it's wrong
|
||||
/* Registor the mod accessor*/
|
||||
|
||||
/* World Events */
|
||||
//ServerTickEvents.START_SERVER_TICK.register(this::serverTickEvent);
|
||||
@@ -80,14 +79,14 @@ public class ClientProxy
|
||||
|
||||
/* World Events */
|
||||
//ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
|
||||
#if PRE_MC_1_18_1 // in 1.18+, we use mixin hook in setClientLightReady(true)
|
||||
ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* World Events */
|
||||
ServerWorldEvents.LOAD.register((server, level) -> this.worldLoadEvent(level));
|
||||
ServerWorldEvents.UNLOAD.register((server, level) -> this.worldUnloadEvent(level));
|
||||
|
||||
|
||||
/* The Client World Events are in the mixins
|
||||
Client world load event is in MixinClientLevel
|
||||
Client world unload event is in MixinMinecraft */
|
||||
@@ -97,6 +96,8 @@ public class ClientProxy
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (client.player != null) onKeyInput();
|
||||
});
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -115,10 +116,12 @@ public class ClientProxy
|
||||
{
|
||||
eventApi.worldSaveEvent();
|
||||
}
|
||||
|
||||
|
||||
/** This is also called when a new dimension loads */
|
||||
public void worldLoadEvent(Level level)
|
||||
{
|
||||
if (Minecraft.getInstance().screen instanceof TitleScreen) return;
|
||||
if (Minecraft.getInstance().getConnection() == null) return; // In 1.19.3, the multiplayer world load is called twice. The first time is before it actually connects to the multiplayer server (so stuff like ip and name arent sent out yet)
|
||||
if (level != null) {
|
||||
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(level));
|
||||
}
|
||||
|
||||
+17
-22
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,15 +23,16 @@ import com.seibel.lod.common.LodCommonMain;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DependencyHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.OptifineAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.StarlightAccessor;
|
||||
import com.seibel.lod.fabric.wrappers.FabricDependencySetup;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
@@ -40,12 +41,12 @@ import net.fabricmc.api.ClientModInitializer;
|
||||
* Initialize and setup the Mod. <br>
|
||||
* If you are looking for the real start of the mod
|
||||
* check out the ClientProxy.
|
||||
*
|
||||
* @author coolGi2007
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
public class FabricMain implements ClientModInitializer
|
||||
public class Main implements ClientModInitializer
|
||||
{
|
||||
// This is a client mod so it should implement ClientModInitializer and in fabric.mod.json it should have "environment": "client"
|
||||
// Once it works on servers change the implement to ModInitializer and in fabric.mod.json it should be "environment": "*"
|
||||
@@ -64,37 +65,31 @@ public class FabricMain implements ClientModInitializer
|
||||
public static void init() {
|
||||
LodCommonMain.initConfig();
|
||||
LodCommonMain.startup(null, false);
|
||||
|
||||
ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
|
||||
// make sure the dependencies are set up before the mod needs them
|
||||
FabricDependencySetup.createInitialBindings();
|
||||
FabricDependencySetup.finishBinding();
|
||||
|
||||
// mod dependencies
|
||||
ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
// Check if this works
|
||||
client_proxy = new ClientProxy();
|
||||
client_proxy.registerEvents();
|
||||
if (SingletonHandler.get(IModChecker.class).isModLoaded("sodium")) {
|
||||
ModAccessorHandler.bind(ISodiumAccessor.class, new SodiumAccessor());
|
||||
}
|
||||
if (SingletonHandler.get(IModChecker.class).isModLoaded("starlight")) {
|
||||
ModAccessorHandler.bind(IStarlightAccessor.class, new StarlightAccessor());
|
||||
}
|
||||
if (SingletonHandler.get(IModChecker.class).isModLoaded("optifine")) {
|
||||
ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
|
||||
}
|
||||
|
||||
|
||||
ModAccessorHandler.finishBinding();
|
||||
|
||||
|
||||
// Check if this works
|
||||
client_proxy = new ClientProxy();
|
||||
client_proxy.registerEvents();
|
||||
}
|
||||
|
||||
public static void initServer() {
|
||||
LodCommonMain.initConfig();
|
||||
LodCommonMain.startup(null, true);
|
||||
|
||||
ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
FabricDependencySetup.createInitialBindings();
|
||||
FabricDependencySetup.finishBinding();
|
||||
ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
||||
#if PRE_MC_1_18_1
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@@ -8,22 +30,26 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public class MixinChunkGenerator {
|
||||
@Redirect(method = "applyBiomeDecoration", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/biome/Biome;generate(Lnet/minecraft/world/level/StructureFeatureManager;"
|
||||
+ "Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/server/level/WorldGenRegion;J"
|
||||
+ "Lnet/minecraft/world/level/levelgen/WorldgenRandom;Lnet/minecraft/core/BlockPos;)V"
|
||||
|
||||
))
|
||||
private void wrapBiomeGenerateCall(Biome biome, StructureFeatureManager structFeatManager, ChunkGenerator generator,
|
||||
WorldGenRegion genRegion, long l, WorldgenRandom random, BlockPos pos) {
|
||||
synchronized((ChunkGenerator)(Object)this) {
|
||||
biome.generate(structFeatManager, (ChunkGenerator)(Object)this, genRegion, l, random, pos);
|
||||
}
|
||||
}
|
||||
@Redirect(method = "applyBiomeDecoration", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/biome/Biome;generate(Lnet/minecraft/world/level/StructureFeatureManager;"
|
||||
+ "Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/server/level/WorldGenRegion;J"
|
||||
+ "Lnet/minecraft/world/level/levelgen/WorldgenRandom;Lnet/minecraft/core/BlockPos;)V"
|
||||
|
||||
))
|
||||
private void wrapBiomeGenerateCall(Biome biome, StructureFeatureManager structFeatManager, ChunkGenerator generator,
|
||||
WorldGenRegion genRegion, long l, WorldgenRandom random, BlockPos pos) {
|
||||
synchronized(ChunkGenerator.class) {
|
||||
biome.generate(structFeatManager, (ChunkGenerator)(Object)this, genRegion, l, random, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public class MixinChunkGenerator {}
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.core.render.F3Screen;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugScreenOverlay.class)
|
||||
public class MixinDebugScreenOverlay {
|
||||
|
||||
@Inject(method = "getSystemInformation", at = @At("RETURN"))
|
||||
private void addCustomF3(CallbackInfoReturnable<List<String>> cir) {
|
||||
List<String> messages = cir.getReturnValue();
|
||||
|
||||
for (String i: F3Screen.f3List) {
|
||||
messages.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(DedicatedServer.class)
|
||||
public class MixinDedicatedServer {
|
||||
@Inject(method = "initServer", at = @At("TAIL"))
|
||||
public void initServer(CallbackInfoReturnable<Boolean> cir) {
|
||||
Main.initServer();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -6,42 +25,56 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
#else
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
#endif
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public class MixinFogRenderer {
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
// Using this instead of Float.MAX_VALUE because Sodium don't like it.
|
||||
private static final float A_REALLY_REALLY_BIG_VALUE = 4206942069.F;
|
||||
private static final float A_EVEN_LARGER_VALUE = 420694206942069.F;
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V")
|
||||
private static final void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) {
|
||||
FogType fogType = camera.getFluidInCamera();
|
||||
Entity entity = camera.getEntity();
|
||||
boolean enableFog = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
|
||||
enableFog |= fogType.equals(FogType.WATER);
|
||||
enableFog |= fogType.equals(FogType.LAVA);
|
||||
enableFog |= fogType.equals(FogType.POWDER_SNOW);
|
||||
|
||||
if (!enableFog) {
|
||||
if (fogMode == FogMode.FOG_TERRAIN && CONFIG.client().graphics().fogQuality().getDisableVanillaFog()) {
|
||||
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
||||
}
|
||||
}
|
||||
// Using this instead of Float.MAX_VALUE because Sodium don't like it.
|
||||
private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F;
|
||||
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupFog")
|
||||
#if PRE_MC_1_19_1
|
||||
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) {
|
||||
#else
|
||||
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float g, CallbackInfo callback) {
|
||||
#endif
|
||||
#if PRE_MC_1_17_1
|
||||
FluidState fluidState = camera.getFluidInCamera();
|
||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
||||
#else
|
||||
FogType fogTypes = camera.getFluidInCamera();
|
||||
boolean cameraNotInFluid = fogTypes == FogType.NONE;
|
||||
#endif
|
||||
|
||||
Entity entity = camera.getEntity();
|
||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
||||
if (!isSpecialFog && cameraNotInFluid && fogMode == FogMode.FOG_TERRAIN
|
||||
&& CONFIG.client().graphics().fogQuality().getDisableVanillaFog())
|
||||
{
|
||||
#if PRE_MC_1_17_1
|
||||
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.fogEnd(A_EVEN_LARGER_VALUE);
|
||||
#else
|
||||
RenderSystem.setShaderFogStart(A_REALLY_REALLY_BIG_VALUE);
|
||||
RenderSystem.setShaderFogEnd(A_EVEN_LARGER_VALUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.fabric.FabricMain;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -16,6 +35,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class MixinMinecraft {
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void startMod(GameConfig gameConfig, CallbackInfo ci) {
|
||||
FabricMain.init();
|
||||
Main.init();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
@@ -8,7 +27,9 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import net.minecraft.client.gui.screens.OptionsScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
#if PRE_MC_1_19_1
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
#endif
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -20,9 +41,9 @@ import java.util.Objects;
|
||||
/**
|
||||
* Adds a button to the menu to goto the config
|
||||
*
|
||||
* @author coolGi2007
|
||||
* @author coolGi
|
||||
* @version 12-02-2021
|
||||
*/
|
||||
*/
|
||||
@Mixin(OptionsScreen.class)
|
||||
public class MixinOptionsScreen extends Screen {
|
||||
// Get the texture for the button
|
||||
@@ -34,19 +55,24 @@ public class MixinOptionsScreen extends Screen {
|
||||
@Inject(at = @At("HEAD"),method = "init")
|
||||
private void lodconfig$init(CallbackInfo ci) {
|
||||
if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton())
|
||||
this.addButton(new TexturedButtonWidget(
|
||||
// Where the button is on the screen
|
||||
this.width / 2 - 180, this.height / 6 - 12,
|
||||
// Width and height of the button
|
||||
20, 20,
|
||||
// Offset
|
||||
0, 0,
|
||||
// Some textuary stuff
|
||||
20, ICON_TEXTURE, 20, 40,
|
||||
// Create the button and tell it where to go
|
||||
// For now it goes to the client option by default
|
||||
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, "client")),
|
||||
// Add a title to the screen
|
||||
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
|
||||
this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif
|
||||
(new TexturedButtonWidget(
|
||||
// Where the button is on the screen
|
||||
this.width / 2 - 180, this.height / 6 - 12,
|
||||
// Width and height of the button
|
||||
20, 20,
|
||||
// Offset
|
||||
0, 0,
|
||||
// Some textuary stuff
|
||||
20, ICON_TEXTURE, 20, 40,
|
||||
// Create the button and tell it where to go
|
||||
// For now it goes to the client option by default
|
||||
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, "client")),
|
||||
// Add a title to the screen
|
||||
#if PRE_MC_1_19_1
|
||||
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
|
||||
#else
|
||||
Component.translatable("text.autoconfig." + ModInfo.ID + ".title")));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.seibel.lod.fabric.ClientProxy;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.seibel.lod.core.util.DummyRunExecutorService;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
@Mixin(Util.class)
|
||||
public class MixinUtilBackgroudThread
|
||||
{
|
||||
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
|
||||
{
|
||||
if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
|
||||
ci.setReturnValue(new DummyRunExecutorService());
|
||||
}
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
|
||||
{
|
||||
if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if POST_MC_1_18_1
|
||||
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
|
||||
{
|
||||
if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
|
||||
ci.setReturnValue(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,19 +20,24 @@
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
#if PRE_MC_1_19_3
|
||||
import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
#endif
|
||||
import com.seibel.lod.common.Config;
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
/**
|
||||
* This class is used to mix in my rendering code
|
||||
* before Minecraft starts rendering blocks.
|
||||
@@ -42,17 +47,23 @@ import net.minecraft.client.renderer.RenderType;
|
||||
*
|
||||
* This is also the mixin for rendering the clouds
|
||||
*
|
||||
* @author coolGi2007
|
||||
* @author coolGi
|
||||
* @author James Seibel
|
||||
* @version 12-31-2021
|
||||
*/
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class MixinWorldRenderer
|
||||
{
|
||||
// TODO: Fix clouds
|
||||
private static float previousPartialTicks = 0;
|
||||
|
||||
public MixinWorldRenderer() {
|
||||
throw new NullPointerException("Null cannot be cast to non-null type.");
|
||||
}
|
||||
|
||||
|
||||
// Inject rendering at first call to renderChunkLayer
|
||||
// HEAD or RETURN
|
||||
#if PRE_MC_1_17_1
|
||||
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
|
||||
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
|
||||
{
|
||||
@@ -61,8 +72,9 @@ public class MixinWorldRenderer
|
||||
previousPartialTicks = partialTicks;
|
||||
}
|
||||
|
||||
// HEAD or RETURN
|
||||
@Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V")
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
|
||||
{
|
||||
// only render before solid blocks
|
||||
@@ -72,14 +84,64 @@ public class MixinWorldRenderer
|
||||
float[] mcProjMatrixRaw = new float[16];
|
||||
GL15.glGetFloatv(GL15.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
Mat4f mcProjectionMatrix = new Mat4f(mcProjMatrixRaw);
|
||||
// OpenGl outputs their matrices in col,row form instead of row,col
|
||||
// (or maybe vice versa I have no idea :P)
|
||||
mcProjectionMatrix.transpose();
|
||||
|
||||
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(matrixStackIn.last().pose());
|
||||
|
||||
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
}
|
||||
if (Config.Client.Advanced.lodOnlyMode) {
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
#elif PRE_MC_1_19_3
|
||||
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
|
||||
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
|
||||
// get the partial ticks since renderChunkLayer doesn't
|
||||
// have access to them
|
||||
previousPartialTicks = tickDelta;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
|
||||
{
|
||||
// only render before solid blocks
|
||||
if (renderType.equals(RenderType.solid()))
|
||||
{
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
|
||||
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
}
|
||||
if (Config.Client.Advanced.lodOnlyMode) {
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
#else
|
||||
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
|
||||
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
|
||||
// get the partial ticks since renderChunkLayer doesn't
|
||||
// have access to them
|
||||
previousPartialTicks = tickDelta;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
|
||||
{
|
||||
// only render before solid blocks
|
||||
if (renderType.equals(RenderType.solid()))
|
||||
{
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
|
||||
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
}
|
||||
if (Config.Client.Advanced.lodOnlyMode) {
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.FabricMain;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
@@ -18,11 +37,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
*/
|
||||
@Mixin(ClientboundBlockUpdatePacket.class)
|
||||
public abstract class MixinBlockUpdate {
|
||||
@Shadow
|
||||
public abstract BlockPos getPos();
|
||||
@Shadow public abstract BlockPos getPos();
|
||||
|
||||
@Inject(method = "handle(Lnet/minecraft/network/protocol/game/ClientGamePacketListener;)V", at = @At("TAIL"))
|
||||
private void onBlockUpdate(ClientGamePacketListener clientGamePacketListener, CallbackInfo ci) {
|
||||
FabricMain.client_proxy.blockChangeEvent(Minecraft.getInstance().player.clientLevel, this.getPos());
|
||||
Main.client_proxy.blockChangeEvent(Minecraft.getInstance().player.clientLevel, this.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.FabricMain;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
#if POST_MC_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
#endif
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -18,11 +41,26 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* This class is used for world loading events
|
||||
* @author Ran
|
||||
*
|
||||
* FIXME: Why does forge not have the 1.18+ onChunkLightReady mixin?
|
||||
*/
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public class MixinClientLevel {
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey<Level> resourceKey, DimensionType dimensionType, int i, Supplier<ProfilerFiller> supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
FabricMain.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
|
||||
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey,
|
||||
#if POST_MC_1_18_2 Holder holder, #else DimensionType dimensionType, #endif int i,
|
||||
#if POST_MC_1_18_1 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
|
||||
}
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
@Inject(method = "setLightReady", at = @At("HEAD"))
|
||||
private void onChunkLightReady(int x, int z, CallbackInfo ci) {
|
||||
ClientLevel l = (ClientLevel) (Object) this;
|
||||
LevelChunk chunk = l.getChunkSource().getChunk(x, z, false);
|
||||
if (chunk!=null&& !chunk.isClientLightReady())
|
||||
Main.client_proxy.chunkLoadEvent(l, chunk);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LightTexture.class)
|
||||
public class MixinLightmap {
|
||||
@Shadow
|
||||
@Final
|
||||
public NativeImage lightPixels;
|
||||
|
||||
@Inject(method="updateLightTexture", at=@At(
|
||||
value="INVOKE",
|
||||
target="Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
|
||||
public void updateLightTexture(float f, CallbackInfo ci) {
|
||||
//ApiShared.LOGGER.info("Lightmap update");
|
||||
MinecraftRenderWrapper.INSTANCE.updateLightmap(lightPixels);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.FabricMain;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -23,11 +41,11 @@ public class MixinMinecraft {
|
||||
|
||||
@Inject(method = "setLevel", at = @At("HEAD"))
|
||||
private void unloadWorldEvent_sL(ClientLevel clientLevel, CallbackInfo ci) {
|
||||
if (level != null) FabricMain.client_proxy.worldUnloadEvent(level);
|
||||
if (level != null) Main.client_proxy.worldUnloadEvent(level);
|
||||
}
|
||||
|
||||
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
|
||||
private void unloadWorldEvent_cL(Screen screen, CallbackInfo ci) {
|
||||
if (this.level != null) FabricMain.client_proxy.worldUnloadEvent(this.level);
|
||||
if (this.level != null) Main.client_proxy.worldUnloadEvent(this.level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.events;
|
||||
|
||||
import com.seibel.lod.fabric.FabricMain;
|
||||
import com.seibel.lod.fabric.Main;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.ProgressListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -14,8 +33,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
*/
|
||||
@Mixin(ServerLevel.class)
|
||||
public class MixinServerLevel {
|
||||
#if PRE_MC_1_17_1
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;save(Z)V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
FabricMain.client_proxy.worldSaveEvent();
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
#else
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;saveAll()V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent_sA(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
@Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;autoSave()V", shift = At.Shift.AFTER))
|
||||
private void saveWorldEvent_aS(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
|
||||
Main.client_proxy.worldSaveEvent();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.seibel.lod.fabric.mixins.unsafe;
|
||||
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
* NOTE: THIS IS NOT A FIX TO THE PROBLEM.
|
||||
* TODO: Do/Find an actual fix to this
|
||||
*
|
||||
* @author Ran
|
||||
*/
|
||||
@Mixin(PalettedContainer.class)
|
||||
public class MixinPalettedContainer {
|
||||
|
||||
@Inject(method = "acquire", at = @At("HEAD"), cancellable = true)
|
||||
private void acquire_skip(CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
}
|
||||
@Inject(method = "release", at = @At("HEAD"), cancellable = true)
|
||||
private void release_skip(CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins.unsafe;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
|
||||
import net.minecraft.util.ThreadingDetector;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
* Why does this exist? But okay! (Will be probably removed when the experimental generator is done)
|
||||
*/
|
||||
@Mixin(ThreadingDetector.class)
|
||||
public class MixinThreadingDectector {
|
||||
@Mutable
|
||||
@Shadow
|
||||
private Semaphore lock;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void setSemaphore(CallbackInfo ci) {
|
||||
this.lock = new Semaphore(2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@Mixin(ServerLevel.class)
|
||||
public class MixinThreadingDectector {} //FIXME: Is there some way to make this file just not be added?
|
||||
#endif
|
||||
@@ -1,11 +1,29 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DependencyHandler;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies, so we
|
||||
@@ -15,18 +33,18 @@ import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Ran
|
||||
* @version 12-1-2021
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public class FabricDependencySetup
|
||||
{
|
||||
public static void createInitialBindings()
|
||||
{
|
||||
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);;
|
||||
SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
|
||||
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
|
||||
}
|
||||
|
||||
public static void finishBinding()
|
||||
{
|
||||
public static void finishBinding() {
|
||||
SingletonHandler.finishBinding();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.config;
|
||||
|
||||
import com.seibel.lod.common.wrappers.config.ConfigGui;
|
||||
@@ -6,9 +25,6 @@ import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* For making the config show up in modmenu
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
|
||||
+32
-14
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -9,17 +27,17 @@ import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
public class OptifineAccessor implements IOptifineAccessor
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return "Optifine-Fabric-1.18.X";
|
||||
}
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return "Optifine-Fabric-1.18.X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks()
|
||||
{
|
||||
// TODO: Impl proper methods here
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks()
|
||||
{
|
||||
// TODO: Impl proper methods here
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+59
-9
@@ -1,32 +1,80 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
#if PRE_MC_1_17_1
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
#else
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
#endif
|
||||
|
||||
public class SodiumAccessor implements ISodiumAccessor {
|
||||
private final IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class);
|
||||
private final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
|
||||
return "Sodium-Fabric-1.16.5";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Sodium-Fabric";
|
||||
}
|
||||
|
||||
#if POST_MC_1_17_1
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.instance();
|
||||
LevelHeightAccessor height = Minecraft.getInstance().level;
|
||||
|
||||
#if POST_MC_1_18_1
|
||||
// 0b11 = Lighted chunk & loaded chunk
|
||||
return renderer.getChunkTracker().getChunks(0b00).filter(
|
||||
(long l) -> {
|
||||
return true;
|
||||
}).mapToObj((long l) -> {
|
||||
return (AbstractChunkPosWrapper)factory.createChunkPos(l);
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
#else
|
||||
// TODO: Maybe use a mixin to make this more efficient, and maybe ignore changes behind the camera
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((AbstractChunkPosWrapper chunk) -> {
|
||||
return (renderer.isBoxVisible(
|
||||
chunk.getMinBlockX()+1, height.getMinBuildHeight()+1, chunk.getMinBlockZ()+1,
|
||||
chunk.getMinBlockX()+15, height.getMaxBuildHeight()-1, chunk.getMinBlockZ()+15));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public HashSet<AbstractChunkPosWrapper> getNormalRenderedChunks() {
|
||||
SodiumWorldRenderer renderer = SodiumWorldRenderer.getInstance();
|
||||
@@ -37,7 +85,7 @@ public class SodiumAccessor implements ISodiumAccessor {
|
||||
return (renderer.isEntityVisible(AABB));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
||||
|
||||
private static class FakeChunkEntity extends Entity {
|
||||
public int cx;
|
||||
public int cz;
|
||||
@@ -62,6 +110,8 @@ public class SodiumAccessor implements ISodiumAccessor {
|
||||
@Override
|
||||
public Packet<?> getAddEntityPacket() {
|
||||
throw new UnsupportedOperationException("This is a FAKE CHUNK ENTITY... For tricking the Sodium to check a AABB.");
|
||||
}}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
|
||||
public class StarlightAccessor implements IStarlightAccessor {
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Starlight-Fabric-1.18.X";
|
||||
}
|
||||
|
||||
public StarlightAccessor() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -455,4 +455,4 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -2,23 +2,27 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.lod.fabric.mixins",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"events.MixinServerLevel",
|
||||
"unsafe.MixinPalettedContainer",
|
||||
"MixinChunkGenerator"
|
||||
"unsafe.MixinThreadingDectector",
|
||||
"MixinUtilBackgroudThread",
|
||||
"events.MixinServerLevel"
|
||||
],
|
||||
"client": [
|
||||
"MixinMinecraft",
|
||||
"MixinOptionsScreen",
|
||||
"MixinWorldRenderer",
|
||||
"MixinFogRenderer",
|
||||
"MixinChunkGenerator",
|
||||
"MixinDebugScreenOverlay",
|
||||
"events.MixinClientLevel",
|
||||
"events.MixinMinecraft",
|
||||
"events.MixinBlockUpdate"
|
||||
"events.MixinBlockUpdate",
|
||||
"events.MixinLightmap"
|
||||
],
|
||||
"server": [
|
||||
"MixinDedicatedServer"
|
||||
],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
"name": "${mod_name}",
|
||||
"description": "${description}",
|
||||
"authors": ["${authors}"],
|
||||
"authors": $authors,
|
||||
|
||||
"contact": {
|
||||
"homepage": "${homepage}",
|
||||
@@ -33,12 +33,11 @@
|
||||
"accessWidener" : "lod.accesswidener",
|
||||
"depends": {
|
||||
"fabricloader": "*",
|
||||
"fabric": "*",
|
||||
"minecraft": ["1.16.5", "1.16.4", "1.16.3", "1.16.2"],
|
||||
"java": ">=8"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-networking-api-v1": "*",
|
||||
"minecraft": $compatible_minecraft_versions,
|
||||
"java": ">=${java_version}"
|
||||
},
|
||||
|
||||
"custom": {
|
||||
|
||||
+186
-5
@@ -1,12 +1,23 @@
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version //FIXME: HERE repeated def
|
||||
group = rootProject.maven_group
|
||||
|
||||
version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm")
|
||||
|
||||
loom {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/lod.accesswidener"))
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener"))
|
||||
forge {
|
||||
convertAccessWideners.set(true)
|
||||
extraAccessWideners.add("lod.accesswidener")
|
||||
@@ -20,11 +31,21 @@ architectury {
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowMe
|
||||
implementation.extendsFrom shadowMe
|
||||
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
jar.dependsOn(project(":core").remapJar)
|
||||
remapSourcesJar.dependsOn(project(":core").remapJar)
|
||||
|
||||
def addMod(path, enabled) {
|
||||
if (enabled == "2")
|
||||
dependencies { modImplementation(path) }
|
||||
@@ -33,13 +54,47 @@ def addMod(path, enabled) {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings & parchment mappings
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
if (
|
||||
rootProject.minecraft_version != "1.19"
|
||||
&& rootProject.minecraft_version != "1.19.1"
|
||||
&& rootProject.minecraft_version != "1.19.2"
|
||||
&& rootProject.minecraft_version != "1.19.3"
|
||||
&& rootProject.minecraft_version != "1.19.4"
|
||||
) // We are not gonna use this build script anymore so dont bother fixing this
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
||||
else
|
||||
parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19.x or higher doesnt have parchment mappings yet, we use 1.18.2 mapping
|
||||
// Note: parchment may have later mappings at the time you are reading this, but at the time this was written, it didnt
|
||||
// Check the main branch for the new build system, with the working mappings
|
||||
}
|
||||
|
||||
//Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
||||
|
||||
// Toml
|
||||
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
||||
|
||||
common(project(":core")) { transitive false }
|
||||
|
||||
// Forge loader
|
||||
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
|
||||
|
||||
// Starlight
|
||||
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
|
||||
annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
|
||||
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
|
||||
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowMe(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
shadowMe files(project(":core").file("build/libs/DistantHorizons-${rootProject.mod_version}.jar"))
|
||||
|
||||
// forgeDependencies(project(":core")) { transitive false }
|
||||
|
||||
@@ -47,12 +102,20 @@ dependencies {
|
||||
// Toml
|
||||
shadowMe("com.electronwill.night-config:toml:${rootProject.toml_version}") {}
|
||||
|
||||
// Compression
|
||||
forgeDependencies('org.tukaani:xz:1.9')
|
||||
forgeDependencies('org.apache.commons:commons-compress:1.21')
|
||||
shadowMe 'org.tukaani:xz:1.9'
|
||||
shadowMe 'org.apache.commons:commons-compress:1.21'
|
||||
}
|
||||
|
||||
// Copies the correct accesswidener and renames it
|
||||
task copyAccessWidener(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
||||
into(file("build/resources/main"))
|
||||
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
||||
}
|
||||
|
||||
task copyCoreResources(type: Copy) {
|
||||
from fileTree(project(":core").file("src/main/resources"))
|
||||
into file("build/resources/main")
|
||||
@@ -63,9 +126,46 @@ task copyCommonResources(type: Copy) {
|
||||
into file("build/resources/main")
|
||||
}
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
processResources {
|
||||
dependsOn(copyAccessWidener)
|
||||
dependsOn(copyCoreResources)
|
||||
dependsOn(copyCommonResources)
|
||||
|
||||
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
||||
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
||||
def replaceProperties = [
|
||||
version : mod_version,
|
||||
mod_name : mod_name,
|
||||
authors : mod_authors,
|
||||
description : mod_description,
|
||||
homepage : mod_homepage,
|
||||
source : mod_source,
|
||||
issues : mod_issues,
|
||||
minecraft_version : minecraft_version,
|
||||
compatible_minecraft_versions: compatible_minecraft_versions,
|
||||
java_version : java_version
|
||||
]
|
||||
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
||||
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
||||
|
||||
inputs.properties replaceProperties
|
||||
replaceProperties.put 'project', project
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
|
||||
intoTargets.each { target ->
|
||||
if (file(target).exists()) {
|
||||
copy {
|
||||
from(sourceSets.main.resources) {
|
||||
include resourceTargets
|
||||
expand replaceProperties
|
||||
}
|
||||
into target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
@@ -76,7 +176,7 @@ shadowJar {
|
||||
configurations = [project.configurations.shadowMe]
|
||||
relocate 'org.tukaani', 'shaded.tukaani'
|
||||
relocate 'org.apache.commons.compress', 'shaded.apache.commons.compress'
|
||||
relocate 'com.electronwill.nightconfig', 'shaded.electronwill.nightconfig'
|
||||
relocate 'com.electronwill.nightconfig', 'shaded.electronwill.nightconfig' // This is already included with forge
|
||||
|
||||
relocate 'com.seibel.lod.common', 'forge.com.seibel.lod.common'
|
||||
|
||||
@@ -90,6 +190,11 @@ remapJar {
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': rootProject.archives_base_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
@@ -118,3 +223,79 @@ publishing {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
|
||||
task printConfigurations {
|
||||
doLast {task ->
|
||||
println "Project Name: $name configurations:"
|
||||
configurations.each {
|
||||
println " $it.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
// For parchment mappings
|
||||
maven { url "https://maven.parchmentmc.org" }
|
||||
|
||||
// used to download and compile dependencies from git repos
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
// For Manifold Preprocessor
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
|
||||
// Required for importing Modrinth mods
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
// Required for importing CursedForge mods
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
content {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
|
||||
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/fabric"
|
||||
content {
|
||||
includeGroup "fabric-mod"
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs "${rootDir}/mods/forge"
|
||||
content {
|
||||
includeGroup "forge-mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
// Add Manifold Preprocessor
|
||||
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
||||
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
||||
//
|
||||
//options.compilerArgs += ['-deprecation']
|
||||
//options.compilerArgs += ['-verbose']
|
||||
//options.compilerArgs += ['-Xlint:unchecked']
|
||||
//options.compilerArgs += ['-Xdiags:verbose']
|
||||
//options.compilerArgs += ['-Xprint']
|
||||
//options.compilerArgs += ['-XprintProcessorInfo']
|
||||
//options.compilerArgs += ['-XprintRounds']
|
||||
|
||||
// println options.compilerArgs
|
||||
|
||||
// Set the java version
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
options.release = rootProject.java_version as Integer //FIXME: This warning??
|
||||
|
||||
// TODO: make everything use java 8
|
||||
// options.release = 8 // Use Java 8 for everything so back porting is easier?
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,9 @@ import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.api.EventApi;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
@@ -32,15 +35,21 @@ import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
#if PRE_MC_1_19_1
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
#else
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.ChunkEvent;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
#endif
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
*
|
||||
*
|
||||
* @author James_Seibel
|
||||
* @version 11-12-2021
|
||||
*/
|
||||
@@ -48,43 +57,70 @@ public class ForgeClientProxy
|
||||
{
|
||||
private final EventApi eventApi = EventApi.INSTANCE;
|
||||
private final ClientApi clientApi = ClientApi.INSTANCE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverTickEvent(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
eventApi.serverTickEvent();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkLoadEvent(ChunkEvent.Load event)
|
||||
{
|
||||
#if PRE_MC_1_19_1
|
||||
clientApi.clientChunkLoadEvent(new ChunkWrapper(event.getChunk(), event.getWorld()), WorldWrapper.getWorldWrapper(event.getWorld()));
|
||||
#else
|
||||
clientApi.clientChunkLoadEvent(new ChunkWrapper(event.getChunk(), event.getLevel()), WorldWrapper.getWorldWrapper(event.getLevel()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
#if PRE_MC_1_19_1
|
||||
public void worldSaveEvent(WorldEvent.Save event)
|
||||
#else
|
||||
public void worldSaveEvent(LevelEvent.Save event)
|
||||
#endif
|
||||
{
|
||||
eventApi.worldSaveEvent();
|
||||
}
|
||||
|
||||
|
||||
/** This is also called when a new dimension loads */
|
||||
@SubscribeEvent
|
||||
#if PRE_MC_1_19_1
|
||||
public void worldLoadEvent(WorldEvent.Load event)
|
||||
#else
|
||||
public void worldLoadEvent(LevelEvent.Load event)
|
||||
#endif
|
||||
{
|
||||
if (Minecraft.getInstance().screen instanceof TitleScreen) return;
|
||||
if (Minecraft.getInstance().getConnection() == null) return; // In 1.19.3, the multiplayer world load is called twice. The first time is before it actually connects to the multiplayer server (so stuff like ip and name arent sent out yet)
|
||||
#if PRE_MC_1_19_1
|
||||
if (event.getWorld() != null) {
|
||||
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
|
||||
}
|
||||
#else
|
||||
if (event.getLevel() != null) {
|
||||
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(event.getLevel()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
#if PRE_MC_1_19_1
|
||||
public void worldUnloadEvent(WorldEvent.Unload event)
|
||||
{
|
||||
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
|
||||
}
|
||||
|
||||
#else
|
||||
public void worldUnloadEvent(LevelEvent.Unload event)
|
||||
{
|
||||
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(event.getLevel()));
|
||||
}
|
||||
#endif
|
||||
|
||||
@SubscribeEvent
|
||||
public void blockChangeEvent(BlockEvent event)
|
||||
{
|
||||
@@ -95,22 +131,26 @@ public class ForgeClientProxy
|
||||
event.getClass() == BlockEvent.FluidPlaceBlockEvent.class ||
|
||||
event.getClass() == BlockEvent.PortalSpawnEvent.class)
|
||||
{
|
||||
#if PRE_MC_1_19_1
|
||||
IChunkWrapper chunk = new ChunkWrapper(event.getWorld().getChunk(event.getPos()), event.getWorld());
|
||||
DimensionTypeWrapper dimType = DimensionTypeWrapper.getDimensionTypeWrapper(event.getWorld().dimensionType());
|
||||
|
||||
#else
|
||||
IChunkWrapper chunk = new ChunkWrapper(event.getLevel().getChunk(event.getPos()), event.getLevel());
|
||||
DimensionTypeWrapper dimType = DimensionTypeWrapper.getDimensionTypeWrapper(event.getLevel().dimensionType());
|
||||
#endif
|
||||
|
||||
// recreate the LOD where the blocks were changed
|
||||
eventApi.blockChangeEvent(chunk, dimType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
public void onKeyInput(#if PRE_MC_1_19_1 InputEvent.KeyInputEvent event #else InputEvent.Key event #endif)
|
||||
{
|
||||
if (Minecraft.getInstance().player == null) return;
|
||||
if (event.getAction() != GLFW.GLFW_PRESS) return;
|
||||
clientApi.keyPressedEvent(event.getKey());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user