mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
reformat
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
@@ -13,7 +14,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 org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
fun Project.configureCompilation() {
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
@@ -52,12 +52,12 @@ fun Project.configureDistribution() {
|
||||
dest.parentFile.mkdirs()
|
||||
|
||||
val zip = ZipOutputStream(FileOutputStream(dest))
|
||||
|
||||
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = (tasks.named("jar").get() as Jar)
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}.")
|
||||
|
||||
val boot = if(extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
|
||||
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
|
||||
zip.putNextEntry(entry)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
|
||||
var isPrerelease = false
|
||||
|
||||
@@ -7,18 +7,19 @@
|
||||
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
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();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -16,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeExpander;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
|
||||
@@ -7,14 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -26,6 +18,14 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class BiomePipelineProvider implements BiomeProvider {
|
||||
private final LoadingCache<SeededVector, BiomeHolder> holderCache;
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public interface BiomeDelegate extends StringIdentifiable {
|
||||
Biome getBiome();
|
||||
|
||||
Set<String> getTags();
|
||||
|
||||
default boolean isEphemeral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isSelf() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static BiomeDelegate ephemeral(String id) {
|
||||
return new EphemeralBiomeDelegate(id);
|
||||
}
|
||||
@@ -31,5 +19,17 @@ public interface BiomeDelegate extends StringIdentifiable {
|
||||
return SelfDelegate.INSTANCE;
|
||||
}
|
||||
|
||||
Biome getBiome();
|
||||
|
||||
Set<String> getTags();
|
||||
|
||||
default boolean isEphemeral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isSelf() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
final class DelegatedBiome implements BiomeDelegate {
|
||||
private final Biome biome;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
final class EphemeralBiomeDelegate implements BiomeDelegate {
|
||||
private final Set<String> tags;
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.delegate;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
final class SelfDelegate implements BiomeDelegate {
|
||||
public static final SelfDelegate INSTANCE = new SelfDelegate();
|
||||
|
||||
private SelfDelegate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
throw new UnsupportedOperationException("Cannot get biome from self delegate");
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.stage;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
|
||||
|
||||
public interface Stage {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.api.stage.type;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
|
||||
|
||||
public interface BiomeMutator {
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.dfsek.terra.addons.biome.pipeline.BiomePipeline;
|
||||
import com.dfsek.terra.addons.biome.pipeline.BiomePipelineProvider;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
public class BorderMutator implements BiomeMutator {
|
||||
private final String border;
|
||||
@@ -53,13 +53,13 @@ public class BorderMutator implements BiomeMutator {
|
||||
Set<BiomeDelegate> biomeSet = new HashSet<>();
|
||||
biomes.forEach(biomeSet::add);
|
||||
biomeSet.addAll(
|
||||
replace
|
||||
.getContents()
|
||||
.stream()
|
||||
.filter(
|
||||
Predicate.not(BiomeDelegate::isSelf)
|
||||
)
|
||||
.toList()
|
||||
replace
|
||||
.getContents()
|
||||
.stream()
|
||||
.filter(
|
||||
Predicate.not(BiomeDelegate::isSelf)
|
||||
)
|
||||
.toList()
|
||||
);
|
||||
return biomeSet;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.mutator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeMutator;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class ReplaceMutator implements BiomeMutator {
|
||||
private final String replaceableTag;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.stages;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeExpander;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeExpander;
|
||||
|
||||
|
||||
public class ExpanderStage implements Stage {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline.stages;
|
||||
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.BiomeHolder;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeMutator;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.type.BiomeMutator;
|
||||
|
||||
|
||||
public class MutatorStage implements Stage {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.single;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class SingleBiomeProvider implements BiomeProvider {
|
||||
private final Biome biome;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
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.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public class BiomeNoiseConfigTemplate implements ObjectTemplate<BiomeNoiseProper
|
||||
|
||||
@Override
|
||||
public BiomeNoiseProperties get() {
|
||||
return new BiomeNoiseProperties(baseSampler, elevationSampler, carvingSampler, blendDistance, blendStep, blendWeight, elevationWeight);
|
||||
return new BiomeNoiseProperties(baseSampler, elevationSampler, carvingSampler, blendDistance, blendStep, blendWeight,
|
||||
elevationWeight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,18 +11,18 @@ 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.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderBuilder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderBuilder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
|
||||
public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
@Value("slant")
|
||||
@@ -44,10 +44,10 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
builder.add(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TreeMap<Double, PaletteHolder> slantLayers = new TreeMap<>();
|
||||
double minThreshold = Double.MAX_VALUE;
|
||||
|
||||
|
||||
for(SlantLayer layer : slant) {
|
||||
double threshold = layer.getThreshold();
|
||||
if(threshold < minThreshold) minThreshold = threshold;
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.dfsek.terra.addons.chunkgenerator.config.palette;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderBuilder;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class SlantLayer implements ObjectTemplate<SlantLayer> {
|
||||
@Value("threshold")
|
||||
|
||||
@@ -11,9 +11,6 @@ package com.dfsek.terra.addons.chunkgenerator.generation;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.PaletteUtil;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.LazilyEvaluatedInterpolator;
|
||||
@@ -29,7 +26,6 @@ import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
|
||||
@@ -120,7 +116,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
|
||||
int fdX = FastMath.floorMod(x, 16);
|
||||
int fdZ = FastMath.floorMod(z, 16);
|
||||
|
||||
|
||||
Palette palette = PaletteUtil.getPalette(fdX, y, fdZ, sampler, paletteInfo);
|
||||
double noise = sampler.sample(fdX, y, fdZ);
|
||||
if(noise > 0) {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.SlantHolder;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ChunkInterpolator {
|
||||
BiomeNoiseProperties gen = entry.getKey();
|
||||
int weight = entry.getValue().get();
|
||||
double noise = computeNoise(gen, x, y, z);
|
||||
|
||||
|
||||
n += noise * weight;
|
||||
div += gen.blendWeight() * weight;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ public class ElevationInterpolator {
|
||||
// Precompute generators.
|
||||
for(int x = -1 - smooth; x <= 16 + smooth; x++) {
|
||||
for(int z = -1 - smooth; z <= 16 + smooth; z++) {
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getContext().get(BiomeNoiseProperties.class);
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getContext().get(
|
||||
BiomeNoiseProperties.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import static com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.Interpolator.lerp;
|
||||
|
||||
|
||||
@@ -26,9 +25,10 @@ public class LazilyEvaluatedInterpolator {
|
||||
private final long seed;
|
||||
private final int min;
|
||||
|
||||
public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max, int min, int horizontalRes, int verticalRes, long seed) {
|
||||
int hSamples = FastMath.ceilToInt(16.0/horizontalRes);
|
||||
int vSamples = FastMath.ceilToInt((double) (max-min) / verticalRes);
|
||||
public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max, int min, int horizontalRes, int verticalRes,
|
||||
long seed) {
|
||||
int hSamples = FastMath.ceilToInt(16.0 / horizontalRes);
|
||||
int vSamples = FastMath.ceilToInt((double) (max - min) / verticalRes);
|
||||
samples = new Double[hSamples + 1][vSamples + 1][hSamples + 1];
|
||||
samplers = new NoiseSampler[hSamples + 1][hSamples + 1];
|
||||
this.chunkX = cx << 4;
|
||||
@@ -43,8 +43,8 @@ public class LazilyEvaluatedInterpolator {
|
||||
private double sample(int x, int y, int z, int ox, int oy, int oz) {
|
||||
Double sample = samples[x][y][z];
|
||||
if(sample == null) {
|
||||
int xi = ox+chunkX;
|
||||
int zi = oz+chunkZ;
|
||||
int xi = ox + chunkX;
|
||||
int zi = oz + chunkZ;
|
||||
|
||||
NoiseSampler sampler = samplers[x][z];
|
||||
if(sampler == null) {
|
||||
@@ -71,10 +71,10 @@ public class LazilyEvaluatedInterpolator {
|
||||
}
|
||||
|
||||
double sample_0_0_1 = sample(xIndex, yIndex, zIndex + 1, x, y, z + horizontalRes);
|
||||
|
||||
|
||||
double sample_1_0_0 = sample(xIndex + 1, yIndex, zIndex, x + horizontalRes, y, z);
|
||||
double sample_1_0_1 = sample(xIndex + 1, yIndex, zIndex + 1, x + horizontalRes, y, z + horizontalRes);
|
||||
|
||||
|
||||
double xFrac = (double) (x % horizontalRes) / horizontalRes;
|
||||
double zFrac = (double) (z % horizontalRes) / horizontalRes;
|
||||
double lerp_bottom_0 = lerp(zFrac, sample_0_0_0, sample_0_0_1);
|
||||
@@ -95,10 +95,10 @@ public class LazilyEvaluatedInterpolator {
|
||||
|
||||
double sample_1_1_0 = sample(xIndex + 1, yIndex + 1, zIndex, x + horizontalRes, y + verticalRes, z);
|
||||
double sample_1_1_1 = sample(xIndex + 1, yIndex + 1, zIndex + 1, x + horizontalRes, y + verticalRes, z + horizontalRes);
|
||||
|
||||
|
||||
double lerp_top_0 = lerp(zFrac, sample_0_1_0, sample_0_1_1);
|
||||
double lerp_top_1 = lerp(zFrac, sample_1_1_0, sample_1_1_1);
|
||||
|
||||
|
||||
double lerp_top = lerp(xFrac, lerp_top_0, lerp_top_1);
|
||||
|
||||
return lerp(yFrac, lerp_bottom, lerp_top);
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -28,6 +26,7 @@ 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;
|
||||
|
||||
|
||||
@@ -35,7 +34,6 @@ public class SamplerProvider {
|
||||
private final LoadingCache<Pair<Long, World>, Sampler3D> cache;
|
||||
|
||||
|
||||
|
||||
public SamplerProvider(Platform platform, BiomeProvider provider, int elevationSmooth) {
|
||||
cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache())
|
||||
.build(new CacheLoader<>() {
|
||||
@@ -45,7 +43,8 @@ public class SamplerProvider {
|
||||
int cx = (int) (key >> 32);
|
||||
int cz = (int) key;
|
||||
World world = pair.getRight();
|
||||
return new Sampler3D(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight(), provider, elevationSmooth);
|
||||
return new Sampler3D(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight(), provider,
|
||||
elevationSmooth);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.command.biome;
|
||||
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -35,7 +34,8 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncBiomeFinder(BiomeProvider provider, Biome target, @NotNull Vector3 origin, ServerWorld world, int startRadius, int maxRadius,
|
||||
public AsyncBiomeFinder(BiomeProvider provider, Biome target, @NotNull Vector3 origin, ServerWorld world, int startRadius,
|
||||
int maxRadius,
|
||||
Consumer<Vector3> callback, Platform platform) {
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
|
||||
@@ -7,13 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
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.structure.feature.Feature;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
@@ -7,13 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.flora;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
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.structure.Structure;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.flora.flora.gen;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -26,6 +24,7 @@ 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.Vector3;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ import com.dfsek.paralithic.functions.dynamic.Context;
|
||||
import com.dfsek.paralithic.functions.dynamic.DynamicFunction;
|
||||
import com.dfsek.paralithic.node.Statefulness;
|
||||
|
||||
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
|
||||
|
||||
|
||||
public class UserDefinedFunction implements DynamicFunction {
|
||||
private final Expression expression;
|
||||
@@ -42,7 +42,7 @@ public class UserDefinedFunction implements DynamicFunction {
|
||||
FunctionTemplate nest = entry.getValue();
|
||||
parser.registerFunction(id, newInstance(nest));
|
||||
}
|
||||
|
||||
|
||||
return new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,17 @@ public class DomainWarpedSampler implements NoiseSampler {
|
||||
@Override
|
||||
public double noise(long seed, double x, double y) {
|
||||
return function.noise(seed++,
|
||||
x + warp.noise(seed++, x, y) * amplitude,
|
||||
y + warp.noise(seed, x, y) * amplitude
|
||||
x + warp.noise(seed++, x, y) * amplitude,
|
||||
y + warp.noise(seed, x, y) * amplitude
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return function.noise(seed++,
|
||||
x + warp.noise(seed++, x, y, z) * amplitude,
|
||||
y + warp.noise(seed++, x, y, z) * amplitude,
|
||||
z + warp.noise(seed, x, y, z) * amplitude
|
||||
x + warp.noise(seed++, x, y, z) * amplitude,
|
||||
y + warp.noise(seed++, x, y, z) * amplitude,
|
||||
z + warp.noise(seed, x, y, z) * amplitude
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class GaborNoiseSampler extends NoiseFunction {
|
||||
private double a = 0.1;
|
||||
private double f0 = 0.625;
|
||||
private double kernelRadius = (FastMath.sqrt(-FastMath.log(0.05) / Math.PI) / a);
|
||||
|
||||
private double impulsesPerKernel = 64d;
|
||||
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
|
||||
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.terra.addons.ore.ores.VanillaOre;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.ore.ores;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -21,8 +22,6 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
|
||||
public class VanillaOre implements Structure {
|
||||
|
||||
@@ -68,36 +67,36 @@ public class VanillaOre implements Structure {
|
||||
int centerX = location.getBlockX();
|
||||
int centerZ = location.getBlockZ();
|
||||
int centerY = location.getBlockY();
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class PaletteImpl implements Palette {
|
||||
* Constructs a blank palette.
|
||||
*/
|
||||
public PaletteImpl() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
|
||||
public class StructureAddon implements AddonInitializer {
|
||||
|
||||
@@ -11,16 +11,14 @@ 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.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
public class StructureConfigType implements ConfigType<StructureTemplate, ConfiguredStructure> {
|
||||
public static final TypeKey<ConfiguredStructure> CONFIGURED_STRUCTURE_TYPE_KEY = new TypeKey<>() {
|
||||
};
|
||||
private final ConfigFactory<StructureTemplate, ConfiguredStructure> factory = new StructureFactory();
|
||||
public static final TypeKey<ConfiguredStructure> CONFIGURED_STRUCTURE_TYPE_KEY = new TypeKey<>(){};
|
||||
|
||||
@Override
|
||||
public StructureTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.structure.command;
|
||||
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -16,6 +14,7 @@ import java.util.function.Consumer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -31,7 +30,8 @@ public class AsyncStructureFinder implements Runnable {
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, ServerWorld world, int startRadius,
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, ServerWorld world,
|
||||
int startRadius,
|
||||
int maxRadius, Consumer<Vector3> callback, Platform platform) {
|
||||
//setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
this.provider = provider;
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.structure.structures.loot.functions;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
@@ -22,15 +17,19 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
|
||||
public class EnchantFunction implements LootFunction {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EnchantFunction.class);
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final Platform platform;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EnchantFunction.class);
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform platform) {
|
||||
this.max = max;
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.function.IntConsumer;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
|
||||
|
||||
public class ColumnImpl<T extends WritableWorld> implements Column<T> {
|
||||
|
||||
@@ -77,11 +77,11 @@ public class FeatureGenerationAddon implements AddonInitializer {
|
||||
.build());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
DynamicTemplate template = event.load(templateBuilder.build());
|
||||
|
||||
|
||||
Map<FeatureGenerationStage, List<Feature>> features = new HashMap<>();
|
||||
|
||||
|
||||
featureGenerationStages.forEach(stage -> features.put(stage, template.get(stage.getID(), List.class)));
|
||||
|
||||
event.getLoadedObject(Biome.class).getContext().put(new BiomeFeatures(features));
|
||||
|
||||
@@ -9,11 +9,10 @@ import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
|
||||
public class FeatureStageTemplate implements ObjectTemplate<GenerationStage> {
|
||||
private final Platform platform;
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
private final Platform platform;
|
||||
|
||||
public FeatureStageTemplate(Platform platform) { this.platform = platform; }
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.addons.generation.structure.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BiomeStructures implements Properties {
|
||||
private final List<ConfiguredStructure> structures;
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.dfsek.terra.addons.generation.structure.config;
|
||||
|
||||
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.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.structure.feature.Feature;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
|
||||
public class BiomeStructuresTemplate implements ObjectTemplate<BiomeStructures> {
|
||||
@Value("features")
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
package com.dfsek.terra.addons.yaml;
|
||||
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
@@ -16,9 +18,6 @@ import com.dfsek.terra.api.event.events.config.ConfigurationDiscoveryEvent;
|
||||
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 YamlAddon implements AddonInitializer {
|
||||
|
||||
|
||||
@@ -13,17 +13,6 @@ import ca.solostudios.strata.version.VersionRange;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.AddonManifest;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.WebsiteConfig;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionLoader;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionRangeLoader;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.AddonException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestNotPresentException;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -41,6 +30,16 @@ import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.AddonManifest;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.WebsiteConfig;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionLoader;
|
||||
import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionRangeLoader;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.AddonException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestNotPresentException;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ManifestAddonLoader.class);
|
||||
|
||||
@@ -9,9 +9,9 @@ package com.dfsek.terra.addons.manifest.impl.config;
|
||||
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
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.ConfigTemplate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.dfsek.terra.version
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.sponge;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Random;
|
||||
@@ -21,6 +19,7 @@ import com.dfsek.terra.api.structure.buffer.items.BufferedBlock;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.integer.Vector2Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.dfsek.terra.version
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ package com.dfsek.terra.addons.terrascript;
|
||||
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
@@ -23,10 +27,6 @@ import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.StringUtil;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class TerraScriptAddon implements AddonInitializer {
|
||||
@Inject
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
@@ -17,20 +20,15 @@ import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BufferedLootApplication implements BufferedItem {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||
private final LootTable table;
|
||||
private final Platform platform;
|
||||
private final StructureScript structure;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||
|
||||
public BufferedLootApplication(LootTable table, Platform platform, StructureScript structure) {
|
||||
this.table = table;
|
||||
this.platform = platform;
|
||||
@@ -45,7 +43,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
LOGGER.error("Failed to place loot at {}; block {} is not a container", origin, data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getPack(), structure);
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
@@ -7,20 +7,18 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private final String data;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BufferedStateManipulator.class);
|
||||
private final String data;
|
||||
|
||||
public BufferedStateManipulator(String state) {
|
||||
this.data = state;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.exceptions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public class ParseException extends RuntimeException {
|
||||
@Serial
|
||||
|
||||
@@ -57,13 +57,12 @@ import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
public class StructureScript implements Structure {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureScript.class);
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final Cache<Vector3, StructureBuffer> cache;
|
||||
private final Platform platform;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureScript.class);
|
||||
|
||||
public StructureScript(InputStream inputStream, String id, Platform platform, Registry<Structure> registry,
|
||||
Registry<LootTable> lootRegistry,
|
||||
Registry<FunctionBuilder<?>> functionRegistry) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
|
||||
private final Registry<LootTable> registry;
|
||||
private final Returnable<String> data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
@@ -37,8 +38,6 @@ public class LootFunction implements Function<Void> {
|
||||
private final Platform platform;
|
||||
private final StructureScript script;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
|
||||
|
||||
public LootFunction(Registry<LootTable> registry, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z,
|
||||
Returnable<String> data, Platform platform, Position position, StructureScript script) {
|
||||
this.registry = registry;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -27,19 +29,16 @@ 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 StructureFunction implements Function<Boolean> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureFunction.class);
|
||||
private final Registry<Structure> registry;
|
||||
private final Returnable<String> id;
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final Platform platform;
|
||||
private final List<Returnable<String>> rotations;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureFunction.class);
|
||||
|
||||
public StructureFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> id,
|
||||
List<Returnable<String>> rotations, Registry<Structure> registry, Position position, Platform platform) {
|
||||
this.registry = registry;
|
||||
@@ -79,10 +78,10 @@ public class StructureFunction implements Function<Boolean> {
|
||||
LOGGER.warn("Invalid rotation {}", rotString);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Vector3 offset = new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(),
|
||||
FastMath.roundToInt(xz.getZ()));
|
||||
|
||||
|
||||
return script.generate(new IntermediateBuffer(arguments.getBuffer(), offset), arguments.getWorld(), arguments.getRandom(),
|
||||
arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
||||
}).orElseGet(() -> {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.tokenizer.exceptions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public class EOFException extends TokenizerException {
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.tokenizer.exceptions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public class FormatException extends TokenizerException {
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.tokenizer.exceptions;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
public abstract class TokenizerException extends ParseException {
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addon.terrascript.check;
|
||||
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -24,6 +22,7 @@ import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ package com.dfsek.terra.api.addon;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
|
||||
|
||||
public interface BaseAddon extends StringIdentifiable {
|
||||
default void initialize() { }
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
||||
* Load all the relevant addons in the specified path.
|
||||
*
|
||||
* @param addonsFolder Path containing addons.
|
||||
* @param parent parent class loader
|
||||
* @param parent parent class loader
|
||||
*
|
||||
* @return Loaded addons
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
afterEvaluate {
|
||||
subprojects.forEach {
|
||||
if(it != project) {
|
||||
if (it != project) {
|
||||
println("Project: ${it.name}")
|
||||
dependencies {
|
||||
shadedApi(it)
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
||||
@@ -21,11 +21,9 @@ import com.dfsek.terra.api.tectonic.LoaderHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageProvider;
|
||||
|
||||
|
||||
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder, StringIdentifiable {
|
||||
|
||||
@@ -7,14 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to be implemented for world manipulation.
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
package com.dfsek.terra.api.structure;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.inventory.Inventory;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
|
||||
@Experimental
|
||||
public interface LootTable {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.api.structure;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
|
||||
@Experimental
|
||||
public interface StructureSpawn {
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
@Experimental
|
||||
public interface Buffer {
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@Experimental
|
||||
public interface BufferedItem {
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer.buffers;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer.buffers;
|
||||
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -18,10 +17,9 @@ import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.structure.buffer.items.Cell;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
|
||||
@Experimental
|
||||
public class StructureBuffer implements Buffer {
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -18,6 +16,7 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@Experimental
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer.items;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
|
||||
@Experimental
|
||||
public class Cell implements BufferedItem {
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.configured;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.structure.StructureSpawn;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
|
||||
@Experimental
|
||||
public interface ConfiguredStructure extends StringIdentifiable {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.api.tectonic;
|
||||
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
|
||||
package com.dfsek.terra.api.world.chunk;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
|
||||
|
||||
public interface Chunk extends ChunkAccess {
|
||||
void setBlock(int x, int y, int z, BlockState data, boolean physics);
|
||||
|
||||
@@ -9,14 +9,11 @@ package com.dfsek.terra.api.world.chunk.generation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.integer.Vector3Int;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
|
||||
public interface ChunkGenerator {
|
||||
|
||||
@@ -13,6 +13,7 @@ public interface ProtoWorld extends WritableWorld {
|
||||
* Get the world object this ProtoWorld represents
|
||||
*
|
||||
* <b>Do not read from/write to this world!</b>
|
||||
*
|
||||
* @return The world
|
||||
*/
|
||||
ServerWorld getWorld();
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.api.inject.exception;
|
||||
|
||||
import com.dfsek.terra.api.inject.Injector;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import com.dfsek.terra.api.inject.Injector;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when dynamic dependency injection cannot be completed by an {@link Injector}.
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.api.registry;
|
||||
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
|
||||
public interface CheckedRegistry<T> extends Registry<T> {
|
||||
/**
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package com.dfsek.terra.api.registry;
|
||||
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
|
||||
public interface OpenRegistry<T> extends Registry<T> {
|
||||
/**
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
package com.dfsek.terra.api.registry;
|
||||
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
|
||||
import com.dfsek.terra.api.registry.exception.NoSuchEntryException;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class Either<L, R> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Either<?, ?> that)) return false;
|
||||
|
||||
|
||||
return (this.leftPresent && that.leftPresent && Objects.equals(this.left, that.left))
|
||||
|| (!this.leftPresent && !that.leftPresent && Objects.equals(this.right, that.right));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class Pair<L, R> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Pair<?, ?> that)) return false;
|
||||
|
||||
|
||||
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public final class Pair<L, R> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Mutable<?, ?> that)) return false;
|
||||
|
||||
|
||||
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TypeKey<T> {
|
||||
if(!(b instanceof ParameterizedType pb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return Objects.equals(pa.getOwnerType(), pb.getOwnerType())
|
||||
&& pa.getRawType().equals(pb.getRawType())
|
||||
&& Arrays.equals(pa.getActualTypeArguments(), pb.getActualTypeArguments());
|
||||
@@ -50,13 +50,13 @@ public class TypeKey<T> {
|
||||
if(!(b instanceof GenericArrayType gb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return equals(ga.getGenericComponentType(), gb.getGenericComponentType());
|
||||
} else if(a instanceof WildcardType wa) {
|
||||
if(!(b instanceof WildcardType wb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return Arrays.equals(wa.getUpperBounds(), wb.getUpperBounds())
|
||||
&& Arrays.equals(wa.getLowerBounds(), wb.getLowerBounds());
|
||||
} else if(a instanceof TypeVariable<?> va) {
|
||||
|
||||
@@ -7,11 +7,10 @@ import com.dfsek.terra.api.util.Rotation;
|
||||
* oh yeah
|
||||
*/
|
||||
public class Vector2Int {
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
private static final Vector2Int ZERO = new Vector2Int(0, 0);
|
||||
private static final Vector2Int UNIT = new Vector2Int(0, 1);
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
protected Vector2Int(int x, int z) {
|
||||
this.x = x;
|
||||
@@ -62,19 +61,19 @@ public class Vector2Int {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.dfsek.terra.api.util.vector.integer;
|
||||
|
||||
public class Vector3Int {
|
||||
private final int x, y, z;
|
||||
|
||||
private static final Vector3Int ZERO = new Vector3Int(0, 0, 0);
|
||||
private static final Vector3Int UNIT = new Vector3Int(0, 1, 0);
|
||||
private final int x, y, z;
|
||||
|
||||
protected Vector3Int(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@@ -12,6 +11,18 @@ public class Vector3Int {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static Vector3Int unit() {
|
||||
return UNIT;
|
||||
}
|
||||
|
||||
public static Vector3Int zero() {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
public static Vector3Int of(int x, int y, int z) {
|
||||
return new Vector3Int(x, y, z);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
@@ -28,18 +39,7 @@ public class Vector3Int {
|
||||
return new Mutable(x, y, z);
|
||||
}
|
||||
|
||||
public static Vector3Int unit() {
|
||||
return UNIT;
|
||||
}
|
||||
|
||||
public static Vector3Int zero() {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
public static Vector3Int of(int x, int y, int z) {
|
||||
return new Vector3Int(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
public static class Mutable {
|
||||
private int x, y, z;
|
||||
|
||||
@@ -48,31 +48,31 @@ public class Vector3Int {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vector3Int immutable() {
|
||||
return Vector3Int.of(x, y, z);
|
||||
}
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
import com.dfsek.terra.addon.InternalAddon;
|
||||
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,6 +41,8 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addon.BootstrapAddonLoader;
|
||||
import com.dfsek.terra.addon.DependencySorter;
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
import com.dfsek.terra.addon.InternalAddon;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
@@ -61,6 +57,7 @@ import com.dfsek.terra.api.inject.impl.InjectorImpl;
|
||||
import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.mutable.MutableBoolean;
|
||||
import com.dfsek.terra.commands.CommandUtil;
|
||||
import com.dfsek.terra.commands.TerraCommandManager;
|
||||
@@ -184,14 +181,14 @@ public abstract class AbstractPlatform implements Platform {
|
||||
BootstrapAddonLoader bootstrapAddonLoader = new BootstrapAddonLoader();
|
||||
|
||||
Path addonsFolder = getDataFolder().toPath().resolve("addons");
|
||||
|
||||
|
||||
Injector<Platform> platformInjector = new InjectorImpl<>(this);
|
||||
platformInjector.addExplicitTarget(Platform.class);
|
||||
|
||||
|
||||
bootstrapAddonLoader.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
.forEach(bootstrapAddon -> {
|
||||
platformInjector.inject(bootstrapAddon);
|
||||
|
||||
|
||||
bootstrapAddon.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
.forEach(addonList::add);
|
||||
});
|
||||
@@ -201,7 +198,7 @@ public abstract class AbstractPlatform implements Platform {
|
||||
builder.append("Loading ")
|
||||
.append(addonList.size())
|
||||
.append(" Terra addons:");
|
||||
|
||||
|
||||
for(BaseAddon addon : addonList) {
|
||||
builder.append("\n ")
|
||||
.append("- ")
|
||||
@@ -209,10 +206,10 @@ public abstract class AbstractPlatform implements Platform {
|
||||
.append("@")
|
||||
.append(addon.getVersion().getFormatted());
|
||||
}
|
||||
|
||||
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
|
||||
DependencySorter sorter = new DependencySorter();
|
||||
addonList.forEach(sorter::add);
|
||||
sorter.sort().forEach(addon -> {
|
||||
@@ -222,7 +219,7 @@ public abstract class AbstractPlatform implements Platform {
|
||||
addonRegistry.register(addon.getID(), addon);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventManager.getHandler(FunctionalEventHandler.class)
|
||||
.register(internalAddon, PlatformInitializationEvent.class)
|
||||
.then(event -> {
|
||||
@@ -231,10 +228,10 @@ public abstract class AbstractPlatform implements Platform {
|
||||
logger.info("Loaded packs.");
|
||||
})
|
||||
.global();
|
||||
|
||||
|
||||
|
||||
|
||||
logger.info("Terra addons successfully loaded.");
|
||||
|
||||
|
||||
try {
|
||||
CommandUtil.registerAll(manager);
|
||||
} catch(MalformedCommandException e) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
public class InternalAddon implements BaseAddon {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "terra";
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.dfsek.terra.addon.dependency;
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
public class CircularDependencyException extends DependencyException{
|
||||
public class CircularDependencyException extends DependencyException {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6098780459461482651L;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.dfsek.terra.addon.dependency;
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
public class DependencyVersionException extends DependencyException{
|
||||
public class DependencyVersionException extends DependencyException {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3564288935278878135L;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.dfsek.terra.commands.profiler.ProfileCommand;
|
||||
|
||||
public final class CommandUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommandUtil.class);
|
||||
|
||||
public static void registerAll(CommandManager manager) throws MalformedCommandException {
|
||||
logger.info("Registering Terra commands...");
|
||||
manager.register("profile", ProfileCommand.class);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user