Compare commits

...

4 Commits

Author SHA1 Message Date
Zoë Gidiere 734d4bfb94 reformat 2023-11-27 11:31:20 -07:00
Zoë Gidiere c82e015559 flatten array for pipeline biomes 2023-11-27 11:31:11 -07:00
Astrashh 3aef977384 Patch version 6.4.1 (#435)
* Bump version to 6.4.1

* fix fabric dev env

* Invert exposed ore logic (#433)

* Invert exposed ore logic

* Bump ore addon version

* Use logger in Gradle over println (#434)

* Log info instead of println in gradle scripts

* Missed buildSrc printlns

---------

Co-authored-by: Zoë <duplexsys@protonmail.com>
2023-11-25 01:02:45 +00:00
Zoë 6060ceae57 Merge pull request #432 from PolyhedralDev/dev/codeowners
update condeowners
2023-11-18 10:05:10 +00:00
15 changed files with 87 additions and 73 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
preRelease(true)
versionProjects(":common:api", version("6.4.0"))
versionProjects(":common:implementation", version("6.4.0"))
versionProjects(":platforms", version("6.4.0"))
versionProjects(":common:api", version("6.4.1"))
versionProjects(":common:implementation", version("6.4.1"))
versionProjects(":platforms", version("6.4.1"))
allprojects {
+2 -2
View File
@@ -18,7 +18,7 @@ fun Project.addonDir(dir: File, task: Task) {
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
logger.info("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
@@ -29,7 +29,7 @@ fun Project.addonDir(dir: File, task: Task) {
val base = "${jar.archiveBaseName.get()}-${version}"
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
logger.info("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
jar.archiveFile.orNull?.asFile?.copyTo(target)
}
@@ -53,7 +53,7 @@ fun Project.configureDistribution() {
forSubProjects(":common:addons") {
val jar = getJarTask()
println("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
logger.info("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
+2 -2
View File
@@ -42,10 +42,10 @@ fun preRelease(preRelease: Boolean) {
fun Project.versionProjects(project: String, version: String) {
forSubProjects(project) {
this.version = version
println("Setting version of $path to $version")
logger.info("Setting version of $path to $version")
}
project(project).version = version
println("Setting version of $project to $version")
logger.info("Setting version of $project to $version")
}
fun Project.version(version: String): String {
@@ -82,7 +82,7 @@ abstract class GenerateDocsTask : DefaultTask() {
}
template.add(keyName.toString(), description.toString().ifBlank {
println("No description provided for field " + field.name + " in class " + name)
logger.info("No description provided for field " + field.name + " in class " + name)
"*No description provided.*"
})
}
@@ -1,5 +1,9 @@
package com.dfsek.terra.addons.biome.extrusion.extrusions;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
import com.dfsek.terra.addons.biome.query.api.BiomeQueries;
@@ -8,10 +12,6 @@ import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.Biome;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Sets biomes at locations based on a sampler.
@@ -7,13 +7,13 @@
package com.dfsek.terra.addons.biome.image.v2;
import java.util.Optional;
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
import com.dfsek.terra.addons.image.converter.ColorConverter;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import java.util.Optional;
public class ImageBiomeProvider implements BiomeProvider {
private final int resolution;
@@ -14,7 +14,8 @@ public class BiomeChunkImpl implements BiomeChunk {
private final SeededVector worldOrigin;
private final int chunkOriginArrayIndex;
private final int worldCoordinateScale;
private PipelineBiome[][] biomes;
private final int size;
private PipelineBiome[] biomes;
public BiomeChunkImpl(SeededVector worldOrigin, PipelineImpl pipeline) {
@@ -22,14 +23,14 @@ public class BiomeChunkImpl implements BiomeChunk {
this.chunkOriginArrayIndex = pipeline.getChunkOriginArrayIndex();
this.worldCoordinateScale = pipeline.getResolution();
int size = pipeline.getArraySize();
this.size = pipeline.getArraySize();
int expanderCount = pipeline.getExpanderCount();
int expansionsApplied = 0;
// Allocate working arrays
this.biomes = new PipelineBiome[size][size];
PipelineBiome[][] lookupArray = new PipelineBiome[size][size];
this.biomes = new PipelineBiome[size * size];
PipelineBiome[] lookupArray = new PipelineBiome[size * size];
// A second lookup array is required such that stage application doesn't affect lookups, otherwise application may cascade
// Construct working grid
@@ -43,7 +44,7 @@ public class BiomeChunkImpl implements BiomeChunk {
for(int gridZ = 0; gridZ < gridSize; gridZ++) {
int xIndex = gridOrigin + gridX * gridInterval;
int zIndex = gridOrigin + gridZ * gridInterval;
biomes[xIndex][zIndex] = pipeline.getSource().get(worldOrigin.seed(), xIndexToWorldCoordinate(xIndex),
biomes[(xIndex * size) + zIndex] = pipeline.getSource().get(worldOrigin.seed(), xIndexToWorldCoordinate(xIndex),
zIndexToWorldCoordinate(zIndex));
}
}
@@ -65,7 +66,7 @@ public class BiomeChunkImpl implements BiomeChunk {
// Cycle arrays, the previously populated array is swapped to be used for lookups, and the result of the stage application
// overwrites the previous lookup array. This saves having to allocate a new array copy each time
PipelineBiome[][] tempArray = biomes;
PipelineBiome[] tempArray = biomes;
biomes = lookupArray;
lookupArray = tempArray;
@@ -74,7 +75,8 @@ public class BiomeChunkImpl implements BiomeChunk {
for(int gridX = 0; gridX < gridSize; gridX = gridX + 1) {
int xIndex = gridOrigin + gridX * gridInterval;
int zIndex = gridOrigin + gridZ * gridInterval;
biomes[xIndex][zIndex] = stage.apply(new ViewPoint(this, gridInterval, gridX, gridZ, xIndex, zIndex, lookupArray));
biomes[(xIndex * size) + zIndex] = stage.apply(
new ViewPoint(this, gridInterval, gridX, gridZ, xIndex, zIndex, lookupArray, size));
}
}
}
@@ -133,7 +135,7 @@ public class BiomeChunkImpl implements BiomeChunk {
public PipelineBiome get(int xInChunk, int zInChunk) {
int xIndex = xInChunk + chunkOriginArrayIndex;
int zIndex = zInChunk + chunkOriginArrayIndex;
return biomes[xIndex][zIndex];
return biomes[(xIndex * size) + zIndex];
}
private int xIndexToWorldCoordinate(int xIndex) {
@@ -159,10 +161,11 @@ public class BiomeChunkImpl implements BiomeChunk {
private final int gridZ;
private final int xIndex;
private final int zIndex;
private final PipelineBiome[][] lookupArray;
private final PipelineBiome[] lookupArray;
private final int size;
private ViewPoint(BiomeChunkImpl chunk, int gridInterval, int gridX, int gridZ, int xIndex, int zIndex,
PipelineBiome[][] lookupArray) {
PipelineBiome[] lookupArray, int size) {
this.chunk = chunk;
this.gridInterval = gridInterval;
this.gridX = gridX;
@@ -170,13 +173,14 @@ public class BiomeChunkImpl implements BiomeChunk {
this.xIndex = xIndex;
this.zIndex = zIndex;
this.lookupArray = lookupArray;
this.biome = lookupArray[xIndex][zIndex];
this.size = size;
this.biome = lookupArray[(this.xIndex * this.size) + this.zIndex];
}
public PipelineBiome getRelativeBiome(int x, int z) {
int lookupXIndex = this.xIndex + x * gridInterval;
int lookupZIndex = this.zIndex + z * gridInterval;
return lookupArray[lookupXIndex][lookupZIndex];
return lookupArray[(lookupXIndex * this.size) + lookupZIndex];
}
public PipelineBiome getBiome() {
+1 -1
View File
@@ -1,4 +1,4 @@
version = version("1.1.0")
version = version("1.1.1")
dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
@@ -8,31 +8,24 @@ import com.dfsek.terra.api.world.WritableWorld;
public class VanillaOreUtils {
protected static boolean shouldNotDiscard(Random random, double chance) {
if(chance <= 0.0F) {
return true;
} else if(chance >= 1.0F) {
return false;
} else {
return random.nextFloat() >= chance;
}
private static boolean shouldExpose(Random random, double exposedChance) {
if(exposedChance >= 1.0F) return true;
if(exposedChance <= 0.0F) return false;
return random.nextFloat() < exposedChance;
}
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposed, Random random, WritableWorld world, int x,
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposedChance, Random random, WritableWorld world,
int x,
int y, int z) {
if(!replaceable.contains(type)) {
return false;
} else if(shouldNotDiscard(random, exposed)) {
return true;
} else {
return !(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());
}
if(!replaceable.contains(type)) return false;
if(shouldExpose(random, exposedChance)) return true; // Exposed blocks can be placed regardless of adjacency to air
// Adjacency is checked after determining not exposed rather than vice-versa, assuming block checks are more expensive
boolean adjacentAir = 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();
return !adjacentAir; // Exposed check did not pass earlier so only blocks not adjacent air should place
}
}
@@ -26,6 +26,33 @@ import com.dfsek.tectonic.api.loader.AbstractConfigLoader;
import com.dfsek.tectonic.api.loader.ConfigLoader;
import com.dfsek.tectonic.api.loader.type.TypeLoader;
import com.dfsek.tectonic.yaml.YamlConfiguration;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimaps;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.addon.BaseAddon;
@@ -56,28 +83,16 @@ import com.dfsek.terra.config.fileloaders.FolderLoader;
import com.dfsek.terra.config.fileloaders.ZIPLoader;
import com.dfsek.terra.config.loaders.GenericTemplateSupplierLoader;
import com.dfsek.terra.config.loaders.config.BufferedImageLoader;
import com.dfsek.terra.config.preprocessor.*;
import com.dfsek.terra.config.preprocessor.MetaListLikePreprocessor;
import com.dfsek.terra.config.preprocessor.MetaMapPreprocessor;
import com.dfsek.terra.config.preprocessor.MetaNumberPreprocessor;
import com.dfsek.terra.config.preprocessor.MetaStringPreprocessor;
import com.dfsek.terra.config.preprocessor.MetaValuePreprocessor;
import com.dfsek.terra.config.prototype.ProtoConfig;
import com.dfsek.terra.registry.CheckedRegistryImpl;
import com.dfsek.terra.registry.OpenRegistryImpl;
import com.dfsek.terra.registry.ShortcutHolder;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimaps;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.image.BufferedImage;
import java.io.*;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* Represents a Terra configuration pack.
@@ -1,10 +1,10 @@
package com.dfsek.terra.bukkit.nms.v1_19_R1;
import com.dfsek.terra.api.properties.Properties;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import com.dfsek.terra.api.properties.Properties;
public record NMSBiomeInfo(ResourceKey<Biome> biomeKey) implements Properties {
}
+2
View File
@@ -29,6 +29,8 @@ dependencies {
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
}
loom {
+2 -2
View File
@@ -13,7 +13,7 @@ val dump = tasks.create("dumpDependents") {
doFirst {
taskSet.forEach {
val resource = File(resourcesDir, it.archiveFileName.get())
println("Including archive " + it.archiveFileName.orNull + " in directory " + resource.absolutePath)
logger.info("Including archive " + it.archiveFileName.orNull + " in directory " + resource.absolutePath)
it.archiveFile.get().asFile.copyTo(resource, true)
}
}
@@ -32,6 +32,6 @@ afterEvaluate {
}
tasks["dumpDependents"].dependsOn(task)
taskSet.add(task)
println("Merged JAR will incorporate task ${task.name} from platform ${it.name}.")
logger.info("Merged JAR will incorporate task ${task.name} from platform ${it.name}.")
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ fun includeImmediateChildren(dir: File, type: String) {
dir.walkTopDown().maxDepth(1).forEach {
if (!it.isDirectory || !File(it, "build.gradle.kts").exists()) return@forEach
val addonDir = it.relativeTo(file(".")).path.replace("/", ":").replace("\\", ":")
println("Including $type directory \"$addonDir\" as subproject.")
logger.info("Including $type directory \"$addonDir\" as subproject.")
include(addonDir)
}
}