Ported add-on support from TerraPlusPlus #62
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pipeline
This PR ports the same addon support system from TerraPlusPlus. This is done by introducing
RealWorldGeneratorPipelines, inspired byEarthGeneratorPipelinesfrom T++. Said class calls the events via Bukkit'sPluginManager, to which other plugins can listen and add their own custom functionality. These events are the following:InitRealDatasetsEventfor custom datasetsInitRealBiomeFilterRegistryEventfor custom biome filtersInitRealEarthDataBakerRegistryEventfor custom data bakersInitRealWorldPopulatorRegistryEventfor custom populatorsThese are then collected, alongside the built-in ones (Like the
KoppenBiomeFilteror the legacyTerra121BiomeFilter, depending on the config -biomes.legacy_dataset- both registered under the keybiome_filter), and passed to the generator. The generator initialises the T-- pipeline that gets passed to the cache loaderChunkDataLoaderused by the single cache inRealWorldGenerator. This eliminates the need for other functionalities, ex,TreePopulatorto hold their own chunk data cache and other info that the generator holds.Custom biome provider
The previous biome provider now becomes a proper biome filter and is moved to
KoppenBiomeFilter. This enables the new biome filter to receive the chunk data from T-- pipeline and transform the data to bukkit biome via T--TerraBukkik.Tree populator
The class
TreePopulatorgets moved to the packagegen.populate.tree(as well asTreeBlock) and extends the new classRealWorldPopulator. To receive the biome at a location via the custom biome provider, it receives the generator via dependency injection. Tree populator is registered under thetreeskey in the pipeline, same as in T++.Real-world populator
All block populators must extend the new class
RealWorldPopulator. The said class receives the generator via dependency injection, which then gets passed to the new abstracts populate method with the following signature:The abstract method must be implemented, as it gets called by the default
BlockPopulator::populatemethod.Full changelog:
run-paper-maven-plugin, for easier debuggingCustomBiomeProvider:KoppenBiomeFilter, which gets used innet.buildtheearth.terraminusminus.generator.EarthBiomeProviderEarthBiomeProviderpopulatesCachedChunkData, which gets indirectly acquired viaRealWorldGenerator::getTerraChunkDataand converted to a bukkit biome vianet.buildtheearth.terraminusminus.substitutes.TerraBukkitRealWorldGeneratorPipelines:IEarthDataBaker), biome filters (IEarthBiomeFilter), and block populators (RealWorldPopulator) must be first called viaBukkit::getPluginManager::callEventInitRealDatasetsEventIEarthDataBaker,IEarthBiomeFilterandRealWorldPopulatormust be registered viaInitRealEarthRegistryEventKoppenClimateDatashould now be included in theGeneratorDatasetsRealWorldGeneratorPipelines::biomeFiltersshould by default returnKoppenBiomeFilteror the legacyTerra121BiomeFilterregistered on the key"biome_filter"depending on the config (
"biomes.legacy_dataset"option) and theUserOverrideBiomeFilter, registered under the key"biome_overrides"RealWorldGenerator:CachedChunkDatato be initialised directly via the returnedGeneratorDatasets,IEarthBiomeFilter’sfromRealWorldGeneratorPipelines,and change
TerraMinusMinus:EarthBiomeProviderto be directly initialised viaGeneratorDatasetsandIEarthBiomeFilter’s(viaRealWorldGeneratorPipelines::biomeFilters)GeneratorDatasets,EarthBiomeProvider,RealWorldPopulator's (BlockPopulator)andTerraplusminusinstance insideRealWorldGeneratorgetTerraChunkDataAsyncto returnCachedChunkDatafrom the cache asyncCustomBiomeProviderand port it toTerraPlusMinusBiomeFilter (IEarthBiomeFilter)UserOverrideBiomeFilterto enable overriding biomes the same way as in TerraPlusPlusRealWorldPopulator (BlockPopulator):CachedChunkDatafromRealWorldGeneratormust extend this class and override the second populate methodinstead of the default populate method
populatemethod to get theCachedChunkDatafromRealWorldGenerator, and pass it over alongside other parameters to the second populate method