44import com .mojang .serialization .MapCodec ;
55import java .util .List ;
66import java .util .Random ;
7+ import java .util .Set ;
78import java .util .concurrent .CompletableFuture ;
89import java .util .function .Function ;
910import net .minecraft .core .BlockPos ;
3637import net .minecraft .world .level .levelgen .RandomState ;
3738import net .minecraft .world .level .levelgen .WorldgenRandom ;
3839import net .minecraft .world .level .levelgen .blending .Blender ;
40+ import net .minecraft .world .level .levelgen .densityfunction .SamplerContext ;
3941import net .minecraft .world .level .levelgen .structure .templatesystem .StructureTemplateManager ;
4042import org .bukkit .block .Biome ;
4143import org .bukkit .craftbukkit .CraftHeightMap ;
4446import org .bukkit .generator .ChunkGenerator ;
4547import org .bukkit .generator .ChunkGenerator .BiomeGrid ;
4648import org .bukkit .generator .ChunkGenerator .ChunkData ;
49+ import org .jspecify .annotations .Nullable ;
4750
4851public class CustomChunkGenerator extends InternalChunkGenerator {
4952
@@ -133,15 +136,16 @@ public void createStructures(RegistryAccess registryAccess, ChunkGeneratorStruct
133136 }
134137 }
135138
136- @ Override
139+ // TODO - snapshot - this was moved into NoiseChunkGenerator so...
137140 public void buildSurface (WorldGenRegion level , StructureManager structureManager , RandomState randomState , ChunkAccess protoChunk ) {
138141 WorldgenRandom random = getSeededRandom ();
139142 int x = protoChunk .getPos ().x ();
140143 int z = protoChunk .getPos ().z ();
141144
142145 random .setSeed (Mth .getSeed (x , "should-surface" .hashCode (), z ) ^ level .getSeed ());
143146 if (this .generator .shouldGenerateSurface (this .world .getWorld (), new RandomSourceWrapper .RandomWrapper (random ), x , z )) {
144- this .delegate .buildSurface (level , structureManager , randomState , protoChunk );
147+ // TODO - snapshot
148+ //this.delegate.buildSurface(level, structureManager, randomState, protoChunk);
145149 }
146150
147151 CraftChunkData chunkData = new CraftChunkData (this .world .getWorld (), protoChunk );
@@ -231,15 +235,16 @@ public void buildSurface(WorldGenRegion level, StructureManager structureManager
231235 }
232236 }
233237
234- @ Override
238+ // TODO - snapshot - this no longer exists?
235239 public void applyCarvers (WorldGenRegion region , long seed , RandomState randomState , BiomeManager biomeManager , StructureManager structureManager , ChunkAccess chunk ) {
236240 WorldgenRandom random = getSeededRandom ();
237241 int x = chunk .getPos ().x ();
238242 int z = chunk .getPos ().z ();
239243
240244 random .setSeed (Mth .getSeed (x , "should-caves" .hashCode (), z ) ^ region .getSeed ());
241245 if (this .generator .shouldGenerateCaves (this .world .getWorld (), new RandomSourceWrapper .RandomWrapper (random ), x , z )) {
242- this .delegate .applyCarvers (region , seed , randomState , biomeManager , structureManager , chunk );
246+ // TODO - snapshot
247+ //this.delegate.applyCarvers(region, seed, randomState, biomeManager, structureManager, chunk);
243248 }
244249
245250 // Minecraft removed the LIQUID_CARVERS stage from world generation, without removing the LIQUID Carving enum.
@@ -252,27 +257,35 @@ public void applyCarvers(WorldGenRegion region, long seed, RandomState randomSta
252257 }
253258
254259 @ Override
255- public CompletableFuture <ChunkAccess > fillFromNoise (Blender blender , RandomState randomState , StructureManager structureManager , ChunkAccess centerChunk ) {
260+ public CompletableFuture <ChunkAccess > buildTerrain (
261+ final ChunkAccess chunk ,
262+ final Blender blender ,
263+ final RandomState randomState ,
264+ final StructureManager structureManager ,
265+ final BiomeManager biomeManager ,
266+ final @ Nullable WorldGenRegion carverBiomeRegion ,
267+ final Set <Holder <net .minecraft .world .level .biome .Biome >> possibleBiomes
268+ ) {
256269 CompletableFuture <ChunkAccess > future = null ;
257270 WorldgenRandom random = getSeededRandom ();
258- int x = centerChunk .getPos ().x ();
259- int z = centerChunk .getPos ().z ();
271+ int x = chunk .getPos ().x ();
272+ int z = chunk .getPos ().z ();
260273
261274 random .setSeed (Mth .getSeed (x , "should-noise" .hashCode (), z ) ^ this .world .getSeed ());
262275 if (this .generator .shouldGenerateNoise (this .world .getWorld (), new RandomSourceWrapper .RandomWrapper (random ), x , z )) {
263- future = this .delegate .fillFromNoise ( blender , randomState , structureManager , centerChunk );
276+ future = this .delegate .buildTerrain ( chunk , blender , randomState , structureManager , biomeManager , carverBiomeRegion , possibleBiomes );
264277 }
265278
266- Function <ChunkAccess , ChunkAccess > work = chunk -> {
267- CraftChunkData chunkData = new CraftChunkData (this .world .getWorld (), chunk );
279+ Function <ChunkAccess , ChunkAccess > work = chunkAccess -> {
280+ CraftChunkData chunkData = new CraftChunkData (this .world .getWorld (), chunkAccess );
268281 random .setLargeFeatureWithSalt (INITIAL_SEED , x , z , 0 );
269282
270283 this .generator .generateNoise (this .world .getWorld (), new RandomSourceWrapper .RandomWrapper (random ), x , z , chunkData );
271284 chunkData .breakLink ();
272- return chunk ;
285+ return chunkAccess ;
273286 };
274287
275- return future == null ? CompletableFuture .supplyAsync (() -> work .apply (centerChunk ), io .papermc .paper .FeatureHooks .getWorldgenExecutor ()) : future .thenApply (work ); // Paper - chunk system
288+ return future == null ? CompletableFuture .supplyAsync (() -> work .apply (chunk ), io .papermc .paper .FeatureHooks .getWorldgenExecutor ()) : future .thenApply (work ); // Paper - chunk system
276289 }
277290
278291 @ Override
@@ -292,8 +305,8 @@ public int getBaseHeight(int x, int z, Heightmap.Types type, LevelHeightAccessor
292305 }
293306
294307 @ Override
295- public WeightedList <MobSpawnSettings .SpawnerData > getMobsAt (Holder < net . minecraft . world . level . biome . Biome > biome , StructureManager structureManager , MobCategory mobCategory , BlockPos pos ) {
296- return this .delegate .getMobsAt (biome , structureManager , mobCategory , pos );
308+ public WeightedList <MobSpawnSettings .SpawnerData > getMobsAt (final Level level , StructureManager structureManager , MobCategory mobCategory , BlockPos pos ) {
309+ return this .delegate .getMobsAt (level , structureManager , mobCategory , pos );
297310 }
298311
299312 @ Override
@@ -307,8 +320,8 @@ public void applyBiomeDecoration(WorldGenLevel level, ChunkAccess chunk, Structu
307320 }
308321
309322 @ Override
310- public void addDebugScreenInfo (List <String > result , RandomState randomState , BlockPos feetPos ) {
311- this .delegate .addDebugScreenInfo (result , randomState , feetPos );
323+ public void addDebugScreenInfo (List <String > result , RandomState randomState , BlockPos feetPos , SamplerContext samplerContext ) {
324+ this .delegate .addDebugScreenInfo (result , randomState , feetPos , samplerContext );
312325 }
313326
314327 @ Override
0 commit comments