Merge branch 'master' into ver/6.5.0

This commit is contained in:
Astrash 2023-11-25 12:33:51 +11:00
commit ffb1198da2
9 changed files with 28 additions and 33 deletions

View File

@ -18,7 +18,7 @@ fun Project.addonDir(dir: File, task: Task) {
matchingAddons(dir) { matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon. it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach { }.forEach {
println("Deleting old addon: " + it.absolutePath) logger.info("Deleting old addon: " + it.absolutePath)
it.delete() it.delete()
} }
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
@ -29,7 +29,7 @@ fun Project.addonDir(dir: File, task: Task) {
val base = "${jar.archiveBaseName.get()}-${version}" 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) jar.archiveFile.orNull?.asFile?.copyTo(target)
} }

View File

@ -53,7 +53,7 @@ fun Project.configureDistribution() {
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
val jar = getJarTask() 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 boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}") val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")

View File

@ -42,10 +42,10 @@ fun preRelease(preRelease: Boolean) {
fun Project.versionProjects(project: String, version: String) { fun Project.versionProjects(project: String, version: String) {
forSubProjects(project) { forSubProjects(project) {
this.version = version this.version = version
println("Setting version of $path to $version") logger.info("Setting version of $path to $version")
} }
project(project).version = 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 { fun Project.version(version: String): String {

View File

@ -82,7 +82,7 @@ abstract class GenerateDocsTask : DefaultTask() {
} }
template.add(keyName.toString(), description.toString().ifBlank { 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.*" "*No description provided.*"
}) })
} }

View File

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

View File

@ -8,31 +8,24 @@ import com.dfsek.terra.api.world.WritableWorld;
public class VanillaOreUtils { public class VanillaOreUtils {
protected static boolean shouldNotDiscard(Random random, double chance) { private static boolean shouldExpose(Random random, double exposedChance) {
if(chance <= 0.0F) { if(exposedChance >= 1.0F) return true;
return true; if(exposedChance <= 0.0F) return false;
} else if(chance >= 1.0F) { return random.nextFloat() < exposedChance;
return false;
} else {
return random.nextFloat() >= chance;
}
} }
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) { int y, int z) {
if(!replaceable.contains(type)) { if(!replaceable.contains(type)) return false;
return false; if(shouldExpose(random, exposedChance)) return true; // Exposed blocks can be placed regardless of adjacency to air
} else if(shouldNotDiscard(random, exposed)) { // Adjacency is checked after determining not exposed rather than vice-versa, assuming block checks are more expensive
return true; boolean adjacentAir = world.getBlockState(x, y, z - 1).isAir() ||
} else {
return !(world.getBlockState(x, y, z - 1).isAir() ||
world.getBlockState(x, y, z + 1).isAir() || world.getBlockState(x, y, z + 1).isAir() ||
world.getBlockState(x, y - 1, z).isAir() || world.getBlockState(x, y - 1, z).isAir() ||
world.getBlockState(x, y + 1, z).isAir() || world.getBlockState(x, y + 1, z).isAir() ||
world.getBlockState(x - 1, y, z).isAir() || world.getBlockState(x - 1, y, z).isAir() ||
world.getBlockState(x + 1, y, z).isAir()); world.getBlockState(x + 1, y, z).isAir();
return !adjacentAir; // Exposed check did not pass earlier so only blocks not adjacent air should place
} }
}
} }

View File

@ -29,6 +29,8 @@ dependencies {
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
include("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 { loom {

View File

@ -13,7 +13,7 @@ val dump = tasks.create("dumpDependents") {
doFirst { doFirst {
taskSet.forEach { taskSet.forEach {
val resource = File(resourcesDir, it.archiveFileName.get()) 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) it.archiveFile.get().asFile.copyTo(resource, true)
} }
} }
@ -32,6 +32,6 @@ afterEvaluate {
} }
tasks["dumpDependents"].dependsOn(task) tasks["dumpDependents"].dependsOn(task)
taskSet.add(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}.")
} }
} }

View File

@ -5,7 +5,7 @@ fun includeImmediateChildren(dir: File, type: String) {
dir.walkTopDown().maxDepth(1).forEach { dir.walkTopDown().maxDepth(1).forEach {
if (!it.isDirectory || !File(it, "build.gradle.kts").exists()) return@forEach if (!it.isDirectory || !File(it, "build.gradle.kts").exists()) return@forEach
val addonDir = it.relativeTo(file(".")).path.replace("/", ":").replace("\\", ":") 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) include(addonDir)
} }
} }