Note blocks play on a left click, and take mob heads on top
Mining a note block now plays its note and counts the play_noteblock statistic. A mob head used on the top face is placed instead of tuning the block.
This commit is contained in:
@@ -2510,9 +2510,13 @@ impl Game<'_> {
|
||||
self.process_level_events()
|
||||
}
|
||||
fn attack_block(&mut self, pos: [i32; 3]) -> Result<()> {
|
||||
self.with_level(|b, level, ticks| {
|
||||
b.attack_block(level, ticks, BlockPos::new(pos[0], pos[1], pos[2]));
|
||||
let note = self.with_level(|b, level, ticks| {
|
||||
b.attack_block(level, ticks, BlockPos::new(pos[0], pos[1], pos[2]))
|
||||
});
|
||||
// NoteBlock.attack awards the statistic.
|
||||
if note {
|
||||
self.stats.custom("play_noteblock", 1);
|
||||
}
|
||||
self.process_level_events()
|
||||
}
|
||||
/// Track which chunks are ticking (Ticks needs chunk load/unload).
|
||||
|
||||
@@ -513,20 +513,26 @@ impl Behaviours {
|
||||
sim.game_event_state(pos, "minecraft:block_change", next);
|
||||
}
|
||||
|
||||
/// The state change of `RedStoneOreBlock.attack` when mining begins.
|
||||
/// `BlockBehaviour.attack` when mining begins: `RedStoneOreBlock.attack`
|
||||
/// lights the ore, `NoteBlock.attack` plays the note. True for a note
|
||||
/// block, whose player also earns the `play_noteblock` statistic.
|
||||
pub fn attack_block<L: LevelAccess + ?Sized>(
|
||||
&self,
|
||||
level: &mut L,
|
||||
ticks: &mut Ticks,
|
||||
pos: BlockPos,
|
||||
) {
|
||||
) -> bool {
|
||||
let mut sim = self.sim(level, ticks);
|
||||
let state = sim.state(pos);
|
||||
if self.data(state).chain.contains(&Class::RedStoneOre)
|
||||
&& !self.table.bool(state, self.props.lit)
|
||||
{
|
||||
let chain = &self.data(state).chain;
|
||||
if chain.contains(&Class::Note) {
|
||||
sim.note_play(pos, state);
|
||||
return true;
|
||||
}
|
||||
if chain.contains(&Class::RedStoneOre) && !self.table.bool(state, self.props.lit) {
|
||||
sim.set_block_and_update(pos, self.table.set_bool(state, self.props.lit, true));
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// `BlockState.useWithoutItem` for a right-click on `pos` (hit face and
|
||||
@@ -595,6 +601,25 @@ impl Behaviours {
|
||||
if self.data(state).chain.contains(&Class::CopperGolemStatue) {
|
||||
return self.turn_statue(level, ticks, pos, state, item);
|
||||
}
|
||||
// NoteBlock.useItemOn: a mob head on the top face is placed, not tuned
|
||||
// (`#minecraft:noteblock_top_instruments`).
|
||||
if face == Direction::Up
|
||||
&& self.data(state).chain.contains(&Class::Note)
|
||||
&& item.is_some_and(|i| {
|
||||
matches!(
|
||||
i,
|
||||
"minecraft:zombie_head"
|
||||
| "minecraft:skeleton_skull"
|
||||
| "minecraft:creeper_head"
|
||||
| "minecraft:dragon_head"
|
||||
| "minecraft:wither_skeleton_skull"
|
||||
| "minecraft:piglin_head"
|
||||
| "minecraft:player_head"
|
||||
)
|
||||
})
|
||||
{
|
||||
return InteractionResult::Pass;
|
||||
}
|
||||
self.use_without_item(level, ticks, pos, face, hit, player)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user