Skip to content

Commit

Permalink
Update for Minecraft 1.20.4 (#150)
Browse files Browse the repository at this point in the history
* Initial update for 1.20.3

* neoforge: `SquaremapPlayerCapability` -> `SquaremapPlayerData`

* neoforge: update `mods.toml`

* Update Paper platform

* Add config migration for grass to short_grass rename

* Refactor rename config migration

* build cleanup

* Ignore unclaimed annotation warnings

* 1.20.4

* Update Fabric platform

* neoforge: Replace use of FMLJavaModLoadingContext

* neoforge: bump runtime adventure
  • Loading branch information
jpenilla authored Dec 9, 2023
1 parent f3d2d91 commit a71f23e
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 111 deletions.
7 changes: 6 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ indra {
}
}

tasks.withType<Javadoc> {
tasks.withType<Javadoc>().configureEach {
val options = options as StandardJavadocDocletOptions
options.links(
"https://jd.advntr.dev/api/${libs.versions.adventure.get()}/",
"https://checkerframework.org/api/",
"https://jd.papermc.io/paper/${libs.versions.minecraft.get().split(".", "-").take(2).joinToString(".")}/",
)
}

tasks.withType(JavaCompile::class).configureEach {
// Don't warn about missing forRemoval in @Deprecated
options.compilerArgs.add("-Xlint:-classfile")
}
6 changes: 6 additions & 0 deletions build-logic/src/main/kotlin/base-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ repositories {
mavenContent {
includeGroup("cloud.commandframework")
includeGroup("xyz.jpenilla")
includeModule("net.kyori", "adventure-platform-fabric") // todo
snapshotsOnly()
}
}
Expand All @@ -31,3 +32,8 @@ repositories {
mavenContent { includeGroup("net.fabricmc") }
}
}

tasks.withType(JavaCompile::class).configureEach {
// We don't care about annotations being unclaimed by processors
options.compilerArgs.add("-Xlint:-processing")
}
8 changes: 4 additions & 4 deletions build-logic/src/main/kotlin/ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.gradle.api.Project
import org.gradle.api.file.RegularFile
import org.gradle.api.plugins.BasePluginExtension
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.getByType

val Project.releaseNotes: Provider<String>
get() = providers.environmentVariable("RELEASE_NOTES")

fun Project.lastCommitHash(): String = the<IndraGitExtension>().commit()?.name?.substring(0, 7)
fun Project.lastCommitHash(): String = extensions.getByType<IndraGitExtension>().commit()?.name?.substring(0, 7)
?: error("Could not determine commit hash")

fun Project.decorateVersion() {
Expand All @@ -32,15 +32,15 @@ fun Project.currentBranch(): String {
System.getenv("GITHUB_REF")?.takeIf { it.isNotEmpty() }
?.let { return it.replaceFirst("refs/heads/", "") }

val indraGit = the<IndraGitExtension>().takeIf { it.isPresent }
val indraGit = extensions.getByType<IndraGitExtension>().takeIf { it.isPresent }

val ref = indraGit?.git()?.repository?.exactRef("HEAD")?.target
?: return "detached-head"

return Repository.shortenRefName(ref.name)
}

fun Project.productionJarName(mcVer: Provider<String>): Provider<String> = the<BasePluginExtension>()
fun Project.productionJarName(mcVer: Provider<String>): Provider<String> = extensions.getByType<BasePluginExtension>()
.archivesName.zip(mcVer) { archivesName, mc -> "$archivesName-mc$mc-$version.jar" }

fun Project.productionJarLocation(mcVer: Provider<String>): Provider<RegularFile> =
Expand Down
6 changes: 4 additions & 2 deletions build-logic/src/main/kotlin/platform-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ tasks {
).forEach(::reloc)
}
val copyJar = register("copyJar", CopyFile::class) {
fileToCopy.set(platformExt.productionJar)
destination.set(platformExt.productionJar.flatMap { rootProject.layout.buildDirectory.file("libs/${it.asFile.name}") })
fileToCopy = platformExt.productionJar
destination = platformExt.productionJar.flatMap {
rootProject.layout.buildDirectory.file("libs/${it.asFile.name}")
}
}
assemble {
dependsOn(copyJar)
Expand Down
6 changes: 3 additions & 3 deletions build-logic/src/main/kotlin/publishing-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ indra {
pom {
developers {
developer {
id.set("jmp")
name.set("Jason Penilla")
timezone.set("America/Phoenix")
id = "jmp"
name = "Jason Penilla"
timezone = "America/Phoenix"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

minecraft {
version(libs.versions.minecraft.get())
version().set(libs.versions.minecraft)
accessWideners(layout.projectDirectory.file("src/main/resources/squaremap-common.accesswidener"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.leangen.geantyref.TypeToken;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.NodePath;
Expand All @@ -11,8 +12,10 @@

@SuppressWarnings("unused")
public final class Advanced extends AbstractConfig {
private static final int LATEST_VERSION = 3;

Advanced(final DirectoryProvider directoryProvider) {
super(directoryProvider.dataDirectory(), Advanced.class, "advanced.yml", 2);
super(directoryProvider.dataDirectory(), Advanced.class, "advanced.yml", LATEST_VERSION);
}

@Override
Expand All @@ -33,8 +36,23 @@ protected void addVersions(ConfigurationTransformation.VersionedBuilder versione
return null;
})
.build();
final ConfigurationTransformation twoToThree = ConfigurationTransformation.builder()
.addAction(NodePath.path("world-settings"), Transformations.eachMapChild(worldSection -> {
Transformations.applyMapKeyOrListValueRenames(
List.of(
worldSection.node("invisible-blocks"),
worldSection.node("iterate-up-base-blocks"),
worldSection.node("color-overrides", "blocks")
),
Map.of(
Transformations.maybeMinecraft("grass"), "minecraft:short_grass"
)
);
}))
.build();

versionedBuilder.addVersion(2, oneToTwo);
versionedBuilder.addVersion(LATEST_VERSION, twoToThree);
}

static Advanced config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

@SuppressWarnings("unused")
public final class Config extends AbstractConfig {
private static final int LATEST_VERSION = 2;

Config(final DirectoryProvider directoryProvider) {
super(directoryProvider.dataDirectory(), Config.class, "config.yml", 2);
super(directoryProvider.dataDirectory(), Config.class, "config.yml", LATEST_VERSION);
}

@Override
Expand All @@ -24,7 +26,7 @@ protected void addVersions(final ConfigurationTransformation.VersionedBuilder ve
})
.build();

versionedBuilder.addVersion(2, oneToTwo);
versionedBuilder.addVersion(LATEST_VERSION, oneToTwo);
}

static Config config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package xyz.jpenilla.squaremap.common.config;

import io.leangen.geantyref.TypeToken;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.transformation.TransformAction;
import xyz.jpenilla.squaremap.common.util.CheckedConsumer;

@DefaultQualifier(NonNull.class)
final class Transformations {
private Transformations() {
}

static Set<String> maybeMinecraft(final String name) {
return Set.of(name, "minecraft:" + name);
}

static TransformAction eachMapChild(final CheckedConsumer<ConfigurationNode, ConfigurateException> action) {
return (path, node) -> {
final Set<Object> childKeys = node.childrenMap().keySet();
for (final Object childKey : childKeys) {
final ConfigurationNode childNode = node.node(childKey);
action.accept(childNode);
}
return null;
};
}

// expects nodes to be round-trip representable as List<String> or Map<String, String>
static void applyMapKeyOrListValueRenames(final List<ConfigurationNode> sections, final Map<Set<String>, String> renames) throws SerializationException {
for (final ConfigurationNode sectionNode : sections) {
if (sectionNode.isList()) {
final List<String> list = Objects.requireNonNull(sectionNode.getList(String.class));
boolean anyRemoved = false;
for (final Map.Entry<Set<String>, String> renameEntry : renames.entrySet()) {
boolean removed = false;
for (final String from : renameEntry.getKey()) {
removed |= list.remove(from);
}
if (removed) {
list.add(renameEntry.getValue());
}
anyRemoved |= removed;
}
if (anyRemoved) {
sectionNode.setList(String.class, list);
}
} else if (sectionNode.isMap()) {
final TypeToken<Map<String, String>> type = new TypeToken<>() {};
final Map<String, String> map = Objects.requireNonNull(sectionNode.get(type));
boolean anyRemoved = false;
for (final Map.Entry<Set<String>, String> renameEntry : renames.entrySet()) {
@Nullable String removed = null;
for (final String from : renameEntry.getKey()) {
final @Nullable String remove = map.remove(from);
if (remove != null) {
removed = remove;
}
}
if (removed != null) {
map.put(renameEntry.getValue(), removed);
anyRemoved = true;
}
}
if (anyRemoved) {
sectionNode.set(type, map);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void invisibleBlocks() {
List.of(
"minecraft:tall_grass",
"minecraft:fern",
"minecraft:grass",
"minecraft:short_grass",
"minecraft:large_fern"
)
).forEach(block -> this.invisibleBlocks.add(Util.requireEntry(BuiltInRegistries.BLOCK, new ResourceLocation(block))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class BiomeColors {

private static final Set<Block> GRASS_COLOR_BLOCKS = Set.of(
Blocks.GRASS_BLOCK,
Blocks.GRASS,
Blocks.SHORT_GRASS,
Blocks.TALL_GRASS,
Blocks.FERN,
Blocks.LARGE_FERN,
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ dependencies {
include(libs.cardinalComponentsEntity)
}

squaremapLoomPlatform.modInfoFilePath.set("fabric.mod.json")
squaremapLoomPlatform.modInfoFilePath = "fabric.mod.json"

tasks.remapJar {
archiveFileName.set(productionJarName(libs.versions.minecraft))
archiveFileName = productionJarName(libs.versions.minecraft)
}

publishMods.modrinth {
Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"accessWidener": "squaremap-fabric.accesswidener",
"depends": {
"fabric": "*",
"fabricloader": ">=0.14.10",
"minecraft": "~1.20.2",
"fabricloader": ">=0.15.0",
"minecraft": "~1.20.4",
"cloud": "*",
"adventure-platform-fabric": "*"
}
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ run-paper = { id = "xyz.jpenilla.run-paper", version = "2.2.2" }
hangar-publish = { id = "io.papermc.hangar-publish-plugin", version = "0.1.0" }

[versions]
minecraft = "1.20.2"
minecraft = "1.20.4"
checkerQual = "3.40.0"
cloud = "1.8.4"
cloudNeoForge = "1.0.0+1.20.2-SNAPSHOT"
cloudSponge = "1.8.0-SNAPSHOT"
configurate = "4.1.2"
adventure = "4.14.0"
examination = "1.3.0"
adventurePlatformFabric = "5.10.1"
paperApi = "1.20.2-R0.1-SNAPSHOT"
adventurePlatformFabric = "5.10.2-SNAPSHOT"
paperApi = "1.20.4-R0.1-SNAPSHOT"
bStats = "3.0.2"
fabricApi = "0.91.1+1.20.2"
fabricLoader = "0.15.0"
cardinalComponents = "5.3.0"
fabricApi = "0.91.1+1.20.4"
fabricLoader = "0.15.1"
cardinalComponents = "5.4.0"
guice = "5.1.0"
neoforge = "20.2.86"
neoforge = "20.4.4-beta"

# buildSrc
indra = "3.1.3"
Expand Down
21 changes: 3 additions & 18 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
}

implementation(platform(libs.adventureBom))
include(platform(libs.adventureBom))
include(platform(libs.adventureBom.get().group + ':' + libs.adventureBom.get().name + ":4.15.0-SNAPSHOT")) // todo
implementation(libs.adventureApi)
include(libs.adventureApi)
include(libs.examinationApi)
Expand All @@ -40,25 +40,10 @@ dependencies {
}

tasks.remapJar {
archiveFileName.set(productionJarName(libs.versions.minecraft))
archiveFileName = productionJarName(libs.versions.minecraft)
}

squaremapLoomPlatform.modInfoFilePath.set("META-INF/mods.toml")

// todo https://github.com/FabricMC/fabric-loom/pull/838
configurations.include {
isTransitive = true
withDependencies {
all {
if (this !is ModuleDependency) return@all
val category: Category? = attributes.getAttribute(Category.CATEGORY_ATTRIBUTE)
if (category != null && (category.name == Category.REGULAR_PLATFORM || category.name == Category.ENFORCED_PLATFORM)) {
return@all
}
isTransitive = false
}
}
}
squaremapLoomPlatform.modInfoFilePath = "META-INF/mods.toml"

publishMods.modrinth {
minecraftVersions.add(libs.versions.minecraft)
Expand Down
Loading

0 comments on commit a71f23e

Please sign in to comment.