Skip to content

Commit 3cd8807

Browse files
committed
fix : rebase issues
1 parent 996c6e7 commit 3cd8807

File tree

3 files changed

+16
-44
lines changed

3 files changed

+16
-44
lines changed

src/components/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ bitcode_derive = { workspace = true }
1717
temper-data = { workspace = true }
1818
bevy_math = { workspace = true }
1919
uuid = { workspace = true }
20-
temper-core = { workspace = true }
2120
type_hash = { workspace = true }

src/game_systems/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ physics = { path = "./src/physics" }
1111
player = { path = "./src/player" }
1212
shutdown = { path = "./src/shutdown" }
1313
world = { path = "./src/world" }
14-
interaction = { path = "./src/interaction" }
14+
interactions = { path = "./src/interactions" }
1515

1616
bevy_ecs = { workspace = true }
1717

src/game_systems/src/packets/src/place_block.rs

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ use bevy_ecs::message::MessageWriter;
22
use bevy_ecs::prelude::{Entity, Query, Res};
33
use interactions::block_interactions::is_interactive;
44
use temper_codec::net_types::network_position::NetworkPosition;
5-
use temper_components::bounds::CollisionBounds;
6-
use temper_codec::net_types::var_int::VarInt;
75
use temper_components::player::position::Position;
86
use temper_components::{bounds::CollisionBounds, player::sneak::SneakState};
9-
use temper_core::block_data::BlockData;
107
use temper_core::pos::BlockPos;
118
use temper_messages::BlockInteractMessage;
9+
1210
use temper_net_runtime::connection::StreamWriter;
1311
use temper_protocol::PlaceBlockReceiver;
1412
use temper_protocol::outgoing::block_change_ack::BlockChangeAck;
@@ -44,49 +42,29 @@ pub fn handle(
4442
)>,
4543
pos_q: Query<(&Position, &CollisionBounds)>,
4644
mut world_change: MessageWriter<WorldChange>,
47-
mut interact_writer: MessageWriter<BlockInteractMessage>,
45+
mut block_interact: MessageWriter<BlockInteractMessage>,
4846
) {
4947
'ev_loop: for (event, eid) in receiver.0.try_iter() {
50-
let Ok((entity, conn, inventory, hotbar, pos, rot, sneak_state)) = query.get(eid) else {
48+
let Ok((entity, conn, inventory, hotbar, pos, rot, sneak)) = query.get(eid) else {
5149
debug!("Could not get connection for entity {:?}", eid);
5250
continue;
5351
};
5452
if !state.0.players.is_connected(entity) {
5553
trace!("Entity {:?} is not connected", entity);
5654
continue;
5755
}
58-
59-
// Convert network position to block position (the block that was clicked)
60-
let clicked_pos: BlockPos = event.position.clone().into();
61-
62-
// Check if the clicked block is interactive and the player is NOT sneaking
56+
// If the clicked block is interactive and the player is not sneaking,
57+
// dispatch an interaction and skip block placement entirely.
6358
{
64-
let chunk_result = temper_world::World::get_or_generate_mut(
65-
&state.0.world,
66-
clicked_pos.chunk(),
67-
Dimension::Overworld,
68-
);
69-
let chunk = match chunk_result {
70-
Ok(c) => c,
71-
Err(e) => {
72-
error!("Failed to load chunk for interaction check: {:?}", e);
73-
continue 'ev_loop;
74-
}
75-
};
76-
77-
let clicked_block_state = chunk.get_block(clicked_pos.chunk_block_pos());
78-
79-
debug!(
80-
"PlaceBlock event: pos=({}, {}, {}), clicked_block_state={} (raw: {})",
81-
clicked_pos.pos.x,
82-
clicked_pos.pos.y,
83-
clicked_pos.pos.z,
84-
clicked_block_state,
85-
clicked_block_state.raw()
86-
);
87-
88-
if !sneak_state.is_sneaking && is_interactive(clicked_block_state) {
89-
interact_writer.write(BlockInteractMessage {
59+
let clicked_pos: BlockPos = event.position.clone().into();
60+
let chunk = state
61+
.0
62+
.world
63+
.get_or_generate_chunk(clicked_pos.chunk(), Dimension::Overworld)
64+
.expect("Failed to load chunk for interaction check");
65+
let clicked_block = chunk.get_block(clicked_pos.chunk_block_pos());
66+
if !sneak.is_sneaking && is_interactive(clicked_block) {
67+
block_interact.write(BlockInteractMessage {
9068
player: entity,
9169
position: clicked_pos,
9270
sequence: event.sequence,
@@ -252,7 +230,7 @@ pub fn handle(
252230

253231
let (block_chunk_x, block_chunk_z) = (block_chunk.x(), block_chunk.z());
254232
let render_distance = get_global_config().chunk_render_distance as i32;
255-
for (_, conn, _, _, pos, _) in query.iter() {
233+
for (_, conn, _, _, pos, _, _) in query.iter() {
256234
let chunk = pos.chunk();
257235
let (chunk_x, chunk_z) = (chunk.x(), chunk.z());
258236

@@ -264,11 +242,6 @@ pub fn handle(
264242
error!("Failed to send block update packet: {:?}", err);
265243
}
266244
}
267-
if let Some(ref upper_update) = upper_half_update
268-
&& let Err(err) = conn.send_packet_ref(upper_update)
269-
{
270-
error!("Failed to send block update packet: {:?}", err);
271-
}
272245
}
273246
}
274247
let ack_packet = BlockChangeAck {

0 commit comments

Comments
 (0)