Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.19 #318

Merged
merged 40 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cd57a32
update build to support 1.19
dfsek May 31, 2022
9d131a8
update FabricChunkGeneratorWrapper
dfsek May 31, 2022
9c9487c
1.19 fabric compiles now
dfsek May 31, 2022
d07f9fe
clean up BeardGenerator
dfsek May 31, 2022
1d46968
Merge branch 'master' into dev/1.19
dfsek Jun 2, 2022
2608e94
fix run task addon dependency
dfsek Jun 2, 2022
5b2e8b7
temporarily disable Cloud
dfsek Jun 2, 2022
6e18978
use default block registry
dfsek Jun 2, 2022
d4abeda
remove cloud Fabric dependency entirely
dfsek Jun 2, 2022
64f6647
remove fabric command api dependency
dfsek Jun 2, 2022
229886d
update to minecraft 1.19-rc2
dfsek Jun 4, 2022
3b98f8c
add seed hack for biome provider
dfsek Jun 4, 2022
1eb2d5c
fix mapping change in BeardGenerator
dfsek Jun 4, 2022
f05e4c1
register terra world preset
dfsek Jun 4, 2022
c55c19a
reduce seed hack console spam
dfsek Jun 4, 2022
7027574
Merge remote-tracking branch 'origin/ver/6.0.1' into dev/1.19
dfsek Jun 4, 2022
f870dab
correct key used to register world type
dfsek Jun 4, 2022
b4bee3a
add ReloadCommandMixin
dfsek Jun 4, 2022
b0aca47
registerTags -> registerBiomeTags
dfsek Jun 5, 2022
76e8c2d
tag collection util method
dfsek Jun 5, 2022
ed7bfd2
register normal tag to Terra world presets
dfsek Jun 6, 2022
254bc93
remove unneeded seed from TerraBiomeSource
dfsek Jun 6, 2022
fbbf09a
fix beardification
dfsek Jun 6, 2022
3adcdb4
implement air threshold in beardifier
dfsek Jun 6, 2022
908a5dc
use main executor for generation
dfsek Jun 6, 2022
4e78947
update loom
dfsek Jun 7, 2022
90f3138
Merge remote-tracking branch 'origin/ver/6.0.1' into dev/1.19
dfsek Jun 7, 2022
e89d473
update to 1.19
dfsek Jun 7, 2022
fa66bd3
create addon dir if it doesn't exist
dfsek Jun 7, 2022
5de8df1
specify failed addon path
dfsek Jun 7, 2022
db0067a
improve addonDir addon installation
dfsek Jun 7, 2022
9ac63ce
fix (??) Loom issues
dfsek Jun 7, 2022
098cb74
fix addon check on fresh install
dfsek Jun 7, 2022
c811fd3
warn about nonexistent classpath resources
dfsek Jun 7, 2022
1858bab
only remove old resources if replacement exists
dfsek Jun 7, 2022
f4968e1
downgrade loom
dfsek Jun 7, 2022
9a640de
fix file dumping
dfsek Jun 7, 2022
372931a
fix chunkregion entity spawn crash
dfsek Jun 7, 2022
c468054
spawn entity in serverworld with no world object
dfsek Jun 7, 2022
d0069ff
bump version
dfsek Jun 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
preRelease(true)

versionProjects(":common:api", version("6.0.1"))
versionProjects(":common:implementation", version("6.0.1"))
versionProjects(":platforms", version("6.0.1"))
versionProjects(":common:api", version("6.1.0"))
versionProjects(":common:implementation", version("6.1.0"))
versionProjects(":platforms", version("6.1.0"))


allprojects {
Expand Down
13 changes: 11 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ plugins {
kotlin("jvm") version embeddedKotlinVersion
}

buildscript {
configurations.all {
resolutionStrategy {
force("org.ow2.asm:asm:9.3") // TODO: remove when ShadowJar updates ASM version
force("org.ow2.asm:asm-commons:9.3")
}
}
}

repositories {
mavenCentral()
gradlePluginPortal()
Expand All @@ -11,8 +20,8 @@ repositories {

dependencies {
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
implementation("org.ow2.asm:asm:9.2")
implementation("org.ow2.asm:asm-tree:9.2")
implementation("org.ow2.asm:asm:9.3")
implementation("org.ow2.asm:asm-tree:9.3")
implementation("com.dfsek.tectonic:common:4.2.0")
implementation("org.yaml:snakeyaml:1.27")
}
46 changes: 25 additions & 21 deletions buildSrc/src/main/kotlin/AddonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import java.io.File
import java.util.function.Predicate
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.extra
import kotlin.streams.asStream

Expand All @@ -12,28 +11,33 @@ import kotlin.streams.asStream
* Configures a directory where addons will be put.
*/
fun Project.addonDir(dir: File, task: Task) {
task.dependsOn("compileAddons")
task.doFirst {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = tasks.named("shadowJar").get() as ShadowJar

val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())

val base = "${jar.archiveBaseName.get()}-${version}"

println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
val moveAddons = tasks.register("moveAddons" + task.name) {
dependsOn("compileAddons")
doLast {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = tasks.named("shadowJar").get() as ShadowJar

val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())

val base = "${jar.archiveBaseName.get()}-${version}"

println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")

jar.archiveFile.orNull?.asFile?.copyTo(target)
}
}

jar.archiveFile.orNull?.asFile?.copyTo(target)
}
}

task.dependsOn(moveAddons)
}

fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {
Expand Down
8 changes: 5 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ object Versions {

object Fabric {
const val fabricLoader = "0.14.2"
const val fabricAPI = "0.53.4+1.18.2"
const val minecraft = "1.18.2"
const val yarn = "$minecraft+build.3"
const val fabricAPI = "0.55.1+1.19"
const val minecraft = "1.19"
const val yarn = "$minecraft+build.1"
const val permissionsAPI = "0.1-SNAPSHOT"
const val mixin = "0.11.2+mixin.0.8.5"
const val loom = "0.11-SNAPSHOT"
}

object Bukkit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,6 @@

import com.dfsek.tectonic.api.TypeRegistry;

import com.dfsek.terra.api.util.generic.pair.Pair;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import com.dfsek.terra.addon.BootstrapAddonLoader;
import com.dfsek.terra.addon.DependencySorter;
import com.dfsek.terra.addon.EphemeralAddon;
Expand All @@ -64,6 +37,7 @@
import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.registry.Registry;
import com.dfsek.terra.api.registry.key.StringIdentifiable;
import com.dfsek.terra.api.util.generic.pair.Pair;
import com.dfsek.terra.api.util.mutable.MutableBoolean;
import com.dfsek.terra.api.util.reflection.TypeKey;
import com.dfsek.terra.config.GenericLoaders;
Expand All @@ -75,6 +49,21 @@
import com.dfsek.terra.registry.OpenRegistryImpl;
import com.dfsek.terra.registry.master.ConfigRegistry;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;


/**
* Skeleton implementation of {@link Platform}
Expand Down Expand Up @@ -119,8 +108,10 @@ protected void load() {
logger.info("Initializing Terra...");

try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
logger.info("Loading config.yml");
File configFile = new File(getDataFolder(), "config.yml");
if(!configFile.exists()) {
logger.info("Writing new config.yml...");
FileUtils.copyInputStreamToFile(stream, configFile);
}
} catch(IOException e) {
Expand Down Expand Up @@ -222,6 +213,7 @@ protected void dumpResources() {
Path data = getDataFolder().toPath();

Path addonsPath = data.resolve("addons");
Files.createDirectories(addonsPath);
Set<Pair<Path, String>> paths = Files
.walk(addonsPath)
.map(path -> Pair.of(path, data.relativize(path).toString()))
Expand Down Expand Up @@ -249,7 +241,6 @@ protected void dumpResources() {
.collect(Collectors.toSet());


// Terra-aaa-aaa-1.2.3-BETA+1e6af8923d.jar
String resourceYaml = IOUtils.toString(resourcesConfig, StandardCharsets.UTF_8);
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
resources.forEach((dir, entries) -> entries.forEach(entry -> {
Expand All @@ -258,42 +249,44 @@ protected void dumpResources() {
if(resource.exists())
return; // dont overwrite

paths
.stream()
.filter(Pair.testRight(resourcePath::startsWith))
.forEach(Pair.consumeLeft(path -> {
logger.info("Removing outdated resource {}, replacing with {}", path, resourcePath);
try {
Files.delete(path);
} catch(IOException e) {
throw new UncheckedIOException(e);
}
}));

if(pathsNoMajor
.stream()
.anyMatch(resourcePath::startsWith) && // if any share name
paths
.stream()
.map(Pair.unwrapRight())
.noneMatch(resourcePath::startsWith)) { // but dont share major version
logger.warn(
"Addon {} has a new major version available. It will not be automatically updated; you will need to ensure " +
"compatibility and update manually.",
resourcePath);
}

logger.info("Dumping resource {}...", resource.getAbsolutePath());
try {
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath)) {
if(is == null) {
logger.error("Resource {} doesn't exist on the classpath!", resourcePath);
return;
}

paths
.stream()
.filter(Pair.testRight(resourcePath::startsWith))
.forEach(Pair.consumeLeft(path -> {
logger.info("Removing outdated resource {}, replacing with {}", path, resourcePath);
try {
Files.delete(path);
} catch(IOException e) {
throw new UncheckedIOException(e);
}
}));

if(pathsNoMajor
.stream()
.anyMatch(resourcePath::startsWith) && // if any share name
paths
.stream()
.map(Pair.unwrapRight())
.noneMatch(resourcePath::startsWith)) { // but dont share major version
logger.warn(
"Addon {} has a new major version available. It will not be automatically updated; you will need to " +
"ensure " +
"compatibility and update manually.",
resourcePath);
}

logger.info("Dumping resource {}...", resource.getAbsolutePath());
resource.getParentFile().mkdirs();
resource.createNewFile();
} catch(IOException e) {
throw new UncheckedIOException(e);
}
logger.debug("Copying resource {}", resourcePath);
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath);
OutputStream os = new FileOutputStream(resource)) {
IOUtils.copy(is, os);
try(OutputStream os = new FileOutputStream(resource)) {
IOUtils.copy(is, os);
}
} catch(IOException e) {
throw new UncheckedIOException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,24 @@ private BootstrapBaseAddon<?> loadAddon(Path addonPath, BootstrapAddonClassLoade
}

} catch(IOException e) {
throw new UncheckedIOException(e);
throw new AddonLoadException("Failed to load addon from path " + addonPath, e);
}
}

@Override
public Iterable<BootstrapBaseAddon<?>> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
Path bootstrapFolder = addonsFolder.resolve("bootstrap");
logger.debug("Loading bootstrap addons from {}", bootstrapFolder);

try(Stream<Path> bootstrapAddons = Files.walk(bootstrapFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
return bootstrapAddons.filter(path -> path.toFile().isFile())
.filter(path -> path.toFile().canRead())
.filter(path -> path.toString().endsWith(".jar"))
.map(path -> loadAddon(path, parent))
.collect(Collectors.toList());
try {
Path bootstrapFolder = addonsFolder.resolve("bootstrap");
Files.createDirectories(bootstrapFolder);
logger.debug("Loading bootstrap addons from {}", bootstrapFolder);

try(Stream<Path> bootstrapAddons = Files.walk(bootstrapFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
return bootstrapAddons.filter(path -> path.toFile().isFile())
.filter(path -> path.toFile().canRead())
.filter(path -> path.toString().endsWith(".jar"))
.map(path -> loadAddon(path, parent))
.collect(Collectors.toList());
}
} catch(IOException e) {
throw new UncheckedIOException(e);
}
Expand Down
12 changes: 8 additions & 4 deletions platforms/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import com.modrinth.minotaur.TaskModrinthUpload
import net.fabricmc.loom.task.RemapJarTask

plugins {
id("fabric-loom").version("0.11-SNAPSHOT")
id("fabric-loom").version(Versions.Fabric.loom)
id("com.modrinth.minotaur").version("1.1.0")
}

Expand All @@ -15,7 +15,7 @@ dependencies {

modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")

setOf("fabric-command-api-v1", "fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base").forEach { apiModule ->
setOf("fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base").forEach { apiModule ->
val module = fabricApi.module(apiModule, Versions.Fabric.fabricAPI)
modImplementation(module)
include(module)
Expand All @@ -24,8 +24,12 @@ dependencies {
include(modImplementation("me.lucko", "fabric-permissions-api", Versions.Fabric.permissionsAPI))
include("me.lucko", "fabric-permissions-api", Versions.Fabric.permissionsAPI)

include(modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud))
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
"compileOnly"("net.fabricmc:sponge-mixin:${Versions.Fabric.mixin}")
"annotationProcessor"("net.fabricmc:sponge-mixin:${Versions.Fabric.mixin}")
"annotationProcessor"("net.fabricmc:fabric-loom:${Versions.Fabric.loom}")

//include(modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud))
//include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
}

loom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@

package com.dfsek.terra.fabric;

import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.fabric.FabricServerCommandManager;
import net.fabricmc.api.ModInitializer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.WorldPresets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dfsek.terra.api.command.CommandSender;
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
import com.dfsek.terra.fabric.data.Codecs;


Expand All @@ -49,7 +45,7 @@ public static void register() { // register the things
@Override
public void onInitialize() {
logger.info("Initializing Terra Fabric mod...");

/*
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
CommandExecutionCoordinator.simpleCoordinator(),
serverCommandSource -> (CommandSender) serverCommandSource,
Expand All @@ -60,5 +56,7 @@ public void onInitialize() {
manager.brigadierManager().setNativeNumberSuggestions(false);

TERRA_PLUGIN.getEventManager().callEvent(new CommandRegistrationEvent(manager));
TODO: re-enable when Cloud updates
*/
}
}
Loading