Compare commits

..

47 Commits

Author SHA1 Message Date
dfsek e0d7b03820 fix funny ProbabilityCollection bug 2021-06-14 19:45:41 -07:00
dfsek 68aa38a51a fix ProbabilityCollection#getProbability 2021-06-14 19:39:04 -07:00
dfsek beb07337ae fix NPE 2021-06-14 19:20:00 -07:00
dfsek 2010c48664 mutator meta 2021-06-14 19:15:52 -07:00
dfsek 7473119238 improve ProbabilityCollection#map impl 2021-06-14 19:13:16 -07:00
dfsek 733b9fab4b biome source meta-fication 2021-06-14 18:06:22 -07:00
dfsek 64cf6538cb meta-ify remaining biome stuff 2021-06-14 17:59:48 -07:00
dfsek 9c86d015f0 meta-ify BiomePipelineTemplate 2021-06-14 17:55:47 -07:00
dfsek 008084fae9 TreeLayerLoader -> TreeLayerTemplate 2021-06-14 14:21:42 -07:00
dfsek 139f67af52 oreconfigloader -> OreConfigTemplate 2021-06-14 14:15:21 -07:00
dfsek 2020ef31e4 convert GridSpawnLoader to object template 2021-06-14 14:00:33 -07:00
dfsek c6636a72da convert FloraLayerLoader to object template 2021-06-14 13:58:15 -07:00
dfsek 97b3042357 meta noise type 2021-06-14 13:53:03 -07:00
dfsek 3aaedcf74f normalizer meta 2021-06-14 13:33:57 -07:00
dfsek f0655d1bb9 noise meta 2021-06-14 13:32:28 -07:00
dfsek bdce485ca5 refactor metavalues 2021-06-14 13:19:49 -07:00
dfsek 78991c667c noise function metavalues 2021-06-14 01:44:19 -07:00
dfsek df45aecdab fractal noise meta 2021-06-14 01:35:17 -07:00
dfsek 571a5fdf3a meta values in config manifest 2021-06-14 01:33:06 -07:00
dfsek 1610d4e0c9 finish implementing GenericMetaValueLoader 2021-06-14 01:00:37 -07:00
dfsek 1e43365bbf implement PackMetaContext 2021-06-14 00:54:26 -07:00
dfsek 587cb8755f work on metavalue loading 2021-06-12 02:23:34 -07:00
dfsek f90f7bd063 more metaconfig API 2021-06-10 00:16:14 -07:00
dfsek d95239a5dd start working on meta loaders 2021-06-08 23:50:03 -07:00
dfsek 91703c4fc9 rudimentary metaconfig API 2021-06-08 23:20:47 -07:00
dfsek 1b05ca8e96 source compatibility still java 8
We aren't sure what to do with Java versions yet, so I'm setting
source compatibility to Java 8 until we figure it out.
2021-06-08 15:28:03 -07:00
dfsek 33288c057c Merge pull request #210 from PolyhedralDev/fabric/1.17-dev
1.17 implementation
2021-06-08 10:21:08 -07:00
dfsek 6027c282ab 1.17 full release 2021-06-08 10:17:39 -07:00
dfsek 0068f69982 move chunkified populators to earlier generation stage 2021-06-07 21:54:01 -07:00
dfsek 9df379644b DeformedSphereOre height corrections 2021-06-07 21:13:04 -07:00
dfsek 492939b5d1 correct max_y = 255 assumption 2021-06-07 20:30:46 -07:00
dfsek 20d45a4b1e 1.17 pre-2 2021-06-07 14:33:54 -07:00
dfsek db70b6c88c correct args of zero arg function 2021-06-07 01:07:53 -07:00
dfsek 1cee01a36c material override ore config options 2021-06-05 16:06:10 -07:00
dfsek a9c252f91c 1.17 rc1 2021-06-05 00:58:05 -07:00
dfsek 86ad5b5041 1.17 pre3 2021-06-01 23:25:39 -07:00
solo c1c2ab6df8 General repository maintenance. (#94)
* Fixes #93

Add pull request and issue templates.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Add CODEOWNERS file

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Fix yaml issues

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

fix yaml??

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

Fix name of issue template.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Testing if I can do this with prs too

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

Can I do this with pr templates too??

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

Can I do this with pr templates too??

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

Can I do this with pr templates too??

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Move PULL_REQUEST_TEMPLATE/PULL_REQUEST.md to PULL_REQUEST_TEMPLATE.md, because github :poob:

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* I don't think I can... oof.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Oops, forgot to add this link.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Perform requested changes

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Forgot one

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Server software -> Platform & Merge platform + platform version

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Inclusion of "addon" in language

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* compat with other terrain gen mods

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* inclusion of "addon" in FEATURE_REQUEST.md

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Update CODEOWNERS

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* add discord link to config.yml

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* update PULL_REQUEST_TEMPLATE.md to no longer use "plugin"

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Reintroduce stacktrace section

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* be more specific about compat issues

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* modify CODEOWNERS

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Add CODE_OF_CONDUCT.md

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Repo: add CONTRIBUTING.md file

Add CONTRIBUTING.md file with some basic guidelines on how to get started contributing.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Repo: Update git commit types

Update git commit types in CONTRIBUTING.md and sort them.

Add new entries under "types of changes" for PULL_REQUEST_TEMPLATE.md.

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>

* Repo: Performed requested changes

forgot some stuff lol

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
2021-05-31 17:57:55 -07:00
dfsek 7061328cc7 1.17 pre2 2021-05-31 12:16:59 -07:00
dfsek 3f56da3a65 correct mixin compatibility level 2021-05-28 15:19:55 -07:00
dfsek 16fcf09c78 gradle 7 (temporarily remove Forge module) 2021-05-28 15:10:30 -07:00
dfsek cba3388cb1 resolve merge conflicts 2021-05-28 14:50:24 -07:00
dfsek 94611913c3 Merge remote-tracking branch 'origin/master' into fabric/1.17-dev
# Conflicts:
#	platforms/fabric/build.gradle.kts
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/block/state/FabricBlockState.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/block/state/FabricMobSpawner.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/block/state/FabricSign.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/features/PopulatorFeature.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/handles/FabricWorld.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/handles/chunk/FabricChunk.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/handles/world/FabricSeededWorldAccess.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/handles/world/FabricWorldAccess.java
#	platforms/fabric/src/main/java/com/dfsek/terra/fabric/world/handles/world/FabricWorldHandle.java
#	platforms/fabric/src/main/resources/fabric.mod.json
#	platforms/fabric/src/main/resources/terra.accesswidener
#	platforms/fabric/src/main/resources/terra.mixins.json
2021-05-28 13:50:59 -07:00
dfsek 709180de13 multithread structure and cave population 2021-03-21 22:25:19 -07:00
dfsek 5182651947 multithreaded chunk gen 2021-03-18 17:31:36 -07:00
dfsek 7f33fb20ed remove other assumptions that world bottom is y=0 2021-03-17 21:50:59 -07:00
dfsek c9f49fb06f fix palettes below y=0 2021-03-17 21:22:04 -07:00
dfsek d065f78c0a mostly working 1.17-ification 2021-03-17 21:17:15 -07:00
121 changed files with 1905 additions and 732 deletions
+19
View File
@@ -0,0 +1,19 @@
# Global owners, automatically request review when pull request is submitted
* @dfsek @solonovamax
# Platforms
## dfsek wrote the majority of the platform impls
/platforms/bukkit/ @dfsek
/platforms/fabric/ @dfsek
/platforms/forge/ @dfsek
/platforms/sponge/ @dfsek
## solonovamax is working on the region generator (unless duplexsystem takes it over)
/platforms/region/ @solonovamax
# Common
/common/ @dfsek @solonovamax
# Gradle Stuff
## Most gradle stuff was written by solonovamax
/buildSrc/ @solonovamax
*.gradle.kts @solonovamax
+105
View File
@@ -0,0 +1,105 @@
---
name: "Bug Report"
about: "Open a bug report to help us identify issues with Terra."
title: "[Bug] <Put your title here>"
labels: "Type: Bug, Status: Pending"
assignees: ""
---
<!--
##############################################################################
## WARNING! ##
## IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN YOUR ISSUE BEING CLOSED ##
##############################################################################
-->
## Pre-Issue Checklist
<!--
Please go through this checklist item by item and make sure you have successfully completed each of these steps.
- 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 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.
- Make sure that this is not an issue with a specific Terra *pack* or Terra *addon*, and instead applies to all of Terra.
- Make sure that you attach a copy of the latest.log file.
Putting *just* the exception IS NOT ENOUGH. We need to be able to check that there wasn't anything else before that caused it.
- Make sure that you have filled out all the required information and given descriptions of everything.
You must put an x in all the boxes you have completed. (Like this: [x])
To make sure that your issue is rendered properly, you may check the "Preview" tab (below the title) to see a rendered version of it before you submit it.
-->
- [ ] I have checked that I am on the latest version of Terra.
- [ ] I have searched the github issue tracker for similar issues, including closed ones.
- [ ] I have made sure that this is not a bug with another mod or plugin, and it is Terra that is causing the issue.
- [ ] I have checked that this is an issue with Terra and not an issue with the pack I am using.
<!-- If this is an issue with the default Terra pack, please open an issue on the pack repo: https://github.com/PolyhedralDev/TerraDefaultConfig/issues/new -->
- [ ] I have attached a copy of the `latest.log` file
- [ ] I have filled out and provided all the appropriate information.
## Environment
<!-- You can fill out the different items by putting the correct value beside each cell. -->
| Name | Value |
|------------------------------|-------|
| Terra Version | <!-- Put your Terra version here. (remove the comment) -->
| Platform / Platform Version | <!-- Put your platform and platform version here. (remove the comment) (eg. Spigot, Fabric, Paper, etc.) (If you are using the Region generator, put that here instead) -->
| Any External Plugins or Mods | <!-- Put a list of all the plugins or mods you have installed here. (remove the comment) (Make sure to NOT include any new lines) -->
| Terra Packs In Use | <!-- Put a list of all the Terra packs you have installed here. (remove the comment) (Make sure to NOT include any new lines) (/te packs may be used to get a list) -->
| Terra Addons In Use | <!-- Put a list of all the Terra addons you have installed here. (remove the comment) (Make sure to NOT include any new lines) (/te addons may be used to get a list) -->
## Issue Description
<!--
Put a quick description of the issue here.
Example: 'When generating terrain, something causes the chunks to not load properly', etc.
-->
### Steps to reproduce
<!--
Describe what you were doing when this happened.
Make sure to include ALL information. Including anything you were doing before that may have caused it.
-->
1. <!-- Put step #1 here. -->
2. <!-- Put step #2 here. -->
3. <!-- etc. -->
### Expected behavior
<!-- Describe what you think *should* happen here: -->
### Actual behavior
<!-- Describe what *actually* happens here: -->
<!-- example: When I do _______, it actually does _______ -->
### Full stacktrace
<details>
<summary>Exception Stacktrace</summary>
<!--
If Terra logs an exception, please put it in the following section: (You will find any error logs in your console, or your latest.log)
Note: this *must* be included, in ADDITION to the latest.log file.
-->
```
```
</details>
### Additional details
<!-- Any other information you think should be added -->
+70
View File
@@ -0,0 +1,70 @@
---
name: "Feature Request"
about: "Give us suggestions of features we could add to Terra."
title: "[Feature] <Put your title here>"
labels: "Type: Enhancement, Status: Pending"
assignees: ""
---
<!--
########################################################################################
## WARNING! ##
## IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN YOUR FEATURE REQUEST BEING CLOSED ##
########################################################################################
-->
### Pre-Request Checklist
<!--
Please go through this checklist item by item and make sure you have successfully completed each of these steps.
- You must be on the LATEST version of Terra to make sure your feature hasn't been added yet.
- Make sure that there are no already existing feature requests similar to yours. (Including closed!) If you open a duplicate, it will be closed as such.
- Make sure that this is actually in the scope of Terra.
- Make sure that this is not a feature request that should be made for a specific Terra *pack*, and instead applies to all of Terra.
- Make sure that you attach a copy of the latest.log file, if there are any exceptions thrown in the console.
Putting *just* the exception IS NOT ENOUGH. We need to be able to check that there wasn't anything else before that caused it.
You must put an x in all the boxes you have completed. (Like this: [x])
To make sure that your issue is rendered properly, you may check the "Preview" tab (below the title) to see a rendered version of it before you submit it.
-->
- [ ] I have checked that I am on the latest version of Terra.
- [ ] I have searched github for similar features requests, including closed ones, and found none.
- [ ] I believe this is within the scope of Terra.
- [ ] This feature request is for *all* of Terra, and isn't something that should be implemented by a pack or addon.
## Feature Description
<!--
Quickly describe the basics of your feature request.
Example: 'More noise presets should be added to Terra.'
-->
### What Problem Does This Solve?
<!--
Describe here what the issue is that you have.
Examples: 'When I do _______, it annoys me that _______ does _______.' or 'There is not enough customization in _______ to do _______.'
NOTE: This should NOT be used for a bug report. If this is unintentional, then please submit a bug report instead.
-->
### A Solution You'd Like
<!-- Provide a clear and accurate description of how you would like this to be solved. -->
### Alternative Solutions
<!-- Provide a description of alternatives you have considered to this. -->
1. <!-- Alternative #1. -->
2. <!-- Alternative #2. -->
3. <!-- Alternative #3. -->
### Additonal Context
<!--
Is there any additional context you would like to add?
If not, you may remove this section.
-->
+11
View File
@@ -0,0 +1,11 @@
---
name: "Other Issue"
about: "Use this template if your issue doesn't accurately fit into any of the other categories."
title: ""
labels: "Type: Question, Status: Pending"
assignees: ""
---
## Describe the issue
<!-- Please describe the issue as clearly and as concisely as possible, without missing any details. -->
+11
View File
@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Which Issue Template do I Choose?
url: https://github.com/PolyhedralDev/Terra/wiki/How-To-Choose-An-Issue-Template
about: Click this if you don't know which issue template to select. This will help you make sure you choose the right one and provide enough information for us to help you.
- name: Terra Wiki
url: https://github.com/PolyhedralDev/Terra/wiki
about: Documentation for all things Terra.
- name: Join the Support Discord
url: https://discord.dfsek.com
about: If you have a basic support question, join the Discord instead.
+114
View File
@@ -0,0 +1,114 @@
# Pull Request
## Brief description.
<!-- Please provide a brief description of the goals of your PR -->
<!--
###########################################################################
## WARNING! ##
## IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN YOUR PR BEING CLOSED ##
###########################################################################
-->
<!--
Please go through this checklist item by item and make sure you have successfully completed each of these steps.
- Your pull request MUST be either on the latest version of Terra, or on a branch for a future release.
- Make sure that there are no already existing PRs that fix this. If so, it will be closed as a duplicate.
- Make sure that this change is actually within the scope of Terra and is something a terrain generator should be doing.
- Make sure that this is not an issue with a specific Terra *pack*, and instead applies to all of Terra.
- Make sure that you have filled out all the required information and given descriptions of everything.
-->
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### What Issues Does This Fix?
<!--
Put Fix #XXXX or Closes #XXXX here if there are any open issues that this PR fixes.
This is to automatically close the relevant issues.
You may remove this if there is no issue for this PR.
But unless this is a very small change, you should make an issue for it.
-->
## Licensing
<!-- In order to be accepted, your changes must be under the GPLv3 license. Please check one of the following: -->
- [ ] I am the original author of this code, and I am willing to release it under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
- [ ] I am not the original author of this code, but it is in public domain or released
under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or a compatible license.
<!--
Please provide reliable evidence of this.
NOTE: for compatible licenses, you must make sure to add the included license somewhere in the program, if so required.
(And even if it's not required, it's still nice to do it. Also add attribution somewhere.)
-->
## Goal of the PR
<!--
What is the goal of the PR?
Put a checklist here of what has been done
(and what *hasn't*, but you plan to do),
so we can easily know what was changed.
Note: this is only required for PRs that add new features.
If your PR is not adding new features, only fixing bugs or adding translations, then you may delete this section.
-->
- [ ] <!-- First thing -->
- [ ] <!-- A requirement of the first thing. -->
- [ ] <!-- A second requirement of the first thing. -->
- [ ] <!-- Second thing -->
- [ ] <!-- etc. -->
## Affects of the PR
<!---
What types of changes does your code introduce? (Select any that apply. You may select multiple.)
You must put an x in all the boxes that it applies to. (Like this: [x])
-->
#### Types of changes
- [ ] 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. -->
- [ ] 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. -->
- [ ] 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. -->
#### Compatiblity
- [ ] Breaking change <!-- A fix, or a feature, that breaks some previous functionality to Terra. -->
- [ ] Non-Breaking change.
<!--
A change which does not break *any* previous functionality of Terra.
(ie. is backwards compatible and will work with *any* previously existing supported features.
Note: if a feature is annotated with @Incubating, @Preview, @Experimental,
or is in a package called something similar to the previous annotations,
then you may push breaking changes to only THOSE parts of Terra.)
-->
#### Contribution Guidelines.
- [ ] I have read the [`CONTRIBUTING.md`](https://github.com/PolyhedralDev/Terra/blob/master/CONTRIBUTING.md) document in the root of the
git repository.
- [ ] My code follows the code style for this
project. <!-- There is an included `.editorconfig` file in the base of the repo. Please use a plugin for your IDE of choice that follows those settings. -->
#### Documentation
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
#### Testing
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
<!--
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.
-->
+11 -14
View File
@@ -85,14 +85,14 @@ hs_err_pid*
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/**.iml
.idea/modules
*.iml
*.ipr
# CMake
cmake-build-*/
@@ -137,10 +137,7 @@ build
.idea/modules/**.iml
!lib/*.jar
.idea/Terra.iml
/run/
.idea/**.iml
/lang/
/packs/
/config.yml
/region/
idea/**
testDir/
+337
View File
@@ -0,0 +1,337 @@
# Terra Community Code of Conduct
# TL;DR
Polyhedral Development is dedicated to providing a harassment-free experience for everyone, regardless of gender, gender identity and
expression, preferred pronouns, sexual orientation, disability, physical appearance, age, race, religion, etc. We do not tolerate harassment
of participants in any form.
This code of conduct applies to all Terra community spaces, including the github discussions tab, our
[community discord server](https://discord.gg/PXUEbbF), the [community subreddit](https://reddit.com/r/TerraGenerator), or any other Terra
space, both online and off. Anyone in violation of this code, as determined by the applicable moderators, may be subject to verbal warning,
expulsion from these spaces, or future events and activities for an undetermined amount of time.
Some Terra community spaces may have additional rules in place, which will be made clearly available to all participants. Participants are
responsible for knowing and abiding by these rules.
# Longer version
Polyhedral Development is dedicated to providing a harassment-free experience for everyone. We do not tolerate harassment of participants in
any form.
## When and How to Use These Guidelines
This code of conduct applies to all Terra community spaces, both online and off. This applies to the github discussion tab,
the [Polyhedral Development community discord server](https://discord.gg/PXUEbbF), and any other Terra community. In addition, we may choose
to invoke them in instances of harassment outside the Terra communities, and we will punish the responsible individuals appropriately. We
will not tolerate harassment in any form, even outside of Terra.
Some Terra spaces may have additional rules in place, which will be made clearly available to participants. Participants are responsible for
knowing and abiding by these rules, in addition to this code of conduct.
## Expected Behavior
The following behaviors are expected of all members of the Terra community:
### Be Respectful
Value each other's ideas, styles and viewpoints. We may not always agree, but disagreement is no excuse for poor manners. Be open to
different possibilities and to being wrong. Be respectful in all interactions and communications, especially when debating the merits of
different options. Be aware of your impact and how intense interactions may be affecting people. Be direct, constructive and positive. Take
responsibility for your impact, and your mistakes if someone says they have been harmed through your words or actions, listen carefully,
apologize sincerely, and correct the behavior going forward.
#### Be Prepared to Admit When You are Wrong
Any member of the Terra community should always be open to new ideas and must always be open to the possibility of being wrong. Nobody can
always be right, and we are only human; we are [fallible](https://www.merriam-webster.com/dictionary/fallible) by nature. It is okay to make
mistakes, but we must be willing to admit when we make one.
### Be Direct but Professional
We are likely to have some discussions about if and when criticism is respectful and when it's not. We must be able to speak directly when
we disagree and when we think we need to improve. We cannot withhold hard truths. Doing so respectfully is hard, doing so when others don't
seem to be listening is harder, and hearing such comments when one is the recipient can be even harder still. We need to be honest and
direct, as well as respectful.
### Be Inclusive
Seek diverse perspectives. Diversity of views and of people on teams powers innovation, even if it is not always comfortable. Encourage all
voices. Help new perspectives be heard and listen actively. If you find yourself dominating a discussion, it is especially important to step
back and encourage other voices to join in. Be aware of how much time is taken up by dominant members of the group. Provide alternative ways
to contribute or participate when possible.
Be inclusive of everyone in an interaction, respecting and facilitating people's participation whether they are:
- Not native language speakers
- Coming from a different culture
- Using pronouns other than "he", "she", or "they"
- Living in a different time zone
- Facing other challenges to participate
- Or anything else. Be respectful of *everyone* at *all times*.
Think about how you might facilitate alternative ways to contribute or participate. If you find yourself dominating a discussion, step back.
Make way for other voices and listen actively to them.
### Understand Different Perspectives
Our goal should not be to "win" every disagreement or argument. A more productive goal is to be open to ideas that make our own ideas
better. Strive to be an example for inclusive thinking. "Winning" is when different perspectives make our work richer and stronger. That
means, you must pay attention to all ideas proposed. Don't disregard one without giving it the attention it deserves.
### Appreciate and Accommodate Our Similarities and Differences
People come from many cultures and backgrounds. Cultural differences can encompass everything from official religious observances to
personal habits to clothing. Be respectful of anyone with different cultural practices, attitudes and beliefs. Work to eliminate your own
biases, prejudices and discriminatory practices. Think of others' needs from their point of view. Use preferred titles (including
pronouns<sup>[\[1\]](#1)</sup>) and the appropriate tone of voice. Respect people's right to privacy and confidentiality. Be open to
learning from and educating others as well as educating yourself; it is unrealistic to expect someone to know the cultural practices of
every ethnic and cultural group. Therefore we must be ready to correct someone if they make a mistake, and must be ready ourselves to change
and learn if we make a mistake.
### Lead by Example
By matching your actions with your words, you become a person others want to follow. Your actions influence others to behave and respond in
ways that are valuable and appropriate for our organizational outcomes. Design your community and your work for inclusion. Hold yourself and
others accountable for inclusive behaviors.
## Behavior That Will Not Be Tolerated
The following behaviors are considered to be unacceptable and will not be tolerated:
### Violence and Threats of Violence
Violence and threats of violence are not acceptable - online or offline. This includes incitement of violence toward any individual,
including encouraging a person to commit self-harm, engage in self-harm, or put themselves in a negative position (e.g. one which can lead
to an increase of depression, etc.).
### Personal Attacks
Conflicts will inevitably arise, but frustration should never turn into a personal attack. It is not okay to insult, demean or belittle
others. Attacking someone for their opinions, beliefs and ideas is not acceptable. It is important to speak directly when we disagree and
when we think we need to improve, but such discussions must be conducted respectfully and professionally, remaining focused on the issue at
hand.
### Derogatory Language
Offensive, unwelcome, or hurtful comments related to:
- Gender
- Gender identity or expression
- Preferred pronouns<sup>[\[1\]](#1)</sup>
- Marital status
- Sex
- Sexual orientation or identity
- Native language
- Age
- (Dis)ability
- Mental illness
- Neuro(a)typicality
- Race and/or ethnicity
- Physical appearance
- A person's lifestyle choices or practices,
- A person's physical condition
- A person's mental condition
- Socioeconomic status
- Religion
- Employment
- Or anything really. Just don't be offensive towards people, insult them, or make unwanted comments.
is not acceptable. This includes deliberately referring to someone by a gender that they do not identify with, and/or questioning the
legitimacy of an individual's gender identity. If you're unsure if a word is derogatory, don't use it. This also includes repeated subtle
and/or indirect discrimination; when asked to stop, stop the behavior in question.
### Unwelcome Sexual Attention or Physical Contact
Unwelcome sexual attention or unwelcome physical contact is not acceptable. This includes sexualized comments, jokes or imagery in
interactions, communications or presentation materials, as well as inappropriate touching, groping, or sexual advances. Additionally,
touching a person without permission, including sensitive areas such as their hair, pregnant stomach, mobility device (wheelchair, scooter,
etc) or tattoos is unacceptable. This includes physically blocking or intimidating another person. Physical contact or simulated physical
contact (e.g. emojis like ":&#8203;kiss:", ":hug:", or ":kiss_mark:", textual descriptions like "\*hug\*", "\*backrub\*", or "\*kisses
you\*", etc.) without affirmative consent or after a request to stop will not be accepted.
### Sexual Behaviour Where it is Not Appropriate
Uninvited or off-topic sexual images, text, or behaviour in spaces where they're not appropriate will not be accepted whatsoever. We are an
open community, which means spaces must be appropriate for all ages, and everybody must feel comfortable. Discussion of sexual things, will
be prohibited unless otherwise noted.
### Discussion of Sensitive Topics
Discussion of sensitive topics when asked to stop, or when not appropriate. Including, but not limited to:
- Anything sexual
- Gore
- Suicide
- Self harm
- Anything related to death
- Or really anything that someone may be sensitive about.
shall not be tolerated. As a community for all ages and all kinds of people, we must cater to everyone, and must make sure everyone feels
comfortable here. Repeatedly breaking someone else's boundaries will not be tolerated.
### Disruptive Behavior
Sustained disruption of events, forums, or meetings, online or otherwise, including talks and presentations, will not be tolerated. This
includes:
- 'Talking over', 'heckling', or otherwise disrupting speakers.
- Making derogatory comments about someone else's choices, pushing people to do something they do not wish to do, talking about their
choices or personal preferences to others, or pressuring them to do something they don't wish to - physically or through jeering.
- Behaviour that intentionally disrupts an event.
- Otherwise influencing actions that may cause hostility in the session.
### Influencing Unacceptable Behavior
We will treat influencing or leading such activities the same way we treat the activities themselves, and thus the same consequences apply.
To make someone do something bad is the same thing as if you were to do it yourself, and we will not tolerate it.
### Stalking or Following
Stalking or following in any form (offline or online) is unnacceptable. In addition, you may not take pictures or record video of others
without their express permission or when asked to stop. Any individual may also request for you to delete all footage you have of them, even
if you took it with their prior consent.
### Publication of Personal Information
The publication of personally identifying information (commonly known as "[doxxing](https://en.wikipedia.org/wiki/Doxing)") is directly
prohibited. You may not publish information that someone wants to keep private, unless it is necessary to protect vulnerable people from
intentional abuse. Addditionally, you may not deliberately "out" any aspect of a person's identity without their consent, this includes
gender, pronouns, sexual identity, etc.
Unless it pretains to a case of harassment, as outlined here, in which case some personally identifying information may need to be brought
up in private with the appropriate moderation team to help aid our efforts in keeping the community safe.
### Deliberate Misuse of Pronouns<sup>[\[1\]](#1)</sup> or Names
As an inclusive community, we must respect everyone. That means respecting the pronouns or names they wish for us to use. Deliberate
misgendering, misuse of preferred pronouns<sup>[\[1\]](#1)</sup>, or use of 'dead' or rejected names is not to be tolerated. (If someone
*accidentally* uses the incorrect pronouns, gender, or name, politely ask them to use the correct pronouns/gender/name. But if they are to
continue using the incorrect pronouns, gender, or name, then you should escalate and report them to us.)
### Not Stopping After Multiple Requests
If someone asks you to stop doing something, then you should stop. Continuing to do it may be considered harassment, and can lead you to be
removed from our community.
## Complains We May Ignore
Additionally, Terra prioritizes marginalized people's safety over privileged people's comfort. We reserve the right to ignore complaints
regarding:
- Claims of discrimination against non-marginalized or oppressed groups (eg. being 'superphobic', meaning to not support people who are
'superstraight', which is a dog whistle for transphobic groups, or being 'cisphobic' without large amounts of evidence, etc.), or claims
of discrimination with no evidence. (Basically, don't report 'cisphobia' to us, because it doesn't exist. But if someone is mocking you or
making fun of you for being cis, and it is *really* getting out of hand, then do tell us.)
- Reasonable communication of boundaries, such as "leave me alone," "go away," or "I'm not discussing this with you." (If someone is asking
you to stop, that is not reason for you to report them as harassing you.)
- Communicating in a 'tone' you don't find [congenial](https://www.thefreedictionary.com/congenial). (You may not report someone for
harassment for being 'annoyed with you' or 'talking sternly to you')
- Criticizing or calling out racist, sexist, discriminatory, or otherwise oppressive behavior or assumptions. (You may not say that someone
is harassing you if they are telling you to stop discriminating against someone.)
- Disagreements that do not qualify as harassment. If you have a simple disagreement with someone, and they have not been discriminating to
anyone, in any form, then we will not take action against them. Two people are allowed to disagree on things without it getting toxic.
We may also additionally choose to enact punishment for submitting a complaint in bad-faith or without adequate justification, if we deem
necessary; if you're submitting a complaint just to troll or to annoy people, we may choose to have you banned or removed from the community
spaces. Don't waste our time.
In order to protect volunteers from abuse and burnout, we reserve the right to reject any report we believe to have been made in bad faith
or with misintent. Reports intended to silence legitimate criticism may be deleted without response.
## Reporting
Terra has a global moderation team which is currently comprised of the following members:
- solonovamax
- discord: [@solonovamax#6983](https://discord.com/channels/@me/566146322273402881)*
- github: [@solonovamax](https://github.com/solonovamax)
- email: [solonovamax@12oclockpoint.com](mailto:solonovamax@12oclockpoint.com)
- dfsek
- discord: [@dfsek#4208](https://discord.com/channels/@me/378350362236682240)*
- github: [@dfsek](https://github.com/dfsek)
- email: [dfsek@protonmail.com](mailto:dfsek@protonmail.com)
- duplex (duplexsystem)
- discord: [@Duplex#0797](https://discord.com/channels/@me/356822848641171456)*
- github: [@duplexsystem](https://github.com/duplexsystem)
- email: [duplexsys@protonmail.com](mailto:duplexsys@protonmail.com)
\* The preferred method of communication is through discord. Although we will still be responsive on the other platforms, we will be more
responsive on discord.
These are people you can contact for anything regarding this code of conduct.
If you are being harassed by a member of the Terra community, or by someone in a Terra community space, notice that someone else is being
harassed, or have any other concerns, please contact a moderator of the platform it occurred on, or someone on the global moderation team.
If the person who is harassing you is on the global moderation team, they will [recuse](https://www.thefreedictionary.com/recuse) themselves
from handling your incident. (Meaning: if you are reporting someone on the team, they will not be involved in the discussion.) We will
respond within a reasonable time frame, but generally within about 1 day.
This code of conduct applies to Terra community spaces, but if you are being harassed by a member of Terra *outside* our spaces, we still
want to know about it as we may choose to take action within our community. We will take all good-faith reports seriously and will always
attempt to handle them appropriately. This includes harassment outside our spaces and harassment that took place at any point in time. The
moderation team reserves the right to exclude people from Terra communities based on their past behavior, including behavior outside Terra
spaces and behavior towards people who are not in Terra.
Note: although we only have the ability to moderate official community spaces, if you are being harassed by someone in a non-official
community space, and the moderation team of that platform refuses to do anything to help you (or even if they *do* help you), then you
should notify us so that we may take appropriate action.
We will respect confidentiality requests for the purpose of protecting victims of abuse. At our discretion, we may publicly name a person
which we have received harassment complaints about, or privately warn third parties about them, but only if we believe that doing so will
increase the safety of Terra community members or the general public. We will not name harassment victims or reporters of harassment
(assuming the report was made in good-faith) without their explicit consent; all reports will remain anonymous by default.
## Consequences of Unacceptable Behavior
Participants asked to stop any harassing behavior are expected to comply immediately. Whether or not you comply immediately, you may still
face consequences for you actions, but if the harasser doesn't comply immediately then we may choose to take additional actions to protect
the Terra community members or the individual being harassed.
Violation of this code can result in being asked to leave an event or online space, either temporarily or for the duration of the event, or
being banned from participation in spaces, or future events and activities in perpetuity. If a participant engages in harassing behavior,
the global moderation team may take any action they deem appropriate, up to and including expulsion from all Terra community spaces and
identification of the participant as a harasser to other Terra community members or the general public. Bad behavior from any community
member, including those with decision-making authority, will not be tolerated.
In addition, any participants who abuse the reporting process will be considered to be in violation of these guidelines and subject to
consequences. False reporting, especially to retaliate or exclude, will not be accepted or tolerated.
## Questions
if you have further questions for anything not addressed here, you may open an issue on this github repo, or contact a member of the global
moderation team.
## License and Attribution
This set of guidelines is distributed under a
[Creative Commons Attribution-ShareAlike license](https://creativecommons.org/licenses/by-sa/3.0/).
These guidelines have been adapted from
[Mozilla's Community Participation Guidelines](https://www.mozilla.org/en-US/about/governance/policies/participation/), which were adapted
from:
- Mozilla's original Community Participation Guidelines
- The [Ubuntu Code of Conduct](https://ubuntu.com/community/code-of-conduct)
- Mozilla's [View Source Conference Code of Conduct](https://viewsourceconf.org/berlin-2016/code-of-conduct/)
- And the [Rust Language Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct)
which in turn were based on [Stumptown Syndicate's Citizen Code of Conduct](http://citizencodeofconduct.org/), along with some adapted text
from the [LGBTQ in Technology Code of Conduct](https://lgbtq.technology/coc.html) and
the [WisCon code of conduct](http://wiscon.net/policies/anti-harassment/code-of-conduct/).
It was then modified by solonovamax with various inclusions from
the [LGBTQ in Technology Code of Conduct](https://lgbtq.technology/coc.html) and a few other sources.
## Notes
#### \[1\]
You provide a set of pronouns that everyone is comfortable addressing you with. Although some people are comfortable
using [neopronouns](https://www.mypronouns.org/neopronouns), not everyone is. Therefore, if you use neopronouns, you should have at *least*
one set of more common pronouns (One of he/him, she/her, or they/them; it doesn't matter which one. Anyone who doesn't respect your basic
pronouns will be removed from the community.) that people may use, should they so choose, as some people are not comfortable
using [neopronouns](https://www.mypronouns.org/neopronouns). But if someone refuses to use your more common pronouns, you should report them
to us. Additionally, you may not ask people to use unreasonable pronouns, such as 'acab/acabself', 'that/bitch', 'ur/mom', or
'dream/dreamself' (pronouns related to real people, eg. the minecraft youtuber 'dreamwastaken'). Doing so will be considered mockery of
individuals who use non-standard pronouns and is very disrespectful.
+319
View File
@@ -0,0 +1,319 @@
# Contributing to Terra
First off, thank you for considering contributing to Terra. It's people like you that make Terra such a great tool.
Following these guidelines helps to effectively use the time of the developers managing and developing this open source project, making it
more enjoyable for all of us.
Terra is an open source project and we love to receive contributions from our community, you! There are many ways to contribute, from
writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be
incorporated into Terra.
The following is a set of guidelines for contributing to Terra and its packages, which are hosted in
the [PolyhedralDev Organization](https://github.com/PolyhedralDev) on GitHub. These are mostly guidelines, not rules. Use your best
judgment, and feel free to propose changes to this document in a pull request.
#### Table Of Contents
[Code of Conduct](#code-of-conduct)
[I don't want to read this whole thing, I just have a question!!!](#i-dont-want-to-read-this-whole-thing-i-just-have-a-question)
[Getting Started](#getting-started)
- [Your First Contribution](#your-first-contribution)
- [Reporting Bugs](#reporting-bugs)
- [Before Submitting A Bug Report](#before-submitting-a-bug-report)
- [How Do I Submit A (Good) Bug Report?](#how-do-i-submit-a-good-bug-report)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Before Submitting An Enhancement Suggestion](#before-submitting-an-enhancement-suggestion)
- [How Do I Submit A (Good) Enhancement Suggestion?](#how-do-i-submit-a-good-enhancement-suggestion)
- [Pull Requests](#pull-requests)
- [Before Submitting A Pull Request](#before-submitting-a-pull-request)
- [How Do I Submit A (Good) Pull Request?](#how-do-i-submit-a-good-pull-request)
[Styleguides](#styleguides)
- [Git Commits](#git-commits)
- [Committing](#committing)
- [Git Commit Messages](#git-commit-messages)
- [Code Styleguide](#code-styleguide)
- [Documentation Styleguide](#documentation-styleguide)
- TODO
[Coding Pratices](#coding-practices)
- [Compatibility](#compatibility)
- [General Compatibility](#general-compatibility)
- [Specific Compatibility](#specific-compatibility)
- [Platform-Agnostic Design](#platform-agnostic-design)
- [Data-Driven](#data-driven)
## Code of Conduct
This project and everyone participating in it is governed by the [Terra of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected
to uphold this code. Please report unacceptable behavior to [Terra global moderation team](CODE_OF_CONDUCT.md#Reporting).
## I don't want to read this whole thing I just have a question!!!
> **Note:** Please don't file an issue to ask a question. You'll get faster results by using the resources below.
We have an official discord server where you can request help from various users
- [The official PolyhedralDev discord server](https://discord.dfsek.com)
## Getting Started
### Your First Contribution
Unsure where to begin contributing to Terra? You can start by looking through "beginner" and "help wanted" issues:
- [Beginner issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Good%20First%20Issue) - issues which should be friendly to
anyone new to terra.
- [Help wanted issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Help%20Wanted) - issues which should be a bit more involved
than "beginner" issues.
New to github? Working on your first Pull Request? Check
out [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github)
to get you up on your feet.
At this point, you're ready to make your changes! Feel free to ask for help; everyone is a beginner at first!
If a maintainer asks you to "rebase" your PR, they're saying that a lot of code has changed, and that you need to update your branch so it's
easier to merge.
### Reporting Bugs
This section guides you through submitting a bug report for Terra. Following these guidelines helps maintainers and the community understand
your report, and spend their time fixing the issue instead of understanding what you mean.
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create
one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report).
> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
#### Before Submitting A Bug Report
- Join the [discord server](https://discord.dfsek.com) to help resolve simple issues.
- 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 main project.
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the main project.
- Search for any [already existing issues](https://github.com/PolyhedralDev/Terra/issues?q=is%3Aissue+) 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.
- Double check that this is not an issue with a specific Terra *pack* or Terra *addon*, and instead applies to all of Terra.
- Include a copy of the latest.log file. Putting *just* the exception is not enough. We need to be able to check that there wasn't anything
else before that caused it.
- Be sure to fill out all the required information and give descriptions of everything.
#### How Do I Submit A (Good) Bug Report?
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/)
. [Create an issue](https://github.com/PolyhedralDev/Terra/issues/new) and provide the prerequisite information by filling in the Bug Report
template.
Explain the problem and include additional details to help maintainers reproduce the problem:
- **Use a clear and descriptive title** for the issue to identify the problem.
- **Describe the exact steps which reproduce the problem** in as many details as possible. When listing steps, **don't just say what you
did, but explain how you did it**.
- **Provide specific examples to demonstrate the steps**.
- **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
- **Explain which behavior you expected to see instead and why.**
- **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more
information using the guidelines below.
Include details about your configuration and environment:
- **Which version of Terra are you using?** You can get the exact version by running `/te version`.
- **What's the name and version of the platform you're using**? (eg. Spigot, Fabric, Paper, etc.)
- **Which external plugins or mods do you have installed?**
- **Which Terra packs do you have installed?** You can get that list by running `/te packs`.
- **Which Terra addons do you have installed?** You can get that list by running `/te addons`.
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion for Terra, including completely new features and minor improvements to
existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related
suggestions.
Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that
you don't need to create one. When you are creating an enhancement suggestion,
please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion).
#### Before Submitting An Enhancement Suggestion
- You must be on the **LATEST** version of Terra to make sure your feature hasn't been added yet.
- Search for any [already existing issues](https://github.com/PolyhedralDev/Terra/issues?q=is%3Aissue+) (Including closed!) with your
problem. If you open a duplicate, it will be closed as such.
- Verify that this is actually within the scope of Terra.
- Be sure that this is not a feature request that should be made for a specific Terra *pack*, and instead applies to all of Terra.
- Be sure that this is not something that should be implemented as a Terra addon, and instead applies to all of Terra.
- Make sure that you attach a copy of the latest.log file, if there are any exceptions thrown in the console. Putting *just* the exception
**is not enough**. We need to be able to check that there wasn't anything else before that caused it.
#### How Do I Submit A (Good) Enhancement Suggestion?
Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). Create an issue on our main repository
and provide the following information:
- **Use a clear and descriptive title** for the issue to identify the suggestion.
- **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
- **Provide specific examples to demonstrate the steps**.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
- **Explain why this enhancement would be useful** to most Terra users and isn't something that can or should be implemented as an addon.
### Pull Requests
This section guides you through submitting a pull request for Terra.
While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete
additional design work, tests, or other changes before your pull request can be ultimately accepted.
#### Before Submitting A Pull Request
- You must be on the **LATEST** version of Terra to make sure your feature hasn't been added yet.
- Search for any [already existing issues](https://github.com/PolyhedralDev/Terra/issues?q=is%3Aissue+) (Including closed!) with your
problem. If you open a duplicate, it will be closed as such.
- Verify that this is actually within the scope of Terra.
- Be sure that this is not a feature request that should be made for a specific Terra *pack*, and instead applies to all of Terra.
- Be sure that this is not something that should be implemented as a Terra addon, and instead applies to all of Terra.
- Make sure that you attach a copy of the latest.log file, if there are any exceptions thrown in the console. Putting *just* the
exception **is not enough**. We need to be able to check that there wasn't anything else before that caused it.
#### How Do I Submit A (Good) Pull Request?
Pull Requests are tracked as [GitHub Pull Requests](https://guides.github.com/activities/forking/#making-a-pull-request). Create a pr on our
main repository and provide the following information:
- **Use a clear and descriptive title** to identify the pull request.
- **State what this pull request adds/fixes**.
- **Be sure that you are the owner of the code you contributed** or that it can be licensed under the GPLv3.
- **Provide a description goals and non-goals of the pull request** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
- **Explain why this enhancement would be useful** to most Terra users and isn't something that can or should be implemented as an addon.
## Styleguides
### Git Commits
Following this is not mandatory, but rather a set of guidelines. As long as your commit messages aren't absolutely awful, it's probably
fine. But it would be nice if you followed them.
#### Committing
When you commit code, try to avoid committing large amounts of code in a single go. Splitting up code into smaller commits is much nicer and
makes it easier to trace a feature to a single commit.
Try to stick to one feature/fix/etc. per commit. A good rule of thumb is if you need to use the word "and" in the subject line, then it
should probably™ be two commits.
#### Git Commit Messages
- Subject line must fit the following format: `<type>: <short summary>`. Type must be one of the following:
- Build: Changes that affect the build system or external dependencies.
- Docs: Documentation only changes.
- Feat: A new feature.
- Fix: A bug fix.
- Perf: Performance improvements.
- Refactor: Refactoring sections of the codebase.
- Repo: Changes to the repository structure that do not affect code. (Eg. modification of the `README.md` file, etc.)
- Revert: Revert a previous commit.
- Style: Code style updates.
- Test: Anything related to testing.
- Trans: Translation and localization of Terra to other languages.
- WIP: Work in progress.
- Separate the subject line from the body with a single blank line.
- Do not end subject line with a period.
- Limit the subject line to 50 or less.
- The subject line and all body lines should be in sentence case.
- Use the present tense. ("Add feature" not "Added feature")
- Use the imperative mood. ("Move cursor to..." not "Moves cursor to...")
- Reference relevant issues and pull requests in the body.
>
> Here is a template you can follow:
> ```
> Capitalized, short (50 chars or less) summary
>
> More detailed explanatory text, if necessary. Wrap it to about 72
> characters or so. In some contexts, the first line is treated as
> the subject of the commit and the rest of the text as the body. The
> blank line separating the summary from the body is critical (unless
> you omit the body entirely); various tools like `log`, `shortlog` and
> `rebase` can get confused if you run the two together.
>
> Explain the problem that this commit is solving. Focus on why you are
> making this change as opposed to how (the code explains that). Are
> there side effects or other unintuitive consequences of this
> change? Here's the place to explain them.
>
>
> Further paragraphs come after blank lines.
> - Bullet points are okay, too
> - Typically a hyphen or asterisk is used for the bullet, followed
> by a single space, with blank lines in between, but conventions vary
> here
> - Use a hanging indent
>
> Reference any relevant issues at the bottom, like so:
>
> Resolves: #123
> See also: #456, #789
> ```
### Code Styleguide
Use an IDE with support for `.editorconfig` files. There is an included editorconfig file in the base of the project so that your IDE should
automatically use the correct code style settings.
### Documentation Styleguide
TODO
## Coding Practices
### Compatibility
#### General Compatibility
General compatibility (example: injection of Vanilla structures/features/carvers into packs) is acceptable in the main project.
- General compatibility features should be *disabled by default*. Having things auto-injected causes unpredictable behaviour that is
annoying to diagnose. General-compatibility options should have config values attached which are disabled by default.
- These config options should also be *simple to use*. Think of the people who will be using these compatibility options. They want to flick
a switch and have things be compatible. That means that a majority of compatibility options should stay in `pack.yml`, to make it simple
to go into a pack and turn on specific compatibilities. This does *not* mean that more advanced compatibility options are off the table,
for example, look at Feature compatibility, where features can either be automatically injected, *or* configured individually per Terra
biome, depending on how much control the user wants.
#### Specific Compatibility
Specific compatibility should *not* be put in the main project. (Example: Adding the ability to generate TechCraft v7's doo-dads with a
TerraScript function)
Having specific compatibilities leads to tons of extra dependencies to keep track of, as well as adding lots of additional stuff to
maintain. It quickly becomes a mess. Especially when most users will never need to use this feature.
We have designed an addon API for exactly this purpose. **Specific compatibilities are welcome and encouraged, in the form of addons.**
### Platform-Agnostic Design
Terra must, at all times, remain platform agnostic. This means it must be able to run on theoretically any voxel based platform. Including
non-minecraft games like Terasology.
When adding a new feature to `common`, make no assumptions about what platform it'll be running on.
Examples:
- Don't assume the world height is 256.
- Don't assume that a specific block, item, or entity exists. (Eg. don't assume there exists a block called `minecraft:grass_block`)
### Data-Driven
When adding a new feature, make it abstract. Don't make assumptions about "specific use cases." If you can only think of a few use cases,
your idea should probably be generalized.
You must use configs effectively. Make configs that are *powerful* but also *make sense* and are \[easy\] to use.
@@ -15,7 +15,7 @@ fun Project.configureCompilation() {
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_16
}
tasks.withType<JavaCompile> {
@@ -4,7 +4,6 @@ import com.dfsek.terra.api.addons.TerraAddon;
import com.dfsek.terra.api.event.EventManager;
import com.dfsek.terra.api.platform.handle.ItemHandle;
import com.dfsek.terra.api.platform.handle.WorldHandle;
import com.dfsek.terra.api.platform.modloader.Mod;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.registry.LockedRegistry;
@@ -20,8 +19,6 @@ import com.dfsek.terra.world.TerraWorld;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Set;
import java.util.jar.JarFile;
/**
@@ -78,8 +75,4 @@ public interface TerraPlugin extends LoaderRegistrar {
default JarFile getModJar() throws URISyntaxException, IOException {
return JarUtil.getJarFile();
}
default Set<Mod> getMods() {
return Collections.emptySet();
}
}
@@ -0,0 +1,16 @@
package com.dfsek.terra.api.config.meta;
import com.dfsek.tectonic.exception.LoadException;
import java.lang.reflect.Type;
/**
* Context from which to pull {@link MetaValue}s
*/
public interface MetaContext {
default <T> T load(String meta, Class<T> clazz) throws LoadException {
return load(meta, (Type) clazz);
}
<T> T load(String meta, Type type) throws LoadException;
}
@@ -0,0 +1,9 @@
package com.dfsek.terra.api.config.meta;
import java.util.function.Supplier;
public interface MetaValue<T> extends Supplier<T> {
static <T1> MetaValue<T1> of(T1 value) {
return () -> value;
}
}
@@ -0,0 +1,8 @@
package com.dfsek.terra.api.config.meta.type;
import com.dfsek.terra.api.config.meta.MetaValue;
import java.util.List;
public interface MetaList<T> extends MetaValue<List<T>> {
}
@@ -0,0 +1,8 @@
package com.dfsek.terra.api.config.meta.type;
import com.dfsek.terra.api.config.meta.MetaValue;
import java.util.Map;
public interface MetaMap<K, V> extends MetaValue<Map<K, V>> {
}
@@ -0,0 +1,8 @@
package com.dfsek.terra.api.config.meta.type;
import com.dfsek.terra.api.config.meta.MetaValue;
import java.util.Set;
public interface MetaSet<T> extends MetaValue<Set<T>> {
}
@@ -0,0 +1,6 @@
package com.dfsek.terra.api.config.meta.type.number;
import com.dfsek.terra.api.config.meta.MetaValue;
public interface MetaNumber<T extends Number> extends MetaValue<T> {
}
@@ -3,7 +3,6 @@ package com.dfsek.terra.api.event.events.config;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.terra.api.event.events.PackEvent;
import com.dfsek.terra.config.fileloaders.Loader;
import com.dfsek.terra.config.pack.ConfigPack;
/**
@@ -12,12 +11,10 @@ import com.dfsek.terra.config.pack.ConfigPack;
public abstract class ConfigPackLoadEvent implements PackEvent {
private final ConfigPack pack;
private final ExceptionalConsumer<ConfigTemplate> configLoader;
private final Loader loader;
public ConfigPackLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader, Loader loader) {
public ConfigPackLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
this.pack = pack;
this.configLoader = configLoader;
this.loader = loader;
}
@Override
@@ -37,8 +34,4 @@ public abstract class ConfigPackLoadEvent implements PackEvent {
public interface ExceptionalConsumer<T extends ConfigTemplate> {
void accept(T value) throws ConfigException;
}
public Loader getLoader() {
return loader;
}
}
@@ -1,14 +1,13 @@
package com.dfsek.terra.api.event.events.config;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.terra.config.fileloaders.Loader;
import com.dfsek.terra.config.pack.ConfigPack;
/**
* Called when a config pack has finished loading.
*/
public class ConfigPackPostLoadEvent extends ConfigPackLoadEvent {
public ConfigPackPostLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configTemplateLoader, Loader loader) {
super(pack, configTemplateLoader, loader);
public ConfigPackPostLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> loader) {
super(pack, loader);
}
}
@@ -1,14 +1,14 @@
package com.dfsek.terra.api.event.events.config;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.terra.config.fileloaders.Loader;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.terra.config.pack.ConfigPack;
/**
* Called before a config pack's registries are filled. At this point, the pack manifest has been loaded, and all registries are empty.
*/
public class ConfigPackPreLoadEvent extends ConfigPackLoadEvent {
public ConfigPackPreLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader, Loader loader) {
super(pack, configLoader, loader);
public ConfigPackPreLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
super(pack, configLoader);
}
}
@@ -1,9 +0,0 @@
package com.dfsek.terra.api.platform.modloader;
public interface Mod {
String getID();
String getVersion();
String getName();
}
@@ -42,7 +42,7 @@ public class ZeroArgFunctionBuilder<T> implements FunctionBuilder<Function<T>> {
@Override
public int argNumber() {
return 1;
return 0;
}
@Override
@@ -15,7 +15,7 @@ public class BufferedPulledBlock implements BufferedItem {
@Override
public void paste(Location origin) {
Block pos = origin.getBlock();
while(pos.getY() > 0) {
while(pos.getY() > origin.getWorld().getMinHeight()) {
if(!pos.isEmpty()) {
pos.setBlockData(data, false);
break;
@@ -0,0 +1,22 @@
package com.dfsek.terra.api.util;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
public final class MapUtil {
public static <K1, V1, K2, V2, M extends Map<K2, V2>> M remap(Function<K1, K2> keys, Function<V1, V2> values, Map<K1, V1> in, Supplier<M> newMap) {
M map = newMap.get();
in.forEach((k, v) -> map.put(keys.apply(k), values.apply(v)));
return map;
}
public static <K1, V1, K2, V2> Map<K2, V2> remap(Function<K1, K2> keys, Function<V1, V2> values, Map<K1, V1> in) {
return remap(keys, values, in, HashMap::new);
}
public static <K, V1, V2> Map<K, V2> remapValues(Function<V1, V2> values, Map<K, V1> in) {
return remap(Function.identity(), values, in);
}
}
@@ -0,0 +1,10 @@
package com.dfsek.terra.api.util;
import java.io.Reader;
import java.util.regex.Pattern;
public class MetaTokenizer {
public MetaTokenizer(Reader in) {
}
}
@@ -23,7 +23,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
public ProbabilityCollection<E> add(E item, int probability) {
if(!cont.containsKey(item)) size++;
cont.computeIfAbsent(item, i -> new MutableInteger(0)).increment();
cont.computeIfAbsent(item, i -> new MutableInteger(0)).add(probability);
int oldLength = array.length;
Object[] newArray = new Object[array.length + probability];
System.arraycopy(array, 0, newArray, 0, array.length); // Expand array.
@@ -51,13 +51,19 @@ public class ProbabilityCollection<E> implements Collection<E> {
ProbabilityCollection<T> newCollection = new ProbabilityCollection<>();
newCollection.array = new Object[array.length];
Map<E, T> cache = new HashMap<>();
for(int i = 0; i < array.length; i++) {
if(carryNull && array[i] == null) continue;
newCollection.array[i] = mapper.apply((E) array[i]);
newCollection.array[i] = cache.computeIfAbsent((E) array[i], mapper);
}
return newCollection;
}
public <T> ProbabilityCollection<T> map(Function<E, T> mapper) {
return map(mapper, true);
}
public int getTotalProbability() {
return array.length;
}
@@ -0,0 +1,23 @@
package com.dfsek.terra.api.util.generic;
import java.util.function.Supplier;
public final class Lazy<T> {
private final Supplier<T> fetch;
private T value;
private boolean needsInit = true;
public Lazy(Supplier<T> fetch) {
this.fetch = fetch;
}
public T get() {
if(needsInit) {
value = fetch.get();
needsInit = false;
}
return value;
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.api.world.carving;
import com.dfsek.terra.api.math.vector.Vector3;
import com.dfsek.terra.api.platform.world.World;
import net.jafama.FastMath;
import java.util.Random;
@@ -85,7 +86,7 @@ public abstract class Worm {
return rad[index];
}
public void carve(int chunkX, int chunkZ, BiConsumer<Vector3, Carver.CarvingType> consumer) {
public void carve(int chunkX, int chunkZ, BiConsumer<Vector3, Carver.CarvingType> consumer, World world) {
int xRad = getRadius(0);
int yRad = getRadius(1);
int zRad = getRadius(2);
@@ -97,7 +98,7 @@ public abstract class Worm {
if(!(FastMath.floorDiv(origin.getBlockZ() + z, 16) == chunkZ)) continue;
for(int y = -yRad - 1; y <= yRad + 1; y++) {
Vector3 position = origin.clone().add(new Vector3(x, y, z));
if(position.getY() < 0 || position.getY() > 255) continue;
if(position.getY() < world.getMinHeight() || position.getY() > world.getMaxHeight()) continue;
double eq = ellipseEquation(x, y, z, xRad, yRad, zRad);
if(eq <= 1 &&
y >= -yRad - 1 + bottomCut && y <= yRad + 1 - topCut) {
@@ -5,12 +5,19 @@ import com.dfsek.terra.api.world.palette.Palette;
public class PaletteHolder {
private final Palette<BlockData>[] palettes;
private final int offset;
protected PaletteHolder(Palette<BlockData>[] palettes) {
protected PaletteHolder(Palette<BlockData>[] palettes, int offset) {
this.palettes = palettes;
this.offset = offset;
}
public Palette<BlockData> getPalette(int y) {
return palettes[y];
int index = y + offset;
return index >= 0
? index < palettes.length
? palettes[index]
: palettes[palettes.length - 1]
: palettes[0];
}
}
@@ -17,8 +17,12 @@ public class PaletteHolderBuilder {
@SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"})
public PaletteHolder build() {
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1];
for(int y = 0; y <= FastMath.max(paletteMap.lastKey(), 255); y++) {
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) {
Palette<BlockData> d = null;
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
if(e.getKey() >= y) {
@@ -27,8 +31,8 @@ public class PaletteHolderBuilder {
}
}
if(d == null) throw new IllegalArgumentException("No palette for Y=" + y);
palettes[y] = d;
palettes[y - min] = d;
}
return new PaletteHolder(palettes);
return new PaletteHolder(palettes, -min);
}
}
@@ -15,6 +15,7 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@@ -41,13 +42,13 @@ public class CarverCache {
carving.step();
TerraBiome biome = provider.getBiome(carving.getRunning().toLocation(w));
if(!((UserDefinedBiome) biome).getConfig().getCarvers().containsKey(CarverCache.this.carver)) { // Stop if we enter a biome this carver is not present in
return new GlueList<>();
return Collections.emptyList();
}
points.add(carving.getPoint());
}
return points;
}
return new GlueList<>();
return Collections.emptyList();
}
});
}
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.api.util.collections.MaterialSet;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import net.jafama.FastMath;
import java.util.Map;
import java.util.TreeMap;
@@ -14,6 +15,7 @@ public class CarverPalette {
private final MaterialSet replace;
private final TreeMap<Integer, ProbabilityCollection<BlockData>> map = new TreeMap<>();
private ProbabilityCollection<BlockData>[] layers;
private int offset = 0;
public CarverPalette(MaterialSet replaceable, boolean blacklist) {
this.blacklist = blacklist;
@@ -26,7 +28,12 @@ public class CarverPalette {
}
public ProbabilityCollection<BlockData> get(int y) {
return layers[y];
int index = y + offset;
return index >= 0
? index < layers.length
? layers[index]
: layers[layers.length - 1]
: layers[0];
}
public boolean canReplace(BlockType material) {
@@ -37,9 +44,11 @@ public class CarverPalette {
* Build the palette to an array.
*/
public void build() {
int size = map.lastKey() + 1;
layers = new ProbabilityCollection[size];
for(int y = 0; y < size; y++) {
int min = FastMath.min(map.keySet().stream().min(Integer::compareTo).orElse(0), 0);
int max = FastMath.max(map.keySet().stream().max(Integer::compareTo).orElse(255), 255);
layers = new ProbabilityCollection[map.lastKey() + 1 - min];
for(int y = min; y <= FastMath.max(map.lastKey(), max); y++) {
ProbabilityCollection<BlockData> d = null;
for(Map.Entry<Integer, ProbabilityCollection<BlockData>> e : map.entrySet()) {
if(e.getKey() >= y) {
@@ -47,8 +56,9 @@ public class CarverPalette {
break;
}
}
if(d == null) throw new IllegalArgumentException("Null collection at Y=" + y);
layers[y] = d;
if(d == null) throw new IllegalArgumentException("No palette for Y=" + y);
layers[y - min] = d;
}
offset = -min;
}
}
@@ -116,7 +116,7 @@ public class UserDefinedCarver extends Carver {
Vector3 origin = point.getOrigin();
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ) // We only want to carve this chunk.
return;
point.carve(chunkX, chunkZ, consumer);
point.carve(chunkX, chunkZ, consumer, w);
});
}
}
@@ -25,11 +25,11 @@ import com.dfsek.terra.config.loaders.LinkedHashMapLoader;
import com.dfsek.terra.config.loaders.MaterialSetLoader;
import com.dfsek.terra.config.loaders.ProbabilityCollectionLoader;
import com.dfsek.terra.config.loaders.RangeLoader;
import com.dfsek.terra.config.loaders.config.FloraLayerLoader;
import com.dfsek.terra.config.loaders.config.GridSpawnLoader;
import com.dfsek.terra.config.loaders.config.OreConfigLoader;
import com.dfsek.terra.config.loaders.config.FloraLayerTemplate;
import com.dfsek.terra.config.loaders.config.GridSpawnTemplate;
import com.dfsek.terra.config.loaders.config.OreConfigTemplate;
import com.dfsek.terra.config.loaders.config.OreHolderLoader;
import com.dfsek.terra.config.loaders.config.TreeLayerLoader;
import com.dfsek.terra.config.loaders.config.TreeLayerTemplate;
import com.dfsek.terra.config.loaders.config.biome.BiomeProviderBuilderLoader;
import com.dfsek.terra.config.loaders.config.biome.SourceBuilderLoader;
import com.dfsek.terra.config.loaders.config.biome.StageBuilderLoader;
@@ -46,8 +46,6 @@ import com.dfsek.terra.config.loaders.config.sampler.templates.ImageSamplerTempl
import com.dfsek.terra.config.loaders.config.sampler.templates.normalizer.ClampNormalizerTemplate;
import com.dfsek.terra.config.loaders.config.sampler.templates.normalizer.LinearNormalizerTemplate;
import com.dfsek.terra.config.loaders.config.sampler.templates.normalizer.NormalNormalizerTemplate;
import com.dfsek.terra.config.loaders.mod.ModDependentConfigSection;
import com.dfsek.terra.config.loaders.mod.ModDependentConfigSectionLoader;
import com.dfsek.terra.config.loaders.palette.CarverPaletteLoader;
import com.dfsek.terra.config.loaders.palette.PaletteHolderLoader;
import com.dfsek.terra.config.loaders.palette.PaletteLayerLoader;
@@ -71,13 +69,13 @@ public class GenericLoaders implements LoaderRegistrar {
public void register(TypeRegistry registry) {
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
.registerLoader(Range.class, new RangeLoader())
.registerLoader(GridSpawn.class, new GridSpawnLoader())
.registerLoader(GridSpawn.class, GridSpawnTemplate::new)
.registerLoader(PaletteHolder.class, new PaletteHolderLoader())
.registerLoader(PaletteLayerHolder.class, new PaletteLayerLoader())
.registerLoader(FloraLayer.class, new FloraLayerLoader())
.registerLoader(FloraLayer.class, FloraLayerTemplate::new)
.registerLoader(Ore.Type.class, (t, o, l) -> Ore.Type.valueOf(o.toString()))
.registerLoader(OreConfig.class, new OreConfigLoader())
.registerLoader(TreeLayer.class, new TreeLayerLoader())
.registerLoader(OreConfig.class, OreConfigTemplate::new)
.registerLoader(TreeLayer.class, TreeLayerTemplate::new)
.registerLoader(MaterialSet.class, new MaterialSetLoader())
.registerLoader(OreHolder.class, new OreHolderLoader())
.registerLoader(ImageSamplerTemplate.class, ImageSamplerTemplate::new)
@@ -110,8 +108,7 @@ public class GenericLoaders implements LoaderRegistrar {
if(main != null) {
registry.registerLoader(TerraAddon.class, main.getAddons())
.registerLoader(BlockType.class, (t, object, cf) -> main.getWorldHandle().createBlockData((String) object).getBlockType())
.registerLoader(ModDependentConfigSection.class, new ModDependentConfigSectionLoader(main));
.registerLoader(BlockType.class, (t, object, cf) -> main.getWorldHandle().createBlockData((String) object).getBlockType());
}
}
}
@@ -13,9 +13,9 @@ public class OreFactory implements ConfigFactory<OreTemplate, Ore> {
BlockData m = config.getMaterial();
switch(config.getType()) {
case SPHERE:
return new DeformedSphereOre(m, config.getReplaceable(), config.doPhysics(), config.getDeform(), config.getDeformFrequency(), config.getSize(), main);
return new DeformedSphereOre(m, config.getReplaceable(), config.doPhysics(), config.getDeform(), config.getDeformFrequency(), config.getSize(), main, config.getMaterialOverrides());
case VANILLA:
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), main);
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), main, config.getMaterialOverrides());
}
return null;
}
@@ -1,6 +1,5 @@
package com.dfsek.terra.config.fileloaders;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
@@ -21,7 +20,7 @@ public class ZIPLoader extends Loader {
ZipEntry entry = entries.nextElement();
if(!entry.isDirectory() && entry.getName().equals(singleFile)) return file.getInputStream(entry);
}
throw new FileNotFoundException("No such file: " + singleFile);
throw new IllegalArgumentException("No such file: " + singleFile);
}
@Override
@@ -1,40 +0,0 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.math.noise.samplers.noise.random.WhiteNoiseSampler;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.world.flora.Flora;
import com.dfsek.terra.config.loaders.Types;
import com.dfsek.terra.world.population.items.flora.FloraLayer;
import java.lang.reflect.Type;
import java.util.Map;
@SuppressWarnings("unchecked")
public class FloraLayerLoader implements TypeLoader<FloraLayer> {
@Override
public FloraLayer load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
Map<String, Object> map = (Map<String, Object>) o;
double density = ((Number) map.get("density")).doubleValue();
Range range = configLoader.loadClass(Range.class, map.get("y"));
if(range == null) throw new LoadException("Flora range unspecified");
ProbabilityCollection<Flora> items = (ProbabilityCollection<Flora>) configLoader.loadType(Types.FLORA_PROBABILITY_COLLECTION_TYPE, map.get("items"));
NoiseSeeded sampler;
if(map.containsKey("distribution")) {
try {
sampler = configLoader.loadClass(NoiseSeeded.class, map.get("distribution"));
} catch(ConfigException e) {
throw new LoadException("Unable to load noise", e);
}
return new FloraLayer(density, range, items, sampler.apply(2403L));
}
return new FloraLayer(density, range, items, new WhiteNoiseSampler(2403));
}
}
@@ -0,0 +1,44 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.random.WhiteNoiseSampler;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.world.flora.Flora;
import com.dfsek.terra.world.population.items.flora.FloraLayer;
@SuppressWarnings("FieldMayBeFinal")
public class FloraLayerTemplate implements ObjectTemplate<FloraLayer> {
@Value("density")
private MetaValue<Double> density;
@Value("y")
private MetaValue<Range> range;
@Value("items")
private ProbabilityCollection<Flora> items;
@Value("distribution")
@Default
private MetaValue<NoiseSeeded> sampler = MetaValue.of(new NoiseSeeded() {
@Override
public NoiseSampler apply(Long seed) {
return new WhiteNoiseSampler(seed.intValue());
}
@Override
public int getDimensions() {
return 2;
}
});
@Override
public FloraLayer get() {
return new FloraLayer(density.get(), range.get(), items, sampler.get().apply(2403L));
}
}
@@ -1,17 +0,0 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.math.GridSpawn;
import java.lang.reflect.Type;
import java.util.Map;
@SuppressWarnings("unchecked")
public class GridSpawnLoader implements TypeLoader<GridSpawn> {
@Override
public GridSpawn load(Type type, Object o, ConfigLoader configLoader) {
Map<String, Integer> map = (Map<String, Integer>) o;
return new GridSpawn(map.get("width"), map.get("padding"), map.getOrDefault("salt", 0));
}
}
@@ -0,0 +1,25 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.GridSpawn;
@SuppressWarnings("FieldMayBeFinal")
public class GridSpawnTemplate implements ObjectTemplate<GridSpawn> {
@Value("width")
private MetaValue<Integer> width;
@Value("padding")
private MetaValue<Integer> padding;
@Value("salt")
@Default
private MetaValue<Integer> salt = MetaValue.of(0);
@Override
public GridSpawn get() {
return new GridSpawn(width.get(), padding.get(), salt.get());
}
}
@@ -1,20 +0,0 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.world.population.items.ores.OreConfig;
import java.lang.reflect.Type;
import java.util.Map;
@SuppressWarnings("unchecked")
public class OreConfigLoader implements TypeLoader<OreConfig> {
@Override
public OreConfig load(Type type, Object o, ConfigLoader configLoader) {
Map<String, Integer> map = (Map<String, Integer>) o;
Range amount = new Range(map.get("min"), map.get("max"));
Range height = new Range(map.get("min-height"), map.get("max-height"));
return new OreConfig(amount, height);
}
}
@@ -0,0 +1,27 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.world.population.items.ores.OreConfig;
@SuppressWarnings("unused")
public class OreConfigTemplate implements ObjectTemplate<OreConfig> {
@Value("min")
private MetaValue<Integer> min;
@Value("max")
private MetaValue<Integer> max;
@Value("min-height")
private MetaValue<Integer> minHeight;
@Value("max-height")
private MetaValue<Integer> maxHeight;
@Override
public OreConfig get() {
return new OreConfig(new Range(min.get(), max.get()), new Range(minHeight.get(), maxHeight.get()));
}
}
@@ -1,34 +0,0 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.math.noise.samplers.noise.random.WhiteNoiseSampler;
import com.dfsek.terra.api.platform.world.Tree;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.loaders.Types;
import com.dfsek.terra.world.population.items.tree.TreeLayer;
import java.lang.reflect.Type;
import java.util.Map;
@SuppressWarnings("unchecked")
public class TreeLayerLoader implements TypeLoader<TreeLayer> {
@Override
public TreeLayer load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
Map<String, Object> map = (Map<String, Object>) o;
double density = ((Number) map.get("density")).doubleValue();
Range range = configLoader.loadClass(Range.class, map.get("y"));
if(range == null) throw new LoadException("Tree range unspecified");
ProbabilityCollection<Tree> items = (ProbabilityCollection<Tree>) configLoader.loadType(Types.TREE_PROBABILITY_COLLECTION_TYPE, map.get("items"));
if(map.containsKey("distribution")) {
NoiseSeeded noise = configLoader.loadClass(NoiseSeeded.class, map.get("distribution"));
return new TreeLayer(density, range, items, noise.apply(2403L));
}
return new TreeLayer(density, range, items, new WhiteNoiseSampler(2403));
}
}
@@ -0,0 +1,44 @@
package com.dfsek.terra.config.loaders.config;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.random.WhiteNoiseSampler;
import com.dfsek.terra.api.platform.world.Tree;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.world.population.items.tree.TreeLayer;
@SuppressWarnings({"FieldMayBeFinal", "unused"})
public class TreeLayerTemplate implements ObjectTemplate<TreeLayer> {
@Value("density")
private MetaValue<Double> density;
@Value("y")
private MetaValue<Range> range;
@Value("items")
private ProbabilityCollection<Tree> items;
@Value("distribution")
@Default
private MetaValue<NoiseSeeded> sampler = MetaValue.of(new NoiseSeeded() {
@Override
public NoiseSampler apply(Long seed) {
return new WhiteNoiseSampler(seed.intValue());
}
@Override
public int getDimensions() {
return 2;
}
});
@Override
public TreeLayer get() {
return new TreeLayer(density.get(), range.get(), items, sampler.get().apply(2403L));
}
}
@@ -3,6 +3,7 @@ package com.dfsek.terra.config.loaders.config.biome.templates.provider;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.seeded.SourceSeeded;
import com.dfsek.terra.api.util.seeded.StageSeeded;
import com.dfsek.terra.api.world.biome.pipeline.BiomePipeline;
@@ -16,13 +17,13 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
private final TerraPlugin main;
@Value("pipeline.initial-size")
@Default
private int initialSize = 2;
private MetaValue<Integer> initialSize = MetaValue.of(2);
@Value("pipeline.stages")
private List<StageSeeded> stages;
private List<MetaValue<StageSeeded>> stages;
@Value("pipeline.source")
private SourceSeeded source;
private MetaValue<SourceSeeded> source;
public BiomePipelineTemplate(TerraPlugin main) {
this.main = main;
@@ -30,9 +31,9 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
@Override
public BiomeProvider build(long seed) {
BiomePipeline.BiomePipelineBuilder biomePipelineBuilder = new BiomePipeline.BiomePipelineBuilder(initialSize);
stages.forEach(biomePipelineBuilder::addStage);
BiomePipeline pipeline = biomePipelineBuilder.build(source.apply(seed), seed);
return new StandardBiomeProvider(pipeline, main, resolution, blend.apply(seed), blendAmp, (int) seed);
BiomePipeline.BiomePipelineBuilder biomePipelineBuilder = new BiomePipeline.BiomePipelineBuilder(initialSize.get());
stages.stream().map(MetaValue::get).forEach(biomePipelineBuilder::addStage);
BiomePipeline pipeline = biomePipelineBuilder.build(source.get().apply(seed), seed);
return new StandardBiomeProvider(pipeline, main, resolution.get(), blend.get().apply(seed), blendAmp.get(), (int) seed);
}
}
@@ -3,6 +3,7 @@ package com.dfsek.terra.config.loaders.config.biome.templates.provider;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.ConstantSampler;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
@@ -11,10 +12,11 @@ import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvider.BiomeProviderBuilder>, BiomeProvider.BiomeProviderBuilder {
@Value("resolution")
@Default
protected int resolution = 1;
protected MetaValue<Integer> resolution = MetaValue.of(1);
@Value("blend.noise")
@Default
protected NoiseSeeded blend = new NoiseSeeded() {
protected MetaValue<NoiseSeeded> blend = MetaValue.of(new NoiseSeeded() {
@Override
public NoiseSampler apply(Long seed) {
return new ConstantSampler(0);
@@ -24,12 +26,14 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
public int getDimensions() {
return 2;
}
};
});
@Value("blend.amplitude")
@Default
protected double blendAmp = 0d;
protected MetaValue<Double> blendAmp = MetaValue.of(0d);
@Value("type")
BiomeProvider.Type type;
protected MetaValue<BiomeProvider.Type> type;
@Override
public BiomeProvider.BiomeProviderBuilder get() {
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.biome.templates.provider;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.registry.Registry;
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
import com.dfsek.terra.api.world.biome.provider.ImageBiomeProvider;
@@ -9,13 +10,14 @@ import com.dfsek.terra.config.builder.BiomeBuilder;
import java.awt.image.BufferedImage;
import java.util.stream.Collectors;
@SuppressWarnings("unused")
public class ImageProviderTemplate extends BiomeProviderTemplate {
private final Registry<BiomeBuilder> biomes;
@Value("image.name")
private BufferedImage image;
private MetaValue<BufferedImage> image;
@Value("image.align")
private ImageBiomeProvider.Align align;
private MetaValue<ImageBiomeProvider.Align> align;
public ImageProviderTemplate(Registry<BiomeBuilder> set) {
this.biomes = set;
@@ -23,6 +25,6 @@ public class ImageProviderTemplate extends BiomeProviderTemplate {
@Override
public BiomeProvider build(long seed) {
return new ImageBiomeProvider(biomes.entries().stream().map(biomeBuilder -> biomeBuilder.apply(seed)).collect(Collectors.toSet()), image, resolution, align);
return new ImageBiomeProvider(biomes.entries().stream().map(biomeBuilder -> biomeBuilder.apply(seed)).collect(Collectors.toSet()), image.get(), resolution.get(), align.get());
}
}
@@ -1,19 +1,21 @@
package com.dfsek.terra.config.loaders.config.biome.templates.provider;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
import com.dfsek.terra.api.world.biome.provider.SingleBiomeProvider;
import com.dfsek.terra.config.builder.BiomeBuilder;
@SuppressWarnings("unused")
public class SingleBiomeProviderTemplate extends BiomeProviderTemplate {
@Value("biome")
private BiomeBuilder biome;
private MetaValue<BiomeBuilder> biome;
public SingleBiomeProviderTemplate() {
}
@Override
public BiomeProvider build(long seed) {
return new SingleBiomeProvider(biome.apply(seed));
return new SingleBiomeProvider(biome.get().apply(seed));
}
}
@@ -1,21 +1,23 @@
package com.dfsek.terra.config.loaders.config.biome.templates.source;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.world.biome.pipeline.source.BiomeSource;
import com.dfsek.terra.api.world.biome.pipeline.source.RandomSource;
import com.dfsek.terra.config.builder.BiomeBuilder;
@SuppressWarnings("unused")
public class NoiseSourceTemplate extends SourceTemplate {
@Value("noise")
private NoiseSeeded noise;
private MetaValue<NoiseSeeded> noise;
@Value("biomes")
private ProbabilityCollection<BiomeBuilder> biomes;
private ProbabilityCollection<MetaValue<BiomeBuilder>> biomes;
@Override
public BiomeSource apply(Long seed) {
return new RandomSource(biomes.map((biome) -> biome.apply(seed), false), noise.apply(seed));
return new RandomSource(biomes.map((biome) -> biome.get().apply(seed), false), noise.get().apply(seed));
}
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.biome.templates.stage;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.util.seeded.SeededBuilder;
import com.dfsek.terra.api.util.seeded.StageSeeded;
@@ -9,7 +10,7 @@ import com.dfsek.terra.api.world.biome.pipeline.stages.Stage;
public abstract class StageTemplate implements ObjectTemplate<SeededBuilder<Stage>>, StageSeeded {
@Value("noise")
protected NoiseSeeded noise;
protected MetaValue<NoiseSeeded> noise;
@Override
public StageSeeded get() {
@@ -8,6 +8,6 @@ import com.dfsek.terra.config.loaders.config.biome.templates.stage.StageTemplate
public class ExpanderStageTemplate extends StageTemplate {
@Override
public Stage apply(Long seed) {
return new ExpanderStage(new FractalExpander(noise.apply(seed)));
return new ExpanderStage(new FractalExpander(noise.get().apply(seed)));
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.biome.templates.stage.mutator;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
@@ -13,24 +14,24 @@ import java.util.Map;
@SuppressWarnings("unused")
public class BorderListMutatorTemplate extends MutatorStageTemplate {
@Value("from")
private String from;
private MetaValue<String> from;
@Value("default-replace")
private String defaultReplace;
private MetaValue<String> defaultReplace;
@Value("default-to")
private ProbabilityCollection<BiomeBuilder> defaultTo;
private ProbabilityCollection<MetaValue<BiomeBuilder>> defaultTo;
@Value("replace")
private Map<BiomeBuilder, ProbabilityCollection<BiomeBuilder>> replace;
private Map<BiomeBuilder, ProbabilityCollection<MetaValue<BiomeBuilder>>> replace;
@Override
public BiomeMutator build(long seed) {
Map<TerraBiome, ProbabilityCollection<TerraBiome>> replaceMap = new HashMap<>();
replace.forEach((keyBuilder, replacements) -> replaceMap.put(keyBuilder.apply(seed), replacements.map(replacement -> replacement.apply(seed), true)));
replace.forEach((keyBuilder, replacements) -> replaceMap.put(keyBuilder.apply(seed), replacements.map(MetaValue::get).map(replacement -> replacement.apply(seed))));
return new BorderListMutator(replaceMap, from, defaultReplace, noise.apply(seed), defaultTo.map(biomeBuilder -> biomeBuilder.apply(seed), true));
return new BorderListMutator(replaceMap, from.get(), defaultReplace.get(), noise.get().apply(seed), defaultTo.map(MetaValue::get).map(biomeBuilder -> biomeBuilder.apply(seed)));
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.biome.templates.stage.mutator;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
import com.dfsek.terra.api.world.biome.pipeline.mutator.BorderMutator;
@@ -9,16 +10,16 @@ import com.dfsek.terra.config.builder.BiomeBuilder;
@SuppressWarnings("unused")
public class BorderMutatorTemplate extends MutatorStageTemplate {
@Value("from")
private String from;
private MetaValue<String> from;
@Value("replace")
private String replace;
private MetaValue<String> replace;
@Value("to")
private ProbabilityCollection<BiomeBuilder> to;
private ProbabilityCollection<MetaValue<BiomeBuilder>> to;
@Override
public BiomeMutator build(long seed) {
return new BorderMutator(from, replace, noise.apply(seed), to.map(biomeBuilder -> biomeBuilder.apply(seed), true));
return new BorderMutator(from.get(), replace.get(), noise.get().apply(seed), to.map(MetaValue::get).map(biomeBuilder -> biomeBuilder.apply(seed)));
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.biome.templates.stage.mutator;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
@@ -13,20 +14,20 @@ import java.util.Map;
@SuppressWarnings("unused")
public class ReplaceListMutatorTemplate extends MutatorStageTemplate {
@Value("default-from")
private String defaultFrom;
private MetaValue<String> defaultFrom;
@Value("default-to")
private ProbabilityCollection<BiomeBuilder> defaultTo;
private ProbabilityCollection<MetaValue<BiomeBuilder>> defaultTo;
@Value("to")
private Map<BiomeBuilder, ProbabilityCollection<BiomeBuilder>> replace;
private Map<BiomeBuilder, ProbabilityCollection<MetaValue<BiomeBuilder>>> replace;
@Override
public BiomeMutator build(long seed) {
Map<TerraBiome, ProbabilityCollection<TerraBiome>> replaceMap = new HashMap<>();
replace.forEach((biomeBuilder, biomeBuilders) -> replaceMap.put(biomeBuilder.apply(seed), biomeBuilders.map(builder -> builder.apply(seed), true)));
replace.forEach((biomeBuilder, biomeBuilders) -> replaceMap.put(biomeBuilder.apply(seed), biomeBuilders.map(MetaValue::get).map(builder -> builder.apply(seed))));
return new ReplaceListMutator(replaceMap, defaultFrom, defaultTo.map(biomeBuilder -> biomeBuilder.apply(seed), true), noise.apply(seed));
return new ReplaceListMutator(replaceMap, defaultFrom.get(), defaultTo.map(MetaValue::get).map(biomeBuilder -> biomeBuilder.apply(seed)), noise.get().apply(seed));
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.biome.templates.stage.mutator;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.pipeline.mutator.BiomeMutator;
import com.dfsek.terra.api.world.biome.pipeline.mutator.ReplaceMutator;
@@ -9,13 +10,13 @@ import com.dfsek.terra.config.builder.BiomeBuilder;
@SuppressWarnings("unused")
public class ReplaceMutatorTemplate extends MutatorStageTemplate {
@Value("from")
private String from;
private MetaValue<String> from;
@Value("to")
private ProbabilityCollection<BiomeBuilder> to;
private ProbabilityCollection<MetaValue<BiomeBuilder>> to;
@Override
public BiomeMutator build(long seed) {
return new ReplaceMutator(from, to.map(biomeBuilder -> biomeBuilder.apply(seed), true), noise.apply(seed));
return new ReplaceMutator(from.get(), to.map(MetaValue::get).map(biomeBuilder -> biomeBuilder.apply(seed)), noise.get().apply(seed));
}
}
@@ -6,6 +6,6 @@ import com.dfsek.terra.api.world.biome.pipeline.mutator.SmoothMutator;
public class SmoothMutatorTemplate extends MutatorStageTemplate {
@Override
public BiomeMutator build(long seed) {
return new SmoothMutator(noise.apply(seed));
return new SmoothMutator(noise.get().apply(seed));
}
}
@@ -1,17 +1,20 @@
package com.dfsek.terra.config.loaders.config.sampler;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.Configuration;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.registry.config.NoiseRegistry;
import java.lang.reflect.Type;
import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;
@SuppressWarnings("unchecked")
public class NoiseSamplerBuilderLoader implements TypeLoader<NoiseSeeded> {
@@ -25,11 +28,26 @@ public class NoiseSamplerBuilderLoader implements TypeLoader<NoiseSeeded> {
public NoiseSeeded load(Type t, Object c, ConfigLoader loader) throws LoadException {
Map<String, Object> map = (Map<String, Object>) c;
try {
ObjectTemplate<NoiseSeeded> normalizerTemplate = noiseRegistry.get(((String) map.get("type")).toUpperCase(Locale.ROOT)).get();
loader.load(normalizerTemplate, new Configuration(map));
Template typeTemplate = new Template();
Configuration configuration = new Configuration(map);
loader.load(typeTemplate, configuration);
ObjectTemplate<NoiseSeeded> normalizerTemplate = typeTemplate.get().get();
loader.load(normalizerTemplate, configuration);
return normalizerTemplate.get();
} catch(ConfigException e) {
throw new LoadException("Unable to load noise function: ", e);
}
}
@SuppressWarnings("unused")
private class Template implements ObjectTemplate<Supplier<ObjectTemplate<NoiseSeeded>>> {
@Value("type")
private MetaValue<String> type;
@Override
public Supplier<ObjectTemplate<NoiseSeeded>> get() {
return noiseRegistry.get(type.get().toUpperCase(Locale.ROOT));
}
}
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.sampler.templates;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.DomainWarpedSampler;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
@@ -9,21 +10,21 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class DomainWarpTemplate extends SamplerTemplate<DomainWarpedSampler> {
@Value("warp")
private NoiseSeeded warp;
private MetaValue<NoiseSeeded> warp;
@Value("function")
private NoiseSeeded function;
private MetaValue<NoiseSeeded> function;
@Value("salt")
@Default
private int salt = 0;
private MetaValue<Integer> salt = MetaValue.of(0);
@Value("amplitude")
@Default
private double amplitude = 1;
private MetaValue<Double> amplitude = MetaValue.of(1d);
@Override
public NoiseSampler apply(Long seed) {
return new DomainWarpedSampler(function.apply(seed), warp.apply(seed), (int) (seed + salt), amplitude);
return new DomainWarpedSampler(function.get().apply(seed), warp.get().apply(seed), (int) (seed + salt.get()), amplitude.get());
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.sampler.templates;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.ImageSampler;
@@ -10,16 +11,16 @@ import java.awt.image.BufferedImage;
public class ImageSamplerTemplate extends SamplerTemplate<ImageSampler> {
@Value("image")
private BufferedImage image;
private MetaValue<BufferedImage> image;
@Value("frequency")
private double frequency;
private MetaValue<Double> frequency;
@Value("channel")
private ImageSampler.Channel channel;
private MetaValue<ImageSampler.Channel> channel;
@Override
public NoiseSampler apply(Long seed) {
return new ImageSampler(image, channel, frequency);
return new ImageSampler(image.get(), channel.get(), frequency.get());
}
}
@@ -4,6 +4,7 @@ import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
import com.dfsek.tectonic.exception.ValidationException;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.KernelSampler;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
@@ -14,18 +15,18 @@ import java.util.List;
public class KernelTemplate extends SamplerTemplate<KernelSampler> implements ValidatedConfigTemplate {
@Value("kernel")
private List<List<Double>> kernel;
private List<List<MetaValue<Double>>> kernel;
@Value("factor")
@Default
private double factor = 1;
private MetaValue<Double> factor = MetaValue.of(1d);
@Value("function")
private NoiseSeeded function;
private MetaValue<NoiseSeeded> function;
@Value("frequency")
@Default
private double frequency = 1;
private MetaValue<Double> frequency = MetaValue.of(1d);
@Override
public NoiseSampler apply(Long seed) {
@@ -33,12 +34,12 @@ public class KernelTemplate extends SamplerTemplate<KernelSampler> implements Va
for(int x = 0; x < kernel.size(); x++) {
for(int y = 0; y < kernel.get(x).size(); y++) {
k[x][y] = kernel.get(x).get(y) * factor;
k[x][y] = kernel.get(x).get(y).get() * factor.get();
}
}
KernelSampler sampler = new KernelSampler(k, function.apply(seed));
sampler.setFrequency(frequency);
KernelSampler sampler = new KernelSampler(k, function.get().apply(seed));
sampler.setFrequency(frequency.get());
return sampler;
}
@@ -5,6 +5,7 @@ import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
import com.dfsek.tectonic.exception.ValidationException;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
@@ -12,15 +13,15 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
public abstract class SamplerTemplate<T extends NoiseSampler> implements ValidatedConfigTemplate, ObjectTemplate<NoiseSeeded>, NoiseSeeded {
@Value("dimensions")
@Default
private int dimensions = 2;
private MetaValue<Integer> dimensions = MetaValue.of(2);
public int getDimensions() {
return dimensions;
return dimensions.get();
}
@Override
public boolean validate() throws ValidationException {
if(dimensions != 2 && dimensions != 3) throw new ValidationException("Illegal amount of dimensions: " + dimensions);
if(dimensions.get() != 2 && dimensions.get() != 3) throw new ValidationException("Illegal amount of dimensions: " + dimensions);
return true;
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.noise;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.CellularSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.simplex.OpenSimplex2Sampler;
@@ -11,20 +12,20 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
public class CellularNoiseTemplate extends NoiseTemplate<CellularSampler> {
@Value("distance")
@Default
private CellularSampler.DistanceFunction cellularDistanceFunction = CellularSampler.DistanceFunction.EuclideanSq;
private MetaValue<CellularSampler.DistanceFunction> cellularDistanceFunction = MetaValue.of(CellularSampler.DistanceFunction.EuclideanSq);
@Value("return")
@Default
private CellularSampler.ReturnType cellularReturnType = CellularSampler.ReturnType.Distance;
private MetaValue<CellularSampler.ReturnType> cellularReturnType = MetaValue.of(CellularSampler.ReturnType.Distance);
@Value("jitter")
@Default
private double cellularJitter = 1.0D;
private MetaValue<Double> cellularJitter = MetaValue.of(1.0D);
@Value("lookup")
@Default
private NoiseSeeded lookup = new NoiseSeeded() {
private MetaValue<NoiseSeeded> lookup = MetaValue.of(new NoiseSeeded() {
@Override
public NoiseSampler apply(Long seed) {
@@ -35,16 +36,16 @@ public class CellularNoiseTemplate extends NoiseTemplate<CellularSampler> {
public int getDimensions() {
return 2;
}
};
});
@Override
public NoiseSampler apply(Long seed) {
CellularSampler sampler = new CellularSampler((int) (long) seed + salt);
sampler.setNoiseLookup(lookup.apply(seed));
sampler.setFrequency(frequency);
sampler.setJitterModifier(cellularJitter);
sampler.setReturnType(cellularReturnType);
sampler.setDistanceFunction(cellularDistanceFunction);
CellularSampler sampler = new CellularSampler((int) (long) seed + salt.get());
sampler.setNoiseLookup(lookup.get().apply(seed));
sampler.setFrequency(frequency.get());
sampler.setJitterModifier(cellularJitter.get());
sampler.setReturnType(cellularReturnType.get());
sampler.setDistanceFunction(cellularDistanceFunction.get());
return sampler;
}
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.noise;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.ConstantSampler;
import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
@@ -10,10 +11,10 @@ import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
public class ConstantNoiseTemplate extends SamplerTemplate<ConstantSampler> {
@Value("value")
@Default
private double value = 0d;
private MetaValue<Double> value = MetaValue.of(0d);
@Override
public NoiseSampler apply(Long seed) {
return new ConstantSampler(value);
return new ConstantSampler(value.get());
}
}
@@ -8,12 +8,13 @@ import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
import com.dfsek.tectonic.exception.ValidationException;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.ExpressionFunction;
import com.dfsek.terra.api.math.paralithic.BlankFunction;
import com.dfsek.terra.api.math.paralithic.defined.UserDefinedFunction;
import com.dfsek.terra.api.math.paralithic.noise.NoiseFunction2;
import com.dfsek.terra.api.math.paralithic.noise.NoiseFunction3;
import com.dfsek.terra.api.util.MapUtil;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.loaders.config.function.FunctionTemplate;
import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
@@ -27,24 +28,24 @@ import java.util.Map;
public class ExpressionFunctionTemplate extends SamplerTemplate<ExpressionFunction> implements ValidatedConfigTemplate {
@Value("variables")
@Default
private Map<String, Double> vars = new HashMap<>();
private Map<String, MetaValue<Double>> vars = new HashMap<>();
@Value("equation")
private String equation;
private MetaValue<String> equation;
@Value("functions")
@Default
private LinkedHashMap<String, NoiseSeeded> functions = new LinkedHashMap<>();
private LinkedHashMap<String, MetaValue<NoiseSeeded>> functions = new LinkedHashMap<>();
@Value("expressions")
@Default
private LinkedHashMap<String, FunctionTemplate> expressions = new LinkedHashMap<>();
private LinkedHashMap<String, MetaValue<FunctionTemplate>> expressions = new LinkedHashMap<>();
@Override
public NoiseSampler apply(Long seed) {
try {
Map<String, Function> noiseFunctionMap = generateFunctions(seed);
return new ExpressionFunction(noiseFunctionMap, equation, vars);
return new ExpressionFunction(noiseFunctionMap, equation.get(), MapUtil.remapValues(MetaValue::get, vars));
} catch(ParseException e) {
throw new IllegalStateException(e);
}
@@ -54,7 +55,7 @@ public class ExpressionFunctionTemplate extends SamplerTemplate<ExpressionFuncti
public boolean validate() throws ValidationException {
try {
Map<String, Function> noiseFunctionMap = generateFunctions(0L);
new ExpressionFunction(noiseFunctionMap, equation, vars);
new ExpressionFunction(noiseFunctionMap, equation.get(), MapUtil.remapValues(MetaValue::get, vars));
} catch(ParseException e) {
throw new ValidationException("Errors occurred while parsing noise equation: ", e);
}
@@ -64,14 +65,14 @@ public class ExpressionFunctionTemplate extends SamplerTemplate<ExpressionFuncti
private Map<String, Function> generateFunctions(Long seed) throws ParseException {
Map<String, Function> noiseFunctionMap = new HashMap<>();
for(Map.Entry<String, FunctionTemplate> entry : expressions.entrySet()) {
for(Map.Entry<String, FunctionTemplate> entry : MapUtil.remapValues(MetaValue::get, expressions).entrySet()) {
noiseFunctionMap.put(entry.getKey(), UserDefinedFunction.newInstance(entry.getValue(), new Parser(), new Scope()));
}
functions.forEach((id, function) -> {
if(function.getDimensions() == 2) {
noiseFunctionMap.put(id, new NoiseFunction2(function.apply(seed)));
} else noiseFunctionMap.put(id, new NoiseFunction3(function.apply(seed)));
if(function.get().getDimensions() == 2) {
noiseFunctionMap.put(id, new NoiseFunction2(function.get().apply(seed)));
} else noiseFunctionMap.put(id, new NoiseFunction3(function.get().apply(seed)));
});
return noiseFunctionMap;
@@ -2,39 +2,41 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.noise;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.samplers.noise.GaborNoiseSampler;
@SuppressWarnings("FieldMayBeFinal")
public class GaborNoiseTemplate extends NoiseTemplate<GaborNoiseSampler> {
@Value("rotation")
@Default
private double rotation = 0.25;
private MetaValue<Double> rotation = MetaValue.of(0.25);
@Value("isotropic")
@Default
private boolean isotropic = true;
private MetaValue<Boolean> isotropic = MetaValue.of(true);
@Value("deviation")
@Default
private double deviation = 1.0;
private MetaValue<Double> deviation = MetaValue.of(1.0);
@Value("impulses")
@Default
private double impulses = 64d;
private MetaValue<Double> impulses = MetaValue.of(64d);
@Value("frequency_0")
@Default
private double f0 = 0.625;
private MetaValue<Double> f0 = MetaValue.of(0.625);
@Override
public NoiseSampler apply(Long seed) {
GaborNoiseSampler gaborNoiseSampler = new GaborNoiseSampler((int) (long) seed + salt);
gaborNoiseSampler.setFrequency(frequency);
gaborNoiseSampler.setRotation(rotation);
gaborNoiseSampler.setIsotropic(isotropic);
gaborNoiseSampler.setDeviation(deviation);
gaborNoiseSampler.setImpulsesPerKernel(impulses);
gaborNoiseSampler.setFrequency0(f0);
GaborNoiseSampler gaborNoiseSampler = new GaborNoiseSampler((int) (long) seed + salt.get());
gaborNoiseSampler.setFrequency(frequency.get());
gaborNoiseSampler.setRotation(rotation.get());
gaborNoiseSampler.setIsotropic(isotropic.get());
gaborNoiseSampler.setDeviation(deviation.get());
gaborNoiseSampler.setImpulsesPerKernel(impulses.get());
gaborNoiseSampler.setFrequency0(f0.get());
return gaborNoiseSampler;
}
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.noise;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.samplers.noise.NoiseFunction;
import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
@@ -9,9 +10,9 @@ import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
public abstract class NoiseTemplate<T extends NoiseFunction> extends SamplerTemplate<T> {
@Value("frequency")
@Default
protected double frequency = 0.02d;
protected MetaValue<Double> frequency = MetaValue.of(0.02d);
@Value("salt")
@Default
protected int salt = 0;
protected MetaValue<Integer> salt = MetaValue.of(0);
}
@@ -14,8 +14,8 @@ public class SimpleNoiseTemplate extends NoiseTemplate<NoiseFunction> {
@Override
public NoiseSampler apply(Long seed) {
NoiseFunction sampler = samplerSupplier.apply((int) (long) seed + salt);
sampler.setFrequency(frequency);
NoiseFunction sampler = samplerSupplier.apply((int) (long) seed + salt.get());
sampler.setFrequency(frequency.get());
return sampler;
}
}
@@ -6,11 +6,11 @@ import com.dfsek.terra.api.math.noise.samplers.noise.fractal.BrownianMotionSampl
public class BrownianMotionTemplate extends FractalTemplate<BrownianMotionSampler> {
@Override
public NoiseSampler apply(Long seed) {
BrownianMotionSampler sampler = new BrownianMotionSampler((int) (long) seed, function.apply(seed));
sampler.setGain(fractalGain);
sampler.setLacunarity(fractalLacunarity);
sampler.setOctaves(octaves);
sampler.setWeightedStrength(weightedStrength);
BrownianMotionSampler sampler = new BrownianMotionSampler((int) (long) seed, function.get().apply(seed));
sampler.setGain(fractalGain.get());
sampler.setLacunarity(fractalLacunarity.get());
sampler.setOctaves(octaves.get());
sampler.setWeightedStrength(weightedStrength.get());
return sampler;
}
}
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.noise.fractal;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.samplers.noise.fractal.FractalNoiseFunction;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
@@ -9,20 +10,20 @@ import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
public abstract class FractalTemplate<T extends FractalNoiseFunction> extends SamplerTemplate<T> {
@Value("octaves")
@Default
protected int octaves = 3;
protected MetaValue<Integer> octaves = MetaValue.of(3);
@Value("gain")
@Default
protected double fractalGain = 0.5D;
protected MetaValue<Double> fractalGain = MetaValue.of(0.5D);
@Value("lacunarity")
@Default
protected double fractalLacunarity = 2.0D;
protected MetaValue<Double> fractalLacunarity = MetaValue.of(2.0D);
@Value("weighted-strength")
@Default
protected double weightedStrength = 0.0D;
protected MetaValue<Double> weightedStrength = MetaValue.of(0.0D);
@Value("function")
protected NoiseSeeded function;
protected MetaValue<NoiseSeeded> function;
}
@@ -12,11 +12,11 @@ public class PingPongTemplate extends FractalTemplate<PingPongSampler> {
@Override
public NoiseSampler apply(Long seed) {
PingPongSampler sampler = new PingPongSampler((int) (long) seed, function.apply(seed));
sampler.setGain(fractalGain);
sampler.setLacunarity(fractalLacunarity);
sampler.setOctaves(octaves);
sampler.setWeightedStrength(weightedStrength);
PingPongSampler sampler = new PingPongSampler((int) (long) seed, function.get().apply(seed));
sampler.setGain(fractalGain.get());
sampler.setLacunarity(fractalLacunarity.get());
sampler.setOctaves(octaves.get());
sampler.setWeightedStrength(weightedStrength.get());
sampler.setPingPongStrength(pingPong);
return sampler;
}
@@ -6,11 +6,11 @@ import com.dfsek.terra.api.math.noise.samplers.noise.fractal.RidgedFractalSample
public class RidgedFractalTemplate extends FractalTemplate<RidgedFractalSampler> {
@Override
public NoiseSampler apply(Long seed) {
RidgedFractalSampler sampler = new RidgedFractalSampler((int) (long) seed, function.apply(seed));
sampler.setGain(fractalGain);
sampler.setLacunarity(fractalLacunarity);
sampler.setOctaves(octaves);
sampler.setWeightedStrength(weightedStrength);
RidgedFractalSampler sampler = new RidgedFractalSampler((int) (long) seed, function.get().apply(seed));
sampler.setGain(fractalGain.get());
sampler.setLacunarity(fractalLacunarity.get());
sampler.setOctaves(octaves.get());
sampler.setWeightedStrength(weightedStrength.get());
return sampler;
}
}
@@ -1,6 +1,7 @@
package com.dfsek.terra.config.loaders.config.sampler.templates.normalizer;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.normalizer.ClampNormalizer;
import com.dfsek.terra.api.math.noise.normalizer.LinearNormalizer;
@@ -8,13 +9,13 @@ import com.dfsek.terra.api.math.noise.normalizer.LinearNormalizer;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class ClampNormalizerTemplate extends NormalizerTemplate<LinearNormalizer> {
@Value("max")
private double max;
private MetaValue<Double> max;
@Value("min")
private double min;
private MetaValue<Double> min;
@Override
public NoiseSampler apply(Long seed) {
return new ClampNormalizer(function.apply(seed), min, max);
return new ClampNormalizer(function.get().apply(seed), min.get(), max.get());
}
}
@@ -1,19 +1,20 @@
package com.dfsek.terra.config.loaders.config.sampler.templates.normalizer;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.normalizer.LinearNormalizer;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class LinearNormalizerTemplate extends NormalizerTemplate<LinearNormalizer> {
@Value("max")
private double max;
private MetaValue<Double> max;
@Value("min")
private double min;
private MetaValue<Double> min;
@Override
public NoiseSampler apply(Long seed) {
return new LinearNormalizer(function.apply(seed), min, max);
return new LinearNormalizer(function.get().apply(seed), min.get(), max.get());
}
}
@@ -2,23 +2,24 @@ package com.dfsek.terra.config.loaders.config.sampler.templates.normalizer;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.NoiseSampler;
import com.dfsek.terra.api.math.noise.normalizer.NormalNormalizer;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class NormalNormalizerTemplate extends NormalizerTemplate<NormalNormalizer> {
@Value("mean")
private double mean;
private MetaValue<Double> mean;
@Value("standard-deviation")
private double stdDev;
private MetaValue<Double> stdDev;
@Value("groups")
@Default
private int groups = 16384;
private MetaValue<Integer> groups = MetaValue.of(16384);
@Override
public NoiseSampler apply(Long seed) {
return new NormalNormalizer(function.apply(seed), groups, mean, stdDev);
return new NormalNormalizer(function.get().apply(seed), groups.get(), mean.get(), stdDev.get());
}
}
@@ -1,11 +1,12 @@
package com.dfsek.terra.config.loaders.config.sampler.templates.normalizer;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.math.noise.normalizer.Normalizer;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.loaders.config.sampler.templates.SamplerTemplate;
public abstract class NormalizerTemplate<T extends Normalizer> extends SamplerTemplate<T> {
@Value("function")
protected NoiseSeeded function;
protected MetaValue<NoiseSeeded> function;
}
@@ -0,0 +1,37 @@
package com.dfsek.terra.config.loaders.meta;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.terra.api.config.meta.MetaContext;
import com.dfsek.terra.api.config.meta.MetaValue;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, Object> {
public GenericMetaValueLoader(MetaContext context) {
super(context);
}
@Override
public MetaValue<Object> load(Type type, Object c, ConfigLoader loader) throws LoadException {
if(type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
Type generic = pType.getActualTypeArguments()[0];
if(c instanceof String) {
String possibleMeta = (String) c;
if(possibleMeta.startsWith("$")) {
String meta = possibleMeta.substring(1);
return MetaValue.of(context.load(meta, generic));
}
}
return MetaValue.of(loader.loadType(generic, c));
} else throw new LoadException("Unable to load config! Could not retrieve parameterized type: " + type);
}
@Override
public Object get() {
return null;
}
}
@@ -0,0 +1,26 @@
package com.dfsek.terra.config.loaders.meta;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.terra.api.config.meta.MetaContext;
import com.dfsek.terra.api.config.meta.type.MetaList;
import com.dfsek.terra.api.util.GlueList;
import java.lang.reflect.Type;
import java.util.List;
public class MetaListLoader extends MetaValueLoader<MetaList<Object>, List<Object>> {
protected MetaListLoader(MetaContext context) {
super(context);
}
@Override
public MetaList<Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
return null;
}
@Override
public List<Object> get() {
return new GlueList<>();
}
}
@@ -0,0 +1,26 @@
package com.dfsek.terra.config.loaders.meta;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.terra.api.config.meta.MetaContext;
import com.dfsek.terra.api.config.meta.type.MetaMap;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
public class MetaMapLoader extends MetaValueLoader<MetaMap<Object, Object>, Map<Object, Object>> {
public MetaMapLoader(MetaContext context) {
super(context);
}
@Override
public MetaMap<Object, Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
return null;
}
@Override
public Map<Object, Object> get() {
return new HashMap<>();
}
}
@@ -0,0 +1,15 @@
package com.dfsek.terra.config.loaders.meta;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.config.meta.MetaContext;
import com.dfsek.terra.api.config.meta.MetaValue;
import java.util.function.Supplier;
public abstract class MetaValueLoader<M extends MetaValue<T>, T> implements TypeLoader<M>, Supplier<T> {
protected final MetaContext context;
protected MetaValueLoader(MetaContext context) {
this.context = context;
}
}
@@ -1,46 +0,0 @@
package com.dfsek.terra.config.loaders.mod;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.platform.modloader.Mod;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class ModDependentConfigSection<T> {
private static final Object NULL = new Object(); // Null object
private final TerraPlugin main;
private final Map<String, T> results = new HashMap<>();
private final T defaultValue;
@SuppressWarnings("unchecked")
private T value = (T) NULL;
protected ModDependentConfigSection(TerraPlugin main, T defaultValue) {
this.main = main;
this.defaultValue = defaultValue;
}
public void add(String id, T value) {
results.put(id, value);
}
public static <T1> ModDependentConfigSection<T1> withDefault(T1 defaultValue) {
return new ModDependentConfigSection<>(null, defaultValue);
}
public T get() {
if(value == NULL) value = compute(); // Cache the value.
return value;
}
private T compute() {
if(main != null) {
Set<String> mods = main.getMods().stream().map(Mod::getID).collect(Collectors.toSet());
for(Map.Entry<String, T> entry : results.entrySet()) {
if(mods.contains(entry.getKey())) return entry.getValue();
}
}
return defaultValue;
}
}
@@ -1,43 +0,0 @@
package com.dfsek.terra.config.loaders.mod;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.TerraPlugin;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;
public class ModDependentConfigSectionLoader implements TypeLoader<ModDependentConfigSection<?>> {
private final TerraPlugin main;
public ModDependentConfigSectionLoader(TerraPlugin main) {
this.main = main;
}
@SuppressWarnings("unchecked")
@Override
public ModDependentConfigSection<?> load(Type type, Object c, ConfigLoader loader) throws LoadException {
if(type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
Type generic = pType.getActualTypeArguments()[0];
if(c instanceof Map && ((Map<?, ?>) c).containsKey("default")) {
Map<String, ?> map = (Map<String, ?>) c;
ModDependentConfigSection<Object> configSection = new ModDependentConfigSection<>(main, loader.loadType(generic, map.get("default")));
if(map.containsKey("mods")) {
for(Map.Entry<String, ?> modEntry : ((Map<String, ?>) map.get("mods")).entrySet()) {
configSection.add(modEntry.getKey(), loader.loadType(generic, modEntry.getValue()));
}
}
return configSection;
} else {
return ModDependentConfigSection.withDefault(loader.loadType(generic, c)); // Load the original type otherwise.
}
} else throw new LoadException("Unable to load config! Could not retrieve parameterized type: " + type);
}
}
@@ -10,6 +10,7 @@ import com.dfsek.tectonic.loading.TypeRegistry;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.LoaderRegistrar;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.event.events.config.ConfigPackPostLoadEvent;
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.platform.block.BlockData;
@@ -42,6 +43,8 @@ import com.dfsek.terra.config.loaders.config.biome.templates.provider.ImageProvi
import com.dfsek.terra.config.loaders.config.biome.templates.provider.SingleBiomeProviderTemplate;
import com.dfsek.terra.config.loaders.config.sampler.NoiseSamplerBuilderLoader;
import com.dfsek.terra.config.loaders.config.sampler.templates.ImageSamplerTemplate;
import com.dfsek.terra.config.loaders.meta.GenericMetaValueLoader;
import com.dfsek.terra.config.pack.meta.PackMetaContext;
import com.dfsek.terra.config.templates.AbstractableTemplate;
import com.dfsek.terra.config.templates.BiomeTemplate;
import com.dfsek.terra.config.templates.CarverTemplate;
@@ -115,6 +118,8 @@ public class ConfigPack implements LoaderRegistrar {
private final BiomeProvider.BiomeProviderBuilder biomeProviderBuilder;
private final PackMetaContext context;
public ConfigPack(File folder, TerraPlugin main) throws ConfigException {
try {
@@ -124,6 +129,9 @@ public class ConfigPack implements LoaderRegistrar {
floraRegistry = new FloraRegistry(main);
paletteRegistry = new PaletteRegistry(main);
treeRegistry = new TreeRegistry();
context = new PackMetaContext(loader, selfLoader);
register(abstractConfigLoader);
register(selfLoader);
@@ -138,7 +146,7 @@ public class ConfigPack implements LoaderRegistrar {
main.logger().info("Loading config pack \"" + template.getID() + "\"");
main.getEventManager().callEvent(new ConfigPackPreLoadEvent(this, template -> selfLoader.load(template, configuration), loader));
main.getEventManager().callEvent(new ConfigPackPreLoadEvent(this, template -> selfLoader.load(template, configuration)));
load(l, main);
@@ -165,6 +173,9 @@ public class ConfigPack implements LoaderRegistrar {
floraRegistry = new FloraRegistry(main);
paletteRegistry = new PaletteRegistry(main);
treeRegistry = new TreeRegistry();
context = new PackMetaContext(loader, selfLoader);
register(abstractConfigLoader);
register(selfLoader);
@@ -185,7 +196,7 @@ public class ConfigPack implements LoaderRegistrar {
selfLoader.load(template, configuration);
main.logger().info("Loading config pack \"" + template.getID() + "\"");
main.getEventManager().callEvent(new ConfigPackPreLoadEvent(this, template -> selfLoader.load(template, configuration), loader));
main.getEventManager().callEvent(new ConfigPackPreLoadEvent(this, template -> selfLoader.load(template, configuration)));
load(l, main);
@@ -253,7 +264,7 @@ public class ConfigPack implements LoaderRegistrar {
.open("flora", ".yml").then(configs -> buildAll(new FloraFactory(), floraRegistry, abstractConfigLoader.loadConfigs(configs, FloraTemplate::new), main)).close()
.open("biomes", ".yml").then(configs -> buildAll(new BiomeFactory(this), biomeRegistry, abstractConfigLoader.loadConfigs(configs, () -> new BiomeTemplate(this, main)), main)).close();
main.getEventManager().callEvent(new ConfigPackPostLoadEvent(this, template -> selfLoader.load(template, configuration), loader));
main.getEventManager().callEvent(new ConfigPackPostLoadEvent(this, template -> selfLoader.load(template, configuration)));
main.logger().info("Loaded config pack \"" + template.getID() + "\" v" + template.getVersion() + " by " + template.getAuthor() + " in " + (System.nanoTime() - start) / 1000000D + "ms.");
}
@@ -295,7 +306,8 @@ public class ConfigPack implements LoaderRegistrar {
.registerLoader(SingleBiomeProviderTemplate.class, SingleBiomeProviderTemplate::new)
.registerLoader(BiomePipelineTemplate.class, () -> new BiomePipelineTemplate(main))
.registerLoader(ImageProviderTemplate.class, () -> new ImageProviderTemplate(biomeRegistry))
.registerLoader(ImageSamplerTemplate.class, () -> new ImageProviderTemplate(biomeRegistry));
.registerLoader(ImageSamplerTemplate.class, () -> new ImageProviderTemplate(biomeRegistry))
.registerLoader(MetaValue.class, new GenericMetaValueLoader(context));
}
public Set<UserDefinedCarver> getCarvers() {
@@ -2,13 +2,14 @@ package com.dfsek.terra.config.pack;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
public class ConfigPackPostTemplate implements ConfigTemplate {
@Value("biomes")
private BiomeProvider.BiomeProviderBuilder providerBuilder;
private MetaValue<BiomeProvider.BiomeProviderBuilder> providerBuilder;
public BiomeProvider.BiomeProviderBuilder getProviderBuilder() {
return providerBuilder;
return providerBuilder.get();
}
}
@@ -4,24 +4,35 @@ import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.terra.api.addons.TerraAddon;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.MapUtil;
import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.loaders.config.function.FunctionTemplate;
import com.dfsek.terra.config.loaders.mod.ModDependentConfigSection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class ConfigPackTemplate implements ConfigTemplate {
@Value("id")
private String id;
@Value("version")
@Default
private String version = "0.1.0";
@Value("author")
@Default
private String author = "Anon Y. Mous";
@Value("noise")
private Map<String, NoiseSeeded> noiseBuilderMap;
private Map<String, MetaValue<NoiseSeeded>> noiseBuilderMap;
private final Lazy<Map<String, NoiseSeeded>> lazyNoiseBuilderMap = new Lazy<>(() -> MapUtil.remapValues(MetaValue::get, noiseBuilderMap));
@Value("addons")
@Default
@@ -29,71 +40,66 @@ public class ConfigPackTemplate implements ConfigTemplate {
@Value("variables")
@Default
private Map<String, Double> variables = new HashMap<>();
private Map<String, MetaValue<Double>> variables = new HashMap<>();
private final Lazy<Map<String, Double>> lazyVariables = new Lazy<>(() -> MapUtil.remapValues(MetaValue::get, variables));
@Value("beta.carving")
@Default
private boolean betaCarvers = false;
private MetaValue<Boolean> betaCarvers = MetaValue.of(false);
@Value("functions")
@Default
private LinkedHashMap<String, FunctionTemplate> functions = new LinkedHashMap<>();
private LinkedHashMap<String, MetaValue<FunctionTemplate>> functions = new LinkedHashMap<>();
private final Lazy<LinkedHashMap<String, FunctionTemplate>> lazyFunctions = new Lazy<>(() -> MapUtil.remap(Function.identity(), MetaValue::get, functions, LinkedHashMap::new));
@Value("structures.locatable")
@Default
private Map<String, ModDependentConfigSection<String>> locatable = new HashMap<>();
private Map<String, MetaValue<String>> locatable = new HashMap<>();
private final Lazy<Map<String, String>> lazyLocatable = new Lazy<>(() -> MapUtil.remapValues(MetaValue::get, locatable));
@Value("blend.terrain.elevation")
@Default
private int elevationBlend = 4;
private MetaValue<Integer> elevationBlend = MetaValue.of(4);
@Value("vanilla.mobs")
@Default
private ModDependentConfigSection<Boolean> vanillaMobs = ModDependentConfigSection.withDefault(true);
private MetaValue<Boolean> vanillaMobs = MetaValue.of(true);
@Value("vanilla.caves")
@Default
private ModDependentConfigSection<Boolean> vanillaCaves = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> vanillaCaves = MetaValue.of(false);
@Value("vanilla.decorations")
@Default
private ModDependentConfigSection<Boolean> vanillaDecorations = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> vanillaDecorations = MetaValue.of(false);
@Value("vanilla.structures")
@Default
private ModDependentConfigSection<Boolean> vanillaStructures = ModDependentConfigSection.withDefault(false);
@Value("author")
@Default
private String author = "Anon Y. Mous";
private MetaValue<Boolean> vanillaStructures = MetaValue.of(false);
@Value("disable.sapling")
@Default
private ModDependentConfigSection<Boolean> disableSaplings = ModDependentConfigSection.withDefault(false);
@Value("version")
@Default
private String version = "0.1.0";
private MetaValue<Boolean> disableSaplings = MetaValue.of(false);
@Value("disable.carvers")
@Default
private ModDependentConfigSection<Boolean> disableCarvers = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> disableCarvers = MetaValue.of(false);
@Value("disable.structures")
@Default
private ModDependentConfigSection<Boolean> disableStructures = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> disableStructures = MetaValue.of(false);
@Value("disable.ores")
@Default
private ModDependentConfigSection<Boolean> disableOres = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> disableOres = MetaValue.of(false);
@Value("disable.trees")
@Default
private ModDependentConfigSection<Boolean> disableTrees = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> disableTrees = MetaValue.of(false);
@Value("disable.flora")
@Default
private ModDependentConfigSection<Boolean> disableFlora = ModDependentConfigSection.withDefault(false);
private MetaValue<Boolean> disableFlora = MetaValue.of(false);
public boolean disableCarvers() {
return disableCarvers.get();
@@ -116,7 +122,7 @@ public class ConfigPackTemplate implements ConfigTemplate {
}
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
return functions;
return lazyFunctions.get();
}
public String getVersion() {
@@ -152,23 +158,23 @@ public class ConfigPackTemplate implements ConfigTemplate {
}
public Map<String, NoiseSeeded> getNoiseBuilderMap() {
return noiseBuilderMap;
return lazyNoiseBuilderMap.get();
}
public Map<String, Double> getVariables() {
return variables;
return lazyVariables.get();
}
public int getElevationBlend() {
return elevationBlend;
return elevationBlend.get();
}
public Map<String, String> getLocatable() {
return locatable.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get()));
return lazyLocatable.get();
}
public boolean doBetaCarvers() {
return betaCarvers;
return betaCarvers.get();
}
public Set<TerraAddon> getAddons() {
@@ -0,0 +1,48 @@
package com.dfsek.terra.config.pack.meta;
import com.dfsek.tectonic.config.Configuration;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.terra.api.config.meta.MetaContext;
import com.dfsek.terra.config.fileloaders.Loader;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
public class PackMetaContext implements MetaContext {
private final Map<String, Configuration> configs = new HashMap<>(); // Lazy init configs
private final Loader fileAccess;
private final ConfigLoader loader;
public PackMetaContext(Loader fileAccess, ConfigLoader loader) {
this.fileAccess = fileAccess;
this.loader = loader;
}
@SuppressWarnings("unchecked")
@Override
public <T> T load(String meta, Type clazz) throws LoadException {
if(meta.indexOf(":") != meta.lastIndexOf(":")) { // We just need to know if there are >1.
throw new LoadException("Malformed metavalue string: " + meta);
}
String file = "/pack.yml";
String key;
if(meta.contains(":")) {
file = meta.substring(0, meta.indexOf(":"));
key = meta.substring(meta.indexOf(":") + 1);
} else {
key = meta;
}
Configuration configuration;
try {
configuration = new Configuration(fileAccess.get(file), file);
} catch(IOException e) {
throw new LoadException("Failed to load config file \"" + file + "\":", e);
}
return (T) loader.loadType(clazz, configuration.get(key));
}
}
@@ -5,9 +5,13 @@ import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.api.util.collections.MaterialSet;
import com.dfsek.terra.world.population.items.ores.Ore;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class OreTemplate extends AbstractableTemplate {
@Value("id")
@@ -17,6 +21,11 @@ public class OreTemplate extends AbstractableTemplate {
@Abstractable
private BlockData material;
@Value("material-overrides")
@Default
@Abstractable
private Map<BlockType, BlockData> materials = new HashMap<>();
@Value("type")
@Abstractable
@Default
@@ -76,4 +85,8 @@ public class OreTemplate extends AbstractableTemplate {
public Ore.Type getType() {
return oreType;
}
public Map<BlockType, BlockData> getMaterialOverrides() {
return materials;
}
}
@@ -70,7 +70,7 @@ public class TerraWorld {
double noise = sampler.sample(fdX, y, fdZ);
if(noise > 0) {
int level = 0;
for(int yi = world.getMaxHeight()-1; yi > y; yi--) {
for(int yi = world.getMaxHeight(); yi > y; yi--) {
if(sampler.sample(fdX, yi, fdZ) > 0) level++;
else level = 0;
}
@@ -59,7 +59,7 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
}
for(int y = 0; y < size + 1; y++) {
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, y << 2, (z << 2) + zOrigin);
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, (y << 2) + min, (z << 2) + zOrigin);
}
}
}
@@ -98,10 +98,10 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
*/
@Override
public double getNoise(double x, double y, double z) {
return interpGrid[reRange(((int) x) / 4, 3)][FastMath.max(FastMath.min(((int) y), max), min) / 4][reRange(((int) z) / 4, 3)].trilerp((x % 4) / 4, (y % 4) / 4, (z % 4) / 4);
return interpGrid[reRange(((int) x) / 4, 3)][(FastMath.max(FastMath.min(((int) y), max), min) - min) / 4][reRange(((int) z) / 4, 3)].trilerp((x % 4) / 4, (y % 4) / 4, (z % 4) / 4);
}
public double getNoise(int x, int y, int z) {
return interpGrid[x / 4][y / 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 % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
}
}
@@ -90,7 +90,7 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
Location mut = l.clone();
BlockData orig = l.getBlock().getBlockData();
do mut.subtract(0, 1, 0);
while(mut.getY() > 0 && mut.getBlock().getBlockData().matches(orig));
while(mut.getY() > world.getMinHeight() && mut.getBlock().getBlockData().matches(orig));
try {
if(template.getShift().get(entry.getValue().getBlockType()).contains(mut.getBlock().getBlockData().getBlockType())) {
mut.getBlock().setBlockData(shiftStorage.computeIfAbsent(entry.getValue().getBlockType(), BlockType::getDefaultData), false);
@@ -6,10 +6,11 @@ import com.dfsek.terra.api.math.noise.samplers.noise.simplex.OpenSimplex2Sampler
import com.dfsek.terra.api.math.vector.Vector3;
import com.dfsek.terra.api.platform.block.Block;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.handle.WorldHandle;
import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.api.platform.world.Chunk;
import com.dfsek.terra.api.util.collections.MaterialSet;
import java.util.Map;
import java.util.Random;
public class DeformedSphereOre extends Ore {
@@ -17,8 +18,8 @@ public class DeformedSphereOre extends Ore {
private final double deformFrequency;
private final Range size;
public DeformedSphereOre(BlockData material, MaterialSet replaceable, boolean applyGravity, double deform, double deformFrequency, Range size, TerraPlugin main) {
super(material, replaceable, applyGravity, main);
public DeformedSphereOre(BlockData material, MaterialSet replaceable, boolean applyGravity, double deform, double deformFrequency, Range size, TerraPlugin main, Map<BlockType, BlockData> materials) {
super(material, replaceable, applyGravity, main, materials);
this.deform = deform;
this.deformFrequency = deformFrequency;
this.size = size;
@@ -27,7 +28,6 @@ public class DeformedSphereOre extends Ore {
@Override
public void generate(Vector3 origin, Chunk c, Random r) {
WorldHandle handle = main.getWorldHandle();
OpenSimplex2Sampler ore = new OpenSimplex2Sampler(r.nextInt());
ore.setFrequency(deformFrequency);
int rad = size.get(r);
@@ -35,12 +35,13 @@ public class DeformedSphereOre extends Ore {
for(int y = -rad; y <= rad; y++) {
for(int z = -rad; z <= rad; z++) {
Vector3 oreLoc = origin.clone().add(new Vector3(x, y, z));
if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > 255 || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < 0)
if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > c.getWorld().getMaxHeight() || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < c.getWorld().getMinHeight())
continue;
if(oreLoc.distance(origin) < (rad + 0.5) * ((ore.getNoise(x, y, z) + 1) * deform)) {
Block b = c.getBlock(oreLoc.getBlockX(), oreLoc.getBlockY(), oreLoc.getBlockZ());
if(getReplaceable().contains(b.getType()) && b.getLocation().getY() >= 0)
b.setBlockData(getMaterial(), isApplyGravity());
BlockType type = b.getType();
if(getReplaceable().contains(type) && b.getLocation().getY() >= c.getWorld().getMinHeight())
b.setBlockData(getMaterial(type), isApplyGravity());
}
}
}
@@ -3,9 +3,11 @@ package com.dfsek.terra.world.population.items.ores;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.math.vector.Vector3;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.api.platform.world.Chunk;
import com.dfsek.terra.api.util.collections.MaterialSet;
import java.util.Map;
import java.util.Random;
public abstract class Ore {
@@ -14,18 +16,20 @@ public abstract class Ore {
private final MaterialSet replaceable;
private final boolean applyGravity;
protected TerraPlugin main;
private final Map<BlockType, BlockData> materials;
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main) {
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main, Map<BlockType, BlockData> materials) {
this.material = material;
this.replaceable = replaceable;
this.applyGravity = applyGravity;
this.main = main;
this.materials = materials;
}
public abstract void generate(Vector3 origin, Chunk c, Random r);
public BlockData getMaterial() {
return material;
public BlockData getMaterial(BlockType replace) {
return materials.getOrDefault(replace, material);
}
public MaterialSet getReplaceable() {
@@ -5,18 +5,20 @@ import com.dfsek.terra.api.math.Range;
import com.dfsek.terra.api.math.vector.Vector3;
import com.dfsek.terra.api.platform.block.Block;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.api.platform.world.Chunk;
import com.dfsek.terra.api.util.collections.MaterialSet;
import net.jafama.FastMath;
import java.util.Map;
import java.util.Random;
public class VanillaOre extends Ore {
private final Range sizeRange;
public VanillaOre(BlockData material, MaterialSet replaceable, boolean applyGravity, Range size, TerraPlugin main) {
super(material, replaceable, applyGravity, main);
public VanillaOre(BlockData material, MaterialSet replaceable, boolean applyGravity, Range size, TerraPlugin main, Map<BlockType, BlockData> materials) {
super(material, replaceable, applyGravity, main, materials);
this.sizeRange = size;
}
@@ -67,8 +69,9 @@ public class VanillaOre extends Ore {
double d15 = (z + 0.5D - (d3 + (d4 - d3) * iFactor)) / (d11 / 2.0D);
if(x > 15 || z > 15 || y > 255 || x < 0 || z < 0 || y < 0) continue;
Block block = chunk.getBlock(x, y, z);
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block.getType())) {
block.setBlockData(getMaterial(), isApplyGravity());
BlockType type = block.getType();
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(type)) {
block.setBlockData(getMaterial(type), isApplyGravity());
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
org.gradle.jvmargs=-Xmx4096m
@@ -1,27 +0,0 @@
package com.dfsek.terra.bukkit;
import com.dfsek.terra.api.platform.modloader.Mod;
import org.bukkit.plugin.Plugin;
public class BukkitPlugin implements Mod {
private final Plugin plugin;
public BukkitPlugin(Plugin plugin) {
this.plugin = plugin;
}
@Override
public String getID() {
return plugin.getName();
}
@Override
public String getVersion() {
return plugin.getDescription().getVersion();
}
@Override
public String getName() {
return plugin.getName();
}
}
@@ -14,7 +14,6 @@ import com.dfsek.terra.api.event.TerraEventManager;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.handle.ItemHandle;
import com.dfsek.terra.api.platform.handle.WorldHandle;
import com.dfsek.terra.api.platform.modloader.Mod;
import com.dfsek.terra.api.platform.world.Biome;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.registry.CheckedRegistry;
@@ -58,12 +57,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
@@ -310,11 +306,6 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
genericLoaders.register(registry);
}
@Override
public Set<Mod> getMods() {
return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(BukkitPlugin::new).collect(Collectors.toSet());
}
@Override
public LockedRegistry<TerraAddon> getAddons() {
return addonLockedRegistry;
+9 -4
View File
@@ -7,7 +7,7 @@ import net.fabricmc.loom.task.RemapJarTask
plugins {
`java-library`
`maven-publish`
id("fabric-loom").version("0.6-SNAPSHOT")
id("fabric-loom").version("0.8-SNAPSHOT")
id("com.modrinth.minotaur").version("1.1.0")
}
@@ -23,9 +23,9 @@ group = "com.dfsek.terra.fabric"
dependencies {
"shadedApi"(project(":common"))
"minecraft"("com.mojang:minecraft:1.16.5")
"mappings"("net.fabricmc:yarn:1.16.5+build.5:v2")
"modImplementation"("net.fabricmc:fabric-loader:0.11.2")
"minecraft"("com.mojang:minecraft:1.17")
"mappings"("net.fabricmc:yarn:1.17+build.1:v2")
"modImplementation"("net.fabricmc:fabric-loader:0.11.3")
"modCompileOnly"("com.sk89q.worldedit:worldedit-fabric-mc1.16:7.2.0-SNAPSHOT") {
exclude(group = "com.google.guava", module = "guava")
@@ -36,6 +36,11 @@ dependencies {
}
}
tasks.named<ShadowJar>("shadowJar") {
relocate("org.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
}
configure<LoomGradleExtension> {
accessWidener("src/main/resources/terra.accesswidener")
@@ -1,28 +0,0 @@
package com.dfsek.terra.fabric;
import com.dfsek.terra.api.platform.modloader.Mod;
import net.fabricmc.loader.api.ModContainer;
public class FabricMod implements Mod {
private final ModContainer mod;
public FabricMod(ModContainer mod) {
this.mod = mod;
}
@Override
public String getID() {
return mod.getMetadata().getId();
}
@Override
public String getVersion() {
return mod.getMetadata().getVersion().getFriendlyString();
}
@Override
public String getName() {
return mod.getMetadata().getName();
}
}
@@ -1,9 +1,7 @@
package com.dfsek.terra.fabric;
import com.dfsek.tectonic.config.Configuration;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeRegistry;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addons.TerraAddon;
@@ -23,7 +21,6 @@ import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.handle.ItemHandle;
import com.dfsek.terra.api.platform.handle.WorldHandle;
import com.dfsek.terra.api.platform.modloader.Mod;
import com.dfsek.terra.api.platform.world.Tree;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.registry.CheckedRegistry;
@@ -73,13 +70,10 @@ import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
@@ -270,7 +264,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
Registry.register(Registry.FEATURE, new Identifier("terra", "populator"), POPULATOR_FEATURE);
RegistryKey<ConfiguredFeature<?, ?>> floraKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("terra", "populator"));
RegistryKey<ConfiguredFeature<?, ?>> floraKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("terra", "populator"));
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, floraKey.getValue(), POPULATOR_CONFIGURED_FEATURE);
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("terra:terra"), FabricChunkGeneratorWrapper.CODEC);
@@ -291,11 +285,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
return eventManager;
}
@Override
public Set<Mod> getMods() {
return FabricLoader.getInstance().getAllMods().stream().map(FabricMod::new).collect(Collectors.toSet());
}
@Override
public Profiler getProfiler() {
return profiler;
@@ -310,13 +299,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
private final Map<ConfigPack, Pair<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> templates = new HashMap<>();
private final Map<ConfigPack, Configuration> compatConfigs = new HashMap<>();
private final ConfigLoader compatLoader = new ConfigLoader();
private FabricAddon(TerraPlugin main) {
this.main = main;
main.register(compatLoader);
}
@Override
@@ -335,7 +319,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
injectTree(treeRegistry, "LARGE_OAK", ConfiguredFeatures.FANCY_OAK);
injectTree(treeRegistry, "LARGE_SPRUCE", ConfiguredFeatures.PINE);
injectTree(treeRegistry, "SMALL_JUNGLE", ConfiguredFeatures.JUNGLE_TREE);
injectTree(treeRegistry, "SWAMP_OAK", ConfiguredFeatures.SWAMP_TREE);
injectTree(treeRegistry, "SWAMP_OAK", ConfiguredFeatures.SWAMP_OAK);
injectTree(treeRegistry, "TALL_BIRCH", ConfiguredFeatures.BIRCH_TALL);
injectTree(treeRegistry, "ACACIA", ConfiguredFeatures.ACACIA);
injectTree(treeRegistry, "BIRCH", ConfiguredFeatures.BIRCH);
@@ -348,24 +332,9 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
injectTree(treeRegistry, "CRIMSON_FUNGUS", ConfiguredFeatures.CRIMSON_FUNGI);
injectTree(treeRegistry, "WARPED_FUNGUS", ConfiguredFeatures.WARPED_FUNGI);
Configuration compat;
try {
compat = new Configuration(event.getLoader().get("compat.yml"));
main.logger().info("Loading compatibility options from compat.yml.");
} catch(FileNotFoundException e) {
compat = new Configuration(new HashMap<>()); // blank config
main.logger().info("No compat.yml found, not loading compatibility options.");
} catch(IOException e) {
throw new RuntimeException("Failed to load compatibility config", e); // Something went wrong.
}
compatConfigs.put(event.getPack(), compat);
PreLoadCompatibilityOptions template = new PreLoadCompatibilityOptions();
try {
compatLoader.load(template, compat);
event.loadTemplate(template);
} catch(ConfigException e) {
e.printStackTrace();
}
@@ -382,7 +351,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
});
}
templates.put(event.getPack(), Pair.of(template, null));
}
@Priority(Priority.HIGHEST)
@@ -391,7 +359,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
PostLoadCompatibilityOptions template = new PostLoadCompatibilityOptions();
try {
compatLoader.load(template, compatConfigs.get(event.getPack()));
event.loadTemplate(template);
} catch(ConfigException e) {
e.printStackTrace();
}
@@ -14,32 +14,39 @@ public class PreLoadCompatibilityOptions implements ConfigTemplate {
@Default
private boolean doRegistryInjection = false;
@Value("features.inject-namespaces")
@Value("features.inject-biome.enable")
@Default
private Set<String> featureNamespaces = new HashSet<>();
@Value("structures.inject-namespaces")
@Default
private Set<String> structureNamespaces = new HashSet<>();
private boolean doBiomeInjection = false;
@Value("features.inject-registry.excluded-features")
@Default
private Set<Identifier> excludedRegistryFeatures = new HashSet<>();
@Value("features.inject-biome.excluded-features")
@Default
private Set<Identifier> excludedBiomeFeatures = new HashSet<>();
public Set<String> getFeatureNamespaces() {
return featureNamespaces;
}
@Value("structures.inject-biome.excluded-features")
@Default
private Set<Identifier> excludedBiomeStructures = new HashSet<>();
public Set<String> getStructureNamespaces() {
return structureNamespaces;
public boolean doBiomeInjection() {
return doBiomeInjection;
}
public boolean doRegistryInjection() {
return doRegistryInjection;
}
public Set<Identifier> getExcludedBiomeFeatures() {
return excludedBiomeFeatures;
}
public Set<Identifier> getExcludedRegistryFeatures() {
return excludedRegistryFeatures;
}
public Set<Identifier> getExcludedBiomeStructures() {
return excludedBiomeStructures;
}
}
@@ -5,11 +5,12 @@ import com.dfsek.terra.api.platform.world.generator.ChunkData;
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
import com.dfsek.terra.api.util.FastRandom;
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
import com.dfsek.terra.api.world.generation.Chunkified;
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
import com.dfsek.terra.config.pack.ConfigPack;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.fabric.block.FabricBlockData;
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
import com.dfsek.terra.fabric.util.FabricAdapter;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
@@ -20,20 +21,17 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.jafama.FastMath;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.structure.StructureManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.SpawnHelper;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
@@ -46,10 +44,10 @@ import net.minecraft.world.gen.chunk.VerticalBlockSample;
import net.minecraft.world.gen.feature.StructureFeature;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
public class FabricChunkGeneratorWrapper extends ChunkGenerator implements GeneratorWrapper {
private final long seed;
@@ -71,7 +69,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack) {
super(biomeSource, new StructuresConfig(configPack.getTemplate().vanillaStructures()));
super(biomeSource, new StructuresConfig(false));
this.pack = configPack;
this.delegate = new DefaultChunkGenerator3D(pack, TerraFabricPlugin.getInstance());
@@ -124,11 +122,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
return super.locateStructure(world, feature, center, radius, skipExistingChunks);
}
@Override
public void populateNoise(WorldAccess world, StructureAccessor accessor, Chunk chunk) {
delegate.generateChunkData((World) world, new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ChunkData) chunk);
}
@Override
public void carve(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver) {
if(pack.getTemplate().vanillaCaves()) super.carve(seed, access, chunk, carver);
@@ -140,6 +133,20 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
super.setStructureStarts(dynamicRegistryManager, structureAccessor, chunk, structureManager, worldSeed);
}
@Override
public CompletableFuture<Chunk> populateNoise(Executor executor, StructureAccessor accessor, Chunk chunk) {
return CompletableFuture.supplyAsync(() -> {
World world = (World) ((StructureAccessorAccessor) accessor).getWorld();
delegate.generateChunkData(world, new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ChunkData) chunk);
delegate.getPopulators().forEach(populator -> {
if(populator instanceof Chunkified) {
populator.populate(world, (com.dfsek.terra.api.platform.world.Chunk) world);
}
});
return chunk;
}, executor);
}
@Override
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
if(pack.getTemplate().vanillaStructures()) return super.isStrongholdStartingChunk(chunkPos);
@@ -147,21 +154,30 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmapType) {
public int getHeightOnGround(int x, int z, Heightmap.Type heightmap, HeightLimitView world) {
return super.getHeightOnGround(x, z, heightmap, world);
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) {
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
int cx = FastMath.floorMod(x, 16);
int cz = FastMath.floorMod(z, 16);
int height = world.getWorld().getMaxHeight();
while(height >= 0 && !heightmapType.getBlockPredicate().test(((FabricBlockData) world.getUngeneratedBlock(x, height - 1, z)).getHandle())) {
height--;
}
while(height >= 0 && sampler.sample(cx, height-1, cz) < 0) height--;
return height;
}
@Override
public BlockView getColumnSample(int x, int z) {
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView view) {
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
int height = getHeight(x, z, Heightmap.Type.WORLD_SURFACE);
int height = getHeight(x, z, Heightmap.Type.WORLD_SURFACE, view);
BlockState[] array = new BlockState[256];
for(int y = 255; y >= 0; y--) {
for(int y = view.getBottomY()+view.getHeight(); y >= view.getBottomY(); y--) {
if(y > height) {
if(y > ((UserDefinedBiome) world.getBiomeProvider().getBiome(x, z)).getConfig().getSeaLevel()) {
array[y] = Blocks.AIR.getDefaultState();
@@ -173,39 +189,18 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
}
return new VerticalBlockSample(array);
}
@Override
public List<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) {
if(pack.getTemplate().vanillaStructures()) {
if(accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren()) {
if(group == SpawnGroup.MONSTER) return StructureFeature.SWAMP_HUT.getMonsterSpawns();
if(group == SpawnGroup.CREATURE) return StructureFeature.SWAMP_HUT.getCreatureSpawns();
}
if(group == SpawnGroup.MONSTER) {
if(accessor.getStructureAt(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren()) {
return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns();
} else if(accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren()) {
return StructureFeature.MONUMENT.getMonsterSpawns();
} else if(accessor.getStructureAt(pos, true, StructureFeature.FORTRESS).hasChildren()) {
return StructureFeature.FORTRESS.getMonsterSpawns();
}
}
}
return super.getEntitySpawnList(biome, accessor, group, pos);
return new VerticalBlockSample(view.getBottomY(), array);
}
@Override
public void populateEntities(ChunkRegion region) {
if(pack.getTemplate().vanillaMobs()) {
int cx = region.getCenterChunkX();
int cy = region.getCenterChunkZ();
int cx = region.getCenterPos().x;
int cy = region.getCenterPos().z;
Biome biome = region.getBiome((new ChunkPos(cx, cy)).getStartPos());
ChunkRandom chunkRandom = new ChunkRandom();
chunkRandom.setPopulationSeed(region.getSeed(), cx << 4, cy << 4);
SpawnHelper.populateEntities(region, biome, cx, cy, chunkRandom);
SpawnHelper.populateEntities(region, biome, region.getCenterPos(), chunkRandom);
}
}

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