mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 07:55:28 +00:00
commit
4daf2d65ee
9
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
9
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@ -37,9 +37,12 @@ assignees: ""
|
||||
-->
|
||||
|
||||
- [ ] I have checked that I am on the latest version of Terra.
|
||||
- [ ] I have searched the github issue tracker for similar issues, including closed ones.
|
||||
- [ ] I have made sure that this is not a bug with another mod or plugin, and it is Terra that is causing the issue.
|
||||
- [ ] I have checked that this is an issue with Terra and not an issue with the pack I am using.
|
||||
- [ ] I have searched the github issue tracker for similar issues, including
|
||||
closed ones.
|
||||
- [ ] I have made sure that this is not a bug with another mod or plugin, and it
|
||||
is Terra that is causing the issue.
|
||||
- [ ] I have checked that this is an issue with Terra and not an issue with the
|
||||
pack I am using.
|
||||
<!-- If this is an issue with the default Terra pack, please open an issue on the pack repo: https://github.com/PolyhedralDev/TerraDefaultConfig/issues/new -->
|
||||
- [ ] I have attached a copy of the `latest.log` file
|
||||
- [ ] I have filled out and provided all the appropriate information.
|
||||
|
6
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
6
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
@ -31,9 +31,11 @@ assignees: ""
|
||||
-->
|
||||
|
||||
- [ ] 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.
|
||||
- [ ] 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
|
||||
|
||||
|
3
.github/ISSUE_TEMPLATE/OTHER_ISSUES.md
vendored
3
.github/ISSUE_TEMPLATE/OTHER_ISSUES.md
vendored
@ -1,6 +1,7 @@
|
||||
---
|
||||
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: ""
|
||||
labels: "Type: Question, Status: Pending"
|
||||
assignees: ""
|
||||
|
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -33,9 +33,11 @@
|
||||
|
||||
<!-- In order to be accepted, your changes must be under the GPLv3 license. Please check one of the following: -->
|
||||
|
||||
- [ ] I am the original author of this code, and I am willing to release it under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
||||
- [ ] I am not the original author of this code, but it is in public domain or released
|
||||
under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or a compatible license.
|
||||
- [ ] I am the original author of this code, and I am willing to release it
|
||||
under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
||||
- [ ] I am not the original author of this code, but it is in public domain or
|
||||
released under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or a
|
||||
compatible license.
|
||||
<!--
|
||||
Please provide reliable evidence of this.
|
||||
NOTE: for compatible licenses, you must make sure to add the included license somewhere in the program, if so required.
|
||||
@ -70,19 +72,24 @@
|
||||
|
||||
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
|
||||
- [ ] Build system <!-- Anything which pretain to the build system. -->
|
||||
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
||||
- [ ]
|
||||
Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
||||
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
|
||||
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
|
||||
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
||||
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
||||
- [ ]
|
||||
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
||||
- [ ]
|
||||
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
||||
- [ ] Revert <!-- Anything which reverts previous commits. -->
|
||||
- [ ] Style <!-- Anything which updates style. -->
|
||||
- [ ] Tests <!-- Anything which adds or updates tests. -->
|
||||
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
||||
- [ ]
|
||||
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
||||
|
||||
#### Compatiblity
|
||||
|
||||
- [ ] 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.
|
||||
<!--
|
||||
A change which does not break *any* previous functionality of Terra.
|
||||
@ -94,8 +101,9 @@
|
||||
|
||||
#### Contribution Guidelines.
|
||||
|
||||
- [ ] I have read the [`CONTRIBUTING.md`](https://github.com/PolyhedralDev/Terra/blob/master/CONTRIBUTING.md) document in the root of the
|
||||
git repository.
|
||||
- [ ] I have read
|
||||
the [`CONTRIBUTING.md`](https://github.com/PolyhedralDev/Terra/blob/master/CONTRIBUTING.md)
|
||||
document in the root of the git repository.
|
||||
- [ ] My code follows the code style for this
|
||||
project. <!-- There is an included `.editorconfig` file in the base of the repo. Please use a plugin for your IDE of choice that follows those settings. -->
|
||||
|
||||
|
@ -27,8 +27,8 @@ for everyone. We do not tolerate harassment of participants in any form.
|
||||
## When and How to Use These Guidelines
|
||||
|
||||
This code of conduct applies to all Terra community spaces, both online and off.
|
||||
This applies to the github discussion tab, the
|
||||
[Polyhedral Development community discord server](https://discord.gg/PXUEbbF),
|
||||
This applies to the github discussion tab, the
|
||||
[Polyhedral Development community discord server](https://discord.gg/PXUEbbF),
|
||||
and any other Terra community. In addition, we may choose to invoke them in
|
||||
instances of harassment outside the Terra communities, and we will punish the
|
||||
responsible individuals appropriately. We will not tolerate harassment in any
|
||||
@ -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
|
||||
always be open to the possibility of being wrong. Nobody can always be right,
|
||||
and we are only human; we are
|
||||
[fallible](https://www.merriam-webster.com/dictionary/fallible) by nature.
|
||||
It is okay to make mistakes, but we must be willing to admit when we make one.
|
||||
[fallible](https://www.merriam-webster.com/dictionary/fallible) by nature. It is
|
||||
okay to make mistakes, but we must be willing to admit when we make one.
|
||||
|
||||
### Be Direct but Professional
|
||||
|
||||
|
@ -77,9 +77,9 @@ Unsure where to begin contributing to Terra? You can start by looking through "
|
||||
beginner" and "help wanted" issues:
|
||||
|
||||
- [Beginner issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Good%20First%20Issue)
|
||||
- issues which should be friendly to anyone new to terra.
|
||||
- issues which should be friendly to anyone new to terra.
|
||||
- [Help wanted issues](https://github.com/PolyhedralDev/Terra/labels/Note%3A%20Help%20Wanted)
|
||||
- issues which should be a bit more involved than "beginner" issues.
|
||||
- issues which should be a bit more involved than "beginner" issues.
|
||||
|
||||
New to github? Working on your first Pull Request? Check
|
||||
out [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github)
|
||||
@ -365,8 +365,9 @@ into packs) is acceptable in the platform project.
|
||||
|
||||
#### Specific Compatibility
|
||||
|
||||
Specific compatibility should *not* be put in the platform project. (Example: Adding
|
||||
the ability to generate TechCraft v7's doo-dads with a TerraScript function)
|
||||
Specific compatibility should *not* be put in the platform project. (Example:
|
||||
Adding the ability to generate TechCraft v7's doo-dads with a TerraScript
|
||||
function)
|
||||
|
||||
Having specific compatibilities leads to tons of extra dependencies to keep
|
||||
track of, as well as adding lots of additional stuff to maintain. It quickly
|
||||
|
@ -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
|
||||
a lot to be added!
|
||||
|
||||
|
||||
## Special Thanks
|
||||
|
||||
[](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
|
||||
can be!
|
||||
|
||||
YourKit supports open source projects with innovative and intelligent tools
|
||||
for monitoring and profiling Java and .NET applications.
|
||||
YourKit is the creator of the
|
||||
YourKit supports open source projects with innovative and intelligent tools for
|
||||
monitoring and profiling Java and .NET applications. YourKit is the creator of
|
||||
the
|
||||
[YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
|
||||
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
|
||||
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
preRelease(true)
|
||||
|
||||
versionProjects(":common:api", version("6.0.0"))
|
||||
|
@ -21,7 +21,7 @@ fun Project.addonDir(dir: File, task: Task) {
|
||||
it.delete()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = if(tasks.findByName("shadowJar") != null) {
|
||||
val jar = if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(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.gradle.api.JavaVersion
|
||||
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.withType
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import com.dfsek.terra.tectonicdoc.TectonicDocPlugin
|
||||
|
||||
fun Project.configureCompilation() {
|
||||
apply(plugin = "maven-publish")
|
||||
|
@ -149,7 +149,7 @@ fun downloadPack(packUrl: URL, project: Project) {
|
||||
}
|
||||
|
||||
fun Project.getJarTask(): Jar {
|
||||
return if(tasks.findByName("shadowJar") != null) {
|
||||
return if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
|
@ -4,7 +4,7 @@ object Versions {
|
||||
const val paralithic = "0.6.0"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.6.1"
|
||||
const val cloud = "1.6.2"
|
||||
|
||||
const val slf4j = "1.7.32"
|
||||
const val log4j_slf4j_impl = "2.14.1"
|
||||
@ -19,9 +19,11 @@ object Versions {
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricAPI = "0.44.0+1.18"
|
||||
const val minecraft = "1.18.1"
|
||||
const val yarn = "$minecraft+build.7"
|
||||
const val fabricLoader = "0.13.3"
|
||||
const val fabricAPI = "0.48.0+1.18.2"
|
||||
const val minecraft = "1.18.2"
|
||||
const val yarn = "$minecraft+build.2"
|
||||
const val permissionsAPI = "0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
object Bukkit {
|
||||
|
@ -36,7 +36,7 @@ abstract class GenerateDocsTask : DefaultTask() {
|
||||
.relativize(file.toPath())
|
||||
.toString()
|
||||
.substringBeforeLast('.')
|
||||
if(name.endsWith("Template")) {
|
||||
if (name.endsWith("Template")) {
|
||||
name = name.substringBeforeLast("Template")
|
||||
}
|
||||
classes[name] = node
|
||||
@ -98,7 +98,7 @@ abstract class GenerateDocsTask : DefaultTask() {
|
||||
}
|
||||
|
||||
private fun getType(node: FieldNode): String {
|
||||
if(node.signature != null) {
|
||||
if (node.signature != null) {
|
||||
return generic(node.signature)
|
||||
}
|
||||
return descriptorToHumanReadable(node.desc).substringAfterLast('.')
|
||||
@ -107,9 +107,9 @@ abstract class GenerateDocsTask : DefaultTask() {
|
||||
private fun generic(type: String): String {
|
||||
val clean = descriptorToHumanReadable(type)
|
||||
|
||||
if(clean.contains('<')) {
|
||||
if (clean.contains('<')) {
|
||||
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('.')
|
||||
@ -127,21 +127,21 @@ abstract class GenerateDocsTask : DefaultTask() {
|
||||
}
|
||||
|
||||
private fun descriptorToHumanReadable(descriptor: String): String {
|
||||
if(descriptor.startsWith('L')) {
|
||||
if (descriptor.startsWith('L')) {
|
||||
return descriptor.substring(1).substringBeforeLast(';').replace('/', '.')
|
||||
}
|
||||
if(descriptor.startsWith("[")) {
|
||||
if (descriptor.startsWith("[")) {
|
||||
return "${descriptorToHumanReadable(descriptor.substring(1))}[]"
|
||||
}
|
||||
return when(descriptor) {
|
||||
"B" -> "byte"
|
||||
"C" -> "char"
|
||||
"I" -> "int"
|
||||
"D" -> "double"
|
||||
"F" -> "float"
|
||||
"J" -> "long"
|
||||
"S" -> "short"
|
||||
"Z" -> "boolean"
|
||||
return when (descriptor) {
|
||||
"B" -> "byte"
|
||||
"C" -> "char"
|
||||
"I" -> "int"
|
||||
"D" -> "double"
|
||||
"F" -> "float"
|
||||
"J" -> "long"
|
||||
"S" -> "short"
|
||||
"Z" -> "boolean"
|
||||
else -> descriptor
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.dfsek.terra.tectonicdoc
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
class TectonicDocPlugin: Plugin<Project> {
|
||||
class TectonicDocPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.tasks.create("generateDocs", GenerateDocsTask::class.java)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
return Collections.emptySet();
|
||||
|
@ -41,7 +41,8 @@ public class ImageBiomeProviderAddon implements AddonInitializer {
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
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();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -4,7 +4,6 @@ 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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
@ -22,7 +21,8 @@ public class BiomeDelegateLoader implements TypeLoader<BiomeDelegate> {
|
||||
}
|
||||
|
||||
@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();
|
||||
return biomeRegistry
|
||||
.getByID((String) c)
|
||||
|
@ -21,10 +21,10 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
|
||||
@Value("resolution")
|
||||
@Default
|
||||
@Description("""
|
||||
The resolution at which to sample biomes.
|
||||
|
||||
Larger values are quadratically faster, but produce lower quality results.
|
||||
For example, a value of 3 would sample every 3 blocks.""")
|
||||
The resolution at which to sample biomes.
|
||||
|
||||
Larger values are quadratically faster, but produce lower quality results.
|
||||
For example, a value of 3 would sample every 3 blocks.""")
|
||||
protected @Meta int resolution = 1;
|
||||
@Value("blend.sampler")
|
||||
@Default
|
||||
|
@ -8,8 +8,6 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
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.ProtoChunk;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
|
||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
@ -87,7 +86,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||
seed);
|
||||
seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ public class ChunkInterpolator {
|
||||
for(int x = 0; x < 5; x++) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class);
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class);
|
||||
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
|
||||
|
||||
int step = generationSettings.blendStep();
|
||||
|
@ -8,12 +8,8 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
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 java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class ElevationInterpolator {
|
||||
private final double[][] values = new double[18][18];
|
||||
@ -39,10 +35,11 @@ public class ElevationInterpolator {
|
||||
|
||||
BiomeNoiseProperties center = gens[x + 1 + smooth][z + 1 + smooth];
|
||||
boolean same = true;
|
||||
|
||||
|
||||
for(int xi = -smooth; xi <= smooth; xi++) {
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -17,23 +17,16 @@
|
||||
|
||||
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.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
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 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 {
|
||||
private final Cache<WorldContext, Sampler3D> cache;
|
||||
@ -53,8 +46,9 @@ public class SamplerProvider {
|
||||
public Sampler3D getChunk(int cx, int cz, WorldProperties world, BiomeProvider provider) {
|
||||
WorldContext context = new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight());
|
||||
try {
|
||||
return cache.get(context, () -> new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider,
|
||||
elevationSmooth));
|
||||
return cache.get(context,
|
||||
() -> new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider,
|
||||
elevationSmooth));
|
||||
} catch(ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -6,16 +6,12 @@ import cloud.commandframework.CommandManager;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
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.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.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class AddonsCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
@ -32,7 +28,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.register(addon, CommandRegistrationEvent.class)
|
||||
.then(event -> {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("addons", ArgumentDescription.of("List installed Terra addons"))
|
||||
.permission("terra.addons")
|
||||
@ -55,9 +51,9 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.handler(context -> {
|
||||
BaseAddon addon = context.get("addon");
|
||||
StringBuilder addonInfo = new StringBuilder("Addon ").append(addon.getID()).append('\n');
|
||||
|
||||
|
||||
addonInfo.append("Version: ").append(addon.getVersion().getFormatted()).append('\n');
|
||||
|
||||
|
||||
addonInfo.append("Dependencies:\n");
|
||||
addon.getDependencies().forEach((id, versions) -> addonInfo
|
||||
.append(" - ")
|
||||
|
@ -2,30 +2,18 @@ package com.dfsek.terra.addons.commands.packs;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
|
||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.LongArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
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.arguments.RegistryArgument;
|
||||
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.functional.FunctionalEventHandler;
|
||||
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 {
|
||||
@ -45,7 +33,7 @@ public class PacksCommandAddon implements AddonInitializer {
|
||||
.register(addon, CommandRegistrationEvent.class)
|
||||
.then(event -> {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("packs", ArgumentDescription.of("List installed config packs"))
|
||||
.permission("terra.packs")
|
||||
@ -66,10 +54,10 @@ public class PacksCommandAddon implements AddonInitializer {
|
||||
.handler(context -> {
|
||||
ConfigPack pack = context.get("pack");
|
||||
StringBuilder packInfo = new StringBuilder("Pack ").append(pack.getID()).append('\n');
|
||||
|
||||
|
||||
packInfo.append("Version: ").append(pack.getVersion().getFormatted()).append('\n');
|
||||
packInfo.append("Author: ").append(pack.getAuthor()).append('\n');
|
||||
|
||||
|
||||
packInfo.append("Addon Dependencies:\n");
|
||||
pack.addons().forEach((id, versions) -> packInfo
|
||||
.append(" - ")
|
||||
|
@ -2,19 +2,17 @@ package com.dfsek.terra.addons.commands.profiler;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
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.event.events.platform.CommandRegistrationEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class ProfilerCommandAddon implements AddonInitializer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProfilerCommandAddon.class);
|
||||
|
@ -2,16 +2,17 @@ package com.dfsek.terra.addons.commands.structure;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
|
||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.LongArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
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.arguments.RegistryArgument;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||
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.reflection.TypeKey;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class StructureCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
@ -31,6 +30,9 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
@ -39,31 +41,27 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
.register(addon, CommandRegistrationEvent.class)
|
||||
.then(event -> {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
|
||||
.literal("generate")
|
||||
.argument(RegistryArgument.builder("structure",
|
||||
StructureCommandAddon::getStructureRegistry,
|
||||
TypeKey.of(Structure.class)))
|
||||
.argument(LongArgument.optional("seed", 0))
|
||||
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
|
||||
.handler(context -> {
|
||||
Structure structure = context.get("structure");
|
||||
Entity sender = context.getSender().getEntity().orElseThrow();
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")),
|
||||
context.get("rotation")
|
||||
);
|
||||
})
|
||||
.permission("terra.structures.generate")
|
||||
.literal("generate")
|
||||
.argument(RegistryArgument.builder("structure",
|
||||
StructureCommandAddon::getStructureRegistry,
|
||||
TypeKey.of(Structure.class)))
|
||||
.argument(LongArgument.optional("seed", 0))
|
||||
.argument(EnumArgument.optional(Rotation.class, "rotation", Rotation.NONE))
|
||||
.handler(context -> {
|
||||
Structure structure = context.get("structure");
|
||||
Entity sender = context.getSender().getEntity().orElseThrow();
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")),
|
||||
context.get("rotation")
|
||||
);
|
||||
})
|
||||
.permission("terra.structures.generate")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.getSender().getEntity().orElseThrow().world().getPack().getRegistry(Structure.class);
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,8 @@ import com.dfsek.tectonic.api.config.template.annotations.Final;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
@ -11,6 +11,7 @@ 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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.List;
|
||||
@ -18,13 +19,12 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PaletteHolderLoader implements TypeLoader<PaletteHolder> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@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;
|
||||
PaletteHolderBuilder builder = new PaletteHolderBuilder();
|
||||
for(Map<String, Integer> layer : palette) {
|
||||
|
@ -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.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.PaddedGridDistributorTemplate;
|
||||
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.YesDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.util.Point;
|
||||
@ -50,7 +50,7 @@ public class DistributorAddon implements AddonInitializer {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event
|
||||
.getPack()
|
||||
.getOrCreateRegistry(DISTRIBUTOR_TOKEN);
|
||||
|
||||
|
||||
distributorRegistry.register(addon.key("SAMPLER"), SamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("POINTS"), PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("PADDED_GRID"), PaddedGridDistributorTemplate::new);
|
||||
|
@ -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.exception.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class XorDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||
@Value("distributors")
|
||||
|
@ -1,13 +1,12 @@
|
||||
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 java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class PaddedGridDistributor implements Distributor {
|
||||
private final int width;
|
||||
@ -22,19 +21,6 @@ public class PaddedGridDistributor implements Distributor {
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
|
||||
private static long murmur64(long h) {
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
@ -43,4 +29,17 @@ public class PaddedGridDistributor implements Distributor {
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.flora.flora.gen;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
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.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
|
@ -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.AndLocatorTemplate;
|
||||
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.PatternLocatorTemplate;
|
||||
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.TopLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.XorLocatorTemplate;
|
||||
@ -63,13 +63,13 @@ public class LocatorAddon implements AddonInitializer {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
||||
locatorRegistry.register(addon.key("SURFACE"), SurfaceLocatorTemplate::new);
|
||||
locatorRegistry.register(addon.key("TOP"), TopLocatorTemplate::new);
|
||||
|
||||
|
||||
locatorRegistry.register(addon.key("RANDOM"), RandomLocatorTemplate::new);
|
||||
locatorRegistry.register(addon.key("GAUSSIAN_RANDOM"), GaussianRandomLocatorTemplate::new);
|
||||
|
||||
|
||||
locatorRegistry.register(addon.key("PATTERN"), PatternLocatorTemplate::new);
|
||||
locatorRegistry.register(addon.key("ADJACENT_PATTERN"), AdjacentPatternLocatorTemplate::new);
|
||||
|
||||
|
||||
locatorRegistry.register(addon.key("SAMPLER"), SamplerLocatorTemplate::new);
|
||||
locatorRegistry.register(addon.key("SAMPLER_3D"), Sampler3DLocatorTemplate::new);
|
||||
|
||||
|
@ -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.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.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
@ -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.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
||||
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.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
@ -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.exception.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class XorLocatorTemplate implements ObjectTemplate<Locator>, ValidatedConfigTemplate {
|
||||
@Value("locators")
|
||||
|
@ -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.exception.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class XorPatternTemplate implements ObjectTemplate<Pattern>, ValidatedConfigTemplate {
|
||||
@Value("patterns")
|
||||
|
@ -7,14 +7,14 @@
|
||||
|
||||
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.Locator;
|
||||
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.BinaryColumnBuilder;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class GaussianRandomLocator implements Locator {
|
||||
private final double mean;
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
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.Locator;
|
||||
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 {
|
||||
|
@ -24,7 +24,7 @@ public class TopLocator implements Locator {
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
for(int y : search) {
|
||||
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();
|
||||
|
@ -2,12 +2,12 @@ package com.dfsek.terra.addons.noise.config.templates;
|
||||
|
||||
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.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
||||
public class BinaryArithmeticTemplate<T extends BinaryArithmeticSampler> extends SamplerTemplate<T> {
|
||||
private final BiFunction<NoiseSampler, NoiseSampler, T> function;
|
||||
|
@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class AdditionSampler extends BinaryArithmeticSampler{
|
||||
public class AdditionSampler extends BinaryArithmeticSampler {
|
||||
public AdditionSampler(NoiseSampler left, NoiseSampler right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public abstract class BinaryArithmeticSampler implements NoiseSampler {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class DivisionSampler extends BinaryArithmeticSampler{
|
||||
public class DivisionSampler extends BinaryArithmeticSampler {
|
||||
public DivisionSampler(NoiseSampler left, NoiseSampler right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
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) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
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) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class MultiplicationSampler extends BinaryArithmeticSampler{
|
||||
public class MultiplicationSampler extends BinaryArithmeticSampler {
|
||||
public MultiplicationSampler(NoiseSampler left, NoiseSampler right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.dfsek.terra.addons.noise.samplers.arithmetic;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class SubtractionSampler extends BinaryArithmeticSampler{
|
||||
public class SubtractionSampler extends BinaryArithmeticSampler {
|
||||
public SubtractionSampler(NoiseSampler left, NoiseSampler right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
|
||||
@Override
|
||||
public VanillaOre build(OreTemplate config, Platform platform) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.ore.ores;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
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.util.Rotation;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@ -47,36 +46,36 @@ public class VanillaOre implements Structure {
|
||||
int centerX = location.getX();
|
||||
int centerZ = location.getZ();
|
||||
int centerY = location.getY();
|
||||
|
||||
|
||||
|
||||
|
||||
float f = random.nextFloat() * (float) Math.PI;
|
||||
|
||||
|
||||
double d1 = centerX + 8 + FastMath.sin(f) * size / 8.0F;
|
||||
double d2 = centerX + 8 - FastMath.sin(f) * size / 8.0F;
|
||||
double d3 = centerZ + 8 + FastMath.cos(f) * size / 8.0F;
|
||||
double d4 = centerZ + 8 - FastMath.cos(f) * size / 8.0F;
|
||||
|
||||
|
||||
double d5 = centerY + random.nextInt(3) - 2D;
|
||||
double d6 = centerY + random.nextInt(3) - 2D;
|
||||
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
float iFactor = (float) i / (float) size;
|
||||
|
||||
|
||||
double d10 = random.nextDouble() * size / 16.0D;
|
||||
double d11 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
double d12 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
|
||||
|
||||
int xStart = FastMath.roundToInt(FastMath.floor(d1 + (d2 - d1) * iFactor - d11 / 2.0D));
|
||||
int yStart = FastMath.roundToInt(FastMath.floor(d5 + (d6 - d5) * iFactor - d12 / 2.0D));
|
||||
int zStart = FastMath.roundToInt(FastMath.floor(d3 + (d4 - d3) * iFactor - d11 / 2.0D));
|
||||
|
||||
|
||||
int xEnd = FastMath.roundToInt(FastMath.floor(d1 + (d2 - d1) * iFactor + d11 / 2.0D));
|
||||
int yEnd = FastMath.roundToInt(FastMath.floor(d5 + (d6 - d5) * iFactor + d12 / 2.0D));
|
||||
int zEnd = FastMath.roundToInt(FastMath.floor(d3 + (d4 - d3) * iFactor + d11 / 2.0D));
|
||||
|
||||
|
||||
for(int x = xStart; x <= xEnd; x++) {
|
||||
double d13 = (x + 0.5D - (d1 + (d2 - d1) * iFactor)) / (d11 / 2.0D);
|
||||
|
||||
|
||||
if(d13 * d13 < 1.0D) {
|
||||
for(int y = yStart; y <= yEnd; y++) {
|
||||
double d14 = (y + 0.5D - (d5 + (d6 - d5) * iFactor)) / (d12 / 2.0D);
|
||||
@ -87,11 +86,11 @@ public class VanillaOre implements Structure {
|
||||
BlockType block = world.getBlockState(x, y, z).getBlockType();
|
||||
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) {
|
||||
if(exposed > random.nextDouble() || !(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 - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).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 - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).isAir())) {
|
||||
world.setBlockState(x, y, z, getMaterial(block), isApplyGravity());
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,10 @@
|
||||
|
||||
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.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
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.world.chunk.generation.util.Palette;
|
||||
|
||||
|
@ -7,14 +7,14 @@
|
||||
|
||||
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.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
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.
|
||||
|
@ -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.Value;
|
||||
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.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PaletteLayerLoader implements ObjectTemplate<PaletteLayerHolder> {
|
||||
@Value("materials")
|
||||
|
@ -13,8 +13,8 @@ import java.util.Random;
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
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.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
|
@ -38,6 +38,6 @@ public class StructureGenerationAddon implements AddonInitializer {
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ public class StructureGenerationStage implements GenerationStage {
|
||||
|
||||
@Override
|
||||
public void populate(ProtoWorld world) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,6 @@ package com.dfsek.terra.addons.manifest.impl;
|
||||
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
|
||||
import com.dfsek.terra.api.inject.impl.InjectorImpl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -21,7 +21,8 @@ import java.lang.reflect.AnnotatedType;
|
||||
|
||||
public class VersionLoader implements TypeLoader<Version> {
|
||||
@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 {
|
||||
return Versions.parseVersion((String) c);
|
||||
} catch(ParseException e) {
|
||||
|
@ -21,7 +21,8 @@ import java.lang.reflect.AnnotatedType;
|
||||
|
||||
public class VersionRangeLoader implements TypeLoader<VersionRange> {
|
||||
@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 {
|
||||
return Versions.parseVersionRange((String) c);
|
||||
} catch(ParseException e) {
|
||||
|
@ -22,8 +22,9 @@ public class PaletteBlockShortcutAddon implements AddonInitializer {
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.registerShortcut(Palette.class, "BLOCK",
|
||||
(configLoader, input, tracker) -> new SingletonPalette(configLoader.loadType(BlockState.class, input, tracker))))
|
||||
.registerShortcut(Palette.class, "BLOCK",
|
||||
(configLoader, input, tracker) -> new SingletonPalette(
|
||||
configLoader.loadType(BlockState.class, input, tracker))))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
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.registry.key.RegistryKey;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class SingletonStructure implements Structure {
|
||||
private final BlockState blockState;
|
||||
|
@ -22,9 +22,10 @@ public class StructureBlockShortcutAddon implements AddonInitializer {
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.registerShortcut(Structure.class, "BLOCK",
|
||||
(configLoader, input, tracker) -> new SingletonStructure(configLoader.loadType(BlockState.class, input, tracker)
|
||||
)))
|
||||
.registerShortcut(Structure.class, "BLOCK",
|
||||
(configLoader, input, tracker) -> new SingletonStructure(
|
||||
configLoader.loadType(BlockState.class, input, tracker)
|
||||
)))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.RegistryKey;
|
||||
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.WriteInterceptor;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
||||
private final RegistryKey key;
|
||||
|
@ -1,7 +1,5 @@
|
||||
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.terra.api.config.AbstractableTemplate;
|
||||
|
@ -3,7 +3,7 @@ contributors:
|
||||
- Terra contributors
|
||||
id: structure-mutator
|
||||
version: @VERSION@
|
||||
entrypoints: []
|
||||
entrypoints: [ ]
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
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.terrascript.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
|
@ -1,10 +1,10 @@
|
||||
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.Map;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||
|
||||
|
||||
public class Scope {
|
||||
private static final Scope NULL = new Scope() {
|
||||
@ -12,7 +12,7 @@ public class Scope {
|
||||
public Variable<?> get(String id) {
|
||||
throw new IllegalStateException("Cannot get variable from null scope: " + id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void put(String id, Variable<?> variable) {
|
||||
throw new IllegalStateException("Cannot set variable in null scope: " + id);
|
||||
@ -38,7 +38,7 @@ public class Scope {
|
||||
public void put(String id, Variable<?> variable) {
|
||||
variableMap.put(id, variable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Scope sub() {
|
||||
return new Scope(this);
|
||||
|
@ -7,11 +7,15 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.keywords.looplike;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
@ -7,7 +7,11 @@
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
@ -7,10 +7,6 @@
|
||||
|
||||
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 org.apache.commons.io.IOUtils;
|
||||
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.profiler.ProfileFrame;
|
||||
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.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@ -68,7 +67,7 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
|
||||
//noinspection unchecked
|
||||
functionRegistry.forEach((key, function) -> parser.registerFunction(key.getID(), function)); // Register registry functions.
|
||||
|
||||
|
@ -24,8 +24,8 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
private final WritableWorld world;
|
||||
private final Map<Vector3, String> marks = new HashMap<>();
|
||||
private final int recursions;
|
||||
private boolean waterlog = false;
|
||||
private final Vector3Int origin;
|
||||
private boolean waterlog = false;
|
||||
|
||||
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, Random random, WritableWorld world, int recursions) {
|
||||
this.rotation = rotation;
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
@ -7,30 +7,27 @@
|
||||
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
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.variables.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
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.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BlockFunction implements Function<Void> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BlockFunction.class);
|
||||
@ -74,13 +71,13 @@ public class BlockFunction implements Function<Void> {
|
||||
TerraImplementationArguments arguments, BlockState rot) {
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
|
||||
|
||||
rot = RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||
try {
|
||||
Vector3.Mutable set = Vector3.of(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).doubleValue(),
|
||||
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
||||
y.apply(implementationArguments, scope).doubleValue(),
|
||||
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin());
|
||||
BlockState current = arguments.getWorld().getBlockState(set);
|
||||
if(overwrite.apply(implementationArguments, scope) || current.isAir()) {
|
||||
if(arguments.isWaterlog() && current.has(Properties.WATERLOGGED) && current.getBlockType().isWater()) {
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
@ -47,8 +47,13 @@ public class EntityFunction implements Function<Void> {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
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));
|
||||
return null;
|
||||
}
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@ -36,9 +36,13 @@ public class GetMarkFunction implements Function<String> {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,6 @@
|
||||
|
||||
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 org.slf4j.Logger;
|
||||
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.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.script.StructureScript;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
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.key.RegistryKey;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
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.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.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
@ -45,11 +45,11 @@ public class PullFunction implements Function<Void> {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
BlockState rot = RotationUtil.rotateBlockData(data, arguments.getRotation().inverse());
|
||||
|
||||
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()) {
|
||||
if(!arguments.getWorld().getBlockState(mutable).isAir()) {
|
||||
arguments.getWorld().setBlockState(mutable, rot);
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@ -38,12 +38,13 @@ public class SetMarkFunction implements Function<Void> {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
|
||||
|
||||
arguments.setMark(Vector3.of(FastMath.floorToInt(xz.getX()),
|
||||
FastMath.floorToInt(
|
||||
y.apply(implementationArguments, scope).doubleValue()),
|
||||
FastMath.floorToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable(), mark.apply(implementationArguments, scope));
|
||||
FastMath.floorToInt(
|
||||
y.apply(implementationArguments, scope).doubleValue()),
|
||||
FastMath.floorToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable(),
|
||||
mark.apply(implementationArguments, scope));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,23 +7,21 @@
|
||||
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
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.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class StateFunction implements Function<Void> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StateFunction.class);
|
||||
@ -45,10 +43,10 @@ public class StateFunction implements Function<Void> {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
|
||||
|
||||
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 {
|
||||
BlockEntity state = arguments.getWorld().getBlockEntity(origin);
|
||||
state.applyState(data.apply(implementationArguments, scope));
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
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 org.slf4j.Logger;
|
||||
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.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.script.StructureScript;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
@ -61,11 +60,11 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
if(arguments.getRecursions() > platform.getTerraConfig().getMaxRecursion())
|
||||
throw new RuntimeException("Structure recursion too deep: " + arguments.getRecursions());
|
||||
|
||||
|
||||
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
|
||||
|
||||
|
||||
|
||||
|
||||
String app = id.apply(implementationArguments, scope);
|
||||
return registry.getByID(app).map(script -> {
|
||||
Rotation rotation1;
|
||||
|
@ -8,13 +8,11 @@
|
||||
package structure;
|
||||
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
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.ImplementationArguments;
|
||||
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.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
@ -1,5 +1,12 @@
|
||||
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.lang.Block;
|
||||
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.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 static void main(String... args) throws IOException {
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
package com.dfsek.terra.addon.terrascript.check;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
||||
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.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.script.TerraImplementationArguments;
|
||||
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(),
|
||||
z.apply(implementationArguments, scope).doubleValue());
|
||||
z.apply(implementationArguments, scope).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
Vector3 location = arguments.getOrigin().toVector3Mutable().add(
|
||||
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());
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ public class TerraScriptCheckFunctionAddon implements AddonInitializer {
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(1)
|
||||
.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();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.Returnable;
|
||||
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.api.noise.NoiseSampler;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
public class SamplerFunction implements Function<Number> {
|
||||
private final Returnable<Number> x, y, z;
|
||||
|
@ -1,5 +1,12 @@
|
||||
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.terrascript.parser.lang.Returnable;
|
||||
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.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> {
|
||||
private final Map<String, DimensionApplicableNoiseSampler> samplers2d;
|
||||
|
@ -28,6 +28,7 @@ public interface BaseAddon extends StringIdentifiable, Namespaced {
|
||||
|
||||
/**
|
||||
* Gets the dependencies of this addon.
|
||||
*
|
||||
* @return Map of dependency ID to {@link VersionRange} of dependency
|
||||
*/
|
||||
default Map<String, VersionRange> getDependencies() {
|
||||
@ -36,6 +37,7 @@ public interface BaseAddon extends StringIdentifiable, Namespaced {
|
||||
|
||||
/**
|
||||
* Get the version of the addon
|
||||
*
|
||||
* @return Version of addon
|
||||
*/
|
||||
Version getVersion();
|
||||
|
@ -14,12 +14,13 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
/**
|
||||
* Interface representing a bootstrap addon.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
*
|
||||
* <p>
|
||||
* Unless you are writing your own addon loader, you will want to depend on the
|
||||
* {@code manifest-addon-loader} addon, and implement its AddonInitializer.
|
||||
*
|
||||
* @param <T> Type of addon this bootstrap addon loads
|
||||
*/
|
||||
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 {
|
||||
/**
|
||||
* Get the default {@link BlockState} of this block
|
||||
*
|
||||
* @return Default block state
|
||||
*/
|
||||
BlockState getDefaultState();
|
||||
|
||||
/**
|
||||
* Get whether this block is solid.
|
||||
*
|
||||
* @return Whether this block is solid.
|
||||
*/
|
||||
boolean isSolid();
|
||||
|
||||
/**
|
||||
* Get whether this block is water.
|
||||
*
|
||||
* @return Whether this block is water.
|
||||
*/
|
||||
boolean isWater();
|
||||
|
@ -21,39 +21,49 @@ public interface BlockState extends Handle {
|
||||
|
||||
/**
|
||||
* Whether this {@link BlockState} matches another.
|
||||
*
|
||||
* <p>
|
||||
* "matches" is defined as this {@link BlockState} holding a matching {@link #getBlockType()}.
|
||||
*
|
||||
* @param other Other {@link BlockState}
|
||||
*
|
||||
* @return Whether this state matches the other
|
||||
*/
|
||||
boolean matches(BlockState other);
|
||||
|
||||
/**
|
||||
* Check whether this {@link BlockState} has a {@link Property}.
|
||||
*
|
||||
* @param property Property to check for
|
||||
*
|
||||
* @return Whether this state has the property.
|
||||
*/
|
||||
<T extends Comparable<T>> boolean has(Property<T> property);
|
||||
|
||||
/**
|
||||
* Get the value of a {@link Property} on this state.
|
||||
*
|
||||
* @param property Property to get
|
||||
*
|
||||
* @return Value of the property
|
||||
*/
|
||||
<T extends Comparable<T>> T get(Property<T> property);
|
||||
|
||||
/**
|
||||
* Return a new {@link BlockState} with a {@link Property} set to a value.
|
||||
*
|
||||
* @param property Property to set
|
||||
* @param value Value of property
|
||||
* @param value Value of property
|
||||
*
|
||||
* @return New {@link BlockState} with property set.
|
||||
*/
|
||||
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
||||
|
||||
/**
|
||||
* Perform an action on this {@link BlockState} if it contains a {@link Property}
|
||||
*
|
||||
* @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}
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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}
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return Block type.
|
||||
*/
|
||||
BlockType getBlockType();
|
||||
|
||||
/**
|
||||
* Get this state and its properties as a String
|
||||
*
|
||||
* @return String representation of this state
|
||||
*/
|
||||
default String getAsString() {
|
||||
@ -88,13 +102,16 @@ public interface BlockState extends Handle {
|
||||
|
||||
/**
|
||||
* Get this state and its properties as a String
|
||||
*
|
||||
* @param properties Whether to include properties
|
||||
*
|
||||
* @return String representation of this state
|
||||
*/
|
||||
String getAsString(boolean properties);
|
||||
|
||||
/**
|
||||
* Get whether this BlockState is air
|
||||
*
|
||||
* @return Whether this state is air
|
||||
*/
|
||||
boolean isAir();
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.api.block.state.properties;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a property a state holds
|
||||
@ -18,12 +18,14 @@ import java.util.Collection;
|
||||
public interface Property<T> extends StringIdentifiable {
|
||||
/**
|
||||
* Get all possible values of this property
|
||||
*
|
||||
* @return All values of this property
|
||||
*/
|
||||
Collection<T> values();
|
||||
|
||||
/**
|
||||
* Get the type of this property.
|
||||
*
|
||||
* @return {@link Class} instance representing the type of this property
|
||||
*/
|
||||
Class<T> getType();
|
||||
|
@ -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.WallHeight;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public final class Properties {
|
||||
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("facing", Direction.class);
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.api.command;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public interface CommandSender extends Handle {
|
||||
void sendMessage(String message);
|
||||
|
@ -5,16 +5,6 @@ import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
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 org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -26,6 +16,11 @@ import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
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> {
|
||||
private RegistryArgument(
|
||||
@ -63,19 +58,23 @@ public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
||||
}
|
||||
|
||||
@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()));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -89,7 +88,7 @@ public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
||||
this.registryFunction = commandContext -> registry;
|
||||
this.typeToken = (TypeToken<R>) TypeToken.get(registry.getType().getType());
|
||||
}
|
||||
|
||||
|
||||
private Builder(@NonNull String name, Function<CommandContext<T>, Registry<R>> registryFunction, TypeToken<R> typeToken) {
|
||||
super(typeToken, name);
|
||||
this.typeToken = typeToken;
|
||||
|
@ -15,11 +15,9 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
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.RegistryKey;
|
||||
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.tectonic.ConfigLoadingDelegate;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
|
@ -7,10 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
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.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector2Int;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user