You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use valence::client::despawn_disconnected_clients;use valence::network::ConnectionMode;use valence::prelude::*;#[allow(unused_imports)]usecrate::extras::*;constSPAWN_Y:i32 = 64;pubfnbuild_app(app:&mutApp){
app.insert_resource(NetworkSettings{connection_mode:ConnectionMode::Offline,
..Default::default()}).add_plugins(DefaultPlugins).add_startup_system(setup).add_system(init_clients).add_system(listener).add_system(despawn_disconnected_clients).add_system(toggle_gamemode_on_sneak.in_schedule(EventLoopSchedule));}fnsetup(mutcommands:Commands,server:Res<Server>,biomes:Query<&Biome>,dimensions:Query<&DimensionType>,){letmut instance = Instance::new(ident!("overworld"),&dimensions,&biomes,&server);for z in -5..5{for x in -5..5{
instance.insert_chunk([x, z],Chunk::default());}}for z in -25..25{for x in -25..25{// Insta-break block
instance.set_block([x,SPAWN_Y, z],BlockState::TNT);}}
commands.spawn(instance);}fninit_clients(mutclients:Query<(&mutLocation,&mutPosition),Added<Client>>,instances:Query<Entity,With<Instance>>,){for(mut loc,mut pos)in&mut clients {
loc.0 = instances.single();
pos.set([0.5,SPAWN_Yasf64 + 1.0,0.5]);}}fnlistener(mutinstances:Query<&mutInstance>,mutevents:EventReader<Digging>){letmut instance = instances.single_mut();for event in events.iter(){if event.state == DiggingState::Stop{
instance.set_block(event.position,BlockState::AIR);}}}
What Went Wrong
I expected for when a block is insta-broken for it to fire an event with the state DiggingState::Stop.
This is actually a bug in the Minecraft client and is out of our control unfortunately. I would leave a link to the issue in the Minecraft bug tracker here, but I can't find it right now.
We can leave this issue open until it's fixed by Mojang.
Valence Version
8897eea (latest as of date of issue)
What You Did
I have code to listen for when a block is mined. It works fine for blocks take time to mine, but if a block instant mines (for example, wheat), the Stop event is not fired. This problem also happens in this example:
https://github.com/valence-rs/valence/blob/main/crates/valence/examples/building.rs
What Went Wrong
I expected for when a block is insta-broken for it to fire an event with the state
DiggingState::Stop
.Additional Information
The reason why this is happening is because the
DiggingState::Stop
event is not firing. https://github.com/valence-rs/valence/blob/main/crates/valence/examples/building.rs has this bug. A quick workaround I used is to check if the block is an insta-breakable block or the event state isDiggingState::Stop
Screen recording: https://github.com/valence-rs/valence/assets/47758296/524e9b88-a039-488a-8956-406b417b9641The text was updated successfully, but these errors were encountered: