From 16cd3a69661a1750d82c3245d1173279ea575a88 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Tue, 22 Oct 2024 22:19:01 +0200 Subject: [PATCH] Add Canola, Flax and Coffee patches Fix generateQuartz config option having the wrong id --- .../103d9f3f36b01595f1aa5172191e60eff02e6924 | 11 +++++- .../1406a188eb544a1b57b1bc878397d8c7862b79de | 1 - .../20d9b6419a057e67e5bca6ce3a3de93ccc3382bf | 1 + .../neoforge/biome_modifier/add_canola.json | 13 +++++++ .../neoforge/biome_modifier/add_coffee.json | 7 ++++ .../neoforge/biome_modifier/add_flax.json | 13 +++++++ .../configured_feature/canola_patch.json | 33 ++++++++++++++++ .../configured_feature/coffee_patch.json | 33 ++++++++++++++++ .../configured_feature/flax_patch.json | 33 ++++++++++++++++ .../worldgen/placed_feature/canola_patch.json | 25 ++++++++++++ .../worldgen/placed_feature/coffee_patch.json | 25 ++++++++++++ .../worldgen/placed_feature/flax_patch.json | 25 ++++++++++++ .../data/ActuallyAdditionsData.java | 4 +- .../mod/blocks/base/AACrops.java | 13 +++++++ .../mod/config/CommonConfig.java | 8 +++- .../mod/gen/ActuallyBiomeModifiers.java | 24 ++++++++++++ .../mod/gen/ActuallyConfiguredFeatures.java | 22 +++++++++++ .../mod/gen/ActuallyPlacedFeatures.java | 38 +++++++++++++++++++ .../BoolConfigFeatureBiomeModifier.java | 6 +++ 19 files changed, 331 insertions(+), 4 deletions(-) delete mode 100644 src/generated/resources/.cache/1406a188eb544a1b57b1bc878397d8c7862b79de create mode 100644 src/generated/resources/.cache/20d9b6419a057e67e5bca6ce3a3de93ccc3382bf create mode 100644 src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_canola.json create mode 100644 src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_coffee.json create mode 100644 src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_flax.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/configured_feature/canola_patch.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/configured_feature/coffee_patch.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/configured_feature/flax_patch.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/placed_feature/canola_patch.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/placed_feature/coffee_patch.json create mode 100644 src/generated/resources/data/actuallyadditions/worldgen/placed_feature/flax_patch.json diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index ab3e13df1..d08d55f66 100644 --- a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,10 +1,19 @@ -// 1.21.1 2024-08-11T19:30:01.8308187 Registries +// 1.21.1 2024-10-22T22:13:28.2925645 Registries 74628b34b75e1a2fa2ac1f6282b7d9d4e155c254 data/actuallyadditions/banner_pattern/book.json 899dfa1e0d0b15ffc090605543ec144bbfcacc4c data/actuallyadditions/banner_pattern/drill.json 7d9a33a9a151ad83de36e9af8822d08c86137adc data/actuallyadditions/banner_pattern/leaf_blo.json 2e09aca41de0d283a4db78add64744852788bbeb data/actuallyadditions/banner_pattern/phan_con.json 020d2b1f1c21d6c6663ef8126a52e2b9deb0e52e data/actuallyadditions/damage_type/atomicreconstructor.json 4ba41428fdcf03f52855029153722e22e8702823 data/actuallyadditions/neoforge/biome_modifier/add_black_quartz.json +360756e7cd20afc4c6b2ad58b2fd4f37358f2ee6 data/actuallyadditions/neoforge/biome_modifier/add_canola.json +0f06d7aad676a45a4ca187552ac8c4bbd6f1b1b7 data/actuallyadditions/neoforge/biome_modifier/add_coffee.json +1401a66bbf2e1daaa459381103ffba9d02be352d data/actuallyadditions/neoforge/biome_modifier/add_flax.json +dceca4be717b43a4dfc945f62f5c09622604d7f4 data/actuallyadditions/worldgen/configured_feature/canola_patch.json +d56ed72dde226d9ac5eb07fa701f7a3902f1dcf2 data/actuallyadditions/worldgen/configured_feature/coffee_patch.json +9a42d5943e40d102c5e9efee988527da3622d88d data/actuallyadditions/worldgen/configured_feature/flax_patch.json 80765c24aa747df53139d14a9ac3293b4b3eab16 data/actuallyadditions/worldgen/configured_feature/ore_black_quartz.json +0401f9a4edd53ed76536a2c050364a6a442185bd data/actuallyadditions/worldgen/placed_feature/canola_patch.json +d7358c6519319ed3950dcdc34102504c53ccaf22 data/actuallyadditions/worldgen/placed_feature/coffee_patch.json +fb7baf3c1d721832a9b5bcea7ac7dd3ee2c50118 data/actuallyadditions/worldgen/placed_feature/flax_patch.json efb41395b407edbd91712bcb63976de46fed5d04 data/actuallyadditions/worldgen/placed_feature/ore_black_quartz.json 7cf126882346a296f045db75facf741c77b7d3b1 data/actuallyadditions/worldgen/processor_list/engineer_house.json diff --git a/src/generated/resources/.cache/1406a188eb544a1b57b1bc878397d8c7862b79de b/src/generated/resources/.cache/1406a188eb544a1b57b1bc878397d8c7862b79de deleted file mode 100644 index 5721dccc6..000000000 --- a/src/generated/resources/.cache/1406a188eb544a1b57b1bc878397d8c7862b79de +++ /dev/null @@ -1 +0,0 @@ -// 1.21.1 2024-10-22T19:46:05.5548254 Update structure files in /structure diff --git a/src/generated/resources/.cache/20d9b6419a057e67e5bca6ce3a3de93ccc3382bf b/src/generated/resources/.cache/20d9b6419a057e67e5bca6ce3a3de93ccc3382bf new file mode 100644 index 000000000..850451f67 --- /dev/null +++ b/src/generated/resources/.cache/20d9b6419a057e67e5bca6ce3a3de93ccc3382bf @@ -0,0 +1 @@ +// 1.21.1 2024-10-22T20:41:07.9123026 Update structure files in /structure/ diff --git a/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_canola.json b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_canola.json new file mode 100644 index 000000000..b26114828 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_canola.json @@ -0,0 +1,13 @@ +{ + "type": "actuallyadditions:bool_config_feature_modifier", + "biomes": { + "type": "neoforge:or", + "values": [ + "#c:is_hot/overworld", + "#c:is_sparse_vegetation/overworld" + ] + }, + "boolConfig": "generateCanola", + "features": "actuallyadditions:canola_patch", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_coffee.json b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_coffee.json new file mode 100644 index 000000000..17df33b51 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_coffee.json @@ -0,0 +1,7 @@ +{ + "type": "actuallyadditions:bool_config_feature_modifier", + "biomes": "#c:is_hot/overworld", + "boolConfig": "generateCoffee", + "features": "actuallyadditions:coffee_patch", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_flax.json b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_flax.json new file mode 100644 index 000000000..f163b1de9 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/neoforge/biome_modifier/add_flax.json @@ -0,0 +1,13 @@ +{ + "type": "actuallyadditions:bool_config_feature_modifier", + "biomes": { + "type": "neoforge:or", + "values": [ + "#c:is_dense_vegetation/overworld", + "#c:is_cold/overworld" + ] + }, + "boolConfig": "generateFlax", + "features": "actuallyadditions:flax_patch", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/canola_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/canola_patch.json new file mode 100644 index 000000000..296139aff --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/canola_patch.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:random_patch", + "config": { + "feature": { + "feature": { + "type": "minecraft:simple_block", + "config": { + "to_place": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "actuallyadditions:canola", + "Properties": { + "age": "7" + } + } + } + } + }, + "placement": [ + { + "type": "minecraft:block_predicate_filter", + "predicate": { + "type": "minecraft:matching_blocks", + "blocks": "minecraft:air" + } + } + ] + }, + "tries": 10, + "xz_spread": 7, + "y_spread": 3 + } +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/coffee_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/coffee_patch.json new file mode 100644 index 000000000..77b85fc67 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/coffee_patch.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:random_patch", + "config": { + "feature": { + "feature": { + "type": "minecraft:simple_block", + "config": { + "to_place": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "actuallyadditions:coffee", + "Properties": { + "age": "7" + } + } + } + } + }, + "placement": [ + { + "type": "minecraft:block_predicate_filter", + "predicate": { + "type": "minecraft:matching_blocks", + "blocks": "minecraft:air" + } + } + ] + }, + "tries": 6, + "xz_spread": 7, + "y_spread": 3 + } +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/flax_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/flax_patch.json new file mode 100644 index 000000000..ee29d4485 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/configured_feature/flax_patch.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:random_patch", + "config": { + "feature": { + "feature": { + "type": "minecraft:simple_block", + "config": { + "to_place": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "actuallyadditions:flax", + "Properties": { + "age": "7" + } + } + } + } + }, + "placement": [ + { + "type": "minecraft:block_predicate_filter", + "predicate": { + "type": "minecraft:matching_blocks", + "blocks": "minecraft:air" + } + } + ] + }, + "tries": 8, + "xz_spread": 7, + "y_spread": 3 + } +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/canola_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/canola_patch.json new file mode 100644 index 000000000..7a52ec5c7 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/canola_patch.json @@ -0,0 +1,25 @@ +{ + "feature": "actuallyadditions:canola_patch", + "placement": [ + { + "type": "minecraft:rarity_filter", + "chance": 8 + }, + { + "type": "minecraft:noise_threshold_count", + "above_noise": 10, + "below_noise": 5, + "noise_level": -0.8 + }, + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:heightmap", + "heightmap": "WORLD_SURFACE_WG" + }, + { + "type": "minecraft:biome" + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/coffee_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/coffee_patch.json new file mode 100644 index 000000000..07d9a42c7 --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/coffee_patch.json @@ -0,0 +1,25 @@ +{ + "feature": "actuallyadditions:coffee_patch", + "placement": [ + { + "type": "minecraft:rarity_filter", + "chance": 8 + }, + { + "type": "minecraft:noise_threshold_count", + "above_noise": 10, + "below_noise": 5, + "noise_level": -0.8 + }, + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:heightmap", + "heightmap": "WORLD_SURFACE_WG" + }, + { + "type": "minecraft:biome" + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/flax_patch.json b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/flax_patch.json new file mode 100644 index 000000000..01efa804e --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/worldgen/placed_feature/flax_patch.json @@ -0,0 +1,25 @@ +{ + "feature": "actuallyadditions:flax_patch", + "placement": [ + { + "type": "minecraft:rarity_filter", + "chance": 8 + }, + { + "type": "minecraft:noise_threshold_count", + "above_noise": 10, + "below_noise": 5, + "noise_level": -0.8 + }, + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:heightmap", + "heightmap": "WORLD_SURFACE_WG" + }, + { + "type": "minecraft:biome" + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java index a8c580497..b444484b0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java @@ -20,6 +20,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.world.damagesource.DamageType; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModList; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; @@ -67,7 +68,8 @@ public class ActuallyAdditionsData { generator.addProvider(true, new SoundsGenerator(packOutput, helper)); - generator.addProvider(true, new PatchouliGenerator(packOutput, lookupProvider)); + if (ModList.get().isLoaded("patchouli")) + generator.addProvider(true, new PatchouliGenerator(packOutput, lookupProvider)); generator.addProvider(true, new GlobalLootModifierGenerator(packOutput, lookupProvider)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java index c314c6c3c..8bd81923d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java @@ -1,8 +1,13 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.tags.BlockTags; import net.minecraft.world.item.Item; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; import java.util.function.Supplier; @@ -17,4 +22,12 @@ public class AACrops extends CropBlock { protected ItemLike getBaseSeedId() { return this.itemSupplier.get(); } + + @Override + protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { + if (level instanceof WorldGenRegion) { + return state.is(BlockTags.DIRT); + } + return super.mayPlaceOn(state, level, pos); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java index 62a8b319f..26c132405 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java @@ -72,11 +72,17 @@ public class CommonConfig { public static class Worldgen { public static ModConfigSpec.BooleanValue GENERATE_QUARTZ; + public static ModConfigSpec.BooleanValue GENERATE_CANOLA; + public static ModConfigSpec.BooleanValue GENERATE_FLAX; + public static ModConfigSpec.BooleanValue GENERATE_COFFEE; public static void build() { BUILDER.comment("Worldgen Settings").push("worldgenSettings"); - GENERATE_QUARTZ = BUILDER.comment("Should Black Quartz generate in the world?").define("laserRelayLoss", true); + GENERATE_QUARTZ = BUILDER.comment("Should Black Quartz generate in the world?").define("generateQuartz", true); + GENERATE_CANOLA = BUILDER.comment("Should Canola generate in the World?").define("generateCanola", true); + GENERATE_FLAX = BUILDER.comment("Should Flax generate in the world?").define("generateFlax", true); + GENERATE_COFFEE = BUILDER.comment("Should Coffee generate in the world?").define("generateCoffee", true); BUILDER.pop(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java index e2d49f8fc..903725f37 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java @@ -16,11 +16,14 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.common.conditions.ICondition; import net.neoforged.neoforge.common.world.BiomeModifier; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; +import net.neoforged.neoforge.registries.holdersets.AndHolderSet; +import net.neoforged.neoforge.registries.holdersets.OrHolderSet; import java.util.function.Supplier; @@ -46,6 +49,12 @@ public final class ActuallyBiomeModifiers { protected static final ResourceKey ADD_BLACK_QUARTZ_ORE_MODIFIER = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ActuallyAdditions.modLoc("add_black_quartz")); + protected static final ResourceKey ADD_CANOLA = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, + ActuallyAdditions.modLoc("add_canola")); + protected static final ResourceKey ADD_FLAX = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, + ActuallyAdditions.modLoc("add_flax")); + protected static final ResourceKey ADD_COFFEE = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, + ActuallyAdditions.modLoc("add_coffee")); public static void bootstrap(BootstrapContext context) { HolderGetter biomeGetter = context.lookup(Registries.BIOME); @@ -58,5 +67,20 @@ public final class ActuallyBiomeModifiers { HolderSet.direct(placedGetter.getOrThrow(ActuallyPlacedFeatures.PLACED_ORE_BLACK_QUARTZ)), GenerationStep.Decoration.UNDERGROUND_ORES, "generateQuartz" )); + context.register(ADD_CANOLA, new BoolConfigFeatureBiomeModifier( + new OrHolderSet<>(biomeGetter.getOrThrow(Tags.Biomes.IS_HOT_OVERWORLD), biomeGetter.getOrThrow(Tags.Biomes.IS_SPARSE_VEGETATION_OVERWORLD)), + HolderSet.direct(placedGetter.getOrThrow(ActuallyPlacedFeatures.CANOLA_PATCH)), + GenerationStep.Decoration.VEGETAL_DECORATION, "generateCanola" + )); + context.register(ADD_FLAX, new BoolConfigFeatureBiomeModifier( + new OrHolderSet<>(biomeGetter.getOrThrow(Tags.Biomes.IS_DENSE_VEGETATION_OVERWORLD), biomeGetter.getOrThrow(Tags.Biomes.IS_COLD_OVERWORLD)), + HolderSet.direct(placedGetter.getOrThrow(ActuallyPlacedFeatures.FLAX_PATCH)), + GenerationStep.Decoration.VEGETAL_DECORATION, "generateFlax" + )); + context.register(ADD_COFFEE, new BoolConfigFeatureBiomeModifier( + biomeGetter.getOrThrow(Tags.Biomes.IS_HOT_OVERWORLD), + HolderSet.direct(placedGetter.getOrThrow(ActuallyPlacedFeatures.COFFEE_PATCH)), + GenerationStep.Decoration.VEGETAL_DECORATION, "generateCoffee" + )); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java index 5b6c2cd6c..826eb21f3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java @@ -1,15 +1,24 @@ package de.ellpeck.actuallyadditions.mod.gen; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlock; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.blocks.base.AACrops; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.BlockTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; @@ -17,6 +26,9 @@ import java.util.List; public class ActuallyConfiguredFeatures { public static final ResourceKey> ORE_BLACK_QUARTZ = createKey("ore_black_quartz"); + public static final ResourceKey> CANOLA_PATCH = createKey("canola_patch"); + public static final ResourceKey> FLAX_PATCH = createKey("flax_patch"); + public static final ResourceKey> COFFEE_PATCH = createKey("coffee_patch"); public static void bootstrap(BootstrapContext> context) { RuleTest stoneRuleTest = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); @@ -26,6 +38,16 @@ public class ActuallyConfiguredFeatures { OreConfiguration.target(deepslateRuleTest, ActuallyBlocks.BLACK_QUARTZ_ORE.get().defaultBlockState()) ); FeatureUtils.register(context, ORE_BLACK_QUARTZ, Feature.ORE, new OreConfiguration(list, 6)); + FeatureUtils.register(context, CANOLA_PATCH, Feature.RANDOM_PATCH, plantPatch(ActuallyBlocks.CANOLA.get(), 10)); + FeatureUtils.register(context, FLAX_PATCH, Feature.RANDOM_PATCH, plantPatch(ActuallyBlocks.FLAX.get(), 8)); + FeatureUtils.register(context, COFFEE_PATCH, Feature.RANDOM_PATCH, plantPatch(ActuallyBlocks.COFFEE.get(), 6)); + } + + private static RandomPatchConfiguration plantPatch(Block crop, int tries) { + BlockStateProvider stateProvider = BlockStateProvider.simple(crop.defaultBlockState().setValue(AACrops.AGE, AACrops.MAX_AGE)); + return FeatureUtils.simpleRandomPatchConfiguration( + tries, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(stateProvider)) + ); } private static ResourceKey> createKey(String name) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java index 77bfa7893..9df7d7a3f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java @@ -4,27 +4,65 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.data.worldgen.features.VegetationFeatures; import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.Rarity; import net.minecraft.world.level.levelgen.VerticalAnchor; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.placement.BiomeFilter; import net.minecraft.world.level.levelgen.placement.CountPlacement; import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; import net.minecraft.world.level.levelgen.placement.InSquarePlacement; +import net.minecraft.world.level.levelgen.placement.NoiseThresholdCountPlacement; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacementModifier; +import net.minecraft.world.level.levelgen.placement.RarityFilter; import java.util.List; public class ActuallyPlacedFeatures { public static final ResourceKey PLACED_ORE_BLACK_QUARTZ = createKey("ore_black_quartz"); + public static final ResourceKey CANOLA_PATCH = createKey("canola_patch"); + public static final ResourceKey FLAX_PATCH = createKey("flax_patch"); + public static final ResourceKey COFFEE_PATCH = createKey("coffee_patch"); public static void bootstrap(BootstrapContext context) { HolderGetter> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE); PlacementUtils.register(context, PLACED_ORE_BLACK_QUARTZ, holdergetter.getOrThrow(ActuallyConfiguredFeatures.ORE_BLACK_QUARTZ), commonOrePlacement(8, HeightRangePlacement.triangle(VerticalAnchor.absolute(-25), VerticalAnchor.absolute(45)))); + + PlacementUtils.register( + context, + CANOLA_PATCH, + holdergetter.getOrThrow(ActuallyConfiguredFeatures.CANOLA_PATCH), + RarityFilter.onAverageOnceEvery(8), + NoiseThresholdCountPlacement.of(-0.8, 5, 10), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome() + ); + PlacementUtils.register( + context, + FLAX_PATCH, + holdergetter.getOrThrow(ActuallyConfiguredFeatures.FLAX_PATCH), + RarityFilter.onAverageOnceEvery(8), + NoiseThresholdCountPlacement.of(-0.8, 5, 10), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome() + ); + PlacementUtils.register( + context, + COFFEE_PATCH, + holdergetter.getOrThrow(ActuallyConfiguredFeatures.COFFEE_PATCH), + RarityFilter.onAverageOnceEvery(8), + NoiseThresholdCountPlacement.of(-0.8, 5, 10), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome() + ); } private static List orePlacement(PlacementModifier modifier, PlacementModifier modifier1) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java index 935479932..6f5412af6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java @@ -29,6 +29,12 @@ public record BoolConfigFeatureBiomeModifier(HolderSet biomes, HolderSet< return true; case "generateQuartz": return CommonConfig.Worldgen.GENERATE_QUARTZ.get(); + case "generateCanola": + return CommonConfig.Worldgen.GENERATE_CANOLA.get(); + case "generateFlax": + return CommonConfig.Worldgen.GENERATE_FLAX.get(); + case "generateCoffee": + return CommonConfig.Worldgen.GENERATE_COFFEE.get(); } }