From 6dd711930e7d48385affc3e4703c4e0d8a008255 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 1 Jul 2022 18:23:04 +0200 Subject: [PATCH] More Feature Changes --- .../betterend/registry/EndFeatures.java | 215 ++++++++++++------ .../biome/cave/EmptyAuroraCaveBiome.java | 4 +- .../world/biome/cave/EmptyEndCaveBiome.java | 4 +- .../biome/cave/EmptySmaragdantCaveBiome.java | 6 +- .../world/biome/cave/EndCaveBiome.java | 15 +- .../world/biome/cave/LushAuroraCaveBiome.java | 18 +- .../biome/cave/LushSmaragdantCaveBiome.java | 6 +- .../world/features/bushes/BushFeature.java | 32 +-- .../features/bushes/BushFeatureConfig.java | 36 +++ .../features/bushes/BushWithOuterFeature.java | 39 ++-- .../bushes/BushWithOuterFeatureConfig.java | 37 +++ .../features/terrain/IceStarFeature.java | 24 +- .../terrain/IceStarFeatureConfig.java | 30 +++ .../features/terrain/SingleBlockFeature.java | 20 +- .../features/terrain/StalactiteFeature.java | 37 +-- .../terrain/StalactiteFeatureConfig.java | 39 ++++ .../caves/CaveChunkPopulatorFeature.java | 18 +- .../terrain/caves/EndCaveFeature.java | 29 ++- .../terrain/caves/TunelCaveFeature.java | 21 +- 19 files changed, 417 insertions(+), 213 deletions(-) create mode 100644 src/main/java/org/betterx/betterend/world/features/bushes/BushFeatureConfig.java create mode 100644 src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeatureConfig.java create mode 100644 src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeatureConfig.java create mode 100644 src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeatureConfig.java diff --git a/src/main/java/org/betterx/betterend/registry/EndFeatures.java b/src/main/java/org/betterx/betterend/registry/EndFeatures.java index d08bec6c..6b4b97b4 100644 --- a/src/main/java/org/betterx/betterend/registry/EndFeatures.java +++ b/src/main/java/org/betterx/betterend/registry/EndFeatures.java @@ -3,7 +3,6 @@ package org.betterx.betterend.registry; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder; import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI; -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature; import org.betterx.bclib.api.v3.levelgen.features.BCLFeature; import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder; @@ -35,6 +34,8 @@ import net.minecraft.world.level.levelgen.feature.OreFeature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; import net.minecraft.world.level.levelgen.placement.CountPlacement; import com.google.common.collect.Lists; @@ -45,6 +46,10 @@ import java.io.InputStream; import java.util.List; public class EndFeatures { + public static final StalactiteFeature STALACTITE_FEATURE = inlineBuild( + "stalactite_feature", + new StalactiteFeature() + ); public static final BuildingListFeature BUILDING_LIST_FEATURE = inlineBuild( "building_list_feature", new BuildingListFeature() @@ -144,69 +149,86 @@ public class EndFeatures { "end_lotus_feature", new EndLotusFeature() ); + + public static final BushFeature BUSH_FEATURE = inlineBuild( + "bush_feature", + new BushFeature() + ); + + public static final SingleBlockFeature SINGLE_BLOCK_FEATURE = inlineBuild( + "single_block_feature", + new SingleBlockFeature() + ); + + public static final BushWithOuterFeature BUSH_WITH_OUTER_FEATURE = inlineBuild( + "bush_with_outer_feature", + new BushWithOuterFeature() + ); public static final BCLFeature MOSSY_GLOWSHROOM = registerVegetation( "mossy_glowshroom", - new MossyGlowshroomFeature(), + inlineBuild("mossy_glowshroom", new MossyGlowshroomFeature()), 2 ); public static final BCLFeature PYTHADENDRON_TREE = registerVegetation( "pythadendron_tree", - new PythadendronTreeFeature(), + inlineBuild("pythadendron_tree", new PythadendronTreeFeature()), 1 ); public static final BCLFeature LACUGROVE = registerVegetation( "lacugrove", - new LacugroveFeature(), + inlineBuild("lacugrove", new LacugroveFeature()), 4 ); public static final BCLFeature DRAGON_TREE = registerVegetation( "dragon_tree", - new DragonTreeFeature(), + inlineBuild("dragon_tree", new DragonTreeFeature()), 2 ); public static final BCLFeature TENANEA = registerVegetation( "tenanea", - new TenaneaFeature(), + inlineBuild("tenanea", new TenaneaFeature()), 2 ); public static final BCLFeature HELIX_TREE = registerVegetation( "helix_tree", - new HelixTreeFeature(), + inlineBuild("helix_tree", new HelixTreeFeature()), 1 ); public static final BCLFeature UMBRELLA_TREE = registerVegetation( "umbrella_tree", - new UmbrellaTreeFeature(), + inlineBuild("umbrella_tree", new UmbrellaTreeFeature()), 2 ); public static final BCLFeature JELLYSHROOM = registerVegetation( "jellyshroom", - new JellyshroomFeature(), + inlineBuild("jellyshroom", new JellyshroomFeature()), 2 ); public static final BCLFeature GIGANTIC_AMARANITA = registerVegetation( "gigantic_amaranita", - new GiganticAmaranitaFeature(), + inlineBuild("gigantic_amaranita", new GiganticAmaranitaFeature()), 1 ); public static final BCLFeature LUCERNIA = registerVegetation( "lucernia", - new LucerniaFeature(), + inlineBuild("lucernia", new LucerniaFeature()), 3 ); // Bushes // - public static final BCLFeature PYTHADENDRON_BUSH = registerVegetation( + public static final BCLFeature PYTHADENDRON_BUSH = registerVegetation( "pythadendron_bush", - new BushFeature( + BUSH_FEATURE, + new BushFeatureConfig( EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.getBark() ), 3 ); - public static final BCLFeature DRAGON_TREE_BUSH = registerVegetation( + public static final BCLFeature DRAGON_TREE_BUSH = registerVegetation( "dragon_tree_bush", - new BushFeature( + BUSH_FEATURE, + new BushFeatureConfig( EndBlocks.DRAGON_TREE_LEAVES, EndBlocks.DRAGON_TREE.getBark() ), @@ -214,31 +236,33 @@ public class EndFeatures { ); public static final BCLFeature TENANEA_BUSH = registerVegetation( "tenanea_bush", - new TenaneaBushFeature(), + inlineBuild("tenanea_bush", new TenaneaBushFeature()), 6 ); public static final BCLFeature LUMECORN = registerVegetation( "lumecorn", - new Lumecorn(), + inlineBuild("lumecorn", new Lumecorn()), 5 ); public static final BCLFeature LARGE_AMARANITA = registerVegetation( "large_amaranita", - new LargeAmaranitaFeature(), + inlineBuild("large_amaranita", new LargeAmaranitaFeature()), 5 ); - public static final BCLFeature LUCERNIA_BUSH = registerVegetation( + public static final BCLFeature LUCERNIA_BUSH = registerVegetation( "lucernia_bush", - new BushWithOuterFeature( + BUSH_WITH_OUTER_FEATURE, + new BushWithOuterFeatureConfig( EndBlocks.LUCERNIA_LEAVES, EndBlocks.LUCERNIA_OUTER_LEAVES, EndBlocks.LUCERNIA.getBark() ), 10 ); - public static final BCLFeature LUCERNIA_BUSH_RARE = registerVegetation( + public static final BCLFeature LUCERNIA_BUSH_RARE = registerVegetation( "lucernia_bush_rare", - new BushWithOuterFeature( + BUSH_WITH_OUTER_FEATURE, + new BushWithOuterFeatureConfig( EndBlocks.LUCERNIA_LEAVES, EndBlocks.LUCERNIA_OUTER_LEAVES, EndBlocks.LUCERNIA.getBark() @@ -247,7 +271,7 @@ public class EndFeatures { ); public static final BCLFeature NEON_CACTUS = registerVegetation( "neon_cactus", - new NeonCactusFeature(), + inlineBuild("neon_cactus", new NeonCactusFeature()), 2 ); @@ -766,50 +790,51 @@ public class EndFeatures { 20 ); + public static final EndLakeFeature END_LAKE_FEATURE = inlineBuild("end_lake", new EndLakeFeature()); // Terrain // public static final BCLFeature END_LAKE = registerLake( "end_lake", - new EndLakeFeature(), + END_LAKE_FEATURE, 4 ); public static final BCLFeature END_LAKE_NORMAL = registerLake( "end_lake_normal", - new EndLakeFeature(), + END_LAKE_FEATURE, 20 ); public static final BCLFeature END_LAKE_RARE = registerLake( "end_lake_rare", - new EndLakeFeature(), + END_LAKE_FEATURE, 40 ); public static final BCLFeature DESERT_LAKE = registerLake( "desert_lake", - new DesertLakeFeature(), + inlineBuild("desert_lake", new DesertLakeFeature()), 8 ); public static final BCLFeature ROUND_CAVE = registerRawGen( "round_cave", - new RoundCaveFeature(), + inlineBuild("round_cave", new RoundCaveFeature()), 2 ); public static final BCLFeature SPIRE = registerRawGen( "spire", - new SpireFeature(), + inlineBuild("spire", new SpireFeature()), 4 ); public static final BCLFeature FLOATING_SPIRE = registerRawGen( "floating_spire", - new FloatingSpireFeature(), + inlineBuild("floating_spire", new FloatingSpireFeature()), 8 ); public static final BCLFeature GEYSER = registerRawGen( "geyser", - new GeyserFeature(), + inlineBuild("geyser", new GeyserFeature()), 8 ); public static final BCLFeature SULPHURIC_LAKE = registerLake( "sulphuric_lake", - new SulphuricLakeFeature(), + inlineBuild("sulphuric_lake", new SulphuricLakeFeature()), 8 ); public static final BCLFeature SULPHURIC_CAVE = BCLFeatureBuilder @@ -824,39 +849,43 @@ public class EndFeatures { .squarePlacement() .onlyInBiome() .buildAndRegister(); - public static final BCLFeature ICE_STAR = registerRawGen( + + public static final IceStarFeature ICE_STAR_FEATURE = inlineBuild("ice_star", new IceStarFeature()); + public static final BCLFeature ICE_STAR = registerRawGen( "ice_star", - new IceStarFeature(5, 15, 10, 25), + ICE_STAR_FEATURE, + new IceStarFeatureConfig(5, 15, 10, 25), 15 ); - public static final BCLFeature ICE_STAR_SMALL = registerRawGen( + public static final BCLFeature ICE_STAR_SMALL = registerRawGen( "ice_star_small", - new IceStarFeature(3, 5, 7, 12), + ICE_STAR_FEATURE, + new IceStarFeatureConfig(3, 5, 7, 12), 8 ); public static final BCLFeature SURFACE_VENT = registerChanced( "surface_vent", - new SurfaceVentFeature(), + inlineBuild("surface_vent", new SurfaceVentFeature()), 4 ); public static final BCLFeature SULPHUR_HILL = registerChanced( "sulphur_hill", - new SulphurHillFeature(), + inlineBuild("sulphur_hill", new SulphurHillFeature()), 8 ); public static final BCLFeature OBSIDIAN_PILLAR_BASEMENT = registerChanced( "obsidian_pillar_basement", - new ObsidianPillarBasementFeature(), + inlineBuild("obsidian_pillar_basement", new ObsidianPillarBasementFeature()), 8 ); public static final BCLFeature OBSIDIAN_BOULDER = registerChanced( "obsidian_boulder", - new ObsidianBoulderFeature(), + inlineBuild("obsidian_boulder", new ObsidianBoulderFeature()), 10 ); public static final BCLFeature FALLEN_PILLAR = registerChanced( "fallen_pillar", - new FallenPillarFeature(), + inlineBuild("fallen_pillar", new FallenPillarFeature()), 20 ); public static final BCLFeature TUNEL_CAVE = BCLFeatureBuilder @@ -930,7 +959,7 @@ public class EndFeatures { // Buildings public static final BCLFeature CRASHED_SHIP = registerChanced( "crashed_ship", - new CrashedShipFeature(), + inlineBuild("crashed_ship", new CrashedShipFeature()), new NBTFeatureConfig(EndBiome.Config.DEFAULT_MATERIAL.getTopMaterial()), 500 ); @@ -938,16 +967,36 @@ public class EndFeatures { // Mobs public static final BCLFeature SILK_MOTH_NEST = registerChanced( "silk_moth_nest", - new SilkMothNestFeature(), + inlineBuild("silk_moth_nest", new SilkMothNestFeature()), 2 ); // Caves - public static final DefaultFeature SMARAGDANT_CRYSTAL = new SmaragdantCrystalFeature(); - public static final DefaultFeature SMARAGDANT_CRYSTAL_SHARD = new SingleBlockFeature(EndBlocks.SMARAGDANT_CRYSTAL_SHARD); - public static final DefaultFeature BIG_AURORA_CRYSTAL = new BigAuroraCrystalFeature(); - public static final DefaultFeature CAVE_BUSH = new BushFeature(EndBlocks.CAVE_BUSH, EndBlocks.CAVE_BUSH); - public static final DefaultFeature CAVE_GRASS = new SingleBlockFeature(EndBlocks.CAVE_GRASS); + public static final BCLConfigureFeature SMARAGDANT_CRYSTAL = BCLFeatureBuilder + .start( + BetterEnd.makeID("smaragdant_crystal"), + inlineBuild("smaragdant_crystal", new SmaragdantCrystalFeature()) + ) + .buildAndRegister(); + public static final BCLConfigureFeature SMARAGDANT_CRYSTAL_SHARD = BCLFeatureBuilder + .start(BetterEnd.makeID("smaragdant_crystal_shard"), SINGLE_BLOCK_FEATURE) + .configuration(new SimpleBlockConfiguration(SimpleStateProvider.simple(EndBlocks.SMARAGDANT_CRYSTAL_SHARD))) + .buildAndRegister(); + + public static final BCLConfigureFeature BIG_AURORA_CRYSTAL = BCLFeatureBuilder + .start( + BetterEnd.makeID("big_aurora_crystal"), + inlineBuild("big_aurora_crystal", new BigAuroraCrystalFeature()) + ) + .buildAndRegister(); + public static final BCLConfigureFeature CAVE_BUSH = BCLFeatureBuilder + .start(BetterEnd.makeID("cave_bush"), BUSH_FEATURE) + .configuration(new BushFeatureConfig(EndBlocks.CAVE_BUSH, EndBlocks.CAVE_BUSH)) + .buildAndRegister(); + public static final BCLConfigureFeature CAVE_GRASS = BCLFeatureBuilder + .start(BetterEnd.makeID("cave_grass"), SINGLE_BLOCK_FEATURE) + .configuration(new SimpleBlockConfiguration(SimpleStateProvider.simple(EndBlocks.CAVE_GRASS))) + .buildAndRegister(); public static final BCLConfigureFeature RUBINEA = BCLFeatureBuilder .start(BetterEnd.makeID("rubinea"), VINE_FEATURE) .configuration(new VineFeatureConfig(EndBlocks.RUBINEA, 8)) @@ -958,28 +1007,40 @@ public class EndFeatures { .configuration(new VineFeatureConfig(EndBlocks.MAGNULA, 8)) .buildAndRegister(); - public static final DefaultFeature END_STONE_STALACTITE = new StalactiteFeature( - true, - EndBlocks.END_STONE_STALACTITE, - Blocks.END_STONE - ); - public static final DefaultFeature END_STONE_STALAGMITE = new StalactiteFeature( - false, - EndBlocks.END_STONE_STALACTITE, - Blocks.END_STONE - ); - public static final DefaultFeature END_STONE_STALACTITE_CAVEMOSS = new StalactiteFeature( - true, - EndBlocks.END_STONE_STALACTITE_CAVEMOSS, - Blocks.END_STONE, - EndBlocks.CAVE_MOSS - ); - public static final DefaultFeature END_STONE_STALAGMITE_CAVEMOSS = new StalactiteFeature( - false, - EndBlocks.END_STONE_STALACTITE_CAVEMOSS, - EndBlocks.CAVE_MOSS - ); - public static final DefaultFeature CAVE_PUMPKIN = new CavePumpkinFeature(); + public static final BCLConfigureFeature END_STONE_STALACTITE = BCLFeatureBuilder + .start(BetterEnd.makeID("end_stone_stalactite"), STALACTITE_FEATURE) + .configuration(new StalactiteFeatureConfig(true, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE)) + .buildAndRegister(); + + + public static final BCLConfigureFeature END_STONE_STALAGMITE = BCLFeatureBuilder + .start(BetterEnd.makeID("end_stone_stalagmite"), STALACTITE_FEATURE) + .configuration(new StalactiteFeatureConfig(false, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE)) + .buildAndRegister(); + public static final BCLConfigureFeature END_STONE_STALACTITE_CAVEMOSS = BCLFeatureBuilder + .start(BetterEnd.makeID("end_stone_stalactite_cavemoss"), STALACTITE_FEATURE) + .configuration(new StalactiteFeatureConfig( + true, + EndBlocks.END_STONE_STALACTITE_CAVEMOSS, + Blocks.END_STONE, + EndBlocks.CAVE_MOSS + )) + .buildAndRegister(); + public static final BCLConfigureFeature END_STONE_STALAGMITE_CAVEMOSS = BCLFeatureBuilder + .start(BetterEnd.makeID("end_stone_stalagmite_cavemoss"), STALACTITE_FEATURE) + .configuration(new StalactiteFeatureConfig( + false, + EndBlocks.END_STONE_STALACTITE_CAVEMOSS, + EndBlocks.CAVE_MOSS + )) + .buildAndRegister(); + public static final BCLConfigureFeature CAVE_PUMPKIN = BCLFeatureBuilder + .start( + BetterEnd.makeID("cave_pumpkin"), + inlineBuild("cave_pumpkin", new CavePumpkinFeature()) + ) + .buildAndRegister(); + public static , FC extends FeatureConfiguration> F inlineBuild(String name, F feature) { ResourceLocation l = BetterEnd.makeID(name); @@ -1019,7 +1080,6 @@ public class EndFeatures { FC config, int density ) { - feature = inlineBuild("feature_" + name, feature); ResourceLocation id = BetterEnd.makeID(name); return BCLFeatureBuilder.start(id, feature) .configuration(config) @@ -1035,9 +1095,18 @@ public class EndFeatures { F feature, int chance ) { - feature = inlineBuild("feature_" + name, feature); + return registerRawGen(name, feature, FeatureConfiguration.NONE, chance); + } + + private static , FC extends FeatureConfiguration> BCLFeature registerRawGen( + String name, + F feature, + FC config, + int chance + ) { return BCLFeatureBuilder .start(BetterEnd.makeID(name), feature) + .configuration(config) .buildAndRegister() .place() .decoration(Decoration.RAW_GENERATION) @@ -1052,7 +1121,6 @@ public class EndFeatures { F feature, int chance ) { - feature = inlineBuild("feature_" + name, feature); return BCLFeatureBuilder .start(BetterEnd.makeID(name), feature) .buildAndRegister() @@ -1078,7 +1146,6 @@ public class EndFeatures { FC config, int chance ) { - feature = inlineBuild("feature_" + name, feature); return BCLFeatureBuilder .start(BetterEnd.makeID(name), feature) diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/EmptyAuroraCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/EmptyAuroraCaveBiome.java index 06a8a0e4..ba329419 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/EmptyAuroraCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/EmptyAuroraCaveBiome.java @@ -14,9 +14,9 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome.Config { public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); - this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1); + this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL.configuredFeature, 1); - this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1); + this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1); } @Override diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/EmptyEndCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/EmptyEndCaveBiome.java index aff4e99f..03029a15 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/EmptyEndCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/EmptyEndCaveBiome.java @@ -13,8 +13,8 @@ public class EmptyEndCaveBiome extends EndCaveBiome.Config { public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); - this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE, 1); - this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1); + this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE.configuredFeature, 1); + this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1); } @Override diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/EmptySmaragdantCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/EmptySmaragdantCaveBiome.java index bf8b80e1..0a852e0e 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/EmptySmaragdantCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/EmptySmaragdantCaveBiome.java @@ -14,10 +14,10 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome.Config { public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); - this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1); - this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20); + this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL.configuredFeature, 1); + this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD.configuredFeature, 20); - this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1); + this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1); } @Override diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/EndCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/EndCaveBiome.java index 7001ea04..dccee983 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/EndCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/EndCaveBiome.java @@ -14,12 +14,13 @@ import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeat import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeatureConfig; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.GenerationStep; -import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; public class EndCaveBiome extends EndBiome { public static abstract class Config extends EndBiome.Config { @@ -59,26 +60,26 @@ public class EndCaveBiome extends EndBiome { } } - private final WeightedList> floorFeatures = new WeightedList>(); - private final WeightedList> ceilFeatures = new WeightedList>(); + private final WeightedList>> floorFeatures = new WeightedList<>(); + private final WeightedList>> ceilFeatures = new WeightedList<>(); public EndCaveBiome(ResourceLocation biomeID, Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); } - public void addFloorFeature(Feature feature, float weight) { + public void addFloorFeature(Holder> feature, float weight) { floorFeatures.add(feature, weight); } - public void addCeilFeature(Feature feature, float weight) { + public void addCeilFeature(Holder> feature, float weight) { ceilFeatures.add(feature, weight); } - public Feature getFloorFeature(RandomSource random) { + public Holder> getFloorFeature(RandomSource random) { return floorFeatures.isEmpty() ? null : floorFeatures.get(random); } - public Feature getCeilFeature(RandomSource random) { + public Holder> getCeilFeature(RandomSource random) { return ceilFeatures.isEmpty() ? null : ceilFeatures.get(random); } diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/LushAuroraCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/LushAuroraCaveBiome.java index a85551ca..4ed8c275 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/LushAuroraCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/LushAuroraCaveBiome.java @@ -19,16 +19,16 @@ public class LushAuroraCaveBiome extends EndCaveBiome.Config { public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); - this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1); - this.addFloorFeature(EndFeatures.CAVE_BUSH, 5); - this.addFloorFeature(EndFeatures.CAVE_GRASS, 40); - this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5); + this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL.configuredFeature, 1); + this.addFloorFeature(EndFeatures.CAVE_BUSH.configuredFeature, 5); + this.addFloorFeature(EndFeatures.CAVE_GRASS.configuredFeature, 40); + this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS.configuredFeature, 5); - this.addCeilFeature(EndFeatures.CAVE_BUSH, 1); - this.addCeilFeature(EndFeatures.CAVE_PUMPKIN, 1); - this.addCeilFeature(EndFeatures.RUBINEA.getFeature(), 3); - this.addCeilFeature(EndFeatures.MAGNULA.getFeature(), 1); - this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10); + this.addCeilFeature(EndFeatures.CAVE_BUSH.configuredFeature, 1); + this.addCeilFeature(EndFeatures.CAVE_PUMPKIN.configuredFeature, 1); + this.addCeilFeature(EndFeatures.RUBINEA.configuredFeature, 3); + this.addCeilFeature(EndFeatures.MAGNULA.configuredFeature, 1); + this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS.configuredFeature, 10); } @Override diff --git a/src/main/java/org/betterx/betterend/world/biome/cave/LushSmaragdantCaveBiome.java b/src/main/java/org/betterx/betterend/world/biome/cave/LushSmaragdantCaveBiome.java index 301e6947..49db8a09 100644 --- a/src/main/java/org/betterx/betterend/world/biome/cave/LushSmaragdantCaveBiome.java +++ b/src/main/java/org/betterx/betterend/world/biome/cave/LushSmaragdantCaveBiome.java @@ -17,10 +17,10 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome.Config { public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) { super(biomeID, biome, settings); - this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1); - this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20); + this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL.configuredFeature, 1); + this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD.configuredFeature, 20); - this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1); + this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1); } @Override diff --git a/src/main/java/org/betterx/betterend/world/features/bushes/BushFeature.java b/src/main/java/org/betterx/betterend/world/features/bushes/BushFeature.java index 0f453a3c..fe084e4c 100644 --- a/src/main/java/org/betterx/betterend/world/features/bushes/BushFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/bushes/BushFeature.java @@ -19,24 +19,21 @@ import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.material.Material; import java.util.function.Function; -public class BushFeature extends DefaultFeature { +public class BushFeature extends Feature { private static final Function REPLACE; - private final Block leaves; - private final Block stem; - public BushFeature(Block leaves, Block stem) { - this.leaves = leaves; - this.stem = stem; + public BushFeature() { + super(BushFeatureConfig.CODEC); } @Override - public boolean place(FeaturePlaceContext featureConfig) { + public boolean place(FeaturePlaceContext featureConfig) { final RandomSource random = featureConfig.random(); final BlockPos pos = featureConfig.origin(); final WorldGenLevel world = featureConfig.level(); @@ -44,16 +41,19 @@ public class BushFeature extends DefaultFeature { .is(CommonBlockTags.END_STONES)) return false; + BushFeatureConfig cfg = featureConfig.config(); + Block leaves = cfg.leaves.getState(random, pos).getBlock(); + BlockState stem = cfg.stem.getState(random, pos); float radius = MHelper.randRange(1.8F, 3.5F, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); - SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves); + SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { - return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3; - }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { - return MHelper.randRange(-2F, 2F, random); - }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval( + vec.x() * 0.2, + vec.y() * 0.2, + vec.z() * 0.2 + ) * 3).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-2F, 2F, random)).setSource(sphere); sphere = new SDFSubtraction().setSourceA(sphere) .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); sphere.setReplaceFunction(REPLACE); @@ -63,7 +63,7 @@ public class BushFeature extends DefaultFeature { if (distance < 7) { return info.getState().setValue(LeavesBlock.DISTANCE, distance); } else { - return AIR; + return DefaultFeature.AIR; } } return info.getState(); diff --git a/src/main/java/org/betterx/betterend/world/features/bushes/BushFeatureConfig.java b/src/main/java/org/betterx/betterend/world/features/bushes/BushFeatureConfig.java new file mode 100644 index 00000000..f2ad3adf --- /dev/null +++ b/src/main/java/org/betterx/betterend/world/features/bushes/BushFeatureConfig.java @@ -0,0 +1,36 @@ +package org.betterx.betterend.world.features.bushes; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; + +public class BushFeatureConfig implements FeatureConfiguration { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance + .group( + BlockStateProvider.CODEC.fieldOf("leaves").forGetter(o -> o.leaves), + BlockStateProvider.CODEC.fieldOf("stem").forGetter(o -> o.stem) + ) + .apply(instance, BushFeatureConfig::new)); + + + public final BlockStateProvider leaves; + public final BlockStateProvider stem; + + public BushFeatureConfig(Block leaves, Block stem) { + this( + SimpleStateProvider.simple(leaves), + SimpleStateProvider.simple(stem) + ); + } + + public BushFeatureConfig( + BlockStateProvider leaves, + BlockStateProvider stem + ) { + this.leaves = leaves; + this.stem = stem; + } +} diff --git a/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeature.java b/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeature.java index ff851e38..72ea2286 100644 --- a/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeature.java @@ -20,29 +20,30 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.material.Material; import java.util.function.Function; -public class BushWithOuterFeature extends DefaultFeature { +public class BushWithOuterFeature extends Feature { private static final Direction[] DIRECTIONS = Direction.values(); private static final Function REPLACE; - private final Block outer_leaves; - private final Block leaves; - private final Block stem; - public BushWithOuterFeature(Block leaves, Block outer_leaves, Block stem) { - this.outer_leaves = outer_leaves; - this.leaves = leaves; - this.stem = stem; + + public BushWithOuterFeature() { + super(BushWithOuterFeatureConfig.CODEC); } @Override - public boolean place(FeaturePlaceContext featureConfig) { + public boolean place(FeaturePlaceContext featureConfig) { final RandomSource random = featureConfig.random(); final BlockPos pos = featureConfig.origin(); + BushWithOuterFeatureConfig cfg = featureConfig.config(); + BlockState outer_leaves = cfg.outer_leaves.getState(random, pos); + Block leaves = cfg.leaves.getState(random, pos).getBlock(); + BlockState stem = cfg.stem.getState(random, pos); + final WorldGenLevel world = featureConfig.level(); if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES) && !world.getBlockState(pos.above()) .is(CommonBlockTags.END_STONES)) @@ -50,14 +51,14 @@ public class BushWithOuterFeature extends DefaultFeature { float radius = MHelper.randRange(1.8F, 3.5F, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); - SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves); + SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { - return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3; - }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { - return MHelper.randRange(-2F, 2F, random); - }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval( + vec.x() * 0.2, + vec.y() * 0.2, + vec.z() * 0.2 + ) * 3).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-2F, 2F, random)).setSource(sphere); sphere = new SDFSubtraction().setSourceA(sphere) .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); sphere.setReplaceFunction(REPLACE); @@ -67,7 +68,7 @@ public class BushWithOuterFeature extends DefaultFeature { if (distance < 7) { return info.getState().setValue(LeavesBlock.DISTANCE, distance); } else { - return AIR; + return DefaultFeature.AIR; } } return info.getState(); @@ -78,7 +79,7 @@ public class BushWithOuterFeature extends DefaultFeature { if (info.getState(dir).isAir()) { info.setBlockPos( info.getPos().relative(dir), - outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir) + outer_leaves.setValue(BlockStateProperties.FACING, dir) ); } } diff --git a/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeatureConfig.java b/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeatureConfig.java new file mode 100644 index 00000000..e88ace38 --- /dev/null +++ b/src/main/java/org/betterx/betterend/world/features/bushes/BushWithOuterFeatureConfig.java @@ -0,0 +1,37 @@ +package org.betterx.betterend.world.features.bushes; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; + +public class BushWithOuterFeatureConfig extends BushFeatureConfig { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance + .group( + BlockStateProvider.CODEC.fieldOf("leaves").forGetter(o -> o.leaves), + BlockStateProvider.CODEC.fieldOf("outer_leaves").forGetter(o -> o.outer_leaves), + BlockStateProvider.CODEC.fieldOf("stem").forGetter(o -> o.stem) + ) + .apply(instance, BushWithOuterFeatureConfig::new)); + + + public final BlockStateProvider outer_leaves; + + public BushWithOuterFeatureConfig(Block leaves, Block outer_leaves, Block stem) { + this( + SimpleStateProvider.simple(leaves), + SimpleStateProvider.simple(outer_leaves), + SimpleStateProvider.simple(stem) + ); + } + + public BushWithOuterFeatureConfig( + BlockStateProvider leaves, + BlockStateProvider outer_leaves, + BlockStateProvider stem + ) { + super(leaves, stem); + this.outer_leaves = outer_leaves; + } +} diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeature.java index 00c9d823..ef5ac55f 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeature.java @@ -1,6 +1,5 @@ package org.betterx.betterend.world.features.terrain; -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; import org.betterx.bclib.sdf.SDF; import org.betterx.bclib.sdf.operator.SDFRotation; import org.betterx.bclib.sdf.operator.SDFTranslate; @@ -14,32 +13,27 @@ import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import java.util.ArrayList; import java.util.List; -public class IceStarFeature extends DefaultFeature { - private final float minSize; - private final float maxSize; - private final int minCount; - private final int maxCount; +public class IceStarFeature extends Feature { - public IceStarFeature(float minSize, float maxSize, int minCount, int maxCount) { - this.minSize = minSize; - this.maxSize = maxSize; - this.minCount = minCount; - this.maxCount = maxCount; + + public IceStarFeature() { + super(IceStarFeatureConfig.CODEC); } @Override - public boolean place(FeaturePlaceContext featureConfig) { + public boolean place(FeaturePlaceContext featureConfig) { final RandomSource random = featureConfig.random(); BlockPos pos = featureConfig.origin(); final WorldGenLevel world = featureConfig.level(); - float size = MHelper.randRange(minSize, maxSize, random); - int count = MHelper.randRange(minCount, maxCount, random); + IceStarFeatureConfig cfg = featureConfig.config(); + float size = MHelper.randRange(cfg.minSize, cfg.maxSize, random); + int count = MHelper.randRange(cfg.minCount, cfg.maxCount, random); List points = getFibonacciPoints(count); SDF sdf = null; SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F) diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeatureConfig.java b/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeatureConfig.java new file mode 100644 index 00000000..33e2b653 --- /dev/null +++ b/src/main/java/org/betterx/betterend/world/features/terrain/IceStarFeatureConfig.java @@ -0,0 +1,30 @@ +package org.betterx.betterend.world.features.terrain; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; + +public class IceStarFeatureConfig implements FeatureConfiguration { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance + .group( + Codec.FLOAT.fieldOf("min_size").forGetter(o -> o.minSize), + Codec.FLOAT.fieldOf("max_size").forGetter(o -> o.maxSize), + Codec.INT.fieldOf("min_count").forGetter(o -> o.minCount), + Codec.INT.fieldOf("max_count").forGetter(o -> o.maxCount) + ) + .apply(instance, IceStarFeatureConfig::new)); + + + public final float minSize; + public final float maxSize; + public final int minCount; + public final int maxCount; + + + public IceStarFeatureConfig(float minSize, float maxSize, int minCount, int maxCount) { + this.minSize = minSize; + this.maxSize = maxSize; + this.minCount = minCount; + this.maxCount = maxCount; + } +} diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/SingleBlockFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/SingleBlockFeature.java index 1e5cad73..ff0d1fc5 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/SingleBlockFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/SingleBlockFeature.java @@ -1,36 +1,34 @@ package org.betterx.betterend.world.features.terrain; -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; import org.betterx.bclib.util.BlocksHelper; import org.betterx.worlds.together.tag.v3.CommonBlockTags; import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration; -public class SingleBlockFeature extends DefaultFeature { - private final Block block; - - public SingleBlockFeature(Block block) { - this.block = block; +public class SingleBlockFeature extends Feature { + public SingleBlockFeature() { + super(SimpleBlockConfiguration.CODEC); } @Override - public boolean place(FeaturePlaceContext featureConfig) { + public boolean place(FeaturePlaceContext featureConfig) { final RandomSource random = featureConfig.random(); final BlockPos pos = featureConfig.origin(); final WorldGenLevel world = featureConfig.level(); + final SimpleBlockConfiguration cfg = featureConfig.config(); if (!world.getBlockState(pos.below()).is(CommonBlockTags.GEN_END_STONES)) { return false; } - BlockState state = block.defaultBlockState(); - if (block.getStateDefinition().getProperty("waterlogged") != null) { + BlockState state = cfg.toPlace().getState(random, pos); + if (state.getBlock().getStateDefinition().getProperty("waterlogged") != null) { boolean waterlogged = !world.getFluidState(pos).isEmpty(); state = state.setValue(BlockStateProperties.WATERLOGGED, waterlogged); } diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeature.java index 68523240..819fb0ce 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeature.java @@ -1,6 +1,5 @@ package org.betterx.betterend.world.features.terrain; -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; import org.betterx.bclib.blocks.StalactiteBlock; import org.betterx.bclib.util.BlocksHelper; import org.betterx.worlds.together.tag.v3.CommonBlockTags; @@ -10,35 +9,30 @@ import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -public class StalactiteFeature extends DefaultFeature { - private final boolean ceiling; - private final Block[] ground; - private final Block block; +public class StalactiteFeature extends Feature { - public StalactiteFeature(boolean ceiling, Block block, Block... ground) { - this.ceiling = ceiling; - this.ground = ground; - this.block = block; + public StalactiteFeature() { + super(StalactiteFeatureConfig.CODEC); } @Override - public boolean place(FeaturePlaceContext featureConfig) { + public boolean place(FeaturePlaceContext featureConfig) { final RandomSource random = featureConfig.random(); final BlockPos pos = featureConfig.origin(); final WorldGenLevel world = featureConfig.level(); - if (!isGround(world.getBlockState(ceiling ? pos.above() : pos.below()).getBlock())) { + final StalactiteFeatureConfig cfg = featureConfig.config(); + if (!cfg.allowedGround.test(world, cfg.ceiling ? pos.above() : pos.below())) { return false; } MutableBlockPos mut = new MutableBlockPos().set(pos); int height = random.nextInt(16); - int dir = ceiling ? -1 : 1; + int dir = cfg.ceiling ? -1 : 1; boolean stalagnate = false; for (int i = 1; i <= height; i++) { @@ -60,9 +54,9 @@ public class StalactiteFeature extends DefaultFeature { mut.setY(pos.getY() + i * dir); int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1; boolean waterlogged = !world.getFluidState(mut).isEmpty(); - BlockState base = block.defaultBlockState() - .setValue(StalactiteBlock.SIZE, size) - .setValue(BlockStateProperties.WATERLOGGED, waterlogged); + BlockState base = cfg.block.getState(random, mut) + .setValue(StalactiteBlock.SIZE, size) + .setValue(BlockStateProperties.WATERLOGGED, waterlogged); BlockState state = stalagnate ? base.setValue( StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center @@ -72,13 +66,4 @@ public class StalactiteFeature extends DefaultFeature { return true; } - - private boolean isGround(Block block) { - for (Block b : ground) { - if (b == block) { - return true; - } - } - return false; - } } diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeatureConfig.java b/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeatureConfig.java new file mode 100644 index 00000000..f68f7d12 --- /dev/null +++ b/src/main/java/org/betterx/betterend/world/features/terrain/StalactiteFeatureConfig.java @@ -0,0 +1,39 @@ +package org.betterx.betterend.world.features.terrain; + + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; + +public class StalactiteFeatureConfig implements FeatureConfiguration { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance + .group( + Codec.BOOL.fieldOf("ceiling").forGetter(o -> o.ceiling), + BlockStateProvider.CODEC.fieldOf("states").forGetter(o -> o.block), + BlockPredicate.CODEC.fieldOf("allowed_ground").forGetter(o -> o.allowedGround) + ) + .apply(instance, StalactiteFeatureConfig::new)); + + + public final boolean ceiling; + public final BlockStateProvider block; + public final BlockPredicate allowedGround; + + public StalactiteFeatureConfig(boolean ceiling, Block block, Block... ground) { + this( + ceiling, + SimpleStateProvider.simple(block), + net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate.matchesBlocks(ground) + ); + } + + public StalactiteFeatureConfig(boolean ceiling, BlockStateProvider block, BlockPredicate allowedGround) { + this.ceiling = ceiling; + this.block = block; + this.allowedGround = allowedGround; + } +} diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java index d8ec9a3d..0f2a41e4 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java @@ -12,12 +12,13 @@ import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import com.google.common.collect.Sets; -import java.util.Optional; import java.util.Set; public class CaveChunkPopulatorFeature extends Feature { @@ -32,6 +33,7 @@ public class CaveChunkPopulatorFeature extends Feature floorPositions = Sets.newHashSet(); Set ceilPositions = Sets.newHashSet(); int sx = (pos.getX() >> 4) << 4; @@ -41,8 +43,8 @@ public class CaveChunkPopulatorFeature extends Feature floorPositions, RandomSource random, @@ -122,9 +125,9 @@ public class CaveChunkPopulatorFeature extends Feature { BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock); if (density > 0 && random.nextFloat() <= density) { - Feature feature = biome.getFloorFeature(random); + ConfiguredFeature feature = biome.getFloorFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null)); + feature.place(world, generator, random, pos.above()); } } }); @@ -132,6 +135,7 @@ public class CaveChunkPopulatorFeature extends Feature ceilPositions, RandomSource random @@ -143,9 +147,9 @@ public class CaveChunkPopulatorFeature extends Feature 0 && random.nextFloat() <= density) { - Feature feature = biome.getCeilFeature(random); + ConfiguredFeature feature = biome.getCeilFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null)); + feature.place(world, generator, random, pos.below()); } } }); diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/caves/EndCaveFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/caves/EndCaveFeature.java index 85e8118a..92378f90 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/caves/EndCaveFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/caves/EndCaveFeature.java @@ -22,8 +22,9 @@ import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; @@ -31,7 +32,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import java.util.List; -import java.util.Optional; import java.util.Set; public abstract class EndCaveFeature extends DefaultFeature { @@ -64,6 +64,7 @@ public abstract class EndCaveFeature extends DefaultFeature { Set caveBlocks = generate(world, center, radius, random); if (!caveBlocks.isEmpty()) { if (biome != null) { + ChunkGenerator generator = featureConfig.chunkGenerator(); setBiomes(world, biome, caveBlocks); Set floorPositions = Sets.newConcurrentHashSet(); Set ceilPositions = Sets.newConcurrentHashSet(); @@ -81,9 +82,9 @@ public abstract class EndCaveFeature extends DefaultFeature { }); BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome); - placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock); - placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random); - placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random); + placeFloor(world, generator, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock); + placeCeil(world, generator, (EndCaveBiome) biome.bclBiome, ceilPositions, random); + placeWalls(world, generator, (EndCaveBiome) biome.bclBiome, caveBlocks, random); } fixBlocks(world, caveBlocks); } @@ -95,6 +96,7 @@ public abstract class EndCaveFeature extends DefaultFeature { protected void placeFloor( WorldGenLevel world, + ChunkGenerator generator, EndCaveBiome biome, Set floorPositions, RandomSource random, @@ -106,9 +108,9 @@ public abstract class EndCaveFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock); } if (density > 0 && random.nextFloat() <= density) { - Feature feature = biome.getFloorFeature(random); + ConfiguredFeature feature = biome.getFloorFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null)); + feature.place(world, generator, random, pos.above()); } } }); @@ -116,6 +118,7 @@ public abstract class EndCaveFeature extends DefaultFeature { protected void placeCeil( WorldGenLevel world, + ChunkGenerator generator, EndCaveBiome biome, Set ceilPositions, RandomSource random @@ -127,15 +130,21 @@ public abstract class EndCaveFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, pos, ceilBlock); } if (density > 0 && random.nextFloat() <= density) { - Feature feature = biome.getCeilFeature(random); + ConfiguredFeature feature = biome.getCeilFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null)); + feature.place(world, generator, random, pos.below()); } } }); } - protected void placeWalls(WorldGenLevel world, EndCaveBiome biome, Set positions, RandomSource random) { + protected void placeWalls( + WorldGenLevel world, + ChunkGenerator generator, + EndCaveBiome biome, + Set positions, + RandomSource random + ) { Set placed = Sets.newHashSet(); positions.forEach(pos -> { if (random.nextInt(4) == 0 && hasOpenSide(pos, positions)) { diff --git a/src/main/java/org/betterx/betterend/world/features/terrain/caves/TunelCaveFeature.java b/src/main/java/org/betterx/betterend/world/features/terrain/caves/TunelCaveFeature.java index d56392b7..543b52cb 100644 --- a/src/main/java/org/betterx/betterend/world/features/terrain/caves/TunelCaveFeature.java +++ b/src/main/java/org/betterx/betterend/world/features/terrain/caves/TunelCaveFeature.java @@ -21,9 +21,10 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraft.world.level.levelgen.LegacyRandomSource; -import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; @@ -31,7 +32,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.stream.IntStream; @@ -136,6 +136,7 @@ public class TunelCaveFeature extends EndCaveFeature { return false; } + final ChunkGenerator generator = featureConfig.chunkGenerator(); Map> floorSets = Maps.newHashMap(); Map> ceilSets = Maps.newHashMap(); MutableBlockPos mut = new MutableBlockPos(); @@ -176,13 +177,13 @@ public class TunelCaveFeature extends EndCaveFeature { floorSets.forEach((biome, floorPositions) -> { BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome); - placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock); + placeFloor(world, generator, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock); }); ceilSets.forEach((biome, ceilPositions) -> { - placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random); + placeCeil(world, generator, (EndCaveBiome) biome.bclBiome, ceilPositions, random); }); BiomePicker.ActualBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ()); - placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random); + placeWalls(world, generator, (EndCaveBiome) biome.bclBiome, caveBlocks, random); fixBlocks(world, caveBlocks); return true; @@ -196,6 +197,7 @@ public class TunelCaveFeature extends EndCaveFeature { @Override protected void placeFloor( WorldGenLevel world, + ChunkGenerator generator, EndCaveBiome biome, Set floorPositions, RandomSource random, @@ -207,9 +209,9 @@ public class TunelCaveFeature extends EndCaveFeature { BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock); } if (density > 0 && random.nextFloat() <= density) { - Feature feature = biome.getFloorFeature(random); + ConfiguredFeature feature = biome.getFloorFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null)); + feature.place(world, generator, random, pos.above()); } } }); @@ -218,6 +220,7 @@ public class TunelCaveFeature extends EndCaveFeature { @Override protected void placeCeil( WorldGenLevel world, + ChunkGenerator generator, EndCaveBiome biome, Set ceilPositions, RandomSource random @@ -229,9 +232,9 @@ public class TunelCaveFeature extends EndCaveFeature { BlocksHelper.setWithoutUpdate(world, pos, ceilBlock); } if (density > 0 && random.nextFloat() <= density) { - Feature feature = biome.getCeilFeature(random); + ConfiguredFeature feature = biome.getCeilFeature(random).value(); if (feature != null) { - feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null)); + feature.place(world, generator, random, pos.below()); } } });