Skip to content

Commit

Permalink
Merge branch '0.2' into 0.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	buildSrc/build.gradle.kts
#	platform/fabric/gradle.properties
#	platform/forge/gradle.properties
#	src/main/java/lol/bai/badpackets/impl/mixin/client/MixinClientPacketListener.java
  • Loading branch information
deirn committed Sep 3, 2023
2 parents e848a60 + 832c1de commit 3c7029b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 49 deletions.
13 changes: 9 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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:1.0.+")
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")
}
65 changes: 31 additions & 34 deletions buildSrc/src/main/kotlin/CurseforgeConfig.kt
Original file line number Diff line number Diff line change
@@ -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 <T : Jar> UploadConfig.curseforge(task: T) = project.run {
apply(plugin = "com.matthewprenger.cursegradle")
apply(plugin = "net.darkhax.curseforgegradle")

env["CURSEFORGE_API"]?.let { CURSEFORGE_API ->
configure<CurseExtension> {
apiKey = CURSEFORGE_API
project(closureOf<CurseProject> {
id = rootProp["cf.projectId"]
releaseType = prop["cf.releaseType"]
tasks.create<TaskPublishCurseForge>("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<CurseArtifact> {
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<CurseRelation> {
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);
}
}
}
8 changes: 4 additions & 4 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions platform/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ dependencies {

loom {
mixin.defaultRefmapName.set("badpackets.refmap.json")

runs.forEach {
it.isIdeConfigGenerated = true
}
}

tasks.processResources {
Expand Down
1 change: 1 addition & 0 deletions platform/fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CurseForge
cf.endpoint = minecraft.curseforge.com
cf.releaseType = release
cf.loader = Fabric, Quilt
cf.gameVersion = 1.19.3
Expand Down
6 changes: 5 additions & 1 deletion platform/forge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import net.minecraftforge.gradle.common.util.RunConfig

plugins {
id("net.minecraftforge.gradle")
id("net.neoforged.gradle")
id("org.spongepowered.mixin")
}

setupPlatform()

repositories {
maven("https://maven.minecraftforge.net")
}

dependencies {
minecraft("net.minecraftforge:forge:${rootProp["minecraft"]}-${rootProp["forge"]}")

Expand Down
1 change: 1 addition & 0 deletions platform/forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CurseForge
cf.endpoint = minecraft.curseforge.com
cf.releaseType = beta
cf.loader = Forge
cf.gameVersion = 1.19.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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;
Expand Down Expand Up @@ -40,13 +39,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 {
Expand Down

0 comments on commit 3c7029b

Please sign in to comment.