From 4886701744568e2b8c34d5e4d03b4119b87f7f18 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Thu, 29 Jun 2023 19:44:56 +0200 Subject: [PATCH 01/10] WIP --- CHANGELOG.md | 2 +- build.gradle | 49 ++++++++++++++++++- docker/docker-compose.yml | 20 ++++++++ gradle.properties | 25 +++++++--- .../de/michiruf/serverportals/Command.java | 7 ++- .../config/PortalRegistrationData.java | 6 +-- .../versioned/VersionedRegistryAccess.java | 16 ++++++ src/main/resources/fabric.mod.json | 4 +- .../versioned/VersionedRegistryAccess.java | 16 ++++++ 9 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 docker/docker-compose.yml create mode 100644 src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ebdb7..3ce0ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -Initial project creation +Add other versions of minecraft 1.19 diff --git a/build.gradle b/build.gradle index 433700d..9e299fe 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,9 @@ plugins { id 'fabric-loom' version '1.0-SNAPSHOT' id 'com.modrinth.minotaur' version '2.+' + + // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself + id 'com.netflix.nebula.facet' version '10.1.2' } allprojects { @@ -29,6 +32,30 @@ allprojects { } } + + facets { + v1_19_2 + v1_19_3 + } + + sourceSets { + v1_19_2 { + compileClasspath += sourceSets.main.output + runtimeClasspath += sourceSets.main.output + } + v1_19_3 { + compileClasspath += sourceSets.main.output + runtimeClasspath += sourceSets.main.output + } + } + +// configurations { +// v1_19_2Implementation.extendsFrom(implementation) +// v1_19_2ModImplementation.extendsFrom(modImplementation) +// v1_19_3Implementation.extendsFrom(implementation) +// v1_19_3ModImplementation.extendsFrom(modImplementation) +// } + try { project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" } catch (Exception ignored) { @@ -38,6 +65,22 @@ allprojects { project.group = 'michiruf' } +task printSourceSetInformation() { + + doLast { + sourceSets.each { srcSet -> + println "[" + srcSet.name + "]" + print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" + print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" + print "-->Compile classpath:\n" + srcSet.compileClasspath.files.each { + print " " + it.path + "\n" + } + println "" + } + } +} + repositories { mavenCentral() maven { url 'https://maven.wispforest.io' } // Owo config @@ -55,7 +98,9 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Owo config - annotationProcessor modImplementation('io.wispforest:owo-lib:0.9.2+1.19') + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) // Custom portal api modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) @@ -67,7 +112,7 @@ modrinth { projectId = 'server-portals' versionNumber = project.version versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = ['1.19.2'] + gameVersions = ['1.19'] // ['1.19.2'] loaders = ['fabric'] dependencies { required.project 'fabric-api' diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..55cb6c8 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,20 @@ +mc: + container_name: mc + image: itzg/minecraft-server:java17-alpine + ports: + - '25565:25565' + environment: + EULA: 'true' + OVERRIDE_SERVER_PROPERTIES: 'true' + TYPE: FABRIC + VERSION: 1.19.3 + MODRINTH_PROJECTS: fabric-api,owo-lib + MODRINTH_ALLOWED_VERSION_TYPE: alpha + USE_AIKAR_FLAGS: 'true' + REMOVE_OLD_MODS: 'true' + volumes: + - 'mc_data:/data/' + - '../build/libs/:/mods/' + - '/etc/timezone:/etc/timezone:ro' + tty: true + restart: always diff --git a/gradle.properties b/gradle.properties index 737a882..1036c32 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,25 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G + # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.28 -loader_version=0.14.11 +# 1.19.2 +#minecraft_version=1.19.2 +#yarn_mappings=1.19.2+build.28 +#loader_version=0.14.9 +#fabric_version=0.72.0+1.19.2 + +# 1.19.1 +#minecraft_version=1.19.1 +#yarn_mappings=1.19.1+build.1 +#loader_version=0.14.12 +#fabric_version=0.58.5+1.19.1 + +# 1.19.3 +minecraft_version=1.19.3 +yarn_mappings=1.19.3+build.5 +loader_version=0.14.9 +fabric_version=0.72.0+1.19.3 + # Mod Properties archives_base_name=server-portals -# Dependencies -# check this on https://modmuss50.me/fabric.html -fabric_version=0.68.0+1.19.2 diff --git a/src/main/java/de/michiruf/serverportals/Command.java b/src/main/java/de/michiruf/serverportals/Command.java index 342ff93..0e3ee4b 100644 --- a/src/main/java/de/michiruf/serverportals/Command.java +++ b/src/main/java/de/michiruf/serverportals/Command.java @@ -9,15 +9,14 @@ import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.command.argument.ColorArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; +import net.minecraft.registry.Registries; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; -import net.minecraft.util.registry.Registry; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -120,8 +119,8 @@ private static int executeRegisterCommand(CommandContext co var portal = new PortalRegistrationData( index, - Registry.BLOCK.getId(frameBlock.getBlockState().getBlock()).toString(), - Registry.ITEM.getId(lightWith.getItem()).toString(), + Registries.BLOCK.getId(frameBlock.getBlockState().getBlock()).toString(), + Registries.ITEM.getId(lightWith.getItem()).toString(), color.getColorValue() != null ? color.getColorValue() : 0, command); // Save must be trigger manually here, because it is a list and cannot observe changes (even when calling diff --git a/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java b/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java index 3d7ac03..bb6db12 100644 --- a/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java +++ b/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java @@ -2,8 +2,8 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; /** * @author Michael Ruf @@ -36,11 +36,11 @@ public PortalRegistrationData( } public Block frameBlock() { - return Registry.BLOCK.get(new Identifier(frameBlockId)); + return Registries.BLOCK.get(new Identifier(frameBlockId)); } public Item lightWithItem() { - return Registry.ITEM.get(new Identifier(lightWithItemId)); + return Registries.ITEM.get(new Identifier(lightWithItemId)); } public String index() { diff --git a/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..20ef4b3 --- /dev/null +++ b/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,16 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.block.Block; +import net.minecraft.registry.DefaultedRegistry; +import net.minecraft.registry.Registries; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static DefaultedRegistry blocks() { + return Registries.BLOCK; + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8e7d596..430b979 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,9 +23,9 @@ }, "mixins": [], "depends": { - "fabricloader": ">=0.14.11", + "fabricloader": ">=0.12.12", "fabric": "*", - "minecraft": "1.19.2", + "minecraft": ">=1.19", "owo-lib": ">=0.8.5" } } diff --git a/src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..20ef4b3 --- /dev/null +++ b/src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,16 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.block.Block; +import net.minecraft.registry.DefaultedRegistry; +import net.minecraft.registry.Registries; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static DefaultedRegistry blocks() { + return Registries.BLOCK; + } +} From 1985cd33141ebc208f53fb57e19b1afb0d3e9484 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Sun, 3 Dec 2023 18:04:32 +0100 Subject: [PATCH 02/10] WIP Another try to achieve anything in regards to multi version setups --- build.gradle | 74 ++++--- build_BACKUP.gradle | 165 ++++++++++++++++ gradle.properties | 3 - settings.gradle | 4 + .../versioned/VersionedRegistryAccess.java | 0 .../versioned/VersionedRegistryAccess.java | 16 ++ v1_19/build.gradle | 182 ++++++++++++++++++ 7 files changed, 415 insertions(+), 29 deletions(-) create mode 100644 build_BACKUP.gradle rename src/{v1_19_2 => v1_19}/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java (100%) create mode 100644 src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 v1_19/build.gradle diff --git a/build.gradle b/build.gradle index 9e299fe..072051b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,10 @@ plugins { +// id 'fabric-loom' version '1.4.4' id 'fabric-loom' version '1.0-SNAPSHOT' id 'com.modrinth.minotaur' version '2.+' // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself - id 'com.netflix.nebula.facet' version '10.1.2' + id 'com.netflix.nebula.facet' version '10.1.5' } allprojects { @@ -32,29 +33,51 @@ allprojects { } } - - facets { - v1_19_2 - v1_19_3 - } +// facets { +// v1_19 { +// // NOTE Should be the default value +// parentSourceSet = 'main' +// } +// v1_19_3 { +// parentSourceSet = 'main' +// } +// } sourceSets { - v1_19_2 { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output + v1_19 { + compileClasspath += sourceSets.main.compileClasspath + runtimeClasspath += sourceSets.main.runtimeClasspath } v1_19_3 { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output + compileClasspath += sourceSets.main.compileClasspath + runtimeClasspath += sourceSets.main.runtimeClasspath } +// v1_20 { +// compileClasspath += sourceSets.main.compileClasspath +// runtimeClasspath += sourceSets.main.runtimeClasspath +// } } -// configurations { -// v1_19_2Implementation.extendsFrom(implementation) -// v1_19_2ModImplementation.extendsFrom(modImplementation) + configurations { + // 1.19.1 + v1_19_1Implementation.extendsFrom(implementation) + v1_19_1ModImplementation.extendsFrom(modImplementation) + v1_19_1Minecraft.extendsFrom(minecraft) + v1_19_1Mappings.extendsFrom(mappings) + // v1_19_3Implementation.extendsFrom(implementation) // v1_19_3ModImplementation.extendsFrom(modImplementation) -// } +// v1_19_3Minecraft.extendsFrom(minecraft) +// v1_19_3Mappings.extendsFrom(mappings) +// v1_19_3Implementation.extendsFrom(implementation) +// v1_19_3ModImplementation.extendsFrom(modImplementation) +// v1_19_3Minecraft.extendsFrom(minecraft) +// v1_19_3Mappings.extendsFrom(mappings) + v1_20Implementation.extendsFrom(implementation) + v1_20ModImplementation.extendsFrom(modImplementation) + v1_20Minecraft.extendsFrom(minecraft) + v1_20Mappings.extendsFrom(mappings) + } try { project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" @@ -63,10 +86,10 @@ allprojects { project.version = '0' } project.group = 'michiruf' + project.archivesBaseName = 'server-portals' } task printSourceSetInformation() { - doLast { sourceSets.each { srcSet -> println "[" + srcSet.name + "]" @@ -89,23 +112,23 @@ repositories { } dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + minecraft 'com.mojang:minecraft:1.19.3' + mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' + modImplementation 'net.fabricmc:fabric-loader:0.14.9' + modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' // Owo config modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) // Custom portal api modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) + + // Version specific minecraft } modrinth { @@ -152,7 +175,6 @@ java { if (JavaVersion.current() < javaVersion) { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } - archivesBaseName = project.archives_base_name // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this line, sources will not be generated. diff --git a/build_BACKUP.gradle b/build_BACKUP.gradle new file mode 100644 index 0000000..6be5e20 --- /dev/null +++ b/build_BACKUP.gradle @@ -0,0 +1,165 @@ +plugins { + id 'fabric-loom' version '1.4.4' + id 'com.modrinth.minotaur' version '2.+' + +// id 'com.netflix.nebula.project' version '10.1.5' + // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself + id 'com.netflix.nebula.facet' version '10.1.5' +} + +allprojects { + // This can get extracted into a root build.gradle if needed + ext { + getLatestTag = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["describe", "--tags", "--abbrev=0"] + standardOutput = os + } + return os.toString().trim() + } + } + + getCurrentCommitCount = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["rev-list", "--all", "--count"] + standardOutput = os + } + return os.toString().trim() + } + } + } + + facets { + v1_19_2 { + parentSourceSet = 'main' + } + v1_19_3 { + parentSourceSet = 'main' + } + } + +// sourceSets { +// v1_19_2 { +// compileClasspath += sourceSets.main.output +// runtimeClasspath += sourceSets.main.output +// } +// v1_19_3 { +// compileClasspath += sourceSets.main.output +// runtimeClasspath += sourceSets.main.output +// } +// } +// +// configurations { +// v1_19_2Implementation.extendsFrom(implementation) +// v1_19_2ModImplementation.extendsFrom(modImplementation) +// v1_19_2Minecraft.extendsFrom(minecraft) +// v1_19_2Mappings.extendsFrom(mappings) +// v1_19_3Implementation.extendsFrom(implementation) +// v1_19_3ModImplementation.extendsFrom(modImplementation) +// } + + try { + project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" + } catch (Exception ignored) { + println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') + project.version = '0' + } + project.group = 'michiruf' +} + +task printSourceSetInformation() { + doLast { + sourceSets.each { srcSet -> + println "[" + srcSet.name + "]" + print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" + print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" + print "-->Compile classpath:\n" + srcSet.compileClasspath.files.each { + print " " + it.path + "\n" + } + println "" + } + } +} + +repositories { + mavenCentral() + maven { url 'https://maven.wispforest.io' } // Owo config + maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // Owo config + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + + // Custom portal api + modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) + modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) + modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) +} + +modrinth { + projectId = 'server-portals' + versionNumber = project.version + versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' + gameVersions = ['1.19'] // ['1.19.2'] + loaders = ['fabric'] + dependencies { + required.project 'fabric-api' + required.project 'owo-lib' + } + uploadFile = remapJar + syncBodyFrom = rootProject.file("README.md").text + + // Use the environment variable `$MODRINTH_TOKEN` for the token + // token = 'mySecretToken' +} +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +processResources { + inputs.property 'version', project.version + filteringCharset 'UTF-8' + + filesMatching('fabric.mod.json') { + expand 'version': project.version + } +} + +def targetJavaVersion = 17 +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + it.options.release = targetJavaVersion + } +} + +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + archivesBaseName = project.archives_base_name + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} diff --git a/gradle.properties b/gradle.properties index 1036c32..82dce40 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,3 @@ minecraft_version=1.19.3 yarn_mappings=1.19.3+build.5 loader_version=0.14.9 fabric_version=0.72.0+1.19.3 - -# Mod Properties -archives_base_name=server-portals diff --git a/settings.gradle b/settings.gradle index f91a4fe..32b7667 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,3 +7,7 @@ pluginManagement { gradlePluginPortal() } } + +include ':common' +include ':v1_19' +include ':v1_19_3' \ No newline at end of file diff --git a/src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/src/v1_19/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java similarity index 100% rename from src/v1_19_2/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename to src/v1_19/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..20ef4b3 --- /dev/null +++ b/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,16 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.block.Block; +import net.minecraft.registry.DefaultedRegistry; +import net.minecraft.registry.Registries; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static DefaultedRegistry blocks() { + return Registries.BLOCK; + } +} diff --git a/v1_19/build.gradle b/v1_19/build.gradle new file mode 100644 index 0000000..072051b --- /dev/null +++ b/v1_19/build.gradle @@ -0,0 +1,182 @@ +plugins { +// id 'fabric-loom' version '1.4.4' + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'com.modrinth.minotaur' version '2.+' + + // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself + id 'com.netflix.nebula.facet' version '10.1.5' +} + +allprojects { + // This can get extracted into a root build.gradle if needed + ext { + getLatestTag = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["describe", "--tags", "--abbrev=0"] + standardOutput = os + } + return os.toString().trim() + } + } + + getCurrentCommitCount = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["rev-list", "--all", "--count"] + standardOutput = os + } + return os.toString().trim() + } + } + } + +// facets { +// v1_19 { +// // NOTE Should be the default value +// parentSourceSet = 'main' +// } +// v1_19_3 { +// parentSourceSet = 'main' +// } +// } + + sourceSets { + v1_19 { + compileClasspath += sourceSets.main.compileClasspath + runtimeClasspath += sourceSets.main.runtimeClasspath + } + v1_19_3 { + compileClasspath += sourceSets.main.compileClasspath + runtimeClasspath += sourceSets.main.runtimeClasspath + } +// v1_20 { +// compileClasspath += sourceSets.main.compileClasspath +// runtimeClasspath += sourceSets.main.runtimeClasspath +// } + } + + configurations { + // 1.19.1 + v1_19_1Implementation.extendsFrom(implementation) + v1_19_1ModImplementation.extendsFrom(modImplementation) + v1_19_1Minecraft.extendsFrom(minecraft) + v1_19_1Mappings.extendsFrom(mappings) + +// v1_19_3Implementation.extendsFrom(implementation) +// v1_19_3ModImplementation.extendsFrom(modImplementation) +// v1_19_3Minecraft.extendsFrom(minecraft) +// v1_19_3Mappings.extendsFrom(mappings) +// v1_19_3Implementation.extendsFrom(implementation) +// v1_19_3ModImplementation.extendsFrom(modImplementation) +// v1_19_3Minecraft.extendsFrom(minecraft) +// v1_19_3Mappings.extendsFrom(mappings) + v1_20Implementation.extendsFrom(implementation) + v1_20ModImplementation.extendsFrom(modImplementation) + v1_20Minecraft.extendsFrom(minecraft) + v1_20Mappings.extendsFrom(mappings) + } + + try { + project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" + } catch (Exception ignored) { + println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') + project.version = '0' + } + project.group = 'michiruf' + project.archivesBaseName = 'server-portals' +} + +task printSourceSetInformation() { + doLast { + sourceSets.each { srcSet -> + println "[" + srcSet.name + "]" + print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" + print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" + print "-->Compile classpath:\n" + srcSet.compileClasspath.files.each { + print " " + it.path + "\n" + } + println "" + } + } +} + +repositories { + mavenCentral() + maven { url 'https://maven.wispforest.io' } // Owo config + maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive +} + +dependencies { + minecraft 'com.mojang:minecraft:1.19.3' + mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' + modImplementation 'net.fabricmc:fabric-loader:0.14.9' + modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' + + // Owo config + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + + // Custom portal api + modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) + modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) + modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) + + // Version specific minecraft +} + +modrinth { + projectId = 'server-portals' + versionNumber = project.version + versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' + gameVersions = ['1.19'] // ['1.19.2'] + loaders = ['fabric'] + dependencies { + required.project 'fabric-api' + required.project 'owo-lib' + } + uploadFile = remapJar + syncBodyFrom = rootProject.file("README.md").text + + // Use the environment variable `$MODRINTH_TOKEN` for the token + // token = 'mySecretToken' +} +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +processResources { + inputs.property 'version', project.version + filteringCharset 'UTF-8' + + filesMatching('fabric.mod.json') { + expand 'version': project.version + } +} + +def targetJavaVersion = 17 +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + it.options.release = targetJavaVersion + } +} + +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} From 1ad31492bc8aefee177e4606ac3afbaa8a9f902b Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Sun, 3 Dec 2023 18:42:06 +0100 Subject: [PATCH 03/10] Multi project WIP --- {v1_19 => OLD}/build.gradle | 0 build.gradle | 150 +--------------- build_BACKUP.gradle | 165 ------------------ common/build.gradle | 38 ++++ .../de/michiruf/serverportals/Command.java | 0 .../serverportals/ServerPortalsMod.java | 1 - .../serverportals/config/ConfigModel.java | 0 .../config/PortalRegistrationData.java | 0 .../versioned/VersionedRegistryAccess.java | 0 .../src}/main/resources/fabric.mod.json | 0 gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 6 +- .../versioned/VersionedRegistryAccess.java | 16 -- .../versioned/VersionedRegistryAccess.java | 0 14 files changed, 44 insertions(+), 334 deletions(-) rename {v1_19 => OLD}/build.gradle (100%) delete mode 100644 build_BACKUP.gradle create mode 100644 common/build.gradle rename {src => common/src}/main/java/de/michiruf/serverportals/Command.java (100%) rename {src => common/src}/main/java/de/michiruf/serverportals/ServerPortalsMod.java (97%) rename {src => common/src}/main/java/de/michiruf/serverportals/config/ConfigModel.java (100%) rename {src => common/src}/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java (100%) rename {src => common/src}/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java (100%) rename {src => common/src}/main/resources/fabric.mod.json (100%) delete mode 100644 src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename {src/v1_19 => v1_19_3/src}/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java (100%) diff --git a/v1_19/build.gradle b/OLD/build.gradle similarity index 100% rename from v1_19/build.gradle rename to OLD/build.gradle diff --git a/build.gradle b/build.gradle index 072051b..5a101e0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,3 @@ -plugins { -// id 'fabric-loom' version '1.4.4' - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'com.modrinth.minotaur' version '2.+' - - // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself - id 'com.netflix.nebula.facet' version '10.1.5' -} - allprojects { // This can get extracted into a root build.gradle if needed ext { @@ -33,52 +24,6 @@ allprojects { } } -// facets { -// v1_19 { -// // NOTE Should be the default value -// parentSourceSet = 'main' -// } -// v1_19_3 { -// parentSourceSet = 'main' -// } -// } - - sourceSets { - v1_19 { - compileClasspath += sourceSets.main.compileClasspath - runtimeClasspath += sourceSets.main.runtimeClasspath - } - v1_19_3 { - compileClasspath += sourceSets.main.compileClasspath - runtimeClasspath += sourceSets.main.runtimeClasspath - } -// v1_20 { -// compileClasspath += sourceSets.main.compileClasspath -// runtimeClasspath += sourceSets.main.runtimeClasspath -// } - } - - configurations { - // 1.19.1 - v1_19_1Implementation.extendsFrom(implementation) - v1_19_1ModImplementation.extendsFrom(modImplementation) - v1_19_1Minecraft.extendsFrom(minecraft) - v1_19_1Mappings.extendsFrom(mappings) - -// v1_19_3Implementation.extendsFrom(implementation) -// v1_19_3ModImplementation.extendsFrom(modImplementation) -// v1_19_3Minecraft.extendsFrom(minecraft) -// v1_19_3Mappings.extendsFrom(mappings) -// v1_19_3Implementation.extendsFrom(implementation) -// v1_19_3ModImplementation.extendsFrom(modImplementation) -// v1_19_3Minecraft.extendsFrom(minecraft) -// v1_19_3Mappings.extendsFrom(mappings) - v1_20Implementation.extendsFrom(implementation) - v1_20ModImplementation.extendsFrom(modImplementation) - v1_20Minecraft.extendsFrom(minecraft) - v1_20Mappings.extendsFrom(mappings) - } - try { project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" } catch (Exception ignored) { @@ -86,97 +31,6 @@ allprojects { project.version = '0' } project.group = 'michiruf' - project.archivesBaseName = 'server-portals' -} - -task printSourceSetInformation() { - doLast { - sourceSets.each { srcSet -> - println "[" + srcSet.name + "]" - print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" - print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" - print "-->Compile classpath:\n" - srcSet.compileClasspath.files.each { - print " " + it.path + "\n" - } - println "" - } - } -} - -repositories { - mavenCentral() - maven { url 'https://maven.wispforest.io' } // Owo config - maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -dependencies { - minecraft 'com.mojang:minecraft:1.19.3' - mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' - modImplementation 'net.fabricmc:fabric-loader:0.14.9' - modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' - - // Owo config - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) - - // Version specific minecraft -} - -modrinth { - projectId = 'server-portals' - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = ['1.19'] // ['1.19.2'] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - -processResources { - inputs.property 'version', project.version - filteringCharset 'UTF-8' - - filesMatching('fabric.mod.json') { - expand 'version': project.version - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() + // TODO + //project.archivesBaseName = 'server-portals' } diff --git a/build_BACKUP.gradle b/build_BACKUP.gradle deleted file mode 100644 index 6be5e20..0000000 --- a/build_BACKUP.gradle +++ /dev/null @@ -1,165 +0,0 @@ -plugins { - id 'fabric-loom' version '1.4.4' - id 'com.modrinth.minotaur' version '2.+' - -// id 'com.netflix.nebula.project' version '10.1.5' - // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself - id 'com.netflix.nebula.facet' version '10.1.5' -} - -allprojects { - // This can get extracted into a root build.gradle if needed - ext { - getLatestTag = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["describe", "--tags", "--abbrev=0"] - standardOutput = os - } - return os.toString().trim() - } - } - - getCurrentCommitCount = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["rev-list", "--all", "--count"] - standardOutput = os - } - return os.toString().trim() - } - } - } - - facets { - v1_19_2 { - parentSourceSet = 'main' - } - v1_19_3 { - parentSourceSet = 'main' - } - } - -// sourceSets { -// v1_19_2 { -// compileClasspath += sourceSets.main.output -// runtimeClasspath += sourceSets.main.output -// } -// v1_19_3 { -// compileClasspath += sourceSets.main.output -// runtimeClasspath += sourceSets.main.output -// } -// } -// -// configurations { -// v1_19_2Implementation.extendsFrom(implementation) -// v1_19_2ModImplementation.extendsFrom(modImplementation) -// v1_19_2Minecraft.extendsFrom(minecraft) -// v1_19_2Mappings.extendsFrom(mappings) -// v1_19_3Implementation.extendsFrom(implementation) -// v1_19_3ModImplementation.extendsFrom(modImplementation) -// } - - try { - project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" - } catch (Exception ignored) { - println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') - project.version = '0' - } - project.group = 'michiruf' -} - -task printSourceSetInformation() { - doLast { - sourceSets.each { srcSet -> - println "[" + srcSet.name + "]" - print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" - print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" - print "-->Compile classpath:\n" - srcSet.compileClasspath.files.each { - print " " + it.path + "\n" - } - println "" - } - } -} - -repositories { - mavenCentral() - maven { url 'https://maven.wispforest.io' } // Owo config - maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - // Owo config - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) -} - -modrinth { - projectId = 'server-portals' - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = ['1.19'] // ['1.19.2'] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - -processResources { - inputs.property 'version', project.version - filteringCharset 'UTF-8' - - filesMatching('fabric.mod.json') { - expand 'version': project.version - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - archivesBaseName = project.archives_base_name - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..842dc46 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'fabric-loom' version '1.4-SNAPSHOT' +} + +repositories { + mavenCentral() + maven { url 'https://maven.wispforest.io' } // Owo config + maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive +} + +dependencies { + minecraft 'com.mojang:minecraft:1.19.3' + mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' + modImplementation 'net.fabricmc:fabric-loader:0.14.9' + modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' + + // Owo config + compileOnly 'io.wispforest:owo-lib:0.9.3+1.19' + compileOnly 'io.wispforest:owo-lib:0.9.3+1.19' + + // Custom portal api + compileOnly 'net.kyrptonaught:customportalapi:0.0.1-beta54-1.19' + compileOnly 'net.kyrptonaught:cpa-polymer:1.0.0-1.19' + compileOnly 'eu.pb4:polymer:0.2.18+1.19.2' +} + +def targetJavaVersion = 17 +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + it.options.release = targetJavaVersion + } +} diff --git a/src/main/java/de/michiruf/serverportals/Command.java b/common/src/main/java/de/michiruf/serverportals/Command.java similarity index 100% rename from src/main/java/de/michiruf/serverportals/Command.java rename to common/src/main/java/de/michiruf/serverportals/Command.java diff --git a/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java similarity index 97% rename from src/main/java/de/michiruf/serverportals/ServerPortalsMod.java rename to common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java index c7a05a2..3f13921 100644 --- a/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java +++ b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java @@ -3,7 +3,6 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; import net.kyrptonaught.customportalapi.api.CustomPortalBuilder; import net.kyrptonaught.customportalapi.util.SHOULDTP; import net.minecraft.entity.Entity; diff --git a/src/main/java/de/michiruf/serverportals/config/ConfigModel.java b/common/src/main/java/de/michiruf/serverportals/config/ConfigModel.java similarity index 100% rename from src/main/java/de/michiruf/serverportals/config/ConfigModel.java rename to common/src/main/java/de/michiruf/serverportals/config/ConfigModel.java diff --git a/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java b/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java similarity index 100% rename from src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java rename to common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java diff --git a/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java similarity index 100% rename from src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename to common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/src/main/resources/fabric.mod.json b/common/src/main/resources/fabric.mod.json similarity index 100% rename from src/main/resources/fabric.mod.json rename to common/src/main/resources/fabric.mod.json diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..db9a6b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 32b7667..be13856 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,6 @@ pluginManagement { } } -include ':common' -include ':v1_19' -include ':v1_19_3' \ No newline at end of file +rootProject.name = 'server-portals' +include 'common' +include 'v1_19_3' diff --git a/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index 20ef4b3..0000000 --- a/src/v1_19_3/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.block.Block; -import net.minecraft.registry.DefaultedRegistry; -import net.minecraft.registry.Registries; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static DefaultedRegistry blocks() { - return Registries.BLOCK; - } -} diff --git a/src/v1_19/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1_19_3/src/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java similarity index 100% rename from src/v1_19/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename to v1_19_3/src/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java From 97efdc43573a0977999403a1deeadf155e273a08 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Mon, 4 Dec 2023 00:46:07 +0100 Subject: [PATCH 04/10] Another failed try, but stil promising --- OLD/build.gradle | 182 ------------------ common/build.gradle | 33 +++- gradle.properties | 19 +- settings.gradle | 13 +- v1.19.3/build.gradle | 83 ++++++++ .../versioned/VersionedRegistryAccess.java | 0 .../src/main/resources/fabric.mod.json | 0 7 files changed, 131 insertions(+), 199 deletions(-) delete mode 100644 OLD/build.gradle create mode 100644 v1.19.3/build.gradle rename {v1_19_3/src => v1.19.3/src/main}/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java (100%) rename {common => v1.19.3}/src/main/resources/fabric.mod.json (100%) diff --git a/OLD/build.gradle b/OLD/build.gradle deleted file mode 100644 index 072051b..0000000 --- a/OLD/build.gradle +++ /dev/null @@ -1,182 +0,0 @@ -plugins { -// id 'fabric-loom' version '1.4.4' - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'com.modrinth.minotaur' version '2.+' - - // Awesome plugin to not have to handle the boilerplate code for sourceSets and configurations yourself - id 'com.netflix.nebula.facet' version '10.1.5' -} - -allprojects { - // This can get extracted into a root build.gradle if needed - ext { - getLatestTag = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["describe", "--tags", "--abbrev=0"] - standardOutput = os - } - return os.toString().trim() - } - } - - getCurrentCommitCount = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["rev-list", "--all", "--count"] - standardOutput = os - } - return os.toString().trim() - } - } - } - -// facets { -// v1_19 { -// // NOTE Should be the default value -// parentSourceSet = 'main' -// } -// v1_19_3 { -// parentSourceSet = 'main' -// } -// } - - sourceSets { - v1_19 { - compileClasspath += sourceSets.main.compileClasspath - runtimeClasspath += sourceSets.main.runtimeClasspath - } - v1_19_3 { - compileClasspath += sourceSets.main.compileClasspath - runtimeClasspath += sourceSets.main.runtimeClasspath - } -// v1_20 { -// compileClasspath += sourceSets.main.compileClasspath -// runtimeClasspath += sourceSets.main.runtimeClasspath -// } - } - - configurations { - // 1.19.1 - v1_19_1Implementation.extendsFrom(implementation) - v1_19_1ModImplementation.extendsFrom(modImplementation) - v1_19_1Minecraft.extendsFrom(minecraft) - v1_19_1Mappings.extendsFrom(mappings) - -// v1_19_3Implementation.extendsFrom(implementation) -// v1_19_3ModImplementation.extendsFrom(modImplementation) -// v1_19_3Minecraft.extendsFrom(minecraft) -// v1_19_3Mappings.extendsFrom(mappings) -// v1_19_3Implementation.extendsFrom(implementation) -// v1_19_3ModImplementation.extendsFrom(modImplementation) -// v1_19_3Minecraft.extendsFrom(minecraft) -// v1_19_3Mappings.extendsFrom(mappings) - v1_20Implementation.extendsFrom(implementation) - v1_20ModImplementation.extendsFrom(modImplementation) - v1_20Minecraft.extendsFrom(minecraft) - v1_20Mappings.extendsFrom(mappings) - } - - try { - project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" - } catch (Exception ignored) { - println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') - project.version = '0' - } - project.group = 'michiruf' - project.archivesBaseName = 'server-portals' -} - -task printSourceSetInformation() { - doLast { - sourceSets.each { srcSet -> - println "[" + srcSet.name + "]" - print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" - print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" - print "-->Compile classpath:\n" - srcSet.compileClasspath.files.each { - print " " + it.path + "\n" - } - println "" - } - } -} - -repositories { - mavenCentral() - maven { url 'https://maven.wispforest.io' } // Owo config - maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -dependencies { - minecraft 'com.mojang:minecraft:1.19.3' - mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' - modImplementation 'net.fabricmc:fabric-loader:0.14.9' - modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' - - // Owo config - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) - - // Version specific minecraft -} - -modrinth { - projectId = 'server-portals' - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = ['1.19'] // ['1.19.2'] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - -processResources { - inputs.property 'version', project.version - filteringCharset 'UTF-8' - - filesMatching('fabric.mod.json') { - expand 'version': project.version - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} diff --git a/common/build.gradle b/common/build.gradle index 842dc46..2b750f4 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,28 +1,47 @@ plugins { - id 'fabric-loom' version '1.4-SNAPSHOT' + id 'idea' + id 'java' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' } repositories { mavenCentral() +// maven { url 'https://libraries.minecraft.net' } // Minecraft + maven { url 'https://maven.fabricmc.net' } // Fabric loader maven { url 'https://maven.wispforest.io' } // Owo config maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive } +base { + archivesName = "${rootProject.name}-common-${minecraft_version}" +} + +minecraft { + version('1.19.2') +} + dependencies { - minecraft 'com.mojang:minecraft:1.19.3' - mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' - modImplementation 'net.fabricmc:fabric-loader:0.14.9' - modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' +// // Minecraft +// compileOnly 'com.mojang:brigadier:1.0.18' + // Minecraft Sponge + compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5' + + // Fabric loader + compileOnly 'net.fabricmc:fabric-loader:0.14.9' + compileOnly 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' // Owo config - compileOnly 'io.wispforest:owo-lib:0.9.3+1.19' - compileOnly 'io.wispforest:owo-lib:0.9.3+1.19' + implementation 'io.wispforest:owo-lib:0.9.3+1.19' + annotationProcessor 'io.wispforest:owo-lib:0.9.3+1.19' // Custom portal api compileOnly 'net.kyrptonaught:customportalapi:0.0.1-beta54-1.19' compileOnly 'net.kyrptonaught:cpa-polymer:1.0.0-1.19' compileOnly 'eu.pb4:polymer:0.2.18+1.19.2' + + // Security + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' } def targetJavaVersion = 17 diff --git a/gradle.properties b/gradle.properties index 82dce40..f5af870 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,11 +3,6 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -# 1.19.2 -#minecraft_version=1.19.2 -#yarn_mappings=1.19.2+build.28 -#loader_version=0.14.9 -#fabric_version=0.72.0+1.19.2 # 1.19.1 #minecraft_version=1.19.1 @@ -15,8 +10,14 @@ org.gradle.jvmargs=-Xmx1G #loader_version=0.14.12 #fabric_version=0.58.5+1.19.1 -# 1.19.3 -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.5 +# 1.19.2 +minecraft_version=1.19.2 +yarn_mappings=1.19.2+build.28 loader_version=0.14.9 -fabric_version=0.72.0+1.19.3 +fabric_version=0.72.0+1.19.2 + +# 1.19.3 +#minecraft_version=1.19.3 +#yarn_mappings=1.19.3+build.5 +#loader_version=0.14.9 +#fabric_version=0.72.0+1.19.3 diff --git a/settings.gradle b/settings.gradle index be13856..cbcac65 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,9 +5,20 @@ pluginManagement { url = 'https://maven.fabricmc.net/' } gradlePluginPortal() + + // For sponge snapshot plugin 'org.spongepowered.gradle.vanilla' + // Got from: https://github.com/jaredlll08/MultiLoader-Template/blob/1.20.2/settings.gradle + maven { + name = 'Sponge' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } } } +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' +} + rootProject.name = 'server-portals' include 'common' -include 'v1_19_3' +include 'v1.19.3' diff --git a/v1.19.3/build.gradle b/v1.19.3/build.gradle new file mode 100644 index 0000000..96be5da --- /dev/null +++ b/v1.19.3/build.gradle @@ -0,0 +1,83 @@ +plugins { + id 'java' + id 'fabric-loom' version '1.4-SNAPSHOT' + id 'com.modrinth.minotaur' version '2.+' +} + +repositories { + mavenCentral() + maven { url 'https://maven.wispforest.io' } // Owo config + maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive +} + +dependencies { + minecraft 'com.mojang:minecraft:1.19.3' + //mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' + mappings loom.officialMojangMappings() + modImplementation 'net.fabricmc:fabric-loader:0.14.9' + modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' + + implementation project(':common') + + // Owo config + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + + // Custom portal api + modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) + modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) + modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) +} + +modrinth { + projectId = 'server-portals' + versionNumber = project.version + versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' + gameVersions = ['1.19'] // ['1.19.2'] + loaders = ['fabric'] + dependencies { + required.project 'fabric-api' + required.project 'owo-lib' + } + uploadFile = remapJar + syncBodyFrom = rootProject.file("README.md").text + + // Use the environment variable `$MODRINTH_TOKEN` for the token + // token = 'mySecretToken' +} +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +processResources { + inputs.property 'version', project.version + filteringCharset 'UTF-8' + + filesMatching('fabric.mod.json') { + expand 'version': project.version + } +} + +def targetJavaVersion = 17 +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + it.options.release = targetJavaVersion + } +} + +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} diff --git a/v1_19_3/src/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java similarity index 100% rename from v1_19_3/src/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename to v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/common/src/main/resources/fabric.mod.json b/v1.19.3/src/main/resources/fabric.mod.json similarity index 100% rename from common/src/main/resources/fabric.mod.json rename to v1.19.3/src/main/resources/fabric.mod.json From 0ad2a39c6449c28aae3862f06316a5b283c3749b Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Tue, 12 Dec 2023 22:31:50 +0100 Subject: [PATCH 05/10] Basically, this approach should work, if the code gets refactored to work with official mojang mappings, since spongepowered vanilla plugins seems to do so aswell --- build.gradle | 4 + common/build.gradle | 118 ++++++++++++++---- .../de/michiruf/serverportals/Command.java | 8 +- .../serverportals/ServerPortalsMod.java | 1 - .../config/PortalRegistrationData.java | 9 +- .../versioned/VersionedRegistryAccess.java | 16 --- common/src/main/resources/fabric.mod.json | 31 +++++ gradle.properties | 21 ---- settings.gradle | 11 +- v1.19.0_sponge/build.gradle | 16 +++ .../versioned/VersionedRegistryAccess.java | 20 +++ v1.19.1_sponge/build.gradle | 16 +++ .../versioned/VersionedRegistryAccess.java | 20 +++ v1.19.2_sponge/build.gradle | 16 +++ .../versioned/VersionedRegistryAccess.java | 21 ++++ v1.19.3/build.gradle | 43 +++++-- v1.19.3_sponge/build.gradle | 16 +++ .../versioned/VersionedRegistryAccess.java | 21 ++++ 18 files changed, 321 insertions(+), 87 deletions(-) delete mode 100644 common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 common/src/main/resources/fabric.mod.json create mode 100644 v1.19.0_sponge/build.gradle create mode 100644 v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 v1.19.1_sponge/build.gradle create mode 100644 v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 v1.19.2_sponge/build.gradle create mode 100644 v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java create mode 100644 v1.19.3_sponge/build.gradle create mode 100644 v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/build.gradle b/build.gradle index 5a101e0..446ef58 100644 --- a/build.gradle +++ b/build.gradle @@ -33,4 +33,8 @@ allprojects { project.group = 'michiruf' // TODO //project.archivesBaseName = 'server-portals' + // Inside project: +// base { +// archivesName = "${rootProject.name}-common-${minecraft_version}" +// } } diff --git a/common/build.gradle b/common/build.gradle index 2b750f4..7516238 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,47 +1,102 @@ plugins { - id 'idea' id 'java' - id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' + // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'com.modrinth.minotaur' version '2.+' } repositories { mavenCentral() -// maven { url 'https://libraries.minecraft.net' } // Minecraft - maven { url 'https://maven.fabricmc.net' } // Fabric loader maven { url 'https://maven.wispforest.io' } // Owo config maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive } -base { - archivesName = "${rootProject.name}-common-${minecraft_version}" -} - -minecraft { - version('1.19.2') -} +// Check minecraft, mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html +def minecraftVersionDefinitions = [ + '1.19.1': [ + minecraft : '1.19.1', + mappings : '1.19.1+build.6', + fabric : '0.15.0', + fabricApi : '0.58.5+1.19.1', + supportedVersions: ['1.19.1'], + versionedRegistryAccess: 'v1.19.1_sponge' + ], + '1.19.2': [ + minecraft: '1.19.2', + mappings : '1.19.2+build.28', + fabric : '0.15.0', + fabricApi: '0.77.0+1.19.2', + supportedVersions: ['1.19.2'], + versionedRegistryAccess: 'v1.19.2_sponge' + ], + '1.19.3': [ + minecraft: '1.19.3', + mappings : '1.19.3+build.5', + fabric : '0.15.0', + fabricApi: '0.76.1+1.19.3', + supportedVersions: ['1.19.3'], + versionedRegistryAccess: 'v1.19.3_sponge' + ] +] +var minecraftVersion = '1.19.1'; +var minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] dependencies { -// // Minecraft -// compileOnly 'com.mojang:brigadier:1.0.18' - // Minecraft Sponge - compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5' + // Minecraft and fabric + minecraft "com.mojang:minecraft:${minecraftVersionDefinition['minecraft']}" + //mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" + // It is necessary to use officialMojangMappings, since it (as least) looks like + // sponge is doing the same in the respective submodules + // In the case it should be possible to go back to sourceSets, this should not be + // needed anymore + mappings loom.officialMojangMappings() + modImplementation "net.fabricmc:fabric-loader:${minecraftVersionDefinition['fabric']}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${minecraftVersionDefinition['fabricApi']}" - // Fabric loader - compileOnly 'net.fabricmc:fabric-loader:0.14.9' - compileOnly 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' + // Versioned subprojects + implementation(include(project(path: ":${minecraftVersionDefinition['versionedRegistryAccess']}"))) // Owo config - implementation 'io.wispforest:owo-lib:0.9.3+1.19' - annotationProcessor 'io.wispforest:owo-lib:0.9.3+1.19' - + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) // Custom portal api - compileOnly 'net.kyrptonaught:customportalapi:0.0.1-beta54-1.19' - compileOnly 'net.kyrptonaught:cpa-polymer:1.0.0-1.19' - compileOnly 'eu.pb4:polymer:0.2.18+1.19.2' + modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) + modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) + modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) +} - // Security - implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' +loom { + interfaceInjection { + enableDependencyInterfaceInjection = true + } +} + +modrinth { + projectId = rootProject.name + versionNumber = project.version + versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' + gameVersions = minecraftVersionDefinition['supportedVersions'] + loaders = ['fabric'] + dependencies { + required.project 'fabric-api' + required.project 'owo-lib' + } + uploadFile = remapJar + syncBodyFrom = rootProject.file("README.md").text + + // Use the environment variable `$MODRINTH_TOKEN` for the token + // token = 'mySecretToken' +} +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +processResources { + inputs.property 'version', project.version + filteringCharset 'UTF-8' + + filesMatching('fabric.mod.json') { + expand 'version': project.version + } } def targetJavaVersion = 17 @@ -55,3 +110,14 @@ tasks.withType(JavaCompile).configureEach { it.options.release = targetJavaVersion } } + +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} diff --git a/common/src/main/java/de/michiruf/serverportals/Command.java b/common/src/main/java/de/michiruf/serverportals/Command.java index 0e3ee4b..e26fa6a 100644 --- a/common/src/main/java/de/michiruf/serverportals/Command.java +++ b/common/src/main/java/de/michiruf/serverportals/Command.java @@ -5,11 +5,11 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.tree.LiteralCommandNode; import de.michiruf.serverportals.config.PortalRegistrationData; +import de.michiruf.serverportals.versioned.VersionedRegistryAccess; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.command.argument.ColorArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; -import net.minecraft.registry.Registries; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; @@ -33,8 +33,6 @@ */ public class Command { - private static final Map> commands = new HashMap<>(); - public static void registerCommands(CommandDispatcher dispatcher, CommandRegistryAccess registry, CommandManager.RegistrationEnvironment environment) { @@ -119,8 +117,8 @@ private static int executeRegisterCommand(CommandContext co var portal = new PortalRegistrationData( index, - Registries.BLOCK.getId(frameBlock.getBlockState().getBlock()).toString(), - Registries.ITEM.getId(lightWith.getItem()).toString(), + VersionedRegistryAccess.block().getId(frameBlock.getBlockState().getBlock()).toString(), + VersionedRegistryAccess.item().getId(lightWith.getItem()).toString(), color.getColorValue() != null ? color.getColorValue() : 0, command); // Save must be trigger manually here, because it is a list and cannot observe changes (even when calling diff --git a/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java index 3f13921..f4b50d5 100644 --- a/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java +++ b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java @@ -5,7 +5,6 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.kyrptonaught.customportalapi.api.CustomPortalBuilder; import net.kyrptonaught.customportalapi.util.SHOULDTP; -import net.minecraft.entity.Entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java b/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java index bb6db12..69e3426 100644 --- a/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java +++ b/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java @@ -2,8 +2,10 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; -import net.minecraft.registry.Registries; +import de.michiruf.serverportals.versioned.VersionedRegistryAccess; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Block; /** * @author Michael Ruf @@ -36,11 +38,12 @@ public PortalRegistrationData( } public Block frameBlock() { - return Registries.BLOCK.get(new Identifier(frameBlockId)); + return VersionedRegistryAccess.block().get(new ResourceLocation(frameBlockId)); + return VersionedRegistryAccess.block().get(new Identifier(frameBlockId)); } public Item lightWithItem() { - return Registries.ITEM.get(new Identifier(lightWithItemId)); + return VersionedRegistryAccess.item().get(new Identifier(lightWithItemId)); } public String index() { diff --git a/common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index 20ef4b3..0000000 --- a/common/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.block.Block; -import net.minecraft.registry.DefaultedRegistry; -import net.minecraft.registry.Registries; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static DefaultedRegistry blocks() { - return Registries.BLOCK; - } -} diff --git a/common/src/main/resources/fabric.mod.json b/common/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..430b979 --- /dev/null +++ b/common/src/main/resources/fabric.mod.json @@ -0,0 +1,31 @@ +{ + "schemaVersion": 1, + "id": "server-portals", + "version": "${version}", + "name": "ServerPortals", + "description": "", + "authors": [ + "michiruf" + ], + "contact": { + "website": "https://github.com/michiruf" + }, + "license": "MIT", + "icon": "assets/serverportals/icon.png", + "environment": "*", + "entrypoints": { + "server": [ + "de.michiruf.serverportals.ServerPortalsMod" + ], + "client": [ + "de.michiruf.serverportals.ServerPortalsMod" + ] + }, + "mixins": [], + "depends": { + "fabricloader": ">=0.12.12", + "fabric": "*", + "minecraft": ">=1.19", + "owo-lib": ">=0.8.5" + } +} diff --git a/gradle.properties b/gradle.properties index f5af870..5cacfe8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,2 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G - -# Fabric Properties -# check these on https://modmuss50.me/fabric.html - -# 1.19.1 -#minecraft_version=1.19.1 -#yarn_mappings=1.19.1+build.1 -#loader_version=0.14.12 -#fabric_version=0.58.5+1.19.1 - -# 1.19.2 -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.28 -loader_version=0.14.9 -fabric_version=0.72.0+1.19.2 - -# 1.19.3 -#minecraft_version=1.19.3 -#yarn_mappings=1.19.3+build.5 -#loader_version=0.14.9 -#fabric_version=0.72.0+1.19.3 diff --git a/settings.gradle b/settings.gradle index cbcac65..98b9561 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,6 +7,7 @@ pluginManagement { gradlePluginPortal() // For sponge snapshot plugin 'org.spongepowered.gradle.vanilla' + // NOTE May remove this if unused // Got from: https://github.com/jaredlll08/MultiLoader-Template/blob/1.20.2/settings.gradle maven { name = 'Sponge' @@ -15,10 +16,10 @@ pluginManagement { } } -plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' -} - rootProject.name = 'server-portals' include 'common' -include 'v1.19.3' +//include 'v1.19.3' +include 'v1.19.0_sponge' +include 'v1.19.1_sponge' +include 'v1.19.2_sponge' +include 'v1.19.3_sponge' diff --git a/v1.19.0_sponge/build.gradle b/v1.19.0_sponge/build.gradle new file mode 100644 index 0000000..4a95e3b --- /dev/null +++ b/v1.19.0_sponge/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java-library' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' +} + +minecraft { + version('1.19') + platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) + runs { + server() + //client() + } +} + +dependencies { +} diff --git a/v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..f411aeb --- /dev/null +++ b/v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,20 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static Registry block() { + return Registry.BLOCK; + } + + public static Registry item() { + return Registry.ITEM; + } +} \ No newline at end of file diff --git a/v1.19.1_sponge/build.gradle b/v1.19.1_sponge/build.gradle new file mode 100644 index 0000000..7818af8 --- /dev/null +++ b/v1.19.1_sponge/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java-library' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' +} + +minecraft { + version('1.19.1') + platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) + runs { + server() + //client() + } +} + +dependencies { +} diff --git a/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..f411aeb --- /dev/null +++ b/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,20 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static Registry block() { + return Registry.BLOCK; + } + + public static Registry item() { + return Registry.ITEM; + } +} \ No newline at end of file diff --git a/v1.19.2_sponge/build.gradle b/v1.19.2_sponge/build.gradle new file mode 100644 index 0000000..a4832e3 --- /dev/null +++ b/v1.19.2_sponge/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java-library' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' +} + +minecraft { + version('1.19.2') + platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) + runs { + server() + //client() + } +} + +dependencies { +} diff --git a/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..b2b442a --- /dev/null +++ b/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,21 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static Registry block() { + return Registry.BLOCK; + } + + public static Registry item() { + return Registry.ITEM; + } +} diff --git a/v1.19.3/build.gradle b/v1.19.3/build.gradle index 96be5da..b921851 100644 --- a/v1.19.3/build.gradle +++ b/v1.19.3/build.gradle @@ -1,6 +1,7 @@ plugins { id 'java' - id 'fabric-loom' version '1.4-SNAPSHOT' + // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work + id 'fabric-loom' version '1.0-SNAPSHOT' id 'com.modrinth.minotaur' version '2.+' } @@ -11,20 +12,36 @@ repositories { maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive } -dependencies { - minecraft 'com.mojang:minecraft:1.19.3' - //mappings 'net.fabricmc:yarn:1.19.3+build.5:v2' - mappings loom.officialMojangMappings() - modImplementation 'net.fabricmc:fabric-loader:0.14.9' - modImplementation 'net.fabricmc.fabric-api:fabric-api:0.72.0+1.19.3' +configurations { + // TODO Try to use those in the common module + sharedMinecraft { + canBeResolved = false + assert canBeConsumed + extendsFrom minecraft + } + sharedMappings { + canBeResolved = false + assert canBeConsumed + extendsFrom mappings + } +} + +ext { + minecraft = '1.19.3' + mappings = '1.19.3+build.5' + fabricLoader = '0.14.9' + fabricApi = '0.72.0+1.19.3' +} - implementation project(':common') +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft}" + mappings "net.fabricmc:yarn:${project.mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.fabricLoader}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabricApi}" // Owo config modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_2Implementation(v1_19_2AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - //v1_19_3Implementation(v1_19_3AnnotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) // Custom portal api modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) @@ -32,6 +49,12 @@ dependencies { modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) } +loom { + interfaceInjection { + enableDependencyInterfaceInjection = true + } +} + modrinth { projectId = 'server-portals' versionNumber = project.version diff --git a/v1.19.3_sponge/build.gradle b/v1.19.3_sponge/build.gradle new file mode 100644 index 0000000..472b2db --- /dev/null +++ b/v1.19.3_sponge/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java-library' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' +} + +minecraft { + version('1.19.3') + platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) + runs { + server() + //client() + } +} + +dependencies { +} diff --git a/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java new file mode 100644 index 0000000..46f56eb --- /dev/null +++ b/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java @@ -0,0 +1,21 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistryAccess { + + public static Registry block() { + return BuiltInRegistries.BLOCK; + } + + public static Registry item() { + return BuiltInRegistries.ITEM; + } +} From 6d2e65d67be1b585ccf2e3def4f8faf5735dc715 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Wed, 13 Dec 2023 01:02:42 +0100 Subject: [PATCH 06/10] Went back to one module only, but with different source sets - this way, the project does not depend on sponge and its mappings and should be more flexible --- buildSrc/build.gradle | 12 ++ .../gradle/findversion/FindVersion.java | 40 +++++++ common/build.gradle | 58 ++++++---- .../de/michiruf/serverportals/Command.java | 35 +++--- .../serverportals/ServerPortalsMod.java | 1 + .../config/PortalRegistrationData.java | 9 +- .../versioned/VersionedMessageSender.java | 16 +++ .../versioned/VersionedMessageSender.java | 23 ++++ .../versioned/VersionedRegistry.java | 21 ++++ .../versioned/VersionedRegistry.java | 8 +- settings.gradle | 5 - v1.19.0_sponge/build.gradle | 16 --- v1.19.1_sponge/build.gradle | 16 --- .../versioned/VersionedRegistryAccess.java | 20 ---- v1.19.2_sponge/build.gradle | 16 --- .../versioned/VersionedRegistryAccess.java | 21 ---- v1.19.3/build.gradle | 106 ------------------ .../versioned/VersionedRegistryAccess.java | 16 --- v1.19.3/src/main/resources/fabric.mod.json | 31 ----- v1.19.3_sponge/build.gradle | 16 --- .../versioned/VersionedRegistryAccess.java | 21 ---- 21 files changed, 170 insertions(+), 337 deletions(-) create mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/src/main/java/de/michiruf/gradle/findversion/FindVersion.java create mode 100644 common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java create mode 100644 common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java create mode 100644 common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java rename v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java => common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java (62%) delete mode 100644 v1.19.0_sponge/build.gradle delete mode 100644 v1.19.1_sponge/build.gradle delete mode 100644 v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java delete mode 100644 v1.19.2_sponge/build.gradle delete mode 100644 v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java delete mode 100644 v1.19.3/build.gradle delete mode 100644 v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java delete mode 100644 v1.19.3/src/main/resources/fabric.mod.json delete mode 100644 v1.19.3_sponge/build.gradle delete mode 100644 v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..5fa53bb --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,12 @@ +plugins { + id 'java-library' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation gradleApi() + implementation 'org.apache.maven:maven-artifact:3.9.6' +} diff --git a/buildSrc/src/main/java/de/michiruf/gradle/findversion/FindVersion.java b/buildSrc/src/main/java/de/michiruf/gradle/findversion/FindVersion.java new file mode 100644 index 0000000..cb84f28 --- /dev/null +++ b/buildSrc/src/main/java/de/michiruf/gradle/findversion/FindVersion.java @@ -0,0 +1,40 @@ +package de.michiruf.gradle.findversion; + +import org.apache.maven.artifact.versioning.ComparableVersion; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +public class FindVersion { + + public static String findClosestLowerOrEqualVersionInDirectory(File directory, String targetVersion) { + return findClosestLowerOrEqualVersionInDirectory(directory, targetVersion, true); + } + + public static String findClosestLowerOrEqualVersionInDirectory(File directory, String targetVersion, boolean onlySubdirectories) { + if (!directory.isDirectory()) + throw new IllegalArgumentException("Given file is not a directory"); + + var contents = onlySubdirectories ? directory.listFiles(File::isDirectory) : directory.listFiles(); + var contentsString = Arrays.stream(Objects.requireNonNull(contents)) + .map(File::getName) + .toList(); + return findClosestLowerOrEqualVersion(contentsString, targetVersion); + } + + public static String findClosestLowerOrEqualVersion(List versions, String targetVersion) { + var comparableTargetVersion = new ComparableVersion(targetVersion); + var result = versions.stream() + .map(ComparableVersion::new) + .filter(comparableVersion -> comparableVersion.compareTo(comparableTargetVersion) <= 0) + .max(ComparableVersion::compareTo); + if (result.isEmpty()) { + System.err.println("No version found. Did you pass versions to the function?"); + return null; + } + + return result.get().toString(); + } +} diff --git a/common/build.gradle b/common/build.gradle index 7516238..79b4047 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,3 +1,5 @@ +import de.michiruf.gradle.findversion.FindVersion + plugins { id 'java' // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work @@ -14,49 +16,57 @@ repositories { // Check minecraft, mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html def minecraftVersionDefinitions = [ + '1.19': [ + minecraft : '1.19', + mappings : '1.19+build.4', + fabric : '0.15.0', + fabricApi : '0.58.0+1.19', + supportedVersions: ['1.19'] + ], '1.19.1': [ minecraft : '1.19.1', mappings : '1.19.1+build.6', fabric : '0.15.0', fabricApi : '0.58.5+1.19.1', - supportedVersions: ['1.19.1'], - versionedRegistryAccess: 'v1.19.1_sponge' + supportedVersions: ['1.19.1'] ], '1.19.2': [ - minecraft: '1.19.2', - mappings : '1.19.2+build.28', - fabric : '0.15.0', - fabricApi: '0.77.0+1.19.2', - supportedVersions: ['1.19.2'], - versionedRegistryAccess: 'v1.19.2_sponge' + minecraft : '1.19.2', + mappings : '1.19.2+build.28', + fabric : '0.15.0', + fabricApi : '0.77.0+1.19.2', + supportedVersions: ['1.19.2'] ], '1.19.3': [ - minecraft: '1.19.3', - mappings : '1.19.3+build.5', - fabric : '0.15.0', - fabricApi: '0.76.1+1.19.3', - supportedVersions: ['1.19.3'], - versionedRegistryAccess: 'v1.19.3_sponge' + minecraft : '1.19.3', + mappings : '1.19.3+build.5', + fabric : '0.15.0', + fabricApi : '0.76.1+1.19.3', + supportedVersions: ['1.19.3'] ] ] -var minecraftVersion = '1.19.1'; +var minecraftVersion = '1.19'; var minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] +sourceSets { + main { + java { + srcDirs = [ + 'src/main/java', + "src/registry/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/registry'), minecraftVersion)}", + "src/message/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/message'), minecraftVersion)}" + ] + } + } +} + dependencies { // Minecraft and fabric minecraft "com.mojang:minecraft:${minecraftVersionDefinition['minecraft']}" - //mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" - // It is necessary to use officialMojangMappings, since it (as least) looks like - // sponge is doing the same in the respective submodules - // In the case it should be possible to go back to sourceSets, this should not be - // needed anymore - mappings loom.officialMojangMappings() + mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" modImplementation "net.fabricmc:fabric-loader:${minecraftVersionDefinition['fabric']}" modImplementation "net.fabricmc.fabric-api:fabric-api:${minecraftVersionDefinition['fabricApi']}" - // Versioned subprojects - implementation(include(project(path: ":${minecraftVersionDefinition['versionedRegistryAccess']}"))) - // Owo config modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) diff --git a/common/src/main/java/de/michiruf/serverportals/Command.java b/common/src/main/java/de/michiruf/serverportals/Command.java index e26fa6a..77244c3 100644 --- a/common/src/main/java/de/michiruf/serverportals/Command.java +++ b/common/src/main/java/de/michiruf/serverportals/Command.java @@ -5,19 +5,16 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.tree.LiteralCommandNode; import de.michiruf.serverportals.config.PortalRegistrationData; -import de.michiruf.serverportals.versioned.VersionedRegistryAccess; +import de.michiruf.serverportals.versioned.VersionedMessageSender; +import de.michiruf.serverportals.versioned.VersionedRegistry; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.command.argument.ColorArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; import java.util.stream.Collectors; /** @@ -40,9 +37,9 @@ public static void registerCommands(CommandDispatcher dispa .literal("serverportals") .requires(cmd -> cmd.hasPermissionLevel(4)) .executes(context -> { - context.getSource().sendMessage(Text.literal("Usage: /serverportals list")); - context.getSource().sendMessage(Text.literal("Usage: /serverportals register name frameBlock lightWith color command")); - context.getSource().sendMessage(Text.literal("Usage: /serverportals unregister name")); + VersionedMessageSender.send(context, "Usage: /serverportals list"); + VersionedMessageSender.send(context, "Usage: /serverportals register name frameBlock lightWith color command"); + VersionedMessageSender.send(context, "Usage: /serverportals unregister name"); return 1; }) .build(); @@ -65,9 +62,9 @@ private static int executeListCommand(CommandContext contex .map(PortalRegistrationData::toString) .collect(Collectors.joining("\n")) : ""; - if (listString.length() == 0) + if (listString.isEmpty()) listString = "None"; - context.getSource().sendMessage(Text.literal(listString)); + VersionedMessageSender.send(context, listString); return 0; } @@ -75,7 +72,7 @@ private static void registerRegisterCommand(LiteralCommandNode { - context.getSource().sendMessage(Text.literal("Invalid usage. See /serverportals")); + VersionedMessageSender.send(context, "Invalid usage. See /serverportals"); return 1; }) .then(CommandManager.argument("index", StringArgumentType.word()) @@ -111,14 +108,14 @@ private static int executeRegisterCommand(CommandContext co .toList(); if (registeredIndexes.contains(index)) { ServerPortalsMod.LOGGER.error("Portal with index {} is already registered. Unregister it first", index); - context.getSource().sendMessage(Text.literal("Portal with index " + index + " is already registered. Unregister it first")); + VersionedMessageSender.send(context, "Portal with index " + index + " is already registered. Unregister it first"); return 2; } var portal = new PortalRegistrationData( index, - VersionedRegistryAccess.block().getId(frameBlock.getBlockState().getBlock()).toString(), - VersionedRegistryAccess.item().getId(lightWith.getItem()).toString(), + VersionedRegistry.block().getId(frameBlock.getBlockState().getBlock()).toString(), + VersionedRegistry.item().getId(lightWith.getItem()).toString(), color.getColorValue() != null ? color.getColorValue() : 0, command); // Save must be trigger manually here, because it is a list and cannot observe changes (even when calling @@ -127,7 +124,7 @@ private static int executeRegisterCommand(CommandContext co ServerPortalsMod.CONFIG.save(); ServerPortalsMod.LOGGER.error("Registered portal {}", portal); - context.getSource().sendMessage(Text.literal("Registered portal " + portal)); + VersionedMessageSender.send(context, "Registered portal " + portal); printRestartInfo(context); return 0; @@ -137,7 +134,7 @@ private static void registerUnregisterCommand(LiteralCommandNode { - context.getSource().sendMessage(Text.literal("Invalid usage. See /serverportals")); + VersionedMessageSender.send(context, "Invalid usage. See /serverportals"); return 1; }) .then(CommandManager.argument("index", StringArgumentType.word()) @@ -152,7 +149,7 @@ private static int executeUnregisterCommand(CommandContext // Cancel if not list exists if (ServerPortalsMod.CONFIG.portals() == null) { ServerPortalsMod.LOGGER.error("Portal list does not exist"); - context.getSource().sendMessage(Text.literal("Portal list does not exist")); + VersionedMessageSender.send(context, "Portal list does not exist"); return 2; } @@ -165,7 +162,7 @@ private static int executeUnregisterCommand(CommandContext if (index.equals(portal.index())) { contained = ServerPortalsMod.CONFIG.portals().remove(portal); ServerPortalsMod.LOGGER.error("Unregistered portal {}", portal); - context.getSource().sendMessage(Text.literal("Unregistered portal " + portal)); + VersionedMessageSender.send(context, "Unregistered portal " + portal); } } } while (contained); @@ -180,6 +177,6 @@ private static int executeUnregisterCommand(CommandContext private static void printRestartInfo(CommandContext context) { ServerPortalsMod.LOGGER.info("For this configuration to take effect, restart the server"); - context.getSource().sendMessage(Text.literal("For this configuration to take effect, restart the server")); + VersionedMessageSender.send(context, "For this configuration to take effect, restart the server"); } } diff --git a/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java index f4b50d5..3f13921 100644 --- a/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java +++ b/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java @@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.kyrptonaught.customportalapi.api.CustomPortalBuilder; import net.kyrptonaught.customportalapi.util.SHOULDTP; +import net.minecraft.entity.Entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java b/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java index 69e3426..ef7e33b 100644 --- a/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java +++ b/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java @@ -1,11 +1,9 @@ package de.michiruf.serverportals.config; +import de.michiruf.serverportals.versioned.VersionedRegistry; import net.minecraft.block.Block; import net.minecraft.item.Item; -import de.michiruf.serverportals.versioned.VersionedRegistryAccess; -import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Identifier; -import net.minecraft.world.level.block.Block; /** * @author Michael Ruf @@ -38,12 +36,11 @@ public PortalRegistrationData( } public Block frameBlock() { - return VersionedRegistryAccess.block().get(new ResourceLocation(frameBlockId)); - return VersionedRegistryAccess.block().get(new Identifier(frameBlockId)); + return VersionedRegistry.block().get(new Identifier(frameBlockId)); } public Item lightWithItem() { - return VersionedRegistryAccess.item().get(new Identifier(lightWithItemId)); + return VersionedRegistry.item().get(new Identifier(lightWithItemId)); } public String index() { diff --git a/common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java b/common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java new file mode 100644 index 0000000..fc21337 --- /dev/null +++ b/common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java @@ -0,0 +1,16 @@ +package de.michiruf.serverportals.versioned; + +import com.mojang.brigadier.context.CommandContext; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.Text; + +/** + * @author Michael Ruf + * @since 2023-12-13 + */ +public class VersionedMessageSender { + + public static void send(CommandContext context, String text) { + context.getSource().sendMessage(Text.literal(text)); + } +} diff --git a/common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java b/common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java new file mode 100644 index 0000000..b05b193 --- /dev/null +++ b/common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java @@ -0,0 +1,23 @@ +package de.michiruf.serverportals.versioned; + +import com.mojang.brigadier.context.CommandContext; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.Text; + +/** + * @author Michael Ruf + * @since 2023-12-13 + */ +public class VersionedMessageSender { + + public static void send(CommandContext context, String text) { + var source = context.getSource(); + var serverPlayerEntity = source.getPlayer(); + if (serverPlayerEntity != null) { + serverPlayerEntity.sendMessage(Text.literal(text)); + } else { + // MRU: I am not entirely sure, if sendFeedback or sendError should be the option to go here + source.sendFeedback(Text.literal(text), false); + } + } +} diff --git a/common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java b/common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java new file mode 100644 index 0000000..33b0129 --- /dev/null +++ b/common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java @@ -0,0 +1,21 @@ +package de.michiruf.serverportals.versioned; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; + +/** + * @author Michael Ruf + * @since 2023-01-18 + */ +public class VersionedRegistry { + + public static Registry block() { + return Registries.BLOCK; + } + + public static Registry item() { + return Registries.ITEM; + } +} diff --git a/v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java similarity index 62% rename from v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java rename to common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java index f411aeb..8b91dd7 100644 --- a/v1.19.0_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ b/common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java @@ -1,14 +1,14 @@ package de.michiruf.serverportals.versioned; -import net.minecraft.core.Registry; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.util.registry.Registry; /** * @author Michael Ruf * @since 2023-01-18 */ -public class VersionedRegistryAccess { +public class VersionedRegistry { public static Registry block() { return Registry.BLOCK; diff --git a/settings.gradle b/settings.gradle index 98b9561..8218cf5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,8 +18,3 @@ pluginManagement { rootProject.name = 'server-portals' include 'common' -//include 'v1.19.3' -include 'v1.19.0_sponge' -include 'v1.19.1_sponge' -include 'v1.19.2_sponge' -include 'v1.19.3_sponge' diff --git a/v1.19.0_sponge/build.gradle b/v1.19.0_sponge/build.gradle deleted file mode 100644 index 4a95e3b..0000000 --- a/v1.19.0_sponge/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'java-library' - id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' -} - -minecraft { - version('1.19') - platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) - runs { - server() - //client() - } -} - -dependencies { -} diff --git a/v1.19.1_sponge/build.gradle b/v1.19.1_sponge/build.gradle deleted file mode 100644 index 7818af8..0000000 --- a/v1.19.1_sponge/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'java-library' - id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' -} - -minecraft { - version('1.19.1') - platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) - runs { - server() - //client() - } -} - -dependencies { -} diff --git a/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index f411aeb..0000000 --- a/v1.19.1_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.core.Registry; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static Registry block() { - return Registry.BLOCK; - } - - public static Registry item() { - return Registry.ITEM; - } -} \ No newline at end of file diff --git a/v1.19.2_sponge/build.gradle b/v1.19.2_sponge/build.gradle deleted file mode 100644 index a4832e3..0000000 --- a/v1.19.2_sponge/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'java-library' - id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' -} - -minecraft { - version('1.19.2') - platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) - runs { - server() - //client() - } -} - -dependencies { -} diff --git a/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index b2b442a..0000000 --- a/v1.19.2_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.core.DefaultedRegistry; -import net.minecraft.core.Registry; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static Registry block() { - return Registry.BLOCK; - } - - public static Registry item() { - return Registry.ITEM; - } -} diff --git a/v1.19.3/build.gradle b/v1.19.3/build.gradle deleted file mode 100644 index b921851..0000000 --- a/v1.19.3/build.gradle +++ /dev/null @@ -1,106 +0,0 @@ -plugins { - id 'java' - // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'com.modrinth.minotaur' version '2.+' -} - -repositories { - mavenCentral() - maven { url 'https://maven.wispforest.io' } // Owo config - maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -configurations { - // TODO Try to use those in the common module - sharedMinecraft { - canBeResolved = false - assert canBeConsumed - extendsFrom minecraft - } - sharedMappings { - canBeResolved = false - assert canBeConsumed - extendsFrom mappings - } -} - -ext { - minecraft = '1.19.3' - mappings = '1.19.3+build.5' - fabricLoader = '0.14.9' - fabricApi = '0.72.0+1.19.3' -} - -dependencies { - minecraft "com.mojang:minecraft:${project.minecraft}" - mappings "net.fabricmc:yarn:${project.mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.fabricLoader}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabricApi}" - - // Owo config - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) -} - -loom { - interfaceInjection { - enableDependencyInterfaceInjection = true - } -} - -modrinth { - projectId = 'server-portals' - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = ['1.19'] // ['1.19.2'] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - -processResources { - inputs.property 'version', project.version - filteringCharset 'UTF-8' - - filesMatching('fabric.mod.json') { - expand 'version': project.version - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} diff --git a/v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index 20ef4b3..0000000 --- a/v1.19.3/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.block.Block; -import net.minecraft.registry.DefaultedRegistry; -import net.minecraft.registry.Registries; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static DefaultedRegistry blocks() { - return Registries.BLOCK; - } -} diff --git a/v1.19.3/src/main/resources/fabric.mod.json b/v1.19.3/src/main/resources/fabric.mod.json deleted file mode 100644 index 430b979..0000000 --- a/v1.19.3/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "schemaVersion": 1, - "id": "server-portals", - "version": "${version}", - "name": "ServerPortals", - "description": "", - "authors": [ - "michiruf" - ], - "contact": { - "website": "https://github.com/michiruf" - }, - "license": "MIT", - "icon": "assets/serverportals/icon.png", - "environment": "*", - "entrypoints": { - "server": [ - "de.michiruf.serverportals.ServerPortalsMod" - ], - "client": [ - "de.michiruf.serverportals.ServerPortalsMod" - ] - }, - "mixins": [], - "depends": { - "fabricloader": ">=0.12.12", - "fabric": "*", - "minecraft": ">=1.19", - "owo-lib": ">=0.8.5" - } -} diff --git a/v1.19.3_sponge/build.gradle b/v1.19.3_sponge/build.gradle deleted file mode 100644 index 472b2db..0000000 --- a/v1.19.3_sponge/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'java-library' - id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' -} - -minecraft { - version('1.19.3') - platform(org.spongepowered.gradle.vanilla.repository.MinecraftPlatform.SERVER) - runs { - server() - //client() - } -} - -dependencies { -} diff --git a/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java b/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java deleted file mode 100644 index 46f56eb..0000000 --- a/v1.19.3_sponge/src/main/java/de/michiruf/serverportals/versioned/VersionedRegistryAccess.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.michiruf.serverportals.versioned; - -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; - -/** - * @author Michael Ruf - * @since 2023-01-18 - */ -public class VersionedRegistryAccess { - - public static Registry block() { - return BuiltInRegistries.BLOCK; - } - - public static Registry item() { - return BuiltInRegistries.ITEM; - } -} From 4853bc6d333545ff7a02e7498e0bca25e2877735 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Wed, 13 Dec 2023 01:30:42 +0100 Subject: [PATCH 07/10] Flatten modules --- build.gradle | 147 +++++++++++++++++- common/build.gradle | 133 ---------------- settings.gradle | 1 - .../de/michiruf/serverportals/Command.java | 0 .../serverportals/ServerPortalsMod.java | 0 .../serverportals/config/ConfigModel.java | 0 .../config/PortalRegistrationData.java | 0 .../main/resources/fabric.mod.json | 4 +- .../versioned/VersionedMessageSender.java | 0 .../versioned/VersionedMessageSender.java | 0 .../versioned/VersionedRegistry.java | 0 .../versioned/VersionedRegistry.java | 0 12 files changed, 143 insertions(+), 142 deletions(-) delete mode 100644 common/build.gradle rename {common/src => src}/main/java/de/michiruf/serverportals/Command.java (100%) rename {common/src => src}/main/java/de/michiruf/serverportals/ServerPortalsMod.java (100%) rename {common/src => src}/main/java/de/michiruf/serverportals/config/ConfigModel.java (100%) rename {common/src => src}/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java (100%) rename {common/src => src}/main/resources/fabric.mod.json (88%) rename {common/src => src}/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java (100%) rename {common/src => src}/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java (100%) rename {common/src => src}/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java (100%) rename {common/src => src}/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java (100%) diff --git a/build.gradle b/build.gradle index 446ef58..9f2eb57 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,12 @@ +import de.michiruf.gradle.findversion.FindVersion + +plugins { + id 'java' + // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'com.modrinth.minotaur' version '2.+' +} + allprojects { // This can get extracted into a root build.gradle if needed ext { @@ -31,10 +40,136 @@ allprojects { project.version = '0' } project.group = 'michiruf' - // TODO - //project.archivesBaseName = 'server-portals' - // Inside project: -// base { -// archivesName = "${rootProject.name}-common-${minecraft_version}" -// } +} + +repositories { + mavenCentral() + maven { url 'https://maven.wispforest.io' } // Owo config + maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive +} + +// Check minecraft, mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html +def minecraftVersionDefinitions = [ + '1.19' : [ + minecraft : '1.19', + mappings : '1.19+build.4', + fabric : '0.12.12', // TODO Check this up again? + fabricApi : '0.58.0+1.19', + supportedVersions: ['1.19'] + ], + '1.19.1': [ + minecraft : '1.19.1', + mappings : '1.19.1+build.6', + fabric : '0.15.0', + fabricApi : '0.58.5+1.19.1', + supportedVersions: ['1.19.1'] + ], + '1.19.2': [ + minecraft : '1.19.2', + mappings : '1.19.2+build.28', + fabric : '0.15.0', + fabricApi : '0.77.0+1.19.2', + supportedVersions: ['1.19.2'] + ], + '1.19.3': [ + minecraft : '1.19.3', + mappings : '1.19.3+build.5', + fabric : '0.15.0', + fabricApi : '0.76.1+1.19.3', + supportedVersions: ['1.19.3'] + ] +] +var minecraftVersion = '1.19'; +var minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] + +sourceSets { + main { + java { + srcDirs = [ + 'src/main/java', + "src/registry/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/registry'), minecraftVersion)}", + "src/message/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/message'), minecraftVersion)}" + ] + } + } +} + +dependencies { + // Minecraft and fabric + minecraft "com.mojang:minecraft:${minecraftVersionDefinition['minecraft']}" + mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" + modImplementation "net.fabricmc:fabric-loader:${minecraftVersionDefinition['fabric']}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${minecraftVersionDefinition['fabricApi']}" + + // Owo config + // TODO Could we also include that? + modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) + // Custom portal api + modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) + modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) + modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) +} + +loom { + interfaceInjection { + enableDependencyInterfaceInjection = true + } +} + +modrinth { + projectId = rootProject.name + versionNumber = project.version + versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' + gameVersions = minecraftVersionDefinition['supportedVersions'] + loaders = ['fabric'] + dependencies { + required.project 'fabric-api' + required.project 'owo-lib' + } + uploadFile = remapJar + syncBodyFrom = rootProject.file("README.md").text + + // Use the environment variable `$MODRINTH_TOKEN` for the token + // token = 'mySecretToken' +} +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +processResources { + var replaceProperties = [ + version : project.version, + minecraft: minecraftVersionDefinition['minecraft'], + mappings : minecraftVersionDefinition['mappings'], + fabric : minecraftVersionDefinition['fabric'], + fabricApi: minecraftVersionDefinition['fabricApi'] + ] + inputs.properties replaceProperties + filteringCharset 'UTF-8' + filesMatching('fabric.mod.json') { + expand replaceProperties + } +} + +def targetJavaVersion = 17 +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + it.options.release = targetJavaVersion + } +} + +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index 79b4047..0000000 --- a/common/build.gradle +++ /dev/null @@ -1,133 +0,0 @@ -import de.michiruf.gradle.findversion.FindVersion - -plugins { - id 'java' - // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'com.modrinth.minotaur' version '2.+' -} - -repositories { - mavenCentral() - maven { url 'https://maven.wispforest.io' } // Owo config - maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -// Check minecraft, mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html -def minecraftVersionDefinitions = [ - '1.19': [ - minecraft : '1.19', - mappings : '1.19+build.4', - fabric : '0.15.0', - fabricApi : '0.58.0+1.19', - supportedVersions: ['1.19'] - ], - '1.19.1': [ - minecraft : '1.19.1', - mappings : '1.19.1+build.6', - fabric : '0.15.0', - fabricApi : '0.58.5+1.19.1', - supportedVersions: ['1.19.1'] - ], - '1.19.2': [ - minecraft : '1.19.2', - mappings : '1.19.2+build.28', - fabric : '0.15.0', - fabricApi : '0.77.0+1.19.2', - supportedVersions: ['1.19.2'] - ], - '1.19.3': [ - minecraft : '1.19.3', - mappings : '1.19.3+build.5', - fabric : '0.15.0', - fabricApi : '0.76.1+1.19.3', - supportedVersions: ['1.19.3'] - ] -] -var minecraftVersion = '1.19'; -var minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] - -sourceSets { - main { - java { - srcDirs = [ - 'src/main/java', - "src/registry/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/registry'), minecraftVersion)}", - "src/message/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/message'), minecraftVersion)}" - ] - } - } -} - -dependencies { - // Minecraft and fabric - minecraft "com.mojang:minecraft:${minecraftVersionDefinition['minecraft']}" - mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" - modImplementation "net.fabricmc:fabric-loader:${minecraftVersionDefinition['fabric']}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${minecraftVersionDefinition['fabricApi']}" - - // Owo config - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) -} - -loom { - interfaceInjection { - enableDependencyInterfaceInjection = true - } -} - -modrinth { - projectId = rootProject.name - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = minecraftVersionDefinition['supportedVersions'] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - -processResources { - inputs.property 'version', project.version - filteringCharset 'UTF-8' - - filesMatching('fabric.mod.json') { - expand 'version': project.version - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} diff --git a/settings.gradle b/settings.gradle index 8218cf5..5be140b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,4 +17,3 @@ pluginManagement { } rootProject.name = 'server-portals' -include 'common' diff --git a/common/src/main/java/de/michiruf/serverportals/Command.java b/src/main/java/de/michiruf/serverportals/Command.java similarity index 100% rename from common/src/main/java/de/michiruf/serverportals/Command.java rename to src/main/java/de/michiruf/serverportals/Command.java diff --git a/common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java b/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java similarity index 100% rename from common/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java rename to src/main/java/de/michiruf/serverportals/ServerPortalsMod.java diff --git a/common/src/main/java/de/michiruf/serverportals/config/ConfigModel.java b/src/main/java/de/michiruf/serverportals/config/ConfigModel.java similarity index 100% rename from common/src/main/java/de/michiruf/serverportals/config/ConfigModel.java rename to src/main/java/de/michiruf/serverportals/config/ConfigModel.java diff --git a/common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java b/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java similarity index 100% rename from common/src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java rename to src/main/java/de/michiruf/serverportals/config/PortalRegistrationData.java diff --git a/common/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json similarity index 88% rename from common/src/main/resources/fabric.mod.json rename to src/main/resources/fabric.mod.json index 430b979..73e806a 100644 --- a/common/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,9 +23,9 @@ }, "mixins": [], "depends": { - "fabricloader": ">=0.12.12", + "minecraft": ">=${minecraft}", + "fabricloader": ">=${fabric}", "fabric": "*", - "minecraft": ">=1.19", "owo-lib": ">=0.8.5" } } diff --git a/common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java b/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java similarity index 100% rename from common/src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java rename to src/message/1.19.1/de/michiruf/serverportals/versioned/VersionedMessageSender.java diff --git a/common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java b/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java similarity index 100% rename from common/src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java rename to src/message/1.19/de/michiruf/serverportals/versioned/VersionedMessageSender.java diff --git a/common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java b/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java similarity index 100% rename from common/src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java rename to src/registry/1.19.3/de/michiruf/serverportals/versioned/VersionedRegistry.java diff --git a/common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java b/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java similarity index 100% rename from common/src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java rename to src/registry/1.19/de/michiruf/serverportals/versioned/VersionedRegistry.java From 673d1ba9388c5a5533e9189988198ea13df81bdf Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Wed, 13 Dec 2023 13:14:32 +0100 Subject: [PATCH 08/10] Building for 1.19 - 1.20.2 finally works now --- .github/workflows/build.yml | 66 ++++++++- CHANGELOG.md | 2 +- README.md | 5 +- build.allprojects.gradle | 34 +++++ build.gradle | 125 ++++-------------- build.versions.gradle | 82 ++++++++++++ .../mixin/VirtualPortalBlock.java | 52 ++++++++ .../mixin/VirtualPortalBlock.java | 51 +++++++ .../serverportals/ServerPortalsMod.java | 4 + .../customportalapi-polymer.mixins.json | 11 ++ src/main/resources/fabric.mod.json | 7 +- 11 files changed, 335 insertions(+), 104 deletions(-) create mode 100644 build.allprojects.gradle create mode 100644 build.versions.gradle create mode 100644 src/customportalapi-polymer/1.19.3/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java create mode 100644 src/customportalapi-polymer/1.19/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java create mode 100644 src/main/resources/customportalapi-polymer.mixins.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 543b0bb..9af0b64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,11 +36,39 @@ jobs: if: success() uses: gradle/gradle-build-action@v2 with: - gradle-version: 7.4.2 + gradle-version: 8.3 - - name: Build + - name: Build v1.19 if: success() - run: gradle remapJar + run: gradle remapJar -Pv=1.19 + + - name: Build v1.19.1 + if: success() + run: gradle remapJar -Pv=1.19.1 + + - name: Build v1.19.2 + if: success() + run: gradle remapJar -Pv=1.19.2 + + - name: Build v1.19.3 + if: success() + run: gradle remapJar -Pv=1.19.3 + + - name: Build v1.19.4 + if: success() + run: gradle remapJar -Pv=1.19.4 + + - name: Build v1.20 + if: success() + run: gradle remapJar -Pv=1.20 + + - name: Build v1.20.1 + if: success() + run: gradle remapJar -Pv=1.20.1 + + - name: Build v1.20.2 + if: success() + run: gradle remapJar -Pv=1.20.2 - name: Release on GitHub if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check again @@ -56,6 +84,34 @@ jobs: prerelease: false fail_on_unmatched_files: true - - name: Upload to modrinth + - name: Upload to modrinth v1.19 + if: success() + run: gradle modrinth -Pv=1.19 + + - name: Upload to modrinth v1.19.1 + if: success() + run: gradle modrinth -Pv=1.19.1 + + - name: Upload to modrinth v1.19.2 + if: success() + run: gradle modrinth -Pv=1.19.2 + + - name: Upload to modrinth v1.19.3 + if: success() + run: gradle modrinth -Pv=1.19.3 + + - name: Upload to modrinth v1.19.4 + if: success() + run: gradle modrinth -Pv=1.19.4 + + - name: Upload to modrinth v1.20 + if: success() + run: gradle modrinth -Pv=1.20 + + - name: Upload to modrinth v1.20.1 + if: success() + run: gradle modrinth -Pv=1.20.1 + + - name: Upload to modrinth v1.20.2 if: success() - run: gradle modrinth + run: gradle modrinth -Pv=1.20.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce0ee1..b04f7cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -Add other versions of minecraft 1.19 +Support for MC 1.19 - 1.20.2 \ No newline at end of file diff --git a/README.md b/README.md index 83ba003..45fff74 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,10 @@ because of that with [Polymer](https://polymer.pb4.eu/). ## Usage instructions -**NOTE: The server must get restarted to load these changes!** + +NOTE: The server must get restarted to load these changes!
+So after every change of the portals, restart the server (unfortunately)! +
--- List configured portals: diff --git a/build.allprojects.gradle b/build.allprojects.gradle new file mode 100644 index 0000000..8c8c275 --- /dev/null +++ b/build.allprojects.gradle @@ -0,0 +1,34 @@ +allprojects { + // This can get extracted into a root build.gradle if needed + ext { + getLatestTag = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["describe", "--tags", "--abbrev=0"] + standardOutput = os + } + return os.toString().trim() + } + } + + getCurrentCommitCount = { + new ByteArrayOutputStream().withStream { os -> + exec { + executable = "git" + args = ["rev-list", "--all", "--count"] + standardOutput = os + } + return os.toString().trim() + } + } + } + + try { + project.version = "${project.getLatestTag()}.${project.getCurrentCommitCount()}" + } catch (Exception ignored) { + println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') + project.version = '0' + } + project.group = 'michiruf' +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9f2eb57..e7ff9f3 100644 --- a/build.gradle +++ b/build.gradle @@ -2,133 +2,66 @@ import de.michiruf.gradle.findversion.FindVersion plugins { id 'java' - // Unfortunately, in higher versions of fabric-loom, multiple submodules do not work - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'com.modrinth.minotaur' version '2.+' } -allprojects { - // This can get extracted into a root build.gradle if needed - ext { - getLatestTag = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["describe", "--tags", "--abbrev=0"] - standardOutput = os - } - return os.toString().trim() - } - } +apply from: 'build.allprojects.gradle' +apply from: 'build.versions.gradle' - getCurrentCommitCount = { - new ByteArrayOutputStream().withStream { os -> - exec { - executable = "git" - args = ["rev-list", "--all", "--count"] - standardOutput = os - } - return os.toString().trim() - } - } - } +def minecraftVersion = project.minecraftVersion as String ?: '1.20.2' +def minecraftVersionDefinitions = ext.minecraftVersionDefinitions +def minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] +project.version = "${project.version}+${minecraftVersion}" - try { - project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}" - } catch (Exception ignored) { - println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') - project.version = '0' - } - project.group = 'michiruf' +sourceSets { + main.java.srcDirs = [ + 'src/main/java', + "src/registry/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/registry'), minecraftVersion)}", + "src/message/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/message'), minecraftVersion)}", + "src/customportalapi-polymer/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/customportalapi-polymer'), minecraftVersion)}" + ] } repositories { mavenCentral() maven { url 'https://maven.wispforest.io' } // Owo config maven { url 'https://maven.kyrptonaught.dev' } // Custom portal api - maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive -} - -// Check minecraft, mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html -def minecraftVersionDefinitions = [ - '1.19' : [ - minecraft : '1.19', - mappings : '1.19+build.4', - fabric : '0.12.12', // TODO Check this up again? - fabricApi : '0.58.0+1.19', - supportedVersions: ['1.19'] - ], - '1.19.1': [ - minecraft : '1.19.1', - mappings : '1.19.1+build.6', - fabric : '0.15.0', - fabricApi : '0.58.5+1.19.1', - supportedVersions: ['1.19.1'] - ], - '1.19.2': [ - minecraft : '1.19.2', - mappings : '1.19.2+build.28', - fabric : '0.15.0', - fabricApi : '0.77.0+1.19.2', - supportedVersions: ['1.19.2'] - ], - '1.19.3': [ - minecraft : '1.19.3', - mappings : '1.19.3+build.5', - fabric : '0.15.0', - fabricApi : '0.76.1+1.19.3', - supportedVersions: ['1.19.3'] - ] -] -var minecraftVersion = '1.19'; -var minecraftVersionDefinition = minecraftVersionDefinitions[minecraftVersion] - -sourceSets { - main { - java { - srcDirs = [ - 'src/main/java', - "src/registry/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/registry'), minecraftVersion)}", - "src/message/${FindVersion.findClosestLowerOrEqualVersionInDirectory(file('src/message'), minecraftVersion)}" - ] - } - } + maven { url 'https://maven.nucleoid.xyz' } // Custom portal api transitive (polymer) + maven { url 'https://api.modrinth.com/maven' } // Custom portal api transitive (sodium) } dependencies { // Minecraft and fabric - minecraft "com.mojang:minecraft:${minecraftVersionDefinition['minecraft']}" + minecraft "com.mojang:minecraft:${minecraftVersion}" mappings "net.fabricmc:yarn:${minecraftVersionDefinition['mappings']}:v2" modImplementation "net.fabricmc:fabric-loader:${minecraftVersionDefinition['fabric']}" modImplementation "net.fabricmc.fabric-api:fabric-api:${minecraftVersionDefinition['fabricApi']}" // Owo config - // TODO Could we also include that? - modImplementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - implementation(annotationProcessor('io.wispforest:owo-lib:0.9.3+1.19')) - // Custom portal api - modImplementation(include('net.kyrptonaught:customportalapi:0.0.1-beta54-1.19')) - modImplementation(include('net.kyrptonaught:cpa-polymer:1.0.0-1.19')) - modImplementation(include('eu.pb4:polymer:0.2.18+1.19.2')) -} + modImplementation annotationProcessor("io.wispforest:owo-lib:${minecraftVersionDefinition['owo']}") { exclude group: 'net.fabricmc.fabric-api' } + // We could include owo-sentinel for auto download, see https://github.com/wisp-forest/owo-lib -loom { - interfaceInjection { - enableDependencyInterfaceInjection = true - } + // Custom portal api + modImplementation include("net.kyrptonaught:customportalapi:${minecraftVersionDefinition['customportalapi']}") { exclude group: 'net.fabricmc.fabric-api' } + modImplementation include("eu.pb4:${minecraftVersionDefinition['polymer']}") { exclude group: 'net.fabricmc.fabric-api' } } +def buildJarFile = file("build/libs/${rootProject.name}-${project.version}.jar") modrinth { projectId = rootProject.name versionNumber = project.version versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = minecraftVersionDefinition['supportedVersions'] + gameVersions = [minecraftVersion] loaders = ['fabric'] dependencies { required.project 'fabric-api' required.project 'owo-lib' } - uploadFile = remapJar + if(buildJarFile.exists()) + uploadFile = buildJarFile; + else + uploadFile = remapJar syncBodyFrom = rootProject.file("README.md").text // Use the environment variable `$MODRINTH_TOKEN` for the token @@ -139,7 +72,7 @@ tasks.modrinth.dependsOn(tasks.modrinthSyncBody) processResources { var replaceProperties = [ version : project.version, - minecraft: minecraftVersionDefinition['minecraft'], + minecraft: minecraftVersion, mappings : minecraftVersionDefinition['mappings'], fabric : minecraftVersionDefinition['fabric'], fabricApi: minecraftVersionDefinition['fabricApi'] diff --git a/build.versions.gradle b/build.versions.gradle new file mode 100644 index 0000000..4098678 --- /dev/null +++ b/build.versions.gradle @@ -0,0 +1,82 @@ +// Check mappings, fabric and fabricApi on: https://modmuss50.me/fabric.html +// Check owo on: https://maven.wispforest.io/io/wispforest/owo-lib/0.11.2%2B1.20/ +// Check customportalapi on: https://maven.kyrptonaught.dev/ +// Check polymer-core on: https://maven.nucleoid.xyz/eu/pb4/polymer-core/ +ext.minecraftVersionDefinitions = [ + '1.19' : [ + mappings : '1.19+build.4', + fabric : '0.12.12', // TODO Check this up again? + fabricApi : '0.58.0+1.19', + owo : '0.9.3+1.19', + customportalapi: '0.0.1-beta54-1.19', // Does not work: '0.0.1-beta62-1.19' AND '0.0.1-beta63.5-1.19.X' + polymer : 'polymer:0.2.10+1.19' + ], + '1.19.1': [ + mappings : '1.19.1+build.6', + fabric : '0.15.0', + fabricApi : '0.58.5+1.19.1', + owo : '0.9.3+1.19', + customportalapi: '0.0.1-beta54-1.19', // Does not work: '0.0.1-beta62-1.19' AND '0.0.1-beta63.5-1.19.X' + polymer : 'polymer:0.2.10+1.19.1' + ], + '1.19.2': [ + mappings : '1.19.2+build.28', + fabric : '0.15.0', + fabricApi : '0.77.0+1.19.2', + owo : '0.9.3+1.19', + customportalapi: '0.0.1-beta54-1.19', // Does not work: '0.0.1-beta62-1.19' AND '0.0.1-beta63.5-1.19.X' + polymer : 'polymer:0.2.28+1.19.2' + ], + '1.19.3': [ + mappings : '1.19.3+build.5', + fabric : '0.15.0', + fabricApi : '0.76.1+1.19.3', + owo : '0.9.3+1.19.3', + customportalapi: '0.0.1-beta63-1.19.3', + polymer : 'polymer-core:0.3.0+1.19.3' + ], + '1.19.4': [ + mappings : '1.19.4+build.2', + fabric : '0.15.1', + fabricApi : '0.87.2+1.19.4', + owo : '0.10.6+1.19.4', // Theres also 0.11.0 for MC 1.19.4 + customportalapi: '0.0.1-beta63-1.19.4', + polymer : 'polymer-core:0.4.11+1.19.4' + ], + '1.20' : [ + mappings : '1.20+build.1', + fabric : '0.15.1', + fabricApi : '0.83.0+1.20', + owo : '0.11.2+1.20', + customportalapi: '0.0.1-beta64-1.20', // beta63 also available + polymer : 'polymer-core:0.5.0+1.20' + ], + '1.20.1': [ + mappings : '1.20.1+build.10', + fabric : '0.15.1', + fabricApi : '0.91.0+1.20.1', + owo : '0.11.2+1.20', // No 1.20.1 artifact + customportalapi: '0.0.1-beta64-1.20', // No 1.20.1 artifact + polymer : 'polymer-core:0.5.18+1.20.1' + ], + '1.20.2': [ + mappings : '1.20.2+build.4', + fabric : '0.15.1', + fabricApi : '0.89.3+1.20.2', // Newest is '0.91.2+1.20.2', but customportalapi needs older + owo : '0.11.4+1.20.2', + customportalapi: '0.0.1-beta64-1.20.2', + polymer : 'polymer-core:0.6.3+1.20.2' + ] + // NOTE There is no customportalapi after 1.20.2 and since this one needs an older fabric api, + // it is probably not worth continuing to newer versions +] + +// Predefine as null to retrieve without checks in build.gradle +ext.minecraftVersion = null + +if (project.hasProperty('v')) + ext.minecraftVersion = project.property('v') + +def minecraftVersionEnv = System.getenv('minecraft_version') ?: "" +if (!minecraftVersionEnv.isEmpty()) + ext.minecraftVersion = minecraftVersionEnv diff --git a/src/customportalapi-polymer/1.19.3/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java b/src/customportalapi-polymer/1.19.3/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java new file mode 100644 index 0000000..b72a09f --- /dev/null +++ b/src/customportalapi-polymer/1.19.3/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java @@ -0,0 +1,52 @@ +package net.kyrptonaught.servercustomportals.mixin; + +import eu.pb4.polymer.core.api.block.PolymerBlock; +import eu.pb4.polymer.core.api.block.PolymerBlockUtils; +import net.kyrptonaught.customportalapi.CustomPortalBlock; +import net.kyrptonaught.customportalapi.networking.ForcePlacePortalPacket; +import net.kyrptonaught.customportalapi.util.CustomPortalHelper; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.NetherPortalBlock; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import org.spongepowered.asm.mixin.Mixin; + +// See https://github.com/kyrptonaught/CustomPortalApi-Polymer/blob/1.18/src/main/java/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java +// Manually edited to match polymer-core, but similar to changes on github +@Mixin(CustomPortalBlock.class) +public class VirtualPortalBlock implements PolymerBlock { + + @Override + public Block getPolymerBlock(BlockState state) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(state); + if (dir == Direction.Axis.Y) + return Blocks.END_PORTAL; + return Blocks.NETHER_PORTAL; + } + + @Override + public BlockState getPolymerBlockState(BlockState state) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(state); + if (dir == Direction.Axis.Y) + return Blocks.END_PORTAL.getDefaultState(); + + if (dir == Direction.Axis.Z) + return this.getPolymerBlock(state).getDefaultState().with(NetherPortalBlock.AXIS, Direction.Axis.Z); + + return this.getPolymerBlock(state).getDefaultState(); + } + + @Override + public void onPolymerBlockSend(BlockState blockState, BlockPos.Mutable pos, ServerPlayerEntity player) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(blockState); + if (dir == Direction.Axis.Y) { + player.networkHandler.sendPacket(PolymerBlockUtils.createBlockEntityPacket(pos, BlockEntityType.END_PORTAL, new NbtCompound())); + } + ForcePlacePortalPacket.sendForcePacket(player, pos.toImmutable(), dir); + } +} \ No newline at end of file diff --git a/src/customportalapi-polymer/1.19/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java b/src/customportalapi-polymer/1.19/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java new file mode 100644 index 0000000..20f3038 --- /dev/null +++ b/src/customportalapi-polymer/1.19/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java @@ -0,0 +1,51 @@ +package net.kyrptonaught.servercustomportals.mixin; + +import eu.pb4.polymer.api.block.PolymerBlock; +import eu.pb4.polymer.api.block.PolymerBlockUtils; +import net.kyrptonaught.customportalapi.CustomPortalBlock; +import net.kyrptonaught.customportalapi.networking.ForcePlacePortalPacket; +import net.kyrptonaught.customportalapi.util.CustomPortalHelper; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.NetherPortalBlock; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import org.spongepowered.asm.mixin.Mixin; + +// See https://github.com/kyrptonaught/CustomPortalApi-Polymer/blob/1.18/src/main/java/net/kyrptonaught/servercustomportals/mixin/VirtualPortalBlock.java +@Mixin(CustomPortalBlock.class) +public class VirtualPortalBlock implements PolymerBlock { + + @Override + public Block getPolymerBlock(BlockState state) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(state); + if (dir == Direction.Axis.Y) + return Blocks.END_PORTAL; + return Blocks.NETHER_PORTAL; + } + + @Override + public BlockState getPolymerBlockState(BlockState state) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(state); + if (dir == Direction.Axis.Y) + return Blocks.END_PORTAL.getDefaultState(); + + if (dir == Direction.Axis.Z) + return this.getPolymerBlock(state).getDefaultState().with(NetherPortalBlock.AXIS, Direction.Axis.Z); + + return this.getPolymerBlock(state).getDefaultState(); + } + + @Override + public void onPolymerBlockSend(ServerPlayerEntity player, BlockPos.Mutable pos, BlockState blockState) { + Direction.Axis dir = CustomPortalHelper.getAxisFrom(blockState); + if (dir == Direction.Axis.Y) { + player.networkHandler.sendPacket(PolymerBlockUtils.createBlockEntityPacket(pos, BlockEntityType.END_PORTAL, new NbtCompound())); + } + ForcePlacePortalPacket.sendForcePacket(player, pos.toImmutable()); + } +} \ No newline at end of file diff --git a/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java b/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java index 3f13921..ea2842b 100644 --- a/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java +++ b/src/main/java/de/michiruf/serverportals/ServerPortalsMod.java @@ -6,6 +6,7 @@ import net.kyrptonaught.customportalapi.api.CustomPortalBuilder; import net.kyrptonaught.customportalapi.util.SHOULDTP; import net.minecraft.entity.Entity; +import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +43,9 @@ private void registerPluginHooks() { private void registerPortals() { for (var portal : CONFIG.portals()) { CustomPortalBuilder.beginPortal() + // It is essential to set this id since 0.0.1-beta63-1.19.3 + // TODO May this version work now on older minecraft target versions aswell? + .destDimID(Identifier.of("serverportals", "undefined")) .frameBlock(portal.frameBlock()) .lightWithItem(portal.lightWithItem()) .tintColor(portal.color()) diff --git a/src/main/resources/customportalapi-polymer.mixins.json b/src/main/resources/customportalapi-polymer.mixins.json new file mode 100644 index 0000000..9df5506 --- /dev/null +++ b/src/main/resources/customportalapi-polymer.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "net.kyrptonaught.servercustomportals.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "VirtualPortalBlock" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 73e806a..ea1e548 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,7 +21,12 @@ "de.michiruf.serverportals.ServerPortalsMod" ] }, - "mixins": [], + "mixins": [ + { + "config": "customportalapi-polymer.mixins.json", + "environment": "server" + } + ], "depends": { "minecraft": ">=${minecraft}", "fabricloader": ">=${fabric}", From 76ae34fc53a632442e94068e269f85c8a3395569 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Wed, 13 Dec 2023 13:24:38 +0100 Subject: [PATCH 09/10] Update build script --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9af0b64..9bdf879 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,9 +15,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Check tag condition - if: startsWith(github.ref, 'refs/tags/') - run: echo "Ref is a tag" + - name: Check tag condition or manual request of build + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' + run: echo "Ref is a tag or this build was requested manually" - name: Check out project if: success() @@ -70,8 +70,12 @@ jobs: if: success() run: gradle remapJar -Pv=1.20.2 + - name: Check tag condition before release + if: success() && startsWith(github.ref, 'refs/tags/') + run: echo "Ref is a tag" + - name: Release on GitHub - if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check again + if: success() uses: softprops/action-gh-release@v1 with: files: | From e581e07b09f11d29ecb57dd83197b7dabb4775e6 Mon Sep 17 00:00:00 2001 From: Michael Ruf Date: Wed, 13 Dec 2023 13:43:59 +0100 Subject: [PATCH 10/10] Implement new gitlab workflow; remove modrith gradle plugin --- .github/workflows/build.yml | 142 +++++++++++---------- .github/workflows/remove-old-artifacts.yml | 23 ++++ build.gradle | 23 ---- 3 files changed, 99 insertions(+), 89 deletions(-) create mode 100644 .github/workflows/remove-old-artifacts.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9bdf879..344c385 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,19 +6,14 @@ on: tags: - '*' -env: - # For any reason, specifying this in the modrinth step does not work? - # But it is also well documented here, so this should be ok to do - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2'] + fail-fast: true steps: - - name: Check tag condition or manual request of build - if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' - run: echo "Ref is a tag or this build was requested manually" - - name: Check out project if: success() uses: actions/checkout@v3 @@ -38,44 +33,36 @@ jobs: with: gradle-version: 8.3 - - name: Build v1.19 - if: success() - run: gradle remapJar -Pv=1.19 - - - name: Build v1.19.1 - if: success() - run: gradle remapJar -Pv=1.19.1 - - - name: Build v1.19.2 + - name: Build if: success() - run: gradle remapJar -Pv=1.19.2 + run: gradle remapJar -Pv=${{ matrix.version }} - - name: Build v1.19.3 + - name: Upload artifact if: success() - run: gradle remapJar -Pv=1.19.3 - - - name: Build v1.19.4 - if: success() - run: gradle remapJar -Pv=1.19.4 - - - name: Build v1.20 - if: success() - run: gradle remapJar -Pv=1.20 + uses: actions/upload-artifact@v3 + with: + name: build-${{ matrix.version }} + path: | + **/libs/server-portals-*.jar - - name: Build v1.20.1 - if: success() - run: gradle remapJar -Pv=1.20.1 + release: + runs-on: ubuntu-latest + needs: build + steps: + - name: Check out metadata + uses: actions/checkout@v3 + with: + sparse-checkout: | + README.md + CHANGELOG.md + LICENSE - - name: Build v1.20.2 + - name: Download artifacts if: success() - run: gradle remapJar -Pv=1.20.2 - - - name: Check tag condition before release - if: success() && startsWith(github.ref, 'refs/tags/') - run: echo "Ref is a tag" + uses: actions/download-artifact@v3 - - name: Release on GitHub - if: success() + - name: Release on github + if: success() # No git tag check, since action-gh-release fails if not valid uses: softprops/action-gh-release@v1 with: files: | @@ -88,34 +75,57 @@ jobs: prerelease: false fail_on_unmatched_files: true - - name: Upload to modrinth v1.19 - if: success() - run: gradle modrinth -Pv=1.19 - - - name: Upload to modrinth v1.19.1 - if: success() - run: gradle modrinth -Pv=1.19.1 - - - name: Upload to modrinth v1.19.2 - if: success() - run: gradle modrinth -Pv=1.19.2 - - - name: Upload to modrinth v1.19.3 - if: success() - run: gradle modrinth -Pv=1.19.3 - - - name: Upload to modrinth v1.19.4 - if: success() - run: gradle modrinth -Pv=1.19.4 + publish: + runs-on: ubuntu-latest + needs: release + strategy: + matrix: + version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2'] + fail-fast: true + steps: + - name: Check out metadata + uses: actions/checkout@v3 + with: + sparse-checkout: | + CHANGELOG.md - - name: Upload to modrinth v1.20 + - name: Download artifact if: success() - run: gradle modrinth -Pv=1.20 + uses: actions/download-artifact@v3 + with: + name: build-${{ matrix.version }} - - name: Upload to modrinth v1.20.1 - if: success() - run: gradle modrinth -Pv=1.20.1 + - name: Publish on modrinth + if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check + # See https://github.com/Kir-Antipov/mc-publish + uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: server-portals + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + modrinth-featured: false + files: | + **/libs/server-portals-*.jar + name: Server Portals ${{ github.ref_name }} + version: ${{ github.ref_name }}+${{ matrix.version }} + version-type: "${{ contains(github.ref_name, 'SNAPSHOT') && 'alpha' || 'release' }}" + changelog-file: CHANGELOG.md + #loaders: fabric + game-versions: "=${{ matrix.version }}" + #dependencies: + + publish_readme: + runs-on: ubuntu-latest + needs: publish + steps: + - name: Check out metadata + uses: actions/checkout@v3 + with: + sparse-checkout: | + README.md - - name: Upload to modrinth v1.20.2 + - name: Update readme if: success() - run: gradle modrinth -Pv=1.20.2 + run: | + readme="$(sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/' README.md)" + json="{ \"body\": \"$readme\" }" + echo "$json" | curl -XPATCH -H "Authorization: ${{ secrets.MODRINTH_TOKEN }}" -H "Content-type: application/json" -d @- 'https://api.modrinth.com/v2/project/server-portals' diff --git a/.github/workflows/remove-old-artifacts.yml b/.github/workflows/remove-old-artifacts.yml new file mode 100644 index 0000000..b22ded2 --- /dev/null +++ b/.github/workflows/remove-old-artifacts.yml @@ -0,0 +1,23 @@ +# See https://github.com/marketplace/actions/remove-artifacts +name: Remove old artifacts + +on: + schedule: + # Every day at 1am + - cron: '0 1 * * *' + +jobs: + remove-old-artifacts: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Remove old artifacts + uses: c-hive/gha-remove-artifacts@v1 + with: + # ' ', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js + age: '2 days' + + # Optional inputs + # skip-tags: true + # skip-recent: 5 diff --git a/build.gradle b/build.gradle index e7ff9f3..14aa4e4 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,6 @@ import de.michiruf.gradle.findversion.FindVersion plugins { id 'java' id 'fabric-loom' version '1.4-SNAPSHOT' - id 'com.modrinth.minotaur' version '2.+' } apply from: 'build.allprojects.gradle' @@ -47,28 +46,6 @@ dependencies { modImplementation include("eu.pb4:${minecraftVersionDefinition['polymer']}") { exclude group: 'net.fabricmc.fabric-api' } } -def buildJarFile = file("build/libs/${rootProject.name}-${project.version}.jar") -modrinth { - projectId = rootProject.name - versionNumber = project.version - versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release' - gameVersions = [minecraftVersion] - loaders = ['fabric'] - dependencies { - required.project 'fabric-api' - required.project 'owo-lib' - } - if(buildJarFile.exists()) - uploadFile = buildJarFile; - else - uploadFile = remapJar - syncBodyFrom = rootProject.file("README.md").text - - // Use the environment variable `$MODRINTH_TOKEN` for the token - // token = 'mySecretToken' -} -tasks.modrinth.dependsOn(tasks.modrinthSyncBody) - processResources { var replaceProperties = [ version : project.version,