Skip to main content

PlayerRef

Struct PlayerRef 

pub struct PlayerRef { /* private fields */ }
Expand description

An online player in one open server world, keyed by UUID. A nested guest turn cannot re-enter a player active in an outer turn; operations requiring that player’s swapped state report them unavailable.

Implementations§

§

impl PlayerRef

pub fn recipe_book_settings( self, host: &dyn Host, book: &RecipeBookTypeKey, ) -> Option<RecipeBookSettings>

Side: server. Read one registered custom book’s authoritative flags. A fresh book returns the default pair; an unavailable player or unregistered key returns None. This never reads a vanilla ordinal or pending client intent.

pub fn address(self, host: &dyn Host) -> Option<String>

Side: server. The IP address the player connects from, without the port (behind a Velocity proxy, the address the proxy forwards). Displaced connected players keep their address; an acting player with no known connection has an empty address. None for a stale or unavailable player.

pub fn name(self, host: &dyn Host) -> Option<String>

Side: server. The stable name of a connected or acting player. None for a stale or unavailable player; displaced online players retain their identity.

pub fn level(self, host: &dyn Host) -> Option<LevelRef>

Side: both. The level the online player is in (ServerPlayer.level): on an integrated server or dedicated server, the player’s current dimension; on a client, the client’s level. None for a stale or unavailable player.

pub fn dimension(self, host: &dyn Host) -> Option<Identifier>

Side: both. The dimension the online player is in (ServerPlayer.level().dimension()): minecraft:overworld, minecraft:the_nether, … None for a stale or unavailable player.

pub fn selected_slot(self, host: &dyn Host) -> Option<usize>

Side: both. Inventory.getSelectedSlot: the hotbar slot the player holds, 0..9.

pub fn container_menu(self, host: &dyn Host) -> Option<MenuRef>

Side: both. A player’s current supported menu. Refuses crafting tables, merchants, workstations, lecterns, mounts and menus with hidden slots; also refuses clients, stale players and players whose state is swapped out.

pub fn item_cooldowns(self, host: &dyn Host) -> Option<Vec<ItemCooldown>>

Side: server. Every group the player waits on and its ticks left, ordered by group.

pub fn has_item_cooldown(self, host: &dyn Host, group: &str) -> Option<bool>

Side: server. ItemCooldowns.isOnCooldown: whether group still has time to run.

pub fn item_cooldown_percent(self, host: &dyn Host, group: &str) -> Option<f32>

Side: server. ItemCooldowns.getCooldownPercent(group, 0): what is left of the group’s cooldown, from 1 (just started) to 0 (none).

pub fn attack_strength_scale(self, host: &dyn Host, partial: f32) -> Option<f32>

Side: server. Player.getAttackStrengthScale(partial): the charge the player’s next Player.attack reads, from 0 (just swung) to 1 (full), where partial (vanilla reads 0.5) is how far between ticks the read is. It is (attackStrengthTicker + partial) / getCurrentItemAttackStrengthDelay(), the delay from the attack speed attribute and the main-hand item. Inside attack_entity it reads the charge that blow uses: the hook runs before Player.attack resets the ticker. 1.0 under 1.8.9 rules, which have no cooldown. None for a stale or unavailable player. Non-finite partial ticks return None; finite partials are not restricted.

pub fn exp_cooldown(self, host: &dyn Host) -> Option<u32>

Side: server. Player.takeXpDelay: the ticks before the player can take the next experience orb.

pub fn last_death_location(self, host: &dyn Host) -> Option<GlobalPos>

Side: both. The dimension and block of the player’s last death (Player.getLastDeathLocation).

pub fn needs_food(self, host: &dyn Host) -> Option<bool>

Side: both. FoodData.needsFood: the food level is below 20.

pub fn has_enough_food(self, host: &dyn Host) -> Option<bool>

Side: both. FoodData.hasEnoughFood: the food level is above 6, enough to sprint.

pub fn can_eat(self, host: &dyn Host, always: bool) -> Option<bool>

Side: both. Player.canEat(always): an invulnerable player (creative), always (food that can always be eaten) or a food level below 20.

pub fn experience(self, host: &dyn Host) -> Option<PlayerExperience>

Side: both. Player.experienceLevel, experienceProgress and totalExperience.

pub fn xp_needed_for_next_level(self, host: &dyn Host) -> Option<i32>

Side: both. Player.getXpNeededForNextLevel: the points the current level needs to fill.

pub fn permission_level(self, host: &dyn Host) -> Option<u8>

Side: server. The player’s permission level, 0 to 4 (Player.permissions(), PlayerList.getProfilePermissions): an op’s level, the single-player owner’s 4 with commands allowed. A displaced connected player keeps their permission level even while their body is unavailable. None for a stale or unavailable player.

pub fn has_infinite_materials(self, host: &dyn Host) -> Option<bool>

Side: server. Player.hasInfiniteMaterials: the instabuild ability, which creative mode gives.

pub fn can_use_game_master_blocks(self, host: &dyn Host) -> Option<bool>

Side: server. Player.canUseGameMasterBlocks: creative and a permission level of at least 2, as command blocks, structure blocks and jigsaws ask.

pub fn previous_game_mode(self, host: &dyn Host) -> Option<Option<GameMode>>

Side: server. ServerPlayerGameMode.getPreviousGameModeForPlayer: the mode the player last left (previousPlayerGameType, saved with the player), or Some(None) when they never changed mode. None for a stale or unavailable player.

pub fn is_secondary_use_active(self, host: &dyn Host) -> Option<bool>

Side: both. Player.isSecondaryUseActive: whether the player uses items and blocks as with sneak held, as vanilla reads it from the shift-key flag (the same read as EntityRef::is_shift_key_down). None for a stale or unavailable player.

pub fn is_fake(self, host: &dyn Host) -> Option<bool>

Side: server. Whether a live player handle names a connectionless actor.

pub fn may_use_item_at( self, host: &dyn Host, pos: [i32; 3], face: BlockFace, stack: &ItemStack, ) -> Option<bool>

Side: server. Player.mayUseItemAt(pos, face, stack): whether the player may use stack at pos, the block it would be placed in when clicked on its face. A player who may build (survival, creative) always may; an adventure or spectator player only with a stack whose can_place_on component matches the clicked block, the one pos lies against. The game’s own use runs the same check (ItemStack.useOn, buckets). None for a stale or unavailable player, and for one in another level than the one in place.

pub fn can_harm(self, host: &dyn Host, other: PlayerRef) -> Option<bool>

Side: server. ServerPlayer.canHarmPlayer(other): whether player may hurt other: the pvp game rule is on, and their teams allow it (allies on a team without friendly fire cannot, Player.canHarmPlayer). Attacks, arrows and tridents ask the same. None when either handle is stale or unavailable.

pub fn respawn_config( self, host: &dyn Host, ) -> Option<Option<PlayerRespawnConfig>>

Side: server. ServerPlayer.getRespawnConfig: where the player comes back after dying: a bed, a respawn anchor or a /spawnpoint, with the yaw they face and whether it is forced. Some(None) when they have none and respawn at the world spawn. None for a stale or unavailable player.

pub fn text_filtering(self, host: &dyn Host) -> Option<bool>

Side: server. ServerPlayer.isTextFilteringEnabled: the text-filtering option the player’s client announced (ClientInformation.textFilteringEnabled). False for the player running the server and for an acting player with no connection, as for a client that sent none. None for a stale or unavailable player.

pub fn sleep_ignored(self, host: &dyn Host) -> Option<bool>

Side: server. Whether player_set_sleep_ignored left the player out of the night’s sleep count. False for a player never ignored. None for a stale handle or a player who isn’t online.

pub fn counts_for_sleep(self, host: &dyn Host) -> Option<bool>

Side: server. Whether the player counts in the night’s sleep count (SleepStatus.update): not a spectator, not a fake player, and not left out through player_set_sleep_ignored while out of bed. None for a stale or unavailable player.

pub fn sleep_timer(self, host: &dyn Host) -> Option<u32>

Side: server. Player.getSleepTimer (sleepCounter): the ticks the player has been in bed, 100 once asleep long enough (isSleepingLongEnough, what the night skip waits for), then counting up 101 to 109 and back to 0 once they are up. None for a stale or unavailable player.

pub fn inventory(self, host: &dyn Host) -> Option<Vec<ItemStack>>

Side: both. Inventory.items: the non-empty main inventory stacks in slot order, including their components. None for a stale or unavailable player; on clients only the local player’s inventory is available.

pub fn game_mode(self, host: &dyn Host) -> Option<GameMode>

Side: both. ServerPlayerGameMode.getGameModeForPlayer; Paper HumanEntity#getGameMode. None for stale, offline or unavailable players (including displaced outer players).

pub fn is_creative(self, host: &dyn Host) -> Option<bool>

Side: both. Player.isCreative; Paper HumanEntity#getGameMode.

pub fn is_spectator(self, host: &dyn Host) -> Option<bool>

Side: both. Player.isSpectator; Paper HumanEntity#getGameMode.

pub fn may_build(self, host: &dyn Host) -> Option<bool>

Side: both. Player.mayBuild; Paper HumanEntity#getGameMode.

pub fn food(self, host: &dyn Host) -> Option<PlayerFood>

Side: both. FoodData.getFoodLevel/getSaturationLevel/getExhaustionLevel; Paper HumanEntity#getFoodLevel/getSaturation/getExhaustion. None until the guest’s body exists, as well as for stale or unavailable players.

pub fn abilities(self, host: &dyn Host) -> Option<PlayerAbilities>

Side: both. Player.getAbilities; Paper Player#getAllowFlight/isFlying/getFlySpeed/getWalkSpeed.

pub fn stat( self, host: &dyn Host, stat_type: StatType, key: &str, ) -> Option<i32>

Side: server. The value of statistic stat_type for key (minecraft:stone, minecraft:jump…), as ServerStatsCounter.getValue: 0 when never counted.

pub fn has_discovered_recipe( self, host: &dyn Host, recipe: &str, ) -> Option<bool>

Side: server. Whether the player’s recipe book knows recipe (ServerRecipeBook.contains).

pub fn discovered_recipes(self, host: &dyn Host) -> Option<Vec<String>>

Side: both. The recipes in the player’s recipe book (ServerRecipeBook.recipes), as qualified ids in order (minecraft:oak_planks). None for a player it can’t reach.

pub fn client_brand(self, host: &dyn Host) -> Option<String>

Side: both. The brand the player’s client announced when it connected (ServerPlayer.clientBrand), empty when it sent none. Displaced connected players keep theirs; an acting player with no known connection has an empty one. None for a stale or unavailable player.

pub fn synced_recipe_book_settings( self, host: &dyn ClientHost, book: &RecipeBookTypeKey, ) -> Option<RecipeBookSettings>

Side: client. The local player’s last authoritative custom-book pair. None before negotiation, while resynchronizing, or for a nonlocal/stale handle.

pub fn block_breaking(self, host: &dyn ClientHost) -> Option<BlockBreakingState>

Side: client. The local player’s predicted breaking state, including Idle. None for stale, nonlocal or fake handles and outside a logged-in client world.

pub fn ambient_mood(self, host: &dyn ClientHost) -> Option<f32>

Side: client. The local player’s existing cave ambience mood, normally 0 through 1. None for stale, nonlocal or fake handles and outside a client world.

pub fn set_recipe_book_settings( self, host: &mut dyn ServerHost, book: &RecipeBookTypeKey, settings: RecipeBookSettings, ) -> bool

Side: server. Set a registered custom book’s authoritative pair and synchronize an accepted change. Returns false for an unavailable player, unknown key or exhausted storage. An unchanged pair succeeds without notification.

pub fn tell( self, host: &mut dyn ServerHost, line: Text, ) -> Result<bool, TextFormError>

Side: server. A system line in that player’s chat, also inside a player’s hook for the acting player; false when they aren’t on. Refuses text deeper than 512 component nodes before applying any changes.

pub fn action_bar( self, host: &mut dyn ServerHost, line: Text, ) -> Result<bool, TextFormError>

Side: server. A line over that player’s hotbar (the action bar), also inside a player’s hook for the acting player; false when they aren’t on. Refuses text deeper than 512 component nodes before applying any changes.

pub fn tab_list( self, host: &mut dyn ServerHost, header: &Text, footer: &Text, ) -> Result<bool, TextFormError>

Side: server. The lines over and under that player’s list of players (Tab): ClientboundTabListPacket, an empty text for none. False when they aren’t on. Refuses text deeper than 512 component nodes before applying any changes.

pub fn set_sleep_ignored(self, host: &mut dyn ServerHost, ignored: bool) -> bool

Side: server. Whether that player counts for players_sleeping_percentage: an ignored player who isn’t in bed is left out of the players the night needs asleep, as a spectator is (an away-from-keyboard mod). Kept until a mod sets it back or the server stops, also if they leave and come back. False when the server list is unavailable, the handle is stale or the player isn’t online.

pub fn set_respawn_config( self, host: &mut dyn ServerHost, config: Option<PlayerRespawnConfig>, ) -> bool

Side: server. ServerPlayer.setRespawnPosition, as /spawnpoint sets it: the player’s respawn point becomes config, or is forgotten for None (they then respawn at the world spawn). The yaw wraps to -180..180 (RespawnData.of) and the player_set_spawn hook may cancel the change, which refuses it. Kept with the player’s record. False for a stale or unavailable player, a dead one, a dimension the game doesn’t have, a yaw that is not finite and a canceled change.

pub fn set_sleep_timer(self, host: &mut dyn ServerHost, ticks: u32) -> bool

Side: server. Sets the player’s sleepCounter: 0 to 109, the values the game reaches (see player_sleep_timer). A player in bed at 100 counts as slept long enough for the night skip. False for a value past 109, a stale or unavailable player, a fake player and a player in another level than the one in place.

pub fn set_nickname( self, host: &mut dyn ServerHost, nickname: Option<&str>, ) -> bool

Side: server. Shows nickname in place of that player’s name in chat (their messages, /me, /msg) and in the Tab list; None shows their name again. Hovering the shown name gives the real one, which stays in the log, commands, selectors and the server’s events. Kept until a mod sets it again or the server stops (also if they leave and come back). Plain text: the mod checks it (Messages::text_allowed, its length, other players’ names). False when the server list is unavailable, the handle is stale or the player isn’t online.

pub fn hide(self, host: &mut dyn ServerHost, level: Option<u8>) -> bool

Side: server. Hides that player (a vanish) from the players below permission level, or shows them again (None): from the next tick those players lose them from the Tab list and the world (their client stops tracking the player, as it does a spectator), and don’t read their joining or leaving; players of level or more still see them, and a player made an operator meanwhile sees them again. Kept by UUID, even after this handle disconnects (the player rejoins hidden), until a mod sets it again or the server stops. Works inside a player’s hook too; false for a stale world epoch, on a client and in a world nobody else can join.

pub fn open_menu( self, host: &mut dyn ServerHost, entity: BlockEntityRef, ) -> Result<bool, BlockEntityError>

Side: server. Opens a block entity’s menu for a connected player (ServerPlayer.openMenu). Returns Stale for an invalidated entity; Ok(false) for a wrong-level player, non-provider, cancelled open, or an unconnected player such as a fake player.

pub fn send_map( self, host: &mut dyn ServerHost, map_id: i32, colors: &[u8], ) -> bool

Side: server. Sends the player uuid the whole picture of map map_id: 128 x 128 colours (MapColor ids times 4 plus the shade, row by row), scale 0, locked, no decorations, as ClientboundMapItemDataPacket. A filled map the mod gives with that minecraft:map_id then shows it in hand and in item frames; the server keeps nothing (a map id with no saved map is never sent again by the game), so send it again after the player joins. Use ids far from the world’s own (they count up from 0). False for a player not here, or colors not 16384 long.

pub fn set_abilities( self, host: &mut dyn ServerHost, abilities: PlayerAbilities, ) -> bool

Side: server. Stores a server player’s Abilities and tells their client (ServerPlayer.onUpdateAbilities). They stay as written until the player’s game mode changes (GameType.updatePlayerAbilities), and are saved with the player. A speed that is not finite refuses the write (vanilla’s setters take any float). Returns false for a stale or unavailable player, a displaced outer player, and a speed that is not finite.

pub fn perform_action( self, host: &mut dyn ServerHost, action: PlayerAction, ) -> Result<ActionOutcome, ActionRefused>

Side: server. A fake player acts as a player does, through the game’s own path for the action (ServerGamePacketListenerImpl.handleUseItemOn / handleUseItem / handleInteract’s ATTACK, and ServerPlayerGameMode.destroyBlock), as its packet would run it: reach, protection and the border, then the action. Once it runs, an effect a fake can’t take part in (a menu, sleep, a ride, another dimension) is stopped where it would start, and the answer says which; the action’s own side effects (the swing, the hooks before it, vanilla’s result) have still happened then. The fake is found once, and its turn starts at that place in the list.

pub fn perform_action_scoped( self, host: &mut dyn ServerHost, action: PlayerAction, setup: PlayerActionSetup, ) -> Result<ScopedActionResult, ActionRefused>

Side: server. A machine’s one use on the persistent actor, with its private state put back even when the action refuses. Only the existing guest turn runs gameplay and its hooks.

pub fn set_item_cooldown( self, host: &mut dyn ServerHost, group: &str, ticks: i32, ) -> bool

Side: server. ItemCooldowns.addCooldown(group, ticks): starts (or restarts) the group’s cooldown, and the player’s client draws it on every item of the group (ServerItemCooldowns.onCooldownStarted).

pub fn remove_item_cooldown( self, host: &mut dyn ServerHost, group: &str, ) -> bool

Side: server. ItemCooldowns.removeCooldown(group): ends the group’s cooldown now, on the client too (ServerItemCooldowns.onCooldownEnded).

pub fn set_exp_cooldown(self, host: &mut dyn ServerHost, ticks: u32) -> bool

Side: server. Sets Player.takeXpDelay: no orb is taken for ticks ticks. The change is not reported to player_exp_cooldown_change.

pub fn set_warden_warning_cooldown( self, host: &mut dyn ServerHost, ticks: u32, ) -> bool

Side: server. Sets the player’s WardenSpawnTracker.cooldownTicks: sculk shriekers they set off don’t warn for ticks ticks. The level’s players share one tracker here, the integrated server owner’s (the shriekers read it for whoever sets them off), so this is every player’s. False, changing nothing, for anyone but the tracker’s owner until each player has their own.

pub fn trigger_criterion( self, host: &mut dyn ServerHost, trigger: &Identifier, test: Arc<dyn CriterionTest>, ) -> Result<(), TriggerCriterionError>

Side: server. Fires the mod’s criteria trigger trigger (mymod:pipe_connected) for player: vanilla’s SimpleCriterionTrigger.trigger. Each criterion of theirs with that trigger, not yet granted, of an advancement not yet done, is tested by test and then by its player predicate; those that pass are granted, and an advancement they complete is awarded with its toast, chat line and rewards, as the game’s own triggers award.

The acting player is reached inside their hook; another live player is reached in their own level, including during a guest’s turn. An outer player displaced by a nested turn is unavailable. Ok(()) means the player was reached, whether or not anything was granted. A stale/offline/displaced handle, a remote client, or a minecraft: trigger or empty id is refused with a typed reason.

test is lent to this call only. A failed test stops further testing and reports Test; earlier matching criteria may already be granted. Wasm predicates run synchronously, including callbacks into the group firing the trigger, within that call’s remaining execution and memory limits.

pub fn trigger_block_use( self, host: &mut dyn ServerHost, pos: [i32; 3], ) -> Result<(), TriggerCriterionError>

Side: server. Fires default_block_use, then any_block_use, without a tool. Evaluates vanilla predicates and rewards in the player’s own level; never reads inventory. Ok(()) means reached, even if no criterion matched. Refuses remote clients (NotServer), stale/offline/displaced players (PlayerUnavailable), and unloaded positions (UnloadedChunk).

pub fn trigger_item_used_on_block( self, host: &mut dyn ServerHost, pos: [i32; 3], original: &ItemStack, after: &ItemStack, ) -> Result<(), TriggerCriterionError>

Side: server. Fires item_used_on_block with original, then any_block_use with after, in vanilla order. original is copied after a before-block PASS and before block/item effects; after is that original hand stack mutated in place, never a replacement swapped into the hand. Neither stack is read from inventory. Consuming right-click/before-block cancellation already fires automatic any_block_use only; do not call this pair helper for it, which would duplicate any and add an inner trigger. Invalid stacks return Stack(StackWriteError) before either trigger fires. Evaluates vanilla predicates and rewards in the player’s own level. Ok(()) means reached, even if nothing matched. Refuses remote clients (NotServer), stale/offline/displaced players (PlayerUnavailable), and unloaded positions (UnloadedChunk).

pub fn set_last_death_location( self, host: &mut dyn ServerHost, location: Option<GlobalPos>, ) -> bool

Side: server. Player.setLastDeathLocation: stores where the player died, or forgets it for None. The client hears of it with the player’s next respawn, as in vanilla. False in the cases a read gives None.

pub fn feed( self, host: &mut dyn ServerHost, nutrition: i32, saturation_modifier: f32, ) -> bool

Side: server. FoodData.eat(nutrition, saturationModifier): adds nutrition to the food level (0 to 20) and nutrition * modifier * 2 to the saturation, which stays at most the food level.

pub fn add_exhaustion(self, host: &mut dyn ServerHost, amount: f32) -> bool

Side: server. Player.causeFoodExhaustion: adds exhaustion (at most 40), as sprinting or jumping does. An invulnerable player (creative) or a spectator gets none, and the call still returns true.

pub fn set_food_level(self, host: &mut dyn ServerHost, level: i32) -> bool

Side: server. FoodData.setFoodLevel: sets the food level as it is, unclamped, as vanilla does.

pub fn set_saturation(self, host: &mut dyn ServerHost, saturation: f32) -> bool

Side: server. FoodData.setSaturation: sets the saturation as it is, unclamped.

pub fn set_exhaustion(self, host: &mut dyn ServerHost, exhaustion: f32) -> bool

Side: server. Sets the exhaustion as it is (Paper’s HumanEntity#setExhaustion; vanilla’s FoodData only adds to it).

pub fn set_experience_points( self, host: &mut dyn ServerHost, points: i32, ) -> bool

Side: server. ServerPlayer.setExperiencePoints: sets the progress toward the next level to points of the points it needs, kept below a full bar. The level and the total are kept.

pub fn set_experience_levels( self, host: &mut dyn ServerHost, levels: i32, ) -> bool

Side: server. ServerPlayer.setExperienceLevels: sets the level, keeping the progress and the total.

pub fn set_game_mode(self, host: &mut dyn ServerHost, mode: GameMode) -> bool

Side: server. Changes a player’s game mode as ServerPlayer.setGameMode and /gamemode do, including the cancellable change hook and ability updates. Returns false for a stale or unavailable player, an active outer guest, no change, or a canceled change.

pub fn set_selected_slot(self, host: &mut dyn ServerHost, slot: usize) -> bool

Side: server. Inventory.setSelectedSlot: makes slot (0 to 8) the hotbar slot the player holds and tells their client (ClientboundSetHeldSlot), as /clear-style server code does. A new slot ends a main-hand use in progress, as the client’s own switch does, and asks no player_switch_hotbar_slot_pre: that hook is for the player’s own input. Returns false for a slot past 8, a stale or unavailable player, and a dead one; true when the player already held slot.

pub fn drop_stack( self, host: &mut dyn ServerHost, stack: ItemStack, thrown_by_player: bool, ) -> Result<Option<ItemStack>, StackWriteError>

Side: server. Player.drop(stack, false, thrown_by_player): stack is thrown from the player’s eyes along their view as an item entity, with the main hand swinging and item_toss asked first. Nothing is taken from an inventory: the stack is the caller’s, taken out through the item places first, which is what separates it from giving or dropping into the inventory. thrown_by_player names the player as the item’s thrower, as the drop key does. Ok(None) when the stack is in the world; otherwise Ok(Some(stack)) comes back, untouched, for the caller to put back: an empty stack, a stale or dead player, or a toss a mod canceled (item_toss), so a refused drop never loses items. Invalid API stack conversion returns StackWriteError, as other checked stack writes do.

pub fn remove_fake(self, host: &mut dyn ServerHost) -> bool

Side: server. Remove a fake without treating it as a disconnect or saving it.

pub fn award_stat( self, host: &mut dyn ServerHost, stat_type: StatType, key: &str, amount: i32, ) -> bool

Side: server. Player.awardStat(stat, amount): adds amount, as the game does for its own counts, so player_stat_award hears it and may cancel it, and scoreboard criteria follow. False for a player it can’t reach.

pub fn reset_stat( self, host: &mut dyn ServerHost, stat_type: StatType, key: &str, ) -> bool

Side: server. Player.resetStat: sets the statistic back to 0, which scoreboard criteria follow. False for a player it can’t reach.

pub fn award_recipes( self, host: &mut dyn ServerHost, recipes: &[&str], ) -> Option<i32>

Side: server. ServerPlayer.awardRecipes, as /recipe give does: the recipes unlock in the player’s book, with their toasts and the player_recipe_discovered hook, and the client hears of them. Unknown ids are skipped. The number of recipe displays added, None for a player it can’t reach.

pub fn reset_recipes( self, host: &mut dyn ServerHost, recipes: &[&str], ) -> Option<i32>

Side: server. ServerPlayer.resetRecipes, as /recipe take does. The number of recipe displays taken out, None for a player it can’t reach.

pub fn give_experience_points( self, host: &mut dyn ServerHost, points: u32, ) -> bool

Side: server. ExperienceOrb.playerTouch: Mending repairs the player’s damaged items with points first (ExperienceOrb.repairPlayerItems), then only the rest goes to their experience (Player.giveExperiencePoints), with the level-up sound. No orb pickup sound. False, and nothing given, as the other writes; points above i32::MAX is refused before Mending repairs anything.

pub fn give_levels(self, host: &mut dyn ServerHost, levels: i32) -> bool

Side: server. Player.giveExperienceLevels: adds levels, or takes them off when negative, as the anvil and the enchanting table charge with. Below 0 the level, the total and the progress toward the next level are all 0.

pub fn stop_sound( self, host: &mut dyn ServerHost, sound: Option<&str>, source: Option<SoundSource>, ) -> bool

Side: server. StopSoundCommand for one player: their client stops the playing sounds that match sound (an event id) and source; None matches any. True means sent.

pub fn play_sound( self, host: &mut dyn ServerHost, sound: &str, source: SoundSource, volume: f32, pitch: f32, ) -> bool

Side: server. PlaySoundCommand for one player: plays sound event sound at the player, for them only, under source’s volume slider. The seed is the level random’s nextLong, drawn once per call. True means sent, not heard.

pub fn simulate_move( self, host: &mut dyn ServerHost, input: PlayerInput, ) -> Option<SimulatedMove>

Side: both. Simulate one client movement tick for this server player without changing the player. Refuses stale, absent, dead, spectator or riding players and invalid input.

pub fn request_recipe_book_settings( self, host: &mut dyn ClientHost, book: &RecipeBookTypeKey, settings: RecipeBookSettings, ) -> bool

Side: client. Request a new pair for the local player’s negotiated book. True means queued, not accepted; only an authoritative reply changes saved state.

§

impl PlayerRef

pub fn entity(self) -> EntityRef

The same player as an entity handle.

pub fn uuid(self) -> u128

The player’s UUID.

Trait Implementations§

§

impl Clone for PlayerRef

§

fn clone(&self) -> PlayerRef

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 Copy for PlayerRef

§

impl Debug for PlayerRef

§

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

Formats the value using the given formatter. Read more
§

impl Eq for PlayerRef

§

impl From<PlayerRef> for EntityRef

§

fn from(player: PlayerRef) -> EntityRef

Converts to this type from the input type.
§

impl Hash for PlayerRef

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for PlayerRef

§

fn eq(&self, other: &PlayerRef) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for PlayerRef

§

impl Wire for PlayerRef

§

const MIN: usize

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<PlayerRef, WireError>

Decodes one value, leaving any following bytes for the caller.

Auto Trait Implementations§

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.

§

impl<T> Put for T
where T: Wire,

§

fn put_to(&self, out: &mut Writer)

Writes it.
§

impl<T> Record for T
where T: Wire,

§

fn encode(&self, out: &mut Writer)

Writes the argument into a hook call.
§

fn apply(&mut self, bytes: &[u8]) -> Result<(), WireError>

Applies one complete reply, refusing malformed or trailing bytes atomically.
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.