package org.bukkit; import java.io.File; import org.bukkit.generator.ChunkGenerator; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.Predicate; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.entity.*; import org.bukkit.generator.BlockPopulator; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.metadata.Metadatable; import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.util.BoundingBox; import org.bukkit.util.Consumer; import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; /** * Represents a world, which may contain entities, chunks and blocks */ public interface World extends PluginMessageRecipient, Metadatable { /** * Gets the {@link Block} at the given coordinates * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @return Block at the given coordinates */ public Block getBlockAt(int x, int y, int z); /** * Gets the {@link Block} at the given {@link Location} * * @param location Location of the block * @return Block at the given location */ public Block getBlockAt(Location location); /** * Gets the y coordinate of the lowest block at this position such that the * block and all blocks above it are transparent for lighting purposes. * * @param x X-coordinate of the blocks * @param z Z-coordinate of the blocks * @return Y-coordinate of the described block */ public int getHighestBlockYAt(int x, int z); /** * Gets the y coordinate of the lowest block at the given {@link Location} * such that the block and all blocks above it are transparent for lighting * purposes. * * @param location Location of the blocks * @return Y-coordinate of the highest non-air block */ public int getHighestBlockYAt(Location location); /** * Gets the lowest block at the given coordinates such that the block and * all blocks above it are transparent for lighting purposes. * * @param x X-coordinate of the block * @param z Z-coordinate of the block * @return Highest non-empty block */ public Block getHighestBlockAt(int x, int z); /** * Gets the lowest block at the given {@link Location} such that the block * and all blocks above it are transparent for lighting purposes. * * @param location Coordinates to get the highest block * @return Highest non-empty block */ public Block getHighestBlockAt(Location location); /** * Gets the {@link Chunk} at the given coordinates * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return Chunk at the given coordinates */ public Chunk getChunkAt(int x, int z); /** * Gets the {@link Chunk} at the given {@link Location} * * @param location Location of the chunk * @return Chunk at the given location */ public Chunk getChunkAt(Location location); /** * Gets the {@link Chunk} that contains the given {@link Block} * * @param block Block to get the containing chunk from * @return The chunk that contains the given block */ public Chunk getChunkAt(Block block); /** * Checks if the specified {@link Chunk} is loaded * * @param chunk The chunk to check * @return true if the chunk is loaded, otherwise false */ public boolean isChunkLoaded(Chunk chunk); /** * Gets an array of all loaded {@link Chunk}s * * @return Chunk[] containing all loaded chunks */ public Chunk[] getLoadedChunks(); /** * Loads the specified {@link Chunk} * * @param chunk The chunk to load */ public void loadChunk(Chunk chunk); /** * Checks if the {@link Chunk} at the specified coordinates is loaded * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return true if the chunk is loaded, otherwise false */ public boolean isChunkLoaded(int x, int z); /** * Checks if the {@link Chunk} at the specified coordinates is generated * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return true if the chunk is generated, otherwise false */ public boolean isChunkGenerated(int x, int z); /** * Checks if the {@link Chunk} at the specified coordinates is loaded and * in use by one or more players * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return true if the chunk is loaded and in use by one or more players, * otherwise false */ public boolean isChunkInUse(int x, int z); /** * Loads the {@link Chunk} at the specified coordinates *
* If the chunk does not exist, it will be generated. *
* This method is analogous to {@link #loadChunk(int, int, boolean)} where * generate is true. * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk */ public void loadChunk(int x, int z); /** * Loads the {@link Chunk} at the specified coordinates * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @param generate Whether or not to generate a chunk if it doesn't * already exist * @return true if the chunk has loaded successfully, otherwise false */ public boolean loadChunk(int x, int z, boolean generate); /** * Safely unloads and saves the {@link Chunk} at the specified coordinates *
* This method is analogous to {@link #unloadChunk(int, int, boolean, * boolean)} where safe and saveis true * * @param chunk the chunk to unload * @return true if the chunk has unloaded successfully, otherwise false */ public boolean unloadChunk(Chunk chunk); /** * Safely unloads and saves the {@link Chunk} at the specified coordinates *
* This method is analogous to {@link #unloadChunk(int, int, boolean, * boolean)} where safe and saveis true * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return true if the chunk has unloaded successfully, otherwise false */ public boolean unloadChunk(int x, int z); /** * Safely unloads and optionally saves the {@link Chunk} at the specified * coordinates *
* This method is analogous to {@link #unloadChunk(int, int, boolean, * boolean)} where save is true * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @param save Whether or not to save the chunk * @return true if the chunk has unloaded successfully, otherwise false */ public boolean unloadChunk(int x, int z, boolean save); /** * Unloads and optionally saves the {@link Chunk} at the specified * coordinates * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @param save Controls whether the chunk is saved * @param safe Controls whether to unload the chunk when players are * nearby * @return true if the chunk has unloaded successfully, otherwise false * @deprecated it is never safe to remove a chunk in use */ @Deprecated public boolean unloadChunk(int x, int z, boolean save, boolean safe); /** * Safely queues the {@link Chunk} at the specified coordinates for * unloading *
* This method is analogous to {@link #unloadChunkRequest(int, int,
* boolean)} where safe is true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true is the queue attempt was successful, otherwise false
*/
public boolean unloadChunkRequest(int x, int z);
/**
* Queues the {@link Chunk} at the specified coordinates for unloading
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
*/
public boolean unloadChunkRequest(int x, int z, boolean safe);
/**
* Regenerates the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually regenerated
*
* @deprecated regenerating a single chunk is not guaranteed to produce the
* same chunk as before as terrain decoration may be spread across chunks
*/
@Deprecated
public boolean regenerateChunk(int x, int z);
/**
* Resends the {@link Chunk} to all clients
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually refreshed
*
* @deprecated This method is not guaranteed to work suitably across all client implementations.
*/
@Deprecated
public boolean refreshChunk(int x, int z);
/**
* Drops an item at the specified {@link Location}
*
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItem(Location location, ItemStack item);
/**
* Drops an item at the specified {@link Location} with a random offset
*
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItemNaturally(Location location, ItemStack item);
/**
* Creates an {@link Arrow} entity at the given {@link Location}
*
* @param location Location to spawn the arrow
* @param direction Direction to shoot the arrow in
* @param speed Speed of the arrow. A recommend speed is 0.6
* @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method
*/
public Arrow spawnArrow(Location location, Vector direction, float speed, float spread);
/**
* Creates an arrow entity of the given class at the given {@link Location}
*
* @param
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the size of the
* search bounding box.
*
* @param location The center of the bounding box
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @return the collection of entities near location. This will always be a
* non-null collection.
*/
public Collection
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the size of the
* search bounding box.
*
* @param location The center of the bounding box
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @param filter only entities that fulfill this predicate are considered,
* or
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the size of the
* search bounding box.
*
* @param boundingBox the bounding box
* @return the collection of entities within the bounding box, will always
* be a non-null collection
*/
public Collection
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the size of the
* search bounding box.
*
* @param boundingBox the bounding box
* @param filter only entities that fulfill this predicate are considered,
* or
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum
* distance.
*
* @param start the start position
* @param direction the ray direction
* @param maxDistance the maximum distance
* @return the closest ray trace hit result, or
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum
* distance.
*
* @param start the start position
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks
* @return the closest ray trace hit result, or
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum
* distance.
*
* @param start the start position
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param filter only entities that fulfill this predicate are considered,
* or
* This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum
* distance.
*
* @param start the start position
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks
* @param filter only entities that fulfill this predicate are considered,
* or
* This takes collisions with passable blocks into account, but ignores
* fluids.
*
* This may cause loading of chunks! Some implementations may impose
* artificial restrictions on the maximum distance.
*
* @param start the start location
* @param direction the ray direction
* @param maxDistance the maximum distance
* @return the ray trace hit result, or
* This takes collisions with passable blocks into account.
*
* This may cause loading of chunks! Some implementations may impose
* artificial restrictions on the maximum distance.
*
* @param start the start location
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param fluidCollisionMode the fluid collision mode
* @return the ray trace hit result, or
* If collisions with passable blocks are ignored, fluid collisions are
* ignored as well regardless of the fluid collision mode.
*
* Portal blocks are only considered passable if the ray starts within
* them. Apart from that collisions with portal blocks will be considered
* even if collisions with passable blocks are otherwise ignored.
*
* This may cause loading of chunks! Some implementations may impose
* artificial restrictions on the maximum distance.
*
* @param start the start location
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param fluidCollisionMode the fluid collision mode
* @param ignorePassableBlocks whether to ignore passable but collidable
* blocks (ex. tall grass, signs, fluids, ..)
* @return the ray trace hit result, or
* Block collisions use the blocks' precise collision shapes. The
*
* If collisions with passable blocks are ignored, fluid collisions are
* ignored as well regardless of the fluid collision mode.
*
* Portal blocks are only considered passable if the ray starts within them.
* Apart from that collisions with portal blocks will be considered even if
* collisions with passable blocks are otherwise ignored.
*
* This may cause loading of chunks! Some implementations may impose
* artificial restrictions on the maximum distance.
*
* @param start the start location
* @param direction the ray direction
* @param maxDistance the maximum distance
* @param fluidCollisionMode the fluid collision mode
* @param ignorePassableBlocks whether to ignore passable but collidable
* blocks (ex. tall grass, signs, fluids, ..)
* @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks
* @param filter only entities that fulfill this predicate are considered,
* or
* The relative time is analogous to hours * 1000
*
* @return The current relative time
* @see #getFullTime() Returns an absolute time of this world
*/
public long getTime();
/**
* Sets the relative in-game time on the server.
*
* The relative time is analogous to hours * 1000
*
* Note that setting the relative time below the current relative time
* will actually move the clock forward a day. If you require to rewind
* time, please see {@link #setFullTime(long)}
*
* @param time The new relative time to set the in-game time to (in
* hours*1000)
* @see #setFullTime(long) Sets the absolute time of this world
*/
public void setTime(long time);
/**
* Gets the full in-game time on this world
*
* @return The current absolute time
* @see #getTime() Returns a relative time of this world
*/
public long getFullTime();
/**
* Sets the in-game time on the server
*
* Note that this sets the full time of the world, which may cause adverse
* effects such as breaking redstone clocks and any scheduled events
*
* @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world
*/
public void setFullTime(long time);
/**
* Returns whether the world has an ongoing storm.
*
* @return Whether there is an ongoing storm
*/
public boolean hasStorm();
/**
* Set whether there is a storm. A duration will be set for the new
* current conditions.
*
* @param hasStorm Whether there is rain and snow
*/
public void setStorm(boolean hasStorm);
/**
* Get the remaining time in ticks of the current conditions.
*
* @return Time in ticks
*/
public int getWeatherDuration();
/**
* Set the remaining time in ticks of the current conditions.
*
* @param duration Time in ticks
*/
public void setWeatherDuration(int duration);
/**
* Returns whether there is thunder.
*
* @return Whether there is thunder
*/
public boolean isThundering();
/**
* Set whether it is thundering.
*
* @param thundering Whether it is thundering
*/
public void setThundering(boolean thundering);
/**
* Get the thundering duration.
*
* @return Duration in ticks
*/
public int getThunderDuration();
/**
* Set the thundering duration.
*
* @param duration Duration in ticks
*/
public void setThunderDuration(int duration);
/**
* Creates explosion at given coordinates with given power
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power);
/**
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire.
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire);
/**
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire or breaking blocks.
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @param breakBlocks Whether or not to have blocks be destroyed
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks);
/**
* Creates explosion at given coordinates with given power
*
* @param loc Location to blow up
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power);
/**
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire.
*
* @param loc Location to blow up
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power, boolean setFire);
/**
* Gets the {@link Environment} type of this world
*
* @return This worlds Environment type
*/
public Environment getEnvironment();
/**
* Gets the Seed for this world.
*
* @return This worlds Seed
*/
public long getSeed();
/**
* Gets the current PVP setting for this world.
*
* @return True if PVP is enabled
*/
public boolean getPVP();
/**
* Sets the PVP setting for this world.
*
* @param pvp True/False whether PVP should be Enabled.
*/
public void setPVP(boolean pvp);
/**
* Gets the chunk generator for this world
*
* @return ChunkGenerator associated with this world
*/
public ChunkGenerator getGenerator();
/**
* Saves world to disk
*/
public void save();
/**
* Gets a list of all applied {@link BlockPopulator}s for this World
*
* @return List containing any or none BlockPopulators
*/
public List
* The Material must be a block type, check with {@link Material#isBlock()
* material.isBlock()}. The Material may not be air.
*
* @param location The {@link Location} to spawn the FallingBlock
* @param data The block data
* @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link
* MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block
*/
public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of
* the specified {@link Material}. The material dictates what is falling.
* When the FallingBlock hits the ground, it will place that block.
*
* The Material must be a block type, check with {@link Material#isBlock()
* material.isBlock()}. The Material may not be air.
*
* @param location The {@link Location} to spawn the FallingBlock
* @param data The block data
* @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link
* BlockData} are null
*/
public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of the
* specified {@link Material}. The material dictates what is falling.
* When the FallingBlock hits the ground, it will place that block.
*
* The Material must be a block type, check with {@link Material#isBlock()
* material.isBlock()}. The Material may not be air.
*
* @param location The {@link Location} to spawn the FallingBlock
* @param material The block {@link Material} type
* @param data The block data
* @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link
* Material} are null or {@link Material} is not a block
* @deprecated Magic value
*/
@Deprecated
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException;
/**
* Plays an effect to all players within a default radius around a given
* location.
*
* @param location the {@link Location} around which players must be to
* hear the sound
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
*/
public void playEffect(Location location, Effect effect, int data);
/**
* Plays an effect to all players within a given radius around a location.
*
* @param location the {@link Location} around which players must be to
* hear the effect
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
* @param radius the radius around the location
*/
public void playEffect(Location location, Effect effect, int data, int radius);
/**
* Plays an effect to all players within a default radius around a given
* location.
*
* @param
* It is safe to run this method when the block does not exist, it will
* not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
* @return Temperature of the requested block
*/
public double getTemperature(int x, int z);
/**
* Gets the humidity for the given block coordinates.
*
* It is safe to run this method when the block does not exist, it will
* not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
* @return Humidity of the requested block
*/
public double getHumidity(int x, int z);
/**
* Gets the maximum height of this world.
*
* If the max height is 100, there are only blocks from y=0 to y=99.
*
* @return Maximum height of the world
*/
public int getMaxHeight();
/**
* Gets the sea level for this world.
*
* This is often half of {@link #getMaxHeight()}
*
* @return Sea level
*/
public int getSeaLevel();
/**
* Gets whether the world's spawn area should be kept loaded into memory
* or not.
*
* @return true if the world's spawn area will be kept loaded into memory.
*/
public boolean getKeepSpawnInMemory();
/**
* Sets whether the world's spawn area should be kept loaded into memory
* or not.
*
* @param keepLoaded if true then the world's spawn area will be kept
* loaded into memory.
*/
public void setKeepSpawnInMemory(boolean keepLoaded);
/**
* Gets whether or not the world will automatically save
*
* @return true if the world will automatically save, otherwise false
*/
public boolean isAutoSave();
/**
* Sets whether or not the world will automatically save
*
* @param value true if the world should automatically save, otherwise
* false
*/
public void setAutoSave(boolean value);
/**
* Sets the Difficulty of the world.
*
* @param difficulty the new difficulty you want to set the world to
*/
public void setDifficulty(Difficulty difficulty);
/**
* Gets the Difficulty of the world.
*
* @return The difficulty of the world.
*/
public Difficulty getDifficulty();
/**
* Gets the folder of this world on disk.
*
* @return The folder of this world.
*/
public File getWorldFolder();
/**
* Gets the type of this world.
*
* @return Type of this world.
*/
public WorldType getWorldType();
/**
* Gets whether or not structures are being generated.
*
* @return True if structures are being generated.
*/
public boolean canGenerateStructures();
/**
* Gets the world's ticks per animal spawns value
*
* This value determines how many ticks there are between attempts to
* spawn animals.
*
* Example Usage:
*
* Note:
* If set to 0, animal spawning will be disabled for this world. We
* recommend using {@link #setSpawnFlags(boolean, boolean)} to control
* this instead.
*
* Minecraft default: 400.
*
* @return The world's ticks per animal spawns value
*/
public long getTicksPerAnimalSpawns();
/**
* Sets the world's ticks per animal spawns value
*
* This value determines how many ticks there are between attempts to
* spawn animals.
*
* Example Usage:
*
* Note:
* If set to 0, animal spawning will be disabled for this world. We
* recommend using {@link #setSpawnFlags(boolean, boolean)} to control
* this instead.
*
* Minecraft default: 400.
*
* @param ticksPerAnimalSpawns the ticks per animal spawns value you want
* to set the world to
*/
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns);
/**
* Gets the world's ticks per monster spawns value
*
* This value determines how many ticks there are between attempts to
* spawn monsters.
*
* Example Usage:
*
* Note:
* If set to 0, monsters spawning will be disabled for this world. We
* recommend using {@link #setSpawnFlags(boolean, boolean)} to control
* this instead.
*
* Minecraft default: 1.
*
* @return The world's ticks per monster spawns value
*/
public long getTicksPerMonsterSpawns();
/**
* Sets the world's ticks per monster spawns value
*
* This value determines how many ticks there are between attempts to
* spawn monsters.
*
* Example Usage:
*
* Note:
* If set to 0, monsters spawning will be disabled for this world. We
* recommend using {@link #setSpawnFlags(boolean, boolean)} to control
* this instead.
*
* Minecraft default: 1.
*
* @param ticksPerMonsterSpawns the ticks per monster spawns value you
* want to set the world to
*/
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns);
/**
* Gets limit for number of monsters that can spawn in a chunk in this
* world
*
* @return The monster spawn limit
*/
int getMonsterSpawnLimit();
/**
* Sets the limit for number of monsters that can spawn in a chunk in this
* world
*
* Note: If set to a negative number the world will use the
* server-wide spawn limit instead.
*
* @param limit the new mob limit
*/
void setMonsterSpawnLimit(int limit);
/**
* Gets the limit for number of animals that can spawn in a chunk in this
* world
*
* @return The animal spawn limit
*/
int getAnimalSpawnLimit();
/**
* Sets the limit for number of animals that can spawn in a chunk in this
* world
*
* Note: If set to a negative number the world will use the
* server-wide spawn limit instead.
*
* @param limit the new mob limit
*/
void setAnimalSpawnLimit(int limit);
/**
* Gets the limit for number of water animals that can spawn in a chunk in
* this world
*
* @return The water animal spawn limit
*/
int getWaterAnimalSpawnLimit();
/**
* Sets the limit for number of water animals that can spawn in a chunk in
* this world
*
* Note: If set to a negative number the world will use the
* server-wide spawn limit instead.
*
* @param limit the new mob limit
*/
void setWaterAnimalSpawnLimit(int limit);
/**
* Gets the limit for number of ambient mobs that can spawn in a chunk in
* this world
*
* @return The ambient spawn limit
*/
int getAmbientSpawnLimit();
/**
* Sets the limit for number of ambient mobs that can spawn in a chunk in
* this world
*
* Note: If set to a negative number the world will use the
* server-wide spawn limit instead.
*
* @param limit the new mob limit
*/
void setAmbientSpawnLimit(int limit);
/**
* Play a Sound at the provided Location in the World
*
* This function will fail silently if Location or Sound are null.
*
* @param location The location to play the sound
* @param sound The sound to play
* @param volume The volume of the sound
* @param pitch The pitch of the sound
*/
void playSound(Location location, Sound sound, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
*
* This function will fail silently if Location or Sound are null. No
* sound will be heard by the players if their clients do not have the
* respective sound for the value passed.
*
* @param location the location to play the sound
* @param sound the internal sound name to play
* @param volume the volume of the sound
* @param pitch the pitch of the sound
*/
void playSound(Location location, String sound, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
*
* This function will fail silently if Location or Sound are null.
*
* @param location The location to play the sound
* @param sound The sound to play
* @param category the category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
*/
void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
*
* This function will fail silently if Location or Sound are null. No sound
* will be heard by the players if their clients do not have the respective
* sound for the value passed.
*
* @param location the location to play the sound
* @param sound the internal sound name to play
* @param category the category of the sound
* @param volume the volume of the sound
* @param pitch the pitch of the sound
*/
void playSound(Location location, String sound, SoundCategory category, float volume, float pitch);
/**
* Get an array containing the names of all the {@link GameRule}s.
*
* @return An array of {@link GameRule} names.
*/
public String[] getGameRules();
/**
* Gets the current state of the specified rule
*
* Will return null if rule passed is null
*
* @param rule Rule to look up value of
* @return String value of rule
* @deprecated use {@link #getGameRuleValue(GameRule)} instead
*/
@Deprecated
public String getGameRuleValue(String rule);
/**
* Set the specified gamerule to specified value.
*
* The rule may attempt to validate the value passed, will return true if
* value was set.
*
* If rule is null, the function will return false.
*
* @param rule Rule to set
* @param value Value to set rule to
* @return True if rule was set
* @deprecated use {@link #setGameRule(GameRule, Object)} instead.
*/
@Deprecated
public boolean setGameRuleValue(String rule, String value);
/**
* Checks if string is a valid game rule
*
* @param rule Rule to check
* @return True if rule exists
*/
public boolean isGameRule(String rule);
/**
* Get the current value for a given {@link GameRule}.
*
* @param rule the GameRule to check
* @param
* The {@code radius} is not a rigid square radius. Each structure may alter
* how many chunks to check for each iteration. Do not assume that only a
* radius x radius chunk area will be checked. For example,
* {@link StructureType#WOODLAND_MANSION} can potentially check up to 20,000
* blocks away (or more) regardless of the radius used.
*
* This will not load or generate chunks. This can also lead to
* instances where the server can hang if you are only looking for
* unexplored structures. This is because it will keep looking further and
* further out in order to find the structure.
*
* @param origin where to start looking for a structure
* @param structureType the type of structure to find
* @param radius the radius, in chunks, around which to search
* @param findUnexplored true to only find unexplored structures
* @return the closest {@link Location}, or null if no structure of the
* specified type exists.
*/
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored);
/**
* Represents various map environment types that a world may be
*/
public enum Environment {
/**
* Represents the "normal"/"surface world" map
*/
NORMAL(0),
/**
* Represents a nether based map ("hell")
*/
NETHER(-1),
/**
* Represents the "end" map
*/
THE_END(1);
private final int id;
private static final Mapnull
to consider all entities
* @return the collection of entities near location. This will always be a
* non-null collection.
*/
public Collectionnull
to consider all entities
* @return the collection of entities within the bounding box, will always
* be a non-null collection
*/
public Collectionnull
if there
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance);
/**
* Performs a ray trace that checks for entity collisions.
* null
if there
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize);
/**
* Performs a ray trace that checks for entity collisions.
* null
to consider all entities
* @return the closest ray trace hit result, or null
if there
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicatenull
to consider all entities
* @return the closest ray trace hit result, or null
if there
* is no hit
*/
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicatenull
if there is no hit
* @see #rayTraceBlocks(Location, Vector, double, FluidCollisionMode, boolean)
*/
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance);
/**
* Performs a ray trace that checks for block collisions using the blocks'
* precise collision shapes.
* null
if there is no hit
* @see #rayTraceBlocks(Location, Vector, double, FluidCollisionMode, boolean)
*/
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode);
/**
* Performs a ray trace that checks for block collisions using the blocks'
* precise collision shapes.
* null
if there is no hit
*/
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks);
/**
* Performs a ray trace that checks for both block and entity collisions.
* raySize
parameter is only taken into account for entity
* collision checks.
* null
to consider all entities
* @return the closest ray trace hit result with either a block or an
* entity, or null
if there is no hit
*/
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate
* The location provided must be equal to this world.
*
* @param location The {@link Location} to set the spawn for this world at.
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(Location location);
/**
* Sets the spawn location of the world
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(int x, int y, int z);
/**
* Gets the relative in-game time of this world.
*
* Note that when the function is run, the entity will not be actually in
* the world. Any operation involving such as teleporting the entity is undefined
* until after this function returns.
*
* @param location the {@link Location} to spawn the entity at
* @param clazz the class of the {@link Entity} to spawn
* @param function the function to be run before the entity is spawned.
* @param
*
*
*
*
*
*
*
*