Last active
June 21, 2022 12:49
-
-
Save desht/0ff85e5b4555e5e2fce17c18c61d1a2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void oilLakeDatagen(GatherDataEvent event, DataGenerator generator, ExistingFileHelper existingFileHelper, RegistryOps<JsonElement> registryOps) { | |
// oil lake configured feature | |
ConfiguredFeature<?,?> oilLakeCF = new ConfiguredFeature<>( | |
Feature.LAKE, | |
new LakeFeature.Configuration( | |
BlockStateProvider.simple(ModBlocks.OIL.get().defaultBlockState()), | |
BlockStateProvider.simple(Blocks.AIR.defaultBlockState()) | |
) | |
); | |
JsonCodecProvider<ConfiguredFeature<?,?>> cfProvider = JsonCodecProvider.forDatapackRegistry( | |
generator, existingFileHelper, Names.MOD_ID, registryOps, Registry.CONFIGURED_FEATURE_REGISTRY, Map.of( | |
OIL_LAKE_RL, oilLakeCF | |
) | |
); | |
generator.addProvider(event.includeServer(), cfProvider); | |
// surface & underground oil lake placed features | |
var oilLakeKey = ResourceKey.create(Registry.CONFIGURED_FEATURE_REGISTRY, OIL_LAKE_RL); | |
var oilLakeHolder = registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).orElseThrow().getOrCreateHolderOrThrow(oilLakeKey); | |
PlacedFeature oilLakeSurface = new PlacedFeature(oilLakeHolder, ImmutableList.of( | |
RarityFilter.onAverageOnceEvery(25), | |
InSquarePlacement.spread(), | |
PlacementUtils.HEIGHTMAP_WORLD_SURFACE, | |
BiomeFilter.biome()) | |
); | |
PlacedFeature oilLakeUnderground = new PlacedFeature(oilLakeHolder, ImmutableList.of( | |
RarityFilter.onAverageOnceEvery(6), | |
InSquarePlacement.spread(), | |
HeightRangePlacement.of(UniformHeight.of(VerticalAnchor.absolute(0), VerticalAnchor.top())), | |
EnvironmentScanPlacement.scanningFor(Direction.DOWN, BlockPredicate.allOf( | |
BlockPredicate.not(BlockPredicate.ONLY_IN_AIR_PREDICATE), | |
BlockPredicate.insideWorld(new BlockPos(0, -5, 0)) | |
), 32 | |
), | |
SurfaceRelativeThresholdFilter.of(Heightmap.Types.OCEAN_FLOOR_WG, Integer.MIN_VALUE, -5), | |
BiomeFilter.biome()) | |
); | |
JsonCodecProvider<PlacedFeature> pfProvider = JsonCodecProvider.forDatapackRegistry( | |
generator, existingFileHelper, Names.MOD_ID, registryOps, Registry.PLACED_FEATURE_REGISTRY, Map.of( | |
OIL_LAKE_SURFACE_RL, oilLakeSurface, | |
OIL_LAKE_UNDERGROUND_RL, oilLakeUnderground | |
) | |
); | |
generator.addProvider(event.includeServer(), pfProvider); | |
// biome modifiers | |
ResourceKey<PlacedFeature> oilLakeSurfaceKey = ResourceKey.create(Registry.PLACED_FEATURE_REGISTRY, OIL_LAKE_SURFACE_RL); | |
BiomeModifier surfaceModifier = new ForgeBiomeModifiers.AddFeaturesBiomeModifier( | |
registryOps.registry(Registry.BIOME_REGISTRY).orElseThrow().getOrCreateTag(BiomeTags.IS_OVERWORLD), | |
HolderSet.direct(registryOps.registry(Registry.PLACED_FEATURE_REGISTRY).orElseThrow().getOrCreateHolderOrThrow(oilLakeSurfaceKey)), | |
GenerationStep.Decoration.LAKES | |
); | |
ResourceKey<PlacedFeature> oilLakeUndergroundKey = ResourceKey.create(Registry.PLACED_FEATURE_REGISTRY, OIL_LAKE_SURFACE_RL); | |
BiomeModifier undergroundModifier = new ForgeBiomeModifiers.AddFeaturesBiomeModifier( | |
registryOps.registry(Registry.BIOME_REGISTRY).orElseThrow().getOrCreateTag(BiomeTags.IS_OVERWORLD), | |
HolderSet.direct(registryOps.registry(Registry.PLACED_FEATURE_REGISTRY).orElseThrow().getOrCreateHolderOrThrow(oilLakeUndergroundKey)), | |
GenerationStep.Decoration.LAKES | |
); | |
JsonCodecProvider<BiomeModifier> bmProvider = JsonCodecProvider.forDatapackRegistry( | |
generator, existingFileHelper, Names.MOD_ID, registryOps, ForgeRegistries.Keys.BIOME_MODIFIERS, Map.of( | |
OIL_LAKE_SURFACE_RL, surfaceModifier, | |
OIL_LAKE_UNDERGROUND_RL, undergroundModifier | |
) | |
); | |
generator.addProvider(event.includeServer(), bmProvider); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment