Skip to content

Commit

Permalink
glowing roots now generate
Browse files Browse the repository at this point in the history
  • Loading branch information
NewJumper committed Dec 14, 2023
1 parent bee999f commit e1c2e95
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 1.20.1 2023-11-21T14:45:12.6053878 Registries
// 1.20.1 2023-12-13T23:00:04.0297822 Registries
65c8c67a4ec7ef0ce6846fb2f4d921cc6ceb02e2 data/deeperdarker/damage_type/bite.json
0b65c61bd1e5086d0f3685566cc6cecf6e324516 data/deeperdarker/damage_type/ring.json
67f8cd0621b1c3614da8c1910f6b7bcb61660293 data/deeperdarker/dimension_type/otherside.json
d215b65d058e1a6fdaa7b27c472982fcacd74821 data/deeperdarker/worldgen/biome/blooming_caverns.json
134828c5454bc507400ff7629cd21f6499e2a18e data/deeperdarker/worldgen/biome/blooming_caverns.json
4491dd6887a8760b77f9a28406c3e4c0535b108d data/deeperdarker/worldgen/biome/deeplands.json
bd2c433caf3a3f7dfff3668a68dbdf56fa994df5 data/deeperdarker/worldgen/biome/echoing_forest.json
06d29b9291ed3a63be90750a8c6f182e0c168b7b data/deeperdarker/worldgen/biome/overcast_columns.json
Expand All @@ -12,6 +12,7 @@ befb8dd1022d3e0e0bea6f211800fe3c8b63bb2e data/deeperdarker/worldgen/configured_f
ba29dfa84f2bebe688044c6e89b6c1d38dbaf0c6 data/deeperdarker/worldgen/configured_feature/gloomslate_generation.json
5d330f021ad1e22b038b08bfd79b49f5da654254 data/deeperdarker/worldgen/configured_feature/gloomy_sculk_patch.json
091c066d3e288c08e5d68a8aca7b3fb0e6e5639b data/deeperdarker/worldgen/configured_feature/gloomy_sculk_vegetation.json
4f5206ae11f51f053829cbd0c5d62109f53ad793 data/deeperdarker/worldgen/configured_feature/glowing_roots.json
4ed58d929172dbbc46472a55443f74a52f909d00 data/deeperdarker/worldgen/configured_feature/glowing_vines.json
0150a1b84d07f143eac3a8f3f6f434ac3565b489 data/deeperdarker/worldgen/configured_feature/ore_blooming_moss.json
1b6dbe9c2e15df01aa9a3c27beb46ccc4e91d5df data/deeperdarker/worldgen/configured_feature/ore_echo_soil.json
Expand Down Expand Up @@ -64,6 +65,7 @@ bf9f314ece53b6c84ff286c845985d7c653e8307 data/deeperdarker/worldgen/placed_featu
f459d9a62a2daf59c22373d51311fb6764c13c8f data/deeperdarker/worldgen/placed_feature/gloomslate_redstone.json
81411f1b6adb7b44958af3921ac9ea0de1b64022 data/deeperdarker/worldgen/placed_feature/gloomy_sculk.json
5afa0f1278333d6805331dae70b7a50f028fa305 data/deeperdarker/worldgen/placed_feature/gloomy_sculk_vegetation.json
36a96483f11aa1dfae2eab1ac1340605a1c31bd4 data/deeperdarker/worldgen/placed_feature/glowing_roots.json
82087dbc271ee36b1aab5e52fdc3c1c1438f3386 data/deeperdarker/worldgen/placed_feature/glowing_vines.json
0ded2720cb77d9a0fc99c65aa1be1db78e14f358 data/deeperdarker/worldgen/placed_feature/infested_sculk.json
d8aa6278f0d32c85ea9460981c00a93e3d57728a data/deeperdarker/worldgen/placed_feature/magma.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
[
"deeperdarker:blooming_sculk_vegetation",
"deeperdarker:blooming_plant",
"deeperdarker:glowing_roots",
"deeperdarker:glowing_vines",
"deeperdarker:sculk_vines_caverns"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "deeperdarker:glowing_roots",
"config": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "deeperdarker:glowing_roots",
"placement": [
{
"type": "minecraft:count",
"count": 58
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"below_top": 0
},
"min_inclusive": {
"above_bottom": 0
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class DDConfiguredFeatures {
public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_GLEAM_EXTRA = createKey("sculk_gleam_extra");
public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_TENDRILS = createKey("sculk_tendrils");
public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_VINES = createKey("sculk_vines");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_ROOTS = createKey("glowing_roots");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_VINES = createKey("glowing_vines");

public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_STONE_GENERATION = createKey("sculk_stone_generation");
Expand Down Expand Up @@ -114,6 +115,7 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
FeatureUtils.register(context, SCULK_GLEAM_EXTRA, DDFeatures.SCULK_GLEAM_BLOB.get());
FeatureUtils.register(context, SCULK_TENDRILS, DDFeatures.SCULK_TENDRILS.get());
FeatureUtils.register(context, SCULK_VINES, DDFeatures.SCULK_VINES.get());
FeatureUtils.register(context, GLOWING_ROOTS, DDFeatures.GLOWING_ROOTS.get());
FeatureUtils.register(context, GLOWING_VINES, DDFeatures.GLOWING_VINES.get());

FeatureUtils.register(context, SCULK_STONE_GENERATION, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(DDBlocks.SCULK_STONE.get())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DDFeatures {
public static final RegistryObject<SculkGleamFeature> SCULK_GLEAM_BLOB = FEATURES.register("sculk_gleam_blob", () -> new SculkGleamFeature(NoneFeatureConfiguration.CODEC));
public static final RegistryObject<SculkTendrilsFeature> SCULK_TENDRILS = FEATURES.register("sculk_tendrils", () -> new SculkTendrilsFeature(NoneFeatureConfiguration.CODEC));
public static final RegistryObject<SculkVinesFeature> SCULK_VINES = FEATURES.register("sculk_vines", () -> new SculkVinesFeature(NoneFeatureConfiguration.CODEC));
public static final RegistryObject<GlowingRootsFeature> GLOWING_ROOTS = FEATURES.register("glowing_roots", () -> new GlowingRootsFeature(NoneFeatureConfiguration.CODEC));
public static final RegistryObject<GlowingVinesFeature> GLOWING_VINES = FEATURES.register("glowing_vines", () -> new GlowingVinesFeature(NoneFeatureConfiguration.CODEC));

public static final RegistryObject<BloomingStemFeature> BLOOMING_STEM = FEATURES.register("blooming_stem", () -> new BloomingStemFeature(NoneFeatureConfiguration.CODEC));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class DDPlacedFeatures {
public static final ResourceKey<PlacedFeature> SCULK_TENDRILS = createKey("sculk_tendrils");
public static final ResourceKey<PlacedFeature> SCULK_VINES = createKey("sculk_vines");
public static final ResourceKey<PlacedFeature> SCULK_VINES_CAVERNS = createKey("sculk_vines_caverns");
public static final ResourceKey<PlacedFeature> GLOWING_ROOTS = createKey("glowing_roots");
public static final ResourceKey<PlacedFeature> GLOWING_VINES = createKey("glowing_vines");

public static final ResourceKey<PlacedFeature> SURFACE_SCULK_STONE = createKey("surface_sculk_stone");
Expand Down Expand Up @@ -72,6 +73,7 @@ public static void bootstrap(BootstapContext<PlacedFeature> context) {
PlacementUtils.register(context, SCULK_TENDRILS, features.getOrThrow(DDConfiguredFeatures.SCULK_TENDRILS), countPlacement(36, PlacementUtils.FULL_RANGE));
PlacementUtils.register(context, SCULK_VINES, features.getOrThrow(DDConfiguredFeatures.SCULK_VINES), countPlacement(28, PlacementUtils.FULL_RANGE));
PlacementUtils.register(context, SCULK_VINES_CAVERNS, features.getOrThrow(DDConfiguredFeatures.SCULK_VINES), countPlacement(56, PlacementUtils.FULL_RANGE));
PlacementUtils.register(context, GLOWING_ROOTS, features.getOrThrow(DDConfiguredFeatures.GLOWING_ROOTS), countPlacement(58, PlacementUtils.FULL_RANGE));
PlacementUtils.register(context, GLOWING_VINES, features.getOrThrow(DDConfiguredFeatures.GLOWING_VINES), countPlacement(64, PlacementUtils.FULL_RANGE));

PlacementUtils.register(context, SURFACE_SCULK_STONE, features.getOrThrow(DDConfiguredFeatures.SURFACE_SCULK_STONE), countPlacement(55, PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.kyanite.deeperdarker.world.features;

import com.kyanite.deeperdarker.content.DDBlocks;
import com.mojang.serialization.Codec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.GrowingPlantHeadBlock;
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 GlowingRootsFeature extends Feature<NoneFeatureConfiguration> {
public GlowingRootsFeature(Codec<NoneFeatureConfiguration> pCodec) {
super(pCodec);
}

@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> pContext) {
WorldGenLevel level = pContext.level();
BlockPos origin = pContext.origin();
RandomSource random = pContext.random();

if(!isValidPlacementLocation(level, origin)) return false;

int width = 5;
int height = 3;
int maxHeight = 6;
BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
for(int i = 0; i < width * width; i++) {
blockPos.set(origin).move(Mth.nextInt(random, -width, width), Mth.nextInt(random, -height, height), Mth.nextInt(random, -width, width));
if(findAirAboveGround(level, blockPos) && isValidPlacementLocation(level, blockPos)) {
int length = random.nextInt(1, maxHeight);
if(random.nextInt(12) == 0) length *= 2;
if(random.nextInt(6) == 0) length = 1;
placeColumn(level, random, blockPos, length);
}
}

return true;
}

private boolean isValidPlacementLocation(LevelAccessor level, BlockPos pos) {
return level.getBlockState(pos.below()).is(DDBlocks.BLOOMING_SCULK_STONE.get());
}

private boolean findAirAboveGround(LevelAccessor level, BlockPos.MutableBlockPos pos) {
do {
pos.move(0, -1, 0);
if(level.isOutsideBuildHeight(pos)) return false;
} while(level.getBlockState(pos).isAir());

pos.move(0, 1, 0);
return true;
}

private void placeColumn(LevelAccessor level, RandomSource random, BlockPos.MutableBlockPos pos, int length) {
for(int i = 1; i <= length; i++) {
if(level.isEmptyBlock(pos)) {
if(i == length || !level.isEmptyBlock(pos.above())) {
level.setBlock(pos, DDBlocks.GLOWING_ROOTS.get().defaultBlockState().setValue(GrowingPlantHeadBlock.AGE, random.nextIntBetweenInclusive(17, 25)), 3);
break;
}

level.setBlock(pos, DDBlocks.GLOWING_ROOTS_PLANT.get().defaultBlockState(), 3);
}

pos.move(Direction.UP);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private static Biome bloomingCaverns(HolderGetter<PlacedFeature> placedFeatures,
biomeBuilder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, DDPlacedFeatures.BLOOMING_SCULK_VEGETATION);
biomeBuilder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, DDPlacedFeatures.BLOOMING_MOSS);
biomeBuilder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, DDPlacedFeatures.BLOOMING_PLANT);
biomeBuilder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, DDPlacedFeatures.GLOWING_ROOTS);
biomeBuilder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, DDPlacedFeatures.GLOWING_VINES);
biomeBuilder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, DDPlacedFeatures.SCULK_VINES_CAVERNS);
addSculkOres(biomeBuilder);
Expand Down

0 comments on commit e1c2e95

Please sign in to comment.