Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Block.java
1 package org.bukkit.block;
2 
3 import java.util.Collection;
4 
5 import org.bukkit.Chunk;
6 import org.bukkit.Material;
7 import org.bukkit.World;
8 import org.bukkit.Location;
11 
12 /**
13  * Represents a block. This is a live object, and only one Block may exist for
14  * any given location in a world. The state of the block may change
15  * concurrently to your own handling of it; use block.getState() to get a
16  * snapshot state of a block which will not be modified.
17  */
18 public interface Block extends Metadatable {
19 
20  /**
21  * Gets the metadata for this block
22  *
23  * @return block specific metadata
24  * @deprecated Magic value
25  */
26  @Deprecated
27  byte getData();
28 
29  /**
30  * Gets the block at the given offsets
31  *
32  * @param modX X-coordinate offset
33  * @param modY Y-coordinate offset
34  * @param modZ Z-coordinate offset
35  * @return Block at the given offsets
36  */
37  Block getRelative(int modX, int modY, int modZ);
38 
39  /**
40  * Gets the block at the given face
41  * <p>
42  * This method is equal to getRelative(face, 1)
43  *
44  * @param face Face of this block to return
45  * @return Block at the given face
46  * @see #getRelative(BlockFace, int)
47  */
49 
50  /**
51  * Gets the block at the given distance of the given face
52  * <p>
53  * For example, the following method places water at 100,102,100; two
54  * blocks above 100,100,100.
55  *
56  * <pre>
57  * Block block = world.getBlockAt(100, 100, 100);
58  * Block shower = block.getRelative(BlockFace.UP, 2);
59  * shower.setType(Material.WATER);
60  * </pre>
61  *
62  * @param face Face of this block to return
63  * @param distance Distance to get the block at
64  * @return Block at the given face
65  */
66  Block getRelative(BlockFace face, int distance);
67 
68  /**
69  * Gets the type of this block
70  *
71  * @return block type
72  */
73  Material getType();
74 
75  /**
76  * Gets the type-id of this block
77  *
78  * @return block type-id
79  * @deprecated Magic value
80  */
81  @Deprecated
82  int getTypeId();
83 
84  /**
85  * Gets the light level between 0-15
86  *
87  * @return light level
88  */
89  byte getLightLevel();
90 
91  /**
92  * Get the amount of light at this block from the sky.
93  * <p>
94  * Any light given from other sources (such as blocks like torches) will
95  * be ignored.
96  *
97  * @return Sky light level
98  */
99  byte getLightFromSky();
100 
101  /**
102  * Get the amount of light at this block from nearby blocks.
103  * <p>
104  * Any light given from other sources (such as the sun) will be ignored.
105  *
106  * @return Block light level
107  */
108  byte getLightFromBlocks();
109 
110  /**
111  * Gets the world which contains this Block
112  *
113  * @return World containing this block
114  */
115  World getWorld();
116 
117  /**
118  * Gets the x-coordinate of this block
119  *
120  * @return x-coordinate
121  */
122  int getX();
123 
124  /**
125  * Gets the y-coordinate of this block
126  *
127  * @return y-coordinate
128  */
129  int getY();
130 
131  /**
132  * Gets the z-coordinate of this block
133  *
134  * @return z-coordinate
135  */
136  int getZ();
137 
138  /**
139  * Gets the Location of the block
140  *
141  * @return Location of block
142  */
144 
145  /**
146  * Stores the location of the block in the provided Location object.
147  * <p>
148  * If the provided Location is null this method does nothing and returns
149  * null.
150  *
151  * @return The Location object provided or null
152  */
154 
155  /**
156  * Gets the chunk which contains this block
157  *
158  * @return Containing Chunk
159  */
160  Chunk getChunk();
161 
162  /**
163  * Sets the metadata for this block
164  *
165  * @param data New block specific metadata
166  * @deprecated Magic value
167  */
168  @Deprecated
169  void setData(byte data);
170 
171  /**
172  * Sets the metadata for this block
173  *
174  * @param data New block specific metadata
175  * @param applyPhysics False to cancel physics from the changed block.
176  * @deprecated Magic value
177  */
178  @Deprecated
179  void setData(byte data, boolean applyPhysics);
180 
181  /**
182  * Sets the type of this block
183  *
184  * @param type Material to change this block to
185  */
186  void setType(Material type);
187 
188  /**
189  * Sets the type-id of this block
190  *
191  * @param type Type-Id to change this block to
192  * @return whether the block was changed
193  * @deprecated Magic value
194  */
195  @Deprecated
196  boolean setTypeId(int type);
197 
198  /**
199  * Sets the type-id of this block
200  *
201  * @param type Type-Id to change this block to
202  * @param applyPhysics False to cancel physics on the changed block.
203  * @return whether the block was changed
204  * @deprecated Magic value
205  */
206  @Deprecated
207  boolean setTypeId(int type, boolean applyPhysics);
208 
209  /**
210  * Sets the type-id of this block
211  *
212  * @param type Type-Id to change this block to
213  * @param data The data value to change this block to
214  * @param applyPhysics False to cancel physics on the changed block
215  * @return whether the block was changed
216  * @deprecated Magic value
217  */
218  @Deprecated
219  boolean setTypeIdAndData(int type, byte data, boolean applyPhysics);
220 
221  /**
222  * Gets the face relation of this block compared to the given block
223  * <p>
224  * For example:
225  * <pre>
226  * Block current = world.getBlockAt(100, 100, 100);
227  * Block target = world.getBlockAt(100, 101, 100);
228  *
229  * current.getFace(target) == BlockFace.Up;
230  * </pre>
231  * <br />
232  * If the given block is not connected to this block, null may be returned
233  *
234  * @param block Block to compare against this block
235  * @return BlockFace of this block which has the requested block, or null
236  */
237  BlockFace getFace(Block block);
238 
239  /**
240  * Captures the current state of this block. You may then cast that state
241  * into any accepted type, such as Furnace or Sign.
242  * <p>
243  * The returned object will never be updated, and you are not guaranteed
244  * that (for example) a sign is still a sign after you capture its state.
245  *
246  * @return BlockState with the current state of this block.
247  */
249 
250  /**
251  * Returns the biome that this block resides in
252  *
253  * @return Biome type containing this block
254  */
255  Biome getBiome();
256 
257  /**
258  * Sets the biome that this block resides in
259  *
260  * @param bio new Biome type for this block
261  */
262  void setBiome(Biome bio);
263 
264  /**
265  * Returns true if the block is being powered by Redstone.
266  *
267  * @return True if the block is powered.
268  */
269  boolean isBlockPowered();
270 
271  /**
272  * Returns true if the block is being indirectly powered by Redstone.
273  *
274  * @return True if the block is indirectly powered.
275  */
276  boolean isBlockIndirectlyPowered();
277 
278  /**
279  * Returns true if the block face is being powered by Redstone.
280  *
281  * @param face The block face
282  * @return True if the block face is powered.
283  */
284  boolean isBlockFacePowered(BlockFace face);
285 
286  /**
287  * Returns true if the block face is being indirectly powered by Redstone.
288  *
289  * @param face The block face
290  * @return True if the block face is indirectly powered.
291  */
293 
294  /**
295  * Returns the redstone power being provided to this block face
296  *
297  * @param face the face of the block to query or BlockFace.SELF for the
298  * block itself
299  * @return The power level.
300  */
301  int getBlockPower(BlockFace face);
302 
303  /**
304  * Returns the redstone power being provided to this block
305  *
306  * @return The power level.
307  */
308  int getBlockPower();
309 
310  /**
311  * Checks if this block is empty.
312  * <p>
313  * A block is considered empty when {@link #getType()} returns {@link
314  * Material#AIR}.
315  *
316  * @return true if this block is empty
317  */
318  boolean isEmpty();
319 
320  /**
321  * Checks if this block is liquid.
322  * <p>
323  * A block is considered liquid when {@link #getType()} returns {@link
324  * Material#WATER}, {@link Material#STATIONARY_WATER}, {@link
325  * Material#LAVA} or {@link Material#STATIONARY_LAVA}.
326  *
327  * @return true if this block is liquid
328  */
329  boolean isLiquid();
330 
331  /**
332  * Gets the temperature of the biome of this block
333  *
334  * @return Temperature of this block
335  */
336  double getTemperature();
337 
338  /**
339  * Gets the humidity of the biome of this block
340  *
341  * @return Humidity of this block
342  */
343  double getHumidity();
344 
345  /**
346  * Returns the reaction of the block when moved by a piston
347  *
348  * @return reaction
349  */
351 
352  /**
353  * Breaks the block and spawns items as if a player had digged it
354  *
355  * @return true if the block was destroyed
356  */
357  boolean breakNaturally();
358 
359  /**
360  * Breaks the block and spawns items as if a player had digged it with a
361  * specific tool
362  *
363  * @param tool The tool or item in hand used for digging
364  * @return true if the block was destroyed
365  */
366  boolean breakNaturally(ItemStack tool);
367 
368  /**
369  * Returns a list of items which would drop by destroying this block
370  *
371  * @return a list of dropped items for this type of block
372  */
373  Collection<ItemStack> getDrops();
374 
375  /**
376  * Returns a list of items which would drop by destroying this block with
377  * a specific tool
378  *
379  * @param tool The tool or item in hand used for digging
380  * @return a list of dropped items for this type of block
381  */
382  Collection<ItemStack> getDrops(ItemStack tool);
383 
384 }
boolean isBlockFaceIndirectlyPowered(BlockFace face)
BlockFace getFace(Block block)
void setBiome(Biome bio)
Block getRelative(int modX, int modY, int modZ)
Collection< ItemStack > getDrops()
boolean setTypeIdAndData(int type, byte data, boolean applyPhysics)
boolean isBlockIndirectlyPowered()
void setData(byte data)
boolean setTypeId(int type)
void setType(Material type)
boolean isBlockFacePowered(BlockFace face)
BlockState getState()
PistonMoveReaction getPistonMoveReaction()