Docs » API reference » World

World

The world: blocks, placed objects, loose items, Voxelmon, time, weather, towns and dungeons.

Only the world around the players is loaded. A block far from everyone is not loaded, and reading it gives nothing. Changing blocks, objects or loose items needs world_edit, and spawning Voxelmon needs creatures.

You get one from server.world().

Methods

MethodDescription
fn seed(&self) -> Result<i64>long seed()The world's seed.
fn day(&self) -> Result<i64>long day()The day's number since the world began.
fn time_of_day(&self) -> Result<f64>double timeOfDay()Where the day is, 0 to 1: 0 dawn, 0.4 dusk (20 minutes of day, 10 of night).
fn is_night(&self) -> Result<bool>boolean isNight()Whether it is night.
fn weather(&self) -> Result<Weather>Weather weather()The weather: what falls and how hard (a spell's own strength while it rains, not its fading), or a plugin's held weather.
fn spawn(&self) -> Result<Place>Place spawn()Where new players arrive.
fn block(&self, at: BlockPos) -> Result<Option<Block>>Optional<Block> block(BlockPos at)The block there, if loaded.
fn set_block(&self, at: BlockPos, r#type: BlockType) -> Result<()>void setBlock(BlockPos at, BlockType type) world_editChanges a loaded block.
fn break_block(&self, at: BlockPos, drop: bool) -> Result<()>void breakBlock(BlockPos at, boolean drop) world_editBreaks a block as a player would, dropping it or not.
fn fill(&self, from: BlockPos, to: BlockPos, r#type: BlockType) -> Result<i64>long fill(BlockPos from, BlockPos to, BlockType type) world_editFills a box of at most 32,768 loaded blocks; returns how many changed.
fn paint_block(&self, at: BlockPos, colour: Colour, surface: Option<BlockType>) -> Result<()>void paintBlock(BlockPos at, Colour colour, BlockType surface) world_editPaints a loaded blank block a colour, showing another block's texture if surface is given (Paint); fails for any other block, or a surface that cannot be painted. Players see it at once, and the world keeps it.
fn clear_paint(&self, at: BlockPos) -> Result<()>void clearPaint(BlockPos at) world_editTakes a blank block's paint away, leaving it blank.
fn surface(&self, x: i64, z: i64) -> Result<Option<i64>>Optional<Long> surface(long x, long z)The height of the highest solid block in a column, if loaded.
fn biome(&self, x: i64, z: i64) -> Result<String>String biome(long x, long z)The biome's name at a column.
fn objects_near(&self, place: Place, radius: f64) -> Result<Vec<PlacedObject>>List<PlacedObject> objectsNear(Place place, double radius)Placed objects nearby (radius at most 64).
fn object_at(&self, at: BlockPos) -> Result<Option<PlacedObject>>Optional<PlacedObject> objectAt(BlockPos at)The placed object filling that block.
fn place_object(&self, item: ItemType, at: BlockPos, facing: f64) -> Result<Option<PlacedObject>>Optional<PlacedObject> placeObject(ItemType item, BlockPos at, double facing) world_editPlaces furniture, a station, a chest, a bed or a door; nothing if it does not fit.
fn place_model(&self, model: Model, at: BlockPos, facing: f64) -> Result<Option<PlacedObject>>Optional<PlacedObject> placeModel(Model model, BlockPos at, double facing) world_editPlaces an object made from a content pack's model, its footprint's first block at at, its front (the side its seat faces and its tray opens on: the model's north, Blockbench's -Z) turned to the nearest quarter of facing (degrees clockwise from north, as a player's facing); nothing if a block or another object is in its way. It needs no floor or wall to stand on.
fn drop_item(&self, place: Place, stack: ItemStack) -> Result<LooseItem>LooseItem dropItem(Place place, ItemStack stack) world_editDrops items on the ground.
fn loose_items_near(&self, place: Place, radius: f64) -> Result<Vec<LooseItem>>List<LooseItem> looseItemsNear(Place place, double radius)Items lying nearby (radius at most 64).
fn creatures_near(&self, place: Place, radius: f64) -> Result<Vec<Creature>>List<Creature> creaturesNear(Place place, double radius)Voxelmon nearby (radius at most 64).
fn spawn_creature(&self, species: Species, level: i64, place: Place) -> Result<Option<Creature>>Optional<Creature> spawnCreature(Species species, long level, Place place) creaturesA wild Voxelmon there; nothing if it does not fit or the world is full. It is the world's to keep: saved with it and never let go by the wild population's own limits, it stays until beaten, caught or removed (Creature.remove).
fn players_near(&self, place: Place, radius: f64) -> Result<Vec<Player>>List<Player> playersNear(Place place, double radius)Players nearby.
fn set_time_of_day(&self, value: f64) -> Result<()>void setTimeOfDay(double value)Sets the time of day, 0 to 1.
fn set_weather(&self, weather: Weather, seconds: f64) -> Result<()>void setWeather(Weather weather, double seconds)Holds the weather for seconds (at most 10,000,000; 0 lets a held weather go at once), then it follows its own course. Every player's sky eases into it over a few seconds; rain falls as snow where it is cold. Measured on the world's clock: setting the time of day past its end, or back before its start, lets it go.
fn set_spawn(&self, place: Place) -> Result<()>void setSpawn(Place place)Moves where new players arrive.
fn town_at(&self, place: Place) -> Result<Option<Town>>Optional<Town> townAt(Place place)The town covering a place.
fn towns_near(&self, place: Place, radius: f64) -> Result<Vec<Town>>List<Town> townsNear(Place place, double radius)Towns whose centres lie within a distance across (at most 1,024), nearest first, at most 64.
fn dungeon_at(&self, place: Place) -> Result<Option<Dungeon>>Optional<Dungeon> dungeonAt(Place place)The dungeon covering a place.
fn dungeons_near(&self, place: Place, radius: f64) -> Result<Vec<Dungeon>>List<Dungeon> dungeonsNear(Place place, double radius)Dungeons whose centres lie within a distance across (at most 1,024), nearest first, at most 64.
fn shop_goods(&self, job: &str, freed: bool) -> Result<Vec<ShopGood>>List<ShopGood> shopGoods(String job, boolean freed)What a townsperson of a trade (blacksmith, cook...) sells, in a town free of its Voxelord or not, with the prices it asks: the content packs' and plugins' goods first, then the trade's own as room allows (four at most).
fn set_shop_goods(&self, job: &str, town: &str, goods: Vec<ShopGood>, replace: bool) -> Result<bool>boolean setShopGoods(String job, String town, List<ShopGood> goods, boolean replace) world_editSets what a trade sells in towns any, threatened or freed: these goods (at most four, each a price of 1 to 1,000,000 coins) before the trade's own, or in their place with replace; an empty list takes the rule away. It stands for the session, in place of a content pack's rule for the same trade and towns, and every player's shop shows it at once. False for an unknown trade or town, the clinic's healer (who sells nothing), or goods past the limits.
fn region(&self, id: &str, from: BlockPos, to: BlockPos) -> Result<Region>Region region(String id, BlockPos from, BlockPos to)A named box players are told of entering and leaving (Region); the same id gives the same region.
fn regions(&self) -> Result<Vec<Region>>List<Region> regions()This plugin's regions.

LooseItem

Items lying in the world.

A handle to something in the game. Once that thing is gone, its calls fail with Gone.

MethodDescription
fn stack(&self) -> Result<ItemStack>ItemStack stack()What they are.
fn position(&self) -> Result<Place>Place position()Where they are.
fn remove(&self) -> Result<()>void remove() world_editTakes them away.

Weather

The weather.

Plain data, copied between the server and the plugin.

FieldDescription
kind: WeatherKindWeatherKind kind()What falls.
strength: f64double strength()How strong, 0 to 1.

WeatherKind

What falls from the sky.

One of a fixed set of values.

ValueMeaning
WeatherKind::ClearWeatherKind.CLEARNothing.
WeatherKind::RainWeatherKind.RAINRain (snow where it is cold).
WeatherKind::StormWeatherKind.STORMA thunderstorm (a snowstorm where it is cold).

Events

Related events: BlockChanged, DayStarted, NightStarted, WeatherChanged, WorldSaved.