From eaffc0c0034e57327f18939abb1ac6478f10421b Mon Sep 17 00:00:00 2001 From: deirn Date: Tue, 8 Nov 2022 15:50:57 +0700 Subject: [PATCH 1/4] release client bound packet buffer after trying to handle it closes #5 --- .../impl/mixin/client/MixinClientPacketListener.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java b/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java index 0be2442..29093ca 100644 --- a/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java +++ b/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.Connection; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; import net.minecraft.network.protocol.game.ClientboundLoginPacket; @@ -45,8 +46,15 @@ private void badpackets_initClientPacketHandler(ClientboundLoginPacket packet, C @Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true) private void badpackets_receiveS2CPacket(ClientboundCustomPayloadPacket packet, CallbackInfo ci) { - if (!minecraft.isSameThread() && badpacket_packetHandler.receive(packet.getIdentifier(), packet.getData())) { - ci.cancel(); + if (!minecraft.isSameThread()) { + FriendlyByteBuf buf = packet.getData(); + try { + if (badpacket_packetHandler.receive(packet.getIdentifier(), buf)) { + ci.cancel(); + } + } finally { + buf.release(); + } } } From fbfbf7eae16573c45c89a78381e0da99aeff2b10 Mon Sep 17 00:00:00 2001 From: deirn Date: Wed, 30 Aug 2023 15:45:58 +0700 Subject: [PATCH 2/4] update to gradle 8 --- buildSrc/build.gradle.kts | 13 ++-- buildSrc/src/main/kotlin/CurseforgeConfig.kt | 65 ++++++++++---------- gradle/wrapper/gradle-wrapper.properties | 8 +-- platform/fabric/build.gradle.kts | 4 ++ platform/fabric/gradle.properties | 5 +- platform/forge/build.gradle.kts | 2 +- platform/forge/gradle.properties | 5 +- 7 files changed, 55 insertions(+), 47 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 965bda2..78f2196 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,16 +7,21 @@ repositories { mavenCentral() gradlePluginPortal() maven("https://maven.fabricmc.net") - maven("https://maven.minecraftforge.net") + maven("https://maven.neoforged.net/releases") maven("https://repo.spongepowered.org/repository/maven-public") + maven("https://jitpack.io") } dependencies { implementation("com.modrinth.minotaur:Minotaur:2.2.1") - implementation("gradle.plugin.com.matthewprenger:CurseGradle:1.4.0") + implementation("com.github.deirn:CurseForgeGradle:c693018f92") implementation("org.spongepowered:vanillagradle:0.2.1-SNAPSHOT") - implementation("fabric-loom:fabric-loom.gradle.plugin:0.12.+") - implementation("net.minecraftforge.gradle:ForgeGradle:5.1.+") + implementation("fabric-loom:fabric-loom.gradle.plugin:1.3.+") + implementation("net.neoforged.gradle:net.neoforged.gradle.gradle.plugin:[6.0.13,6.2)") implementation("org.spongepowered:mixingradle:0.7.+") + + // https://github.com/MinecraftForge/ForgeGradle/issues/919 + // The issue still happens because FART still uses outdated srgutils version + implementation("net.minecraftforge:srgutils:0.5.3") } diff --git a/buildSrc/src/main/kotlin/CurseforgeConfig.kt b/buildSrc/src/main/kotlin/CurseforgeConfig.kt index ce37dea..be4a02b 100644 --- a/buildSrc/src/main/kotlin/CurseforgeConfig.kt +++ b/buildSrc/src/main/kotlin/CurseforgeConfig.kt @@ -1,48 +1,45 @@ -import com.matthewprenger.cursegradle.CurseArtifact -import com.matthewprenger.cursegradle.CurseExtension -import com.matthewprenger.cursegradle.CurseProject -import com.matthewprenger.cursegradle.CurseRelation +import net.darkhax.curseforgegradle.Constants +import net.darkhax.curseforgegradle.TaskPublishCurseForge import org.gradle.jvm.tasks.Jar import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.closureOf -import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.create fun UploadConfig.curseforge(task: T) = project.run { - apply(plugin = "com.matthewprenger.cursegradle") + apply(plugin = "net.darkhax.curseforgegradle") - env["CURSEFORGE_API"]?.let { CURSEFORGE_API -> - configure { - apiKey = CURSEFORGE_API - project(closureOf { - id = rootProp["cf.projectId"] - releaseType = prop["cf.releaseType"] + tasks.create("curseforge") { + group = "publishing" + dependsOn("build") - changelogType = "markdown" - changelog = "https://github.com/badasintended/badpackets/releases/tag/${project.version}" + disableVersionDetection() - prop["cf.loader"].split(", ").forEach(this::addGameVersion) - prop["cf.gameVersion"].split(", ").forEach(this::addGameVersion) + apiToken = env["CURSEFORGE_API"] + apiEndpoint = "https://${prop["cf.endpoint"]}" - mainArtifact(task, closureOf { - displayName = "[${prop["cf.loader"].replace(", ", "/")}] ${project.version}" - }) + upload(prop["cf.projectId"], task).apply { + displayName = "[${project.name.capitalize()} ${rootProp["minecraft"]}] ${project.version}" + releaseType = prop["cf.releaseType"] - if(listOf("cf.require", "cf.optional", "cf.break").any { prop.has(it) }) relations(closureOf { - prop.ifPresent("cf.require") { - it.split(", ").forEach(this::requiredDependency) - } - prop.ifPresent("cf.optional") { - it.split(", ").forEach(this::optionalDependency) - } - prop.ifPresent("cf.break") { - it.split(", ").forEach(this::incompatible) - } - }) + changelogType = "markdown" + changelog = env["CHANGELOG"] + + prop["cf.gameVersion"].split(", ").forEach(this::addGameVersion) - afterEvaluate { - uploadTask.dependsOn("build") + prop["cf.loader"].split(", ").forEach { + addModLoader(it) + } + + fun relation(key: String, type: String) { + prop.ifPresent("cf.${key}") { value -> + value.split(", ").forEach { + addRelation(it, type) + } } - }) + } + + relation("require", Constants.RELATION_REQUIRED); + relation("optional", Constants.RELATION_OPTIONAL); + relation("break", Constants.RELATION_INCOMPATIBLE); } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7472e45..1d8a75d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Sep 14 12:28:28 PDT 2015 -distributionBase =GRADLE_USER_HOME -distributionPath =wrapper/dists -zipStoreBase =GRADLE_USER_HOME +distributionBase = GRADLE_USER_HOME +distributionPath = wrapper/dists +zipStoreBase = GRADLE_USER_HOME zipStorePath = wrapper/dists -distributionUrl = https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl = https\://services.gradle.org/distributions/gradle-8.3-bin.zip diff --git a/platform/fabric/build.gradle.kts b/platform/fabric/build.gradle.kts index 025d791..3ae99a3 100644 --- a/platform/fabric/build.gradle.kts +++ b/platform/fabric/build.gradle.kts @@ -13,6 +13,10 @@ dependencies { loom { mixin.defaultRefmapName.set("badpackets.refmap.json") + + runs.forEach { + it.isIdeConfigGenerated = true + } } tasks.processResources { diff --git a/platform/fabric/gradle.properties b/platform/fabric/gradle.properties index da1e87d..5740601 100644 --- a/platform/fabric/gradle.properties +++ b/platform/fabric/gradle.properties @@ -1,9 +1,10 @@ # CurseForge +cf.endpoint = minecraft.curseforge.com cf.releaseType = release cf.loader = Fabric, Quilt -cf.gameVersion = 1.19.1 +cf.gameVersion = 1.19.1, 1.19.2 # Modrinth mr.releaseType = release mr.loader = fabric, quilt -mr.gameVersion = 1.19.1 +mr.gameVersion = 1.19.1, 1.19.2 diff --git a/platform/forge/build.gradle.kts b/platform/forge/build.gradle.kts index 21720ab..0db5425 100644 --- a/platform/forge/build.gradle.kts +++ b/platform/forge/build.gradle.kts @@ -1,7 +1,7 @@ import net.minecraftforge.gradle.common.util.RunConfig plugins { - id("net.minecraftforge.gradle") + id("net.neoforged.gradle") id("org.spongepowered.mixin") } diff --git a/platform/forge/gradle.properties b/platform/forge/gradle.properties index 18dd916..3629983 100644 --- a/platform/forge/gradle.properties +++ b/platform/forge/gradle.properties @@ -1,9 +1,10 @@ # CurseForge +cf.endpoint = minecraft.curseforge.com cf.releaseType = beta cf.loader = Forge -cf.gameVersion = 1.19.1 +cf.gameVersion = 1.19.1, 1.19.2 # Modrinth mr.releaseType = release mr.loader = forge -mr.gameVersion = 1.19.1 +mr.gameVersion = 1.19.1, 1.19.2 From 18ec6599dfab1fdc01765fcaae4a5595cba657d7 Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 3 Sep 2023 19:20:05 +0700 Subject: [PATCH 3/4] don't trust `ClientboundLoginPacket` to be sent only in valid `PLAY` stage closes https://github.com/badasintended/wthit/issues/230 --- .../impl/mixin/client/MixinClientPacketListener.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java b/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java index 29093ca..a1000b8 100644 --- a/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java +++ b/src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java @@ -10,7 +10,6 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; -import net.minecraft.network.protocol.game.ClientboundLoginPacket; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -39,13 +38,10 @@ private void badpackets_removeClientPacketHandler(Component reason, CallbackInfo badpacket_packetHandler.onDisconnect(); } - @Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V")) - private void badpackets_initClientPacketHandler(ClientboundLoginPacket packet, CallbackInfo ci) { - badpacket_packetHandler.sendInitialChannelSyncPacket(); - } - @Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true) private void badpackets_receiveS2CPacket(ClientboundCustomPayloadPacket packet, CallbackInfo ci) { + badpacket_packetHandler.sendInitialChannelSyncPacket(); + if (!minecraft.isSameThread()) { FriendlyByteBuf buf = packet.getData(); try { From 832c1def1a13613590b097789860451728986c32 Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 3 Sep 2023 19:31:31 +0700 Subject: [PATCH 4/4] hope it builds --- platform/forge/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/forge/build.gradle.kts b/platform/forge/build.gradle.kts index 0db5425..9277bfb 100644 --- a/platform/forge/build.gradle.kts +++ b/platform/forge/build.gradle.kts @@ -7,6 +7,10 @@ plugins { setupPlatform() +repositories { + maven("https://maven.minecraftforge.net") +} + dependencies { minecraft("net.minecraftforge:forge:${rootProp["minecraft"]}-${rootProp["forge"]}")