Compare commits

...

162 Commits

Author SHA1 Message Date
dfsek 0feae25be5 Merge pull request #318 from PolyhedralDev/dev/1.19
Update to 1.19
2022-06-07 15:40:41 -07:00
dfsek d0069ffe83 bump version 2022-06-07 15:13:19 -07:00
dfsek cec83aeb78 Merge pull request #317 from PolyhedralDev/ver/6.0.1
Update addons when new minor and patch versions are available
2022-06-07 15:06:21 -07:00
dfsek c468054bbe spawn entity in serverworld with no world object 2022-06-07 15:05:47 -07:00
dfsek 372931a9c5 fix chunkregion entity spawn crash 2022-06-07 13:56:02 -07:00
dfsek 9a640de8d3 fix file dumping 2022-06-07 11:38:53 -07:00
dfsek f4968e1509 downgrade loom 2022-06-07 11:38:40 -07:00
dfsek 1858bab210 only remove old resources if replacement exists 2022-06-07 11:19:53 -07:00
dfsek c811fd31b1 warn about nonexistent classpath resources 2022-06-07 11:17:07 -07:00
dfsek 098cb740dd fix addon check on fresh install 2022-06-07 11:02:58 -07:00
dfsek 9ac63ce469 fix (??) Loom issues 2022-06-07 11:01:14 -07:00
dfsek db0067a6d9 improve addonDir addon installation 2022-06-07 10:19:42 -07:00
dfsek 5de8df188a specify failed addon path 2022-06-07 08:53:57 -07:00
dfsek fa66bd3c42 create addon dir if it doesn't exist 2022-06-07 08:32:55 -07:00
dfsek e89d473669 update to 1.19 2022-06-07 08:24:58 -07:00
dfsek 90f3138395 Merge remote-tracking branch 'origin/ver/6.0.1' into dev/1.19 2022-06-07 08:18:05 -07:00
dfsek 4e789479e4 update loom 2022-06-07 08:13:59 -07:00
dfsek 3fbb93d157 Merge pull request #312 from duplexsystem/patch-1
Fix fabric config
2022-06-07 00:39:51 -07:00
dfsek 90a48345c2 automatically update addons when minor & patch versions are changed 2022-06-07 00:39:05 -07:00
dfsek 7c00cad4c9 add Pair function API 2022-06-07 00:38:09 -07:00
solo 963e070f92 Merge pull request #313 from duplexsystem/patch-2
fix new lines in PULL_REQUEST_TEMPLATE.md so that check boxes render …
2022-06-06 12:53:05 -04:00
dfsek 908a5dc309 use main executor for generation 2022-06-05 20:59:37 -07:00
dfsek 3adcdb4019 implement air threshold in beardifier 2022-06-05 19:28:08 -07:00
dfsek fbbf09a937 fix beardification 2022-06-05 18:55:43 -07:00
dfsek 254bc93f93 remove unneeded seed from TerraBiomeSource 2022-06-05 17:48:12 -07:00
dfsek ed7bfd2d68 register normal tag to Terra world presets 2022-06-05 17:18:24 -07:00
dfsek 76e8c2d2b1 tag collection util method 2022-06-05 16:57:43 -07:00
dfsek b0aca47e74 registerTags -> registerBiomeTags 2022-06-05 16:56:43 -07:00
dfsek 5d703327db bump versions 2022-06-04 15:11:59 -07:00
dfsek 5ebe09444b Merge pull request #314 from PolyhedralDev/ver/6.0.1
Patch version 6.0.1
2022-06-04 15:05:22 -07:00
dfsek 136ceddff5 getOrDefault with empty list 2022-06-04 14:27:48 -07:00
dfsek b4bee3a65d add ReloadCommandMixin 2022-06-04 01:15:53 -07:00
dfsek f870dab568 correct key used to register world type 2022-06-04 00:36:36 -07:00
dfsek 7027574d35 Merge remote-tracking branch 'origin/ver/6.0.1' into dev/1.19 2022-06-04 00:11:58 -07:00
dfsek c55c19a32e reduce seed hack console spam 2022-06-03 22:36:56 -07:00
dfsek f05e4c1852 register terra world preset 2022-06-03 22:32:30 -07:00
dfsek 1eb2d5c3ac fix mapping change in BeardGenerator 2022-06-03 20:39:14 -07:00
dfsek 3b98f8c0ab add seed hack for biome provider 2022-06-03 20:39:05 -07:00
dfsek 229886d84c update to minecraft 1.19-rc2 2022-06-03 17:24:44 -07:00
dfsek c1dc637eb2 fix run task addon dependency 2022-06-02 22:05:24 -07:00
dfsek a5db29f2ad fix TerraScript EqualsStatement 2022-06-02 22:04:52 -07:00
dfsek 20e6b8bb63 promote terrascript log function to info level 2022-06-02 22:03:36 -07:00
Zoë c7f6e34647 fix new lines in PULL_REQUEST_TEMPLATE.md so that check boxes render correctly on github 2022-06-02 23:44:05 -04:00
Zoë dc59bb5d2e Fix fabric config
the config.yml in the fabric implementation is outdated and presumably unneeded
2022-06-02 23:40:30 -04:00
dfsek 64f66474b1 remove fabric command api dependency 2022-06-02 08:16:25 -07:00
dfsek d4abedaa05 remove cloud Fabric dependency entirely 2022-06-02 08:11:09 -07:00
dfsek 6e18978586 use default block registry 2022-06-02 08:07:21 -07:00
dfsek 5b2e8b7fbd temporarily disable Cloud 2022-06-02 08:05:09 -07:00
dfsek 2608e94980 fix run task addon dependency 2022-06-02 07:47:31 -07:00
dfsek 1d469687cb Merge branch 'master' into dev/1.19 2022-06-02 07:19:14 -07:00
dfsek a9248435a2 Merge pull request #227 from PolyhedralDev/ver/6.0.0
Major Version 6.0 Tracking PR
2022-06-01 11:01:24 -07:00
dfsek b4cdb7f16c yell very loudly if NMS bindings fail to initialize 2022-05-31 23:00:44 -07:00
dfsek 675a4465d7 redo addon bundling 2022-05-31 22:31:51 -07:00
dfsek 839013d89a split NMS away from core bukkit code 2022-05-31 22:31:40 -07:00
dfsek 8e933a1bb4 remove println 2022-05-31 18:41:39 -07:00
dfsek 10308959a1 fix stronghold deadlock 2022-05-31 18:33:39 -07:00
dfsek 68ac277471 clean up 2022-05-31 16:43:43 -07:00
dfsek b93ff99b2e use server structure registry 2022-05-31 15:51:58 -07:00
dfsek 285367f616 dont inject vanilla gen settings in bukkit biome delegate 2022-05-31 15:43:24 -07:00
dfsek e3dd42c856 fix deadlock 2022-05-31 15:20:23 -07:00
dfsek a54b48f68a fix NMSBiomeProvider 2022-05-31 15:12:14 -07:00
dfsek de2d37cdf5 implement more vanilla methods in NMSChunkGeneratorDelegate 2022-05-31 14:54:41 -07:00
dfsek 75b72a500d remove unneeded chunkgenerator overrides 2022-05-31 14:37:30 -07:00
dfsek 7da0580eda Revert "implement hacky Bukkit structure workaround"
This reverts commit 6883151809.
2022-05-31 14:22:36 -07:00
dfsek 6883151809 implement hacky Bukkit structure workaround 2022-05-31 13:23:38 -07:00
dfsek 00e9ab4263 pass seed into NMSChunkGeneratorDelegate 2022-05-31 00:26:05 -07:00
dfsek 2acfada4f8 add core count throttling option to bukkit buildscript 2022-05-30 22:32:17 -07:00
dfsek d07f9fe341 clean up BeardGenerator 2022-05-30 20:44:29 -07:00
dfsek 9c9487ced6 1.19 fabric compiles now 2022-05-30 20:44:04 -07:00
dfsek 9d131a8992 update FabricChunkGeneratorWrapper 2022-05-30 19:55:42 -07:00
dfsek cd57a32f31 update build to support 1.19 2022-05-30 19:48:37 -07:00
dfsek 4c2ece3eb7 dont shade fastmath when it's unneeded 2022-05-30 17:56:13 -07:00
dfsek 59318d75fc use caffeine cache in biome pipeline provider 2022-05-30 17:43:27 -07:00
dfsek d9eef2e5d5 clean up imports 2022-05-30 17:32:05 -07:00
dfsek 2f189d94ac add inject lock 2022-05-30 15:53:37 -07:00
dfsek 223db88462 log when spawn found 2022-05-30 14:05:51 -07:00
dfsek f2d9511f01 implement BukkitChunkGeneratorWrapper#getFixedSpawnLocation 2022-05-30 13:58:09 -07:00
dfsek ef1f1c0af0 fix range bounds check 2022-05-29 23:49:25 -07:00
dfsek da28244f81 typo 2022-05-29 23:46:05 -07:00
dfsek 77ba13ce93 actually fix rangeloader 2022-05-29 23:44:43 -07:00
dfsek eb8bafe5d8 fix rangeloader singleton 2022-05-29 23:37:54 -07:00
dfsek 411ef10c0c fix versioning issues 2022-05-29 21:44:52 -07:00
dfsek 01d4174092 bump all addon versions 2022-05-29 21:33:45 -07:00
dfsek d072e72590 fix bukkit isSolid check 2022-05-29 21:09:02 -07:00
dfsek 38e4e9bc94 simplify NMS impl 2022-05-29 21:04:48 -07:00
dfsek 126ddaf9c7 dont shade unneeded bukkit dependencies 2022-05-29 20:42:11 -07:00
dfsek 4bf5be5734 demote biome registration to debug log 2022-05-29 19:17:23 -07:00
dfsek c8a4f8be6a fix colors 2022-05-29 19:13:00 -07:00
dfsek 049c5cc83a inject tags into Bukkit biome delegates 2022-05-29 18:51:29 -07:00
dfsek ef1f2e882d implement NMS chunk generator on bukkit 2022-05-29 18:35:38 -07:00
dfsek e94d90050a remove unneeded PaperListener 2022-05-29 15:28:06 -07:00
dfsek 8977e82b73 add Bukkit NMS dependency 2022-05-29 15:05:29 -07:00
dfsek dfff178bfe update paper build number 2022-05-29 05:08:24 -07:00
dfsek 4f00dadc22 update purpur URL 2022-05-29 05:06:14 -07:00
dfsek 7b439f005e geerate vanilla structures on bukkit 2022-05-29 05:02:47 -07:00
dfsek 5c165cd40d fix chunk generator wrapper codec 2022-05-29 04:51:25 -07:00
dfsek 43a84cca3d simplify biome tag injection 2022-05-29 03:36:52 -07:00
dfsek a4d87a428c add vanilla bonemeal flowers to Terra biomes 2022-05-29 03:05:01 -07:00
dfsek 414c0b8a38 cache UserDefinedFunctions 2022-05-28 17:39:52 -07:00
dfsek a11e02a84a use paralithic eval in MetaNumberPreprocessor 2022-05-28 17:16:12 -07:00
dfsek 1a08414822 bump paralithic version 2022-05-28 17:11:30 -07:00
dfsek 0b6b66b7e6 apply vanilla biome flower feature supplier to terra biomes 2022-05-28 16:39:10 -07:00
dfsek 278ab648dd fix tag injection logger 2022-05-28 15:56:00 -07:00
dfsek fe101f1221 refactor fabric util methods 2022-05-28 14:05:25 -07:00
dfsek b6b6cb185d implement API for 3d biomes 2022-05-27 14:40:50 -07:00
dfsek ee373bbe4b reformat code 2022-05-26 19:40:41 -07:00
dfsek 49857f6b91 remove Properties 2022-05-26 19:33:37 -07:00
dfsek 8655f7811a remove rotationutil methods 2022-05-26 19:32:20 -07:00
dfsek ce47cd9316 bump fabric API version 2022-05-26 15:23:38 -07:00
dfsek c4c71ac9ef add slant singleton 2022-05-26 14:40:58 -07:00
dfsek eaebc445f6 apply narrowing operation to BinaryColumn#and 2022-05-26 13:18:00 -07:00
dfsek 3ec15960cf reduce overhead of profiler when not profiling 2022-05-26 12:51:18 -07:00
dfsek 5275c40c6a remove some @Shadow methods in favor of casts 2022-05-26 12:16:40 -07:00
dfsek 68ef5a5a32 demote tag log to debug 2022-05-25 23:57:00 -07:00
dfsek 63bfa6bf14 fix NotEqualsStatement 2022-05-25 23:01:14 -07:00
dfsek bce25b8702 fix refactor typo in BUG_REPORT.md 2022-05-25 22:27:52 -07:00
dfsek c88fbc0321 remove unneeded lang file 2022-05-25 22:27:18 -07:00
dfsek 0d1e7fd686 Merge remote-tracking branch 'origin/master' into ver/6.0.0
# Conflicts:
#	build.gradle.kts
#	common/src/main/resources/lang/de_de.yml
#	platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/world/BukkitTree.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java
2022-05-25 22:26:09 -07:00
dfsek bd2ec52832 fix tag registration 2022-05-25 20:44:26 -07:00
dfsek c3b9902c5f remove unneeded jank warning 2022-05-25 19:59:04 -07:00
dfsek 69a5cfecd1 remove println 2022-05-25 17:51:32 -07:00
dfsek 304ae3075b Revert "remove unneeded lifecycle mixins"
This reverts commit af90088505.
2022-05-25 14:48:30 -07:00
dfsek 0550f36447 fix biome provider codec 2022-05-25 14:36:41 -07:00
dfsek b82e84d447 better error message when injecting tags 2022-05-25 12:22:30 -07:00
dfsek 7a59aeb80c add BukkitAdapter util method 2022-05-25 12:22:30 -07:00
dfsek 0228facd71 sort of fix more stuff 2022-05-25 00:43:52 -07:00
dfsek af90088505 remove unneeded lifecycle mixins 2022-05-24 23:53:23 -07:00
dfsek 2ddf620fb8 register biomes to builtin registries 2022-05-24 23:35:28 -07:00
dfsek 0c3d4f4f4e lazily evaluate terrascript binary operations 2022-05-24 18:25:24 -07:00
dfsek e339b26657 remove unused hashmap impl 2022-05-15 22:13:20 -07:00
dfsek cee42ac467 bump fabric loader dependency 2022-05-15 19:22:14 -07:00
dfsek a2b061ce0d fix JIJ 2022-05-15 19:22:05 -07:00
dfsek 7d2c2bb141 use cast for ServerWorldMixin#getSeed 2022-05-15 18:41:10 -07:00
dfsek 8cd31ead99 bump mixin config java version 2022-05-15 18:40:54 -07:00
dfsek 3a8fb37cd6 remove unneeded iface map option 2022-05-15 18:32:40 -07:00
dfsek 2abf809d0f improve constant baking in SamplerFunction 2022-05-14 14:19:49 -07:00
dfsek cc9c7870ba shade api into Fabric 2022-05-14 13:01:33 -07:00
dfsek 2fe04d7f6b Merge remote-tracking branch 'origin/ver/6.0.0' into ver/6.0.0
# Conflicts:
#	build.gradle.kts
#	buildSrc/src/main/kotlin/DependencyConfig.kt
#	buildSrc/src/main/kotlin/DistributionConfig.kt
#	common/addons/biome-provider-image/build.gradle.kts
#	common/addons/biome-provider-pipeline/build.gradle.kts
#	common/addons/biome-provider-single/build.gradle.kts
#	common/addons/chunk-generator-noise-3d/build.gradle.kts
#	common/addons/command-addons/build.gradle.kts
#	common/addons/command-packs/build.gradle.kts
#	common/addons/command-profiler/build.gradle.kts
#	common/addons/command-structures/build.gradle.kts
#	common/addons/config-biome/build.gradle.kts
#	common/addons/config-distributors/build.gradle.kts
#	common/addons/config-feature/build.gradle.kts
#	common/addons/config-flora/build.gradle.kts
#	common/addons/config-locators/build.gradle.kts
#	common/addons/config-noise-function/build.gradle.kts
#	common/addons/config-ore/build.gradle.kts
#	common/addons/config-palette/build.gradle.kts
#	common/addons/config-structure/build.gradle.kts
#	common/addons/generation-stage-feature/build.gradle.kts
#	common/addons/generation-stage-structure/build.gradle.kts
#	common/addons/language-yaml/build.gradle.kts
#	common/addons/manifest-addon-loader/build.gradle.kts
#	common/addons/palette-block-shortcut/build.gradle.kts
#	common/addons/structure-block-shortcut/build.gradle.kts
#	common/addons/structure-mutator/build.gradle.kts
#	common/addons/structure-sponge-loader/build.gradle.kts
#	common/addons/structure-terrascript-loader/build.gradle.kts
#	common/addons/terrascript-function-check-noise-3d/build.gradle.kts
#	common/addons/terrascript-function-sampler/build.gradle.kts
#	common/api/build.gradle.kts
#	common/implementation/base/build.gradle.kts
#	common/implementation/bootstrap-addon-loader/build.gradle.kts
#	platforms/bukkit/build.gradle.kts
#	platforms/cli/build.gradle.kts
#	platforms/merged/build.gradle.kts
2022-05-14 12:03:56 -07:00
dfsek 977316c57f make bukkit warning less obnoxious 2022-05-05 15:25:53 -07:00
dfsek d2c5f711ef Merge remote-tracking branch 'origin/ver/6.0.0' into ver/6.0.0 2022-05-05 15:16:40 -07:00
dfsek b8baa05922 fix bukkit shading 2022-05-05 15:16:27 -07:00
dfsek 98b332fe54 fix shading config 2022-05-05 14:56:51 -07:00
dfsek 6e61154cc5 update paralithic version 2022-05-05 14:47:38 -07:00
dfsek 0a5450a345 shade paralithic in noise addon 2022-05-05 10:16:09 -07:00
dfsek 83baf377e0 fix bootstrap addon class referencing from addons 2022-05-05 09:14:45 -07:00
dfsek ffc884384c create BootstrapAddonClassLoader 2022-05-05 08:56:35 -07:00
dfsek 0c302456a2 use shadowJar for addon packaging 2022-05-05 08:32:48 -07:00
dfsek 41e7ad35bd simplify dependency configuration 2022-05-05 08:25:30 -07:00
dfsek 82b474ead2 Merge pull request #307 from LtPeriwinkle/posterization-normalizer
Implement posterization normalizer
2022-05-03 18:10:14 -07:00
LtPeriwinkle d544e16885 Feat: Implement posterization normalizer
Closes #204
2022-05-03 17:45:19 -07:00
dfsek 4396623420 improve addon dependency system 2022-04-29 23:03:18 -07:00
dfsek d2795bfdb6 replace ChunkInterpolator mod by 4 with and by 3 2022-04-29 22:00:22 -07:00
dfsek 42fb3642f9 update bukkit testing stuff 2022-04-24 23:43:37 -07:00
dfsek e445fd986d Bump version 2021-09-06 12:45:53 -07:00
Cubxity d7bb818f51 Mitigate issues with tree generation in paper (#260)
* fix: mitigate cocoa tree generation crash

* chore: suppress warnings

* chore: fix formatting

* refactor: catch specific exception

* chore: added reference to PaperMC/Paper#6028
2021-09-06 12:44:43 -07:00
dfsek eef0e04682 Merge pull request #238 from pavog/patch-1
Fix spelling issues / typos in german translation
2021-09-06 12:44:24 -07:00
dfsek 9c857bf86b Merge pull request #255 from uRyanxD/master
Addition: Portuguese translation.
2021-09-06 12:44:13 -07:00
dfsek d440dacf30 Merge pull request #233 from ishland/fix/devlaunch
Fix fabric development environment launch
2021-09-06 12:43:58 -07:00
uRyanxD ffbc253477 Addition: Portuguese translation. 2021-08-12 20:48:27 -03:00
Paul Vogel b4ed874043 Fix spelling issues / typos in german translation 2021-07-07 23:10:43 +02:00
ishland f1845b1ecd Made requested changes 2021-07-04 13:41:56 +08:00
ishland f2946d85aa Fix fabric development environment launch 2021-07-04 00:15:53 +08:00
260 changed files with 2851 additions and 2395 deletions
+2 -2
View File
@@ -21,8 +21,8 @@ assignees: ""
- You must be on the LATEST version of Terra to receive any support. There is no support for older versions of Terra.
- Make sure that this is not a *specific* compatibility issue with another terrain generation mod.
Do not request *specific* compatibility with mods or plugins (e.g. "Compatibility with TechCraft v7").
That should be implemented in an addon, **not** in the platform project.
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the platform project.
That should be implemented in an addon, **not** in the main project.
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the main project.
- Make sure that there are no already existing issues open with your problem. If you open a duplicate, it will be closed as such.
- Make sure that it is actually Terra causing the issue, and not another mod/plugin.
You can do this by testing to see if you can recreate the issue without Terra installed.
+5 -9
View File
@@ -72,19 +72,15 @@
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
- [ ] Build system <!-- Anything which pretain to the build system. -->
- [ ]
Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
- [ ]
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ]
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ] Revert <!-- Anything which reverts previous commits. -->
- [ ] Style <!-- Anything which updates style. -->
- [ ] Tests <!-- Anything which adds or updates tests. -->
- [ ]
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
#### Compatiblity
@@ -119,4 +115,4 @@
<!--
If it only introduces small changes, you don't need to add tests.
But if you add big changes, you should probably at least write *some* testing, where applicable.
-->
-->
+10 -6
View File
@@ -1,8 +1,8 @@
preRelease(true)
versionProjects(":common:api", version("6.0.0"))
versionProjects(":common:implementation", version("6.0.0"))
versionProjects(":platforms", version("6.0.0"))
versionProjects(":common:api", version("6.1.0"))
versionProjects(":common:implementation", version("6.1.0"))
versionProjects(":platforms", version("6.1.0"))
allprojects {
@@ -39,14 +39,18 @@ allprojects {
}
afterEvaluate {
forSubProjects(":platforms") {
forImmediateSubProjects(":platforms") {
configureDistribution()
}
forSubProjects(":common:addons") {
apply(plugin = "com.github.johnrengelman.shadow")
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}
dependencies {
"compileOnly"(project(":common:api"))
"shadedImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
"testImplementation"(project(":common:api"))
}
}
+11 -2
View File
@@ -3,6 +3,15 @@ plugins {
kotlin("jvm") version embeddedKotlinVersion
}
buildscript {
configurations.all {
resolutionStrategy {
force("org.ow2.asm:asm:9.3") // TODO: remove when ShadowJar updates ASM version
force("org.ow2.asm:asm-commons:9.3")
}
}
}
repositories {
mavenCentral()
gradlePluginPortal()
@@ -11,8 +20,8 @@ repositories {
dependencies {
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
implementation("org.ow2.asm:asm:9.2")
implementation("org.ow2.asm:asm-tree:9.2")
implementation("org.ow2.asm:asm:9.3")
implementation("org.ow2.asm:asm-tree:9.3")
implementation("com.dfsek.tectonic:common:4.2.0")
implementation("org.yaml:snakeyaml:1.27")
}
+24 -23
View File
@@ -3,7 +3,6 @@ import java.io.File
import java.util.function.Predicate
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.extra
import kotlin.streams.asStream
@@ -12,31 +11,33 @@ import kotlin.streams.asStream
* Configures a directory where addons will be put.
*/
fun Project.addonDir(dir: File, task: Task) {
task.doFirst {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = if (tasks.findByName("shadowJar") != null) {
(tasks.named("shadowJar").get() as ShadowJar)
} else {
(tasks.named("jar").get() as Jar)
val moveAddons = tasks.register("moveAddons" + task.name) {
dependsOn("compileAddons")
doLast {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = tasks.named("shadowJar").get() as ShadowJar
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())
val base = "${jar.archiveBaseName.get()}-${version}"
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
jar.archiveFile.orNull?.asFile?.copyTo(target)
}
}
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())
val base = "${jar.archiveBaseName.get()}-${version}"
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
jar.archiveFile.orNull?.asFile?.copyTo(target)
}
}
task.dependsOn(moveAddons)
}
fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {
+8 -5
View File
@@ -3,14 +3,16 @@ import org.gradle.kotlin.dsl.creating
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.maven
import org.gradle.kotlin.dsl.repositories
fun Project.configureDependencies() {
val api by configurations.getting
val implementation by configurations.getting
val testImplementation by configurations.getting
val compileOnly by configurations.getting
val api by configurations.getting
val implementation by configurations.getting
val shaded by configurations.creating
@Suppress("UNUSED_VARIABLE")
@@ -28,9 +30,10 @@ fun Project.configureDependencies() {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url = uri("https://maven.fabricmc.net/") }
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
maven("https://maven.fabricmc.net/")
maven("https://repo.codemc.org/repository/maven-public")
maven("https://repo.codemc.io/repository/nms/")
maven("https://papermc.io/repo/repository/maven-public/")
}
dependencies {
+33 -40
View File
@@ -1,23 +1,25 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileWriter
import java.net.URL
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.BasePluginExtension
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.creating
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.named
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
fun Project.configureDistribution() {
apply(plugin = "com.github.johnrengelman.shadow")
@@ -30,50 +32,45 @@ fun Project.configureDistribution() {
}
}
val installAddons = tasks.create("installAddons") {
group = "terra"
val compileAddons = tasks.create("compileAddons") {
forSubProjects(":common:addons") {
afterEvaluate {
dependsOn(getJarTask())
}
}
}
val installAddons = tasks.create("installAddons") {
group = "terra"
dependsOn(compileAddons)
doLast {
// The addons are copied into a JAR because of a ShadowJar bug
// which expands *all* JARs, even resource ones, into the fat JAR.
// To get around this, we copy all addon JARs into a *new* JAR,
// then, ShadowJar expands the newly created JAR, putting the original
// JARs where they should go.
//
// https://github.com/johnrengelman/shadow/issues/111
val dest = File(buildDir, "/resources/main/addons.jar")
dest.parentFile.mkdirs()
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().asFile.toPath()
val zip = ZipOutputStream(FileOutputStream(dest))
forSubProjects(":common:addons") {
val jar = getJarTask()
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
zip.putNextEntry(entry)
FileInputStream(jar.archiveFile.get().asFile).run {
copyTo(zip)
close()
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
forSubProjects(":common:addons") {
val jar = getJarTask()
println("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}");
if (!Files.exists(addonPath)) {
Files.createDirectories(addonPath.parent)
Files.createFile(addonPath)
Files.copy(jar.archiveFile.get().asFile.toPath(), addonPath, StandardCopyOption.REPLACE_EXISTING)
}
}
zip.closeEntry()
}
zip.close()
}
}
val generateResourceManifest = tasks.create("generateResourceManifest") {
group = "terra"
dependsOn(downloadDefaultPacks)
dependsOn(installAddons)
doLast {
val resources = HashMap<String, MutableList<String>>()
val packsDir = File("${project.buildDir}/resources/main/packs/")
@@ -118,18 +115,20 @@ fun Project.configureDistribution() {
tasks["processResources"].dependsOn(generateResourceManifest)
tasks.named<ShadowJar>("shadowJar") {
// Tell shadow to download the packs
dependsOn(downloadDefaultPacks)
configurations = listOf(project.configurations["shaded"])
archiveClassifier.set("shaded")
setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
relocate("org.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
finalizedBy(installAddons)
}
configure<BasePluginExtension> {
@@ -148,10 +147,4 @@ fun downloadPack(packUrl: URL, project: Project) {
file.outputStream().write(packUrl.readBytes())
}
fun Project.getJarTask(): Jar {
return if (tasks.findByName("shadowJar") != null) {
(tasks.named("shadowJar").get() as ShadowJar)
} else {
(tasks.named("jar").get() as Jar)
}
}
fun Project.getJarTask() = tasks.named("shadowJar").get() as ShadowJar
+6
View File
@@ -29,6 +29,12 @@ fun Project.forSubProjects(project: String, action: Action<Project>) {
}
}
fun Project.forImmediateSubProjects(project: String, action: Action<Project>) {
project(project).childProjects.forEach {
action.execute(it.value)
}
}
fun preRelease(preRelease: Boolean) {
isPrerelease = preRelease
}
+6 -5
View File
@@ -1,7 +1,7 @@
object Versions {
object Libraries {
const val tectonic = "4.2.0"
const val paralithic = "0.6.0"
const val paralithic = "0.7.0"
const val strata = "1.1.1"
const val cloud = "1.6.2"
@@ -13,17 +13,18 @@ object Versions {
const val apacheText = "1.9"
const val jafama = "2.3.2"
const val apacheIO = "2.6"
const val asm = "9.2"
const val fastutil = "8.5.6"
}
}
object Fabric {
const val fabricLoader = "0.14.2"
const val fabricAPI = "0.51.1+1.18.2"
const val minecraft = "1.18.2"
const val yarn = "$minecraft+build.3"
const val fabricAPI = "0.55.1+1.19"
const val minecraft = "1.19"
const val yarn = "$minecraft+build.1"
const val permissionsAPI = "0.1-SNAPSHOT"
const val mixin = "0.11.2+mixin.0.8.5"
const val loom = "0.11-SNAPSHOT"
}
object Bukkit {
@@ -0,0 +1,26 @@
package com.dfsek.terra.addon.loader;
import ca.solostudios.strata.version.Version;
import com.dfsek.terra.api.addon.BaseAddon;
public class ApiAddon implements BaseAddon {
private final Version version;
private final String id;
public ApiAddon(Version version, String id) {
this.version = version;
this.id = id;
}
@Override
public Version getVersion() {
return version;
}
@Override
public String getID() {
return id;
}
}
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addon.loader;
import java.net.URL;
import java.net.URLClassLoader;
public class ApiAddonClassLoader extends URLClassLoader {
static {
ClassLoader.registerAsParallelCapable();
}
public ApiAddonClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
}
@@ -14,6 +14,7 @@ import java.nio.file.Path;
import java.util.Collections;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
@@ -21,7 +22,8 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
private static final Version VERSION = Versions.getVersion(1, 0, 0);
@Override
public Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
public Iterable<BaseAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
return Collections.emptySet();
}
@@ -1,5 +1,11 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.biome.image.lib.jafama")
}
@@ -37,7 +37,7 @@ public class ImageBiomeProvider implements BiomeProvider {
}
@Override
public Biome getBiome(int x, int z, long seed) {
public Biome getBiome(int x, int y, int z, long seed) {
x /= resolution;
z /= resolution;
Color color = align.getColor(image, x, z);
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.biome.image.ImageBiomeProviderAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-biome-provider-image/issues
source: https://github.com/PolyhedralDev/Terra-biome-provider-image
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,14 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("com.github.ben-manes.caffeine:caffeine:3.1.0")
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("com.github.benmanes.caffeine", "com.dfsek.terra.addons.biome.pipeline.lib.caffeine")
relocate("net.jafama", "com.dfsek.terra.addons.biome.pipeline.lib.jafama")
}
@@ -7,11 +7,9 @@
package com.dfsek.terra.addons.biome.pipeline;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import net.jafama.FastMath;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.HashSet;
@@ -40,16 +38,9 @@ public class BiomePipelineProvider implements BiomeProvider {
this.resolution = resolution;
this.mutator = mutator;
this.noiseAmp = noiseAmp;
holderCache = CacheBuilder.newBuilder()
.maximumSize(1024)
.build(
new CacheLoader<>() {
@Override
public BiomeHolder load(@NotNull SeededVector key) {
return pipeline.getBiomes(key.x, key.z, key.seed);
}
}
);
holderCache = Caffeine.newBuilder()
.maximumSize(1024)
.build(key -> pipeline.getBiomes(key.x, key.z, key.seed));
this.pipeline = pipeline;
Set<BiomeDelegate> biomeSet = new HashSet<>();
@@ -81,7 +72,7 @@ public class BiomePipelineProvider implements BiomeProvider {
}
@Override
public Biome getBiome(int x, int z, long seed) {
public Biome getBiome(int x, int y, int z, long seed) {
x += mutator.noise(seed + 1, x, z) * noiseAmp;
z += mutator.noise(seed + 2, x, z) * noiseAmp;
@@ -92,7 +83,7 @@ public class BiomePipelineProvider implements BiomeProvider {
int fdX = FastMath.floorDiv(x, pipeline.getSize());
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
return holderCache.getUnchecked(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
return holderCache.get(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
z - fdZ * pipeline.getSize()).getBiome();
}
@@ -10,7 +10,7 @@ final class SelfDelegate implements BiomeDelegate {
public static final SelfDelegate INSTANCE = new SelfDelegate();
private SelfDelegate() {
}
@Override
@@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
@Description("""
The initial size of biome chunks. This value must be at least 2.
<b>This is not the final size of biome chunks. Final chunks will be much larger</b>.
It is recommended to keep biome chunks' final size in the range of [50, 300]
to prevent performance issues. To calculate the size of biome chunks, simply
take initial-size and for each expand stage, multiply the running value by 2
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.biome.pipeline.BiomePipelineAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline/issues
source: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -21,7 +21,7 @@ public class SingleBiomeProvider implements BiomeProvider {
}
@Override
public Biome getBiome(int x, int z, long seed) {
public Biome getBiome(int x, int y, int z, long seed) {
return biome;
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.biome.single.SingleBiomeProviderAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-biome-provider-single/issues
source: https://github.com/PolyhedralDev/Terra-biome-provider-single
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,12 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.chunkgenerator.lib.jafama")
}
@@ -79,6 +79,6 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
slantLayers.put(threshold, layer.getPalette());
}
return new PaletteInfo(builder.build(), new SlantHolder(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
return new PaletteInfo(builder.build(), SlantHolder.of(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
}
}
@@ -18,7 +18,6 @@ import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.profiler.ProfileFrame;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
@@ -51,61 +50,61 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
@NotNull BiomeProvider biomeProvider,
int chunkX, int chunkZ) {
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
int xOrig = (chunkX << 4);
int zOrig = (chunkZ << 4);
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
long seed = world.getSeed();
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
chunkX,
chunkZ,
world.getMaxHeight(),
world.getMinHeight(),
carverHorizontalResolution,
carverVerticalResolution,
seed);
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
int paletteLevel = 0;
int cx = xOrig + x;
int cz = zOrig + z;
Biome biome = biomeProvider.getBiome(cx, cz, seed);
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
int sea = paletteInfo.seaLevel();
Palette seaPalette = paletteInfo.ocean();
BlockState data;
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
if(sampler.sample(x, y, z) > 0) {
if(carver.sample(x, y, z) <= 0) {
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
seed);
chunk.setBlock(x, y, z, data);
}
paletteLevel++;
} else if(y <= sea) {
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
paletteLevel = 0;
} else {
paletteLevel = 0;
platform.getProfiler().push("chunk_base_3d");
int xOrig = (chunkX << 4);
int zOrig = (chunkZ << 4);
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
long seed = world.getSeed();
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
chunkX,
chunkZ,
world.getMaxHeight(),
world.getMinHeight(),
carverHorizontalResolution,
carverVerticalResolution,
seed);
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
int paletteLevel = 0;
int cx = xOrig + x;
int cz = zOrig + z;
Biome biome = biomeProvider.getBiome(cx, 0, cz, seed);
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
int sea = paletteInfo.seaLevel();
Palette seaPalette = paletteInfo.ocean();
BlockState data;
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
if(sampler.sample(x, y, z) > 0) {
if(carver.sample(x, y, z) <= 0) {
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
seed);
chunk.setBlock(x, y, z, data);
}
paletteLevel++;
} else if(y <= sea) {
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
paletteLevel = 0;
} else {
paletteLevel = 0;
}
}
}
}
platform.getProfiler().pop("chunk_base_3d");
}
@Override
public BlockState getBlock(WorldProperties world, int x, int y, int z, BiomeProvider biomeProvider) {
Biome biome = biomeProvider.getBiome(x, z, world.getSeed());
Biome biome = biomeProvider.getBiome(x, y, z, world.getSeed());
Sampler3D sampler = samplerCache.get(x, z, world, biomeProvider);
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
@@ -129,7 +128,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
@Override
public Palette getPalette(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) {
return biomeProvider.getBiome(x, z, world.getSeed()).getContext().get(PaletteInfo.class).paletteHolder().getPalette(y);
return biomeProvider.getBiome(x, y, z, world.getSeed()).getContext().get(PaletteInfo.class).paletteHolder().getPalette(y);
}
public SamplerProvider samplerProvider() {
@@ -55,7 +55,7 @@ public class ChunkInterpolator {
for(int x = 0; x < 5; x++) {
for(int z = 0; z < 5; z++) {
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), 0, zOrigin + (z << 2), seed)
.getContext()
.get(BiomeNoiseProperties.class);
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
@@ -66,7 +66,7 @@ public class ChunkInterpolator {
for(int xi = -blend; xi <= blend; xi++) {
for(int zi = -blend; zi <= blend; zi++) {
genMap.computeIfAbsent(
provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step), seed)
provider.getBiome(xOrigin + (x << 2) + (xi * step), 0, zOrigin + (z << 2) + (zi * step), seed)
.getContext()
.get(BiomeNoiseProperties.class),
g -> new MutableInteger(0)).increment(); // Increment by 1
@@ -133,6 +133,10 @@ public class ChunkInterpolator {
}
public double getNoise(int x, int y, int z) {
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp((double) (x % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp(
(double) (x & 3) / 4, // x & 3 == x % 4
(double) (y & 3) / 4, // x & 3 == x % 4
(double) (z & 3) / 4 // x & 3 == x % 4
);
}
}
@@ -23,7 +23,7 @@ public class ElevationInterpolator {
// Precompute generators.
for(int x = -1 - smooth; x <= 16 + smooth; x++) {
for(int z = -1 - smooth; z <= 16 + smooth; z++) {
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getContext().get(
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, 0, zOrigin + z, seed).getContext().get(
BiomeNoiseProperties.class);
}
}
@@ -48,7 +48,7 @@ public class LazilyEvaluatedInterpolator {
NoiseSampler sampler = samplers[x][z];
if(sampler == null) {
sampler = biomeProvider.getBiome(xi, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
sampler = biomeProvider.getBiome(xi, y, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
samplers[x][z] = sampler;
}
@@ -8,6 +8,7 @@
package com.dfsek.terra.addons.chunkgenerator.palette;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -15,11 +16,19 @@ public class SlantHolder {
private final TreeMap<Double, PaletteHolder> layers;
private final double minSlope;
public SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
private SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
this.layers = layers;
this.minSlope = minSlope;
}
public static SlantHolder of(TreeMap<Double, PaletteHolder> layers, double minSlope) {
if(layers.size() == 1) {
Entry<Double, PaletteHolder> firstEntry = layers.firstEntry();
return new Single(firstEntry.getValue(), minSlope);
}
return new SlantHolder(layers, minSlope);
}
public boolean isEmpty() {
return layers.isEmpty();
}
@@ -31,4 +40,25 @@ public class SlantHolder {
public double getMinSlope() {
return minSlope;
}
private static final class Single extends SlantHolder {
private final PaletteHolder layers;
public Single(PaletteHolder layers, double minSlope) {
super(of(minSlope, layers), minSlope);
this.layers = layers;
}
private static TreeMap<Double, PaletteHolder> of(double v, PaletteHolder layer) {
TreeMap<Double, PaletteHolder> map = new TreeMap<>();
map.put(v, layer);
return map;
}
@Override
public PaletteHolder getPalette(double slope) {
return layers;
}
}
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.chunkgenerator.NoiseChunkGenerator3DAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d/issues
source: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
+2 -2
View File
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
+2 -2
View File
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -7,8 +7,6 @@
package com.dfsek.terra.addons.biome.holder;
import net.jafama.FastMath;
import java.util.Map;
import java.util.TreeMap;
@@ -25,11 +23,11 @@ public class PaletteHolderBuilder {
public PaletteHolder build() {
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
int min = Math.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
int max = Math.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
Palette[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) {
for(int y = min; y <= Math.max(paletteMap.lastKey(), max); y++) {
Palette d = null;
for(Map.Entry<Integer, Palette> e : paletteMap.entrySet()) {
if(e.getKey() >= y) {
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.biome.BiomeAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-biome/issues
source: https://github.com/PolyhedralDev/Terra-config-biome
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,12 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.feature.distributor.lib.jafama")
}
@@ -34,12 +34,12 @@ public class PaddedGridDistributor implements Distributor {
public boolean matches(int x, int z, long seed) {
int cellX = FastMath.floorDiv(x, cellWidth);
int cellZ = FastMath.floorDiv(z, cellWidth);
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
int pointX = random.nextInt(width) + cellX * cellWidth;
int pointZ = random.nextInt(width) + cellZ * cellWidth;
return x == pointX && z == pointZ;
}
}
@@ -6,10 +6,10 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.feature.distributor.DistributorAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-distributors/issues
source: https://github.com/PolyhedralDev/Terra-config-distributors
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
depends:
config-feature: "0.1.+"
generation-stage-feature: "0.1.+"
config-feature: "1.+"
generation-stage-feature: "1.+"
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -6,9 +6,9 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.feature.FeatureAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-feature/issues
source: https://github.com/PolyhedralDev/Terra-config-feature
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
depends:
generation-stage-feature: "0.1.+"
generation-stage-feature: "1.+"
+8 -2
View File
@@ -1,5 +1,11 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.flora.lib.jafama")
}
@@ -15,7 +15,6 @@ import java.util.List;
import java.util.Random;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.properties.base.Properties;
import com.dfsek.terra.api.block.state.properties.enums.Direction;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.structure.Structure;
@@ -90,12 +89,6 @@ public class TerraFlora implements Structure {
if(doRotation) {
Direction oneFace = new ArrayList<>(faces).get(
new Random(location.getX() ^ location.getZ()).nextInt(faces.size())); // Get random face.
data = data.setIfPresent(Properties.DIRECTION, oneFace.opposite())
.setIfPresent(Properties.NORTH, faces.contains(Direction.NORTH))
.setIfPresent(Properties.SOUTH, faces.contains(Direction.SOUTH))
.setIfPresent(Properties.EAST, faces.contains(Direction.EAST))
.setIfPresent(Properties.WEST, faces.contains(Direction.WEST));
}
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.flora.FloraAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-flora/issues
source: https://github.com/PolyhedralDev/Terra-config-flora
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,12 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.feature.locator.lib.jafama")
}
@@ -7,8 +7,6 @@
package com.dfsek.terra.addons.feature.locator.locators;
import net.jafama.FastMath;
import java.util.List;
import com.dfsek.terra.api.noise.NoiseSampler;
@@ -31,11 +29,24 @@ public class SamplerLocator implements Locator {
long seed = column.getWorld().getSeed();
samplers.forEach(sampler -> {
int y = FastMath.floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
int y = floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
if(y >= column.getMaxY() || y < column.getMinY()) return;
results.set(y);
});
return results.build();
}
private static int floorToInt(double value) {
int valueInt = (int)value;
if (value < 0.0) {
if (value == (double)valueInt) {
return valueInt;
} else {
return valueInt == Integer.MIN_VALUE ? valueInt : valueInt - 1;
}
} else {
return valueInt;
}
}
}
@@ -6,10 +6,10 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.feature.locator.LocatorAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-locators/issues
source: https://github.com/PolyhedralDev/Terra-config-locators
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
depends:
config-feature: "0.1.+"
generation-stage-feature: "0.1.+"
config-feature: "1.+"
generation-stage-feature: "1.+"
@@ -1,5 +1,16 @@
version = version("0.1.0")
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<ShadowJar>("shadowJar") {
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
relocate("net.jafama", "com.dfsek.terra.addons.noise.lib.jafama")
}
@@ -32,6 +32,7 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractal
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
@@ -90,6 +91,7 @@ public class NoiseAddon implements AddonInitializer {
noiseRegistry.register(addon.key("CLAMP"), ClampNormalizerTemplate::new);
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
@@ -121,7 +123,6 @@ public class NoiseAddon implements AddonInitializer {
noiseRegistry.register(addon.key("LINEAR_HEIGHTMAP"), LinearHeightmapSamplerTemplate::new);
noiseRegistry.register(addon.key("ADD"), () -> new BinaryArithmeticTemplate<>(AdditionSampler::new));
noiseRegistry.register(addon.key("SUB"), () -> new BinaryArithmeticTemplate<>(SubtractionSampler::new));
noiseRegistry.register(addon.key("MUL"), () -> new BinaryArithmeticTemplate<>(MultiplicationSampler::new));
@@ -13,6 +13,7 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import com.dfsek.terra.api.config.meta.Meta;
@@ -45,4 +46,17 @@ public class FunctionTemplate implements ObjectTemplate<FunctionTemplate> {
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
return functions;
}
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
FunctionTemplate that = (FunctionTemplate) o;
return args.equals(that.args) && function.equals(that.function) && functions.equals(that.functions);
}
@Override
public int hashCode() {
return Objects.hash(args, function, functions);
}
}
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addons.noise.config.templates.normalizer;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.terra.addons.noise.normalizer.PosterizationNormalizer;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.noise.NoiseSampler;
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
public class PosterizationNormalizerTemplate extends NormalizerTemplate<PosterizationNormalizer> {
@Value("steps")
private @Meta int steps;
@Override
public NoiseSampler get() {
return new PosterizationNormalizer(function, steps);
}
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addons.noise.normalizer;
import net.jafama.FastMath;
import com.dfsek.terra.api.noise.NoiseSampler;
public class PosterizationNormalizer extends Normalizer {
private final double stepSize;
public PosterizationNormalizer(NoiseSampler sampler, int steps) {
super(sampler);
this.stepSize = 2.0 / (steps - 1);
}
@Override
public double normalize(double in) {
return FastMath.roundToInt((in + 1) / stepSize) * stepSize - 1;
}
}
@@ -15,6 +15,8 @@ import com.dfsek.paralithic.functions.dynamic.Context;
import com.dfsek.paralithic.functions.dynamic.DynamicFunction;
import com.dfsek.paralithic.node.Statefulness;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
@@ -24,26 +26,33 @@ public class UserDefinedFunction implements DynamicFunction {
private final Expression expression;
private final int args;
private static final Map<FunctionTemplate, UserDefinedFunction> CACHE = new HashMap<>();
protected UserDefinedFunction(Expression expression, int args) {
this.expression = expression;
this.args = args;
}
public static UserDefinedFunction newInstance(FunctionTemplate template) throws ParseException {
Parser parser = new Parser();
Scope parent = new Scope();
Scope functionScope = new Scope().withParent(parent);
template.getArgs().forEach(functionScope::addInvocationVariable);
for(Entry<String, FunctionTemplate> entry : template.getFunctions().entrySet()) {
String id = entry.getKey();
FunctionTemplate nest = entry.getValue();
parser.registerFunction(id, newInstance(nest));
UserDefinedFunction function = CACHE.get(template);
if(function == null) {
Parser parser = new Parser();
Scope parent = new Scope();
Scope functionScope = new Scope().withParent(parent);
template.getArgs().forEach(functionScope::addInvocationVariable);
for(Entry<String, FunctionTemplate> entry : template.getFunctions().entrySet()) {
String id = entry.getKey();
FunctionTemplate nest = entry.getValue();
parser.registerFunction(id, newInstance(nest));
}
function = new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
CACHE.put(template, function);
}
return new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
return function;
}
@Override
@@ -22,6 +22,7 @@ public class GaborNoiseSampler extends NoiseFunction {
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
private double g = FastMath.exp(-impulsesPerCell);
private double omega0 = Math.PI * 0.25;
private boolean isotropic = true;
@@ -1,95 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addons.noise.util;
import java.io.Serial;
import java.io.Serializable;
public abstract class HashIntrinsic implements Serializable {
public static final int FLOAT_EXP_BIT_MASK = 2139095040;
public static final int FLOAT_SIGNIF_BIT_MASK = 8388607;
public static final long DOUBLE_EXP_BIT_MASK = 9218868437227405312L;
public static final long DOUBLE_SIGNIF_BIT_MASK = 4503599627370495L;
protected static final int DEFAULT_INITIAL_CAPACITY = 16;
protected static final int MAXIMUM_CAPACITY = 1073741824;
protected static final float DEFAULT_LOAD_FACTOR = 0.75F;
@Serial
private static final long serialVersionUID = 8058099372006904458L;
protected int size;
protected int threshold;
protected float loadFactor;
protected int capMinus1;
protected HashIntrinsic(int initialCapacity, float loadFactor) {
if(initialCapacity <= 0) {
throw new IllegalArgumentException("Illegal initial capacity: " + initialCapacity);
} else if(!(loadFactor <= 0.0F) && !Float.isNaN(loadFactor)) {
if(initialCapacity > 1073741824) {
initialCapacity = 1073741824;
}
int capacity;
for(capacity = 1; capacity < initialCapacity; capacity <<= 1) {
}
this.capMinus1 = capacity - 1;
this.loadFactor = loadFactor;
this.threshold = (int) ((float) capacity * loadFactor);
} else {
throw new IllegalArgumentException("Illegal load factor: " + loadFactor);
}
}
public static int floatToIntBits(float value) {
int result = Float.floatToRawIntBits(value);
if((result & 2139095040) == 2139095040 && (result & 8388607) != 0) {
result = 2143289344;
}
return result;
}
public static long doubleToLongBits(double value) {
long result = Double.doubleToRawLongBits(value);
if((result & 9218868437227405312L) == 9218868437227405312L && (result & 4503599627370495L) != 0L) {
result = 9221120237041090560L;
}
return result;
}
protected static int hashCodeLong(long value) {
return (int) (value ^ value >>> 32);
}
protected static int hashCodeFloat(float value) {
return floatToIntBits(value);
}
protected static int hashCodeDouble(double value) {
long bits = doubleToLongBits(value);
return (int) (bits ^ bits >>> 32);
}
protected static int tableIndex(int hc, int lm1) {
hc ^= hc >>> 20 ^ hc >>> 12;
hc ^= hc >>> 7 ^ hc >>> 4;
return hc & lm1;
}
public int size() {
return this.size;
}
public abstract void clear();
public boolean isEmpty() {
return this.size == 0;
}
}
@@ -1,272 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addons.noise.util;
import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class HashMapDoubleDouble extends HashIntrinsic {
@Serial
private static final long serialVersionUID = 2109458761298324234L;
private HashMapDoubleDouble.Entry[] table;
public HashMapDoubleDouble(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
this.table = this.createTable(this.capMinus1 + 1);
}
public HashMapDoubleDouble(int initialCapacity) {
this(initialCapacity, 0.75F);
}
public HashMapDoubleDouble() {
this(16, 0.75F);
}
public final boolean contains(double key) {
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
if(e.key == key) {
return true;
}
}
return false;
}
public boolean containsValue(double value) {
for(Entry entry : this.table) {
for(Entry e = entry; e != null; e = e.next) {
if(value == e.value) {
return true;
}
}
}
return false;
}
public double get(double key) {
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
if(key == e.key) {
return e.value;
}
}
return 4.9E-324D;
}
public double put(double key, double value) {
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
if(key == e.key) {
double oldValue = e.value;
e.value = value;
return oldValue;
}
}
this.addEntry(key, value, i);
return 4.9E-324D;
}
public void resize(int newCapacity) {
int oldCapacity = this.table.length;
if(oldCapacity == 1073741824) {
this.threshold = 2147483647;
} else {
HashMapDoubleDouble.Entry[] newTable = this.createTable(newCapacity);
this.capMinus1 = newCapacity - 1;
this.transfer(newTable);
this.table = newTable;
this.threshold = (int) ((float) newCapacity * this.loadFactor);
}
}
public final HashMapDoubleDouble.Entry remove(double key) {
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
HashMapDoubleDouble.Entry prev = this.table[i];
HashMapDoubleDouble.Entry e;
HashMapDoubleDouble.Entry next;
for(e = prev; e != null; e = next) {
next = e.next;
if(key == e.key) {
--this.size;
if(prev == e) {
this.table[i] = next;
} else {
prev.next = next;
}
return e;
}
prev = e;
}
return e;
}
public void clear() {
Arrays.fill(this.table, null);
this.size = 0;
}
public long memoryEstimate(int ptrsize) {
return (long) ptrsize * (long) (this.capMinus1 + this.size + 1) + (this.size * 64L / 4);
}
public HashMapDoubleDouble.Iterator iterator() {
return new HashMapDoubleDouble.Iterator();
}
private void addEntry(double key, double value, int index) {
HashMapDoubleDouble.Entry e = this.table[index];
this.table[index] = new HashMapDoubleDouble.Entry(key, value, e);
if(this.size++ >= this.threshold) {
this.resize(2 * this.table.length);
}
}
private void transfer(HashMapDoubleDouble.Entry[] newTable) {
for(int j = 0; j < this.table.length; ++j) {
HashMapDoubleDouble.Entry e = this.table[j];
if(e != null) {
this.table[j] = null;
HashMapDoubleDouble.Entry next;
do {
next = e.next;
int i = tableIndex(hashCodeDouble(e.key), this.capMinus1);
e.next = newTable[i];
newTable[i] = e;
e = next;
} while(next != null);
}
}
}
private HashMapDoubleDouble.Entry[] createTable(int capacity) {
return new HashMapDoubleDouble.Entry[capacity];
}
public HashMapDoubleDouble.Entry getEntry(double key) {
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
if(key == e.key) {
return e;
}
}
return null;
}
public static class Entry implements Serializable {
@Serial
private static final long serialVersionUID = 7972173983741231238L;
private final double key;
private double value;
private HashMapDoubleDouble.Entry next;
public Entry(double key, double val, HashMapDoubleDouble.Entry n) {
this.key = key;
this.value = val;
this.next = n;
}
public final double setValue(double newValue) {
double oldValue = this.value;
this.value = newValue;
return oldValue;
}
public final double getKey() {
return this.key;
}
public final double getValue() {
return this.value;
}
public final int hashCode() {
return hashCodeDouble(key) + hashCodeDouble(value);
}
public final boolean equals(Object o) {
HashMapDoubleDouble.Entry e = (HashMapDoubleDouble.Entry) o;
return this.key == e.key && this.value == e.value;
}
public final String toString() {
return this.key + " = " + this.value;
}
}
public class Iterator {
HashMapDoubleDouble.Entry next;
int index;
HashMapDoubleDouble.Entry current;
Iterator() {
if(HashMapDoubleDouble.this.size > 0) {
while(this.index < HashMapDoubleDouble.this.table.length &&
(this.next = HashMapDoubleDouble.this.table[this.index++]) == null) {
}
}
}
public HashMapDoubleDouble.Entry nextEntry() {
HashMapDoubleDouble.Entry e = this.next;
if(e == null) {
throw new NoSuchElementException();
} else {
if((this.next = e.next) == null) {
while(this.index < HashMapDoubleDouble.this.table.length &&
(this.next = HashMapDoubleDouble.this.table[this.index++]) == null) {
}
}
this.current = e;
return e;
}
}
public double next() {
return this.nextEntry().value;
}
public void remove() {
if(this.current == null) {
throw new IllegalStateException();
} else {
double k = this.current.key;
this.current = null;
HashMapDoubleDouble.this.remove(k);
}
}
public final boolean hasNext() {
return this.next != null;
}
}
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.noise.NoiseAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-noise-function/issues
source: https://github.com/PolyhedralDev/Terra-config-noise-function
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
+8 -2
View File
@@ -1,5 +1,11 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.ore.lib.jafama")
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.ore.OreAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-ore/issues
source: https://github.com/PolyhedralDev/Terra-config-ore
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.palette.PaletteAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-palette/issues
source: https://github.com/PolyhedralDev/Terra-config-palette
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,6 +1,13 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi("com.googlecode.json-simple:json-simple:1.1.1")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("com.googlecode.json-simple:json-simple:1.1.1")
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.structure.lib.jafama")
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.structure.StructureAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-config-structure/issues
source: https://github.com/PolyhedralDev/Terra-config-structure
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -12,7 +12,6 @@ import java.util.Random;
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.profiler.ProfileFrame;
import com.dfsek.terra.api.registry.key.StringIdentifiable;
import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int;
@@ -27,49 +26,52 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
private final String id;
private final String profile;
public FeatureGenerationStage(Platform platform, String id) {
this.platform = platform;
this.id = id;
this.profile = "feature_stage:" + id;
}
@Override
@SuppressWarnings("try")
public void populate(ProtoWorld world) {
try(ProfileFrame ignore = platform.getProfiler().profile("feature_stage:" + id)) {
int cx = world.centerChunkX() << 4;
int cz = world.centerChunkZ() << 4;
long seed = world.getSeed();
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
int tx = cx + x;
int tz = cz + z;
Column<WritableWorld> column = world.column(tx, tz);
long coordinateSeed = (seed * 31 + tx) * 31 + tz;
world.getBiomeProvider()
.getBiome(tx, tz, seed)
.getContext()
.get(BiomeFeatures.class)
.getFeatures()
.getOrDefault(this, Collections.emptyList())
.forEach(feature -> {
try(ProfileFrame ignored = platform.getProfiler().profile(feature.getID())) {
if(feature.getDistributor().matches(tx, tz, seed)) {
feature.getLocator()
.getSuitableCoordinates(column)
.forEach(y ->
feature.getStructure(world, tx, y, tz)
.generate(Vector3Int.of(tx, y, tz),
world,
new Random(coordinateSeed * 31 + y),
Rotation.NONE)
);
}
}
});
}
platform.getProfiler().push(profile);
int cx = world.centerChunkX() << 4;
int cz = world.centerChunkZ() << 4;
long seed = world.getSeed();
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
int tx = cx + x;
int tz = cz + z;
Column<WritableWorld> column = world.column(tx, tz);
long coordinateSeed = (seed * 31 + tx) * 31 + tz;
world.getBiomeProvider()
.getBiome(tx, 0, tz, seed)
.getContext()
.get(BiomeFeatures.class)
.getFeatures()
.getOrDefault(this, Collections.emptyList())
.forEach(feature -> {
platform.getProfiler().push(feature.getID());
if(feature.getDistributor().matches(tx, tz, seed)) {
feature.getLocator()
.getSuitableCoordinates(column)
.forEach(y ->
feature.getStructure(world, tx, y, tz)
.generate(Vector3Int.of(tx, y, tz),
world,
new Random(coordinateSeed * 31 + y),
Rotation.NONE)
);
}
platform.getProfiler().pop(feature.getID());
});
}
}
platform.getProfiler().pop(profile);
}
@Override
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.generation.feature.FeatureGenerationAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-generation-stage-feature/issues
source: https://github.com/PolyhedralDev/Terra-generation-stage-feature
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.generation.structure.StructureGenerationAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-generation-stage-structure/issues
source: https://github.com/PolyhedralDev/Terra-generation-stage-structure
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
+3 -3
View File
@@ -1,6 +1,6 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
shadedApi(project(":common:addons:manifest-addon-loader"))
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.yaml.YamlAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-language-yaml/issues
source: https://github.com/PolyhedralDev/Terra-language-yaml
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,8 +1,8 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
api("commons-io:commons-io:2.7")
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
}
tasks.withType<Jar> {
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -38,6 +37,7 @@ import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionRangeLoader;
import com.dfsek.terra.addons.manifest.impl.exception.AddonException;
import com.dfsek.terra.addons.manifest.impl.exception.ManifestException;
import com.dfsek.terra.addons.manifest.impl.exception.ManifestNotPresentException;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
@@ -72,13 +72,9 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
throw new AddonException("Addon " + manifest.getID() + " has unknown schema version: " + manifest.getSchemaVersion());
}
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed", "resource" })
ManifestAddonClassLoader childLoader = new ManifestAddonClassLoader(new URL[]{ addonPath.toUri().toURL() },
loader);
List<AddonInitializer> initializers = manifest.getEntryPoints().stream().map(entryPoint -> {
try {
Object in = childLoader.loadClass(entryPoint).getConstructor().newInstance();
Object in = loader.loadClass(entryPoint).getConstructor().newInstance();
if(!(in instanceof AddonInitializer)) {
throw new AddonException(in.getClass() + " does not extend " + AddonInitializer.class);
}
@@ -103,7 +99,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
}
@Override
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
logger.debug("Loading addons...");
try(Stream<Path> files = Files.walk(addonsFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
@@ -114,16 +110,16 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
.filter(path -> path.toString().endsWith(".jar"))
.toList();
ManifestAddonClassLoader loader = new ManifestAddonClassLoader(addons.stream().map(path -> {
addons.stream().map(path -> {
try {
return path.toUri().toURL();
} catch(MalformedURLException e) {
throw new UncheckedIOException(e);
}
}).toArray(URL[]::new), getClass().getClassLoader());
}).forEach(parent::addURL);
return addons.stream()
.map(jar -> loadAddon(jar, loader))
.map(jar -> loadAddon(jar, parent))
.collect(Collectors.toList());
} catch(IOException e) {
throw new UncheckedIOException(e);
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
version = version("1.0.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -8,5 +8,5 @@ entrypoints:
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
@@ -7,5 +7,5 @@ entrypoints: [ ]
website:
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://github.com/PolyhedralDev/Terra/wiki
docs: https://terra.polydev.org
license: MIT License
@@ -1,25 +1,17 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("0.1.0")
plugins {
id("com.github.johnrengelman.shadow")
}
version = version("1.0.0")
repositories {
maven { url = uri("https://jitpack.io/") }
}
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedApi("com.github.Querz:NBT:6.1")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("commons-io:commons-io:2.7")
api("com.github.Querz:NBT:6.1")
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}
@@ -6,7 +6,7 @@ version: @VERSION@
entrypoints:
- "com.dfsek.terra.addons.sponge.SpongeSchematicAddon"
website:
issues: https://github.com/PolyhedralDev/Terra-structure-sponge-loader/issues
source: https://github.com/PolyhedralDev/Terra-structure-sponge-loader
docs: https://github.com/PolyhedralDev/Terra/wiki
license: GNU LGPL v3.0
issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org
license: MIT License
@@ -1,21 +1,15 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("0.1.0")
plugins {
id("com.github.johnrengelman.shadow")
}
version = version("1.0.1")
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("commons-io:commons-io:2.7")
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
relocate("net.jafama", "com.dfsek.terra.addons.terrascript.lib.jafama")
}
@@ -12,7 +12,7 @@ public class Scope {
public Variable<?> get(String id) {
throw new IllegalStateException("Cannot get variable from null scope: " + id);
}
@Override
public void put(String id, Variable<?> variable) {
throw new IllegalStateException("Cannot set variable in null scope: " + id);
@@ -38,7 +38,7 @@ public class Scope {
public void put(String id, Variable<?> variable) {
variableMap.put(id, variable);
}
public Scope sub() {
return new Scope(this);
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
@@ -24,11 +26,11 @@ public abstract class BinaryOperation<I, O> implements Returnable<O> {
this.start = start;
}
public abstract O apply(I left, I right);
public abstract O apply(Supplier<I> left, Supplier<I> right);
@Override
public O apply(ImplementationArguments implementationArguments, Scope scope) {
return apply(left.apply(implementationArguments, scope), right.apply(implementationArguments, scope));
return apply(() -> left.apply(implementationArguments, scope), () -> right.apply(implementationArguments, scope));
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class BooleanAndOperation extends BinaryOperation<Boolean, Boolean> {
}
@Override
public Boolean apply(Boolean left, Boolean right) {
return left && right;
public Boolean apply(Supplier<Boolean> left, Supplier<Boolean> right) {
return left.get() && right.get();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class BooleanOrOperation extends BinaryOperation<Boolean, Boolean> {
}
@Override
public Boolean apply(Boolean left, Boolean right) {
return left || right;
public Boolean apply(Supplier<Boolean> left, Supplier<Boolean> right) {
return left.get() || right.get();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class ConcatenationOperation extends BinaryOperation<Object, Object> {
}
@Override
public String apply(Object left, Object right) {
return left.toString() + right.toString();
public String apply(Supplier<Object> left, Supplier<Object> right) {
return left.get().toString() + right.get().toString();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class DivisionOperation extends BinaryOperation<Number, Number> {
}
@Override
public Number apply(Number left, Number right) {
return left.doubleValue() / right.doubleValue();
public Number apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() / right.get().doubleValue();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class ModuloOperation extends BinaryOperation<Number, Number> {
}
@Override
public Number apply(Number left, Number right) {
return left.doubleValue() % right.doubleValue();
public Number apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() % right.get().doubleValue();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class MultiplicationOperation extends BinaryOperation<Number, Number> {
}
@Override
public Number apply(Number left, Number right) {
return left.doubleValue() * right.doubleValue();
public Number apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() * right.get().doubleValue();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class NumberAdditionOperation extends BinaryOperation<Number, Number> {
}
@Override
public Number apply(Number left, Number right) {
return left.doubleValue() + right.doubleValue();
public Number apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() + right.get().doubleValue();
}
@Override
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -17,8 +19,8 @@ public class SubtractionOperation extends BinaryOperation<Number, Number> {
}
@Override
public Number apply(Number left, Number right) {
return left.doubleValue() - right.doubleValue();
public Number apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() - right.get().doubleValue();
}
@Override
@@ -9,25 +9,30 @@ package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import net.jafama.FastMath;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import static com.dfsek.terra.api.util.MathUtil.EPSILON;
public class EqualsStatement extends BinaryOperation<Object, Boolean> {
private static final double EPSILON = 0.000000001D;
public EqualsStatement(Returnable<Object> left, Returnable<Object> right, Position position) {
super(left, right, position);
}
@Override
public Boolean apply(Object left, Object right) {
if(left instanceof Number && right instanceof Number) {
return FastMath.abs(((Number) left).doubleValue() - ((Number) right).doubleValue()) <= EPSILON;
public Boolean apply(Supplier<Object> left, Supplier<Object> right) {
Object leftUnwrapped = left.get();
Object rightUnwrapped = right.get();
if(leftUnwrapped instanceof Number l && rightUnwrapped instanceof Number r) {
return FastMath.abs(l.doubleValue() - r.doubleValue()) <= EPSILON;
}
return left.equals(right);
return leftUnwrapped.equals(rightUnwrapped);
}
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -18,8 +20,8 @@ public class GreaterOrEqualsThanStatement extends BinaryOperation<Number, Boolea
}
@Override
public Boolean apply(Number left, Number right) {
return left.doubleValue() >= right.doubleValue();
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() >= right.get().doubleValue();
}
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
@@ -18,8 +20,8 @@ public class GreaterThanStatement extends BinaryOperation<Number, Boolean> {
}
@Override
public Boolean apply(Number left, Number right) {
return left.doubleValue() > right.doubleValue();
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
return left.get().doubleValue() > right.get().doubleValue();
}

Some files were not shown because too many files have changed in this diff Show More