Skip to content

Commit

Permalink
Switch from specifying UUID to having optional support for DevLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jun 18, 2024
1 parent 24d58a3 commit 95623a6
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import mekanism.MergeModuleResources
import mekanism.OptimizePng
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.darkhax.curseforgegradle.UploadArtifact
import net.neoforged.gradle.dsl.common.runs.run.Run

import java.util.function.Consumer

Expand All @@ -20,7 +19,7 @@ plugins {
id('eclipse')
id('idea')
id('maven-publish')
id('net.neoforged.gradle.userdev') version('7.0.142')//https://projects.neoforged.net/neoforged/neogradle
id('net.neoforged.gradle.userdev') version('7.0.145')//https://projects.neoforged.net/neoforged/neogradle
}

tasks.named('wrapper', Wrapper).configure {
Expand Down Expand Up @@ -243,29 +242,6 @@ minecraft.accessTransformers.files(
file('src/gameTest/resources/META-INF/gametest_ats.cfg')
)

static void setupClientAcc(Run run) {
//The below if statements are to add args to your gradle.properties file in user home
// (DO NOT add them directly to the gradle.properties file for this project)
// Setting the below properties allows use of your normal Minecraft account in the
// dev environment including having your skin load. Each property also has a comment
// explaining what information to set the value to/format it expects
// One thing to note is because of the caching that goes on, after changing these
// variables, you need to refresh the project and rerun genIntellijRuns/genEclipseRuns
if (run.project.hasProperty('mc_uuid')) {
//Your uuid without any dashes in the middle
run.programArguments.addAll('--uuid', (String) run.project.property('mc_uuid'))
}
if (run.project.hasProperty('mc_username')) {
//Your username/display name, this is the name that shows up in chat
// Note: This is not your email, even if you have a Mojang account
run.programArguments.addAll('--username', (String) run.project.property('mc_username'))
}
if (run.project.hasProperty('mc_accessToken')) {
//Your access token, you can find it in your '.minecraft/launcher_accounts.json' file
run.programArguments.addAll('--accessToken', (String) run.project.property('mc_accessToken'))
}
}

runs {
configureEach {
if (hasProperty('forge_force_ansi')) {
Expand All @@ -285,11 +261,16 @@ runs {
jvmArguments.add('-XX:+AllowEnhancedClassRedefinition')
}
}
client { Run run -> setupClientAcc(run) }
//Note: To enable logging into the client account, set the neogradle.subsystems.devLogin.conventionForRun property to true in your gradle user home
// https://github.com/neoforged/NeoGradle?tab=readme-ov-file#per-run-configuration
client {
}
clientAlt {
configure('client')
if (!project.hasProperty('mc_username')) {
//If the property is missing (so the normal runClient task would use Dev as the name),
//Force disable devLogin for clientAlt regardless of if it is enabled via gradle properties for the main gradle run
devLogin.enabled(false)
if (!(findProperty('neogradle.subsystems.devLogin.conventionForRun') ?: false)) {
//If the property is missing or set to false (so the normal runClient task would use Dev as the name),
// change the name of the alt client type so that it doesn't conflict with the main dev one
programArguments.addAll((String[]) ['--username', 'AltDev'])
}
Expand All @@ -299,9 +280,8 @@ runs {
gameTestServer {
modSources.add((SourceSet) sourceSets.gameTest)
}
gameTestClient { Run run ->
gameTestClient {
configure('client')
setupClientAcc(run)
modSources.add((SourceSet) sourceSets.gameTest)
}
junit {
Expand Down

0 comments on commit 95623a6

Please sign in to comment.