Skip to main content

ScreenView

Struct ScreenView 

#[non_exhaustive]
pub struct ScreenView<'a> { pub id: &'static str, pub menu: Option<&'a str>, pub title: Option<&'a Text>, pub rect: [f32; 4], pub slots: usize, pub mouse: [f32; 2], pub partial_tick: f32, }
Expand description

The open screen, for the screen hooks (native_screen_render_post, the mouse ones native_screen_mouse_button_pressed_pre, ..._released_pre and native_screen_mouse_scrolled_pre, and the key ones native_screen_key_pressed_pre and native_screen_char_typed_pre): what it is, its menu and title, where its container panel is, how many slots its menu has, and where the mouse and the frame’s partial tick are.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: &'static str

One id per Screen (Screen::id): inventory, creative, paused, stats, options, win… Stable across releases, so a mod can match on it. Every container, station and mod window draws on the inventory screen and so reports inventory: tell them apart by menu and title (both None on a window the client opened itself) and by slots. The title’s own screens report theirs: title, world_select, world_create, world_create_flat, world_edit, multiplayer, add_server, direct_connect…, with no menu, no title and no slots.

§menu: Option<&'a str>

The type id of the menu the server opened for this screen (minecraft:generic_9x3, minecraft:furnace, a mod’s own id; a mount’s inventory is horizon:mount<n>). None on a screen without one (the client’s own inventory, creative, the pause menu, stats…) and for a menu type the client does not know.

§title: Option<&'a Text>

The title the server gave the open menu, if it has one: the component itself, borrowed as an owned API component tree. None when the server gave none, on a screen the client opened, and while playing.

§rect: [f32; 4]

The screen’s container panel in GUI pixels, [x, y, width, height]; the whole window for a screen with none. The panel is where the game draws the window: 176 wide for most, wider for the merchant and the beacon, a mod screen’s own size for a mod’s.

§slots: usize

The slots the open menu has, as Game::slots counts them: the player inventory’s 36, then the container’s, the station’s, the mod screen’s or the crafting grid’s (a screen with no menu of its own still counts the inventory menu’s). Counted, not listed.

§mouse: [f32; 2]

The pointer in GUI pixels (Screen.mouseX, mouseY, from the window’s top left), as cursor gives it: for hover highlights.

§partial_tick: f32

This frame’s partial tick (getGameTimeDeltaPartialTick(false), 0 to 1): what the screen draws animation against.

Trait Implementations§

§

impl<'a> Clone for ScreenView<'a>

§

fn clone(&self) -> ScreenView<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a> Copy for ScreenView<'a>

§

impl<'a> Debug for ScreenView<'a>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'a> From<ScreenView<'a>> for ScreenView<'a>

§

fn from(v: ScreenView<'a>) -> ScreenView<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for ScreenView<'a>

§

impl<'a> RefUnwindSafe for ScreenView<'a>

§

impl<'a> Send for ScreenView<'a>

§

impl<'a> Sync for ScreenView<'a>

§

impl<'a> Unpin for ScreenView<'a>

§

impl<'a> UnsafeUnpin for ScreenView<'a>

§

impl<'a> UnwindSafe for ScreenView<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.