Fabric API DSL 1.21.11
Dokumentation für die Fabric API Unterstützung beim Fabric Loom Gradle Plugin.
WARNING
Diese Seite ist für die Version 1.21.11 geschrieben. Dokumentationen für ältere Versionen sind möglicherweise unvollständig.
Loom verfügt über eine DSL, die bei der Konfiguration bestimmter Aspekte der Fabric-API hilft, z. B. bei der Datengenerierung und bei Tests.
Datengenerator
Einen Schritt-für-Schritt-Leitfaden zur Vernwendung der Datengenerierung findest du auf der Seite Einrichtung der Datengenerierung. Die einfachste Art der Datengenerierung kann mit dem folgenden Code konfiguriert werden:
groovy
fabricApi {
configureDataGeneration()
}1
2
3
2
3
Dadurch wird eine neue Laufkonfiguration erstellt, die die Fabric API mit aktivierter Datengenerierung ausführt. Eine Reihe von fortgeschritteneren Optionen kann wie unten gezeigt konfiguriert werden:
groovy
fabricApi {
configureDataGeneration {
// Contains the output directory where generated data files will be stored.
// Defaults to `src/main/generated`
outputDirectory = file("src/generated/resources")
// Contains a boolean indicating whether a run configuration should be created for the data generation process.
// Defaults to `true`
createRunConfiguration = true
// Contains a boolean indicating whether a new source set should be created for the data generation process.
// This is useful if you do not want your datagen code to be exported in your mod jar.
// Defaults to `false`
createSourceSet = true
// Contains a string representing the mod ID associated with the data generation process. This must be set if `createSourceSet` is true.
// This must be the mod id of the mod used for datagen in the datagen source set and not your main mod id.
modId = "example-datagen"
// Contains a boolean indicating whether strict validation is enabled.
// Defaults to `false`
strictValidation = true
// Contains a boolean indicating whether the generated resources will be automatically added to the main source set.
// Defaults to `true`
addToResources = true
// Contains a boolean indicating whether data generation will be compiled and run with the client.
// Defaults to `false`
client = true
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Tests
Wie bei der Datengenerierung kannst du mit den folgenden Methoden grundlegende Tests einrichten:
groovy
fabricApi {
configureTests()
}1
2
3
2
3
Dadurch werden zwei neue Laufkonfigurationen erstellt, eine für die serverseitigen Spieltests und eine für die clientseitigen Spieltests. Eine Reihe von fortgeschritteneren Optionen kann wie unten gezeigt konfiguriert werden:
groovy
fabricApi {
configureTests {
// Contains a boolean indicating whether a new source set should be created for the tests.
// Defaults to `false`
createSourceSet = true
// Contains a string representing the mod ID associated with the tests. This must be set if `createSourceSet` is true.
// This must be the mod id of the mod used for tests in the gametest source set and not your main mod id.
modId = "example-tests"
// Contains a boolean indicating whether a run configuration will be created for the server side game tests, using Vanilla Game Test framework.
// Defaults to `true`
enableGameTests = true
// Contains a boolean indicating whether a run configuration will be created for the client side game tests, using the Fabric API Client Test framework.
// Defaults to `true`
enableClientGameTests = true
// Contains a boolean indicating whether the eula has been accepted. By enabling this you agree to the Minecraft EULA located at https://aka.ms/MinecraftEULA.
// Defaults to `false`
eula = true
// Contains a boolean indicating whether the run directories should be cleared before running the tests.
// This only works when `enableClientGameTests` is `true`.
// Defaults to `true`
clearRunDirectory = true
// Contains a string representing the username to use for the client side game tests.
// Defaults to `Player0`
username = "Username"
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32








