Merge remote-tracking branch 'origin/ver/6.2.0' into biomestuff

This commit is contained in:
Zoë
2022-06-08 22:18:49 -05:00
11 changed files with 130 additions and 51 deletions

View File

@@ -72,19 +72,15 @@
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
- [ ] Build system <!-- Anything which pretain to the build system. -->
- [ ]
Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
- [ ]
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ]
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ] Revert <!-- Anything which reverts previous commits. -->
- [ ] Style <!-- Anything which updates style. -->
- [ ] Tests <!-- Anything which adds or updates tests. -->
- [ ]
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
#### Compatiblity
@@ -119,4 +115,4 @@
<!--
If it only introduces small changes, you don't need to add tests.
But if you add big changes, you should probably at least write *some* testing, where applicable.
-->
-->

View File

@@ -1,8 +1,8 @@
preRelease(true)
versionProjects(":common:api", version("6.1.0"))
versionProjects(":common:implementation", version("6.1.0"))
versionProjects(":platforms", version("6.1.0"))
versionProjects(":common:api", version("6.1.1"))
versionProjects(":common:implementation", version("6.1.1"))
versionProjects(":platforms", version("6.1.1"))
allprojects {

View File

@@ -1,4 +1,4 @@
version = version("1.0.0")
version = version("1.1.0")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))

View File

@@ -73,15 +73,17 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
int cx = xOrig + x;
int cz = zOrig + z;
Biome biome = biomeProvider.getBiome(cx, 0, cz, seed);
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
int sea = paletteInfo.seaLevel();
Palette seaPalette = paletteInfo.ocean();
BlockState data;
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
Biome biome = biomeProvider.getBiome(cx, y, cz, seed);
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
int sea = paletteInfo.seaLevel();
Palette seaPalette = paletteInfo.ocean();
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,

View File

@@ -7,15 +7,15 @@
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
import com.dfsek.terra.api.util.mutable.MutableInteger;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import net.jafama.FastMath;
import java.util.HashMap;
import java.util.Map;
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
import com.dfsek.terra.api.util.mutable.MutableInteger;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
/**
* Class to abstract away the Interpolators needed to generate a chunk.<br>
@@ -55,25 +55,24 @@ public class ChunkInterpolator {
for(int x = 0; x < 5; x++) {
for(int z = 0; z < 5; z++) {
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), 0, zOrigin + (z << 2), seed)
.getContext()
.get(BiomeNoiseProperties.class);
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
int step = generationSettings.blendStep();
int blend = generationSettings.blendDistance();
for(int xi = -blend; xi <= blend; xi++) {
for(int zi = -blend; zi <= blend; zi++) {
genMap.computeIfAbsent(
provider.getBiome(xOrigin + (x << 2) + (xi * step), 0, zOrigin + (z << 2) + (zi * step), seed)
.getContext()
.get(BiomeNoiseProperties.class),
g -> new MutableInteger(0)).increment(); // Increment by 1
}
}
for(int y = 0; y < size + 1; y++) {
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), (y << 2) + min, zOrigin + (z << 2), seed)
.getContext()
.get(BiomeNoiseProperties.class);
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
int step = generationSettings.blendStep();
int blend = generationSettings.blendDistance();
for(int xi = -blend; xi <= blend; xi++) {
for(int zi = -blend; zi <= blend; zi++) {
genMap.computeIfAbsent(
provider.getBiome(xOrigin + (x << 2) + (xi * step), 0, zOrigin + (z << 2) + (zi * step), seed)
.getContext()
.get(BiomeNoiseProperties.class),
g -> new MutableInteger(0)).increment(); // Increment by 1
}
}
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, (y << 2) + this.min, (z << 2) + zOrigin);
}
}

View File

@@ -0,0 +1,36 @@
package com.dfsek.terra.api.util;
import com.dfsek.terra.api.util.function.IntObjConsumer;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
public interface Column<T> {
int getMinY();
int getMaxY();
T get(int y);
default void forEach(Consumer<T> consumer) {
for(int y = getMinY(); y < getMaxY(); y++) {
consumer.accept(get(y));
}
}
default void forEach(IntObjConsumer<T> consumer) {
for(int y = getMinY(); y < getMaxY(); y++) {
consumer.accept(y, get(y));
}
}
default List<? extends T> asList() {
List<T> list = new ArrayList<>();
forEach((Consumer<T>) list::add);
return list;
}
}

View File

@@ -0,0 +1,6 @@
package com.dfsek.terra.api.util.function;
@FunctionalInterface
public interface IntObjConsumer<T> {
void accept(int i, T obj);
}

View File

@@ -0,0 +1,39 @@
package com.dfsek.terra.api.world.biome.generation;
import com.dfsek.terra.api.util.Column;
import com.dfsek.terra.api.world.biome.Biome;
class BiomeColumn implements Column<Biome> {
private final BiomeProvider biomeProvider;
private final int min;
private final int max;
private final int x;
private final int z;
private final long seed;
protected BiomeColumn(BiomeProvider biomeProvider, int min, int max, int x, int z, long seed) {
this.biomeProvider = biomeProvider;
this.min = min;
this.max = max;
this.x = x;
this.z = z;
this.seed = seed;
}
@Override
public int getMinY() {
return min;
}
@Override
public int getMaxY() {
return max;
}
@Override
public Biome get(int y) {
return biomeProvider.getBiome(x, y, z, seed);
}
}

View File

@@ -7,6 +7,7 @@
package com.dfsek.terra.api.world.biome.generation;
import com.dfsek.terra.api.util.Column;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.biome.Biome;
@@ -62,6 +63,14 @@ public interface BiomeProvider {
return getBiome(vector3.getX(), vector3.getY(), vector3.getZ(), seed);
}
default Column<Biome> getColumn(int x, int z, int min, int max, long seed) {
return new BiomeColumn(this, min, max, x, z, seed);
}
default Column<Biome> getColumn(int x, int z, WorldProperties properties) {
return getColumn(x, z, properties.getMinHeight(), properties.getMaxHeight(), properties.getSeed());
}
/**
* Get all biomes this {@link BiomeProvider} is capable of generating in the world.
* <p>

View File

@@ -244,12 +244,13 @@ public abstract class AbstractPlatform implements Platform {
String resourceYaml = IOUtils.toString(resourcesConfig, StandardCharsets.UTF_8);
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
resources.forEach((dir, entries) -> entries.forEach(entry -> {
String resourcePath = dir + File.separatorChar + entry;
String resourceClassPath = dir + "/" + entry;
String resourcePath = resourceClassPath.replace('/', File.separatorChar);
File resource = new File(getDataFolder(), resourcePath);
if(resource.exists())
return; // dont overwrite
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath)) {
try(InputStream is = getClass().getResourceAsStream("/" + resourceClassPath)) {
if(is == null) {
logger.error("Resource {} doesn't exist on the classpath!", resourcePath);
return;

View File

@@ -1,9 +0,0 @@
debug: false
data-save: PT6M
language: "en_us"
fail-type: SHUTDOWN
dump-default: true
biome-search-resolution: 4
cache-size: 384
master-disable:
caves: false