Merge pull request #2424 from kacpherek/fix/note-block-particle
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `NoteBlock.triggerEvent` adds the note particle 1.2 above the block with note / 24 as its colour, as here. Gate: this wave's 50 PRs merged on main in one tree (union 9033a9c3b): fmt and clippy `-D warnings` clean, the horizon-client (1136 lib plus the integration tests), horizon-client-core (37), horizon-world (165) and horizon-protocol (100) tests pass, the fast build links, and the 140 harnesses `parity.py` picks for the tree's changed files pass on playhorizon (remote_fireworks, a known load flake there, passed on a rerun on a quiet Mac mini). `lan_e2e.py` passes 14 checks with the host on its server thread and in-frame (chest, xp, damage, kills, projectiles, mobs, drops, body, stopsound, digging, instant_digging, books, knockback, barter); `hurt` fails on main too when run after `damage` (check-order dependency, not this wave). Thanks @kacpherek!
This commit is contained in:
@@ -3192,6 +3192,31 @@ impl Game<'_> {
|
||||
LevelEvent::BlockEntityEvent { pos, a, b, .. } => {
|
||||
self.block_entity_event([pos.x, pos.y, pos.z], a, b)
|
||||
}
|
||||
// NoteBlock.triggerEvent: a NOTE particle above, coloured by
|
||||
// the note (`note / 24.0` in the x speed).
|
||||
LevelEvent::BlockEvent {
|
||||
pos,
|
||||
state,
|
||||
kind: "note_particle",
|
||||
} => {
|
||||
use horizon_client::particles::{ParticleOptions, ParticleType};
|
||||
let note = self
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
.and_then(|s| s.properties.get("note")?.parse::<f64>().ok())
|
||||
.unwrap_or(0.0);
|
||||
self.particles.add(
|
||||
&ParticleOptions::simple(ParticleType::Note),
|
||||
[
|
||||
f64::from(pos.x) + 0.5,
|
||||
f64::from(pos.y) + 1.2,
|
||||
f64::from(pos.z) + 0.5,
|
||||
],
|
||||
[note / 24.0, 0.0, 0.0],
|
||||
);
|
||||
}
|
||||
LevelEvent::GrowTree { .. }
|
||||
| LevelEvent::PlaceFeature { .. }
|
||||
| LevelEvent::BlockEvent { .. } => {}
|
||||
|
||||
@@ -1174,7 +1174,8 @@ impl<L: LevelAccess + ?Sized> Sim<'_, L> {
|
||||
self.game_event(pos, "minecraft:note_block_play");
|
||||
}
|
||||
}
|
||||
/// `NoteBlock.triggerEvent`: the note's sound.
|
||||
/// `NoteBlock.triggerEvent`: the note's particle (tunable instruments)
|
||||
/// and sound.
|
||||
pub(crate) fn note_trigger_event(&mut self, pos: BlockPos, state: BlockStateId) {
|
||||
let b = self.b;
|
||||
let instrument = b.table.text(state, b.props.instrument).to_owned();
|
||||
@@ -1186,6 +1187,12 @@ impl<L: LevelAccess + ?Sized> Sim<'_, L> {
|
||||
let pitch = if mob_head {
|
||||
1.0
|
||||
} else {
|
||||
// `isTunable`: the client adds the NOTE particle above the block.
|
||||
self.emit(LevelEvent::BlockEvent {
|
||||
pos,
|
||||
state,
|
||||
kind: "note_particle",
|
||||
});
|
||||
horizon_core::jmath::pow(2.0, f64::from(note - 12) / 12.0) as f32
|
||||
};
|
||||
let sound = match instrument.as_str() {
|
||||
|
||||
Reference in New Issue
Block a user