From 327b94d7cdbddf35f3709bd9c6aa2615007ef627 Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Sat, 11 Jan 2025 21:41:59 +0100 Subject: [PATCH] Improve world generation - Code cleanup - Granite, Andesite and Diorite Rocks now have a chance to generate everywhere - Spruce sticks can now generate on top of snow blocks - Biome exclusion list (closes #32) --- .../generated/assets/rocks/lang/de_de.json | 4 + .../generated/assets/rocks/lang/en_us.json | 4 + .../worldgen/configured_feature/rock_mix.json | 118 ++++++++++++ .../worldgen/placed_feature/rock_mix.json | 170 +++++++++++++++++ .../worldgen/placed_feature/spruce_stick.json | 2 +- .../motschen/rocks/RocksDataGen.java | 3 +- .../motschen/rocks/config/RocksConfig.java | 5 + .../motschen/rocks/datagen/Language.java | 13 +- .../motschen/rocks/world/FeatureInjector.java | 57 +++--- .../configured_feature/NetherFeatures.java | 43 +---- .../configured_feature/RockFeatures.java | 173 +++++++++--------- .../configured_feature/StickFeatures.java | 3 +- 12 files changed, 437 insertions(+), 158 deletions(-) create mode 100644 src/main/generated/data/rocks/worldgen/configured_feature/rock_mix.json create mode 100644 src/main/generated/data/rocks/worldgen/placed_feature/rock_mix.json diff --git a/src/main/generated/assets/rocks/lang/de_de.json b/src/main/generated/assets/rocks/lang/de_de.json index 41ad822..4638f97 100644 --- a/src/main/generated/assets/rocks/lang/de_de.json +++ b/src/main/generated/assets/rocks/lang/de_de.json @@ -66,6 +66,8 @@ "item.rocks.starfish": "Seestern", "item.rocks.warped_stick": "Wirrstock", "itemGroup.rocks.rocks": "This Rocks!", + "rocks.midnightconfig.biomeExclusions": "Ausgeschlosene Biome", + "rocks.midnightconfig.biomeExclusions.tooltip": "In diesen Biomen werden keine Features der Mod generiert.\nFormat: modid:biome_name", "rocks.midnightconfig.category.effects": "Effekte", "rocks.midnightconfig.category.misc": "Sonstiges", "rocks.midnightconfig.category.rocks": "Brocken", @@ -78,6 +80,8 @@ "rocks.midnightconfig.needs_restart2": "§cStarte das Spiel neu, nachdem du Änderungen vorgenommen hast!", "rocks.midnightconfig.netherGeyserDamage": "Nether Geysir Schaden", "rocks.midnightconfig.polymerViewDistance": "Polymer-Sichtweite", + "rocks.midnightconfig.rockMix": "Gemischte Brocken", + "rocks.midnightconfig.rockMix.tooltip": "Fügt kleine Mengen an Granit-, Andesit- und Diorit-Brocken zu allen Biomen hinzu", "rocks.midnightconfig.title": "This Rocks! Config", "rocks.midnightconfig.underwaterSeashell": "Unterwasser-Muschel", "rocks.midnightconfig.underwaterStarfish": "Unterwasser-Seestern" diff --git a/src/main/generated/assets/rocks/lang/en_us.json b/src/main/generated/assets/rocks/lang/en_us.json index 4b79bf4..08ab90f 100644 --- a/src/main/generated/assets/rocks/lang/en_us.json +++ b/src/main/generated/assets/rocks/lang/en_us.json @@ -66,6 +66,8 @@ "item.rocks.starfish": "Starfish", "item.rocks.warped_stick": "Warped Stick", "itemGroup.rocks.rocks": "This Rocks!", + "rocks.midnightconfig.biomeExclusions": "Excluded biomes", + "rocks.midnightconfig.biomeExclusions.tooltip": "No feature will generate in these biomes.\nFormat: modid:biome_name", "rocks.midnightconfig.category.effects": "Effects", "rocks.midnightconfig.category.misc": "Miscellaneous", "rocks.midnightconfig.category.rocks": "Rocks", @@ -78,6 +80,8 @@ "rocks.midnightconfig.needs_restart2": "§cRestart the game after changing options here!", "rocks.midnightconfig.netherGeyserDamage": "Nether Geyser Damage", "rocks.midnightconfig.polymerViewDistance": "Polymer View Distance", + "rocks.midnightconfig.rockMix": "Mixed Rocks", + "rocks.midnightconfig.rockMix.tooltip": "Adds small batches of Granite, Andesite and Diorite rocks to all biomes", "rocks.midnightconfig.title": "This Rocks! Config", "rocks.midnightconfig.underwaterSeashell": "Underwater Seashell", "rocks.midnightconfig.underwaterStarfish": "Underwater Starfish" diff --git a/src/main/generated/data/rocks/worldgen/configured_feature/rock_mix.json b/src/main/generated/data/rocks/worldgen/configured_feature/rock_mix.json new file mode 100644 index 0000000..49159ee --- /dev/null +++ b/src/main/generated/data/rocks/worldgen/configured_feature/rock_mix.json @@ -0,0 +1,118 @@ +{ + "type": "minecraft:simple_block", + "config": { + "to_place": { + "type": "minecraft:weighted_state_provider", + "entries": [ + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + } + ] + } + } +} \ No newline at end of file diff --git a/src/main/generated/data/rocks/worldgen/placed_feature/rock_mix.json b/src/main/generated/data/rocks/worldgen/placed_feature/rock_mix.json new file mode 100644 index 0000000..0ee562f --- /dev/null +++ b/src/main/generated/data/rocks/worldgen/placed_feature/rock_mix.json @@ -0,0 +1,170 @@ +{ + "feature": { + "type": "minecraft:simple_block", + "config": { + "to_place": { + "type": "minecraft:weighted_state_provider", + "entries": [ + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:granite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:diorite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "tiny" + } + }, + "weight": 10 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "small" + } + }, + "weight": 7 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "medium" + } + }, + "weight": 5 + }, + { + "data": { + "Name": "rocks:andesite_rock", + "Properties": { + "variation": "large" + } + }, + "weight": 1 + } + ] + } + } + }, + "placement": [ + { + "type": "minecraft:count", + "count": 3 + }, + { + "type": "minecraft:rarity_filter", + "chance": 1 + }, + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:heightmap", + "heightmap": "WORLD_SURFACE_WG" + }, + { + "type": "minecraft:biome" + }, + { + "type": "minecraft:block_predicate_filter", + "predicate": { + "type": "minecraft:all_of", + "predicates": [ + { + "type": "minecraft:matching_blocks", + "blocks": "minecraft:air" + }, + { + "type": "minecraft:not", + "predicate": { + "type": "minecraft:matching_blocks", + "blocks": [ + "minecraft:ice", + "minecraft:packed_ice", + "minecraft:sand", + "minecraft:red_sand", + "minecraft:end_stone" + ], + "offset": [ + 0, + -1, + 0 + ] + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/rocks/worldgen/placed_feature/spruce_stick.json b/src/main/generated/data/rocks/worldgen/placed_feature/spruce_stick.json index 831fd11..e13dd50 100644 --- a/src/main/generated/data/rocks/worldgen/placed_feature/spruce_stick.json +++ b/src/main/generated/data/rocks/worldgen/placed_feature/spruce_stick.json @@ -71,7 +71,7 @@ "type": "minecraft:matching_blocks", "blocks": [ "minecraft:grass_block", - "minecraft:mud", + "minecraft:snow_block", "minecraft:podzol" ], "offset": [ diff --git a/src/main/java/eu/midnightdust/motschen/rocks/RocksDataGen.java b/src/main/java/eu/midnightdust/motschen/rocks/RocksDataGen.java index ba9b412..d43b515 100644 --- a/src/main/java/eu/midnightdust/motschen/rocks/RocksDataGen.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/RocksDataGen.java @@ -35,9 +35,10 @@ public class RocksDataGen implements DataGeneratorEntrypoint { @Override public void buildRegistry(RegistryBuilder registryBuilder) { + RockFeatures.init(); registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, RockFeatures::initConfigured); registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, RockFeatures::initPlaced); - StickFeatures.initFeatures(); + StickFeatures.init(); registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, StickFeatures::initConfigured); registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, StickFeatures::initPlaced); registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, NetherFeatures::initConfigured); diff --git a/src/main/java/eu/midnightdust/motschen/rocks/config/RocksConfig.java b/src/main/java/eu/midnightdust/motschen/rocks/config/RocksConfig.java index 30c3b1d..c060cfe 100755 --- a/src/main/java/eu/midnightdust/motschen/rocks/config/RocksConfig.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/config/RocksConfig.java @@ -2,11 +2,15 @@ package eu.midnightdust.motschen.rocks.config; import eu.midnightdust.lib.config.MidnightConfig; +import java.util.ArrayList; +import java.util.List; + public class RocksConfig extends MidnightConfig { public final static String rocks = "rocks"; @Comment(category = rocks, centered = true) public static Comment needs_restart; @Entry(category = rocks, name = "block.rocks.rock") public static boolean rock = true; + @Entry(category = rocks) public static boolean rockMix = true; @Entry(category = rocks, name = "block.rocks.granite_rock") public static boolean graniteRock = true; @Entry(category = rocks, name = "block.rocks.diorite_rock") public static boolean dioriteRock = true; @Entry(category = rocks, name = "block.rocks.andesite_rock") public static boolean andesiteRock = true; @@ -49,4 +53,5 @@ public class RocksConfig extends MidnightConfig { @Entry(category = effects) public static boolean enablePolymerMode = true; @Entry(category = effects, requiredMod = "factorytools", min = 0, max = 200, isSlider = true) public static int polymerViewDistance = 100; + @Entry(category = effects) public static List biomeExclusions = new ArrayList<>(); } diff --git a/src/main/java/eu/midnightdust/motschen/rocks/datagen/Language.java b/src/main/java/eu/midnightdust/motschen/rocks/datagen/Language.java index e5a4028..d59b1bd 100644 --- a/src/main/java/eu/midnightdust/motschen/rocks/datagen/Language.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/datagen/Language.java @@ -112,11 +112,17 @@ public abstract class Language extends FabricLanguageProvider { midnightconfig(translationBuilder, key, "§cRestart the game after changing options here!"); } + midnightconfig(translationBuilder, "rockMix", "Mixed Rocks"); + midnightconfig(translationBuilder, "rockMix.tooltip", "Adds small batches of Granite, Andesite and Diorite rocks to all biomes"); midnightconfig(translationBuilder, "underwaterSeashell", "Underwater Seashell"); midnightconfig(translationBuilder, "underwaterStarfish", "Underwater Starfish"); midnightconfig(translationBuilder, "geyserLevitation", "Geyser Levitation"); midnightconfig(translationBuilder, "netherGeyserDamage", "Nether Geyser Damage"); + + midnightconfig(translationBuilder, "biomeExclusions", "Excluded biomes"); + midnightconfig(translationBuilder, "biomeExclusions.tooltip", "No feature will generate in these biomes.\nFormat: modid:biome_name"); + midnightconfig(translationBuilder, "enablePolymerMode", "Enable Polymer Mode"); midnightconfig(translationBuilder, "enablePolymerMode.tooltip", "Allows the mod to work fully server-sided when used in combination with Polymer and FactoryTools"); midnightconfig(translationBuilder, "polymerViewDistance", "Polymer View Distance"); @@ -151,13 +157,18 @@ public abstract class Language extends FabricLanguageProvider { midnightconfig(translationBuilder, key, "§cStarte das Spiel neu, nachdem du Änderungen vorgenommen hast!"); } + midnightconfig(translationBuilder, "rockMix", "Gemischte Brocken"); + midnightconfig(translationBuilder, "rockMix.tooltip", "Fügt kleine Mengen an Granit-, Andesit- und Diorit-Brocken zu allen Biomen hinzu"); midnightconfig(translationBuilder, "underwaterSeashell", "Unterwasser-Muschel"); midnightconfig(translationBuilder, "underwaterStarfish", "Unterwasser-Seestern"); midnightconfig(translationBuilder, "geyserLevitation", "Geysir Schwebeeffekt"); midnightconfig(translationBuilder, "netherGeyserDamage", "Nether Geysir Schaden"); - midnightconfig(translationBuilder, "enablePolymerMode", "Aktiviere Polymer-Modus"); + midnightconfig(translationBuilder, "biomeExclusions", "Ausgeschlosene Biome"); + midnightconfig(translationBuilder, "biomeExclusions.tooltip", "In diesen Biomen werden keine Features der Mod generiert.\nFormat: modid:biome_name"); + + midnightconfig(translationBuilder, "enablePolymerMode", "Aktiviere Polymer-Modus"); midnightconfig(translationBuilder, "enablePolymerMode.tooltip", "Erlaubt der Mod, komplett serverseitig zu funktionieren, wenn Polymer und FactoryTools installiert sind"); midnightconfig(translationBuilder, "polymerViewDistance", "Polymer-Sichtweite"); } diff --git a/src/main/java/eu/midnightdust/motschen/rocks/world/FeatureInjector.java b/src/main/java/eu/midnightdust/motschen/rocks/world/FeatureInjector.java index 46acb13..e1a47e7 100755 --- a/src/main/java/eu/midnightdust/motschen/rocks/world/FeatureInjector.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/world/FeatureInjector.java @@ -17,33 +17,38 @@ import net.minecraft.world.gen.structure.OceanRuinStructure; import java.util.function.Predicate; public class FeatureInjector { + public static boolean isNotExcluded(BiomeSelectionContext ctx) { + return !RocksConfig.biomeExclusions.contains(ctx.getBiomeKey().getValue().toString()); + } public static void init() { + // Rocks - Predicate rocks = (ctx -> + Predicate rocks = (ctx -> isNotExcluded(ctx) && !ctx.hasTag(BiomeTags.IS_NETHER) && !ctx.hasTag(BiomeTags.END_CITY_HAS_STRUCTURE) && !ctx.hasTag(BiomeTags.IS_BEACH) && !ctx.hasTag(BiomeTags.DESERT_PYRAMID_HAS_STRUCTURE) && !ctx.hasTag(BiomeTags.IS_BADLANDS) && !ctx.hasTag(BiomeTags.IGLOO_HAS_STRUCTURE) && !ctx.hasTag(BiomeTags.IS_OCEAN)); if (RocksConfig.rock) BiomeModifications.addFeature(rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("rock")); + if (RocksConfig.rockMix) BiomeModifications.addFeature(rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("rock_mix")); if (RocksConfig.graniteRock) BiomeModifications.addFeature(rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("granite_rock")); if (RocksConfig.dioriteRock) BiomeModifications.addFeature(rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("diorite_rock")); if (RocksConfig.andesiteRock) BiomeModifications.addFeature(rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("andesite_rock")); - Predicate sand_rocks = (ctx -> ctx.hasTag(BiomeTags.IS_BEACH) || ctx.hasTag(BiomeTags.DESERT_PYRAMID_HAS_STRUCTURE) || ctx.hasTag(BiomeTags.IS_BADLANDS) || ctx.getBiomeKey().getValue().toString().contains("terrestria:lush_desert")); + Predicate sand_rocks = (ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_BEACH) || ctx.hasTag(BiomeTags.DESERT_PYRAMID_HAS_STRUCTURE) || ctx.hasTag(BiomeTags.IS_BADLANDS) || ctx.getBiomeKey().getValue().toString().contains("terrestria:lush_desert")); if (RocksConfig.sandRock) BiomeModifications.addFeature(sand_rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("sand_rock")); - Predicate red_sand_rocks = (ctx -> ctx.hasTag(BiomeTags.IS_BADLANDS) || ctx.hasTag(BiomeTags.DESERT_PYRAMID_HAS_STRUCTURE) || ctx.getBiomeKey().getValue().toString().contains("terrestria:lush_desert")); + Predicate red_sand_rocks = (ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_BADLANDS) || ctx.hasTag(BiomeTags.DESERT_PYRAMID_HAS_STRUCTURE) || ctx.getBiomeKey().getValue().toString().contains("terrestria:lush_desert")); if (RocksConfig.redSandRock) BiomeModifications.addFeature(red_sand_rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("red_sand_rock")); - Predicate ice_rocks = (ctx -> ctx.hasTag(BiomeTags.IGLOO_HAS_STRUCTURE) || ctx.getBiome().getTemperature() < 0.15F); + Predicate ice_rocks = (ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IGLOO_HAS_STRUCTURE) || ctx.getBiome().getTemperature() < 0.15F); if (RocksConfig.iceRock) BiomeModifications.addFeature(ice_rocks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("ice_rock")); - if (RocksConfig.endStoneRock) BiomeModifications.addFeature(ctx -> ctx.getBiomeKey().getValue().toString().contains("the_end"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("end_stone_rock")); + if (RocksConfig.endStoneRock) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.getBiomeKey().getValue().toString().contains("the_end"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("end_stone_rock")); // Sticks Predicate oak_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:forest") || name.contains("minecraft:wooded_hills") || name.contains("oak") || + return isNotExcluded(ctx) && name.contains("minecraft:forest") || name.contains("minecraft:wooded_hills") || name.contains("oak") || name.contains("minecraft:wooded_mountains") || name.contains("minecraft:plains") || name.contains("minecraft:flower_forest") || name.contains("minecraft:wooded_badlands_plateau") || name.contains("minecraft:modified_wooded_badlands_plateau") || ctx.hasTag(BiomeTags.SWAMP_HUT_HAS_STRUCTURE);}); @@ -51,55 +56,55 @@ public class FeatureInjector { Predicate birch_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:forest") || name.contains("birch") || name.contains("minecraft:flower_forest");}); + return isNotExcluded(ctx) && name.contains("minecraft:forest") || name.contains("birch") || name.contains("minecraft:flower_forest");}); if (RocksConfig.birchStick) BiomeModifications.addFeature(birch_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("birch_stick")); Predicate spruce_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:wooded_mountains") || ctx.hasTag(BiomeTags.IS_TAIGA);}); + return isNotExcluded(ctx) && name.contains("minecraft:wooded_mountains") || ctx.hasTag(BiomeTags.IS_TAIGA);}); if (RocksConfig.spruceStick) BiomeModifications.addFeature(spruce_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("spruce_stick")); if (RocksConfig.pinecone) BiomeModifications.addFeature(spruce_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("pinecone")); - if (RocksConfig.acaciaStick) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.VILLAGE_SAVANNA_HAS_STRUCTURE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("acacia_stick")); + if (RocksConfig.acaciaStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.VILLAGE_SAVANNA_HAS_STRUCTURE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("acacia_stick")); - if (RocksConfig.jungleStick) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_JUNGLE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("jungle_stick")); - if (RocksConfig.bambooStick) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_JUNGLE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("bamboo_stick")); - if (RocksConfig.paleOakStick) BiomeModifications.addFeature(ctx -> ctx.getBiomeKey().equals(BiomeKeys.PALE_GARDEN), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("pale_oak_stick")); + if (RocksConfig.jungleStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_JUNGLE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("jungle_stick")); + if (RocksConfig.bambooStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_JUNGLE), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("bamboo_stick")); + if (RocksConfig.paleOakStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.getBiomeKey().equals(BiomeKeys.PALE_GARDEN), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("pale_oak_stick")); Predicate dark_oak_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:dark_forest") || name.contains("minecraft:dark_forest_hills") || + return isNotExcluded(ctx) && name.contains("minecraft:dark_forest") || name.contains("minecraft:dark_forest_hills") || name.contains("minecraft:dark_forest_mountains");}); if (RocksConfig.darkOakStick) BiomeModifications.addFeature(dark_oak_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("dark_oak_stick")); Predicate mangrove_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:mangrove_swamp");}); + return isNotExcluded(ctx) && name.contains("minecraft:mangrove_swamp");}); if (RocksConfig.mangroveStick) BiomeModifications.addFeature(mangrove_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("mangrove_stick")); Predicate cherry_sticks = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return name.contains("minecraft:cherry_grove");}); + return isNotExcluded(ctx) && name.contains("minecraft:cherry_grove");}); if (RocksConfig.cherryStick) BiomeModifications.addFeature(cherry_sticks, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("cherry_stick")); // Misc Predicate beach = (ctx -> { String name = ctx.getBiomeKey().getValue().toString(); - return ctx.hasTag(BiomeTags.IS_BEACH) && !name.contains("snow");}); + return isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_BEACH) && !name.contains("snow");}); if (RocksConfig.seashell) BiomeModifications.addFeature(beach, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("seashell")); if (RocksConfig.starfish) BiomeModifications.addFeature(beach, GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("starfish")); - if (RocksConfig.underwaterStarfish) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_OCEAN) && !ctx.getBiomeKey().toString().contains("cold"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("underwater_starfish")); - if (RocksConfig.underwaterSeashell) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_OCEAN), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("underwater_seashell")); + if (RocksConfig.underwaterStarfish) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_OCEAN) && !ctx.getBiomeKey().toString().contains("cold"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("underwater_starfish")); + if (RocksConfig.underwaterSeashell) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_OCEAN), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("underwater_seashell")); - if (RocksConfig.netherrackRock) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("netherrack_rock")); - if (RocksConfig.soulSoilRock) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("soul_soil_rock")); - if (RocksConfig.gravelRock) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("nether_gravel_rock")); - if (RocksConfig.netherGeyser) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("nether_geyser")); - if (RocksConfig.warpedStick) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("warped_stick")); - if (RocksConfig.crimsonStick) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("crimson_stick")); + if (RocksConfig.netherrackRock) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("netherrack_rock")); + if (RocksConfig.soulSoilRock) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("soul_soil_rock")); + if (RocksConfig.gravelRock) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("nether_gravel_rock")); + if (RocksConfig.netherGeyser) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("nether_geyser")); + if (RocksConfig.warpedStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("warped_stick")); + if (RocksConfig.crimsonStick) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("crimson_stick")); - if (RocksConfig.gravelRock) BiomeModifications.addFeature(ctx -> !ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("gravel_rock")); + if (RocksConfig.gravelRock) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && !ctx.hasTag(BiomeTags.IS_NETHER), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("gravel_rock")); - if (RocksConfig.geyser) BiomeModifications.addFeature(ctx -> ctx.hasTag(BiomeTags.IGLOO_HAS_STRUCTURE) || ctx.getBiomeKey().toString().contains("snowy"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("snowy_geyser")); + if (RocksConfig.geyser) BiomeModifications.addFeature(ctx -> isNotExcluded(ctx) && ctx.hasTag(BiomeTags.IGLOO_HAS_STRUCTURE) || ctx.getBiomeKey().toString().contains("snowy"), GenerationStep.Feature.TOP_LAYER_MODIFICATION, getKey("snowy_geyser")); } public static RegistryKey getKey(String name) { return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(RocksMain.MOD_ID, name)); diff --git a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/NetherFeatures.java b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/NetherFeatures.java index 50bb24d..f68cfd8 100755 --- a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/NetherFeatures.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/NetherFeatures.java @@ -2,12 +2,8 @@ package eu.midnightdust.motschen.rocks.world.configured_feature; import com.google.common.collect.ImmutableList; import eu.midnightdust.motschen.rocks.RocksMain; -import eu.midnightdust.motschen.rocks.blockstates.RockVariation; -import eu.midnightdust.motschen.rocks.blockstates.StickVariation; -import eu.midnightdust.motschen.rocks.util.RockType; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.block.WoodType; import net.minecraft.registry.Registerable; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.collection.DataPool; @@ -19,52 +15,23 @@ import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; import java.util.List; -import static eu.midnightdust.motschen.rocks.RocksMain.rocksByType; -import static eu.midnightdust.motschen.rocks.RocksMain.sticksByType; import static eu.midnightdust.motschen.rocks.util.RegistryUtil.register; public class NetherFeatures { - - public static ConfiguredFeature NETHERRACK_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.NETHERRACK).getDefaultState().with(RocksMain.ROCK_VARIATION, RockVariation.TINY), 10) - .add(rocksByType.get(RockType.NETHERRACK).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.NETHERRACK).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.NETHERRACK).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature SOUL_SOIL_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.SOUL_SOIL).getDefaultState().with(RocksMain.ROCK_VARIATION, RockVariation.TINY), 10) - .add(rocksByType.get(RockType.SOUL_SOIL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.SOUL_SOIL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.SOUL_SOIL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature NETHER_GRAVEL_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION, RockVariation.TINY), 10) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); public static ConfiguredFeature NETHER_GEYSER_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( new WeightedBlockStateProvider(DataPool.builder().add(RocksMain.NetherGeyser.getDefaultState(), 1))) ); - public static PlacedFeature NETHERRACK_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(NETHERRACK_ROCK_FEATURE), List.of(CountPlacementModifier.of(90), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate .bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.NETHERRACK,Blocks.WARPED_NYLIUM,Blocks.CRIMSON_NYLIUM)))))); - public static PlacedFeature SOUL_SOIL_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(SOUL_SOIL_ROCK_FEATURE), List.of(CountPlacementModifier.of(60), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.SOUL_SOIL,Blocks.SOUL_SAND)))))); - public static PlacedFeature NETHER_GRAVEL_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(NETHER_GRAVEL_ROCK_FEATURE), List.of(CountPlacementModifier.of(30), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.GRAVEL)))))); - public static PlacedFeature NETHER_GEYSER_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(NETHER_GEYSER_FEATURE), List.of(CountPlacementModifier.of(15), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.NETHERRACK)))))); + public static PlacedFeature NETHER_GEYSER_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(NETHER_GEYSER_FEATURE), + List.of(CountPlacementModifier.of(15), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), + PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), + BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, + BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.NETHERRACK)))))); public static void initConfigured(Registerable> context) { - register(context, "netherrack_rock", NETHERRACK_ROCK_FEATURE); - register(context, "soul_soil_rock", SOUL_SOIL_ROCK_FEATURE); - register(context, "nether_gravel_rock", NETHER_GRAVEL_ROCK_FEATURE); register(context, "nether_geyser", NETHER_GEYSER_FEATURE); } public static void initPlaced(Registerable context) { - register(context, "netherrack_rock", NETHERRACK_ROCK_PLACED_FEATURE); - register(context, "soul_soil_rock", SOUL_SOIL_ROCK_PLACED_FEATURE); - register(context, "nether_gravel_rock", NETHER_GRAVEL_ROCK_PLACED_FEATURE); register(context, "nether_geyser", NETHER_GEYSER_PLACED_FEATURE); } } diff --git a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/RockFeatures.java b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/RockFeatures.java index 5d03eb8..5777c03 100755 --- a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/RockFeatures.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/RockFeatures.java @@ -1,9 +1,9 @@ package eu.midnightdust.motschen.rocks.world.configured_feature; -import com.google.common.collect.ImmutableList; import eu.midnightdust.motschen.rocks.RocksMain; import eu.midnightdust.motschen.rocks.blockstates.RockVariation; import eu.midnightdust.motschen.rocks.util.RockType; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.registry.*; @@ -15,106 +15,99 @@ import net.minecraft.world.gen.feature.*; import net.minecraft.world.gen.placementmodifier.*; import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; +import java.util.HashMap; import java.util.List; +import java.util.Map; -import static eu.midnightdust.motschen.rocks.RocksMain.rocksByType; +import static eu.midnightdust.motschen.rocks.RocksMain.*; import static eu.midnightdust.motschen.rocks.util.RegistryUtil.register; public class RockFeatures { - public static ConfiguredFeature ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature GRANITE_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature DIORITE_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature ANDESITE_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature SAND_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature RED_SAND_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK,new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.RED_SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.RED_SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.RED_SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.RED_SANDSTONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature END_STONE_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.END_STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.END_STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.END_STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.END_STONE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build()) - )); - public static ConfiguredFeature GRAVEL_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) - ); - public static ConfiguredFeature ICE_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( + private static final Map> CONFIGURED_FEATURES = new HashMap<>(); + + public static List getModifiers(int count, int rarity, Block... groundBlocks) { + return List.of(CountPlacementModifier.of(count), RarityFilterPlacementModifier.of(rarity), + SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), + BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), groundBlocks)))); + } + public static List getModifiersInvertedGroundCheck(int count, int rarity, Block... groundBlocks) { + return List.of(CountPlacementModifier.of(count), RarityFilterPlacementModifier.of(rarity), + SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), + BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.not(BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), groundBlocks))))); + } + public static List getNetherModifiers(int count, int rarity, Block... groundBlocks) { + return List.of(CountPlacementModifier.of(count), RarityFilterPlacementModifier.of(rarity), + SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of(), + BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), groundBlocks)))); + } + public static List getEndModifiers(int count, int rarity, Block... groundBlocks) { + return List.of(CountPlacementModifier.of(count), RarityFilterPlacementModifier.of(rarity), + SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of(), + BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), groundBlocks)))); + } + public static ConfiguredFeature ROCK_MIX_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( new WeightedBlockStateProvider(DataPool.builder() - .add(rocksByType.get(RockType.ICE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.TINY), 10) - .add(rocksByType.get(RockType.ICE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) - .add(rocksByType.get(RockType.ICE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) - .add(rocksByType.get(RockType.ICE).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) + .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(ROCK_VARIATION,RockVariation.TINY), 10).add(rocksByType.get(RockType.GRANITE).getDefaultState().with(ROCK_VARIATION,RockVariation.SMALL), 7) + .add(rocksByType.get(RockType.GRANITE).getDefaultState().with(ROCK_VARIATION,RockVariation.MEDIUM), 5).add(rocksByType.get(RockType.GRANITE).getDefaultState().with(ROCK_VARIATION,RockVariation.LARGE), 1) + .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(ROCK_VARIATION,RockVariation.TINY), 10).add(rocksByType.get(RockType.DIORITE).getDefaultState().with(ROCK_VARIATION,RockVariation.SMALL), 7) + .add(rocksByType.get(RockType.DIORITE).getDefaultState().with(ROCK_VARIATION,RockVariation.MEDIUM), 5).add(rocksByType.get(RockType.DIORITE).getDefaultState().with(ROCK_VARIATION,RockVariation.LARGE), 1) + .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(ROCK_VARIATION,RockVariation.TINY), 10).add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(ROCK_VARIATION,RockVariation.SMALL), 7) + .add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(ROCK_VARIATION,RockVariation.MEDIUM), 5).add(rocksByType.get(RockType.ANDESITE).getDefaultState().with(ROCK_VARIATION,RockVariation.LARGE), 1) + .build())) + ); + public static ConfiguredFeature NETHER_GRAVEL_ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( + new WeightedBlockStateProvider(DataPool.builder() + .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION, RockVariation.TINY), 10) + .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.SMALL), 7) + .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.MEDIUM), 5) + .add(rocksByType.get(RockType.GRAVEL).getDefaultState().with(RocksMain.ROCK_VARIATION,RockVariation.LARGE), 1).build())) ); - public static PlacedFeature ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.not(BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.ICE, Blocks.PACKED_ICE, Blocks.SAND, Blocks.RED_SAND, Blocks.END_STONE))))))); - public static PlacedFeature GRANITE_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(GRANITE_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.GRANITE)))))); - public static PlacedFeature DIORITE_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(DIORITE_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.DIORITE)))))); - public static PlacedFeature ANDESITE_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(ANDESITE_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.ANDESITE)))))); - public static PlacedFeature SAND_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(SAND_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.SAND, Blocks.SANDSTONE)))))); - public static PlacedFeature RED_SAND_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(RED_SAND_ROCK_FEATURE), List.of(CountPlacementModifier.of(7), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.RED_SAND, Blocks.RED_SANDSTONE)))))); - public static PlacedFeature END_STONE_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(END_STONE_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.END_STONE)))))); - public static PlacedFeature GRAVEL_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(GRAVEL_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(1), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.GRAVEL)))))); - public static PlacedFeature ICE_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(ICE_ROCK_FEATURE), List.of(CountPlacementModifier.of(3), RarityFilterPlacementModifier.of(5), SquarePlacementModifier.of(), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.bothOf(BlockPredicate.IS_AIR, BlockPredicate.matchingBlocks(new Vec3i(0, -1, 0), ImmutableList.of(Blocks.ICE, Blocks.PACKED_ICE, Blocks.BLUE_ICE)))))); + public static PlacedFeature ROCK_MIX_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(ROCK_MIX_FEATURE), getModifiersInvertedGroundCheck(3, 1, Blocks.ICE, Blocks.PACKED_ICE, Blocks.SAND, Blocks.RED_SAND, Blocks.END_STONE)); + public static PlacedFeature NETHER_GRAVEL_ROCK_PLACED_FEATURE = new PlacedFeature(RegistryEntry.of(NETHER_GRAVEL_ROCK_FEATURE), getNetherModifiers(30, 1, Blocks.GRAVEL)); + + public static void init() { + for (RockType type : RockType.values()) { + ConfiguredFeature ROCK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( + new WeightedBlockStateProvider(DataPool.builder() + .add(rocksByType.get(type).getDefaultState().with(ROCK_VARIATION, RockVariation.TINY), 10) + .add(rocksByType.get(type).getDefaultState().with(ROCK_VARIATION, RockVariation.SMALL), 7) + .add(rocksByType.get(type).getDefaultState().with(ROCK_VARIATION, RockVariation.MEDIUM), 5) + .add(rocksByType.get(type).getDefaultState().with(ROCK_VARIATION, RockVariation.LARGE), 1) + .build())) + ); + CONFIGURED_FEATURES.put(type, ROCK_FEATURE); + } + } public static void initConfigured(Registerable> context) { - register(context, "rock", ROCK_FEATURE); - register(context, "granite_rock", GRANITE_ROCK_FEATURE); - register(context, "diorite_rock", DIORITE_ROCK_FEATURE); - register(context, "andesite_rock", ANDESITE_ROCK_FEATURE); - register(context, "sand_rock", SAND_ROCK_FEATURE); - register(context, "red_sand_rock", RED_SAND_ROCK_FEATURE); - register(context, "end_stone_rock", END_STONE_ROCK_FEATURE); - register(context, "gravel_rock", GRAVEL_ROCK_FEATURE); - register(context, "ice_rock", ICE_ROCK_FEATURE); + register(context, "rock_mix", ROCK_MIX_FEATURE); + register(context, "nether_gravel_rock", NETHER_GRAVEL_ROCK_FEATURE); + + for (RockType type : RockType.values()) { + register(context, type.getName(), CONFIGURED_FEATURES.get(type)); + } } + public static void initPlaced(Registerable context) { - register(context, "rock", ROCK_PLACED_FEATURE); - register(context, "granite_rock", GRANITE_ROCK_PLACED_FEATURE); - register(context, "diorite_rock", DIORITE_ROCK_PLACED_FEATURE); - register(context, "andesite_rock", ANDESITE_ROCK_PLACED_FEATURE); - register(context, "sand_rock", SAND_ROCK_PLACED_FEATURE); - register(context, "red_sand_rock", RED_SAND_ROCK_PLACED_FEATURE); - register(context, "end_stone_rock", END_STONE_ROCK_PLACED_FEATURE); - register(context, "gravel_rock", GRAVEL_ROCK_PLACED_FEATURE); - register(context, "ice_rock", ICE_ROCK_PLACED_FEATURE); + register(context, "rock_mix", ROCK_MIX_PLACED_FEATURE); + register(context, "nether_gravel_rock", NETHER_GRAVEL_ROCK_PLACED_FEATURE); + + for (RockType type : RockType.values()) { + PlacedFeature ROCK_PLACED_FEATURE = switch (type) { + case STONE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiersInvertedGroundCheck(3, 1, Blocks.ICE, Blocks.PACKED_ICE, Blocks.SAND, Blocks.RED_SAND, Blocks.END_STONE)); + case SANDSTONE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(3, 1, Blocks.SAND, Blocks.SANDSTONE)); + case RED_SANDSTONE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(7, 1, Blocks.RED_SAND, Blocks.RED_SANDSTONE)); + case ICE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(3, 5, Blocks.ICE, Blocks.PACKED_ICE, Blocks.BLUE_ICE)); + + case NETHERRACK -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getNetherModifiers(90, 1, Blocks.NETHERRACK, Blocks.WARPED_NYLIUM, Blocks.CRIMSON_NYLIUM)); + case SOUL_SOIL -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getNetherModifiers(60, 1, Blocks.SOUL_SOIL, Blocks.SOUL_SAND)); + + case END_STONE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getEndModifiers(3, 1, type.getStoneBlock())); + + default -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(3, 1, type.getStoneBlock())); + }; + register(context, type.getName(), ROCK_PLACED_FEATURE); + } } } diff --git a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/StickFeatures.java b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/StickFeatures.java index 91476de..c9bc5c5 100755 --- a/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/StickFeatures.java +++ b/src/main/java/eu/midnightdust/motschen/rocks/world/configured_feature/StickFeatures.java @@ -38,7 +38,7 @@ public class StickFeatures { groundBlocks)))); } - public static void initFeatures() { + public static void init() { for (StickType type : StickType.values()) { ConfiguredFeature STICK_FEATURE = new ConfiguredFeature<>(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig( new WeightedBlockStateProvider(DataPool.builder() @@ -62,6 +62,7 @@ public class StickFeatures { case CRIMSON -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getNetherModifiers(90, 1, Blocks.CRIMSON_NYLIUM)); case WARPED -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getNetherModifiers(90, 1, Blocks.WARPED_NYLIUM)); case PALE_OAK -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(20, 1, Blocks.GRASS_BLOCK, Blocks.PALE_MOSS_BLOCK)); + case SPRUCE -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(3, 1, Blocks.GRASS_BLOCK, Blocks.SNOW_BLOCK, Blocks.PODZOL)); default -> new PlacedFeature(RegistryEntry.of(CONFIGURED_FEATURES.get(type)), getModifiers(3, 1, Blocks.GRASS_BLOCK, Blocks.MUD, Blocks.PODZOL)); }; register(context, type.getName() + "_stick", STICK_PLACED_FEATURE);