Skip to content

Commit

Permalink
icicle cluster biome modification
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDeathlyCow committed Nov 15, 2023
1 parent 718d100 commit 20423fc
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@
public class IcicleHelper {

public static boolean canReplace(BlockState state) {
return state.isIn(FBlockTags.ICICLE_GROWABLE) || state.isIn(FBlockTags.ICICLE_REPLACEABLE_BLOCKS);
return (!state.isOf(Blocks.ICE) && state.isIn(FBlockTags.ICICLE_GROWABLE)) || state.isIn(FBlockTags.ICICLE_REPLACEABLE_BLOCKS);
}

public static boolean canGenerate(BlockState state) {
return state.isAir() || state.isOf(Blocks.WATER);
}

public static boolean cannotGenerate(BlockState state) {
return !canGenerate(state);
}

public static boolean generateIceBaseBlock(WorldAccess world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
if (blockState.isIn(FBlockTags.ICICLE_REPLACEABLE_BLOCKS)) {
Expand All @@ -41,17 +37,20 @@ public static void generateIcicle(WorldAccess world, BlockPos pos, Direction dir
return;
}
BlockPos.Mutable mutable = pos.mutableCopy();
generateIcicle(
placeWithThickness(
direction, height, merge,
state -> {
state = state.with(IcicleBlock.WATERLOGGED, world.isWater(mutable));
world.setBlockState(mutable, state, Block.NOTIFY_LISTENERS);
mutable.move(direction);
BlockState current = world.getBlockState(mutable);
if (current.isAir() || current.isOf(Blocks.WATER)) {
state = state.with(IcicleBlock.WATERLOGGED, world.isWater(mutable));
world.setBlockState(mutable, state, Block.NOTIFY_LISTENERS);
mutable.move(direction);
}
}
);
}

private static void generateIcicle(
private static void placeWithThickness(
Direction direction,
int height,
boolean merge,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
public class FHasFeatureTags {

public static final TagKey<Biome> SUN_LICHEN_COVERED_ROCK = FBiomeTags.register("has_feature/sun_lichen_covered_rock");
public static final TagKey<Biome> ICICLE_CLUSTER = FBiomeTags.register("has_feature/icicle_cluster");

private FHasFeatureTags() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class FPlacedFeatures {

public static final RegistryKey<PlacedFeature> SUN_LICHEN_COVERED_ROCK = of("sun_lichen_covered_rock");
public static final RegistryKey<PlacedFeature> ICICLE_CLUSTER = of("icicle_cluster");

public static void placeFeatures() {

Expand All @@ -29,6 +30,17 @@ public static void placeFeatures() {
);
}
);

modification.add(
ModificationPhase.ADDITIONS,
BiomeSelectors.tag(FHasFeatureTags.ICICLE_CLUSTER),
(biomeSelectionContext, biomeModificationContext) -> {
biomeModificationContext.getGenerationSettings().addFeature(
GenerationStep.Feature.UNDERGROUND_DECORATION,
FPlacedFeatures.ICICLE_CLUSTER
);
}
);
}

private static RegistryKey<PlacedFeature> of(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.util.CaveSurface;
import net.minecraft.world.gen.feature.util.FeatureContext;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;
import java.util.OptionalInt;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"#c:snowy",
"#c:icy",
"#c:aquatic_icy"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "minecraft:uniform",
"value": {
"min_inclusive": 1,
"max_inclusive": 6
"max_inclusive": 4
}
},
"radius": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"count": {
"type": "minecraft:uniform",
"value": {
"min_inclusive": 192,
"max_inclusive": 256
"min_inclusive": 1,
"max_inclusive": 6
}
}
},
Expand All @@ -19,44 +19,13 @@
"height": {
"type": "minecraft:uniform",
"min_inclusive": {
"above_bottom": 0
"above_bottom": 25
},
"max_inclusive": {
"absolute": 256
}
}
},
{
"type": "minecraft:count",
"count": {
"type": "minecraft:uniform",
"value": {
"min_inclusive": 1,
"max_inclusive": 5
}
}
},
{
"type": "minecraft:random_offset",
"xz_spread": {
"type": "minecraft:clamped_normal",
"value": {
"min_inclusive": -10,
"max_inclusive": 10,
"mean": 0,
"deviation": 3
}
},
"y_spread": {
"type": "minecraft:clamped_normal",
"value": {
"min_inclusive": -2,
"max_inclusive": 2,
"mean": 0,
"deviation": 0.6
}
}
},
{
"type": "minecraft:biome"
}
Expand Down

0 comments on commit 20423fc

Please sign in to comment.