001 package org.bukkit;
002
003 import org.bukkit.block.Block;
004 import org.bukkit.block.BlockState;
005 import org.bukkit.entity.Entity;
006
007 /**
008 * Represents a chunk of blocks
009 */
010 public interface Chunk {
011
012 /**
013 * Gets the X-coordinate of this chunk
014 *
015 * @return X-coordinate
016 */
017 int getX();
018
019 /**
020 * Gets the Z-coordinate of this chunk
021 *
022 * @return Z-coordinate
023 */
024 int getZ();
025
026 /**
027 * Gets the world containing this chunk
028 *
029 * @return Parent World
030 */
031 World getWorld();
032
033 /**
034 * Gets a block from this chunk
035 *
036 * @param x 0-15
037 * @param y 0-127
038 * @param z 0-15
039 * @return the Block
040 */
041 Block getBlock(int x, int y, int z);
042
043 /**
044 * Capture thread-safe read-only snapshot of chunk data
045 *
046 * @return ChunkSnapshot
047 */
048 ChunkSnapshot getChunkSnapshot();
049
050 /**
051 * Capture thread-safe read-only snapshot of chunk data
052 *
053 * @param includeMaxblocky - if true, snapshot includes per-coordinate
054 * maximum Y values
055 * @param includeBiome - if true, snapshot includes per-coordinate biome
056 * type
057 * @param includeBiomeTempRain - if true, snapshot includes per-coordinate
058 * raw biome temperature and rainfall
059 * @return ChunkSnapshot
060 */
061 ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain);
062
063 /**
064 * Get a list of all entities in the chunk.
065 *
066 * @return The entities.
067 */
068 Entity[] getEntities();
069
070 /**
071 * Get a list of all tile entities in the chunk.
072 *
073 * @return The tile entities.
074 */
075 BlockState[] getTileEntities();
076
077 /**
078 * Checks if the chunk is loaded.
079 *
080 * @return True if it is loaded.
081 */
082 boolean isLoaded();
083
084 /**
085 * Loads the chunk.
086 *
087 * @param generate Whether or not to generate a chunk if it doesn't
088 * already exist
089 * @return true if the chunk has loaded successfully, otherwise false
090 */
091 boolean load(boolean generate);
092
093 /**
094 * Loads the chunk.
095 *
096 * @return true if the chunk has loaded successfully, otherwise false
097 */
098 boolean load();
099
100 /**
101 * Unloads and optionally saves the Chunk
102 *
103 * @param save Controls whether the chunk is saved
104 * @param safe Controls whether to unload the chunk when players are
105 * nearby
106 * @return true if the chunk has unloaded successfully, otherwise false
107 */
108 boolean unload(boolean save, boolean safe);
109
110 /**
111 * Unloads and optionally saves the Chunk
112 *
113 * @param save Controls whether the chunk is saved
114 * @return true if the chunk has unloaded successfully, otherwise false
115 */
116 boolean unload(boolean save);
117
118 /**
119 * Unloads and optionally saves the Chunk
120 *
121 * @return true if the chunk has unloaded successfully, otherwise false
122 */
123 boolean unload();
124 }