mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
reformat all code
This commit is contained in:
@@ -37,9 +37,12 @@ assignees: ""
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I have checked that I am on the latest version of Terra.
|
- [ ] 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 searched the github issue tracker for similar issues, including
|
||||||
- [ ] I have made sure that this is not a bug with another mod or plugin, and it is Terra that is causing the issue.
|
closed ones.
|
||||||
- [ ] I have checked that this is an issue with Terra and not an issue with the pack I am using.
|
- [ ] 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 -->
|
<!-- 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 attached a copy of the `latest.log` file
|
||||||
- [ ] I have filled out and provided all the appropriate information.
|
- [ ] I have filled out and provided all the appropriate information.
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ assignees: ""
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I have checked that I am on the latest version of Terra.
|
- [ ] 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 have searched github for similar features requests, including closed
|
||||||
|
ones, and found none.
|
||||||
- [ ] I believe this is within the scope of Terra.
|
- [ ] 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.
|
- [ ] This feature request is for *all* of Terra, and isn't something that
|
||||||
|
should be implemented by a pack or addon.
|
||||||
|
|
||||||
## Feature Description
|
## Feature Description
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: "Other Issue"
|
name: "Other Issue"
|
||||||
about: "Use this template if your issue doesn't accurately fit into any of the other categories."
|
about: "Use this template if your issue doesn't accurately fit into any of the
|
||||||
|
other categories."
|
||||||
title: ""
|
title: ""
|
||||||
labels: "Type: Question, Status: Pending"
|
labels: "Type: Question, Status: Pending"
|
||||||
assignees: ""
|
assignees: ""
|
||||||
|
|||||||
@@ -33,9 +33,11 @@
|
|||||||
|
|
||||||
<!-- In order to be accepted, your changes must be under the GPLv3 license. Please check one of the following: -->
|
<!-- 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 the original author of this code, and I am willing to release it
|
||||||
- [ ] 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).
|
||||||
under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or a compatible license.
|
- [ ] 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.
|
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.
|
NOTE: for compatible licenses, you must make sure to add the included license somewhere in the program, if so required.
|
||||||
@@ -70,19 +72,24 @@
|
|||||||
|
|
||||||
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
|
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
|
||||||
- [ ] Build system <!-- Anything which pretain to the build system. -->
|
- [ ] Build system <!-- Anything which pretain to the build system. -->
|
||||||
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
- [ ]
|
||||||
|
Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
||||||
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
|
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
|
||||||
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
|
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
|
||||||
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
- [ ]
|
||||||
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
||||||
|
- [ ]
|
||||||
|
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
||||||
- [ ] Revert <!-- Anything which reverts previous commits. -->
|
- [ ] Revert <!-- Anything which reverts previous commits. -->
|
||||||
- [ ] Style <!-- Anything which updates style. -->
|
- [ ] Style <!-- Anything which updates style. -->
|
||||||
- [ ] Tests <!-- Anything which adds or updates tests. -->
|
- [ ] Tests <!-- Anything which adds or updates tests. -->
|
||||||
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
- [ ]
|
||||||
|
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
||||||
|
|
||||||
#### Compatiblity
|
#### Compatiblity
|
||||||
|
|
||||||
- [ ] Breaking change <!-- A fix, or a feature, that breaks some previous functionality to Terra. -->
|
- [ ] Breaking
|
||||||
|
change <!-- A fix, or a feature, that breaks some previous functionality to Terra. -->
|
||||||
- [ ] Non-Breaking change.
|
- [ ] Non-Breaking change.
|
||||||
<!--
|
<!--
|
||||||
A change which does not break *any* previous functionality of Terra.
|
A change which does not break *any* previous functionality of Terra.
|
||||||
@@ -94,8 +101,9 @@
|
|||||||
|
|
||||||
#### Contribution Guidelines.
|
#### Contribution Guidelines.
|
||||||
|
|
||||||
- [ ] I have read the [`CONTRIBUTING.md`](https://github.com/PolyhedralDev/Terra/blob/master/CONTRIBUTING.md) document in the root of the
|
- [ ] I have read
|
||||||
git repository.
|
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
|
- [ ] 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. -->
|
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. -->
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -58,8 +58,8 @@ listen carefully, apologize sincerely, and correct the behavior going forward.
|
|||||||
Any member of the Terra community should always be open to new ideas and must
|
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,
|
always be open to the possibility of being wrong. Nobody can always be right,
|
||||||
and we are only human; we are
|
and we are only human; we are
|
||||||
[fallible](https://www.merriam-webster.com/dictionary/fallible) by nature.
|
[fallible](https://www.merriam-webster.com/dictionary/fallible) by nature. It is
|
||||||
It is okay to make mistakes, but we must be willing to admit when we make one.
|
okay to make mistakes, but we must be willing to admit when we make one.
|
||||||
|
|
||||||
### Be Direct but Professional
|
### Be Direct but Professional
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -77,9 +77,9 @@ Unsure where to begin contributing to Terra? You can start by looking through "
|
|||||||
beginner" and "help wanted" issues:
|
beginner" and "help wanted" issues:
|
||||||
|
|
||||||
- [Beginner issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Good%20First%20Issue)
|
- [Beginner issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Good%20First%20Issue)
|
||||||
- issues which should be friendly to anyone new to terra.
|
- issues which should be friendly to anyone new to terra.
|
||||||
- [Help wanted issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Help%20Wanted)
|
- [Help wanted issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Help%20Wanted)
|
||||||
- issues which should be a bit more involved than "beginner" issues.
|
- issues which should be a bit more involved than "beginner" issues.
|
||||||
|
|
||||||
New to github? Working on your first Pull Request? Check
|
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)
|
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)
|
||||||
@@ -365,8 +365,9 @@ into packs) is acceptable in the platform project.
|
|||||||
|
|
||||||
#### Specific Compatibility
|
#### Specific Compatibility
|
||||||
|
|
||||||
Specific compatibility should *not* be put in the platform project. (Example: Adding
|
Specific compatibility should *not* be put in the platform project. (Example:
|
||||||
the ability to generate TechCraft v7's doo-dads with a TerraScript function)
|
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
|
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
|
track of, as well as adding lots of additional stuff to maintain. It quickly
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ If you're not sure which license a particular file is under, check:
|
|||||||
Terra is still in beta! While it is stable, it is not feature-complete. There is
|
Terra is still in beta! While it is stable, it is not feature-complete. There is
|
||||||
a lot to be added!
|
a lot to be added!
|
||||||
|
|
||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
[](https://www.yourkit.com/)
|
[](https://www.yourkit.com/)
|
||||||
@@ -100,9 +99,9 @@ YourKit has granted Polyhedral Development an open-source license to their
|
|||||||
outstanding Java profiler, allowing us to make our software as performant as it
|
outstanding Java profiler, allowing us to make our software as performant as it
|
||||||
can be!
|
can be!
|
||||||
|
|
||||||
YourKit supports open source projects with innovative and intelligent tools
|
YourKit supports open source projects with innovative and intelligent tools for
|
||||||
for monitoring and profiling Java and .NET applications.
|
monitoring and profiling Java and .NET applications. YourKit is the creator of
|
||||||
YourKit is the creator of the
|
the
|
||||||
[YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
|
[YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
|
||||||
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
|
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
|
||||||
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
preRelease(true)
|
preRelease(true)
|
||||||
|
|
||||||
versionProjects(":common:api", version("6.0.0"))
|
versionProjects(":common:api", version("6.0.0"))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fun Project.addonDir(dir: File, task: Task) {
|
|||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
forSubProjects(":common:addons") {
|
forSubProjects(":common:addons") {
|
||||||
val jar = if(tasks.findByName("shadowJar") != null) {
|
val jar = if (tasks.findByName("shadowJar") != null) {
|
||||||
(tasks.named("shadowJar").get() as ShadowJar)
|
(tasks.named("shadowJar").get() as ShadowJar)
|
||||||
} else {
|
} else {
|
||||||
(tasks.named("jar").get() as Jar)
|
(tasks.named("jar").get() as Jar)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import com.dfsek.terra.tectonicdoc.TectonicDocPlugin
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
import org.gradle.api.JavaVersion
|
import org.gradle.api.JavaVersion
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
@@ -12,7 +13,6 @@ import org.gradle.kotlin.dsl.getByName
|
|||||||
import org.gradle.kotlin.dsl.register
|
import org.gradle.kotlin.dsl.register
|
||||||
import org.gradle.kotlin.dsl.withType
|
import org.gradle.kotlin.dsl.withType
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
import com.dfsek.terra.tectonicdoc.TectonicDocPlugin
|
|
||||||
|
|
||||||
fun Project.configureCompilation() {
|
fun Project.configureCompilation() {
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ fun downloadPack(packUrl: URL, project: Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Project.getJarTask(): Jar {
|
fun Project.getJarTask(): Jar {
|
||||||
return if(tasks.findByName("shadowJar") != null) {
|
return if (tasks.findByName("shadowJar") != null) {
|
||||||
(tasks.named("shadowJar").get() as ShadowJar)
|
(tasks.named("shadowJar").get() as ShadowJar)
|
||||||
} else {
|
} else {
|
||||||
(tasks.named("jar").get() as Jar)
|
(tasks.named("jar").get() as Jar)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
.relativize(file.toPath())
|
.relativize(file.toPath())
|
||||||
.toString()
|
.toString()
|
||||||
.substringBeforeLast('.')
|
.substringBeforeLast('.')
|
||||||
if(name.endsWith("Template")) {
|
if (name.endsWith("Template")) {
|
||||||
name = name.substringBeforeLast("Template")
|
name = name.substringBeforeLast("Template")
|
||||||
}
|
}
|
||||||
classes[name] = node
|
classes[name] = node
|
||||||
@@ -98,7 +98,7 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getType(node: FieldNode): String {
|
private fun getType(node: FieldNode): String {
|
||||||
if(node.signature != null) {
|
if (node.signature != null) {
|
||||||
return generic(node.signature)
|
return generic(node.signature)
|
||||||
}
|
}
|
||||||
return descriptorToHumanReadable(node.desc).substringAfterLast('.')
|
return descriptorToHumanReadable(node.desc).substringAfterLast('.')
|
||||||
@@ -107,9 +107,9 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
private fun generic(type: String): String {
|
private fun generic(type: String): String {
|
||||||
val clean = descriptorToHumanReadable(type)
|
val clean = descriptorToHumanReadable(type)
|
||||||
|
|
||||||
if(clean.contains('<')) {
|
if (clean.contains('<')) {
|
||||||
val typeIndex = clean.indexOf('<')
|
val typeIndex = clean.indexOf('<')
|
||||||
return clean.substring(0, typeIndex+1).substringAfterLast('.') + generic(clean.substring(typeIndex+1)) + "\\>"
|
return clean.substring(0, typeIndex + 1).substringAfterLast('.') + generic(clean.substring(typeIndex + 1)) + "\\>"
|
||||||
}
|
}
|
||||||
|
|
||||||
return clean.substringAfterLast('.')
|
return clean.substringAfterLast('.')
|
||||||
@@ -127,21 +127,21 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun descriptorToHumanReadable(descriptor: String): String {
|
private fun descriptorToHumanReadable(descriptor: String): String {
|
||||||
if(descriptor.startsWith('L')) {
|
if (descriptor.startsWith('L')) {
|
||||||
return descriptor.substring(1).substringBeforeLast(';').replace('/', '.')
|
return descriptor.substring(1).substringBeforeLast(';').replace('/', '.')
|
||||||
}
|
}
|
||||||
if(descriptor.startsWith("[")) {
|
if (descriptor.startsWith("[")) {
|
||||||
return "${descriptorToHumanReadable(descriptor.substring(1))}[]"
|
return "${descriptorToHumanReadable(descriptor.substring(1))}[]"
|
||||||
}
|
}
|
||||||
return when(descriptor) {
|
return when (descriptor) {
|
||||||
"B" -> "byte"
|
"B" -> "byte"
|
||||||
"C" -> "char"
|
"C" -> "char"
|
||||||
"I" -> "int"
|
"I" -> "int"
|
||||||
"D" -> "double"
|
"D" -> "double"
|
||||||
"F" -> "float"
|
"F" -> "float"
|
||||||
"J" -> "long"
|
"J" -> "long"
|
||||||
"S" -> "short"
|
"S" -> "short"
|
||||||
"Z" -> "boolean"
|
"Z" -> "boolean"
|
||||||
else -> descriptor
|
else -> descriptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.tectonicdoc
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
|
||||||
class TectonicDocPlugin: Plugin<Project> {
|
class TectonicDocPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.tasks.create("generateDocs", GenerateDocsTask::class.java)
|
project.tasks.create("generateDocs", GenerateDocsTask::class.java)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -41,7 +41,8 @@ public class ImageBiomeProviderAddon implements AddonInitializer {
|
|||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||||
PROVIDER_REGISTRY_KEY);
|
PROVIDER_REGISTRY_KEY);
|
||||||
providerRegistry.register(addon.key("IMAGE"), () -> new ImageProviderTemplate(event.getPack().getRegistry(Biome.class)));
|
providerRegistry.register(addon.key("IMAGE"),
|
||||||
|
() -> new ImageProviderTemplate(event.getPack().getRegistry(Biome.class)));
|
||||||
})
|
})
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1,6 +1,5 @@
|
|||||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,6 @@ import com.dfsek.tectonic.api.depth.DepthTracker;
|
|||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.AnnotatedType;
|
import java.lang.reflect.AnnotatedType;
|
||||||
@@ -22,7 +21,8 @@ public class BiomeDelegateLoader implements TypeLoader<BiomeDelegate> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeDelegate load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker) throws LoadException {
|
public BiomeDelegate load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker)
|
||||||
|
throws LoadException {
|
||||||
if(c.equals("SELF")) return BiomeDelegate.self();
|
if(c.equals("SELF")) return BiomeDelegate.self();
|
||||||
return biomeRegistry
|
return biomeRegistry
|
||||||
.getByID((String) c)
|
.getByID((String) c)
|
||||||
|
|||||||
+3
-3
@@ -21,10 +21,10 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
|
|||||||
@Value("resolution")
|
@Value("resolution")
|
||||||
@Default
|
@Default
|
||||||
@Description("""
|
@Description("""
|
||||||
The resolution at which to sample biomes.
|
The resolution at which to sample biomes.
|
||||||
|
|
||||||
Larger values are quadratically faster, but produce lower quality results.
|
Larger values are quadratically faster, but produce lower quality results.
|
||||||
For example, a value of 3 would sample every 3 blocks.""")
|
For example, a value of 3 would sample every 3 blocks.""")
|
||||||
protected @Meta int resolution = 1;
|
protected @Meta int resolution = 1;
|
||||||
@Value("blend.sampler")
|
@Value("blend.sampler")
|
||||||
@Default
|
@Default
|
||||||
|
|||||||
+2
-3
@@ -8,8 +8,6 @@
|
|||||||
package com.dfsek.terra.addons.chunkgenerator.generation;
|
package com.dfsek.terra.addons.chunkgenerator.generation;
|
||||||
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -26,6 +24,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
|||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
|
|
||||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||||
@@ -87,7 +86,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
if(sampler.sample(x, y, z) > 0) {
|
if(sampler.sample(x, y, z) > 0) {
|
||||||
if(carver.sample(x, y, z) <= 0) {
|
if(carver.sample(x, y, z) <= 0) {
|
||||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||||
seed);
|
seed);
|
||||||
chunk.setBlock(x, y, z, data);
|
chunk.setBlock(x, y, z, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ public class ChunkInterpolator {
|
|||||||
for(int x = 0; x < 5; x++) {
|
for(int x = 0; x < 5; x++) {
|
||||||
for(int z = 0; z < 5; z++) {
|
for(int z = 0; z < 5; z++) {
|
||||||
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
|
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
|
||||||
.getContext()
|
.getContext()
|
||||||
.get(BiomeNoiseProperties.class);
|
.get(BiomeNoiseProperties.class);
|
||||||
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
|
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
|
||||||
|
|
||||||
int step = generationSettings.blendStep();
|
int step = generationSettings.blendStep();
|
||||||
|
|||||||
+2
-5
@@ -8,12 +8,8 @@
|
|||||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||||
import com.dfsek.terra.api.util.MathUtil;
|
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class ElevationInterpolator {
|
public class ElevationInterpolator {
|
||||||
private final double[][] values = new double[18][18];
|
private final double[][] values = new double[18][18];
|
||||||
@@ -42,7 +38,8 @@ public class ElevationInterpolator {
|
|||||||
|
|
||||||
for(int xi = -smooth; xi <= smooth; xi++) {
|
for(int xi = -smooth; xi <= smooth; xi++) {
|
||||||
for(int zi = -smooth; zi <= smooth; zi++) {
|
for(int zi = -smooth; zi <= smooth; zi++) {
|
||||||
if(gens[x + 1 + smooth + xi][z + 1 + smooth + zi] != center) { // test referential equality because thats all we need to know
|
if(gens[x + 1 + smooth + xi][z + 1 + smooth + zi] !=
|
||||||
|
center) { // test referential equality because thats all we need to know
|
||||||
same = false;
|
same = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-13
@@ -17,23 +17,16 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||||
|
|
||||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.util.MathUtil;
|
|
||||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
|
||||||
import com.dfsek.terra.api.world.World;
|
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
|
|
||||||
public class SamplerProvider {
|
public class SamplerProvider {
|
||||||
private final Cache<WorldContext, Sampler3D> cache;
|
private final Cache<WorldContext, Sampler3D> cache;
|
||||||
@@ -53,8 +46,9 @@ public class SamplerProvider {
|
|||||||
public Sampler3D getChunk(int cx, int cz, WorldProperties world, BiomeProvider provider) {
|
public Sampler3D getChunk(int cx, int cz, WorldProperties world, BiomeProvider provider) {
|
||||||
WorldContext context = new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight());
|
WorldContext context = new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight());
|
||||||
try {
|
try {
|
||||||
return cache.get(context, () -> new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider,
|
return cache.get(context,
|
||||||
elevationSmooth));
|
() -> new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider,
|
||||||
|
elevationSmooth));
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-5
@@ -6,16 +6,12 @@ import cloud.commandframework.CommandManager;
|
|||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.api.command.CommandSender;
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class AddonsCommandAddon implements AddonInitializer {
|
public class AddonsCommandAddon implements AddonInitializer {
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
+3
-15
@@ -2,30 +2,18 @@ package com.dfsek.terra.addons.commands.packs;
|
|||||||
|
|
||||||
import cloud.commandframework.ArgumentDescription;
|
import cloud.commandframework.ArgumentDescription;
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
import org.slf4j.LoggerFactory;
|
||||||
import cloud.commandframework.arguments.standard.LongArgument;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.api.command.CommandSender;
|
||||||
|
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class PacksCommandAddon implements AddonInitializer {
|
public class PacksCommandAddon implements AddonInitializer {
|
||||||
|
|||||||
+2
-4
@@ -2,19 +2,17 @@ package com.dfsek.terra.addons.commands.profiler;
|
|||||||
|
|
||||||
import cloud.commandframework.ArgumentDescription;
|
import cloud.commandframework.ArgumentDescription;
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.api.command.CommandSender;
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class ProfilerCommandAddon implements AddonInitializer {
|
public class ProfilerCommandAddon implements AddonInitializer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProfilerCommandAddon.class);
|
private static final Logger logger = LoggerFactory.getLogger(ProfilerCommandAddon.class);
|
||||||
|
|||||||
+23
-25
@@ -2,16 +2,17 @@ package com.dfsek.terra.addons.commands.structure;
|
|||||||
|
|
||||||
import cloud.commandframework.ArgumentDescription;
|
import cloud.commandframework.ArgumentDescription;
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
|
|
||||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||||
import cloud.commandframework.arguments.standard.LongArgument;
|
import cloud.commandframework.arguments.standard.LongArgument;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.api.command.CommandSender;
|
||||||
|
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
@@ -21,8 +22,6 @@ import com.dfsek.terra.api.structure.Structure;
|
|||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class StructureCommandAddon implements AddonInitializer {
|
public class StructureCommandAddon implements AddonInitializer {
|
||||||
@Inject
|
@Inject
|
||||||
@@ -31,6 +30,9 @@ public class StructureCommandAddon implements AddonInitializer {
|
|||||||
@Inject
|
@Inject
|
||||||
private BaseAddon addon;
|
private BaseAddon addon;
|
||||||
|
|
||||||
|
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||||
|
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
@@ -42,28 +44,24 @@ public class StructureCommandAddon implements AddonInitializer {
|
|||||||
|
|
||||||
manager.command(
|
manager.command(
|
||||||
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
|
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
|
||||||
.literal("generate")
|
.literal("generate")
|
||||||
.argument(RegistryArgument.builder("structure",
|
.argument(RegistryArgument.builder("structure",
|
||||||
StructureCommandAddon::getStructureRegistry,
|
StructureCommandAddon::getStructureRegistry,
|
||||||
TypeKey.of(Structure.class)))
|
TypeKey.of(Structure.class)))
|
||||||
.argument(LongArgument.optional("seed", 0))
|
.argument(LongArgument.optional("seed", 0))
|
||||||
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
|
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
|
||||||
.handler(context -> {
|
.handler(context -> {
|
||||||
Structure structure = context.get("structure");
|
Structure structure = context.get("structure");
|
||||||
Entity sender = context.getSender().getEntity().orElseThrow();
|
Entity sender = context.getSender().getEntity().orElseThrow();
|
||||||
structure.generate(
|
structure.generate(
|
||||||
sender.position().toInt(),
|
sender.position().toInt(),
|
||||||
sender.world(),
|
sender.world(),
|
||||||
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")),
|
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")),
|
||||||
context.get("rotation")
|
context.get("rotation")
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.permission("terra.structures.generate")
|
.permission("terra.structures.generate")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
|
||||||
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -13,10 +13,8 @@ import com.dfsek.tectonic.api.config.template.annotations.Final;
|
|||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
|
|||||||
+3
-3
@@ -11,6 +11,7 @@ import com.dfsek.tectonic.api.depth.DepthTracker;
|
|||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.AnnotatedType;
|
import java.lang.reflect.AnnotatedType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,13 +19,12 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
|
||||||
public class PaletteHolderLoader implements TypeLoader<PaletteHolder> {
|
public class PaletteHolderLoader implements TypeLoader<PaletteHolder> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public PaletteHolder load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader, DepthTracker depthTracker) throws LoadException {
|
public PaletteHolder load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader, DepthTracker depthTracker)
|
||||||
|
throws LoadException {
|
||||||
List<Map<String, Integer>> palette = (List<Map<String, Integer>>) o;
|
List<Map<String, Integer>> palette = (List<Map<String, Integer>>) o;
|
||||||
PaletteHolderBuilder builder = new PaletteHolderBuilder();
|
PaletteHolderBuilder builder = new PaletteHolderBuilder();
|
||||||
for(Map<String, Integer> layer : palette) {
|
for(Map<String, Integer> layer : palette) {
|
||||||
|
|||||||
+2
-2
@@ -13,10 +13,10 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.AndDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.AndDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.NoDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.NoDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridDistributorTemplate;
|
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate;
|
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.OrDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.OrDistributorTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.PointSetDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.PointSetDistributorTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.XorDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.XorDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.config.YesDistributorTemplate;
|
import com.dfsek.terra.addons.feature.distributor.config.YesDistributorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.distributor.util.Point;
|
import com.dfsek.terra.addons.feature.distributor.util.Point;
|
||||||
|
|||||||
+2
-2
@@ -12,11 +12,11 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import com.dfsek.tectonic.api.exception.ValidationException;
|
import com.dfsek.tectonic.api.exception.ValidationException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class XorDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
public class XorDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||||
@Value("distributors")
|
@Value("distributors")
|
||||||
|
|||||||
+12
-13
@@ -1,13 +1,12 @@
|
|||||||
package com.dfsek.terra.addons.feature.distributor.distributors;
|
package com.dfsek.terra.addons.feature.distributor.distributors;
|
||||||
|
|
||||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.MathUtil;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||||
|
import com.dfsek.terra.api.util.MathUtil;
|
||||||
|
|
||||||
|
|
||||||
public class PaddedGridDistributor implements Distributor {
|
public class PaddedGridDistributor implements Distributor {
|
||||||
private final int width;
|
private final int width;
|
||||||
@@ -22,6 +21,15 @@ public class PaddedGridDistributor implements Distributor {
|
|||||||
this.cellWidth = width + padding;
|
this.cellWidth = width + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long murmur64(long h) {
|
||||||
|
h ^= h >>> 33;
|
||||||
|
h *= 0xff51afd7ed558ccdL;
|
||||||
|
h ^= h >>> 33;
|
||||||
|
h *= 0xc4ceb9fe1a85ec53L;
|
||||||
|
h ^= h >>> 33;
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(int x, int z, long seed) {
|
public boolean matches(int x, int z, long seed) {
|
||||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||||
@@ -34,13 +42,4 @@ public class PaddedGridDistributor implements Distributor {
|
|||||||
|
|
||||||
return x == pointX && z == pointZ;
|
return x == pointX && z == pointZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long murmur64(long h) {
|
|
||||||
h ^= h >>> 33;
|
|
||||||
h *= 0xff51afd7ed558ccdL;
|
|
||||||
h ^= h >>> 33;
|
|
||||||
h *= 0xc4ceb9fe1a85ec53L;
|
|
||||||
h ^= h >>> 33;
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.flora.flora.gen;
|
package com.dfsek.terra.addons.flora.flora.gen;
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -24,6 +22,7 @@ import com.dfsek.terra.api.structure.Structure;
|
|||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,11 +14,11 @@ import java.util.function.Supplier;
|
|||||||
import com.dfsek.terra.addons.feature.locator.config.AdjacentPatternLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.AdjacentPatternLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.GaussianRandomLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.GaussianRandomLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.Sampler3DLocatorTemplate;
|
|
||||||
import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate;
|
|
||||||
import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.locator.config.Sampler3DLocatorTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.TopLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.TopLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.XorLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.XorLocatorTemplate;
|
||||||
|
|||||||
-1
@@ -11,7 +11,6 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
import com.dfsek.terra.api.util.Range;
|
import com.dfsek.terra.api.util.Range;
|
||||||
|
|||||||
-2
@@ -10,9 +10,7 @@ package com.dfsek.terra.addons.feature.locator.config;
|
|||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
|
||||||
import com.dfsek.terra.addons.feature.locator.locators.TopLocator;
|
import com.dfsek.terra.addons.feature.locator.locators.TopLocator;
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
import com.dfsek.terra.api.util.Range;
|
import com.dfsek.terra.api.util.Range;
|
||||||
|
|||||||
+2
-2
@@ -12,11 +12,11 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import com.dfsek.tectonic.api.exception.ValidationException;
|
import com.dfsek.tectonic.api.exception.ValidationException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class XorLocatorTemplate implements ObjectTemplate<Locator>, ValidatedConfigTemplate {
|
public class XorLocatorTemplate implements ObjectTemplate<Locator>, ValidatedConfigTemplate {
|
||||||
@Value("locators")
|
@Value("locators")
|
||||||
|
|||||||
+2
-2
@@ -12,11 +12,11 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import com.dfsek.tectonic.api.exception.ValidationException;
|
import com.dfsek.tectonic.api.exception.ValidationException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class XorPatternTemplate implements ObjectTemplate<Pattern>, ValidatedConfigTemplate {
|
public class XorPatternTemplate implements ObjectTemplate<Pattern>, ValidatedConfigTemplate {
|
||||||
@Value("patterns")
|
@Value("patterns")
|
||||||
|
|||||||
+2
-2
@@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.feature.locator.locators;
|
package com.dfsek.terra.addons.feature.locator.locators;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
import com.dfsek.terra.api.util.Range;
|
import com.dfsek.terra.api.util.Range;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class GaussianRandomLocator implements Locator {
|
public class GaussianRandomLocator implements Locator {
|
||||||
private final double mean;
|
private final double mean;
|
||||||
|
|||||||
+1
-2
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.feature.locator.locators;
|
package com.dfsek.terra.addons.feature.locator.locators;
|
||||||
|
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,6 +15,7 @@ import com.dfsek.terra.api.noise.NoiseSampler;
|
|||||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||||
|
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||||
|
|
||||||
|
|
||||||
public class SamplerLocator implements Locator {
|
public class SamplerLocator implements Locator {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public class TopLocator implements Locator {
|
|||||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||||
for(int y : search) {
|
for(int y : search) {
|
||||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||||
return new BinaryColumn(y, y+1, yi -> true);
|
return new BinaryColumn(y, y + 1, yi -> true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BinaryColumn.getNull();
|
return BinaryColumn.getNull();
|
||||||
|
|||||||
+2
-2
@@ -2,12 +2,12 @@ package com.dfsek.terra.addons.noise.config.templates;
|
|||||||
|
|
||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.BinaryArithmeticSampler;
|
import com.dfsek.terra.addons.noise.samplers.arithmetic.BinaryArithmeticSampler;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
|
|
||||||
public class BinaryArithmeticTemplate<T extends BinaryArithmeticSampler> extends SamplerTemplate<T> {
|
public class BinaryArithmeticTemplate<T extends BinaryArithmeticSampler> extends SamplerTemplate<T> {
|
||||||
private final BiFunction<NoiseSampler, NoiseSampler, T> function;
|
private final BiFunction<NoiseSampler, NoiseSampler, T> function;
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
|||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
|
||||||
public class AdditionSampler extends BinaryArithmeticSampler{
|
public class AdditionSampler extends BinaryArithmeticSampler {
|
||||||
public AdditionSampler(NoiseSampler left, NoiseSampler right) {
|
public AdditionSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ public abstract class BinaryArithmeticSampler implements NoiseSampler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double noise(long seed, double x, double y) {
|
public double noise(long seed, double x, double y) {
|
||||||
return operate(left.noise(seed, x, y),right.noise(seed, x, y));
|
return operate(left.noise(seed, x, y), right.noise(seed, x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
|||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
|
||||||
public class DivisionSampler extends BinaryArithmeticSampler{
|
public class DivisionSampler extends BinaryArithmeticSampler {
|
||||||
public DivisionSampler(NoiseSampler left, NoiseSampler right) {
|
public DivisionSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||||
|
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
public class MaxSampler extends BinaryArithmeticSampler{
|
|
||||||
|
public class MaxSampler extends BinaryArithmeticSampler {
|
||||||
public MaxSampler(NoiseSampler left, NoiseSampler right) {
|
public MaxSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||||
|
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
public class MinSampler extends BinaryArithmeticSampler{
|
|
||||||
|
public class MinSampler extends BinaryArithmeticSampler {
|
||||||
public MinSampler(NoiseSampler left, NoiseSampler right) {
|
public MinSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
|||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
|
||||||
public class MultiplicationSampler extends BinaryArithmeticSampler{
|
public class MultiplicationSampler extends BinaryArithmeticSampler {
|
||||||
public MultiplicationSampler(NoiseSampler left, NoiseSampler right) {
|
public MultiplicationSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
|||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
|
||||||
public class SubtractionSampler extends BinaryArithmeticSampler{
|
public class SubtractionSampler extends BinaryArithmeticSampler {
|
||||||
public SubtractionSampler(NoiseSampler left, NoiseSampler right) {
|
public SubtractionSampler(NoiseSampler left, NoiseSampler right) {
|
||||||
super(left, right);
|
super(left, right);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -18,10 +18,10 @@ public class GaborNoiseSampler extends NoiseFunction {
|
|||||||
private double a = 0.1;
|
private double a = 0.1;
|
||||||
private double f0 = 0.625;
|
private double f0 = 0.625;
|
||||||
private double kernelRadius = (FastMath.sqrt(-FastMath.log(0.05) / Math.PI) / a);
|
private double kernelRadius = (FastMath.sqrt(-FastMath.log(0.05) / Math.PI) / a);
|
||||||
private double impulsesPerKernel = 64d;
|
|
||||||
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
|
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
|
||||||
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
|
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
|
||||||
private double g = FastMath.exp(-impulsesPerCell);
|
private double g = FastMath.exp(-impulsesPerCell);
|
||||||
|
private double impulsesPerKernel = 64d;
|
||||||
private double omega0 = Math.PI * 0.25;
|
private double omega0 = Math.PI * 0.25;
|
||||||
private boolean isotropic = true;
|
private boolean isotropic = true;
|
||||||
|
|
||||||
|
|||||||
-3
@@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.noise.samplers.noise.random;
|
package com.dfsek.terra.addons.noise.samplers.noise.random;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.noise.samplers.noise.NoiseFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NoiseSampler implementation to produce random, uniformly distributed (white) noise.
|
* NoiseSampler implementation to produce random, uniformly distributed (white) noise.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
|
|||||||
@Override
|
@Override
|
||||||
public VanillaOre build(OreTemplate config, Platform platform) {
|
public VanillaOre build(OreTemplate config, Platform platform) {
|
||||||
BlockState m = config.getMaterial();
|
BlockState m = config.getMaterial();
|
||||||
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(), config.getMaterialOverrides());
|
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||||
|
config.getMaterialOverrides());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.ore.ores;
|
package com.dfsek.terra.addons.ore.ores;
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -19,6 +17,7 @@ import com.dfsek.terra.api.block.state.BlockState;
|
|||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
|
||||||
@@ -87,11 +86,11 @@ public class VanillaOre implements Structure {
|
|||||||
BlockType block = world.getBlockState(x, y, z).getBlockType();
|
BlockType block = world.getBlockState(x, y, z).getBlockType();
|
||||||
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) {
|
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) {
|
||||||
if(exposed > random.nextDouble() || !(world.getBlockState(x, y, z - 1).isAir() ||
|
if(exposed > random.nextDouble() || !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||||
world.getBlockState(x, y, z + 1).isAir() ||
|
world.getBlockState(x, y, z + 1).isAir() ||
|
||||||
world.getBlockState(x, y - 1, z).isAir() ||
|
world.getBlockState(x, y - 1, z).isAir() ||
|
||||||
world.getBlockState(x, y + 1, z).isAir() ||
|
world.getBlockState(x, y + 1, z).isAir() ||
|
||||||
world.getBlockState(x - 1, y, z).isAir() ||
|
world.getBlockState(x - 1, y, z).isAir() ||
|
||||||
world.getBlockState(x + 1, y, z).isAir())) {
|
world.getBlockState(x + 1, y, z).isAir())) {
|
||||||
world.setBlockState(x, y, z, getMaterial(block), isApplyGravity());
|
world.setBlockState(x, y, z, getMaterial(block), isApplyGravity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -7,17 +7,10 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.palette;
|
package com.dfsek.terra.addons.palette;
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
|
||||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.palette.palette.PaletteImpl;
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.config.ConfigFactory;
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.api.config.ConfigType;
|
import com.dfsek.terra.api.config.ConfigType;
|
||||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.palette.palette;
|
package com.dfsek.terra.addons.palette.palette;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representation of a "slice" of the world.
|
* A class representation of a "slice" of the world.
|
||||||
|
|||||||
-9
@@ -10,20 +10,11 @@ package com.dfsek.terra.addons.palette.palette;
|
|||||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
|
||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
|
||||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
|
||||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
|
||||||
|
|
||||||
import java.lang.reflect.AnnotatedType;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
|
||||||
public class PaletteLayerLoader implements ObjectTemplate<PaletteLayerHolder> {
|
public class PaletteLayerLoader implements ObjectTemplate<PaletteLayerHolder> {
|
||||||
@Value("materials")
|
@Value("materials")
|
||||||
|
|||||||
+1
-1
@@ -13,8 +13,8 @@ import java.util.Random;
|
|||||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
|
||||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||||
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||||
|
|||||||
-3
@@ -9,9 +9,6 @@ package com.dfsek.terra.addons.manifest.impl;
|
|||||||
|
|
||||||
import ca.solostudios.strata.version.Version;
|
import ca.solostudios.strata.version.Version;
|
||||||
import ca.solostudios.strata.version.VersionRange;
|
import ca.solostudios.strata.version.VersionRange;
|
||||||
|
|
||||||
import com.dfsek.terra.api.inject.impl.InjectorImpl;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -21,7 +21,8 @@ import java.lang.reflect.AnnotatedType;
|
|||||||
|
|
||||||
public class VersionLoader implements TypeLoader<Version> {
|
public class VersionLoader implements TypeLoader<Version> {
|
||||||
@Override
|
@Override
|
||||||
public Version load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker) throws LoadException {
|
public Version load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker)
|
||||||
|
throws LoadException {
|
||||||
try {
|
try {
|
||||||
return Versions.parseVersion((String) c);
|
return Versions.parseVersion((String) c);
|
||||||
} catch(ParseException e) {
|
} catch(ParseException e) {
|
||||||
|
|||||||
+2
-1
@@ -21,7 +21,8 @@ import java.lang.reflect.AnnotatedType;
|
|||||||
|
|
||||||
public class VersionRangeLoader implements TypeLoader<VersionRange> {
|
public class VersionRangeLoader implements TypeLoader<VersionRange> {
|
||||||
@Override
|
@Override
|
||||||
public VersionRange load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker) throws LoadException {
|
public VersionRange load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker)
|
||||||
|
throws LoadException {
|
||||||
try {
|
try {
|
||||||
return Versions.parseVersionRange((String) c);
|
return Versions.parseVersionRange((String) c);
|
||||||
} catch(ParseException e) {
|
} catch(ParseException e) {
|
||||||
|
|||||||
+3
-2
@@ -22,8 +22,9 @@ public class PaletteBlockShortcutAddon implements AddonInitializer {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack()
|
.then(event -> event.getPack()
|
||||||
.registerShortcut(Palette.class, "BLOCK",
|
.registerShortcut(Palette.class, "BLOCK",
|
||||||
(configLoader, input, tracker) -> new SingletonPalette(configLoader.loadType(BlockState.class, input, tracker))))
|
(configLoader, input, tracker) -> new SingletonPalette(
|
||||||
|
configLoader.loadType(BlockState.class, input, tracker))))
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -1,14 +1,13 @@
|
|||||||
package com.dfsek.terra.addons.palette.shortcut.block;
|
package com.dfsek.terra.addons.palette.shortcut.block;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class SingletonStructure implements Structure {
|
public class SingletonStructure implements Structure {
|
||||||
private final BlockState blockState;
|
private final BlockState blockState;
|
||||||
|
|||||||
+4
-3
@@ -22,9 +22,10 @@ public class StructureBlockShortcutAddon implements AddonInitializer {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack()
|
.then(event -> event.getPack()
|
||||||
.registerShortcut(Structure.class, "BLOCK",
|
.registerShortcut(Structure.class, "BLOCK",
|
||||||
(configLoader, input, tracker) -> new SingletonStructure(configLoader.loadType(BlockState.class, input, tracker)
|
(configLoader, input, tracker) -> new SingletonStructure(
|
||||||
)))
|
configLoader.loadType(BlockState.class, input, tracker)
|
||||||
|
)))
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,7 @@
|
|||||||
package com.dfsek.terra.addons.structure.mutator;
|
package com.dfsek.terra.addons.structure.mutator;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
@@ -9,8 +11,6 @@ import com.dfsek.terra.api.world.WritableWorld;
|
|||||||
import com.dfsek.terra.api.world.util.ReadInterceptor;
|
import com.dfsek.terra.api.world.util.ReadInterceptor;
|
||||||
import com.dfsek.terra.api.world.util.WriteInterceptor;
|
import com.dfsek.terra.api.world.util.WriteInterceptor;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
||||||
private final RegistryKey key;
|
private final RegistryKey key;
|
||||||
|
|||||||
-2
@@ -1,7 +1,5 @@
|
|||||||
package com.dfsek.terra.addons.structure.mutator.config;
|
package com.dfsek.terra.addons.structure.mutator.config;
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ contributors:
|
|||||||
- Terra contributors
|
- Terra contributors
|
||||||
id: structure-mutator
|
id: structure-mutator
|
||||||
version: @VERSION@
|
version: @VERSION@
|
||||||
entrypoints: []
|
entrypoints: [ ]
|
||||||
website:
|
website:
|
||||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||||
source: https://github.com/PolyhedralDev/Terra
|
source: https://github.com/PolyhedralDev/Terra
|
||||||
|
|||||||
-2
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript;
|
package com.dfsek.terra.addons.terrascript;
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.parser.lang;
|
package com.dfsek.terra.addons.terrascript.parser.lang;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||||
|
|
||||||
|
|
||||||
public class Scope {
|
public class Scope {
|
||||||
private static final Scope NULL = new Scope() {
|
private static final Scope NULL = new Scope() {
|
||||||
|
|||||||
+5
-1
@@ -7,11 +7,15 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.parser.lang.keywords.looplike;
|
package com.dfsek.terra.addons.terrascript.parser.lang.keywords.looplike;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.*;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Keyword;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -7,7 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.parser.lang.keywords.looplike;
|
package com.dfsek.terra.addons.terrascript.parser.lang.keywords.looplike;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.*;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Keyword;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -7,10 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script;
|
package com.dfsek.terra.addons.terrascript.script;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -45,9 +41,12 @@ import com.dfsek.terra.addons.terrascript.script.builders.ZeroArgFunctionBuilder
|
|||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
import com.dfsek.terra.api.structure.LootTable;
|
import com.dfsek.terra.api.structure.LootTable;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,8 +24,8 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
|||||||
private final WritableWorld world;
|
private final WritableWorld world;
|
||||||
private final Map<Vector3, String> marks = new HashMap<>();
|
private final Map<Vector3, String> marks = new HashMap<>();
|
||||||
private final int recursions;
|
private final int recursions;
|
||||||
private boolean waterlog = false;
|
|
||||||
private final Vector3Int origin;
|
private final Vector3Int origin;
|
||||||
|
private boolean waterlog = false;
|
||||||
|
|
||||||
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, Random random, WritableWorld world, int recursions) {
|
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, Random random, WritableWorld world, int recursions) {
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
|||||||
+1
-1
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|||||||
+6
-9
@@ -7,30 +7,27 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.constants.StringConstant;
|
import com.dfsek.terra.addons.terrascript.parser.lang.constants.StringConstant;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||||
import com.dfsek.terra.api.util.RotationUtil;
|
import com.dfsek.terra.api.util.RotationUtil;
|
||||||
import com.dfsek.terra.api.util.vector.Vector2;
|
import com.dfsek.terra.api.util.vector.Vector2;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class BlockFunction implements Function<Void> {
|
public class BlockFunction implements Function<Void> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(BlockFunction.class);
|
private static final Logger logger = LoggerFactory.getLogger(BlockFunction.class);
|
||||||
@@ -79,8 +76,8 @@ public class BlockFunction implements Function<Void> {
|
|||||||
rot = RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
rot = RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||||
try {
|
try {
|
||||||
Vector3.Mutable set = Vector3.of(FastMath.roundToInt(xz.getX()),
|
Vector3.Mutable set = Vector3.of(FastMath.roundToInt(xz.getX()),
|
||||||
y.apply(implementationArguments, scope).doubleValue(),
|
y.apply(implementationArguments, scope).doubleValue(),
|
||||||
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
||||||
BlockState current = arguments.getWorld().getBlockState(set);
|
BlockState current = arguments.getWorld().getBlockState(set);
|
||||||
if(overwrite.apply(implementationArguments, scope) || current.isAir()) {
|
if(overwrite.apply(implementationArguments, scope) || current.isAir()) {
|
||||||
if(arguments.isWaterlog() && current.has(Properties.WATERLOGGED) && current.getBlockType().isWater()) {
|
if(arguments.isWaterlog() && current.has(Properties.WATERLOGGED) && current.getBlockType().isWater()) {
|
||||||
|
|||||||
+1
-1
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|||||||
+6
-1
@@ -48,7 +48,12 @@ public class EntityFunction implements Function<Void> {
|
|||||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||||
|
|
||||||
Entity entity = arguments.getWorld().spawnEntity(Vector3.of(xz.getX(), y.apply(implementationArguments, scope).doubleValue(), xz.getZ()).mutable().add(arguments.getOrigin()).add(0.5, 0, 0.5).immutable(), data);
|
Entity entity = arguments.getWorld().spawnEntity(Vector3.of(xz.getX(), y.apply(implementationArguments, scope).doubleValue(),
|
||||||
|
xz.getZ())
|
||||||
|
.mutable()
|
||||||
|
.add(arguments.getOrigin())
|
||||||
|
.add(0.5, 0, 0.5)
|
||||||
|
.immutable(), data);
|
||||||
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getPack(), entity));
|
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getPack(), entity));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
@@ -38,7 +38,11 @@ public class GetMarkFunction implements Function<String> {
|
|||||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||||
|
|
||||||
String mark = arguments.getMark(Vector3.of(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(
|
String mark = arguments.getMark(Vector3.of(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(
|
||||||
y.apply(implementationArguments, scope).doubleValue()), FastMath.floorToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable());
|
y.apply(implementationArguments, scope).doubleValue()),
|
||||||
|
FastMath.floorToInt(xz.getZ()))
|
||||||
|
.mutable()
|
||||||
|
.add(arguments.getOrigin())
|
||||||
|
.immutable());
|
||||||
return mark == null ? "" : mark;
|
return mark == null ? "" : mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-8
@@ -7,14 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
|
||||||
import com.dfsek.terra.api.block.entity.Container;
|
|
||||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -23,15 +15,21 @@ import java.util.Random;
|
|||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||||
|
import com.dfsek.terra.api.block.entity.Container;
|
||||||
|
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
import com.dfsek.terra.api.structure.LootTable;
|
import com.dfsek.terra.api.structure.LootTable;
|
||||||
import com.dfsek.terra.api.util.RotationUtil;
|
import com.dfsek.terra.api.util.RotationUtil;
|
||||||
import com.dfsek.terra.api.util.vector.Vector2;
|
import com.dfsek.terra.api.util.vector.Vector2;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
|
|
||||||
|
|
||||||
public class LootFunction implements Function<Void> {
|
public class LootFunction implements Function<Void> {
|
||||||
|
|||||||
+2
-2
@@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.constants.ConstantExpression;
|
import com.dfsek.terra.addons.terrascript.parser.lang.constants.ConstantExpression;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
@@ -49,7 +49,7 @@ public class PullFunction implements Function<Void> {
|
|||||||
BlockState rot = RotationUtil.rotateBlockData(data, arguments.getRotation().inverse());
|
BlockState rot = RotationUtil.rotateBlockData(data, arguments.getRotation().inverse());
|
||||||
|
|
||||||
Vector3.Mutable mutable = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
Vector3.Mutable mutable = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||||
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
||||||
while(mutable.getY() > arguments.getWorld().getMinHeight()) {
|
while(mutable.getY() > arguments.getWorld().getMinHeight()) {
|
||||||
if(!arguments.getWorld().getBlockState(mutable).isAir()) {
|
if(!arguments.getWorld().getBlockState(mutable).isAir()) {
|
||||||
arguments.getWorld().setBlockState(mutable, rot);
|
arguments.getWorld().setBlockState(mutable, rot);
|
||||||
|
|||||||
+5
-4
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
@@ -41,9 +41,10 @@ public class SetMarkFunction implements Function<Void> {
|
|||||||
|
|
||||||
|
|
||||||
arguments.setMark(Vector3.of(FastMath.floorToInt(xz.getX()),
|
arguments.setMark(Vector3.of(FastMath.floorToInt(xz.getX()),
|
||||||
FastMath.floorToInt(
|
FastMath.floorToInt(
|
||||||
y.apply(implementationArguments, scope).doubleValue()),
|
y.apply(implementationArguments, scope).doubleValue()),
|
||||||
FastMath.floorToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable(), mark.apply(implementationArguments, scope));
|
FastMath.floorToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable(),
|
||||||
|
mark.apply(implementationArguments, scope));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -7,23 +7,21 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||||
import com.dfsek.terra.api.util.RotationUtil;
|
import com.dfsek.terra.api.util.RotationUtil;
|
||||||
import com.dfsek.terra.api.util.vector.Vector2;
|
import com.dfsek.terra.api.util.vector.Vector2;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class StateFunction implements Function<Void> {
|
public class StateFunction implements Function<Void> {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(StateFunction.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(StateFunction.class);
|
||||||
@@ -48,7 +46,7 @@ public class StateFunction implements Function<Void> {
|
|||||||
|
|
||||||
|
|
||||||
Vector3 origin = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
Vector3 origin = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||||
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable();
|
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable();
|
||||||
try {
|
try {
|
||||||
BlockEntity state = arguments.getWorld().getBlockEntity(origin);
|
BlockEntity state = arguments.getWorld().getBlockEntity(origin);
|
||||||
state.applyState(data.apply(implementationArguments, scope));
|
state.applyState(data.apply(implementationArguments, scope));
|
||||||
|
|||||||
+2
-3
@@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -18,7 +15,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
|
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
|
|||||||
@@ -8,13 +8,11 @@
|
|||||||
package structure;
|
package structure;
|
||||||
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
||||||
@@ -22,6 +20,7 @@ import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
|||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,12 @@
|
|||||||
package structure;
|
package structure;
|
||||||
|
|
||||||
|
import net.jafama.FastMath;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Block;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
@@ -12,13 +19,6 @@ import com.dfsek.terra.addons.terrascript.script.builders.UnaryNumberFunctionBui
|
|||||||
import com.dfsek.terra.addons.terrascript.script.builders.UnaryStringFunctionBuilder;
|
import com.dfsek.terra.addons.terrascript.script.builders.UnaryStringFunctionBuilder;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class PerformanceTest {
|
public class PerformanceTest {
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
|
|||||||
+3
-3
@@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addon.terrascript.check;
|
package com.dfsek.terra.addon.terrascript.check;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
||||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
@@ -44,13 +44,13 @@ public class CheckFunction implements Function<String> {
|
|||||||
|
|
||||||
|
|
||||||
Vector2 xz = Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
Vector2 xz = Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||||
z.apply(implementationArguments, scope).doubleValue());
|
z.apply(implementationArguments, scope).doubleValue());
|
||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
Vector3 location = arguments.getOrigin().toVector3Mutable().add(
|
Vector3 location = arguments.getOrigin().toVector3Mutable().add(
|
||||||
Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
||||||
FastMath.roundToInt(xz.getZ()))).immutable();
|
FastMath.roundToInt(xz.getZ()))).immutable();
|
||||||
|
|
||||||
return apply(location, arguments.getWorld());
|
return apply(location, arguments.getWorld());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -23,7 +23,8 @@ public class TerraScriptCheckFunctionAddon implements AddonInitializer {
|
|||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.priority(1)
|
.priority(1)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().getOrCreateRegistry(FunctionBuilder.class).register(addon.key("check"), new CheckFunctionBuilder(platform));
|
event.getPack().getOrCreateRegistry(FunctionBuilder.class).register(addon.key("check"),
|
||||||
|
new CheckFunctionBuilder(platform));
|
||||||
})
|
})
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,7 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.sampler;
|
package com.dfsek.terra.addons.terrascript.sampler;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
@@ -8,8 +10,6 @@ import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
|||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
|
|
||||||
public class SamplerFunction implements Function<Number> {
|
public class SamplerFunction implements Function<Number> {
|
||||||
private final Returnable<Number> x, y, z;
|
private final Returnable<Number> x, y, z;
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,12 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.sampler;
|
package com.dfsek.terra.addons.terrascript.sampler;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
|
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable.ReturnType;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable.ReturnType;
|
||||||
@@ -9,13 +16,6 @@ import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
|||||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
|
|
||||||
public class SamplerFunctionBuilder implements FunctionBuilder<SamplerFunction> {
|
public class SamplerFunctionBuilder implements FunctionBuilder<SamplerFunction> {
|
||||||
private final Map<String, DimensionApplicableNoiseSampler> samplers2d;
|
private final Map<String, DimensionApplicableNoiseSampler> samplers2d;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public interface BaseAddon extends StringIdentifiable, Namespaced {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the dependencies of this addon.
|
* Gets the dependencies of this addon.
|
||||||
|
*
|
||||||
* @return Map of dependency ID to {@link VersionRange} of dependency
|
* @return Map of dependency ID to {@link VersionRange} of dependency
|
||||||
*/
|
*/
|
||||||
default Map<String, VersionRange> getDependencies() {
|
default Map<String, VersionRange> getDependencies() {
|
||||||
@@ -36,6 +37,7 @@ public interface BaseAddon extends StringIdentifiable, Namespaced {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of the addon
|
* Get the version of the addon
|
||||||
|
*
|
||||||
* @return Version of addon
|
* @return Version of addon
|
||||||
*/
|
*/
|
||||||
Version getVersion();
|
Version getVersion();
|
||||||
|
|||||||
+3
-2
@@ -14,12 +14,13 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing a bootstrap addon.
|
* Interface representing a bootstrap addon.
|
||||||
*
|
* <p>
|
||||||
* A bootstrap addon is the only type of addon Terra implements a loader for.
|
* A bootstrap addon is the only type of addon Terra implements a loader for.
|
||||||
* It is a minimal base for addon loaders to be implemented on top of.
|
* It is a minimal base for addon loaders to be implemented on top of.
|
||||||
*
|
* <p>
|
||||||
* Unless you are writing your own addon loader, you will want to depend on the
|
* Unless you are writing your own addon loader, you will want to depend on the
|
||||||
* {@code manifest-addon-loader} addon, and implement its AddonInitializer.
|
* {@code manifest-addon-loader} addon, and implement its AddonInitializer.
|
||||||
|
*
|
||||||
* @param <T> Type of addon this bootstrap addon loads
|
* @param <T> Type of addon this bootstrap addon loads
|
||||||
*/
|
*/
|
||||||
public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
||||||
|
|||||||
@@ -17,18 +17,21 @@ import com.dfsek.terra.api.block.state.BlockState;
|
|||||||
public interface BlockType extends Handle {
|
public interface BlockType extends Handle {
|
||||||
/**
|
/**
|
||||||
* Get the default {@link BlockState} of this block
|
* Get the default {@link BlockState} of this block
|
||||||
|
*
|
||||||
* @return Default block state
|
* @return Default block state
|
||||||
*/
|
*/
|
||||||
BlockState getDefaultState();
|
BlockState getDefaultState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether this block is solid.
|
* Get whether this block is solid.
|
||||||
|
*
|
||||||
* @return Whether this block is solid.
|
* @return Whether this block is solid.
|
||||||
*/
|
*/
|
||||||
boolean isSolid();
|
boolean isSolid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether this block is water.
|
* Get whether this block is water.
|
||||||
|
*
|
||||||
* @return Whether this block is water.
|
* @return Whether this block is water.
|
||||||
*/
|
*/
|
||||||
boolean isWater();
|
boolean isWater();
|
||||||
|
|||||||
@@ -21,39 +21,49 @@ public interface BlockState extends Handle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this {@link BlockState} matches another.
|
* Whether this {@link BlockState} matches another.
|
||||||
*
|
* <p>
|
||||||
* "matches" is defined as this {@link BlockState} holding a matching {@link #getBlockType()}.
|
* "matches" is defined as this {@link BlockState} holding a matching {@link #getBlockType()}.
|
||||||
|
*
|
||||||
* @param other Other {@link BlockState}
|
* @param other Other {@link BlockState}
|
||||||
|
*
|
||||||
* @return Whether this state matches the other
|
* @return Whether this state matches the other
|
||||||
*/
|
*/
|
||||||
boolean matches(BlockState other);
|
boolean matches(BlockState other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether this {@link BlockState} has a {@link Property}.
|
* Check whether this {@link BlockState} has a {@link Property}.
|
||||||
|
*
|
||||||
* @param property Property to check for
|
* @param property Property to check for
|
||||||
|
*
|
||||||
* @return Whether this state has the property.
|
* @return Whether this state has the property.
|
||||||
*/
|
*/
|
||||||
<T extends Comparable<T>> boolean has(Property<T> property);
|
<T extends Comparable<T>> boolean has(Property<T> property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a {@link Property} on this state.
|
* Get the value of a {@link Property} on this state.
|
||||||
|
*
|
||||||
* @param property Property to get
|
* @param property Property to get
|
||||||
|
*
|
||||||
* @return Value of the property
|
* @return Value of the property
|
||||||
*/
|
*/
|
||||||
<T extends Comparable<T>> T get(Property<T> property);
|
<T extends Comparable<T>> T get(Property<T> property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new {@link BlockState} with a {@link Property} set to a value.
|
* Return a new {@link BlockState} with a {@link Property} set to a value.
|
||||||
|
*
|
||||||
* @param property Property to set
|
* @param property Property to set
|
||||||
* @param value Value of property
|
* @param value Value of property
|
||||||
|
*
|
||||||
* @return New {@link BlockState} with property set.
|
* @return New {@link BlockState} with property set.
|
||||||
*/
|
*/
|
||||||
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an action on this {@link BlockState} if it contains a {@link Property}
|
* Perform an action on this {@link BlockState} if it contains a {@link Property}
|
||||||
|
*
|
||||||
* @param property Property to check for
|
* @param property Property to check for
|
||||||
* @param action Action to perform if property is present
|
* @param action Action to perform if property is present
|
||||||
|
*
|
||||||
* @return This {@link BlockState}
|
* @return This {@link BlockState}
|
||||||
*/
|
*/
|
||||||
default <T extends Comparable<T>> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
default <T extends Comparable<T>> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
||||||
@@ -63,8 +73,10 @@ public interface BlockState extends Handle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a {@link Property} on this {@link BlockState} if it is present.
|
* Set the value of a {@link Property} on this {@link BlockState} if it is present.
|
||||||
|
*
|
||||||
* @param property Property to check for/set.
|
* @param property Property to check for/set.
|
||||||
* @param value Value to set if property is present.
|
* @param value Value to set if property is present.
|
||||||
|
*
|
||||||
* @return Thie {@link BlockState}
|
* @return Thie {@link BlockState}
|
||||||
*/
|
*/
|
||||||
default <T extends Comparable<T>> BlockState setIfPresent(Property<T> property, T value) {
|
default <T extends Comparable<T>> BlockState setIfPresent(Property<T> property, T value) {
|
||||||
@@ -74,12 +86,14 @@ public interface BlockState extends Handle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link BlockType} this state applies to.
|
* Get the {@link BlockType} this state applies to.
|
||||||
|
*
|
||||||
* @return Block type.
|
* @return Block type.
|
||||||
*/
|
*/
|
||||||
BlockType getBlockType();
|
BlockType getBlockType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this state and its properties as a String
|
* Get this state and its properties as a String
|
||||||
|
*
|
||||||
* @return String representation of this state
|
* @return String representation of this state
|
||||||
*/
|
*/
|
||||||
default String getAsString() {
|
default String getAsString() {
|
||||||
@@ -88,13 +102,16 @@ public interface BlockState extends Handle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this state and its properties as a String
|
* Get this state and its properties as a String
|
||||||
|
*
|
||||||
* @param properties Whether to include properties
|
* @param properties Whether to include properties
|
||||||
|
*
|
||||||
* @return String representation of this state
|
* @return String representation of this state
|
||||||
*/
|
*/
|
||||||
String getAsString(boolean properties);
|
String getAsString(boolean properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether this BlockState is air
|
* Get whether this BlockState is air
|
||||||
|
*
|
||||||
* @return Whether this state is air
|
* @return Whether this state is air
|
||||||
*/
|
*/
|
||||||
boolean isAir();
|
boolean isAir();
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.block.state.properties;
|
package com.dfsek.terra.api.block.state.properties;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a property a state holds
|
* Represents a property a state holds
|
||||||
@@ -18,12 +18,14 @@ import java.util.Collection;
|
|||||||
public interface Property<T> extends StringIdentifiable {
|
public interface Property<T> extends StringIdentifiable {
|
||||||
/**
|
/**
|
||||||
* Get all possible values of this property
|
* Get all possible values of this property
|
||||||
|
*
|
||||||
* @return All values of this property
|
* @return All values of this property
|
||||||
*/
|
*/
|
||||||
Collection<T> values();
|
Collection<T> values();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of this property.
|
* Get the type of this property.
|
||||||
|
*
|
||||||
* @return {@link Class} instance representing the type of this property
|
* @return {@link Class} instance representing the type of this property
|
||||||
*/
|
*/
|
||||||
Class<T> getType();
|
Class<T> getType();
|
||||||
|
|||||||
+1
@@ -14,6 +14,7 @@ import com.dfsek.terra.api.block.state.properties.enums.RailShape;
|
|||||||
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
||||||
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public final class Properties {
|
public final class Properties {
|
||||||
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("facing", Direction.class);
|
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("facing", Direction.class);
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.command;
|
package com.dfsek.terra.api.command;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Handle;
|
import com.dfsek.terra.api.Handle;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.entity.Player;
|
import com.dfsek.terra.api.entity.Player;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
|
|
||||||
public interface CommandSender extends Handle {
|
public interface CommandSender extends Handle {
|
||||||
void sendMessage(String message);
|
void sendMessage(String message);
|
||||||
|
|||||||
+13
-14
@@ -5,16 +5,6 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.exception.NoSuchEntryException;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
|
||||||
|
|
||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@@ -26,6 +16,11 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
|
import com.dfsek.terra.api.registry.exception.NoSuchEntryException;
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
||||||
private RegistryArgument(
|
private RegistryArgument(
|
||||||
@@ -63,19 +58,23 @@ public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T, R> Builder<T, R> builder(String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeKey<R> registryType) {
|
public static <T, R> Builder<T, R> builder(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
|
||||||
|
TypeKey<R> registryType) {
|
||||||
return new Builder<>(name, registryFunction, (TypeToken<R>) TypeToken.get(registryType.getType()));
|
return new Builder<>(name, registryFunction, (TypeToken<R>) TypeToken.get(registryType.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> CommandArgument<T, R> of(String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeKey<R> registryType) {
|
public static <T, R> CommandArgument<T, R> of(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
|
||||||
|
TypeKey<R> registryType) {
|
||||||
return RegistryArgument.<T, R>builder(name, registryFunction, registryType).build();
|
return RegistryArgument.<T, R>builder(name, registryFunction, registryType).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeKey<R> registryType) {
|
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
|
||||||
|
TypeKey<R> registryType) {
|
||||||
return RegistryArgument.builder(name, registryFunction, registryType).asOptional().build();
|
return RegistryArgument.builder(name, registryFunction, registryType).asOptional().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeKey<R> registryType, String defaultKey) {
|
public static <T, R> CommandArgument<T, R> optional(String name, Function<CommandContext<T>, Registry<R>> registryFunction,
|
||||||
|
TypeKey<R> registryType, String defaultKey) {
|
||||||
return RegistryArgument.builder(name, registryFunction, registryType).asOptionalWithDefault(defaultKey).build();
|
return RegistryArgument.builder(name, registryFunction, registryType).asOptionalWithDefault(defaultKey).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.properties.PropertyHolder;
|
import com.dfsek.terra.api.properties.PropertyHolder;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
import com.dfsek.terra.api.registry.meta.CheckedRegistryHolder;
|
import com.dfsek.terra.api.registry.meta.CheckedRegistryHolder;
|
||||||
import com.dfsek.terra.api.registry.meta.RegistryHolder;
|
|
||||||
import com.dfsek.terra.api.registry.meta.RegistryProvider;
|
import com.dfsek.terra.api.registry.meta.RegistryProvider;
|
||||||
import com.dfsek.terra.api.tectonic.ConfigLoadingDelegate;
|
import com.dfsek.terra.api.tectonic.ConfigLoadingDelegate;
|
||||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.config;
|
package com.dfsek.terra.api.config;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ package com.dfsek.terra.api.noise;
|
|||||||
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector2;
|
import com.dfsek.terra.api.util.vector.Vector2;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector2Int;
|
import com.dfsek.terra.api.util.vector.Vector2Int;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.registry;
|
package com.dfsek.terra.api.registry;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||||
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
|
||||||
|
|
||||||
public interface CheckedRegistry<T> extends Registry<T> {
|
public interface CheckedRegistry<T> extends Registry<T> {
|
||||||
|
|||||||
@@ -7,12 +7,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.registry;
|
package com.dfsek.terra.api.registry;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||||
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
|
||||||
|
|
||||||
public interface OpenRegistry<T> extends Registry<T> {
|
public interface OpenRegistry<T> extends Registry<T> {
|
||||||
|
|||||||
@@ -8,10 +8,6 @@
|
|||||||
package com.dfsek.terra.api.registry;
|
package com.dfsek.terra.api.registry;
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -23,6 +19,9 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
public interface Registry<T> extends TypeLoader<T> {
|
public interface Registry<T> extends TypeLoader<T> {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user