Struct LevelRef
pub struct LevelRef { /* private fields */ }Expand description
A level of the open world, by its dimension (minecraft:the_nether).
Host::level makes one, and entity.level(host) gives an entity’s.
Implementations§
§impl LevelRef
impl LevelRef
pub fn find_closest_biome(
self,
host: &dyn Host,
biome: &str,
parameters: BiomeSearch,
) -> Option<BiomeSearchResult>
pub fn find_closest_biome( self, host: &dyn Host, biome: &str, parameters: BiomeSearch, ) -> Option<BiomeSearchResult>
Side: server.
ServerLevel.findClosestBiome3d: search this level’s generator for an id or #tag.
The result follows vanilla’s sampled spiral and vertical order; it is not a search
through edited biome cells. Does not load resident chunks or switch parked levels.
None for no match, a stale/unavailable level, an unavailable generator, a negative
radius, nonpositive sampling steps, or a potential sample count above
BiomeSearch::MAX_SAMPLES (see BiomeSearch::new for the work formula).
Positive vertical steps larger than the build height sample only the clamped origin.
pub fn find_nearest_structure(
self,
host: &dyn Host,
structure: &str,
parameters: StructureSearch,
) -> Option<StructureSearchResult>
pub fn find_nearest_structure( self, host: &dyn Host, structure: &str, parameters: StructureSearch, ) -> Option<StructureSearchResult>
Side: server.
ServerLevel.findNearestMapStructure without skipping known starts: the
nearest start of structure, an id or a #tag, searched in this
level’s generator as /locate structure does. Random-spread structure
sets are searched in squares of placement cells out to
StructureSearch::radius; concentric rings (strongholds) check every
ring position whatever the radius. Starts are built as the search needs
them, without loading or generating chunks or switching parked levels.
None for no start, a structure that does not generate in this level,
a world without structures, a stale level, a client, a negative radius,
one above StructureSearch::MAX_RADIUS, and an origin outside the
world’s 30,000,000-block bound.
pub fn get_sky_darken(self, host: &dyn Host) -> Option<i32>
pub fn get_sky_darken(self, host: &dyn Host) -> Option<i32>
Side: both.
Level.getSkyDarken: the sky-light reduction from dimension, time and weather.
Reads any loaded server level, including parked levels, or the current client level.
None for a stale or unavailable level. Does not load chunks.
pub fn block_floor_height(self, host: &dyn Host, pos: [i32; 3]) -> Option<f64>
pub fn block_floor_height(self, host: &dyn Host, pos: [i32; 3]) -> Option<f64>
Side: both.
BlockGetter.getBlockFloorHeight with the normal collision shapes and an empty
entity context. The result is relative to the block: negative infinity means no floor.
None for a stale level, an unloaded column or a position outside build height.
Reads parked server levels and the current client level without loading chunks.
pub fn biome_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<String>
pub fn biome_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<String>
Side: server.
The biome id selected by LevelReader.getBiome and this level’s biome zoom.
Reads an active or parked server level. None for a
stale handle or an unloaded selected noise column. Never generates or loads chunks.
pub fn datapack_entries(
self,
host: &dyn Host,
registry: &str,
) -> Option<Vec<String>>
pub fn datapack_entries( self, host: &dyn Host, registry: &str, ) -> Option<Vec<String>>
Side: both.
The entry ids (addon:fire) of a datapack registry a mod declared
(declare_datapack_registry), sorted, as this world session last loaded them. On a client
they are the ones its server sent at the join and after each reload, and only for a
registry declared Required or Optional. None for a stale or parked level and a
registry no mod declared (or, on a client, one the server did not send). Reads nothing
from disk.
pub fn datapack_handle(
self,
host: &dyn Host,
registry: &str,
entry: &str,
) -> Result<DatapackHandle, DatapackReadError>
pub fn datapack_handle( self, host: &dyn Host, registry: &str, entry: &str, ) -> Result<DatapackHandle, DatapackReadError>
Side: both.
A handle to entry of registry at the generation now loaded (on a client, the one its
server last sent). A handle kept across a reload fails its next read with
StaleGeneration, one from an earlier world session with WrongSession. A stale or parked
level and a registry no mod declared are UnknownRegistry; an entry no pack defines is
MissingEntry.
pub fn datapack_read(
self,
host: &dyn Host,
handle: &DatapackHandle,
) -> Result<Vec<(String, DatapackValue)>, DatapackReadError>
pub fn datapack_read( self, host: &dyn Host, handle: &DatapackHandle, ) -> Result<Vec<(String, DatapackValue)>, DatapackReadError>
Side: both.
The decoded fields of the entry a handle names, in the registry’s schema order, as plain
values: a copy, which carries no authority after the read. The handle is checked first
(session, then generation), then the entry; the errors are those of
level_datapack_handle.
pub fn block_break_speed(
self,
host: &dyn Host,
pos: [i32; 3],
tool: Option<&ItemStack>,
) -> Option<f32>
pub fn block_break_speed( self, host: &dyn Host, pos: [i32; 3], tool: Option<&ItemStack>, ) -> Option<f32>
Side: both.
How fast tool (None is an empty hand) mines the block at pos: the tool’s own mining
speed on that block (ItemStack.getDestroySpeed, 1.0 for no tool; for a block it has no
rule for, the tool’s default mining speed), before the player’s enchantments, attributes, water, ground and
player_break_speed hooks, which player_break_speed itself hears. None for a stale
handle or an unloaded or out-of-height position. Reads no chunks.
pub fn client_biome(self, host: &dyn Host, pos: [i32; 3]) -> Option<String>
pub fn client_biome(self, host: &dyn Host, pos: [i32; 3]) -> Option<String>
Side: client.
The biome in the client’s current level (LevelReader.getBiome). None before
login, for a stale or foreign dimension, or an unloaded selected column. Never loads chunks.
pub fn biome_spawners(
self,
host: &dyn Host,
biome: &str,
) -> Option<Vec<BiomeSpawners>>
pub fn biome_spawners( self, host: &dyn Host, biome: &str, ) -> Option<Vec<BiomeSpawners>>
Side: both.
A biome’s natural spawners by category (MobSpawnSettings.getMobs), from the level’s
biome table, data packs and biome modifiers included, categories sorted by name. None for a
stale handle or an unknown biome. This is the biome’s own list; potential_spawns is
what a position gets after mods edit it. Reads no chunks.
pub fn biome_effects(self, host: &dyn Host, biome: &str) -> Option<BiomeEffects>
pub fn biome_effects(self, host: &dyn Host, biome: &str) -> Option<BiomeEffects>
Side: both.
A biome’s own sky, fog and water colours (BiomeSpecialEffects), from the level’s biome
table. None for a stale handle or an unknown biome. Reads no chunks.
pub fn biome_in_tag(
self,
host: &dyn Host,
biome: &str,
tag: &str,
) -> Option<bool>
pub fn biome_in_tag( self, host: &dyn Host, biome: &str, tag: &str, ) -> Option<bool>
Side: both.
Whether a biome is in a biome tag (Holder.is(TagKey)), by the level’s tag tables: the
vanilla tags, the world’s data packs and mods’ biome tags merged. tag is a namespaced
id (minecraft:is_forest), with or without a leading #. A tag no pack defines holds
nothing, so false. None for a stale handle, an unknown biome or a level that has no tag
tables loaded. Reads no chunks.
pub fn biome_properties(
self,
host: &dyn Host,
biome: &str,
) -> Option<BiomeProperties>
pub fn biome_properties( self, host: &dyn Host, biome: &str, ) -> Option<BiomeProperties>
Side: both.
A biome’s climate by id (minecraft:plains), from the level’s biome table, data packs
included: temperature, downfall, whether it has precipitation and the frozen modifier
(Biome.ClimateSettings). None for a stale handle or an unknown biome. Reads no chunks.
pub fn logical_height(self, host: &dyn Host) -> Option<i32>
pub fn logical_height(self, host: &dyn Host) -> Option<i32>
Side: both.
The dimension’s logical height (ServerLevel.getLogicalHeight), which may differ
from build height. Reads active and parked server levels or the client’s current level.
None for a stale or unavailable level. Does not load chunks.
pub fn world_border(self, host: &dyn Host) -> Option<[f64; 4]>
pub fn world_border(self, host: &dyn Host) -> Option<[f64; 4]>
Side: server. The level’s world border as [min_x, min_z, max_x, max_z], using the previous size while it moves. Horizon currently shares one border across its dimensions. None for a stale handle or a closed level.
pub fn chunk_ref(self, host: &dyn Host, pos: [i32; 2]) -> Option<ChunkRef>
pub fn chunk_ref(self, host: &dyn Host, pos: [i32; 2]) -> Option<ChunkRef>
Side: server.
A handle for chunk pos of an open level, loaded or not, so a mod can
force an unloaded chunk. None for a stale handle, on a client, and for
a chunk outside the world (ChunkPos past 30 million blocks).
pub fn forced_chunks(self, host: &dyn Host) -> Option<Vec<[i32; 2]>>
pub fn forced_chunks(self, host: &dyn Host) -> Option<Vec<[i32; 2]>>
Side: server.
The level’s force-loaded chunks (/forceload query), sorted as
the command lists them. None for a stale handle or on a client.
pub fn mod_forced_chunks(
self,
host: &dyn Host,
controller: TicketController,
) -> Option<Vec<(TicketOwner, [i32; 2], bool)>>
pub fn mod_forced_chunks( self, host: &dyn Host, controller: TicketController, ) -> Option<Vec<(TicketOwner, [i32; 2], bool)>>
Side: server.
The chunk tickets controller holds in the level, as (owner, chunk
position, natural_spawning), in order. None for a stale handle, on a
client, outside a mod’s hook and for another mod’s controller.
pub fn recipe_for(
self,
host: &dyn Host,
recipe_type: &Identifier,
inputs: &RecipeInput,
) -> Result<Option<RecipeMatch>, RecipeLookupError>
pub fn recipe_for( self, host: &dyn Host, recipe_type: &Identifier, inputs: &RecipeInput, ) -> Result<Option<RecipeMatch>, RecipeLookupError>
Side: server. Match and assemble through the engine’s recipe matcher, without consuming inputs. Covers minecraft:crafting, smelting, blasting, smoking, campfire_cooking, stonecutting and smithing, including data-pack recipes of those types. Mod-owned types return RecipeLookupError::NotMatchable: cache recipes_of_type once per load/reload and match those in mod memory (no per-tick host crossing). Dynamic custom outputs and contextual predicates remain mod-owned. A valid input without a match returns Ok(None); invalid shapes/items and unavailable levels are typed refusals. Crafting dimensions are 1 through 3, with row-major slots.
pub fn all_entities(self, host: &dyn Host) -> Option<Vec<EntityRef>>
pub fn all_entities(self, host: &dyn Host) -> Option<Vec<EntityRef>>
Side: server.
Every available member of the server level’s entity lookup
(ServerLevel.getAllEntities), including spectators and entities outside
any spatial query. Dragon parts are not lookup members.
Returns None on a remote client, for a stale handle or a parked level.
Returns None while any lookup member is temporarily extracted, rather
than returning an incomplete list.
Order is lookup admission order, preserved across temporary extraction;
removal and re-admission moves an entity to the end. A chunk’s entities
join in the order it stored them: section by section, each in admission
order, as vanilla stores them. An entity that moved into another section
since it joined keeps its admission place there, where vanilla moves it
to the end of that section. Zero runtime IDs fall back to stable storage
join order, not runtime admission order. Unregistered entity kinds have
no authoritative lookup handle and are omitted. These limitations mean
saved-world and whole-level ordering parity is not yet complete (#2703).
Allocates a result buffer, not one allocation per entity; sorting is
O(n log n), followed by one authoritative handle lookup per candidate.
pub fn entities_in(
self,
host: &dyn Host,
min: [f64; 3],
max: [f64; 3],
) -> Option<Vec<EntityRef>>
pub fn entities_in( self, host: &dyn Host, min: [f64; 3], max: [f64; 3], ) -> Option<Vec<EntityRef>>
Side: server.
Entities whose bounding boxes intersect this box (Level.getEntities).
Face-only contact does not intersect; spectator players are excluded.
Returns None on a client, for a stale handle, or for a parked level:
its entity handles cannot resolve until the level is in place. The walk
is in entity-list order followed by players; each overlap requires a
handle lookup, so cost grows with the box’s contents. Tridents cannot
yet resolve; frames, paintings and other special entities
are not on the entity-list walk. The dragon follows ordinary entities;
its eight intersecting parts follow players in vanilla hash-table order (Level.getEntities).
During hears_projectile_impacts, the projectile list is taken out of
the game and is not visible; it is restored for projectile_impact.
pub fn online_players(self, host: &dyn Host) -> Option<Vec<PlayerRef>>
pub fn online_players(self, host: &dyn Host) -> Option<Vec<PlayerRef>>
Side: server.
ServerLevel.players: the online players in this level, parked or in
place, each once under their own UUID, also during a guest’s turn. Fake
players are not listed, as vanilla’s list leaves out connectionless
players; a player displaced by a nested guest turn is not listed either,
since its handle cannot resolve until that turn ends. None on a client
and for a stale handle.
pub fn block_state(self, host: &dyn Host, pos: [i32; 3]) -> Option<BlockState>
pub fn block_state(self, host: &dyn Host, pos: [i32; 3]) -> Option<BlockState>
Side: both.
The block state ID at pos (Level.getBlockState), without formatting a string.
None for a chunk that isn’t loaded or a y outside the world. On a client, the
state is the one the server sent for a chunk the client holds.
pub fn block_transform(
self,
host: &dyn Host,
player: PlayerRef,
hand: Hand,
stack: &ItemStack,
pos: [i32; 3],
hit: BlockHit,
) -> Option<BlockTransformPreview>
pub fn block_transform( self, host: &dyn Host, player: PlayerRef, hand: Hand, stack: &ItemStack, pos: [i32; 3], hit: BlockHit, ) -> Option<BlockTransformPreview>
Side: server.
Preview a held tool’s transformation without changing the block or stack. The existing
block-tool hook fires with simulated true; listeners must not mutate the level in a
simulation. The player must be live in the level in place, and the block must be loaded;
parked levels cannot provide the hook’s level context. A stale handle, invalid face,
unavailable player or level, or no transformation returns None.
pub fn block(self, host: &dyn Host, pos: [i32; 3]) -> Option<BlockKey>
pub fn block(self, host: &dyn Host, pos: [i32; 3]) -> Option<BlockKey>
Side: both.
The block at pos without its properties: minecraft:oak_stairs.
None as for block_state. API 381.
pub fn block_property(
self,
host: &dyn Host,
pos: [i32; 3],
key: &str,
) -> Option<String>
pub fn block_property( self, host: &dyn Host, pos: [i32; 3], key: &str, ) -> Option<String>
Side: both.
Property key of the block state at pos (BlockState.getValue):
east for facing. None for a block without it, or as for
block_state. API 381.
pub fn in_place(self, host: &dyn Host) -> bool
pub fn in_place(self, host: &dyn Host) -> bool
Side: server.
Whether this is the level in place: the one the server ticks now, whose block entities
the game’s own capabilities read and write and whose capabilities
LevelRef::capability looks up. False for a level parked while the server ticks
another (its blocks can still be read), for a handle of an earlier open, and on a
client.
pub fn is_loaded(self, host: &dyn Host, pos: [i32; 3]) -> bool
pub fn is_loaded(self, host: &dyn Host, pos: [i32; 3]) -> bool
Side: both.
Whether pos is inside the world’s height and its chunk is loaded
(Level.isLoaded, which is false outside isInValidBounds): a block
read or write there finds the world. False on a client or for a stale
handle: the position is not loaded here. On a client, a chunk it holds is loaded
(ClientLevel.hasChunkAt). API 381.
pub fn brightness(
self,
host: &dyn Host,
layer: LightLayer,
pos: [i32; 3],
) -> Option<i32>
pub fn brightness( self, host: &dyn Host, layer: LightLayer, pos: [i32; 3], ) -> Option<i32>
Side: server.
The stored light of one layer at pos (BlockAndLightGetter.getBrightness), 0 to 15.
None as for block_state: a position that isn’t loaded has no light to read.
pub fn height(self, host: &dyn Host) -> Option<(i32, i32)>
pub fn height(self, host: &dyn Host) -> Option<(i32, i32)>
Side: both.
The lowest block y and the height of the level
(LevelHeightAccessor.getMinY, getHeight). Reads any loaded server level
or the client’s current level. None for a stale handle, before client login,
or for a dimension unavailable on this side. Does not load chunks. API 381.
pub fn in_world_bounds(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
pub fn in_world_bounds(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
Side: both.
Level.isInWorldBounds: pos within 30,000,000 blocks on x and z and inside the level’s
build height. None as for native_level_height. Does not load chunks.
pub fn in_spawnable_bounds(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
pub fn in_spawnable_bounds(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
Side: both.
Level.isInSpawnableBounds: 30,000,000 blocks on x and z, 20,000,000 on y. None as for
native_level_height. Does not load chunks.
pub fn game_time(self, host: &dyn Host) -> Option<i64>
pub fn game_time(self, host: &dyn Host) -> Option<i64>
Side: both.
The level’s game time (Level.getGameTime). On clients this is the
synchronized time advanced by the local level tick. API 381.
pub fn day_time(self, host: &dyn Host) -> Option<i64>
pub fn day_time(self, host: &dyn Host) -> Option<i64>
Side: both.
The time of day in ticks (Level.getOverworldClockTime), shared by
every level; it keeps counting past 24000. On a client, the synchronized
Overworld clock, advanced at its server-supplied rate, even when the
displayed dimension has a different default clock. API 381.
pub fn clock_time(self, host: &dyn Host) -> Option<i64>
pub fn clock_time(self, host: &dyn Host) -> Option<i64>
Side: server.
The time of the level’s own clock in ticks: the clock its dimension type names as
default_clock, which its sky, spawning and beds go by and /time sets there. A mod’s
level with a day_cycle clock of its own counts it apart from the Overworld’s; a level
without a default clock, like the Nether, is None, as is a stale handle and a client.
pub fn fluid_flow(self, host: &dyn Host, pos: [i32; 3]) -> Option<Vec3>
pub fn fluid_flow(self, host: &dyn Host, pos: [i32; 3]) -> Option<Vec3>
Side: both.
FluidState.getFlow at pos: the current that pushes an entity there, after the
fluid_flow hook, as entities feel it. Zero where no fluid flows. None as for
block_state.
pub fn block_shape(
self,
host: &dyn Host,
state: BlockState,
pos: [i32; 3],
kind: BlockShapeKind,
) -> Option<Vec<[f64; 6]>>
pub fn block_shape( self, host: &dyn Host, state: BlockState, pos: [i32; 3], kind: BlockShapeKind, ) -> Option<Vec<[f64; 6]>>
Side: server.
The supplied state’s block-local outline or collision boxes at pos,
with an empty context (BlockState.getShape / getCollisionShape).
The state need not be the block stored there; level-dependent shapes
still read the real level. Pass block_state(host, pos) to query the
state at that position. Interaction, visual, occlusion and support shapes
are not exposed. Returns None on a client, for an unknown state, a stale
handle or a closed level. Collision errors return no boxes.
pub fn clip(
self,
host: &dyn Host,
from: [f64; 3],
to: [f64; 3],
blocks: ClipBlock,
fluids: ClipFluid,
) -> Option<ClipHit>
pub fn clip( self, host: &dyn Host, from: [f64; 3], to: [f64; 3], blocks: ClipBlock, fluids: ClipFluid, ) -> Option<ClipHit>
Side: server. Clip an empty-context ray against collider or outline shapes, without fluids. None on failed reads, dynamic shapes, invalid rays or traversal limits.
pub fn block_face_sturdy(
self,
host: &dyn Host,
pos: [i32; 3],
face: BlockFace,
support: SupportType,
) -> Option<bool>
pub fn block_face_sturdy( self, host: &dyn Host, pos: [i32; 3], face: BlockFace, support: SupportType, ) -> Option<bool>
Side: server. Gameplay’s face support in the current or a parked server level, including live block entities for dynamic shapes. None for stale or closed levels, unloaded blocks, unsupported states or a shape query error.
pub fn signal(
self,
host: &dyn Host,
pos: [i32; 3],
direction: Direction,
) -> Option<i32>
pub fn signal( self, host: &dyn Host, pos: [i32; 3], direction: Direction, ) -> Option<i32>
Side: server.
How strongly the block at pos powers the block on its direction side, power it
conducts included (SignalGetter.getSignal(pos, direction), as a block reads its
neighbour pos that lies direction from it), 0 to 15. None for another level, a stale
handle or a client. Takes a shared host and opens no transaction.
pub fn direct_signal(
self,
host: &dyn Host,
pos: [i32; 3],
direction: Direction,
) -> Option<i32>
pub fn direct_signal( self, host: &dyn Host, pos: [i32; 3], direction: Direction, ) -> Option<i32>
Side: server.
The strong power alone that the block at pos gives that way
(SignalGetter.getDirectSignal(pos, direction)), 0 to 15. None as for signal.
pub fn direct_signal_to(self, host: &dyn Host, pos: [i32; 3]) -> Option<i32>
pub fn direct_signal_to(self, host: &dyn Host, pos: [i32; 3]) -> Option<i32>
Side: server.
The strongest strong power reaching the block at pos from its six neighbours
(SignalGetter.getDirectSignalTo), 0 to 15. None as for signal.
pub fn best_neighbor_signal(self, host: &dyn Host, pos: [i32; 3]) -> Option<i32>
pub fn best_neighbor_signal(self, host: &dyn Host, pos: [i32; 3]) -> Option<i32>
Side: server.
The strongest power reaching the block at pos from its six neighbours
(SignalGetter.getBestNeighborSignal, what a dispenser or a piston reads), 0 to 15.
None as for signal.
pub fn has_neighbor_signal(self, host: &dyn Host, pos: [i32; 3]) -> bool
pub fn has_neighbor_signal(self, host: &dyn Host, pos: [i32; 3]) -> bool
Side: server.
Whether any neighbour powers the block at pos (SignalGetter.hasNeighborSignal),
asking no side past the first that does. False where signal is None.
pub fn dimension_shape(self, host: &dyn Host) -> Option<LevelDimensionShape>
pub fn dimension_shape(self, host: &dyn Host) -> Option<LevelDimensionShape>
Side: both. Dimension shape of a loaded server level, including parked levels.
pub fn dimension_type(self, host: &dyn Host) -> Option<LevelDimensionType>
pub fn dimension_type(self, host: &dyn Host) -> Option<LevelDimensionType>
Side: both.
The level’s dimension type (Level.dimensionType() and its gameplay attributes): coordinate
scale, ambient light, fixed time, infiniburn, monster spawn light, sky and the gameplay
switches a mod’s DimensionSettings or a data pack sets. A level whose type neither gave
fields for has the Overworld’s. None for a stale handle; on a client, the level it shows.
pub fn sea_level(self, host: &dyn Host) -> Option<i32>
pub fn sea_level(self, host: &dyn Host) -> Option<i32>
Side: server.
Level.getSeaLevel: 63 in the Overworld, 32 in the Nether, 0 in the End; for a level of the
noise generator the sea_level of its noise settings (a data pack’s too, when it replaces
them), for another level the sea_level its DimensionSettings gave, else 63. It is the sea
level the game uses for the level: terrain and aquifers, mob spawning and mob behaviour, rain
and snow, and maps. None for a stale handle and on a client.
pub fn seed(self, host: &dyn Host) -> Option<i64>
pub fn seed(self, host: &dyn Host) -> Option<i64>
Side: server.
The world’s seed (WorldOptions.seed), as /seed shows it.
pub fn difficulty(self, host: &dyn Host) -> Option<&'static str>
pub fn difficulty(self, host: &dyn Host) -> Option<&'static str>
Side: server.
The difficulty (Level.getDifficulty): peaceful, easy, normal
or hard, as /difficulty names it.
pub fn local_difficulty(
self,
host: &dyn Host,
pos: [i32; 3],
) -> Option<Difficulty>
pub fn local_difficulty( self, host: &dyn Host, pos: [i32; 3], ) -> Option<Difficulty>
Side: server.
The local difficulty at pos (ServerLevel.getCurrentDifficultyAt), as mobs spawned
there are finalized with: the world difficulty scaled by the level’s age, the chunk’s
inhabited time and the moon (both 0 for a chunk that isn’t loaded). Its
special_multiplier is vanilla’s getSpecialMultiplier. None for a stale handle, a level
the server has not opened, or a client.
pub fn game_rule_bool(
self,
host: &dyn Host,
key: BoolGameRuleKey,
) -> Option<bool>
pub fn game_rule_bool( self, host: &dyn Host, key: BoolGameRuleKey, ) -> Option<bool>
Side: server. Read a registered boolean game rule.
pub fn game_rule(
self,
host: &dyn Host,
rule: &str,
) -> Result<Option<GameRuleValue>, LevelReadError>
pub fn game_rule( self, host: &dyn Host, rule: &str, ) -> Result<Option<GameRuleValue>, LevelReadError>
Side: server.
Game rule rule (minecraft:keep_inventory or keep_inventory), as
/gamerule queries it: Ok(None) for an unknown rule. A gone/reopened level
returns Stale; an unreadable side or phase returns Unavailable.
pub fn game_rules(
self,
host: &dyn Host,
) -> Result<Vec<(String, GameRuleValue)>, LevelReadError>
pub fn game_rules( self, host: &dyn Host, ) -> Result<Vec<(String, GameRuleValue)>, LevelReadError>
Side: server.
Every game rule the world has (GameRules) with its current value, by minecraft: id
(max_minecart_speed only with minecart improvements). A gone/reopened level
returns Stale; an unreadable side or phase returns Unavailable.
pub fn weather(self, host: &dyn Host) -> Option<(f32, f32)>
pub fn weather(self, host: &dyn Host) -> Option<(f32, f32)>
Side: both.
The rain and thunder levels, each 0.0 to 1.0 (Level.getRainLevel,
getThunderLevel at partial tick 1.0): both 0 in a level with no weather.
Reads any open server level or the client’s current synchronized level;
None for a stale handle, an unavailable level or a client not logged in.
pub fn is_raining(self, host: &dyn Host) -> Option<bool>
pub fn is_raining(self, host: &dyn Host) -> Option<bool>
Side: server.
Whether it rains (Level.isRaining: a rain level above 0.2).
pub fn is_raining_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
pub fn is_raining_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
Side: server.
Level.isRainingAt(pos) in the level a handle names, the one in place or a parked one:
it rains there and pos is under open sky in a biome that rains. None for a stale
handle, on a client, and where pos is not loaded or outside the world’s height; a
read never loads a chunk.
pub fn enabled_features(self, host: &dyn Host) -> Option<FeatureFlags>
pub fn enabled_features(self, host: &dyn Host) -> Option<FeatureFlags>
Side: server.
LevelReader.enabledFeatures of the level a handle names. Every level of a world shares
the world’s flags. None for a stale handle and on a client.
pub fn is_thundering(self, host: &dyn Host) -> Option<bool>
pub fn is_thundering(self, host: &dyn Host) -> Option<bool>
Side: server.
Whether it thunders (Level.isThundering: a thunder level above 0.9).
pub fn random(self, host: &dyn Host) -> Option<LegacyRandom>
pub fn random(self, host: &dyn Host) -> Option<LegacyRandom>
Side: server.
The random of the server level level names: vanilla’s Level.random
(level.getRandom()), the one its explosions, block drops and other
level draws use, so a mod’s draws move vanilla’s later ones as a Java
mod’s do. A parked level (the Nether while the server ticks the
Overworld) answers with its own stream. This is a copy of it as it
stands: draw with LevelRef::with_random, which stores the stream
back, so the draws move the level’s own. None on a client of a
server, for a stale handle and for a level not open: the Nether and
the End open when someone first goes there and close after 300 ticks
with nobody in them (close_idle_levels).
pub fn raid(self, host: &dyn Host, id: i32) -> Option<RaidRef>
pub fn raid(self, host: &dyn Host, id: i32) -> Option<RaidRef>
Side: server.
Raids.get(id): the raid saved under id in the requested level, if
Raids still holds it (a stopped raid goes at its next tick).
pub fn raid_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<RaidRef>
pub fn raid_at(self, host: &dyn Host, pos: [i32; 3]) -> Option<RaidRef>
Side: server.
ServerLevel.getRaidAt(pos): the closest active raid whose centre is
less than 96 blocks away (Raids.getNearbyRaid, 9216 squared).
pub fn raids(self, host: &dyn Host) -> Option<Vec<RaidRef>>
pub fn raids(self, host: &dyn Host) -> Option<Vec<RaidRef>>
Side: server.
Every raid Raids holds, in its iteration order, stopped ones
included until their next tick. None for a closed or stale level.
pub fn fluid_state(self, host: &dyn Host, pos: [i32; 3]) -> Option<FluidState>
pub fn fluid_state(self, host: &dyn Host, pos: [i32; 3]) -> Option<FluidState>
Side: server.
The fluid state at pos of the level level names (BlockGetter.getFluidState). None
for a stale handle, a chunk that isn’t loaded or a y outside the world: a read never
loads a chunk.
pub fn loaded_chunks(self, host: &dyn Host) -> Option<Vec<ChunkRef>>
pub fn loaded_chunks(self, host: &dyn Host) -> Option<Vec<ChunkRef>>
Side: both. Every loaded chunk of an open server level as handles, ordered by chunk x then z. None for a stale handle or on a client. Loads nothing.
pub fn collision_boxes(
self,
host: &dyn Host,
aabb: [f64; 6],
) -> Option<Vec<[f64; 6]>>
pub fn collision_boxes( self, host: &dyn Host, aabb: [f64; 6], ) -> Option<Vec<[f64; 6]>>
Side: both. World-space block collision boxes under an empty collision context, without entities or border. Refuses a stale or nonresident level and invalid or overlarge boxes.
pub fn respawn_data(self, host: &dyn Host) -> Option<RespawnData>
pub fn respawn_data(self, host: &dyn Host) -> Option<RespawnData>
Side: server.
The world’s respawn data (LevelData.getRespawnData): the world spawn and the way a
player appearing there faces, as /setworldspawn sets them. Horizon keeps one world
spawn, in the Overworld, so every level of a world answers the same. None on a client,
for a stale handle, and before the world has chosen its spawn.
pub fn map_data(self, host: &dyn Host, id: i32) -> Option<MapState>
pub fn map_data(self, host: &dyn Host, id: i32) -> Option<MapState>
Side: server.
Map id’s saved data (ServerLevel.getMapData(new MapId(id))): read from memory, or
from data/minecraft/maps/<id>.dat when nothing has loaded it yet, without keeping it.
Maps belong to the world, not to a level. None on a client, for a stale handle and for
a map id nothing ever made.
pub fn can_see_sky(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
pub fn can_see_sky(self, host: &dyn Host, pos: [i32; 3]) -> Option<bool>
Side: server.
BlockAndTintGetter.canSeeSky: the sky light at pos is full (15), so nothing above
blocks it. None as for brightness.
pub fn line_of_sight(
self,
host: &dyn Host,
from: [f64; 3],
to: [f64; 3],
) -> Option<bool>
pub fn line_of_sight( self, host: &dyn Host, from: [f64; 3], to: [f64; 3], ) -> Option<bool>
Side: server.
Whether nothing solid lies on the segment from..to, as
LivingEntity.hasLineOfSight clips between two eyes (ClipContext.Block.COLLIDER,
ClipContext.Fluid.NONE): clip’s miss. Fluids, entities and the border don’t block it.
None as for clip.
pub fn has_collisions(self, host: &dyn Host, aabb: [f64; 6]) -> Option<bool>
pub fn has_collisions(self, host: &dyn Host, aabb: [f64; 6]) -> Option<bool>
Side: both.
Whether any block collision shape shares volume with aabb ([min_x, min_y, min_z, max_x, max_y, max_z]): the block half of CollisionGetter.noCollision(aabb), negated. The same
walk and limits as collision_boxes, stopping at the first shape it finds; entities and
the world border are not counted. None as for collision_boxes.
pub fn fluid_shape(
self,
host: &dyn Host,
pos: [i32; 3],
) -> Option<Vec<[f64; 6]>>
pub fn fluid_shape( self, host: &dyn Host, pos: [i32; 3], ) -> Option<Vec<[f64; 6]>>
Side: both.
The fluid’s shape at pos (FluidState.getShape), as block-local boxes: none for no
fluid, else one box from the floor to the fluid’s height (FluidState.getHeight), a
full block under the same fluid, else the fluid’s own height (amount / 9). None as for
block_state; an unloaded block above counts as no fluid there.
pub fn fluid_tick_delay(
self,
host: &dyn Host,
fluid: FluidKey,
pos: [i32; 3],
) -> Option<i32>
pub fn fluid_tick_delay( self, host: &dyn Host, fluid: FluidKey, pos: [i32; 3], ) -> Option<i32>
Side: server.
Fluid.getTickDelay(level): the game ticks between a flow step of fluid at pos and the
next. Water is 5, lava 30 (10 in the Nether, where it flows fast) and the empty fluid 0; a
flowing form answers as its source. A mod’s world fluid answers what it declared, as its
fluid_rules parts change it at pos, floored at 1. None for a stale handle, a client,
a level parked while the server ticks another, a position that isn’t loaded or is outside
the world, and a fluid with no world form.
pub fn fluid_height(self, host: &dyn Host, pos: [i32; 3]) -> Option<f32>
pub fn fluid_height(self, host: &dyn Host, pos: [i32; 3]) -> Option<f32>
Side: both.
FluidState.getHeight(level, pos) of the fluid at pos: 0 for none, a full block under
the same fluid, else the fluid’s own height (amount / 9). None as for block_state.
An unloaded block above counts as no fluid there.
pub fn fluid_height_for_camera(
self,
host: &dyn Host,
pos: [i32; 3],
) -> Option<f32>
pub fn fluid_height_for_camera( self, host: &dyn Host, pos: [i32; 3], ) -> Option<f32>
Side: both.
The surface height of the fluid at pos that the camera’s immersion test reads: a source
with a block above whose underside is sturdy fills its cell (1), anything else is
fluid_height. None as for fluid_height.
pub fn fluid_can_be_replaced_with(
self,
host: &dyn Host,
pos: [i32; 3],
fluid: FluidKey,
direction: Direction,
) -> Option<bool>
pub fn fluid_can_be_replaced_with( self, host: &dyn Host, pos: [i32; 3], fluid: FluidKey, direction: Direction, ) -> Option<bool>
Side: both.
FluidState.canBeReplacedWith(level, pos, fluid, direction) for the fluid at pos: whether
fluid flowing in direction takes its place. The empty fluid yields to anything, water
only to a non-water fluid flowing down, lava to water once it stands 4/9 of a block high,
and a mod’s world fluid to nothing. False for a fluid with no world form. None as for
fluid_height.
pub fn ray_trace_entities(
self,
host: &dyn Host,
from: [f64; 3],
to: [f64; 3],
margin: f64,
exclude: Option<EntityRef>,
) -> Option<Vec<EntityRayHit>>
pub fn ray_trace_entities( self, host: &dyn Host, from: [f64; 3], to: [f64; 3], margin: f64, exclude: Option<EntityRef>, ) -> Option<Vec<EntityRayHit>>
Side: server.
Every entity the segment from from to to passes through, nearest first: the test
ProjectileUtil.getEntityHitResult makes on each candidate, each entity’s box grown by
margin on every side and clipped against the segment. A ray that starts inside a box
does not hit that entity, as in vanilla. exclude (the shooter) is skipped. Vanilla’s
filter (canHitEntity, isPickable) is the caller’s: take the first hit it accepts.
Candidates are those entities_in finds, so spectators are not hit and the same kinds
are left out. None for a negative or non-finite margin, a non-finite point, and where
entities_in is None (a client, a stale handle, a parked level).
pub fn spawn_limits(self, host: &dyn Host) -> Option<SpawnLimits>
pub fn spawn_limits(self, host: &dyn Host) -> Option<SpawnLimits>
Side: server.
The level’s natural spawning limits by category (SpawnLimits):
SpawnLimits::VANILLA until a mod sets others. Reads parked levels.
None on a client and for a stale handle.
pub fn spawn_flags(self, host: &dyn Host) -> Option<SpawnFlags>
pub fn spawn_flags(self, host: &dyn Host) -> Option<SpawnFlags>
Side: server.
Which categories the level’s natural spawning may spawn (SpawnFlags):
both on until a mod turns one off. Reads parked levels. None on a
client and for a stale handle.
pub fn can_spawn_entities_in_chunk(
self,
host: &dyn Host,
pos: [i32; 2],
) -> Option<bool>
pub fn can_spawn_entities_in_chunk( self, host: &dyn Host, pos: [i32; 2], ) -> Option<bool>
Side: server.
ServerLevel.canSpawnEntitiesInChunk: whether natural spawning may place
a mob in chunk pos ([x, z]), the question it asks of every spawn
position outside the chunk it started in. Horizon’s answer is the one
its spawner uses: the chunk is loaded. Reads parked levels and loads
nothing. None on a client and for a stale handle.
pub fn spawn_mob(
self,
host: &mut dyn ServerHost,
kind: &str,
pos: [f64; 3],
reason: SpawnReason,
) -> Option<EntityRef>
pub fn spawn_mob( self, host: &mut dyn ServerHost, kind: &str, pos: [f64; 3], reason: SpawnReason, ) -> Option<EntityRef>
Side: server.
Spawns a mob of kind (minecraft:zombie) at pos in the level as
EntityType.spawn does with reason: the entity type creates it (its
Parts and attachments with it, and entity_constructing), with a random
yaw from the level random, then finalize_spawn and finalizeSpawn
with that reason (equipment, variants, jockeys), and it joins the level
(entity_join_level), not persistent, as a natural spawn joins. The
level’s spawn limits, flags and spawn rules don’t apply, as they don’t
to /summon. The new mob as a handle. None, with nothing spawned, for a
kind that isn’t a mob, a position that isn’t finite or is outside the
spawnable bounds (Level.isInSpawnableBounds), an unloaded chunk, a
stale handle, a level not in place, a client, a finalize_spawn that
cancelled the spawn or a mob a mod kept out.
pub fn set_spawn_limits(
self,
host: &mut dyn ServerHost,
limits: SpawnLimits,
) -> bool
pub fn set_spawn_limits( self, host: &mut dyn ServerHost, limits: SpawnLimits, ) -> bool
Side: server.
Sets the level’s natural spawning limits (SpawnLimits), from the next
spawn pass on. They hold until the world closes, while the level is
parked and across its closing and opening again, and are not saved: the
world opens with vanilla’s, so a mod sets its own in level_load. Mobs
already in the level stay. False, with nothing set, on a client and for
a stale handle or a level that isn’t open.
pub fn set_spawn_flags(
self,
host: &mut dyn ServerHost,
flags: SpawnFlags,
) -> bool
pub fn set_spawn_flags( self, host: &mut dyn ServerHost, flags: SpawnFlags, ) -> bool
Side: server.
Sets which categories the level’s natural spawning may spawn
(SpawnFlags), from the next spawn pass on. Kept and refused as
set_spawn_limits.
pub fn set_block(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
state: BlockState,
flags: BlockUpdateFlags,
) -> Result<bool, LevelWriteError>
pub fn set_block( self, host: &mut dyn ServerHost, pos: [i32; 3], state: BlockState, flags: BlockUpdateFlags, ) -> Result<bool, LevelWriteError>
Side: server.
Set a block (Level.setBlock). Stale/unavailable levels and invalid states return
typed errors without mutation. Ok(false) means vanilla refused an unchanged,
unloaded or out-of-height write. Notification follows the supplied update flags.
pub fn remove_block(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
moved: bool,
) -> bool
pub fn remove_block( self, host: &mut dyn ServerHost, pos: [i32; 3], moved: bool, ) -> bool
Side: server.
Remove a block in place (Level.removeBlock), preserving its fluid.
pub fn destroy_block(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
drop: bool,
tool: Option<&ItemStack>,
collect: bool,
) -> Result<Option<Vec<ItemStack>>, StackWriteError>
pub fn destroy_block( self, host: &mut dyn ServerHost, pos: [i32; 3], drop: bool, tool: Option<&ItemStack>, collect: bool, ) -> Result<Option<Vec<ItemStack>>, StackWriteError>
Side: server.
Destroy a block in the level in place (Level.destroyBlock), optionally dropping
resources with tool (None is an empty hand). With collect, return the dropped
stacks without spawning their item entities; otherwise return an empty list after
spawning them. The one level drop path runs loot, block-drop hooks and experience
once, in vanilla’s random order. drop false suppresses resources entirely.
None means nothing broke: air, a refused write, a stale handle, a client, an
unloaded/out-of-height position, or a parked level.
pub fn set_respawn_data(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
yaw: f32,
pitch: f32,
) -> bool
pub fn set_respawn_data( self, host: &mut dyn ServerHost, pos: [i32; 3], yaw: f32, pitch: f32, ) -> bool
Side: server.
LevelData.setRespawnData(RespawnData.of(..)), as /setworldspawn does: the world spawn
moves to pos, facing yaw (wrapped to -180..180) and pitch (clamped to -90..90), a
player whose own respawn point was the old world spawn follows it, and spawn_change
fires. Only the Overworld’s handle, where Horizon keeps the world spawn. False for
another level, a stale handle, a client, a non-finite angle and a position outside the
spawnable bounds.
pub fn set_map_data(
self,
host: &mut dyn ServerHost,
id: i32,
colors: &[u8],
) -> bool
pub fn set_map_data( self, host: &mut dyn ServerHost, id: i32, colors: &[u8], ) -> bool
Side: server.
Repaint map id with colors (128 by 128 colour ids, row by row), pixel by pixel as
MapItemSavedData.setColor does: each changed pixel marks the map to save, to redraw and
to send to the players carrying or framing it. True when a pixel changed. False for
another length, a stale handle, a client and a map id nothing made.
pub fn block_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
pub fn block_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
Side: server.
Run the block at pos’s scheduled tick now (ServerLevel.tickBlock): the path a due
tick from the queue takes, the block’s part first, else BlockState.tick, with the same
random draws and level events. The queue is not read or changed; schedule_block_tick
queues one. False for a refused write, a stale or parked handle, a client and an
unloaded or out-of-height position.
pub fn request_save(self, host: &mut dyn ServerHost) -> bool
pub fn request_save(self, host: &mut dyn ServerHost) -> bool
Side: server.
Ask for the level to be saved: its level data, chunks and entities, as the autosave and
/save-all save a level, with its chunks on disk when it ends. The save runs at the start
of the next server tick, not inside the call, which may be in a hook of the very tick that
is saving; a level asked for twice before then is saved once. True when the request was
taken: the call cannot tell whether the save worked. level_save fires with the level’s
dimension once it was written; a save that fails fires nothing and is logged. False for a
stale handle and on a client.
pub fn set_world_border_center(
self,
host: &mut dyn ServerHost,
center: [f64; 2],
) -> bool
pub fn set_world_border_center( self, host: &mut dyn ServerHost, center: [f64; 2], ) -> bool
Side: server.
Moves the world border’s centre (WorldBorder.setCenter), as /worldborder center
does. Horizon keeps one border for every level, so this moves it everywhere; the
players see it after the next sync. The centre it already has is true, with nothing
heard. False for a centre that isn’t finite or lies past 2.9999984E7 on x or z, a call
from inside world_border_center_changed, a stale handle, a level the server has not
opened or a client.
pub fn set_world_border_size(
self,
host: &mut dyn ServerHost,
size: f64,
ticks: i64,
) -> bool
pub fn set_world_border_size( self, host: &mut dyn ServerHost, size: f64, ticks: i64, ) -> bool
Side: server.
Sets the world border’s size, as /worldborder set: at once when ticks is 0
(setSize), otherwise growing or shrinking in a straight line over ticks game ticks
from its size now (lerpSizeBetween). The one border every level shares. A still
border set to the size it has at once is true, with nothing heard. False for a size
outside 1 to 5.9999968E7, a negative ticks, a call from inside
world_border_bounds_changed, a stale handle, a level the server has not opened or a
client.
pub fn set_world_border_damage(
self,
host: &mut dyn ServerHost,
per_block: f64,
safe_zone: f64,
) -> bool
pub fn set_world_border_damage( self, host: &mut dyn ServerHost, per_block: f64, safe_zone: f64, ) -> bool
Side: server.
The world border’s damage (setDamagePerBlock, setSafeZone), as /worldborder damage amount and buffer: a player outside the border and past safe_zone blocks
takes per_block damage for each block beyond it. False for a value that is
negative or not finite, a stale handle, a level the server has not opened or a client.
pub fn set_world_border_warning(
self,
host: &mut dyn ServerHost,
distance: i32,
ticks: i32,
) -> bool
pub fn set_world_border_warning( self, host: &mut dyn ServerHost, distance: i32, ticks: i32, ) -> bool
Side: server.
The world border’s warning (setWarningBlocks, setWarningTime), as /worldborder warning distance and time: a player’s screen tints red within distance blocks of
the border, or when a shrinking border will reach them within ticks game ticks.
False for a negative value, a stale handle, a level the server has not opened or a
client.
pub fn set_weather(
self,
host: &mut dyn ServerHost,
clear_ticks: i32,
weather_ticks: i32,
raining: bool,
thundering: bool,
) -> bool
pub fn set_weather( self, host: &mut dyn ServerHost, clear_ticks: i32, weather_ticks: i32, raining: bool, thundering: bool, ) -> bool
Side: server.
Sets the weather as /weather does (ServerLevel.setWeatherParameters): clear for
clear_ticks, or raining (and thundering) for weather_ticks, after which the
weather cycle goes on as usual. Rain and thunder then fade in or out as vanilla’s do;
set_weather_levels sets their strength at once. The weather_change hook may cancel
all of it and thunder_change the thunder. The players see it after the next sync.
False for a negative time, a call from inside weather_change or thunder_change, a
parked level, a stale handle or a client.
pub fn set_weather_levels(
self,
host: &mut dyn ServerHost,
rain: f32,
thunder: f32,
) -> bool
pub fn set_weather_levels( self, host: &mut dyn ServerHost, rain: f32, thunder: f32, ) -> bool
Side: server.
How strong the rain and thunder are now (Level.setRainLevel, setThunderLevel),
each clamped to 0 to 1 and set without fading. They still drift toward the weather
the level has (set_weather) by 0.01 a tick, as vanilla’s do. False for a value that
isn’t finite, a parked level, a stale handle or a client.
pub fn block_random_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
pub fn block_random_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
Side: server.
Random-tick pos now, as ServerLevel.tickChunk does for a position it picked: the
block’s randomTick when it ticks randomly (its part first), then lava’s fluid random
tick, with the same random draws and level events. False as for block_tick.
pub fn fluid_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
pub fn fluid_tick(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
Side: server.
Run the flow step of the fluid at pos now (FluidState.tick, which ServerLevel.tickFluid
calls for a due fluid tick): the fluid levels, spreads and schedules its next step with
the same random draws, hooks and level events as a queued one. Ticking the empty fluid does
nothing. The queue is not read or changed; schedule_fluid_tick queues one. False for a
refused write, a stale or parked handle, a client and an unloaded or out-of-height
position.
pub fn lightning_target(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
) -> Option<[i32; 3]>
pub fn lightning_target( self, host: &mut dyn ServerHost, pos: [i32; 3], ) -> Option<[i32; 3]>
Side: server.
ServerLevel.findLightningTargetAround: the closest lightning rod near the column at
pos’s x and z, else a living entity under open sky within 3 blocks of it, picked
with the level random as vanilla does (so this moves later draws), else the top of the
column. Strikes nothing. None for a refused level, a stale or parked handle, a client and
an unloaded column.
pub fn block_drops(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
tool: Option<&ItemStack>,
entity: Option<EntityRef>,
) -> Result<Option<Vec<ItemStack>>, StackWriteError>
pub fn block_drops( self, host: &mut dyn ServerHost, pos: [i32; 3], tool: Option<&ItemStack>, entity: Option<EntityRef>, ) -> Result<Option<Vec<ItemStack>>, StackWriteError>
Side: server.
What the block at pos would drop (Block.getDrops(state, level, pos, blockEntity, entity, tool)), without breaking it or spawning anything: its loot table rolled with
tool (None is an empty hand) and entity as the breaker, with what its block entity
copies into the drops (a shulker box’s contents, a banner’s patterns, a pot’s sherds).
The roll draws from the table’s random sequence, else the level random, as vanilla’s
does, so it moves later draws: that is why this is a write. No block_drops event,
item entity or experience: that is destroy_block. None for a refused write, a stale or
parked handle, a client, an unloaded or out-of-height position, and a stale entity.
pub fn roll_loot(
self,
host: &mut dyn ServerHost,
table: &str,
origin: [f64; 3],
tool: Option<&ItemStack>,
entity: Option<EntityRef>,
) -> Result<Option<Vec<ItemStack>>, StackWriteError>
pub fn roll_loot( self, host: &mut dyn ServerHost, table: &str, origin: [f64; 3], tool: Option<&ItemStack>, entity: Option<EntityRef>, ) -> Result<Option<Vec<ItemStack>>, StackWriteError>
Side: server.
One roll of the loot table table (mymod:sifting/gravel, the world’s data packs
merged), handed back instead of dropped: LootTable.getRandomItems(LootParams) with
origin as ORIGIN, tool as TOOL when given and entity as THIS_ENTITY when given,
the context /loot … fish <table> <pos> <tool> gives. The roll draws from the table’s
random sequence, else the level random, as vanilla’s does, so it moves later draws: that
is why this is a write. The stacks come split to their stack sizes, empties left out.
Mods’ loot kinds see origin and this level; no loot_drops event, since nothing
drops. None for a table that isn’t there, a stale or parked handle, a client, and a
stale entity.
pub fn set_break_progress(
self,
host: &mut dyn ServerHost,
breaker: i32,
pos: [i32; 3],
progress: i32,
) -> bool
pub fn set_break_progress( self, host: &mut dyn ServerHost, breaker: i32, pos: [i32; 3], progress: i32, ) -> bool
Side: server.
Send ServerLevel.destroyBlockProgress in this level: stages 0..9 show a crack,
any other stage removes it. A machine uses a stable negative breaker id.
pub fn send_block_updated(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
) -> bool
pub fn send_block_updated( self, host: &mut dyn ServerHost, pos: [i32; 3], ) -> bool
Side: server.
Tell the clients the block at pos changed (Level.sendBlockUpdated): its state and
block entity data are sent again at the end of the tick, without writing anything, for
a mod that changed what a block shows by other means than a block write. False, with
nothing queued, for a stale or parked handle, a client, and an unloaded or out-of-height
position. True with no player to notify (no one is in the level) when the position is
valid: the chunk is marked changed and nothing is sent.
pub fn play_sound(
self,
host: &mut dyn ServerHost,
sound: &str,
at: [f64; 3],
source: SoundSource,
volume: f32,
pitch: f32,
) -> bool
pub fn play_sound( self, host: &mut dyn ServerHost, sound: &str, at: [f64; 3], source: SoundSource, volume: f32, pitch: f32, ) -> bool
Side: server.
Plays sound event sound at at for the players in this level
within range (16 blocks, times the volume above 1), as
ServerLevel.playSound(null, ...) does, under source’s volume
slider. A minecraft: event must be registered; a mod’s goes by name
and is heard where its resources define it. True means queued, not
heard.
pub fn send_particles(
self,
host: &mut dyn ServerHost,
options: &ParticleOptions,
state: Option<BlockState>,
at: [f64; 3],
spread: [f64; 3],
speed: f64,
count: i32,
) -> bool
pub fn send_particles( self, host: &mut dyn ServerHost, options: &ParticleOptions, state: Option<BlockState>, at: [f64; 3], spread: [f64; 3], speed: f64, count: i32, ) -> bool
Side: server.
Sends count particles around at to the players in this level
within 32 blocks, as ServerLevel.sendParticles does: each offset is
a Gaussian times spread, and speed scales their motion (a zero
count sends one particle moving along spread). Block particle types
need state; item particles need options.item_stack (validated against
the item registry and stack limits). Trail and vibration remain unsupported.
True means queued, not drawn.
pub fn level_event(
self,
host: &mut dyn ServerHost,
id: i32,
pos: [i32; 3],
data: i32,
) -> bool
pub fn level_event( self, host: &mut dyn ServerHost, id: i32, pos: [i32; 3], data: i32, ) -> bool
Side: server.
Plays level event id at pos with data for the players near it
(Level.levelEvent(null, id, pos, data)): 1000s are sounds, 2000s
particles, as vanilla’s LevelEvent numbers them (2001 breaks a
block with state id data). No player is left out, the acting one
included. False for an event that carries a block state (2001, 2014,
3008) when data isn’t one.
pub fn game_event(
self,
host: &mut dyn ServerHost,
event: &str,
at: [f64; 3],
context: GameEventContext,
) -> bool
pub fn game_event( self, host: &mut dyn ServerHost, event: &str, at: [f64; 3], context: GameEventContext, ) -> bool
Side: server.
Sends game event event (minecraft:block_change…) from at, as
Level.gameEvent(event, at, context) does: sculk sensors, shriekers,
wardens and allays receive the optional source and affected state.
Returns false without emitting for an unknown event, invalid position,
stale or foreign source, unregistered state, client or inactive level.
pub fn block_event(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
block: BlockKey,
a: i32,
b: i32,
) -> bool
pub fn block_event( self, host: &mut dyn ServerHost, pos: [i32; 3], block: BlockKey, a: i32, b: i32, ) -> bool
Side: server.
Queues block event a, b for block at pos, as ServerLevel.blockEvent(pos, block, a, b) does: after this tick’s scheduled ticks the level runs the block’s
triggerEvent with them (a powered piston’s 0 extends it, a note block’s plays its
note, a bell’s 1 rings it) if pos still holds block, and a handled event reaches the
players’ copy of the block. The same event queued twice runs once; one in a chunk
that isn’t ticking waits for it. True means queued, not handled. False for a block
key no block has, a position outside the level’s build height, a parked level, a stale
handle or a client.
pub fn explode(
self,
host: &mut dyn ServerHost,
center: [f64; 3],
radius: f32,
fire: bool,
interaction: ExplosionInteraction,
) -> bool
pub fn explode( self, host: &mut dyn ServerHost, center: [f64; 3], radius: f32, fire: bool, interaction: ExplosionInteraction, ) -> bool
Side: server.
Explodes at center with no source entity, as Level.explode(null, x, y, z, radius, fire, interaction) does (native_explode): fire
lights some of the air around, interaction says what happens to
blocks: None, Block or Tnt (vanilla’s Mob and Trigger aren’t
offered yet). False for a chunk that isn’t loaded or a radius outside
0 < radius <= 32.
pub fn strike_lightning(
self,
host: &mut dyn ServerHost,
at: [f64; 3],
visual_only: bool,
) -> bool
pub fn strike_lightning( self, host: &mut dyn ServerHost, at: [f64; 3], visual_only: bool, ) -> bool
Side: server.
Strikes lightning at at, as summoning a minecraft:lightning_bolt
does: it sets fire, hurts and converts what it hits (a pig to a
zombified piglin…) and every player hears the thunder. With
visual_only it only flashes and sounds (setVisualOnly). The
lightning_strike hook hears it first with the cause mod and may
cancel it. False for a chunk that isn’t loaded or a canceled strike.
pub fn pop_resource(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
stack: ItemStack,
) -> Result<Option<EntityRef>, StackWriteError>
pub fn pop_resource( self, host: &mut dyn ServerHost, pos: [i32; 3], stack: ItemStack, ) -> Result<Option<EntityRef>, StackWriteError>
Side: server.
Drops stack as a broken block drops it (Block.popResource): an
item entity at a random point within a quarter block of the middle of
pos (three draws from the level random, made for an empty stack and
with block_drops off too), with its own random motion and the
default pickup delay of 10 ticks. None, with nothing spawned, for an
empty stack or an unknown item, with the block_drops rule off, on a
client, for a stale handle, a level not in place, or an item a mod
kept out (native_entity_join_level).
pub fn spawn_item(
self,
host: &mut dyn ServerHost,
x: f64,
y: f64,
z: f64,
stack: ItemStack,
pickup_delay: u32,
) -> Result<Option<EntityRef>, StackWriteError>
pub fn spawn_item( self, host: &mut dyn ServerHost, x: f64, y: f64, z: f64, stack: ItemStack, pickup_delay: u32, ) -> Result<Option<EntityRef>, StackWriteError>
Side: server.
Spawns stack as an item entity at x y z (new ItemEntity(level, x, y, z, stack) and addFreshEntity): its own random motion (up 0.2, up
to 0.1 either way across), with pickup_delay ticks before it can be
picked up, as ItemEntity.setPickupDelay at construction (vanilla
passes 10 for a block’s drop, 40 for a player’s throw and 32767 for
never). None, with nothing
spawned, for an empty stack or an unknown item, a value that isn’t
finite, on a client, for a stale handle, a level not in place, or an
item a mod kept out (native_entity_join_level).
pub fn spawn_item_with_motion(
self,
host: &mut dyn ServerHost,
x: f64,
y: f64,
z: f64,
stack: ItemStack,
motion: [f64; 3],
pickup_delay: u32,
) -> Result<Option<EntityRef>, StackWriteError>
pub fn spawn_item_with_motion( self, host: &mut dyn ServerHost, x: f64, y: f64, z: f64, stack: ItemStack, motion: [f64; 3], pickup_delay: u32, ) -> Result<Option<EntityRef>, StackWriteError>
Side: server.
spawn_item with the item entity’s motion set to
motion (blocks a tick), as new ItemEntity(level, x, y, z, stack, deltaX, deltaY, deltaZ), and the same pickup_delay ticks before it
can be picked up (ItemEntity.setPickupDelay). None in the same
cases, and for a motion that isn’t finite.
pub fn award_experience(
self,
host: &mut dyn ServerHost,
x: f64,
y: f64,
z: f64,
amount: u32,
) -> bool
pub fn award_experience( self, host: &mut dyn ServerHost, x: f64, y: f64, z: f64, amount: u32, ) -> bool
Side: server.
Awards amount experience at x y z as vanilla’s ExperienceOrb.award
does: orbs of the largest sizes first (2477, 1237, … 3, 1), each
drawing the id tryMergeToExisting compares from the level random and
merging into an orb of the same value whose box meets the 1 block box
around x y z, or else a new orb with its own random motion. The
block_drops rule doesn’t apply (vanilla’s blocks check it before
they award). True once the orbs are awarded, even if a mod keeps a new
one out (native_entity_join_level). False, with no orbs, for 0, a
value that isn’t finite, on a client, for a stale handle or a level
not in place.
pub fn update_neighbors(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
source: BlockState,
update: NeighbourUpdate,
) -> Result<bool, LevelWriteError>
pub fn update_neighbors( self, host: &mut dyn ServerHost, pos: [i32; 3], source: BlockState, update: NeighbourUpdate, ) -> Result<bool, LevelWriteError>
Side: server.
Tell the neighbours of pos that a block changed there, as vanilla’s own writes do:
Neighbours (Level.updateNeighborsAt: a lever’s or a button’s own block, and the one
it is attached to, when the signal it gives changes), NeighboursExcept(direction)
(updateNeighborsAtExceptFromFacing: a diode’s front) or OutputSignal
(updateNeighbourForOutputSignal: the comparators beside it, when its comparator output
changes without its state changing). source is the state whose block vanilla passes as
the one that changed. Typed errors refuse stale/unavailable levels or invalid states
without mutation; Ok(false) means an unloaded or out-of-height position.
pub fn neighbor_changed(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
source: BlockState,
) -> Result<bool, LevelWriteError>
pub fn neighbor_changed( self, host: &mut dyn ServerHost, pos: [i32; 3], source: BlockState, ) -> Result<bool, LevelWriteError>
Side: server.
Tell the block at pos that source’s block beside it changed (Level.neighborChanged),
as a diode tells the block in front of it before updating that block’s neighbours.
Typed errors refuse stale/unavailable levels or invalid states; Ok(false) means an
unloaded or out-of-height position. Errors never mutate the level.
pub fn set_random(self, host: &mut dyn ServerHost, random: LegacyRandom) -> bool
pub fn set_random(self, host: &mut dyn ServerHost, random: LegacyRandom) -> bool
Side: server.
Replace the random of the server level level names with random,
a stream native_level_random gave and the mod drew from. False where
that gives None.
pub fn bone_meal(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
pub fn bone_meal(self, host: &mut dyn ServerHost, pos: [i32; 3]) -> bool
Side: both.
Apply bone meal to the block at pos as a dispenser does (BoneMealItem.growCrop, then
growWaterPlant), with no player and no item: the mods’ bonemeal hook first, level event
1505 when something grew. True when something grew; false for a refused write, a stale or
parked handle, a client, and a block that did not grow.
pub fn set_biome(
self,
host: &mut dyn ServerHost,
pos: [i32; 3],
biome: &str,
) -> bool
pub fn set_biome( self, host: &mut dyn ServerHost, pos: [i32; 3], biome: &str, ) -> bool
Side: both.
Set the biome of the 4x4x4 cell holding pos to biome (minecraft:plains), as
/fillbiome does for one cell. False for a refused write, a stale or parked handle, a
client, an unknown biome and an unchanged cell.
pub fn set_client_break_progress(
self,
host: &mut dyn ClientHost,
breaker: i32,
pos: [i32; 3],
progress: i32,
) -> bool
pub fn set_client_break_progress( self, host: &mut dyn ClientHost, breaker: i32, pos: [i32; 3], progress: i32, ) -> bool
Side: client.
Show or clear the crack of breaker on the block at pos in this client’s own view
(LevelRenderer.destroyBlockProgress): stages 0..9 show a crack, any other stage removes
it. Nothing is sent to the server or to other players, and a crack not updated for 400
ticks goes away. False for a stale or foreign level or before login.
use mod_api::{LevelRef, ServerHost};
fn wrong_side(level: LevelRef, host: &mut dyn ServerHost) {
level.set_client_break_progress(host, -1, [0, 64, 0], 3);
}§impl LevelRef
impl LevelRef
pub fn capability<T>(
self,
host: &mut dyn ServerHost,
key: &CapabilityKey<T>,
pos: [i32; 3],
side: Option<Direction>,
) -> Option<Capability<T>>where
T: 'static + ?Sized,
pub fn capability<T>(
self,
host: &mut dyn ServerHost,
key: &CapabilityKey<T>,
pos: [i32; 3],
side: Option<Direction>,
) -> Option<Capability<T>>where
T: 'static + ?Sized,
key‘s handler for the block entity at pos in this level, reached through side
(Level.getCapability): the first provider to answer, of those mods registered for its
type before_game, the game’s own, and the mods’ others, each in registration order. None
for a stale handle, and for a level not in place (LevelRef::in_place), whose block
entities the game doesn’t write: no provider is asked for one. Disabled mods’ providers
are skipped; re-enabling a mod makes its registrations available to the next lookup.
§impl LevelRef
impl LevelRef
pub fn dimension(self) -> DimensionKey
pub fn dimension(self) -> DimensionKey
The level’s dimension. level.dimension().id(host) gives its name.
pub fn with_random<T>(
self,
host: &mut dyn ServerHost,
draw: impl FnOnce(&mut LegacyRandom) -> T,
) -> Option<T>
pub fn with_random<T>( self, host: &mut dyn ServerHost, draw: impl FnOnce(&mut LegacyRandom) -> T, ) -> Option<T>
Draw from the level’s own random stream (vanilla’s Level.random), in vanilla’s order:
draw gets the stream and the level keeps it after. None where random is None.
pub fn epoch(self) -> WorldEpoch
pub fn epoch(self) -> WorldEpoch
The open of the world the handle belongs to.