Configure NeoGradle and NeoForge
Developing a mod is a complex endeavor that requires a lot of tools and configurations. This guide will help you configure NeoGradle and NeoForge to work with your mod. We will cover the following topics:
- Setting the exact version of NeoForge that you want to use
- Registering Access-Transformers and Interface-Injections
- Configuring Data-Generators
- Creating a library instead of a mod
- Using a random player name
- Setting the primary jars classifier
All sections of this guide will happen in the neogradle
block of the Tableau DSL.
Setting the exact version of NeoForge that you want to use
By default, Tableau will configure NeoGradle to use the latest version of NeoForge.
This is good if you just want to get started, or always want to use the latest version of NeoForge, with the newest features and bug fixes.
However, if you want to use a specific version of NeoForge, you can do so by setting the neoforgeVersion
property in the neogradle
block of the Tableau DSL:
- Groovy
- Kotlin
tableau {
neogradle {
//Use the lastest version of NeoForge
//Available under: https://project.neoforged.net
neoforgeVersion = '1.0.0'
}
}
tableau {
neogradle {
//Use the lastest version of NeoForge
//Available under: https://project.neoforged.net
neoforgeVersion.set("1.0.0")
}
}
Registering Access-Transformers and Interface-Injections
NeoForge allows you to register Access-Transformers and Interface-Injections.
Access-Transformers are used to modify the access level of fields, methods and classes as well as remove final modifiers from these as well.
Interface-Injections are used to inject interfaces into classes, this allows you to add mixins to classes so that at compile time they are properly registered,
ensuring that you do not need to do double casts: ((IMixinInterface) (Object) this).method()
.
To register Access-Transformers and Interface-Injections, you can use the accessTransformers
and interfaceInjections
properties in the neogradle
block of the Tableau DSL:
We are improving the API and functionality in this area to ensure that the relevant files are also properly injected into the jar.
Right now we recommend to put the files in your resources
directory and use the file
function to reference them.
Then you can reference them properly from your mods.toml
file.
It is also possible to directly register access transformers from the NeoForge metadata generation module in Tableau, which will automatically register them here
- Groovy
- Kotlin
tableau {
neogradle {
accessTransformers += [file('src/path/to/your/AccessTransformer.at')]
interfaceInjections += [file('src/path/to/your/InterfaceInjection.json')]
}
}
tableau {
neogradle {
accessTransformers.add(file("src/path/to/your/AccessTransformer.at"))
interfaceInjections.add(file("src/path/to/your/InterfaceInjection.json"))
}
}
Alternatively to add a single file you can use the accessTransformer
and interfaceInjection
methods:
- Groovy
- Kotlin
tableau {
neogradle {
accessTransformer(file('src/path/to/your/AccessTransformer.at'))
interfaceInjection(file('src/path/to/your/InterfaceInjection.json'))
}
}
tableau {
neogradle {
accessTransformer(file("src/path/to/your/AccessTransformer.at"))
interfaceInjection(file("src/path/to/your/InterfaceInjection.json"))
}
}
Configuring Data-Generators
NeoForge allows you to register Data-Generators.
By default, only the Data-Generators of your own mod will run.
If you want to run the Data-Generators of other mods as well, you can add their mod id to the additionalDataGenMods
property in the neogradle
block of the Tableau DSL:
- Groovy
- Kotlin
tableau {
neogradle {
additionalDataGenMods += ['modid']
}
}
tableau {
neogradle {
additionalDataGenMods.add("modid")
}
}
Alternatively to add a single mod you can use the additionalDataGenMod
method:
- Groovy
- Kotlin
tableau {
neogradle {
additionalDataGenMod("modid")
}
}
tableau {
neogradle {
additionalDataGenMod("modid")
}
}
Creating a library instead of a mod
If you want to create a library instead of a mod, you can set the isLibrary
property in the neogradle
block of the Tableau DSL:
- Groovy
- Kotlin
tableau {
neogradle {
isLibrary = true
}
}
tableau {
neogradle {
isLibrary.set(true)
}
}
Using a random player name
When you want to run your client with a random player name, you can set the useRandomPlayerName
property in the neogradle
block of the Tableau DSL:
This is useful when you want to run multiple clients at the same time, for example when testing multiplayer.
The name pattern used here is: Dev<random number between 1 and 600>
.
This means it is possible that there might be some overlap with other instances.
Please note that this won't work if you have imported the run into your IDE, as the IDE will always use the same player name.
- Groovy
- Kotlin
tableau {
neogradle {
useRandomPlayerName = true
}
}
tableau {
neogradle {
useRandomPlayerName.set(true)
}
}
Setting the primary jars classifier
By default, the primary jar of your mod will have the classifier universal
.
This is historically grown as in the past there were different jars for client and server.
If you want to change the classifier of the primary jar, you can set the primaryJarClassifier
property in the neogradle
block of the Tableau DSL:
- Groovy
- Kotlin
tableau {
neogradle {
//Any value is possible
primaryJarClassifier = 'mod'
}
}
tableau {
neogradle {
//Any value is possible
primaryJarClassifier.set("mod")
}
}