Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7d2758a
add infinite height
coco875 Jun 30, 2026
734dfde
make salt being i64
coco875 Jun 30, 2026
58b1443
add alias
coco875 Jun 30, 2026
fd75d79
add color also as i32
coco875 Jun 30, 2026
b31cc76
Merge branch 'master' of https://github.com/Steel-Foundation/SteelMC …
coco875 Jul 4, 2026
ed17c34
add missing StructureProcessorKind, StructureRuleTestData
coco875 Jul 4, 2026
4c29555
allow datapack to simplify by not putting a namespace
coco875 Jul 4, 2026
ea2f47d
ignore unknow properties
coco875 Jul 4, 2026
e9ae762
add place no_op
coco875 Jul 5, 2026
7a5cba2
use and complete holderset
coco875 Jul 5, 2026
e1f48ae
add ore missing feature
coco875 Jul 5, 2026
3c1a18c
fix a test
coco875 Jul 5, 2026
2a4627a
add more vanilla feature in structure
coco875 Jul 5, 2026
0cf4915
more alias for density function
coco875 Jul 5, 2026
a3de968
more alias surface rule
coco875 Jul 5, 2026
9c4a4fe
add ReplaceSingleBlock
coco875 Jul 5, 2026
dc9fafa
finish add foliage
coco875 Jul 5, 2026
bec7f99
some add for tree
coco875 Jul 5, 2026
b772f98
add support for startHeight of vanilla
coco875 Jul 5, 2026
b60475c
fix around range
coco875 Jul 5, 2026
33feb81
add missing field on structure
coco875 Jul 5, 2026
1b7e51a
add missing generation step
coco875 Jul 5, 2026
0413cc0
Update data.rs
coco875 Jul 5, 2026
58b3945
Update fossil.rs
coco875 Jul 5, 2026
e1f2bf7
tiring to make clean commit
coco875 Jul 5, 2026
0b26a8c
Update biomes.rs
coco875 Jul 5, 2026
095eea1
Update biomes.rs
coco875 Jul 5, 2026
9b4c99a
Update block_tags.rs
coco875 Jul 5, 2026
e297f28
Update carvers.rs
coco875 Jul 5, 2026
67ecc9c
add alias
coco875 Jul 5, 2026
7c163a0
Update feature_data.rs
coco875 Jul 5, 2026
47bbf6d
Update features.rs
coco875 Jul 5, 2026
457a88c
Update generator_functions.rs
coco875 Jul 5, 2026
c994c2b
Update item_tags.rs
coco875 Jul 5, 2026
880680e
Update items.rs
coco875 Jul 5, 2026
b44a654
Update items.rs
coco875 Jul 5, 2026
7a8431a
Update loot_tables.rs
coco875 Jul 5, 2026
6637fb9
Update shared_structs.rs
coco875 Jul 5, 2026
dd5377e
Update structure_processors.rs
coco875 Jul 6, 2026
cd227bf
Update structure_sets.rs
coco875 Jul 6, 2026
12ae71a
Update structure_sets.rs
coco875 Jul 6, 2026
0ffb2b9
Update structure_sets.rs
coco875 Jul 6, 2026
8a0acb8
Update structure_sets.rs
coco875 Jul 6, 2026
2d99879
Update loot_tables.rs
coco875 Jul 6, 2026
4715f6b
Update template_pools.rs
coco875 Jul 6, 2026
444483a
revert ProcessorList related
coco875 Jul 6, 2026
9bd5447
Update loot_table.rs
coco875 Jul 6, 2026
5700a1b
Update types.rs
coco875 Jul 6, 2026
c4ea6a8
fix around identifier
coco875 Jul 6, 2026
1e54ebc
Update template_pool.rs
coco875 Jul 6, 2026
d727ed1
fmt
coco875 Jul 6, 2026
df8e384
Update template_pools.rs
coco875 Jul 6, 2026
14820f9
Merge remote-tracking branch 'upstream/master' into datapack
coco875 Jul 6, 2026
5a22e18
fix clippy
coco875 Jul 6, 2026
ebc8922
Update shared_structs.rs
coco875 Jul 6, 2026
1b5e1bd
Merge remote-tracking branch 'upstream/master' into datapack
coco875 Jul 6, 2026
1f4dbf3
Merge Identifier parsing and IntProvider deserialization improvements…
coco875 Jul 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions steel-core/src/worldgen/feature/configured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl FeatureDecorationRunner {
ConfiguredFeatureKind::PointedDripstone(_) => place_pointed_dripstone,
ConfiguredFeatureKind::RandomBooleanSelector(_) => place_random_boolean_selector,
ConfiguredFeatureKind::RandomSelector(_) => place_random_selector,
ConfiguredFeatureKind::ReplaceSingleBlock(_) => place_replace_single_block,
ConfiguredFeatureKind::WeightedRandomSelector(_) => place_weighted_random_selector,
ConfiguredFeatureKind::RootSystem(_) => place_root_system,
ConfiguredFeatureKind::ScatteredOre(_) => place_scattered_ore,
Expand All @@ -135,10 +136,65 @@ impl FeatureDecorationRunner {
place_waterlogged_vegetation_patch
}
ConfiguredFeatureKind::WeepingVines => place_weeping_vines,
ConfiguredFeatureKind::NoOp => place_no_op,
}
}
}

fn place_replace_single_block(
context: &mut ConfiguredFeaturePlaceContext<'_, '_>,
kind: &ConfiguredFeatureKind,
) -> bool {
let ConfiguredFeatureKind::ReplaceSingleBlock(config) = kind else {
panic!("replace_single_block placer received wrong configured feature kind");
};
for target in &config.targets {
if rule_test_matches(
context.region,
context.registry,
context.random,
&target.target,
context.origin,
) {
let state =
FeatureDecorationRunner::block_state_from_data(context.registry, &target.state);
let _ =
context
.region
.set_block_state(context.origin, state, UpdateFlags::UPDATE_CLIENTS);
break;
}
}
true
}

fn rule_test_matches(
region: &WorldGenRegion<'_>,
registry: &Registry,
random: &mut WorldgenRandom,
rule: &RuleTest,
pos: BlockPos,
) -> bool {
let state = region.block_state(pos);
match rule {
RuleTest::BlockMatch { block } => state.get_block() == *block,
RuleTest::BlockStateMatch { block_state } => {
state == FeatureDecorationRunner::block_state_from_data(registry, block_state)
}
RuleTest::RandomBlockMatch { block, probability } => {
state.get_block() == *block && random.next_f32() < *probability
}
RuleTest::TagMatch { tag } => registry.blocks.is_in_tag(state.get_block(), tag),
}
}

const fn place_no_op(
_context: &mut ConfiguredFeaturePlaceContext<'_, '_>,
_kind: &ConfiguredFeatureKind,
) -> bool {
true
}

fn place_random_boolean_selector(
context: &mut ConfiguredFeaturePlaceContext<'_, '_>,
kind: &ConfiguredFeatureKind,
Expand Down
16 changes: 11 additions & 5 deletions steel-core/src/worldgen/feature/features/fossil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::super::prelude::*;
use super::super::runner::FeatureDecorationRunner;
use steel_registry::structure::LiquidSettingsData;
use steel_registry::structure_processor::StructureProcessorKind;
use steel_registry::template_pool::ProcessorList;

const VANILLA_ROTATIONS: [Rotation; 4] = [
Rotation::None,
Expand Down Expand Up @@ -129,13 +130,18 @@ impl FeatureDecorationRunner {

fn structure_processors<'a>(
registry: &'a Registry,
key: &Identifier,
processors: &'a ProcessorList,
context: &str,
) -> &'a [StructureProcessorKind] {
let Some(processor_list) = registry.structure_processors.by_key(key) else {
panic!("{context} references unknown processor list {key}");
};
&processor_list.data.processors
match processors {
ProcessorList::Empty => &[],
ProcessorList::Registry(key) => {
let Some(processor_list) = registry.structure_processors.by_key(key) else {
panic!("{context} references unknown processor list {key}");
};
&processor_list.data.processors
}
}
}

fn lowest_fossil_surface_y(
Expand Down
8 changes: 3 additions & 5 deletions steel-core/src/worldgen/feature/features/multiface_growth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::super::prelude::*;
use super::super::runner::FeatureDecorationRunner;
use smallvec::SmallVec;
use steel_registry::feature::BlockHolderSet;
use steel_registry::vanilla_block_tags::BlockTag;

#[derive(Clone, Copy)]
Expand All @@ -19,7 +20,7 @@ struct ResolvedMultifaceGrowth<'a> {
raw: &'a MultifaceGrowthConfiguration,
place_block: BlockRef,
default_state: BlockStateId,
can_be_placed_on: &'a [BlockRef],
can_be_placed_on: &'a BlockHolderSet,
is_sculk_vein: bool,
}

Expand Down Expand Up @@ -402,10 +403,7 @@ impl FeatureDecorationRunner {
config: &ResolvedMultifaceGrowth<'_>,
state: BlockStateId,
) -> bool {
config
.can_be_placed_on
.iter()
.any(|block| state.get_block() == *block)
config.can_be_placed_on.contains(state.get_block())
}

fn multiface_is_place_block(config: &ResolvedMultifaceGrowth<'_>, state: BlockStateId) -> bool {
Expand Down
42 changes: 34 additions & 8 deletions steel-core/src/worldgen/feature/features/ore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl FeatureDecorationRunner {
pending_section.key.chunk_z,
pending_section.key.section_index,
&pending_section.positions,
|block_state| targets.matching_replacement(registry, block_state),
|block_state| targets.matching_replacement(registry, block_state, random),
);
}
if let Some(started_at) = batch_apply_started_at
Expand Down Expand Up @@ -384,7 +384,7 @@ impl FeatureDecorationRunner {
) -> bool {
if config.discard_chance_on_air_exposure <= 0.0 {
return sections.replace_ore_target_block_state(pos, |block_state| {
targets.matching_replacement(registry, block_state)
targets.matching_replacement(registry, block_state, random)
});
}

Expand All @@ -410,7 +410,8 @@ impl FeatureDecorationRunner {
pos: BlockPos,
block_id: usize,
) -> bool {
if !target.matches_block_id(block_id) {
let state = region.block_state(pos);
if !target.matches_state(state, block_id, random) {
return false;
}

Expand All @@ -430,7 +431,8 @@ impl FeatureDecorationRunner {
pos: BlockPos,
block_id: usize,
) -> bool {
if !target.matches_block_id(block_id) {
let state = sections.ore_target_block_state(pos);
if !target.matches_state(state, block_id, random) {
return false;
}

Expand Down Expand Up @@ -514,7 +516,9 @@ struct ResolvedOreTarget {

enum ResolvedOreRuleTest {
Block(usize),
BlockState(BlockStateId),
Tag(SmallVec<[usize; 8]>),
RandomBlock(usize, f32),
}

#[derive(Clone, Copy)]
Expand Down Expand Up @@ -559,6 +563,16 @@ impl ResolvedOreTargets {
for target in &config.targets {
let matcher = match &target.target {
RuleTest::BlockMatch { block } => ResolvedOreRuleTest::Block(block.id()),
RuleTest::BlockStateMatch { block_state } => ResolvedOreRuleTest::BlockState(
WorldgenStateResolver::feature_block_state_from_data(
registry,
block_state,
"ore feature target",
),
),
RuleTest::RandomBlockMatch { block, probability } => {
ResolvedOreRuleTest::RandomBlock(block.id(), *probability)
}
RuleTest::TagMatch { tag } => {
let block_ids = registry
.blocks
Expand Down Expand Up @@ -587,11 +601,14 @@ impl ResolvedOreTargets {
&self,
registry: &Registry,
state: BlockStateId,
random: &mut WorldgenRandom,
) -> Option<BlockStateId> {
let block_id = Self::block_id_for_state(registry, state);
self.targets
.iter()
.find_map(|target| target.matches_block_id(block_id).then_some(target.state))
self.targets.iter().find_map(|target| {
target
.matches_state(state, block_id, random)
.then_some(target.state)
})
}

fn block_id_for_state(registry: &Registry, state: BlockStateId) -> usize {
Expand All @@ -603,10 +620,19 @@ impl ResolvedOreTargets {
}

impl ResolvedOreTarget {
fn matches_block_id(&self, block_id: usize) -> bool {
fn matches_state(
&self,
state: BlockStateId,
block_id: usize,
random: &mut WorldgenRandom,
) -> bool {
match &self.matcher {
ResolvedOreRuleTest::Block(target_block_id) => block_id == *target_block_id,
ResolvedOreRuleTest::BlockState(target_state) => state == *target_state,
ResolvedOreRuleTest::Tag(block_ids) => block_ids.contains(&block_id),
ResolvedOreRuleTest::RandomBlock(target_block_id, probability) => {
block_id == *target_block_id && random.next_f32() < *probability
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion steel-core/src/worldgen/feature/features/tree/foliage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl FeatureDecorationRunner {
FoliagePlacer::Acacia(_) => 0,
FoliagePlacer::DarkOak(_) => 4,
FoliagePlacer::Jungle(placer) => placer.height.sample(random),
FoliagePlacer::RandomSpread(placer) => placer.foliage_height,
FoliagePlacer::RandomSpread(placer) => placer.foliage_height.sample(random),
FoliagePlacer::Cherry(placer) => placer.height.sample(random),
}
}
Expand Down
19 changes: 17 additions & 2 deletions steel-core/src/worldgen/feature/features/tree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use steel_registry::feature::BlockHolderSet;
use steel_registry::vanilla_block_tags::BlockTag;

use super::super::prelude::*;
Expand Down Expand Up @@ -187,7 +188,7 @@ impl FeatureDecorationRunner {
) -> bool {
match trunk_placer {
TrunkPlacer::UpwardsBranching(placer) => {
Self::tree_valid_pos_or_tag(region, pos, &placer.can_grow_through)
Self::tree_valid_pos_or_tag_id(region, pos, &placer.can_grow_through)
}
TrunkPlacer::Straight(_)
| TrunkPlacer::Forking(_)
Expand All @@ -200,7 +201,21 @@ impl FeatureDecorationRunner {
}
}

fn tree_valid_pos_or_tag(region: &WorldGenRegion<'_>, pos: BlockPos, tag: &Identifier) -> bool {
fn tree_valid_pos_or_tag(
region: &WorldGenRegion<'_>,
pos: BlockPos,
tag: &BlockHolderSet,
) -> bool {
let state = region.block_state(pos);
let block = state.get_block();
state.is_air() || block.has_tag(&BlockTag::REPLACEABLE_BY_TREES) || tag.contains(block)
}

fn tree_valid_pos_or_tag_id(
region: &WorldGenRegion<'_>,
pos: BlockPos,
tag: &Identifier,
) -> bool {
let state = region.block_state(pos);
let block = state.get_block();
state.is_air() || block.has_tag(&BlockTag::REPLACEABLE_BY_TREES) || block.has_tag(tag)
Expand Down
28 changes: 8 additions & 20 deletions steel-core/src/worldgen/feature/features/tree/roots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ impl FeatureDecorationRunner {
placer: &MangroveRootPlacer,
placement: &mut TreePlacement,
) {
if Self::block_matches_identifiers(
registry,
region.block_state(pos),
&placer.mangrove_root_placement.muddy_roots_in,
) {
if placer
.mangrove_root_placement
.muddy_roots_in
.contains(region.block_state(pos).get_block())
{
let state = Self::sample_block_state_provider(
region,
registry,
Expand All @@ -210,31 +210,19 @@ impl FeatureDecorationRunner {
placement.set_root(region, pos, state);

let above = pos.above();
if random.next_f32() < placer.above_root_placement.above_root_placement_chance
if let Some(above_root) = &placer.above_root_placement
&& random.next_f32() < above_root.above_root_placement_chance
&& region.block_state(above).is_air()
{
let state = Self::sample_block_state_provider(
region,
registry,
random,
&placer.above_root_placement.above_root_provider,
&above_root.above_root_provider,
above,
);
let state = Self::copy_waterlogged_from(region, above, state);
placement.set_root(region, above, state);
}
}

fn block_matches_identifiers(
registry: &Registry,
state: BlockStateId,
blocks: &[Identifier],
) -> bool {
blocks.iter().any(|block_key| {
let Some(block) = registry.blocks.by_key(block_key) else {
panic!("mangrove root placement references unknown block {block_key}");
};
state.get_block() == block
})
}
}
2 changes: 1 addition & 1 deletion steel-core/src/worldgen/feature/features/tree/trunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ impl FeatureDecorationRunner {
config: &TreeConfiguration,
placement: &mut TreePlacement,
) -> bool {
if !Self::tree_valid_pos_or_tag(region, pos, can_grow_through) {
if !Self::tree_valid_pos_or_tag_id(region, pos, can_grow_through) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions steel-core/src/worldgen/feature/predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ impl FeatureDecorationRunner {
}
BlockPredicate::MatchingBlocks { blocks, offset } => {
let state = region.block_state(Self::offset(origin, offset));
blocks.0.contains(&state.get_block())
blocks.contains(state.get_block())
}
BlockPredicate::MatchingFluids { fluids, offset } => {
let state = region.block_state(Self::offset(origin, offset));
let fluid_state = get_fluid_state_from_block(state);
fluids.0.contains(&fluid_state.fluid_id)
fluids.contains(fluid_state.fluid_id)
}
BlockPredicate::Solid { offset } => {
region.block_state(Self::offset(origin, offset)).is_solid()
Expand Down
Loading
Loading