Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 282 lines 6.9 kB view raw
1package org.bukkit.block; 2 3import org.bukkit.Chunk; 4import org.bukkit.Location; 5import org.bukkit.Material; 6import org.bukkit.World; 7 8/** 9 * Represents a block. This is a live object, and only one Block may exist for 10 * any given location in a world. The state of the block may change concurrently 11 * to your own handling of it; use block.getState() to get a snapshot state of a 12 * block which will not be modified. 13 */ 14public interface Block { 15 16 /** 17 * Gets the metadata for this block 18 * 19 * @return block specific metadata 20 */ 21 byte getData(); 22 23 /** 24 * @deprecated use {@link #getRelative(BlockFace face)} 25 */ 26 @Deprecated 27 Block getFace(BlockFace face); 28 29 /** 30 * @deprecated use {@link #getRelative(BlockFace face, int distance)} 31 */ 32 @Deprecated 33 Block getFace(BlockFace face, int distance); 34 35 /** 36 * Gets the block at the given offsets 37 * 38 * @param modX X-coordinate offset 39 * @param modY Y-coordinate offset 40 * @param modZ Z-coordinate offset 41 * @return Block at the given offsets 42 */ 43 Block getRelative(int modX, int modY, int modZ); 44 45 /** 46 * Gets the block at the given face<br /> 47 * <br /> 48 * This method is equal to getRelative(face, 1) 49 * 50 * @param face Face of this block to return 51 * @return Block at the given face 52 * @see Block.getRelative(BlockFace face, int distance); 53 */ 54 Block getRelative(BlockFace face); 55 56 /** 57 * Gets the block at the given distance of the given face<br /> 58 * <br /> 59 * For example, the following method places water at 100,102,100; two blocks 60 * above 100,100,100. 61 * <pre> 62 * Block block = world.getBlockAt(100,100,100); 63 * Block shower = block.getFace(BlockFace.UP, 2); 64 * shower.setType(Material.WATER); 65 * </pre> 66 * 67 * @param face Face of this block to return 68 * @param distance Distance to get the block at 69 * @return Block at the given face 70 */ 71 Block getRelative(BlockFace face, int distance); 72 73 /** 74 * Gets the type of this block 75 * 76 * @return block type 77 */ 78 Material getType(); 79 80 /** 81 * Gets the type-id of this block 82 * 83 * @return block type-id 84 */ 85 int getTypeId(); 86 87 /** 88 * Gets the light level between 0-15 89 * 90 * @return light level 91 */ 92 byte getLightLevel(); 93 94 /** 95 * Gets the world which contains this Block 96 * 97 * @return World containing this block 98 */ 99 World getWorld(); 100 101 /** 102 * Gets the x-coordinate of this block 103 * 104 * @return x-coordinate 105 */ 106 int getX(); 107 108 /** 109 * Gets the y-coordinate of this block 110 * 111 * @return y-coordinate 112 */ 113 int getY(); 114 115 /** 116 * Gets the z-coordinate of this block 117 * 118 * @return z-coordinate 119 */ 120 int getZ(); 121 122 /** 123 * Gets the Location of the block 124 * 125 * @return Location of block 126 */ 127 128 Location getLocation(); 129 130 /** 131 * Gets the chunk which contains this block 132 * 133 * @return Containing Chunk 134 */ 135 Chunk getChunk(); 136 137 /** 138 * Sets the metadata for this block 139 * 140 * @param data New block specific metadata 141 */ 142 void setData(byte data); 143 144 void setData(byte data, boolean applyPhyiscs); 145 146 /** 147 * Sets the type of this block 148 * 149 * @param type Material to change this block to 150 */ 151 void setType(Material type); 152 153 /** 154 * Sets the type-id of this block 155 * 156 * @param type Type-Id to change this block to 157 * @return whether the block was changed 158 */ 159 boolean setTypeId(int type); 160 161 boolean setTypeId(int type, boolean applyPhysics); 162 163 boolean setTypeIdAndData(int type, byte data, boolean applyPhyiscs); 164 165 /** 166 * Gets the face relation of this block compared to the given block<br /> 167 * <br /> 168 * For example: 169 * <pre> 170 * Block current = world.getBlockAt(100, 100, 100); 171 * Block target = world.getBlockAt(100, 101, 100); 172 * 173 * current.getFace(target) == BlockFace.Up; 174 * </pre> 175 * <br /> 176 * If the given block is not connected to this block, null may be returned 177 * 178 * @param block Block to compare against this block 179 * @return BlockFace of this block which has the requested block, or null 180 */ 181 BlockFace getFace(Block block); 182 183 /** 184 * Captures the current state of this block. You may then cast that state 185 * into any accepted type, such as Furnace or Sign. 186 * <p> 187 * The returned object will never be updated, and you are not guaranteed that 188 * (for example) a sign is still a sign after you capture its state. 189 * 190 * @return BlockState with the current state of this block. 191 */ 192 BlockState getState(); 193 194 /** 195 * Returns the biome that this block resides in 196 * 197 * @return Biome type containing this block 198 */ 199 Biome getBiome(); 200 201 /** 202 * Returns true if the block is being powered by Redstone. 203 * 204 * @return 205 */ 206 boolean isBlockPowered(); 207 208 /** 209 * Returns true if the block is being indirectly powered by Redstone. 210 * 211 * @return 212 */ 213 boolean isBlockIndirectlyPowered(); 214 215 /** 216 * Returns true if the block face is being powered by Redstone. 217 * 218 * @return 219 */ 220 boolean isBlockFacePowered(BlockFace face); 221 222 /** 223 * Returns true if the block face is being indirectly powered by Redstone. 224 * 225 * @return 226 */ 227 boolean isBlockFaceIndirectlyPowered(BlockFace face); 228 229 /** 230 * Returns the redstone power being provided to this block face 231 * 232 * @param face the face of the block to query or BlockFace.SELF for the block itself 233 * @return 234 */ 235 int getBlockPower(BlockFace face); 236 237 /** 238 * Returns the redstone power being provided to this block 239 * 240 * @return 241 */ 242 int getBlockPower(); 243 244 /** 245 * Checks if this block is empty. 246 * <p> 247 * A block is considered empty when {@link #getType()} returns {@link Material#AIR}. 248 * 249 * @return true if this block is empty 250 */ 251 boolean isEmpty(); 252 253 /** 254 * Checks if this block is liquid. 255 * <p> 256 * A block is considered liquid when {@link #getType()} returns {@link Material#WATER}, {@link Material#STATIONARY_WATER}, {@link Material#LAVA} or {@link Material#STATIONARY_LAVA}. 257 * 258 * @return true if this block is liquid 259 */ 260 boolean isLiquid(); 261 262 /** 263 * Gets the temperature of the biome of this block 264 * 265 * @return Temperature of this block 266 */ 267 double getTemperature(); 268 269 /** 270 * Gets the humidity of the biome of this block 271 * 272 * @return Humidity of this block 273 */ 274 double getHumidity(); 275 276 /** 277 * Returns the reaction of the block when moved by a piston 278 * 279 * @return reaction 280 */ 281 PistonMoveReaction getPistonMoveReaction(); 282}