diff --git a/build.gradle b/build.gradle index 7e6af2b6..d3b90f2b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { - id 'fabric-loom' version '0.9-SNAPSHOT' + id 'fabric-loom' version '0.11-SNAPSHOT' id 'maven-publish' id 'com.matthewprenger.cursegradle' version '1.4.0' - id 'com.modrinth.minotaur' version '1.2.1' + id 'com.modrinth.minotaur' version '2.1.1' id 'org.cadixdev.licenser' version '0.6.1' id "com.github.breadmoirai.github-release" version "2.2.12" } @@ -14,7 +14,7 @@ archivesBaseName = project.archives_base_name version = "${project.mod_version}+mc${project.minecraft_version}" group = project.maven_group -minecraft { +loom { } repositories { @@ -50,7 +50,7 @@ dependencies { transitive false } - modRuntime("com.github.astei:lazydfu:master-SNAPSHOT") + modRuntimeOnly("com.github.astei:lazydfu:master-SNAPSHOT") testmodImplementation sourceSets.main.output } @@ -92,7 +92,6 @@ task sourcesJar(type: Jar, dependsOn: classes) { jar { from "LICENSE" - archiveClassifier.set("") } // configure the maven publication @@ -100,13 +99,9 @@ publishing { publications { mavenJava(MavenPublication) { artifactId = "${project.archives_base_name}-${project.minecraft_major_version}" - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } + + from components.java + java.withSourcesJar() } } repositories { @@ -134,9 +129,9 @@ task uploadToModSites { group = "upload" } -if (project.hasProperty("siphalorCurseForgeApi")) { +if (project.hasProperty("curseforgeToken")) { curseforge { - apiKey project.siphalorCurseForgeApi + apiKey project.curseforgeToken project { id = "314633" releaseType = project.mod_release @@ -158,36 +153,31 @@ if (project.hasProperty("siphalorCurseForgeApi")) { uploadToModSites.finalizedBy(tasks.curseforge) } -import com.modrinth.minotaur.TaskModrinthUpload -if (project.hasProperty("siphalorModrinthApi")) { - task modrinth (type: TaskModrinthUpload) { - group = "upload" - dependsOn(build) - - token = project.siphalorModrinthApi - projectId = "18ztUZP5" - versionNumber = version - versionName = "[${project.mod_mc_version_specifier}] ${project.mod_version}" - changelog = getChangelog() - uploadFile = remapJar - versionType = project.mod_release - for (version in ((String) project.mod_mc_versions).split(";")) { - addGameVersion(version) - } - addLoader("fabric") +modrinth { + if (project.hasProperty("modrinthToken")) { + token = project.modrinthToken + uploadToModSites.finalizedBy(tasks.modrinth) } - uploadToModSites.finalizedBy(tasks.modrinth) + + projectId = "18ztUZP5" + versionName = "[$project.mod_mc_version_specifier] $project.mod_version" + versionType = project.mod_release + changelog = project.getChangelog() + uploadFile = remapJar + gameVersions = project.mod_mc_versions.split(";") as List + loaders = ["fabric"] } +tasks.modrinth.group = "upload" -if (project.hasProperty("siphalorGitHubToken")) { +if (project.hasProperty("githubToken")) { githubRelease { - token siphalorGitHubToken - targetCommitish.set("$minecraft_major_version-2.0") - releaseName.set("Version $mod_version") - body.set(getChangelog()) + token githubToken + targetCommitish = "$minecraft_major_version-2.0" + releaseName = "Version $mod_version" + body = getChangelog() releaseAssets remapJar.getArchiveFile() - prerelease.set(mod_release != "release") - overwrite.set(true) + prerelease = mod_release != "release" + overwrite = true } uploadToModSites.finalizedBy(tasks.githubRelease) } diff --git a/gradle.properties b/gradle.properties index b1d80407..dcc6f673 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,8 +10,8 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.11.6 # Mod Properties - mod_version = 2.1.2 - mod_release = alpha + mod_version = 2.1.3 + mod_release = release mod_mc_version_specifier = 1.16.2+ mod_mc_versions = 1.16.2;1.16.3;1.16.4 mod_id = nbtcrafting diff --git a/src/main/java/de/siphalor/nbtcrafting/mixin/MixinIngredient.java b/src/main/java/de/siphalor/nbtcrafting/mixin/MixinIngredient.java index c667002d..b5d19453 100644 --- a/src/main/java/de/siphalor/nbtcrafting/mixin/MixinIngredient.java +++ b/src/main/java/de/siphalor/nbtcrafting/mixin/MixinIngredient.java @@ -116,16 +116,18 @@ public void matches(ItemStack stack, CallbackInfoReturnable callbackInf @Inject(method = "write", at = @At("HEAD"), cancellable = true) public void write(PacketByteBuf buf, CallbackInfo callbackInfo) { if (NbtCrafting.isAdvancedIngredientSerializationEnabled()) { - if (advancedEntries != null) { + if (advancedEntries != null && advancedEntries.length != 0) { buf.writeVarInt(advancedEntries.length); for (IngredientEntry entry : advancedEntries) { buf.writeBoolean(entry instanceof IngredientMultiStackEntry); entry.write(buf); } + callbackInfo.cancel(); } else { - buf.writeVarInt(0); + // -1 is used to keep network compatibility with lower versions of Nbt Crafting, + // that used 0 to just indicate no advanced ingredients + buf.writeVarInt(-1); } - callbackInfo.cancel(); } } @@ -181,15 +183,17 @@ private static void ofStacks(ItemStack[] arr, CallbackInfoReturnable private static void fromPacket(PacketByteBuf buf, CallbackInfoReturnable cir) { if (NbtCrafting.isAdvancedIngredientSerializationEnabled()) { int length = buf.readVarInt(); - ArrayList entries = new ArrayList<>(length); - for (int i = 0; i < length; i++) { - if (buf.readBoolean()) { - entries.add(IngredientMultiStackEntry.read(buf)); - } else { - entries.add(IngredientStackEntry.read(buf)); + if (length >= 0) { + ArrayList entries = new ArrayList<>(length); + for (int i = 0; i < length; i++) { + if (buf.readBoolean()) { + entries.add(IngredientMultiStackEntry.read(buf)); + } else { + entries.add(IngredientStackEntry.read(buf)); + } } + cir.setReturnValue(ofAdvancedEntries(entries.stream())); } - cir.setReturnValue(ofAdvancedEntries(entries.stream())); } }