You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

/* pub fn tnt(
mut commands: Commands,
mut clients: Query<(&mut Inventory, &GameMode, &PlayerInventoryState)>,
mut thingies: Query<Entity, With<Instance>>,
mut events: EventReader<PlayerInteractBlock>,
) {
for event in events.iter() {
let Ok((mut inventory, game_mode, inv_state)) = clients.get_mut(event.client) else {
continue;
};
if event.hand != Hand::Main {
continue;
}
let slot_id = inv_state.held_item_slot();
let Some(stack) = inventory.slot(slot_id) else {
continue;
};
let Some(block_kind) = stack.item.to_block_kind() else {
continue;
};
if block_kind != BlockKind::Tnt {
continue;
}
if *game_mode == GameMode::Survival {
if stack.count() > 1 {
let count = stack.count();
inventory.set_slot_amount(slot_id, count - 1);
} else {
inventory.set_slot(slot_id, None);
}
}
let real_pos = event.position.get_in_direction(event.direction);
tracing::info!(
"Spawning TNT ({}, {}, {})!",
real_pos.x,
real_pos.y,
real_pos.z
);
commands.spawn(TntEntityBundle {
location: Location(thingies.single()),
position: Position(DVec3 {
x: real_pos.x as f64 + 0.5,
y: real_pos.y as f64,
z: real_pos.z as f64 + 0.5,
}),
..Default::default()
});
}
} */