@@ -98,6 +98,17 @@ runs {
9898 file(' src/generated/resources/' ). absolutePath, ' --existing' ,
9999 file(' src/main/resources/' ). absolutePath
100100 }
101+
102+ [' Fresh' , ' Reload' ]. each { String phase ->
103+ register(" biomeIntegration${ phase} " ) {
104+ runType ' server'
105+ workingDirectory layout. buildDirectory. dir(' biome-integration-run' )
106+ systemProperty ' forge.logging.console.level' , ' info'
107+ systemProperty ' cakeworld.biomeIntegrationPhase' , phase. toLowerCase(Locale . ROOT )
108+ argument ' --nogui'
109+ modSource project. sourceSets. main
110+ }
111+ }
101112}
102113
103114configurations {
@@ -189,6 +200,88 @@ tasks.named('test', Test).configure {
189200 useJUnitPlatform()
190201}
191202
203+ def biomeIntegrationClasses = layout. buildDirectory. dir(' biome-integration-fixture/classes' )
204+ def compileBiomeIntegrationTestMod = tasks. register(' compileBiomeIntegrationTestMod' , JavaCompile ) {
205+ dependsOn tasks. named(' classes' )
206+ source fileTree(' src/biomeIntegrationTest/java' )
207+ classpath = files(sourceSets. main. output, sourceSets. main. compileClasspath)
208+ destinationDirectory. set(biomeIntegrationClasses)
209+ javaCompiler. set(javaToolchains. compilerFor {
210+ languageVersion = JavaLanguageVersion . of(21 )
211+ })
212+ options. release = 21
213+ options. encoding = ' UTF-8'
214+ }
215+
216+ def biomeIntegrationTestModJar = tasks. register(' biomeIntegrationTestModJar' , Jar ) {
217+ dependsOn compileBiomeIntegrationTestMod
218+ archiveFileName = ' cakeworldprobe.jar'
219+ destinationDirectory = layout. buildDirectory. dir(' biome-integration-fixture' )
220+ from biomeIntegrationClasses
221+ from ' src/biomeIntegrationTest/resources'
222+ }
223+
224+ def biomeIntegrationRunDirectory = layout. buildDirectory. dir(' biome-integration-run' )
225+ def prepareBiomeIntegrationTest = tasks. register(' prepareBiomeIntegrationTest' ) {
226+ dependsOn biomeIntegrationTestModJar
227+ doLast {
228+ File runDirectory = biomeIntegrationRunDirectory. get(). asFile
229+ delete runDirectory
230+ runDirectory. mkdirs()
231+ copy {
232+ from biomeIntegrationTestModJar. flatMap { it. archiveFile }
233+ into biomeIntegrationRunDirectory. map { it. dir(' mods' ) }
234+ }
235+ new File (runDirectory, ' server.properties' ). setText(''' \
236+ level-name=biome-integration-world
237+ level-seed=-4965128775892001975
238+ level-type=minecraft:normal
239+ online-mode=false
240+ allow-nether=true
241+ generate-structures=false
242+ spawn-protection=0
243+ max-tick-time=-1
244+ ''' , ' UTF-8' )
245+ }
246+ }
247+
248+ tasks. configureEach {
249+ if (name == ' runBiomeIntegrationFresh' ) {
250+ dependsOn prepareBiomeIntegrationTest
251+ } else if (name == ' runBiomeIntegrationReload' ) {
252+ dependsOn ' runBiomeIntegrationFresh'
253+ }
254+ }
255+
256+ def biomeIntegrationTest = tasks. register(' biomeIntegrationTest' ) {
257+ group = ' verification'
258+ description = ' Verifies a provider-owned custom biome in fresh and reloaded normal terrain.'
259+ dependsOn ' runBiomeIntegrationReload'
260+ doLast {
261+ File marker = biomeIntegrationRunDirectory. get(). file(
262+ ' biome-integration-world/cakeworld-biome-integration.properties' ). asFile
263+ if (! marker. isFile()) {
264+ throw new GradleException (" Biome integration completion marker is missing: ${ marker} " )
265+ }
266+ Properties result = new Properties ()
267+ marker. withInputStream { result. load(it) }
268+ if (result. getProperty(' reload_verified' ) != ' true' ) {
269+ throw new GradleException (" Biome integration reload was not verified: ${ marker} " )
270+ }
271+ File eulaFile = biomeIntegrationRunDirectory. get(). file(' eula.txt' ). asFile
272+ if (eulaFile. exists()) {
273+ throw new GradleException (" Biome integration test unexpectedly created an EULA file: ${ eulaFile} " )
274+ }
275+ logger. lifecycle(' Custom-biome integration verified: {} chunks, {} top blocks, {} filler blocks, fresh + reload' ,
276+ result. getProperty(' matching_chunks' ), result. getProperty(' pink_surface' ),
277+ result. getProperty(' white_filler' ))
278+ }
279+ }
280+
281+ tasks. named(' check' ) {
282+ dependsOn biomeIntegrationTest
283+ }
284+
192285idea {
193286 module {
194287 downloadSources = true
0 commit comments