Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2f76d0f
feat: Add Vanilla-compatible destructive explosions and TNT
kdcokenny Oct 7, 2026
afa98c5
refactor: Address explosion review feedback
kdcokenny Oct 7, 2026
ceab24d
perf: Build stable-air occupancy from section palettes
kdcokenny Oct 7, 2026
1dee124
refactor: Simplify explosion code
kdcokenny Oct 7, 2026
a5d1804
Merge branch 'master' into kdcokenny/finish-explosions
kdcokenny Oct 9, 2026
dfc06c9
fix: preserve Java tree-bin order for explosions
kdcokenny Oct 10, 2026
5885032
Merge branch 'master' into kdcokenny/finish-explosions
kdcokenny Oct 11, 2026
b5bc0af
fix: scope explosion randomness without a world RNG
kdcokenny Oct 12, 2026
fdeac98
Merge branch 'master' into kdcokenny/finish-explosions
kdcokenny Oct 12, 2026
3fe3de8
Merge branch 'master' into kdcokenny/finish-explosions
JunkyDeveloper Oct 22, 2026
55f9435
fmt
JunkyDeveloper Oct 22, 2026
a60a499
fmt
JunkyDeveloper Oct 22, 2026
fe93fed
fixes
Joniii11 Oct 23, 2026
f8d54b2
Merge branch 'master' into kdcokenny/finish-explosions
JunkyDeveloper Oct 24, 2026
57c24bb
fmt
JunkyDeveloper Oct 24, 2026
876ed57
clippy
JunkyDeveloper Oct 24, 2026
1cf104b
clippy
JunkyDeveloper Oct 24, 2026
ba2e414
Merge remote-tracking branch 'Joniii11/fix/pr428-review' into pr/428
JunkyDeveloper Oct 25, 2026
79e77de
remove some magic number and comment
coco875 Oct 25, 2026
270ea4b
merge both JavaBlockPosSet
coco875 Oct 25, 2026
3ed863b
replace with json
coco875 Oct 26, 2026
bf62392
more json
coco875 Oct 26, 2026
1f83186
fix warning
coco875 Oct 26, 2026
357b377
Merge remote-tracking branch 'upstream/master' into pr/428
coco875 Oct 26, 2026
3fcd950
Merge branch 'master' into kdcokenny/finish-explosions
JunkyDeveloper Oct 26, 2026
f9f04d8
fixes from claude
JunkyDeveloper Oct 27, 2026
15bebd0
Merge branch 'master' into kdcokenny/finish-explosions
JunkyDeveloper Oct 27, 2026
3b0b1ba
I think for big explosions every microsecond counts, so here I was ab…
JunkyDeveloper Oct 28, 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
13 changes: 13 additions & 0 deletions steel-core/src/behavior/block/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub struct BlockLootContext<'a> {
entity: Option<&'a dyn Entity>,
block_entity: Option<&'a dyn BlockEntity>,
tool: Option<&'a ItemStack>,
explosion_radius: Option<f32>,
luck: f32,
}

Expand All @@ -125,6 +126,7 @@ impl<'a> BlockLootContext<'a> {
entity: None,
block_entity: None,
tool: None,
explosion_radius: None,
luck: 0.0,
}
}
Expand All @@ -150,6 +152,13 @@ impl<'a> BlockLootContext<'a> {
self
}

/// Adds the explosion radius used by explosion-decay loot functions.
#[must_use]
pub const fn with_explosion(mut self, radius: f32) -> Self {
self.explosion_radius = Some(radius);
self
}

/// Adds the luck used to evaluate the loot table.
#[must_use]
pub const fn with_luck(mut self, luck: f32) -> Self {
Expand Down Expand Up @@ -187,6 +196,10 @@ impl<'a> BlockLootContext<'a> {
self.tool
}

pub(crate) const fn explosion_radius(&self) -> Option<f32> {
self.explosion_radius
}

pub(crate) const fn luck(&self) -> f32 {
self.luck
}
Expand Down
77 changes: 75 additions & 2 deletions steel-core/src/behavior/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ use crate::physics::collide;
use crate::player::Player;
use crate::world::game_event::SharedGameEventListener;
use crate::world::{
ClipHitResult, ConditionalBlockSetResult, LevelAccessor, LevelReader, ScheduledTickAccess,
SignalQueryContext, World,
BlockInteraction, ClipHitResult, ConditionalBlockSetResult, Explosion, LevelAccessor,
LevelReader, ScheduledTickAccess, SignalQueryContext, World,
};
use steel_registry::vanilla_fluids;

Expand Down Expand Up @@ -400,6 +400,79 @@ pub trait BlockBehavior: Send + Sync {
) {
}

/// Applies Vanilla's default block response to an explosion.
fn on_explosion_hit(
&self,
state: BlockStateId,
world: &Arc<World>,
pos: BlockPos,
explosion: &dyn Explosion,
on_hit: &mut dyn FnMut(ItemStack, BlockPos),
) {
self.default_on_explosion_hit(state, world, pos, explosion, on_hit);
}

/// Applies the default response from an overriding explosion hook.
fn default_on_explosion_hit(
&self,
state: BlockStateId,
world: &Arc<World>,
pos: BlockPos,
explosion: &dyn Explosion,
on_hit: &mut dyn FnMut(ItemStack, BlockPos),
) {
if state.is_air() {
return;
}
Comment thread
coco875 marked this conversation as resolved.

if self.drop_from_explosion(explosion) {
let empty_tool = ItemStack::empty();
let block_entity = if state.has_block_entity() {
world.get_block_entity(pos)
} else {
None
};
let context = BlockLootContext::new(world, pos)
.with_block_entity(block_entity.as_deref())
.with_entity(explosion.direct_source_entity())
.with_tool(&empty_tool);
let context = if explosion.block_interaction() == BlockInteraction::DestroyWithDecay {
context.with_explosion(explosion.radius())
} else {
context
};
let drop_experience = explosion
.indirect_source_entity()
.is_some_and(|entity| entity.as_player().is_some());
self.spawn_after_break(state, world, pos, &empty_tool, drop_experience);
for stack in World::block_drops(state, &context) {
on_hit(stack, pos);
}
}

world.set_block(
pos,
vanilla_blocks::AIR.default_state(),
UpdateFlags::UPDATE_ALL,
);
self.was_exploded(state, world, pos, explosion);
}

/// Called after this block is removed by an explosion.
fn was_exploded(
&self,
_state: BlockStateId,
_world: &Arc<World>,
_pos: BlockPos,
_explosion: &dyn Explosion,
) {
}

/// Returns whether this block contributes normal explosion loot.
fn drop_from_explosion(&self, _explosion: &dyn Explosion) -> bool {
true
}

/// Called after this block is removed from the world, to affect neighbors.
///
/// This is used for things like rails notifying neighbors when removed.
Expand Down
7 changes: 1 addition & 6 deletions steel-core/src/behavior/blocks/redstone/java_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ pub(super) fn sort_small_map_positions(positions: &mut [BlockPos]) {

#[must_use]
pub(super) const fn bucket(pos: BlockPos) -> u32 {
let hash = pos
.z()
.wrapping_mul(31)
.wrapping_add(pos.y())
.wrapping_mul(31)
.wrapping_add(pos.x()) as u32;
let hash = pos.java_hash_code() as u32;
(hash ^ (hash >> 16)) & 15
}
2 changes: 2 additions & 0 deletions steel-core/src/behavior/blocks/redstone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod redstone_lamp_block;
mod redstone_ore_block;
mod redstone_torch_block;
mod target_block;
mod tnt_block;
mod tripwire;
mod weathering_lightning_rod_block;
mod wire;
Expand Down Expand Up @@ -43,6 +44,7 @@ pub use redstone_lamp_block::*;
pub use redstone_ore_block::*;
pub use redstone_torch_block::*;
pub use target_block::*;
pub use tnt_block::*;
pub use tripwire::*;
pub use weathering_lightning_rod_block::*;
pub use wire::*;
Loading
Loading