Trait ClientInputClientHost
pub trait ClientInputClientHost {
// Provided methods
fn claim_items(&mut self, mod_id: &str, ids: &[String]) { ... }
fn poll(&mut self, mod_id: &str) -> Vec<ModEvent> { ... }
fn cursor(&self) -> [f32; 2] { ... }
fn mod_key(
&self,
mod_id: &str,
name: &str,
) -> Option<(String, ClientModifiers)> { ... }
fn playing(&self) -> bool { ... }
fn mapping(&self, name: &str) -> Result<Option<KeyMapping>, TextFormError> { ... }
fn millis(&self) -> u64 { ... }
fn modifiers(&self) -> ClientModifiers { ... }
fn clipboard_text(&self) -> Option<String> { ... }
fn set_clipboard_text(&self, text: &str) -> bool { ... }
}Expand description
The client host’s methods of the client_input area, implemented by the game and reached through crate::ClientHost.
Provided Methods§
fn claim_items(&mut self, mod_id: &str, ids: &[String])
fn claim_items(&mut self, mod_id: &str, ids: &[String])
Side: client.
Right-clicks with these items (at most 64 ids) are mod mod_id’s; a later call replaces the list.
fn poll(&mut self, mod_id: &str) -> Vec<ModEvent>
fn poll(&mut self, mod_id: &str) -> Vec<ModEvent>
Side: client.
Mod mod_id’s events since its last poll (at most 256 wait).
fn mod_key(&self, mod_id: &str, name: &str) -> Option<(String, ClientModifiers)>
fn mod_key(&self, mod_id: &str, name: &str) -> Option<(String, ClientModifiers)>
Side: client. The saved key and modifiers for an owner-bound registration, or its declared default.
fn mapping(&self, name: &str) -> Result<Option<KeyMapping>, TextFormError>
fn mapping(&self, name: &str) -> Result<Option<KeyMapping>, TextFormError>
Side: client.
A vanilla mapping (key.forward, key.jump, key.attack…): whether
it is held (KeyMapping.isDown), and its key’s name as Controls shows
it. Ok(None) for a mapping it doesn’t answer for. Refuses an invalid
label with TextFormError, including components deeper than 512 nodes.
fn millis(&self) -> u64
fn millis(&self) -> u64
Side: client.
Milliseconds on the game’s own clock (Util.getMillis), counting from the game’s start:
what a text field’s cursor blinks by and what tells a double click from two clicks.
Only differences between two readings mean anything.
fn modifiers(&self) -> ClientModifiers
fn modifiers(&self) -> ClientModifiers
Side: client. The current window modifier keys in the same GLFW encoding as input hooks. Cleared when the window loses focus; available even outside a world.
fn clipboard_text(&self) -> Option<String>
fn clipboard_text(&self) -> Option<String>
Side: client.
The clipboard’s text (KeyboardHandler.getClipboard), empty when it holds none,
while the game handles a key, mouse or typed-text event: a mod’s key or screen hook
pasting into its own field. None at any other moment (a tick, a frame, a packet),
so no mod reads the clipboard without the player doing something, and None on a
server.
fn set_clipboard_text(&self, text: &str) -> bool
fn set_clipboard_text(&self, text: &str) -> bool
Side: client.
Puts text on the clipboard (KeyboardHandler.setClipboard) on the same terms as
native_clipboard_text reads it. False, with nothing copied, at any other moment or
on a server; empty text copies nothing, as vanilla’s.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".